Merge lp:~vanvugt/unity/fix-1057528 into lp:unity

Proposed by Daniel van Vugt
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: no longer in the source branch.
Merged at revision: 2818
Proposed branch: lp:~vanvugt/unity/fix-1057528
Merge into: lp:unity
Diff against target: 96 lines (+39/-18)
2 files modified
manual-tests/Panel.txt (+16/-0)
plugins/unityshell/src/unityshell.cpp (+23/-18)
To merge this branch: bzr merge lp:~vanvugt/unity/fix-1057528
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+127436@code.launchpad.net

Commit message

Draw the panel shadow only within the redraw region. Using a bounding box
allowed parts to get redrawn when they should not, appearing as small chunks
of extra-dark panel shadow.
(LP: #1057528)

Description of the change

See commit message.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

75 + for (auto r : rects)

auto const& r could save some copies there..

67 + if (launcher_controller_->IsOverlayOpen() &&
68 + current_monitor == overlay_monitor_)

On stylistic basis I'd prefer that to be in one line...

Btw, code looks good and it works as expected.

review: Approve
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

82 + // Sub-rectangle of the shadow needing redrawing:
83 + float x1 = r.x1();
84 + float y1 = r.y1();
85 + float x2 = r.x2();
86 + float y2 = r.y2();
87 +
88 + // Texture coordinates of the above rectangle:
89 + float tx1 = (x1 - shadowX) / shadowWidth;
90 + float ty1 = (y1 - shadowY) / shadowHeight;
91 + float tx2 = (x2 - shadowX) / shadowWidth;
92 + float ty2 = (y2 - shadowY) / shadowHeight;

This definitely seems like something that's autotestable. Has that been looked into?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Certainly a simple formula can be auto-tested. However in this case it would make the code significantly less readable and more complex. And more importantly, any mistakes or regressions here are immediately visible on screen.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Works for me. I also think that a manual test in this case can be sufficient. We don't want to complicate code unnecessarily.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'manual-tests/Panel.txt'
2--- manual-tests/Panel.txt 2012-08-23 16:55:54 +0000
3+++ manual-tests/Panel.txt 2012-10-02 09:41:22 +0000
4@@ -95,3 +95,19 @@
5 At no point during the actions should the panel (or launcher) blink or
6 flicker out of existence.
7
8+
9+Panel shadow overdraw
10+---------------------
11+Setup:
12+#. Install Google Chrome or Chromium.
13+
14+Actions:
15+#. Maximize a Chrome window.
16+#. Open several tabs so that the titles of some tabs are not fully visible
17+ and fade out to the right.
18+#. Hover the mouse over the very top part of some tabs so tooltips appear.
19+
20+Expected Result:
21+ No part of the panel shadow should ever appear on top of the maximized
22+ Chrome window.
23+
24
25=== modified file 'plugins/unityshell/src/unityshell.cpp'
26--- plugins/unityshell/src/unityshell.cpp 2012-10-01 23:32:49 +0000
27+++ plugins/unityshell/src/unityshell.cpp 2012-10-02 09:41:22 +0000
28@@ -562,6 +562,9 @@
29
30 void UnityScreen::paintPanelShadow(const CompRegion& clip)
31 {
32+ if (panel_controller_->opacity() == 0.0f)
33+ return;
34+
35 if (sources_.GetSource(local::RELAYOUT_TIMEOUT))
36 return;
37
38@@ -587,22 +590,6 @@
39 if (redraw.isEmpty())
40 return;
41
42- const CompRect& bounds(redraw.boundingRect());
43-
44- // Sub-rectangle of the shadow needing redrawing:
45- float x1 = bounds.x1();
46- float y1 = bounds.y1();
47- float x2 = bounds.x2();
48- float y2 = bounds.y2();
49-
50- // Texture coordinates of the above rectangle:
51- float tx1 = (x1 - shadowX) / shadowWidth;
52- float ty1 = (y1 - shadowY) / shadowHeight;
53- float tx2 = (x2 - shadowX) / shadowWidth;
54- float ty2 = (y2 - shadowY) / shadowHeight;
55-
56- nuxPrologue();
57-
58 // compiz doesn't use the same method of tracking monitors as our toolkit
59 // we need to make sure we properly associate with the right monitor
60 int current_monitor = -1;
61@@ -618,8 +605,14 @@
62 i++;
63 }
64
65- if (!(launcher_controller_->IsOverlayOpen() && current_monitor == overlay_monitor_)
66- && panel_controller_->opacity() > 0.0f)
67+ if (launcher_controller_->IsOverlayOpen() && current_monitor == overlay_monitor_)
68+ return;
69+
70+ nuxPrologue();
71+
72+ const CompRect::vector& rects = redraw.rects();
73+
74+ for (auto const& r : rects)
75 {
76 foreach(GLTexture * tex, _shadow_texture)
77 {
78@@ -641,6 +634,18 @@
79 (GLushort)(panel_controller_->opacity() * 0xFFFF)
80 };
81
82+ // Sub-rectangle of the shadow needing redrawing:
83+ float x1 = r.x1();
84+ float y1 = r.y1();
85+ float x2 = r.x2();
86+ float y2 = r.y2();
87+
88+ // Texture coordinates of the above rectangle:
89+ float tx1 = (x1 - shadowX) / shadowWidth;
90+ float ty1 = (y1 - shadowY) / shadowHeight;
91+ float tx2 = (x2 - shadowX) / shadowWidth;
92+ float ty2 = (y2 - shadowY) / shadowHeight;
93+
94 vertexData = {
95 x1, y1, 0,
96 x1, y2, 0,