Merge lp:~vanvugt/unity/regionalDamage into lp:unity
- regionalDamage
- Merge into trunk
Status: | Superseded | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp:~vanvugt/unity/regionalDamage | ||||||||||||||||||||||||||||
Merge into: | lp:unity | ||||||||||||||||||||||||||||
Diff against target: |
413 lines (+166/-35) 8 files modified
launcher/AbstractLauncherIcon.h (+1/-0) launcher/Launcher.cpp (+11/-0) launcher/Launcher.h (+4/-0) launcher/LauncherIcon.cpp (+3/-0) panel/PanelController.cpp (+15/-0) panel/PanelController.h (+1/-0) plugins/unityshell/src/unityshell.cpp (+125/-33) plugins/unityshell/src/unityshell.h (+6/-2) |
||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp:~vanvugt/unity/regionalDamage | ||||||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email: mp+109809@code.launchpad.net |
Commit message
Description of the change
*PROTOTYPE*
Stop Unity from redrawing on every frame (ie. when it doesn't need to). It has a severe performance impact on graphics performance (LP: #988079)
For me, this branch eliminates the 25-30% slowdown experienced when unity is running with a single monitor. With 2 monitors, this branch eliminates the 75%(!) slowdown experienced when unity is running. Extrapolate and hypothesize as you like.
This also fixes bug 967112 and bug 992516. Probably more...
Sam Spilsbury (smspillaz) wrote : | # |
Sam Spilsbury (smspillaz) wrote : | # |
FYI, this is going to have pretty giant conflict with:
https:/
Since the "should we repaint" logic was moved into a separate file.
You should be able to get away with:
12 + /*
13 + * TODO: Figure out if we can ask compiz when:
14 + * output-
15 + * and if true, then force doShellRepaint=
16 + */
bool doShellRepaint = wt->GetDrawList
18 + BackgroundEffec
19 + switcher_
20 + launcher_
21 + (mask & (PAINT_
22 + PAINT_SCREEN_
23 + PAINT_SCREEN_
24 +
if (doShellRepaint)
ShellRepaintR
25 + /* Warning: ^ checking for PAINT_SCREEN_
26 + * to avoid flickering. However it will nullify our performance
27 + * optimizations for people who have enabled "Force full screen
28 + * redraws" in the Workarounds plugin.
29 + */
A small note - it would certainly be nice if we had a method to get a collection of all the nux base windows.
Daniel van Vugt (vanvugt) wrote : | # |
Rev 2405 is way out of date. Ignore it. Still in progress.
Daniel van Vugt (vanvugt) wrote : | # |
I will fix conflicts as they arise :)
Sam Spilsbury (smspillaz) wrote : | # |
Of course, just a heads up :)
Sam Spilsbury (smspillaz) wrote : | # |
Tip on detecting if the shell is hidden (I did this once myself).
It might make more sense to use core's built in occlusion detection to figure this out. I think in that case when you get a redraw on a nux window, region will be empty in glPaint. That's worth double checking. (Also worth noting is that this only works if you disable removing the nux windows from the paint list, which should hopefully be done in the future)
Daniel van Vugt (vanvugt) wrote : | # |
Well, the current method of detecting if the shell is occluded is working perfectly. It's also simple and fast. But there's still more testing to go and I'm open to any reasonable changes.
Andrea Azzarone (azzar1) wrote : | # |
Fix bug 992516 for me too.
Regression: when I try to expand/collapse a dash category Unity freezes (not a crash).
Sam Spilsbury (smspillaz) wrote : | # |
Sure, just using cores occlusion detection will be faster and less breakable. this will only work wehnwe arent removing nux windows from the paint list.
Andrea Azzarone (azzar1) wrote : | # |
> Fix bug 992516 for me too.
> Regression: when I try to expand/collapse a dash category Unity freezes (not a
> crash).
Nvm. The freeze no longer happens.
Sam Spilsbury (smspillaz) wrote : | # |
I've noticed that on multiple monitors there is definitely a feedback effect, where compizDamageNux causes something on the second screen to redraw, and then that redraw region is fed right back to us in glPaintOutput which causes that thing to be queued for redraw again.
I'll let you come to your own ideas on this, but one "solution" I've found (and I say "solution" because it has known problems which I think are fixable, more on that on a bit) is to use damageRegion to compute the dirty regions that need redrawing so that we can use the wrap handlers to avoid feedback. For example:
=== modified file 'plugins/
--- plugins/
+++ plugins/
@@ -1306,34 +1306,35 @@
{
bool ret;
+
+ bool requiring_repaint = false;
+
// A few cases where we want to force the shell to be painted
- if (forcePaintOnTop() ||
- PluginAdapter:
+ if ((GetProhibited
+ PluginAdapter:
(mask & (PAINT_
{
- compizDamageNux
- doShellRepaint = true;
+ requiring_repaint = true;
}
else if (shellIsHidden(
{
// Don't ever waste GPU and CPU rendering the shell in games/benchmarks!
- doShellRepaint = false;
+ requiring_repaint = false;
}
else
{
- compizDamageNux
- doShellRepaint = wt->GetDrawList
- BackgroundEffec
+ bool isDamaged = RegionIsNuxDamaged (CompRegion (*output));
+ requiring_repaint = isDamaged &&
+ (wt->GetDrawLis
+ BackgroundEffec
}
/* glPaintOutput is part of the opengl plugin, so we need the GLScreen base class. */
@@ -1419,6 +1416,19 @@
}
+bool UnityScreen:
+{
+ static CompRegion tmp = emptyRegion;
+
+ tmp &= emptyRegion;
+ tmp |= r;
+ tmp &= nux_damage_;
+
+ nux_damage_ -= tmp;
+
+ return !tmp.isEmpty ();
+}
+
^ Checks if a particular output region has damaged nux regions intersecting the output region that came from damageRegion
void UnityScreen:
{
std::list <ShowdesktopHan
@@ -1491,8 +1501,6 @@
/* Grab changed nux regions and add damage rects for them */
void UnityScreen:
{
- CompRegion nux_damage;
-
if (damaged)
return;
@@ -1503,7 +1511,7 @@
it != end; ++it)
{
nux::Geometry const& geo = *it;
- nux_damage += CompRegion(geo.x, geo.y, geo.width, geo.height);
+ nux_damage_ += CompRegion(geo.x, geo.y, geo.width, geo.height);
}
// launcher_
@@ -1518,22 +1526,22 @@
if (!tooltip.IsNull())
{
const nux::Geometry &g = tooltip-
- nux_damage += CompRegion(g.x, g.y, g.width, g.height)...
Sam Spilsbury (smspillaz) wrote : | # |
(These feedback problems make it good to think about testing too...)
Daniel van Vugt (vanvugt) wrote : | # |
I haven't even begun multi-monitor testing. Will do this week. Please wait...
Sam Spilsbury (smspillaz) wrote : | # |
On Mon, 18 Jun 2012, Daniel van Vugt wrote:
> I haven't even begun multi-monitor testing. Will do this week. Please wait...
No problem, I've just been playing around with the branch because I want
faster rendering :P
> --
> https:/
> Your team DX Unity Bugs is subscribed to branch lp:unity.
>
Sam Spilsbury (smspillaz) wrote : | # |
(Small update, moving wt->ClearDrawList () to donePaint instead of glPaintOutput fixes most of the annoyances to do with flicking. No nux patching needed)
Daniel van Vugt (vanvugt) wrote : | # |
Looks like this fix now depends on bug 1014610 being resolved for Nux :(
Preview Diff
1 | === modified file 'launcher/AbstractLauncherIcon.h' | |||
2 | --- launcher/AbstractLauncherIcon.h 2012-06-06 15:40:19 +0000 | |||
3 | +++ launcher/AbstractLauncherIcon.h 2012-06-19 09:18:19 +0000 | |||
4 | @@ -218,6 +218,7 @@ | |||
5 | 218 | 218 | ||
6 | 219 | sigc::signal<void, AbstractLauncherIcon::Ptr> needs_redraw; | 219 | sigc::signal<void, AbstractLauncherIcon::Ptr> needs_redraw; |
7 | 220 | sigc::signal<void, AbstractLauncherIcon::Ptr> remove; | 220 | sigc::signal<void, AbstractLauncherIcon::Ptr> remove; |
8 | 221 | sigc::signal<void, nux::ObjectPtr<nux::View>> tooltip_visible; | ||
9 | 221 | sigc::signal<void> visibility_changed; | 222 | sigc::signal<void> visibility_changed; |
10 | 222 | 223 | ||
11 | 223 | sigc::connection needs_redraw_connection; | 224 | sigc::connection needs_redraw_connection; |
12 | 224 | 225 | ||
13 | === modified file 'launcher/Launcher.cpp' | |||
14 | --- launcher/Launcher.cpp 2012-06-15 02:03:31 +0000 | |||
15 | +++ launcher/Launcher.cpp 2012-06-19 09:18:19 +0000 | |||
16 | @@ -1520,6 +1520,11 @@ | |||
17 | 1520 | } | 1520 | } |
18 | 1521 | } | 1521 | } |
19 | 1522 | 1522 | ||
20 | 1523 | nux::ObjectPtr<nux::View> Launcher::GetActiveTooltip() const | ||
21 | 1524 | { | ||
22 | 1525 | return _active_tooltip; | ||
23 | 1526 | } | ||
24 | 1527 | |||
25 | 1523 | void Launcher::SetActionState(LauncherActionState actionstate) | 1528 | void Launcher::SetActionState(LauncherActionState actionstate) |
26 | 1524 | { | 1529 | { |
27 | 1525 | if (_launcher_action_state == actionstate) | 1530 | if (_launcher_action_state == actionstate) |
28 | @@ -1681,6 +1686,7 @@ | |||
29 | 1681 | EnsureAnimation(); | 1686 | EnsureAnimation(); |
30 | 1682 | 1687 | ||
31 | 1683 | icon->needs_redraw.connect(sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw)); | 1688 | icon->needs_redraw.connect(sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw)); |
32 | 1689 | icon->tooltip_visible.connect(sigc::mem_fun(this, &Launcher::OnTooltipVisible)); | ||
33 | 1684 | } | 1690 | } |
34 | 1685 | 1691 | ||
35 | 1686 | void Launcher::OnIconRemoved(AbstractLauncherIcon::Ptr icon) | 1692 | void Launcher::OnIconRemoved(AbstractLauncherIcon::Ptr icon) |
36 | @@ -1757,6 +1763,11 @@ | |||
37 | 1757 | EnsureAnimation(); | 1763 | EnsureAnimation(); |
38 | 1758 | } | 1764 | } |
39 | 1759 | 1765 | ||
40 | 1766 | void Launcher::OnTooltipVisible(nux::ObjectPtr<nux::View> view) | ||
41 | 1767 | { | ||
42 | 1768 | _active_tooltip = view; | ||
43 | 1769 | } | ||
44 | 1770 | |||
45 | 1760 | void Launcher::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) | 1771 | void Launcher::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) |
46 | 1761 | { | 1772 | { |
47 | 1762 | 1773 | ||
48 | 1763 | 1774 | ||
49 | === modified file 'launcher/Launcher.h' | |||
50 | --- launcher/Launcher.h 2012-06-15 02:03:31 +0000 | |||
51 | +++ launcher/Launcher.h 2012-06-19 09:18:19 +0000 | |||
52 | @@ -96,6 +96,8 @@ | |||
53 | 96 | return _parent; | 96 | return _parent; |
54 | 97 | }; | 97 | }; |
55 | 98 | 98 | ||
56 | 99 | nux::ObjectPtr<nux::View> GetActiveTooltip() const; // nullptr = no tooltip | ||
57 | 100 | |||
58 | 99 | virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags); | 101 | virtual void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags); |
59 | 100 | virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags); | 102 | virtual void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags); |
60 | 101 | virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); | 103 | virtual void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); |
61 | @@ -269,6 +271,7 @@ | |||
62 | 269 | void OnOrderChanged(); | 271 | void OnOrderChanged(); |
63 | 270 | 272 | ||
64 | 271 | void OnIconNeedsRedraw(AbstractLauncherIcon::Ptr icon); | 273 | void OnIconNeedsRedraw(AbstractLauncherIcon::Ptr icon); |
65 | 274 | void OnTooltipVisible(nux::ObjectPtr<nux::View> view); | ||
66 | 272 | 275 | ||
67 | 273 | void OnOverlayHidden(GVariant* data); | 276 | void OnOverlayHidden(GVariant* data); |
68 | 274 | void OnOverlayShown(GVariant* data); | 277 | void OnOverlayShown(GVariant* data); |
69 | @@ -311,6 +314,7 @@ | |||
70 | 311 | 314 | ||
71 | 312 | LauncherModel::Ptr _model; | 315 | LauncherModel::Ptr _model; |
72 | 313 | nux::BaseWindow* _parent; | 316 | nux::BaseWindow* _parent; |
73 | 317 | nux::ObjectPtr<nux::View> _active_tooltip; | ||
74 | 314 | QuicklistView* _active_quicklist; | 318 | QuicklistView* _active_quicklist; |
75 | 315 | 319 | ||
76 | 316 | nux::HLayout* m_Layout; | 320 | nux::HLayout* m_Layout; |
77 | 317 | 321 | ||
78 | === modified file 'launcher/LauncherIcon.cpp' | |||
79 | --- launcher/LauncherIcon.cpp 2012-06-19 01:00:36 +0000 | |||
80 | +++ launcher/LauncherIcon.cpp 2012-06-19 09:18:19 +0000 | |||
81 | @@ -513,6 +513,7 @@ | |||
82 | 513 | LoadTooltip(); | 513 | LoadTooltip(); |
83 | 514 | _tooltip->ShowTooltipWithTipAt(tip_x, tip_y); | 514 | _tooltip->ShowTooltipWithTipAt(tip_x, tip_y); |
84 | 515 | _tooltip->ShowWindow(!tooltip_text().empty()); | 515 | _tooltip->ShowWindow(!tooltip_text().empty()); |
85 | 516 | tooltip_visible.emit(_tooltip); | ||
86 | 516 | } | 517 | } |
87 | 517 | 518 | ||
88 | 518 | void | 519 | void |
89 | @@ -534,6 +535,7 @@ | |||
90 | 534 | 535 | ||
91 | 535 | if (_tooltip) | 536 | if (_tooltip) |
92 | 536 | _tooltip->ShowWindow(false); | 537 | _tooltip->ShowWindow(false); |
93 | 538 | tooltip_visible.emit(nux::ObjectPtr<nux::View>(nullptr)); | ||
94 | 537 | } | 539 | } |
95 | 538 | 540 | ||
96 | 539 | bool LauncherIcon::OpenQuicklist(bool select_first_item, int monitor) | 541 | bool LauncherIcon::OpenQuicklist(bool select_first_item, int monitor) |
97 | @@ -653,6 +655,7 @@ | |||
98 | 653 | { | 655 | { |
99 | 654 | if (_tooltip) | 656 | if (_tooltip) |
100 | 655 | _tooltip->ShowWindow(false); | 657 | _tooltip->ShowWindow(false); |
101 | 658 | tooltip_visible.emit(nux::ObjectPtr<nux::View>(nullptr)); | ||
102 | 656 | } | 659 | } |
103 | 657 | 660 | ||
104 | 658 | bool | 661 | bool |
105 | 659 | 662 | ||
106 | === modified file 'panel/PanelController.cpp' | |||
107 | --- panel/PanelController.cpp 2012-06-15 02:03:31 +0000 | |||
108 | +++ panel/PanelController.cpp 2012-06-19 09:18:19 +0000 | |||
109 | @@ -49,6 +49,7 @@ | |||
110 | 49 | void QueueRedraw(); | 49 | void QueueRedraw(); |
111 | 50 | 50 | ||
112 | 51 | std::vector<Window> GetTrayXids() const; | 51 | std::vector<Window> GetTrayXids() const; |
113 | 52 | std::vector<nux::View*> GetPanelViews() const; | ||
114 | 52 | std::vector<nux::Geometry> GetGeometries() const; | 53 | std::vector<nux::Geometry> GetGeometries() const; |
115 | 53 | 54 | ||
116 | 54 | // NOTE: nux::Property maybe? | 55 | // NOTE: nux::Property maybe? |
117 | @@ -106,6 +107,15 @@ | |||
118 | 106 | return xids; | 107 | return xids; |
119 | 107 | } | 108 | } |
120 | 108 | 109 | ||
121 | 110 | std::vector<nux::View*> Controller::Impl::GetPanelViews() const | ||
122 | 111 | { | ||
123 | 112 | std::vector<nux::View*> views; | ||
124 | 113 | views.reserve(windows_.size()); | ||
125 | 114 | for (auto window: windows_) | ||
126 | 115 | views.push_back(ViewForWindow(window)); | ||
127 | 116 | return views; | ||
128 | 117 | } | ||
129 | 118 | |||
130 | 109 | std::vector<nux::Geometry> Controller::Impl::GetGeometries() const | 119 | std::vector<nux::Geometry> Controller::Impl::GetGeometries() const |
131 | 110 | { | 120 | { |
132 | 111 | std::vector<nux::Geometry> geometries; | 121 | std::vector<nux::Geometry> geometries; |
133 | @@ -325,6 +335,11 @@ | |||
134 | 325 | return pimpl->GetTrayXids(); | 335 | return pimpl->GetTrayXids(); |
135 | 326 | } | 336 | } |
136 | 327 | 337 | ||
137 | 338 | std::vector<nux::View*> Controller::GetPanelViews() const | ||
138 | 339 | { | ||
139 | 340 | return pimpl->GetPanelViews(); | ||
140 | 341 | } | ||
141 | 342 | |||
142 | 328 | std::vector<nux::Geometry> Controller::GetGeometries() const | 343 | std::vector<nux::Geometry> Controller::GetGeometries() const |
143 | 329 | { | 344 | { |
144 | 330 | return pimpl->GetGeometries(); | 345 | return pimpl->GetGeometries(); |
145 | 331 | 346 | ||
146 | === modified file 'panel/PanelController.h' | |||
147 | --- panel/PanelController.h 2012-05-06 23:48:38 +0000 | |||
148 | +++ panel/PanelController.h 2012-06-19 09:18:19 +0000 | |||
149 | @@ -41,6 +41,7 @@ | |||
150 | 41 | void QueueRedraw(); | 41 | void QueueRedraw(); |
151 | 42 | 42 | ||
152 | 43 | std::vector<Window> GetTrayXids() const; | 43 | std::vector<Window> GetTrayXids() const; |
153 | 44 | std::vector<nux::View*> GetPanelViews() const; | ||
154 | 44 | std::vector<nux::Geometry> GetGeometries() const; | 45 | std::vector<nux::Geometry> GetGeometries() const; |
155 | 45 | 46 | ||
156 | 46 | // NOTE: nux::Property maybe? | 47 | // NOTE: nux::Property maybe? |
157 | 47 | 48 | ||
158 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
159 | --- plugins/unityshell/src/unityshell.cpp 2012-06-15 02:03:31 +0000 | |||
160 | +++ plugins/unityshell/src/unityshell.cpp 2012-06-19 09:18:19 +0000 | |||
161 | @@ -1204,7 +1204,20 @@ | |||
162 | 1204 | { | 1204 | { |
163 | 1205 | bool ret; | 1205 | bool ret; |
164 | 1206 | 1206 | ||
166 | 1207 | doShellRepaint = true; | 1207 | /* |
167 | 1208 | * Very important! | ||
168 | 1209 | * Don't waste GPU and CPU rendering the shell on every frame if you don't | ||
169 | 1210 | * need to. Doing so on every frame causes Nux to hog the GPU and slow down | ||
170 | 1211 | * all other OpenGL apps (LP: #988079) | ||
171 | 1212 | */ | ||
172 | 1213 | if (forcePaintOnTop() || PluginAdapter::Default()->IsExpoActive()) | ||
173 | 1214 | doShellRepaint = true; | ||
174 | 1215 | else if (region.isEmpty() || shellIsHidden(*output)) | ||
175 | 1216 | doShellRepaint = false; | ||
176 | 1217 | else | ||
177 | 1218 | doShellRepaint = wt->GetDrawList().size() > 0 || | ||
178 | 1219 | BackgroundEffectHelper::HasDirtyHelpers(); | ||
179 | 1220 | |||
180 | 1208 | allowWindowPaint = true; | 1221 | allowWindowPaint = true; |
181 | 1209 | _last_output = output; | 1222 | _last_output = output; |
182 | 1210 | paint_panel_ = false; | 1223 | paint_panel_ = false; |
183 | @@ -1220,7 +1233,8 @@ | |||
184 | 1220 | * attempts to bind it will only increment | 1233 | * attempts to bind it will only increment |
185 | 1221 | * its bind reference so make sure that | 1234 | * its bind reference so make sure that |
186 | 1222 | * you always unbind as much as you bind */ | 1235 | * you always unbind as much as you bind */ |
188 | 1223 | _fbo->bind (nux::Geometry (output->x (), output->y (), output->width (), output->height ())); | 1236 | if (doShellRepaint) |
189 | 1237 | _fbo->bind (nux::Geometry (output->x (), output->y (), output->width (), output->height ())); | ||
190 | 1224 | #endif | 1238 | #endif |
191 | 1225 | 1239 | ||
192 | 1226 | /* glPaintOutput is part of the opengl plugin, so we need the GLScreen base class. */ | 1240 | /* glPaintOutput is part of the opengl plugin, so we need the GLScreen base class. */ |
193 | @@ -1279,16 +1293,20 @@ | |||
194 | 1279 | for (ShowdesktopHandlerWindowInterface *wi : ShowdesktopHandler::animating_windows) | 1293 | for (ShowdesktopHandlerWindowInterface *wi : ShowdesktopHandler::animating_windows) |
195 | 1280 | wi->HandleAnimations (ms); | 1294 | wi->HandleAnimations (ms); |
196 | 1281 | 1295 | ||
197 | 1296 | // Workaround Nux bug LP: #1014610: | ||
198 | 1282 | if (damaged) | 1297 | if (damaged) |
199 | 1283 | { | 1298 | { |
200 | 1284 | damaged = false; | 1299 | damaged = false; |
202 | 1285 | damageNuxRegions(); | 1300 | nuxDamageCompiz(); |
203 | 1286 | } | 1301 | } |
204 | 1287 | 1302 | ||
205 | 1303 | compizDamageNux(cScreen->currentDamage()); | ||
206 | 1288 | } | 1304 | } |
207 | 1289 | 1305 | ||
208 | 1290 | void UnityScreen::donePaint() | 1306 | void UnityScreen::donePaint() |
209 | 1291 | { | 1307 | { |
210 | 1308 | wt->ClearDrawList(); | ||
211 | 1309 | |||
212 | 1292 | std::list <ShowdesktopHandlerWindowInterface *> remove_windows; | 1310 | std::list <ShowdesktopHandlerWindowInterface *> remove_windows; |
213 | 1293 | 1311 | ||
214 | 1294 | for (ShowdesktopHandlerWindowInterface *wi : ShowdesktopHandler::animating_windows) | 1312 | for (ShowdesktopHandlerWindowInterface *wi : ShowdesktopHandler::animating_windows) |
215 | @@ -1309,11 +1327,94 @@ | |||
216 | 1309 | cScreen->donePaint (); | 1327 | cScreen->donePaint (); |
217 | 1310 | } | 1328 | } |
218 | 1311 | 1329 | ||
219 | 1330 | bool UnityScreen::shellIsHidden(const CompOutput &output) | ||
220 | 1331 | { | ||
221 | 1332 | bool hidden = false; | ||
222 | 1333 | const std::vector<Window> &nuxwins(nux::XInputWindow::NativeHandleList()); | ||
223 | 1334 | |||
224 | 1335 | // Loop through windows from back to front | ||
225 | 1336 | for (CompWindow *w : screen->windows ()) | ||
226 | 1337 | { | ||
227 | 1338 | /* | ||
228 | 1339 | * The shell is hidden if there exists any window that fully covers | ||
229 | 1340 | * the output and is in front of all Nux windows on that output. | ||
230 | 1341 | * We could also check CompositeWindow::opacity() but that would be slower | ||
231 | 1342 | * and almost always pointless. | ||
232 | 1343 | */ | ||
233 | 1344 | if (w->isMapped() && | ||
234 | 1345 | w->isViewable() && | ||
235 | 1346 | !w->inShowDesktopMode() && // Why must this != isViewable? | ||
236 | 1347 | w->geometry().contains(output)) | ||
237 | 1348 | { | ||
238 | 1349 | hidden = true; | ||
239 | 1350 | } | ||
240 | 1351 | else if (hidden) | ||
241 | 1352 | { | ||
242 | 1353 | for (Window n : nuxwins) | ||
243 | 1354 | { | ||
244 | 1355 | if (w->id() == n && output.intersects(w->geometry())) | ||
245 | 1356 | { | ||
246 | 1357 | hidden = false; | ||
247 | 1358 | break; | ||
248 | 1359 | } | ||
249 | 1360 | } | ||
250 | 1361 | } | ||
251 | 1362 | } | ||
252 | 1363 | |||
253 | 1364 | return hidden; | ||
254 | 1365 | } | ||
255 | 1366 | |||
256 | 1367 | void UnityScreen::compizDamageNux(const CompRegion &damage) | ||
257 | 1368 | { | ||
258 | 1369 | auto launchers = launcher_controller_->launchers(); | ||
259 | 1370 | for (auto launcher : launchers) | ||
260 | 1371 | { | ||
261 | 1372 | if (!launcher->Hidden()) | ||
262 | 1373 | { | ||
263 | 1374 | nux::Geometry geo = launcher->GetAbsoluteGeometry(); | ||
264 | 1375 | CompRegion launcher_region(geo.x, geo.y, geo.width, geo.height); | ||
265 | 1376 | if (damage.intersects(launcher_region)) | ||
266 | 1377 | launcher->QueueDraw(); | ||
267 | 1378 | nux::ObjectPtr<nux::View> tooltip = launcher->GetActiveTooltip(); | ||
268 | 1379 | if (!tooltip.IsNull()) | ||
269 | 1380 | { | ||
270 | 1381 | nux::Geometry tip = tooltip->GetAbsoluteGeometry(); | ||
271 | 1382 | CompRegion tip_region(tip.x, tip.y, tip.width, tip.height); | ||
272 | 1383 | if (damage.intersects(tip_region)) | ||
273 | 1384 | tooltip->QueueDraw(); | ||
274 | 1385 | } | ||
275 | 1386 | } | ||
276 | 1387 | } | ||
277 | 1388 | |||
278 | 1389 | const std::vector<nux::View*> &panels(panel_controller_->GetPanelViews()); | ||
279 | 1390 | for (nux::View *view : panels) | ||
280 | 1391 | { | ||
281 | 1392 | nux::Geometry geo = view->GetAbsoluteGeometry(); | ||
282 | 1393 | CompRegion panel_region(geo.x, geo.y, geo.width, geo.height); | ||
283 | 1394 | if (damage.intersects(panel_region)) | ||
284 | 1395 | view->QueueDraw(); | ||
285 | 1396 | } | ||
286 | 1397 | |||
287 | 1398 | QuicklistManager *qm = QuicklistManager::Default(); | ||
288 | 1399 | if (qm) | ||
289 | 1400 | { | ||
290 | 1401 | QuicklistView *view = qm->Current(); | ||
291 | 1402 | if (view) | ||
292 | 1403 | { | ||
293 | 1404 | nux::Geometry geo = view->GetAbsoluteGeometry(); | ||
294 | 1405 | CompRegion quicklist_region(geo.x, geo.y, geo.width, geo.height); | ||
295 | 1406 | if (damage.intersects(quicklist_region)) | ||
296 | 1407 | view->QueueDraw(); | ||
297 | 1408 | } | ||
298 | 1409 | } | ||
299 | 1410 | } | ||
300 | 1411 | |||
301 | 1312 | /* Grab changed nux regions and add damage rects for them */ | 1412 | /* Grab changed nux regions and add damage rects for them */ |
303 | 1313 | void UnityScreen::damageNuxRegions() | 1413 | void UnityScreen::nuxDamageCompiz() |
304 | 1314 | { | 1414 | { |
305 | 1315 | CompRegion nux_damage; | 1415 | CompRegion nux_damage; |
306 | 1316 | 1416 | ||
307 | 1417 | // Workaround Nux bug LP: #1014610 (unbounded DrawList growth) | ||
308 | 1317 | if (damaged) | 1418 | if (damaged) |
309 | 1318 | return; | 1419 | return; |
310 | 1319 | 1420 | ||
311 | @@ -1327,12 +1428,23 @@ | |||
312 | 1327 | nux_damage += CompRegion(geo.x, geo.y, geo.width, geo.height); | 1428 | nux_damage += CompRegion(geo.x, geo.y, geo.width, geo.height); |
313 | 1328 | } | 1429 | } |
314 | 1329 | 1430 | ||
321 | 1330 | nux::Geometry geo = wt->GetWindowCompositor().GetTooltipMainWindowGeometry(); | 1431 | // launcher_controller_ will still be null on startup |
322 | 1331 | nux_damage += CompRegion(geo.x, geo.y, geo.width, geo.height); | 1432 | if (launcher_controller_.get()) |
323 | 1332 | 1433 | { | |
324 | 1333 | geo = lastTooltipArea; | 1434 | auto launchers = launcher_controller_->launchers(); |
325 | 1334 | nux_damage += CompRegion(lastTooltipArea.x, lastTooltipArea.y, | 1435 | for (auto launcher : launchers) |
326 | 1335 | lastTooltipArea.width, lastTooltipArea.height); | 1436 | { |
327 | 1437 | if (!launcher->Hidden()) | ||
328 | 1438 | { | ||
329 | 1439 | nux::ObjectPtr<nux::View> tooltip = launcher->GetActiveTooltip(); | ||
330 | 1440 | if (!tooltip.IsNull()) | ||
331 | 1441 | { | ||
332 | 1442 | const nux::Geometry &g = tooltip->GetAbsoluteGeometry(); | ||
333 | 1443 | nux_damage += CompRegion(g.x, g.y, g.width, g.height); | ||
334 | 1444 | } | ||
335 | 1445 | } | ||
336 | 1446 | } | ||
337 | 1447 | } | ||
338 | 1336 | 1448 | ||
339 | 1337 | /* | 1449 | /* |
340 | 1338 | * Avoid Nux damaging Nux as recommended by smspillaz. Though I don't | 1450 | * Avoid Nux damaging Nux as recommended by smspillaz. Though I don't |
341 | @@ -1341,10 +1453,6 @@ | |||
342 | 1341 | cScreen->damageRegionSetEnabled(this, false); | 1453 | cScreen->damageRegionSetEnabled(this, false); |
343 | 1342 | cScreen->damageRegion(nux_damage); | 1454 | cScreen->damageRegion(nux_damage); |
344 | 1343 | cScreen->damageRegionSetEnabled(this, true); | 1455 | cScreen->damageRegionSetEnabled(this, true); |
345 | 1344 | |||
346 | 1345 | wt->ClearDrawList(); | ||
347 | 1346 | |||
348 | 1347 | lastTooltipArea = geo; | ||
349 | 1348 | } | 1456 | } |
350 | 1349 | 1457 | ||
351 | 1350 | /* handle X Events */ | 1458 | /* handle X Events */ |
352 | @@ -1511,6 +1619,8 @@ | |||
353 | 1511 | BackgroundEffectHelper::ProcessDamage(geo); | 1619 | BackgroundEffectHelper::ProcessDamage(geo); |
354 | 1512 | } | 1620 | } |
355 | 1513 | 1621 | ||
356 | 1622 | compizDamageNux(region); | ||
357 | 1623 | |||
358 | 1514 | cScreen->damageRegion(region); | 1624 | cScreen->damageRegion(region); |
359 | 1515 | } | 1625 | } |
360 | 1516 | 1626 | ||
361 | @@ -2527,25 +2637,7 @@ | |||
362 | 2527 | 2637 | ||
363 | 2528 | void UnityScreen::onRedrawRequested() | 2638 | void UnityScreen::onRedrawRequested() |
364 | 2529 | { | 2639 | { |
384 | 2530 | // disable blur updates so we dont waste perf. This can stall the blur during animations | 2640 | nuxDamageCompiz(); |
366 | 2531 | // but ensures a smooth animation. | ||
367 | 2532 | if (_in_paint) | ||
368 | 2533 | { | ||
369 | 2534 | if (!sources_.GetSource(local::REDRAW_IDLE)) | ||
370 | 2535 | { | ||
371 | 2536 | auto redraw_idle(std::make_shared<glib::Idle>(glib::Source::Priority::DEFAULT)); | ||
372 | 2537 | sources_.Add(redraw_idle, local::REDRAW_IDLE); | ||
373 | 2538 | |||
374 | 2539 | redraw_idle->Run([&]() { | ||
375 | 2540 | onRedrawRequested(); | ||
376 | 2541 | return false; | ||
377 | 2542 | }); | ||
378 | 2543 | } | ||
379 | 2544 | } | ||
380 | 2545 | else | ||
381 | 2546 | { | ||
382 | 2547 | damageNuxRegions(); | ||
383 | 2548 | } | ||
385 | 2549 | } | 2641 | } |
386 | 2550 | 2642 | ||
387 | 2551 | /* Handle option changes and plug that into nux windows */ | 2643 | /* Handle option changes and plug that into nux windows */ |
388 | 2552 | 2644 | ||
389 | === modified file 'plugins/unityshell/src/unityshell.h' | |||
390 | --- plugins/unityshell/src/unityshell.h 2012-06-15 02:03:31 +0000 | |||
391 | +++ plugins/unityshell/src/unityshell.h 2012-06-19 09:18:19 +0000 | |||
392 | @@ -212,7 +212,12 @@ | |||
393 | 212 | 212 | ||
394 | 213 | bool initPluginActions(); | 213 | bool initPluginActions(); |
395 | 214 | void initLauncher(); | 214 | void initLauncher(); |
397 | 215 | void damageNuxRegions(); | 215 | |
398 | 216 | void compizDamageNux(const CompRegion ®ion); | ||
399 | 217 | void nuxDamageCompiz(); | ||
400 | 218 | |||
401 | 219 | bool shellIsHidden(const CompOutput &output); | ||
402 | 220 | |||
403 | 216 | void onRedrawRequested(); | 221 | void onRedrawRequested(); |
404 | 217 | void Relayout(); | 222 | void Relayout(); |
405 | 218 | 223 | ||
406 | @@ -255,7 +260,6 @@ | |||
407 | 255 | bool enable_shortcut_overlay_; | 260 | bool enable_shortcut_overlay_; |
408 | 256 | 261 | ||
409 | 257 | GestureEngine gesture_engine_; | 262 | GestureEngine gesture_engine_; |
410 | 258 | nux::Geometry lastTooltipArea; | ||
411 | 259 | bool needsRelayout; | 263 | bool needsRelayout; |
412 | 260 | bool _in_paint; | 264 | bool _in_paint; |
413 | 261 | bool super_keypressed_; | 265 | bool super_keypressed_; |
Approve the concept, been wanting to do this for some time ;-)