Merge lp:~smspillaz/unity/unity.less-paint-insanity into lp:unity

Proposed by Sam Spilsbury on 2012-06-07
Status: Superseded
Proposed branch: lp:~smspillaz/unity/unity.less-paint-insanity
Merge into: lp:unity
Diff against target: 158 lines (+31/-72)
2 files modified
plugins/unityshell/src/unityshell.cpp (+31/-68)
plugins/unityshell/src/unityshell.h (+0/-4)
To merge this branch: bzr merge lp:~smspillaz/unity/unity.less-paint-insanity
Reviewer Review Type Date Requested Status
Daniel van Vugt 2012-06-07 Needs Fixing on 2012-06-11
Marco Trevisan (Treviño) 2012-06-07 Pending
Jason Smith 2012-06-07 Pending
Review via email: mp+109079@code.launchpad.net

This proposal supersedes a proposal from 2012-06-07.

This proposal has been superseded by a proposal from 2012-06-12.

Description of the change

Removes the whole scanning of the list thing in getWindowPaintList and the whole "trying to figure out where the window was because we don't actually know" in glDraw by scanning the paint list again and again.

There's a much better way of doing this - just hook glPaint, skip the wrap chain to core (eg every single plugin skipped) and tell core not to do anything with the window.

I have no idea why there is a bunch of logic about whether or not to paint the panel in glDraw (that was moved to glPaint). Someone enlighten me?

To post a comment you must log in.
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Bump?

I'd like to see this go in, because it should reduce lots of list copying within unity and also lots of unecessary list traversal, which should represent a nice speed boost. In addition, its far simpler in its implementation and far less bug prone.

I'm sure testing is probably an issue. I'll have another quick look at the code and see if I can think of a way to get it under test.

Daniel van Vugt (vanvugt) wrote :

Works for me. Though there are some indentation/tab mismatches around line 107. Looks like your tabs are not 8 characters wide like they should be?

review: Needs Fixing
2373. By Sam Spilsbury on 2012-06-12

Fix indentation

2374. By Sam Spilsbury on 2012-06-12

Merge lp:unity

2375. By Sam Spilsbury on 2012-06-12

Merge lp:~vanvugt/unity/fix-1010348

2376. By Sam Spilsbury on 2012-06-14

Make the code slightly more sane, use some interfaces to demonstrate
what is happening and break dependencies a little

2377. By Sam Spilsbury on 2012-06-14

Ensure that we always paint on top of the topmost nux window

2378. By Sam Spilsbury on 2012-06-14

Also return false if someone tries to paint us with PAINT_WINDOW_NO_CORE_INSTANCE_MASK

2379. By Sam Spilsbury on 2012-06-14

Implement top window detection in terms of paint requestor

2380. By Sam Spilsbury on 2012-06-14

Merge lp:unity

2381. By Sam Spilsbury on 2012-06-14

Move paint requestor enforcement to UnityPaintDispatch

2382. By Sam Spilsbury on 2012-06-14

Move paint mask prohibition into UnityPaintDispatch through strategy

2383. By Sam Spilsbury on 2012-06-14

Ensure that the backing fbo is painted too

2384. By Sam Spilsbury on 2012-06-14

Work correctly with USE_MODERN_COMPIZ_GL too

2385. By Sam Spilsbury on 2012-06-14

Move UnityPaintDispatch to separate file

2386. By Sam Spilsbury on 2012-06-14

Use UnityPaintDispatch by composition

2387. By Sam Spilsbury on 2012-06-14

Rename variable

2388. By Sam Spilsbury on 2012-06-14

UnityPaint* -> ShellPaint*

2389. By Sam Spilsbury on 2012-06-14

mv UnityPaintSchedule -> ShellPaintSchedule

2390. By Sam Spilsbury on 2012-06-14

Initial tests for ShellPaintSchedule

2391. By Sam Spilsbury on 2012-06-14

Basic paint tests

2392. By Sam Spilsbury on 2012-06-14

Basic prohibition test

2393. By Sam Spilsbury on 2012-06-14

Inverse prohibition test case

2394. By Sam Spilsbury on 2012-06-14

Basic top requestor tests

2395. By Sam Spilsbury on 2012-06-14

Test suprvening requestor behaviour

2396. By Sam Spilsbury on 2012-06-14

Tests for RepaintPending value

2397. By Sam Spilsbury on 2012-06-14

Test prohibited paint requestor retreival

2398. By Sam Spilsbury on 2012-06-17

Merge lp:unity

2399. By Sam Spilsbury on 2012-06-19

Merge lp:unity

2400. By Sam Spilsbury on 2012-06-19

Change namespace to unity::compiz

2401. By Sam Spilsbury on 2012-06-19

unsigned int -> enum && move namespace compiz {} to namespace unity::compiz

2402. By Sam Spilsbury on 2012-06-19

Nuke FBOBindingQueryInterface

2403. By Sam Spilsbury on 2012-06-19

Basic documentation, not really a substitute for better code ...

2404. By Sam Spilsbury on 2012-06-25

Merge lp:unity

2405. By Sam Spilsbury on 2012-06-26

Remove unused method and rename methods to make more sense

Unmerged revisions

2405. By Sam Spilsbury on 2012-06-26

Remove unused method and rename methods to make more sense

2404. By Sam Spilsbury on 2012-06-25

Merge lp:unity

2403. By Sam Spilsbury on 2012-06-19

Basic documentation, not really a substitute for better code ...

2402. By Sam Spilsbury on 2012-06-19

Nuke FBOBindingQueryInterface

2401. By Sam Spilsbury on 2012-06-19

unsigned int -> enum && move namespace compiz {} to namespace unity::compiz

2400. By Sam Spilsbury on 2012-06-19

Change namespace to unity::compiz

2399. By Sam Spilsbury on 2012-06-19

Merge lp:unity

2398. By Sam Spilsbury on 2012-06-17

Merge lp:unity

2397. By Sam Spilsbury on 2012-06-14

Test prohibited paint requestor retreival

2396. By Sam Spilsbury on 2012-06-14

Tests for RepaintPending value

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2012-05-31 09:28:02 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2012-06-07 07:22:25 +0000
4@@ -2127,31 +2127,6 @@
5 return "Unity";
6 }
7
8-bool isNuxWindow (CompWindow* value)
9-{
10- std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList();
11- auto id = value->id();
12-
13- // iterate loop by hand rather than use std::find as this is considerably faster
14- // we care about performance here becuase of the high frequency in which this function is
15- // called (nearly every frame)
16- unsigned int size = xwns.size();
17- for (unsigned int i = 0; i < size; ++i)
18- {
19- if (xwns[i] == id)
20- return true;
21- }
22- return false;
23-}
24-
25-const CompWindowList& UnityScreen::getWindowPaintList()
26-{
27- CompWindowList& pl = _withRemovedNuxWindows = cScreen->getWindowPaintList();
28- pl.remove_if(isNuxWindow);
29-
30- return pl;
31-}
32-
33 void UnityScreen::RaiseInputWindows()
34 {
35 std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList();
36@@ -2164,13 +2139,11 @@
37 }
38 }
39
40-/* detect occlusions
41- *
42- * core passes down the PAINT_WINDOW_OCCLUSION_DETECTION
43- * mask when it is doing occlusion detection, so use that
44- * order to fill our occlusion buffer which we'll flip
45- * to nux later
46- */
47+/* we want to paint underneath other windows here,
48+ * so we need to find if this window is actually
49+ * stacked on top of one of the nux input windows
50+ * and if so paint nux and stop us from painting
51+ * other windows or on top of the whole screen */
52 bool UnityWindow::glPaint(const GLWindowPaintAttrib& attrib,
53 const GLMatrix& matrix,
54 const CompRegion& region,
55@@ -2199,25 +2172,6 @@
56 }
57 }
58
59- return gWindow->glPaint(wAttrib, matrix, region, mask);
60-}
61-
62-/* handle window painting in an opengl context
63- *
64- * we want to paint underneath other windows here,
65- * so we need to find if this window is actually
66- * stacked on top of one of the nux input windows
67- * and if so paint nux and stop us from painting
68- * other windows or on top of the whole screen */
69-bool UnityWindow::glDraw(const GLMatrix& matrix,
70-#ifndef USE_MODERN_COMPIZ_GL
71- GLFragment::Attrib& attrib,
72-#else
73- const GLWindowPaintAttrib& attrib,
74-#endif
75- const CompRegion& region,
76- unsigned int mask)
77-{
78 if (uScreen->doShellRepaint && !uScreen->paint_panel_ && window->type() == CompWindowTypeNormalMask)
79 {
80 guint32 id = window->id();
81@@ -2234,30 +2188,39 @@
82 }
83 }
84
85- if (uScreen->doShellRepaint && !uScreen->forcePaintOnTop ())
86+ std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList();
87+ for (unsigned int i = 0; i < xwns.size(); i++)
88 {
89- std::vector<Window> const& xwns = nux::XInputWindow::NativeHandleList();
90- unsigned int size = xwns.size();
91-
92- for (CompWindow* w = window; w && uScreen->doShellRepaint; w = w->prev)
93+ if (xwns[i] == window->id ())
94 {
95- auto id = w->id();
96-
97- for (unsigned int i = 0; i < size; ++i)
98- {
99- if (xwns[i] == id)
100- {
101-#ifdef USE_MODERN_COMPIZ_GL
102- uScreen->paintDisplay();
103+ if (uScreen->doShellRepaint &&
104+ !uScreen->forcePaintOnTop () &&
105+ !(mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK))
106+#ifndef USE_MODERN_COMPIZ_GL
107+ uScreen->paintDisplay (region, matrix, mask);
108 #else
109- uScreen->paintDisplay(region, matrix, mask);
110+ uScreen->paintDisplay ();
111 #endif
112- break;
113- }
114- }
115+ /* Skip to end and don't paint */
116+ gWindow->glPaintSetCurrentIndex (std::numeric_limits<unsigned int>::max ());
117+ return gWindow->glPaint (attrib, matrix, emptyRegion, mask | PAINT_WINDOW_NO_CORE_INSTANCE_MASK);
118 }
119 }
120
121+ return gWindow->glPaint(wAttrib, matrix, region, mask);
122+}
123+
124+/* handle window painting in an opengl context
125+ */
126+bool UnityWindow::glDraw(const GLMatrix& matrix,
127+#ifndef USE_MODERN_COMPIZ_GL
128+ GLFragment::Attrib& attrib,
129+#else
130+ const GLWindowPaintAttrib& attrib,
131+#endif
132+ const CompRegion& region,
133+ unsigned int mask)
134+{
135 if (window->type() == CompWindowTypeDesktopMask)
136 uScreen->setPanelShadowMatrix(matrix);
137
138
139=== modified file 'plugins/unityshell/src/unityshell.h'
140--- plugins/unityshell/src/unityshell.h 2012-05-28 03:19:35 +0000
141+++ plugins/unityshell/src/unityshell.h 2012-06-07 07:22:25 +0000
142@@ -132,9 +132,6 @@
143 CompOutput*,
144 unsigned int);
145
146- /* Pop our InputOutput windows from the paint list */
147- const CompWindowList& getWindowPaintList();
148-
149 /* handle X11 events */
150 void handleEvent(XEvent*);
151
152@@ -279,7 +276,6 @@
153 bool damaged;
154 bool _key_nav_mode_requested;
155 CompOutput* _last_output;
156- CompWindowList _withRemovedNuxWindows;
157
158 nux::Property<nux::Geometry> primary_monitor_;
159