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

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~smspillaz/unity/untiy.less-paint-insanity
Merge into: lp:unity
Diff against target: 158 lines (+31/-75)
2 files modified
plugins/unityshell/src/unityshell.cpp (+31/-71)
plugins/unityshell/src/unityshell.h (+0/-4)
To merge this branch: bzr merge lp:~smspillaz/unity/untiy.less-paint-insanity
Reviewer Review Type Date Requested Status
Unity Team Pending
Marco Trevisan (Treviño) Pending
Jason Smith Pending
Review via email: mp+109056@code.launchpad.net

This proposal supersedes a proposal from 2012-05-29.

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

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.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

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.

Unmerged revisions

2371. By Sam Spilsbury

Just use PAINT_WINDOW_NO_CORE_INSTANCE_MASK properly in glPaint
rather than futzing around with paint lists

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 00:52:22 +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,36 @@
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- {
94- auto id = w->id();
95-
96- for (unsigned int i = 0; i < size; ++i)
97+ if (xwns[i] == window->id ())
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+ uScreen->paintDisplay (region, matrix, mask);
107+
108+ /* Skip to end and don't paint */
109+ gWindow->glPaintSetCurrentIndex (std::numeric_limits<unsigned int>::max ());
110+ return gWindow->glPaint (attrib, matrix, emptyRegion, mask | PAINT_WINDOW_NO_CORE_INSTANCE_MASK);
111+ }
112+ }
113+
114+ return gWindow->glPaint(wAttrib, matrix, region, mask);
115+}
116+
117+/* handle window painting in an opengl context
118+ */
119+bool UnityWindow::glDraw(const GLMatrix& matrix,
120+#ifndef USE_MODERN_COMPIZ_GL
121+ GLFragment::Attrib& attrib,
122 #else
123- uScreen->paintDisplay(region, matrix, mask);
124+ const GLWindowPaintAttrib& attrib,
125 #endif
126- break;
127- }
128- }
129- }
130- }
131-
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 00:52:22 +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