Skip to content

Commit

Permalink
Draw the panel shadow only within the redraw region. Using a bounding…
Browse files Browse the repository at this point in the history
… box

allowed parts to get redrawn when they should not, appearing as small chunks
of extra-dark panel shadow.
(LP: #1057528). Fixes: https://bugs.launchpad.net/bugs/1057528. Approved by Łukasz Zemczak, Marco Trevisan (Treviño).
  • Loading branch information
vanvugt authored and Tarmac committed Oct 10, 2012
2 parents 7e7b6a8 + 635006e commit ccb4573
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
16 changes: 16 additions & 0 deletions manual-tests/Panel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,19 @@ Expected Result:
At no point during the actions should the panel (or launcher) blink or
flicker out of existence.


Panel shadow overdraw
---------------------
Setup:
#. Install Google Chrome or Chromium.

Actions:
#. Maximize a Chrome window.
#. Open several tabs so that the titles of some tabs are not fully visible
and fade out to the right.
#. Hover the mouse over the very top part of some tabs so tooltips appear.

Expected Result:
No part of the panel shadow should ever appear on top of the maximized
Chrome window.

41 changes: 23 additions & 18 deletions plugins/unityshell/src/unityshell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ void UnityScreen::setPanelShadowMatrix(const GLMatrix& matrix)

void UnityScreen::paintPanelShadow(const CompRegion& clip)
{
if (panel_controller_->opacity() == 0.0f)
return;

if (sources_.GetSource(local::RELAYOUT_TIMEOUT))
return;

Expand All @@ -585,22 +588,6 @@ void UnityScreen::paintPanelShadow(const CompRegion& clip)
if (redraw.isEmpty())
return;

const CompRect& bounds(redraw.boundingRect());

// Sub-rectangle of the shadow needing redrawing:
float x1 = bounds.x1();
float y1 = bounds.y1();
float x2 = bounds.x2();
float y2 = bounds.y2();

// Texture coordinates of the above rectangle:
float tx1 = (x1 - shadowX) / shadowWidth;
float ty1 = (y1 - shadowY) / shadowHeight;
float tx2 = (x2 - shadowX) / shadowWidth;
float ty2 = (y2 - shadowY) / shadowHeight;

nuxPrologue();

// compiz doesn't use the same method of tracking monitors as our toolkit
// we need to make sure we properly associate with the right monitor
int current_monitor = -1;
Expand All @@ -616,8 +603,14 @@ void UnityScreen::paintPanelShadow(const CompRegion& clip)
i++;
}

if (!(launcher_controller_->IsOverlayOpen() && current_monitor == overlay_monitor_)
&& panel_controller_->opacity() > 0.0f)
if (launcher_controller_->IsOverlayOpen() && current_monitor == overlay_monitor_)
return;

nuxPrologue();

const CompRect::vector& rects = redraw.rects();

for (auto const& r : rects)
{
foreach(GLTexture * tex, _shadow_texture)
{
Expand All @@ -639,6 +632,18 @@ void UnityScreen::paintPanelShadow(const CompRegion& clip)
(GLushort)(panel_controller_->opacity() * 0xFFFF)
};

// Sub-rectangle of the shadow needing redrawing:
float x1 = r.x1();
float y1 = r.y1();
float x2 = r.x2();
float y2 = r.y2();

// Texture coordinates of the above rectangle:
float tx1 = (x1 - shadowX) / shadowWidth;
float ty1 = (y1 - shadowY) / shadowHeight;
float tx2 = (x2 - shadowX) / shadowWidth;
float ty2 = (y2 - shadowY) / shadowHeight;

vertexData = {
x1, y1, 0,
x1, y2, 0,
Expand Down

0 comments on commit ccb4573

Please sign in to comment.