Skip to content

Commit

Permalink
cc: Fix occlusion tracking for layers with non-default blend modes
Browse files Browse the repository at this point in the history
When computing the occlusion from a layer, draw_blend_mode rather than
blend_mode needs to be considered, since draw_blend_mode is what's used
when drawing the layer. However, non-default blend modes currently always
trigger surface creation, and then the blend mode gets applied when
drawing the surface. This means that draw_blend_mode is always SrcOver.
This CL replaces the incorrect use of blend_mode in
OcclusionTracker::MarkOcclusionBehindLayer with a DCHECK that
draw_blend_mode is SrcOver.

CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2176903002
Cr-Commit-Position: refs/heads/master@{#407572}
  • Loading branch information
alijuma authored and Commit bot committed Jul 25, 2016
1 parent cb4ce77 commit 2d466aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cc/trees/occlusion_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,9 @@ void OcclusionTracker::MarkOccludedBehindLayer(const LayerImpl* layer) {
if (layer->draw_opacity() < 1)
return;

if (!layer->uses_default_blend_mode())
return;
// The only currently supported draw_blend_mode is SrcOver mode, so
// draw_blend_mode does not affect occlusion.
DCHECK_EQ(layer->draw_blend_mode(), SkXfermode::kSrcOver_Mode);

if (layer->Is3dSorted())
return;
Expand Down
7 changes: 5 additions & 2 deletions cc/trees/occlusion_tracker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1986,10 +1986,13 @@ class OcclusionTrackerTestBlendModeDoesNotOcclude
EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());

this->VisitLayer(blend_mode_layer, &occlusion);
// |top_layer| occludes but not |blend_mode_layer|.
// |top_layer| and |blend_mode_layer| both occlude, since the blend mode
// gets applied by blend_mode_layer's render surface, not when drawing the
// layer itself.
EXPECT_EQ(gfx::Rect(100, 100).ToString(),
occlusion.occlusion_from_inside_target().ToString());
EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());

this->VisitContributingSurface(blend_mode_layer, &occlusion);
// |top_layer| occludes but not |blend_mode_layer|.
Expand Down

0 comments on commit 2d466aa

Please sign in to comment.