Chromium Code Reviews| Index: cc/trees/occlusion_tracker_unittest.cc |
| diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc |
| index e6464a254dcd8b82f20b42161df255ac94458d42..5794c5876f9897dc24afc2171137bf716bec471c 100644 |
| --- a/cc/trees/occlusion_tracker_unittest.cc |
| +++ b/cc/trees/occlusion_tracker_unittest.cc |
| @@ -33,9 +33,11 @@ class TestContentLayer : public Layer { |
| SetIsDrawable(true); |
| } |
| - virtual Region VisibleContentOpaqueRegion() const OVERRIDE { |
| - if (override_opaque_contents_rect_) |
| - return gfx::IntersectRects(opaque_contents_rect_, visible_content_rect()); |
| + virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const OVERRIDE { |
| + if (override_opaque_contents_rect_) { |
| + return SimpleEnclosedRegion( |
| + gfx::IntersectRects(opaque_contents_rect_, visible_content_rect())); |
| + } |
| return Layer::VisibleContentOpaqueRegion(); |
| } |
| void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { |
| @@ -57,9 +59,11 @@ class TestContentLayerImpl : public LayerImpl { |
| SetDrawsContent(true); |
| } |
| - virtual Region VisibleContentOpaqueRegion() const OVERRIDE { |
| - if (override_opaque_contents_rect_) |
| - return gfx::IntersectRects(opaque_contents_rect_, visible_content_rect()); |
| + virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const OVERRIDE { |
| + if (override_opaque_contents_rect_) { |
| + return SimpleEnclosedRegion( |
| + gfx::IntersectRects(opaque_contents_rect_, visible_content_rect())); |
| + } |
| return LayerImpl::VisibleContentOpaqueRegion(); |
| } |
| void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { |
| @@ -179,13 +183,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { |
| virtual void RunMyTest() = 0; |
| - virtual void TearDown() { |
| - Types::DestroyLayer(&root_); |
| - render_surface_layer_list_.reset(); |
| - render_surface_layer_list_impl_.clear(); |
| - replica_layers_.clear(); |
| - mask_layers_.clear(); |
| - } |
| + virtual void TearDown() { DestroyLayers(); } |
| typename Types::HostType* GetHost(); |
| @@ -287,6 +285,14 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { |
| return layer; |
| } |
| + void DestroyLayers() { |
| + Types::DestroyLayer(&root_); |
| + render_surface_layer_list_.reset(); |
| + render_surface_layer_list_impl_.clear(); |
| + replica_layers_.clear(); |
| + mask_layers_.clear(); |
| + ResetLayerIterator(); |
| + } |
| void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} |
| @@ -336,14 +342,14 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { |
| void EnterLayer(typename Types::LayerType* layer, |
| typename Types::OcclusionTrackerType* occlusion) { |
| - ASSERT_EQ(layer, *layer_iterator_); |
| + ASSERT_EQ(*layer_iterator_, layer); |
| ASSERT_TRUE(layer_iterator_.represents_itself()); |
| occlusion->EnterLayer(layer_iterator_); |
| } |
| void LeaveLayer(typename Types::LayerType* layer, |
| typename Types::OcclusionTrackerType* occlusion) { |
| - ASSERT_EQ(layer, *layer_iterator_); |
| + ASSERT_EQ(*layer_iterator_, layer); |
| ASSERT_TRUE(layer_iterator_.represents_itself()); |
| occlusion->LeaveLayer(layer_iterator_); |
| ++layer_iterator_; |
| @@ -358,7 +364,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { |
| void EnterContributingSurface( |
| typename Types::LayerType* layer, |
| typename Types::OcclusionTrackerType* occlusion) { |
| - ASSERT_EQ(layer, *layer_iterator_); |
| + ASSERT_EQ(*layer_iterator_, layer); |
| ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); |
| occlusion->EnterLayer(layer_iterator_); |
| occlusion->LeaveLayer(layer_iterator_); |
| @@ -370,7 +376,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { |
| void LeaveContributingSurface( |
| typename Types::LayerType* layer, |
| typename Types::OcclusionTrackerType* occlusion) { |
| - ASSERT_EQ(layer, *layer_iterator_); |
| + ASSERT_EQ(*layer_iterator_, layer); |
| ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
| occlusion->LeaveLayer(layer_iterator_); |
| ++layer_iterator_; |
| @@ -544,38 +550,32 @@ class OcclusionTrackerTestIdentityTransforms |
| EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 69, 70))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 31, 70, 69))); |
| - |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| parent, gfx::Rect(30, 30, 70, 70)).IsEmpty()); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 30, 1, 70), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 30, 70, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 29, 70, 70), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 29, 70, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(30, 29, 70, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 29, 70, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(31, 29, 69, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 29, 69, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 30, 69, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 31, 69, 69))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 31, 70, 69))); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 31, 1, 69), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 31, 70, 69))); |
| + EXPECT_EQ(gfx::Rect(29, 30, 1, 70), |
|
danakj
2014/08/21 01:28:27
I changed all EXPECT_RECT_EQ to EXPECT_EQ in this
|
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(29, 30, 70, 70))); |
| + EXPECT_EQ(gfx::Rect(29, 29, 70, 70), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(29, 29, 70, 70))); |
| + EXPECT_EQ(gfx::Rect(30, 29, 70, 1), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(30, 29, 70, 70))); |
| + EXPECT_EQ(gfx::Rect(31, 29, 69, 1), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(31, 29, 69, 70))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(31, 30, 69, 70))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(31, 31, 69, 69))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(30, 31, 70, 69))); |
| + EXPECT_EQ(gfx::Rect(29, 31, 1, 69), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(29, 31, 70, 69))); |
| } |
| }; |
| @@ -619,12 +619,12 @@ class OcclusionTrackerTestQuadsMismatchLayer |
| EXPECT_TRUE(occlusion.UnoccludedContentRect(gfx::Rect(0, 0, 10, 10), |
| quad_transform).IsEmpty()); |
| - EXPECT_RECT_EQ(gfx::Rect(40, 40, 10, 10), |
| - occlusion.UnoccludedContentRect(gfx::Rect(40, 40, 10, 10), |
| - quad_transform)); |
| - EXPECT_RECT_EQ(gfx::Rect(40, 30, 5, 10), |
| - occlusion.UnoccludedContentRect(gfx::Rect(35, 30, 10, 10), |
| - quad_transform)); |
| + EXPECT_EQ(gfx::Rect(40, 40, 10, 10), |
| + occlusion.UnoccludedContentRect(gfx::Rect(40, 40, 10, 10), |
| + quad_transform)); |
| + EXPECT_EQ(gfx::Rect(40, 30, 5, 10), |
| + occlusion.UnoccludedContentRect(gfx::Rect(35, 30, 10, 10), |
| + quad_transform)); |
| } |
| }; |
| @@ -665,38 +665,32 @@ class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest<Types> { |
| EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); |
|
danakj
2014/08/21 01:28:27
I removed all the checks for OccludedLayer() all o
|
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 69, 70))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 31, 70, 69))); |
| - |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| parent, gfx::Rect(30, 30, 70, 70)).IsEmpty()); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 30, 1, 70), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 30, 69, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 29, 70, 70), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 29, 70, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(30, 29, 70, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 29, 70, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(31, 29, 69, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 29, 69, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 30, 69, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 31, 69, 69))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 31, 70, 69))); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 31, 1, 69), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 31, 70, 69))); |
| + EXPECT_EQ(gfx::Rect(29, 30, 1, 70), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(29, 30, 69, 70))); |
| + EXPECT_EQ(gfx::Rect(29, 29, 70, 70), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(29, 29, 70, 70))); |
| + EXPECT_EQ(gfx::Rect(30, 29, 70, 1), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(30, 29, 70, 70))); |
| + EXPECT_EQ(gfx::Rect(31, 29, 69, 1), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(31, 29, 69, 70))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(31, 30, 69, 70))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(31, 31, 69, 69))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(30, 31, 70, 69))); |
| + EXPECT_EQ(gfx::Rect(29, 31, 1, 69), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(29, 31, 70, 69))); |
| } |
| }; |
| @@ -735,35 +729,29 @@ class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest<Types> { |
| EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(50, 50, 50, 50))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(49, 50, 50, 50))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(50, 49, 50, 50))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(51, 50, 49, 50))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(50, 51, 50, 49))); |
| - |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| parent, gfx::Rect(50, 50, 50, 50)).IsEmpty()); |
| - EXPECT_RECT_EQ(gfx::Rect(49, 50, 1, 50), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(49, 50, 50, 50))); |
| - EXPECT_RECT_EQ(gfx::Rect(49, 49, 50, 50), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(49, 49, 50, 50))); |
| - EXPECT_RECT_EQ(gfx::Rect(50, 49, 50, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(50, 49, 50, 50))); |
| - EXPECT_RECT_EQ(gfx::Rect(51, 49, 49, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(51, 49, 49, 50))); |
| + EXPECT_EQ(gfx::Rect(49, 50, 1, 50), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(49, 50, 50, 50))); |
| + EXPECT_EQ(gfx::Rect(49, 49, 50, 50), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(49, 49, 50, 50))); |
| + EXPECT_EQ(gfx::Rect(50, 49, 50, 1), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(50, 49, 50, 50))); |
| + EXPECT_EQ(gfx::Rect(51, 49, 49, 1), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(51, 49, 49, 50))); |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| parent, gfx::Rect(51, 50, 49, 50)).IsEmpty()); |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| parent, gfx::Rect(51, 51, 49, 49)).IsEmpty()); |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| parent, gfx::Rect(50, 51, 50, 49)).IsEmpty()); |
| - EXPECT_RECT_EQ(gfx::Rect(49, 51, 1, 49), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(49, 51, 50, 49))); |
| + EXPECT_EQ(gfx::Rect(49, 51, 1, 49), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(49, 51, 50, 49))); |
| } |
| }; |
| @@ -814,12 +802,6 @@ class OcclusionTrackerTestChildInRotatedChild |
| EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 40, 69, 60))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 41, 70, 59))); |
| - |
| /* Justification for the above occlusion from |layer|: |
| 100 |
| +---------------------+ |
| @@ -912,15 +894,15 @@ class OcclusionTrackerTestScaledRenderSurface |
| EXPECT_EQ(gfx::Rect().ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_RECT_EQ( |
| + EXPECT_EQ( |
| gfx::Rect(0, 0, 25, 25), |
| occlusion.UnoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25))); |
| - EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25), |
| - occlusion.UnoccludedLayerContentRect( |
| - layer2, gfx::Rect(10, 25, 25, 25))); |
| - EXPECT_RECT_EQ(gfx::Rect(25, 10, 25, 15), |
| - occlusion.UnoccludedLayerContentRect( |
| - layer2, gfx::Rect(25, 10, 25, 25))); |
| + EXPECT_EQ(gfx::Rect(10, 25, 15, 25), |
| + occlusion.UnoccludedLayerContentRect(layer2, |
| + gfx::Rect(10, 25, 25, 25))); |
| + EXPECT_EQ(gfx::Rect(25, 10, 25, 15), |
| + occlusion.UnoccludedLayerContentRect(layer2, |
| + gfx::Rect(25, 10, 25, 25))); |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| layer2, gfx::Rect(25, 25, 25, 25)).IsEmpty()); |
| } |
| @@ -935,171 +917,60 @@ class OcclusionTrackerTestVisitTargetTwoTimes |
| explicit OcclusionTrackerTestVisitTargetTwoTimes(bool opaque_layers) |
| : OcclusionTrackerTest<Types>(opaque_layers) {} |
| void RunMyTest() { |
| - gfx::Transform child_transform; |
| - child_transform.Translate(250.0, 250.0); |
| - child_transform.Rotate(90.0); |
| - child_transform.Translate(-250.0, -250.0); |
| - |
| typename Types::ContentLayerType* root = this->CreateRoot( |
| this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| - typename Types::ContentLayerType* parent = this->CreateDrawingLayer( |
| - root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); |
| - parent->SetMasksToBounds(true); |
| - typename Types::LayerType* child = this->CreateSurface( |
| - parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500)); |
| - child->SetMasksToBounds(true); |
| - typename Types::ContentLayerType* layer = |
| - this->CreateDrawingLayer(child, |
| + typename Types::LayerType* surface = this->CreateSurface( |
| + root, this->identity_matrix, gfx::PointF(30.f, 30.f), gfx::Size()); |
| + typename Types::ContentLayerType* surface_child = |
| + this->CreateDrawingLayer(surface, |
| this->identity_matrix, |
| gfx::PointF(10.f, 10.f), |
| - gfx::Size(500, 500), |
| + gfx::Size(50, 50), |
| true); |
| - // |child2| makes |parent|'s surface get considered by OcclusionTracker |
| - // first, instead of |child|'s. This exercises different code in |
| - // LeaveToRenderTarget, as the target surface has already been seen. |
| - typename Types::ContentLayerType* child2 = |
| - this->CreateDrawingLayer(parent, |
| + // |top_layer| makes |root|'s surface get considered by OcclusionTracker |
| + // first, instead of |surface|'s. This exercises different code in |
| + // LeaveToRenderTarget, as the target surface has already been seen when |
| + // leaving |surface| later. |
| + typename Types::ContentLayerType* top_layer = |
| + this->CreateDrawingLayer(root, |
| this->identity_matrix, |
| - gfx::PointF(30.f, 30.f), |
| - gfx::Size(60, 20), |
| + gfx::PointF(40.f, 90.f), |
| + gfx::Size(50, 20), |
| true); |
| this->CalcDrawEtc(root); |
| TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| gfx::Rect(0, 0, 1000, 1000)); |
| - this->VisitLayer(child2, &occlusion); |
| + this->VisitLayer(top_layer, &occlusion); |
| EXPECT_EQ(gfx::Rect().ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), |
| + EXPECT_EQ(gfx::Rect(40, 90, 50, 20).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - this->VisitLayer(layer, &occlusion); |
| + this->VisitLayer(surface_child, &occlusion); |
| - EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), |
| + EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
| + EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - this->EnterContributingSurface(child, &occlusion); |
| + this->EnterContributingSurface(surface, &occlusion); |
| - EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), |
| + EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
| + EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - // Occlusion in |child2| should get merged with the |child| surface we are |
| - // leaving now. |
| - this->LeaveContributingSurface(child, &occlusion); |
| - this->EnterLayer(parent, &occlusion); |
| + // Occlusion from |top_layer| already in the root target should get merged |
| + // with the occlusion from the |surface| we are leaving now. |
| + this->LeaveContributingSurface(surface, &occlusion); |
| + this->EnterLayer(root, &occlusion); |
| - EXPECT_EQ(gfx::Rect().ToString(), |
| - occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)) |
| - .ToString(), |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| + EXPECT_EQ(gfx::Rect(40, 40, 50, 70).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 30, 70, 70))); |
| - |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 60, 10))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 60, 10))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 60, 10))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 60, 10))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 31, 60, 10))); |
| - |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); |
| - |
| - EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 30, 60, 10)).IsEmpty()); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 30, 1, 10), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 30, 60, 10))); |
| - EXPECT_RECT_EQ(gfx::Rect(30, 29, 60, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 29, 60, 10))); |
| - EXPECT_RECT_EQ(gfx::Rect(90, 30, 1, 10), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 30, 60, 10))); |
| - EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 31, 60, 10)).IsEmpty()); |
| - |
| - EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 40, 70, 60)).IsEmpty()); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 40, 1, 60), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 40, 70, 60))); |
| - // This rect is mostly occluded by |child2|. |
| - EXPECT_RECT_EQ(gfx::Rect(90, 39, 10, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 39, 70, 60))); |
| - // This rect extends past top/right ends of |child2|. |
| - EXPECT_RECT_EQ(gfx::Rect(30, 29, 70, 11), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 29, 70, 70))); |
| - // This rect extends past left/right ends of |child2|. |
| - EXPECT_RECT_EQ(gfx::Rect(20, 39, 80, 60), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(20, 39, 80, 60))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 40, 69, 60))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 41, 70, 59))); |
| - |
| - /* Justification for the above occlusion from |layer|: |
| - 100 |
| - +---------------------+ |
| - | | |
| - | 30 | rotate(90) |
| - | 30 + ------------+--------------------+ |
| - 100 | | 10 | | | ==> |
| - | |10+----------|----------------------+ |
| - | + ------------+ | | | |
| - | | | | | | |
| - | | | | | | |
| - +----|--|-------------+ | | |
| - | | | | |
| - | | | | |
| - | | | |500 |
| - | | | | |
| - | | | | |
| - | | | | |
| - | | | | |
| - +--|-------------------------------+ | |
| - | | |
| - +---------------------------------+ |
| - 500 |
| - |
| - |
| - +---------------------+ |
| - | |30 Visible region of |layer|: ///// |
| - | 30 60 | |child2|: \\\\\ |
| - | 30 +------------+--------------------+ |
| - | |\\\\\\\\\\\\| |10 | |
| - | +--|\\\\\\\\\\\\|-----------------+ | |
| - | | +------------+//| 420 | | |
| - | | |///////////////|60 | | |
| - | | |///////////////| | | |
| - +--|--|---------------+ | | |
| - 20|10| 70 | | |
| - | | | | |
| - | | | | |
| - | | | | |
| - | | | | |
| - | | | | |
| - | | |10| |
| - | +------------------------------|--+ |
| - | 490 | |
| - +---------------------------------+ |
| - 500 |
| - */ |
| } |
| }; |
| @@ -1153,8 +1024,7 @@ class OcclusionTrackerTestSurfaceRotatedOffAxis |
| EXPECT_EQ(gfx::Rect().ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(75, 55, 1, 1))); |
| - EXPECT_RECT_EQ( |
| + EXPECT_EQ( |
| gfx::Rect(75, 55, 1, 1), |
| occlusion.UnoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1))); |
| } |
| @@ -1213,22 +1083,17 @@ class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren |
| EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 430, 60, 70))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(child, gfx::Rect(9, 430, 60, 70))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(11, 430, 59, 70))); |
| - EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 431, 60, 69))); |
| - |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| child, gfx::Rect(10, 430, 60, 70)).IsEmpty()); |
| - EXPECT_RECT_EQ( |
| + EXPECT_EQ( |
| gfx::Rect(9, 430, 1, 70), |
| occlusion.UnoccludedLayerContentRect(child, gfx::Rect(9, 430, 60, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - child, gfx::Rect(11, 430, 59, 70))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - child, gfx::Rect(10, 431, 60, 69))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(child, |
| + gfx::Rect(11, 430, 59, 70))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(child, |
| + gfx::Rect(10, 431, 60, 69))); |
| this->LeaveContributingSurface(child, &occlusion); |
| this->EnterLayer(parent, &occlusion); |
| @@ -1238,24 +1103,20 @@ class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren |
| EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); |
| - |
| EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| parent, gfx::Rect(30, 40, 70, 60)).IsEmpty()); |
| - EXPECT_RECT_EQ(gfx::Rect(29, 40, 1, 60), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(29, 40, 70, 60))); |
| - EXPECT_RECT_EQ(gfx::Rect(30, 39, 70, 1), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 39, 70, 60))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(31, 40, 69, 60))); |
| - EXPECT_RECT_EQ(gfx::Rect(), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(30, 41, 70, 59))); |
| + EXPECT_EQ(gfx::Rect(29, 40, 1, 60), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(29, 40, 70, 60))); |
| + EXPECT_EQ(gfx::Rect(30, 39, 70, 1), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(30, 39, 70, 60))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(31, 40, 69, 60))); |
| + EXPECT_EQ(gfx::Rect(), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(30, 41, 70, 59))); |
| /* Justification for the above occlusion from |layer1| and |layer2|: |
| @@ -1293,29 +1154,20 @@ class OcclusionTrackerTestOverlappingSurfaceSiblings |
| explicit OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaque_layers) |
| : OcclusionTrackerTest<Types>(opaque_layers) {} |
| void RunMyTest() { |
| - gfx::Transform child_transform; |
| - child_transform.Translate(250.0, 250.0); |
| - child_transform.Rotate(90.0); |
| - child_transform.Translate(-250.0, -250.0); |
| - |
| typename Types::ContentLayerType* parent = this->CreateRoot( |
| this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| parent->SetMasksToBounds(true); |
| typename Types::LayerType* child1 = this->CreateSurface( |
| - parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(10, 10)); |
| + parent, this->identity_matrix, gfx::PointF(10.f, 0.f), gfx::Size()); |
| typename Types::LayerType* child2 = this->CreateSurface( |
| - parent, child_transform, gfx::PointF(20.f, 40.f), gfx::Size(10, 10)); |
| - typename Types::ContentLayerType* layer1 = |
| - this->CreateDrawingLayer(child1, |
| - this->identity_matrix, |
| - gfx::PointF(-10.f, -10.f), |
| - gfx::Size(510, 510), |
| - true); |
| + parent, this->identity_matrix, gfx::PointF(30.f, 0.f), gfx::Size()); |
| + typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer( |
| + child1, this->identity_matrix, gfx::PointF(), gfx::Size(40, 50), true); |
| typename Types::ContentLayerType* layer2 = |
| this->CreateDrawingLayer(child2, |
| this->identity_matrix, |
| - gfx::PointF(-10.f, -10.f), |
| - gfx::Size(510, 510), |
| + gfx::PointF(10.f, 0.f), |
| + gfx::Size(40, 50), |
| true); |
| this->CalcDrawEtc(parent); |
| @@ -1325,72 +1177,30 @@ class OcclusionTrackerTestOverlappingSurfaceSiblings |
| this->VisitLayer(layer2, &occlusion); |
| this->EnterContributingSurface(child2, &occlusion); |
| + // layer2's occlusion. |
| EXPECT_EQ(gfx::Rect().ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), |
| + EXPECT_EQ(gfx::Rect(10, 0, 40, 50).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - // There is nothing above child2's surface in the z-order. |
| - EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - child2, false, gfx::Rect(-10, 420, 70, 80))); |
| - |
| this->LeaveContributingSurface(child2, &occlusion); |
| this->VisitLayer(layer1, &occlusion); |
| this->EnterContributingSurface(child1, &occlusion); |
| - EXPECT_EQ(gfx::Rect(0, 430, 70, 80).ToString(), |
| + // layer2's occlusion in the target space of layer1. |
| + EXPECT_EQ(gfx::Rect(30, 0, 40, 50).ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(), |
| + // layer1's occlusion. |
| + EXPECT_EQ(gfx::Rect(0, 0, 40, 50).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - // child2's contents will occlude child1 below it. |
| - EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - child1, false, gfx::Rect(-10, 430, 80, 70))); |
| - |
| this->LeaveContributingSurface(child1, &occlusion); |
| this->EnterLayer(parent, &occlusion); |
| - EXPECT_EQ(gfx::Rect().ToString(), |
| - occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)) |
| - .ToString(), |
| + // The occlusion from from layer1 and layer2 is merged. |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| + EXPECT_EQ(gfx::Rect(10, 0, 70, 50).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(20, 20, 80, 80))); |
| - |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 20, 70, 80))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 20, 70, 80))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 19, 70, 80))); |
| - |
| - EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(20, 30, 80, 70))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(19, 30, 80, 70))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(20, 29, 80, 70))); |
| - |
| - /* Justification for the above occlusion: |
| - 100 |
| - +---------------------+ |
| - | 20 | layer1 |
| - | 30+ ---------------------------------+ |
| - 100 | 30| | layer2 | |
| - |20+----------------------------------+ | |
| - | | | | | | |
| - | | | | | | |
| - | | | | | | |
| - +--|-|----------------+ | | |
| - | | | | 510 |
| - | | | | |
| - | | | | |
| - | | | | |
| - | | | | |
| - | | | | |
| - | | | | |
| - | +--------------------------------|-+ |
| - | | |
| - +----------------------------------+ |
| - 510 |
| - */ |
| } |
| }; |
| @@ -1454,9 +1264,9 @@ class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms |
| this->EnterContributingSurface(child2, &occlusion); |
| // There is nothing above child2's surface in the z-order. |
| - EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - child2, false, gfx::Rect(-10, 420, 70, 80))); |
| + EXPECT_EQ(gfx::Rect(-10, 420, 70, 80), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + child2, false, gfx::Rect(-10, 420, 70, 80))); |
| this->LeaveContributingSurface(child2, &occlusion); |
| this->VisitLayer(layer1, &occlusion); |
| @@ -1620,14 +1430,10 @@ class OcclusionTrackerTestReplicaDoesOcclude |
| void RunMyTest() { |
| typename Types::ContentLayerType* parent = this->CreateRoot( |
| this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
| - typename Types::LayerType* surface = |
| - this->CreateDrawingSurface(parent, |
| - this->identity_matrix, |
| - gfx::PointF(0.f, 100.f), |
| - gfx::Size(50, 50), |
| - true); |
| + typename Types::LayerType* surface = this->CreateDrawingSurface( |
| + parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), true); |
| this->CreateReplicaLayer( |
| - surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); |
| + surface, this->identity_matrix, gfx::PointF(0.f, 50.f), gfx::Size()); |
| this->CalcDrawEtc(parent); |
| TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| @@ -1642,10 +1448,8 @@ class OcclusionTrackerTestReplicaDoesOcclude |
| this->EnterLayer(parent, &occlusion); |
| // The surface and replica should both be occluding the parent. |
| - EXPECT_EQ( |
| - UnionRegions(gfx::Rect(0, 100, 50, 50), |
| - gfx::Rect(50, 150, 50, 50)).ToString(), |
| - occlusion.occlusion_from_inside_target().ToString()); |
| + EXPECT_EQ(gfx::Rect(50, 100).ToString(), |
| + occlusion.occlusion_from_inside_target().ToString()); |
| } |
| }; |
| @@ -1668,7 +1472,7 @@ class OcclusionTrackerTestReplicaWithClipping |
| gfx::Size(50, 50), |
| true); |
| this->CreateReplicaLayer( |
| - surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); |
| + surface, this->identity_matrix, gfx::PointF(0.f, 50.f), gfx::Size()); |
| this->CalcDrawEtc(parent); |
| TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| @@ -1676,17 +1480,19 @@ class OcclusionTrackerTestReplicaWithClipping |
| this->VisitLayer(surface, &occlusion); |
| + // The surface layer's occlusion in its own space. |
| EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| this->VisitContributingSurface(surface, &occlusion); |
| this->EnterLayer(parent, &occlusion); |
| - // The surface and replica should both be occluding the parent. |
| - EXPECT_EQ( |
| - UnionRegions(gfx::Rect(0, 100, 50, 50), |
| - gfx::Rect(50, 150, 50, 20)).ToString(), |
| - occlusion.occlusion_from_inside_target().ToString()); |
| + // The surface and replica should both be occluding the parent, the |
| + // replica's occlusion is clipped by the parent. |
| + EXPECT_EQ(gfx::Rect(0, 100, 50, 70).ToString(), |
| + occlusion.occlusion_from_inside_target().ToString()); |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| } |
| }; |
| @@ -1752,16 +1558,15 @@ class OcclusionTrackerTestOpaqueContentsRegionEmpty |
| gfx::Rect(0, 0, 1000, 1000)); |
| this->EnterLayer(layer, &occlusion); |
| - EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); |
| - EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| + EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| this->LeaveLayer(layer, &occlusion); |
| this->VisitContributingSurface(layer, &occlusion); |
| this->EnterLayer(parent, &occlusion); |
| EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| + EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| } |
| }; |
| @@ -1794,13 +1599,6 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty |
| EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - |
| - EXPECT_FALSE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); |
| - EXPECT_TRUE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); |
| - EXPECT_FALSE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); |
| } |
| { |
| TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| @@ -1813,13 +1611,6 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty |
| EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - |
| - EXPECT_FALSE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); |
| - EXPECT_FALSE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); |
| - EXPECT_TRUE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); |
| } |
| { |
| TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| @@ -1832,13 +1623,6 @@ class OcclusionTrackerTestOpaqueContentsRegionNonEmpty |
| EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - |
| - EXPECT_FALSE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); |
| - EXPECT_FALSE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); |
| - EXPECT_FALSE( |
| - occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); |
| } |
| } |
| }; |
| @@ -1872,7 +1656,7 @@ class OcclusionTrackerTest3dTransform : public OcclusionTrackerTest<Types> { |
| // The layer is rotated in 3d but without preserving 3d, so it only gets |
| // resized. |
| - EXPECT_RECT_EQ( |
| + EXPECT_EQ( |
| gfx::Rect(0, 0, 200, 200), |
| occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); |
| } |
| @@ -1966,7 +1750,7 @@ class OcclusionTrackerTestPerspectiveTransform |
| gfx::Rect(0, 0, 1000, 1000)); |
| this->EnterLayer(layer, &occlusion); |
| - EXPECT_RECT_EQ( |
| + EXPECT_EQ( |
| gfx::Rect(0, 0, 200, 200), |
| occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); |
| } |
| @@ -2195,18 +1979,18 @@ class OcclusionTrackerTestAnimationOpacity1OnMainThread |
| occlusion.occlusion_from_inside_target().ToString()); |
| EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), |
| - occlusion.UnoccludedLayerContentRect( |
| - surface_child, gfx::Rect(0, 0, 200, 300))); |
| + EXPECT_EQ(gfx::Rect(100, 0, 100, 300), |
| + occlusion.UnoccludedLayerContentRect(surface_child, |
| + gfx::Rect(0, 0, 200, 300))); |
| this->LeaveLayer(surface_child, &occlusion); |
| this->EnterLayer(surface, &occlusion); |
| EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), |
| - occlusion.UnoccludedLayerContentRect( |
| - surface, gfx::Rect(0, 0, 300, 300))); |
| + EXPECT_EQ(gfx::Rect(200, 0, 50, 300), |
| + occlusion.UnoccludedLayerContentRect(surface, |
| + gfx::Rect(0, 0, 300, 300))); |
| this->LeaveLayer(surface, &occlusion); |
| this->EnterContributingSurface(surface, &occlusion); |
| @@ -2215,9 +1999,9 @@ class OcclusionTrackerTestAnimationOpacity1OnMainThread |
| occlusion.occlusion_from_inside_target().ToString()); |
| EXPECT_EQ(gfx::Rect().ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface, false, gfx::Rect(0, 0, 300, 300))); |
| + EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface, false, gfx::Rect(0, 0, 300, 300))); |
| this->LeaveContributingSurface(surface, &occlusion); |
| // Occlusion from outside the animating surface still exists. |
| @@ -2230,9 +2014,9 @@ class OcclusionTrackerTestAnimationOpacity1OnMainThread |
| this->EnterLayer(parent, &occlusion); |
| // Occlusion is not added for the animating |layer|. |
| - EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(0, 0, 300, 300))); |
| + EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(0, 0, 300, 300))); |
| } |
| }; |
| @@ -2304,9 +2088,9 @@ class OcclusionTrackerTestAnimationOpacity0OnMainThread |
| occlusion.occlusion_from_inside_target().ToString()); |
| EXPECT_EQ(gfx::Rect().ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(0, 0, 300, 300))); |
| + EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(0, 0, 300, 300))); |
| this->LeaveLayer(parent2, &occlusion); |
| this->VisitLayer(surface_child2, &occlusion); |
| @@ -2315,18 +2099,18 @@ class OcclusionTrackerTestAnimationOpacity0OnMainThread |
| occlusion.occlusion_from_inside_target().ToString()); |
| EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), |
| - occlusion.UnoccludedLayerContentRect( |
| - surface_child, gfx::Rect(0, 0, 200, 300))); |
| + EXPECT_EQ(gfx::Rect(100, 0, 100, 300), |
| + occlusion.UnoccludedLayerContentRect(surface_child, |
| + gfx::Rect(0, 0, 200, 300))); |
| this->LeaveLayer(surface_child, &occlusion); |
| this->EnterLayer(surface, &occlusion); |
| EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), |
| - occlusion.UnoccludedLayerContentRect( |
| - surface, gfx::Rect(0, 0, 300, 300))); |
| + EXPECT_EQ(gfx::Rect(200, 0, 50, 300), |
| + occlusion.UnoccludedLayerContentRect(surface, |
| + gfx::Rect(0, 0, 300, 300))); |
| this->LeaveLayer(surface, &occlusion); |
| this->EnterContributingSurface(surface, &occlusion); |
| @@ -2335,9 +2119,9 @@ class OcclusionTrackerTestAnimationOpacity0OnMainThread |
| occlusion.occlusion_from_inside_target().ToString()); |
| EXPECT_EQ(gfx::Rect().ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface, false, gfx::Rect(0, 0, 300, 300))); |
| + EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface, false, gfx::Rect(0, 0, 300, 300))); |
| this->LeaveContributingSurface(surface, &occlusion); |
| // Occlusion from outside the animating surface still exists. |
| @@ -2350,9 +2134,9 @@ class OcclusionTrackerTestAnimationOpacity0OnMainThread |
| this->EnterLayer(parent, &occlusion); |
| // Occlusion is not added for the animating |layer|. |
| - EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
| - occlusion.UnoccludedLayerContentRect( |
| - parent, gfx::Rect(0, 0, 300, 300))); |
| + EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| + occlusion.UnoccludedLayerContentRect(parent, |
| + gfx::Rect(0, 0, 300, 300))); |
| } |
| }; |
| @@ -2527,8 +2311,8 @@ class OcclusionTrackerTestSurfaceOcclusionTranslatesToParent |
| occlusion.occlusion_from_inside_target().ToString()); |
| // Clear any stored occlusion. |
| - occlusion.set_occlusion_from_outside_target(Region()); |
| - occlusion.set_occlusion_from_inside_target(Region()); |
| + occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| + occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| this->VisitLayer(surface, &occlusion); |
| this->VisitContributingSurface(surface, &occlusion); |
| @@ -2627,9 +2411,9 @@ class OcclusionTrackerTestReplicaOccluded : public OcclusionTrackerTest<Types> { |
| this->EnterContributingSurface(surface, &occlusion); |
| // Surface is not occluded so it shouldn't think it is. |
| - EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface, false, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface, false, gfx::Rect(0, 0, 100, 100))); |
| } |
| }; |
| @@ -2684,12 +2468,12 @@ class OcclusionTrackerTestSurfaceWithReplicaUnoccluded |
| this->EnterContributingSurface(surface, &occlusion); |
| // Surface is occluded, but only the top 10px of the replica. |
| - EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface, false, gfx::Rect(0, 0, 100, 100))); |
| - EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface, true, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface, false, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_EQ(gfx::Rect(0, 10, 100, 90), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface, true, gfx::Rect(0, 0, 100, 100))); |
| } |
| }; |
| @@ -2704,7 +2488,7 @@ class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently |
| : OcclusionTrackerTest<Types>(opaque_layers) {} |
| void RunMyTest() { |
| typename Types::ContentLayerType* parent = this->CreateRoot( |
| - this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
| + this->identity_matrix, gfx::PointF(), gfx::Size(200, 100)); |
| typename Types::LayerType* surface = |
| this->CreateDrawingSurface(parent, |
| this->identity_matrix, |
| @@ -2713,14 +2497,18 @@ class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently |
| true); |
| this->CreateReplicaLayer(surface, |
| this->identity_matrix, |
| - gfx::PointF(0.f, 100.f), |
| + gfx::PointF(100.f, 0.f), |
| gfx::Size(100, 100)); |
| - typename Types::LayerType* over_surface = this->CreateDrawingLayer( |
| - parent, this->identity_matrix, gfx::PointF(), gfx::Size(40, 100), true); |
| + typename Types::LayerType* over_surface = |
| + this->CreateDrawingLayer(parent, |
| + this->identity_matrix, |
| + gfx::PointF(60.f, 0.f), |
| + gfx::Size(40, 100), |
| + true); |
| typename Types::LayerType* over_replica = |
| this->CreateDrawingLayer(parent, |
| this->identity_matrix, |
| - gfx::PointF(0.f, 100.f), |
| + gfx::PointF(100.f, 0.f), |
| gfx::Size(50, 100), |
| true); |
| this->CalcDrawEtc(parent); |
| @@ -2735,8 +2523,7 @@ class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently |
| EXPECT_EQ(gfx::Rect().ToString(), |
| occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 100)) |
| - .ToString(), |
| + EXPECT_EQ(gfx::Rect(60, 0, 90, 100).ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| this->VisitLayer(surface, &occlusion); |
| @@ -2750,12 +2537,12 @@ class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently |
| this->EnterContributingSurface(surface, &occlusion); |
| // Surface and replica are occluded different amounts. |
| - EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface, false, gfx::Rect(0, 0, 100, 100))); |
| - EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface, true, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_EQ(gfx::Rect(0, 0, 60, 100), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface, false, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_EQ(gfx::Rect(50, 0, 50, 100), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface, true, gfx::Rect(0, 0, 100, 100))); |
| } |
| }; |
| @@ -2821,9 +2608,9 @@ class OcclusionTrackerTestSurfaceChildOfSurface |
| // The surface_child's parent does not have a clip rect as it owns a render |
| // surface. Make sure the unoccluded rect does not get clipped away |
| // inappropriately. |
| - EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface_child, false, gfx::Rect(0, 0, 100, 50))); |
| + EXPECT_EQ(gfx::Rect(0, 40, 100, 10), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface_child, false, gfx::Rect(0, 0, 100, 50))); |
| this->LeaveContributingSurface(surface_child, &occlusion); |
| // When the surface_child's occlusion is transformed up to its parent, make |
| @@ -2837,9 +2624,9 @@ class OcclusionTrackerTestSurfaceChildOfSurface |
| this->EnterContributingSurface(surface, &occlusion); |
| // The surface's parent does have a clip rect as it is the root layer. |
| - EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50), |
| - occlusion.UnoccludedSurfaceContentRect( |
| - surface, false, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_EQ(gfx::Rect(0, 50, 100, 50), |
| + occlusion.UnoccludedSurfaceContentRect( |
| + surface, false, gfx::Rect(0, 0, 100, 100))); |
| } |
| }; |
| @@ -2856,146 +2643,113 @@ class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter |
| gfx::Transform scale_by_half; |
| scale_by_half.Scale(0.5, 0.5); |
| - // Make a 50x50 filtered surface that is completely surrounded by opaque |
| - // layers which are above it in the z-order. The surface is scaled to test |
| - // that the pixel moving is done in the target space, where the background |
| - // filter is applied. |
| - typename Types::ContentLayerType* parent = this->CreateRoot( |
| - this->identity_matrix, gfx::PointF(), gfx::Size(200, 150)); |
| - typename Types::LayerType* filtered_surface = |
| - this->CreateDrawingLayer(parent, |
| - scale_by_half, |
| - gfx::PointF(50.f, 50.f), |
| - gfx::Size(100, 100), |
| - false); |
| - typename Types::LayerType* occluding_layer1 = this->CreateDrawingLayer( |
| - parent, this->identity_matrix, gfx::PointF(), gfx::Size(200, 50), true); |
| - typename Types::LayerType* occluding_layer2 = |
| - this->CreateDrawingLayer(parent, |
| - this->identity_matrix, |
| - gfx::PointF(0.f, 100.f), |
| - gfx::Size(200, 50), |
| - true); |
| - typename Types::LayerType* occluding_layer3 = |
| - this->CreateDrawingLayer(parent, |
| - this->identity_matrix, |
| - gfx::PointF(0.f, 50.f), |
| - gfx::Size(50, 50), |
| - true); |
| - typename Types::LayerType* occluding_layer4 = |
| - this->CreateDrawingLayer(parent, |
| - this->identity_matrix, |
| - gfx::PointF(100.f, 50.f), |
| - gfx::Size(100, 50), |
| - true); |
| - |
| - // Filters make the layer own a surface. |
| FilterOperations filters; |
| filters.Append(FilterOperation::CreateBlurFilter(10.f)); |
| - filtered_surface->SetBackgroundFilters(filters); |
| // Save the distance of influence for the blur effect. |
| int outset_top, outset_right, outset_bottom, outset_left; |
| filters.GetOutsets( |
| &outset_top, &outset_right, &outset_bottom, &outset_left); |
| - this->CalcDrawEtc(parent); |
| - |
| - TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| - gfx::Rect(0, 0, 1000, 1000)); |
| - |
| - // These layers occlude pixels directly beside the filtered_surface. Because |
| - // filtered surface blends pixels in a radius, it will need to see some of |
| - // the pixels (up to radius far) underneath the occluding layers. |
| - this->VisitLayer(occluding_layer4, &occlusion); |
| - this->VisitLayer(occluding_layer3, &occlusion); |
| - this->VisitLayer(occluding_layer2, &occlusion); |
| - this->VisitLayer(occluding_layer1, &occlusion); |
| - |
| - Region expected_occlusion; |
| - expected_occlusion.Union(gfx::Rect(0, 0, 200, 50)); |
| - expected_occlusion.Union(gfx::Rect(0, 50, 50, 50)); |
| - expected_occlusion.Union(gfx::Rect(100, 50, 100, 50)); |
| - expected_occlusion.Union(gfx::Rect(0, 100, 200, 50)); |
| - |
| - EXPECT_EQ(expected_occlusion.ToString(), |
| - occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect().ToString(), |
| - occlusion.occlusion_from_outside_target().ToString()); |
| - |
| - this->VisitLayer(filtered_surface, &occlusion); |
| - |
| - // The filtered layer does not occlude. |
| - Region expected_occlusion_outside_surface; |
| - expected_occlusion_outside_surface.Union(gfx::Rect(-50, -50, 200, 50)); |
| - expected_occlusion_outside_surface.Union(gfx::Rect(-50, 0, 50, 50)); |
| - expected_occlusion_outside_surface.Union(gfx::Rect(50, 0, 100, 50)); |
| - expected_occlusion_outside_surface.Union(gfx::Rect(-50, 50, 200, 50)); |
| + enum Direction { |
| + LEFT, |
| + RIGHT, |
| + TOP, |
| + BOTTOM, |
| + LAST_DIRECTION = BOTTOM, |
| + }; |
| + |
| + for (int i = 0; i <= LAST_DIRECTION; ++i) { |
| + SCOPED_TRACE(i); |
| + |
| + // Make a 50x50 filtered surface that is adjacent to occluding layers |
|
danakj
2014/08/21 01:28:27
I did this test in 4 passes so we can test each si
|
| + // which are above it in the z-order in various configurations. The |
| + // surface isscaled to test that the pixel moving is done in the target |
| + // space, where the background filter is applied. |
| + typename Types::ContentLayerType* parent = this->CreateRoot( |
| + this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| + typename Types::LayerType* filtered_surface = |
| + this->CreateDrawingLayer(parent, |
| + scale_by_half, |
| + gfx::PointF(50.f, 50.f), |
| + gfx::Size(100, 100), |
| + false); |
| + filtered_surface->SetBackgroundFilters(filters); |
| + |
| + gfx::Rect occlusion_rect; |
| + switch (i) { |
| + case LEFT: |
| + occlusion_rect = gfx::Rect(0, 0, 50, 200); |
| + break; |
| + case RIGHT: |
| + occlusion_rect = gfx::Rect(100, 0, 50, 200); |
| + break; |
| + case TOP: |
| + occlusion_rect = gfx::Rect(0, 0, 200, 50); |
| + break; |
| + case BOTTOM: |
| + occlusion_rect = gfx::Rect(0, 100, 200, 50); |
| + break; |
| + } |
| + |
| + typename Types::LayerType* occluding_layer = |
| + this->CreateDrawingLayer(parent, |
| + this->identity_matrix, |
| + occlusion_rect.origin(), |
| + occlusion_rect.size(), |
| + true); |
| + this->CalcDrawEtc(parent); |
| - EXPECT_EQ(expected_occlusion_outside_surface.ToString(), |
| - occlusion.occlusion_from_outside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect().ToString(), |
| - occlusion.occlusion_from_inside_target().ToString()); |
| + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| + gfx::Rect(0, 0, 200, 200)); |
| - // The surface has a background blur, so it needs pixels that are currently |
| - // considered occluded in order to be drawn. So the pixels it needs should |
| - // be removed some the occluded area so that when we get to the parent they |
| - // are drawn. |
| - this->VisitContributingSurface(filtered_surface, &occlusion); |
| + // This layer occludes pixels directly beside the filtered_surface. |
| + // Because filtered surface blends pixels in a radius, it will need to see |
| + // some of the pixels (up to radius far) underneath the occluding layers. |
| + this->VisitLayer(occluding_layer, &occlusion); |
| - this->EnterLayer(parent, &occlusion); |
| + EXPECT_EQ(occlusion_rect.ToString(), |
| + occlusion.occlusion_from_inside_target().ToString()); |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| - Region expected_blurred_occlusion; |
| - expected_blurred_occlusion.Union(gfx::Rect(0, 0, 200, 50 - outset_top)); |
| - expected_blurred_occlusion.Union(gfx::Rect( |
| - 0, 50 - outset_top, 50 - outset_left, 50 + outset_top + outset_bottom)); |
| - expected_blurred_occlusion.Union( |
| - gfx::Rect(100 + outset_right, |
| - 50 - outset_top, |
| - 100 - outset_right, |
| - 50 + outset_top + outset_bottom)); |
| - expected_blurred_occlusion.Union( |
| - gfx::Rect(0, 100 + outset_bottom, 200, 50 - outset_bottom)); |
| + this->VisitLayer(filtered_surface, &occlusion); |
| - EXPECT_EQ(expected_blurred_occlusion.ToString(), |
| - occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect().ToString(), |
| - occlusion.occlusion_from_outside_target().ToString()); |
| + // The occlusion is used fully inside the surface. |
| + gfx::Rect occlusion_inside_surface = |
| + occlusion_rect - gfx::Vector2d(50, 50); |
| + EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| + EXPECT_EQ(occlusion_inside_surface.ToString(), |
| + occlusion.occlusion_from_outside_target().ToString()); |
| - gfx::Rect outset_rect; |
| - gfx::Rect test_rect; |
| + // The surface has a background blur, so it needs pixels that are |
| + // currently considered occluded in order to be drawn. So the pixels it |
| + // needs should be removed some the occluded area so that when we get to |
| + // the parent they are drawn. |
| + this->VisitContributingSurface(filtered_surface, &occlusion); |
| + this->EnterLayer(parent, &occlusion); |
| - // Nothing in the blur outsets for the filtered_surface is occluded. |
| - outset_rect = gfx::Rect(50 - outset_left, |
| - 50 - outset_top, |
| - 50 + outset_left + outset_right, |
| - 50 + outset_top + outset_bottom); |
| - test_rect = outset_rect; |
| - EXPECT_EQ( |
| - outset_rect.ToString(), |
| - occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); |
| + gfx::Rect expected_occlusion = occlusion_rect; |
| + switch (i) { |
| + case LEFT: |
| + expected_occlusion.Inset(0, 0, outset_right, 0); |
| + break; |
| + case RIGHT: |
| + expected_occlusion.Inset(outset_right, 0, 0, 0); |
| + break; |
| + case TOP: |
| + expected_occlusion.Inset(0, 0, 0, outset_right); |
| + break; |
| + case BOTTOM: |
| + expected_occlusion.Inset(0, outset_right, 0, 0); |
| + break; |
| + } |
| + |
| + EXPECT_EQ(expected_occlusion.ToString(), |
| + occlusion.occlusion_from_inside_target().ToString()); |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| - // Stuff outside the blur outsets is still occluded though. |
| - test_rect = outset_rect; |
| - test_rect.Inset(0, 0, -1, 0); |
| - EXPECT_EQ( |
| - outset_rect.ToString(), |
| - occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); |
| - test_rect = outset_rect; |
| - test_rect.Inset(0, 0, 0, -1); |
| - EXPECT_EQ( |
| - outset_rect.ToString(), |
| - occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); |
| - test_rect = outset_rect; |
| - test_rect.Inset(-1, 0, 0, 0); |
| - EXPECT_EQ( |
| - outset_rect.ToString(), |
| - occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); |
| - test_rect = outset_rect; |
| - test_rect.Inset(0, -1, 0, 0); |
| - EXPECT_EQ( |
| - outset_rect.ToString(), |
| - occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); |
| + this->DestroyLayers(); |
| + } |
| } |
| }; |
| @@ -3133,21 +2887,28 @@ class OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter |
| this->VisitContributingSurface(filtered_surface, &occlusion); |
| this->VisitLayer(behind_replica_layer, &occlusion); |
| - this->VisitLayer(behind_surface_layer, &occlusion); |
| // The layers behind the surface are not blurred, and their occlusion does |
| // not change, until we leave the surface. So it should not be modified by |
| // the filter here. |
| - gfx::Rect occlusion_behind_surface = gfx::Rect(60, 60, 30, 30); |
| gfx::Rect occlusion_behind_replica = gfx::Rect(210, 60, 30, 30); |
| - |
| - Region expected_opaque_bounds = |
| - UnionRegions(occlusion_behind_surface, occlusion_behind_replica); |
| - EXPECT_EQ(expected_opaque_bounds.ToString(), |
| + EXPECT_EQ(occlusion_behind_replica.ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| - EXPECT_EQ(gfx::Rect().ToString(), |
| - occlusion.occlusion_from_outside_target().ToString()); |
| + // Clear the occlusion so the |behind_surface_layer| can add its occlusion |
| + // without existing occlusion interfering. |
| + occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| + |
| + this->VisitLayer(behind_surface_layer, &occlusion); |
| + |
| + // The layers behind the surface are not blurred, and their occlusion does |
| + // not change, until we leave the surface. So it should not be modified by |
| + // the filter here. |
| + gfx::Rect occlusion_behind_surface = gfx::Rect(60, 60, 30, 30); |
| + EXPECT_EQ(occlusion_behind_surface.ToString(), |
| + occlusion.occlusion_from_inside_target().ToString()); |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| } |
| }; |
| @@ -3318,24 +3079,21 @@ class OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded |
| gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10); |
| gfx::Rect occlusion_beside_replica = gfx::Rect(200, 40, 10, 10); |
| - Region expected_occlusion; |
| - expected_occlusion.Union(occlusion_above_surface); |
| - expected_occlusion.Union(occlusion_above_replica); |
| - expected_occlusion.Union(occlusion_beside_surface); |
| + SimpleEnclosedRegion expected_occlusion; |
| expected_occlusion.Union(occlusion_beside_replica); |
| + expected_occlusion.Union(occlusion_beside_surface); |
| + expected_occlusion.Union(occlusion_above_replica); |
| + expected_occlusion.Union(occlusion_above_surface); |
| - ASSERT_EQ(expected_occlusion.ToString(), |
| + EXPECT_EQ(expected_occlusion.ToString(), |
| occlusion.occlusion_from_inside_target().ToString()); |
| - EXPECT_EQ(gfx::Rect().ToString(), |
| - occlusion.occlusion_from_outside_target().ToString()); |
| + EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| - Region::Iterator expected_rects(expected_occlusion); |
| - Region::Iterator target_surface_rects( |
| - occlusion.occlusion_from_inside_target()); |
| - for (; expected_rects.has_rect(); |
| - expected_rects.next(), target_surface_rects.next()) { |
| - ASSERT_TRUE(target_surface_rects.has_rect()); |
| - EXPECT_EQ(expected_rects.rect(), target_surface_rects.rect()); |
| + const SimpleEnclosedRegion& actual_occlusion = |
| + occlusion.occlusion_from_inside_target(); |
| + for (size_t i = 0; i < expected_occlusion.GetRegionComplexity(); ++i) { |
| + ASSERT_LT(i, actual_occlusion.GetRegionComplexity()); |
| + EXPECT_EQ(expected_occlusion.GetRect(i), actual_occlusion.GetRect(i)); |
| } |
| } |
| }; |
| @@ -3561,5 +3319,95 @@ class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude |
| ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) |
| +template <class Types> |
| +class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest<Types> { |
| + protected: |
| + explicit OcclusionTrackerTestOccludedLayer(bool opaque_layers) |
| + : OcclusionTrackerTest<Types>(opaque_layers) {} |
| + void RunMyTest() { |
| + gfx::Transform translate; |
| + translate.Translate(10.0, 20.0); |
| + typename Types::ContentLayerType* root = this->CreateRoot( |
| + this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); |
| + typename Types::LayerType* surface = this->CreateSurface( |
| + root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); |
| + typename Types::LayerType* layer = this->CreateDrawingLayer( |
| + surface, translate, gfx::Point(), gfx::Size(200, 200), false); |
| + typename Types::ContentLayerType* outside_layer = this->CreateDrawingLayer( |
| + root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false); |
| + this->CalcDrawEtc(root); |
| + |
| + TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| + gfx::Rect(0, 0, 200, 200)); |
| + this->VisitLayer(outside_layer, &occlusion); |
| + this->EnterLayer(layer, &occlusion); |
| + |
| + // No occlusion, is not occluded. |
| + occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| + occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100))); |
| + |
| + // Partial occlusion from outside, is not occluded. |
| + occlusion.set_occlusion_from_outside_target( |
| + SimpleEnclosedRegion(50, 50, 100, 100)); |
| + occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| + |
| + // Full occlusion from outside, is occluded. |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| + |
| + // Partial occlusion from inside, is not occluded. |
| + occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| + occlusion.set_occlusion_from_inside_target( |
| + SimpleEnclosedRegion(50, 50, 100, 100)); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| + |
| + // Full occlusion from inside, is occluded. |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| + |
| + // Partial occlusion from both, is not occluded. |
| + occlusion.set_occlusion_from_outside_target( |
| + SimpleEnclosedRegion(50, 50, 100, 50)); |
| + occlusion.set_occlusion_from_inside_target( |
| + SimpleEnclosedRegion(50, 100, 100, 50)); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); |
| + EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); |
| + |
| + // Full occlusion from both, is occluded. |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); |
| + EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); |
| + } |
| +}; |
| + |
| +ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOccludedLayer) |
| + |
| } // namespace |
| } // namespace cc |