Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3932)

Unified Diff: cc/trees/occlusion_tracker_unittest.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/occlusion_tracker.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/occlusion_tracker_unittest.cc
diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc
index 172b22798b28a4423826613db2b01d80b4d34003..e3639adeb0a99f04a9022e459b09fd3aedda8204 100644
--- a/cc/trees/occlusion_tracker_unittest.cc
+++ b/cc/trees/occlusion_tracker_unittest.cc
@@ -101,8 +101,9 @@ class TestOcclusionTrackerWithClip : public TestOcclusionTracker<LayerType> {
gfx::Rect UnoccludedSurfaceContentRect(const LayerType* layer,
const gfx::Rect& content_rect) const {
typename LayerType::RenderSurfaceType* surface = layer->render_surface();
- return this->UnoccludedContributingSurfaceContentRect(
- content_rect, surface->draw_transform());
+ return this->GetCurrentOcclusionForContributingSurface(
+ surface->draw_transform())
+ .GetUnoccludedContentRect(content_rect);
}
};
@@ -2671,6 +2672,53 @@ ALL_OCCLUSIONTRACKER_TEST(
OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded);
template <class Types>
+class OcclusionTrackerTestBlendModeDoesNotOcclude
+ : public OcclusionTrackerTest<Types> {
+ protected:
+ explicit OcclusionTrackerTestBlendModeDoesNotOcclude(bool opaque_layers)
+ : OcclusionTrackerTest<Types>(opaque_layers) {}
+ void RunMyTest() override {
+ typename Types::ContentLayerType* parent = this->CreateRoot(
+ this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
+ typename Types::LayerType* blend_mode_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(0.f, 0.f),
+ gfx::Size(100, 100), true);
+ typename Types::LayerType* top_layer = this->CreateDrawingLayer(
+ parent, this->identity_matrix, gfx::PointF(10.f, 12.f),
+ gfx::Size(20, 22), true);
+
+ // Blend mode makes the layer own a surface.
+ Types::SetForceRenderSurface(blend_mode_layer, true);
+ blend_mode_layer->SetBlendMode(SkXfermode::kMultiply_Mode);
+
+ this->CalcDrawEtc(parent);
+
+ TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
+ gfx::Rect(0, 0, 1000, 1000));
+
+ this->VisitLayer(top_layer, &occlusion);
+ // |top_layer| occludes.
+ EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
+ occlusion.occlusion_from_inside_target().ToString());
+ EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
+
+ this->VisitLayer(blend_mode_layer, &occlusion);
+ // |top_layer| occludes but not |blend_mode_layer|.
+ 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|.
+ EXPECT_EQ(gfx::Rect(10, 12, 20, 22).ToString(),
+ occlusion.occlusion_from_inside_target().ToString());
+ EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
+ }
+};
+
+ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestBlendModeDoesNotOcclude);
+
+template <class Types>
class OcclusionTrackerTestMinimumTrackingSize
: public OcclusionTrackerTest<Types> {
protected:
@@ -2816,12 +2864,22 @@ class OcclusionTrackerTestCopyRequestDoesOcclude
gfx::PointF(),
gfx::Size(200, 400),
true);
+ typename Types::LayerType* top_layer =
+ this->CreateDrawingLayer(root, this->identity_matrix,
+ gfx::PointF(50, 0), gfx::Size(50, 400), true);
this->CalcDrawEtc(root);
TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
gfx::Rect(0, 0, 1000, 1000));
+ this->VisitLayer(top_layer, &occlusion);
+ EXPECT_EQ(gfx::Rect().ToString(),
+ occlusion.occlusion_from_outside_target().ToString());
+ EXPECT_EQ(gfx::Rect(50, 0, 50, 400).ToString(),
+ occlusion.occlusion_from_inside_target().ToString());
+
this->VisitLayer(copy_child, &occlusion);
+ // Layers outside the copy request do not occlude.
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
EXPECT_EQ(gfx::Rect(200, 400).ToString(),
@@ -2833,7 +2891,7 @@ class OcclusionTrackerTestCopyRequestDoesOcclude
// The occlusion from the copy should be kept.
EXPECT_EQ(gfx::Rect().ToString(),
occlusion.occlusion_from_outside_target().ToString());
- EXPECT_EQ(gfx::Rect(100, 0, 200, 400).ToString(),
+ EXPECT_EQ(gfx::Rect(50, 0, 250, 400).ToString(),
occlusion.occlusion_from_inside_target().ToString());
}
};
« no previous file with comments | « cc/trees/occlusion_tracker.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698