Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/occlusion_tracker.h" | 5 #include "cc/trees/occlusion_tracker.h" |
| 6 | 6 |
| 7 #include "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
| 8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 namespace cc { | 27 namespace cc { |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class TestContentLayer : public Layer { | 30 class TestContentLayer : public Layer { |
| 31 public: | 31 public: |
| 32 TestContentLayer() : Layer(), override_opaque_contents_rect_(false) { | 32 TestContentLayer() : Layer(), override_opaque_contents_rect_(false) { |
| 33 SetIsDrawable(true); | 33 SetIsDrawable(true); |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual Region VisibleContentOpaqueRegion() const OVERRIDE { | 36 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const OVERRIDE { |
| 37 if (override_opaque_contents_rect_) | 37 if (override_opaque_contents_rect_) { |
| 38 return gfx::IntersectRects(opaque_contents_rect_, visible_content_rect()); | 38 return SimpleEnclosedRegion( |
| 39 gfx::IntersectRects(opaque_contents_rect_, visible_content_rect())); | |
| 40 } | |
| 39 return Layer::VisibleContentOpaqueRegion(); | 41 return Layer::VisibleContentOpaqueRegion(); |
| 40 } | 42 } |
| 41 void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { | 43 void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { |
| 42 override_opaque_contents_rect_ = true; | 44 override_opaque_contents_rect_ = true; |
| 43 opaque_contents_rect_ = opaque_contents_rect; | 45 opaque_contents_rect_ = opaque_contents_rect; |
| 44 } | 46 } |
| 45 | 47 |
| 46 private: | 48 private: |
| 47 virtual ~TestContentLayer() {} | 49 virtual ~TestContentLayer() {} |
| 48 | 50 |
| 49 bool override_opaque_contents_rect_; | 51 bool override_opaque_contents_rect_; |
| 50 gfx::Rect opaque_contents_rect_; | 52 gfx::Rect opaque_contents_rect_; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 class TestContentLayerImpl : public LayerImpl { | 55 class TestContentLayerImpl : public LayerImpl { |
| 54 public: | 56 public: |
| 55 TestContentLayerImpl(LayerTreeImpl* tree_impl, int id) | 57 TestContentLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 56 : LayerImpl(tree_impl, id), override_opaque_contents_rect_(false) { | 58 : LayerImpl(tree_impl, id), override_opaque_contents_rect_(false) { |
| 57 SetDrawsContent(true); | 59 SetDrawsContent(true); |
| 58 } | 60 } |
| 59 | 61 |
| 60 virtual Region VisibleContentOpaqueRegion() const OVERRIDE { | 62 virtual SimpleEnclosedRegion VisibleContentOpaqueRegion() const OVERRIDE { |
| 61 if (override_opaque_contents_rect_) | 63 if (override_opaque_contents_rect_) { |
| 62 return gfx::IntersectRects(opaque_contents_rect_, visible_content_rect()); | 64 return SimpleEnclosedRegion( |
| 65 gfx::IntersectRects(opaque_contents_rect_, visible_content_rect())); | |
| 66 } | |
| 63 return LayerImpl::VisibleContentOpaqueRegion(); | 67 return LayerImpl::VisibleContentOpaqueRegion(); |
| 64 } | 68 } |
| 65 void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { | 69 void SetOpaqueContentsRect(const gfx::Rect& opaque_contents_rect) { |
| 66 override_opaque_contents_rect_ = true; | 70 override_opaque_contents_rect_ = true; |
| 67 opaque_contents_rect_ = opaque_contents_rect; | 71 opaque_contents_rect_ = opaque_contents_rect; |
| 68 } | 72 } |
| 69 | 73 |
| 70 private: | 74 private: |
| 71 bool override_opaque_contents_rect_; | 75 bool override_opaque_contents_rect_; |
| 72 gfx::Rect opaque_contents_rect_; | 76 gfx::Rect opaque_contents_rect_; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 | 176 |
| 173 int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; | 177 int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; |
| 174 | 178 |
| 175 template <typename Types> class OcclusionTrackerTest : public testing::Test { | 179 template <typename Types> class OcclusionTrackerTest : public testing::Test { |
| 176 protected: | 180 protected: |
| 177 explicit OcclusionTrackerTest(bool opaque_layers) | 181 explicit OcclusionTrackerTest(bool opaque_layers) |
| 178 : opaque_layers_(opaque_layers), host_(FakeLayerTreeHost::Create()) {} | 182 : opaque_layers_(opaque_layers), host_(FakeLayerTreeHost::Create()) {} |
| 179 | 183 |
| 180 virtual void RunMyTest() = 0; | 184 virtual void RunMyTest() = 0; |
| 181 | 185 |
| 182 virtual void TearDown() { | 186 virtual void TearDown() { DestroyLayers(); } |
| 183 Types::DestroyLayer(&root_); | |
| 184 render_surface_layer_list_.reset(); | |
| 185 render_surface_layer_list_impl_.clear(); | |
| 186 replica_layers_.clear(); | |
| 187 mask_layers_.clear(); | |
| 188 } | |
| 189 | 187 |
| 190 typename Types::HostType* GetHost(); | 188 typename Types::HostType* GetHost(); |
| 191 | 189 |
| 192 typename Types::ContentLayerType* CreateRoot(const gfx::Transform& transform, | 190 typename Types::ContentLayerType* CreateRoot(const gfx::Transform& transform, |
| 193 const gfx::PointF& position, | 191 const gfx::PointF& position, |
| 194 const gfx::Size& bounds) { | 192 const gfx::Size& bounds) { |
| 195 typename Types::ContentLayerPtrType layer( | 193 typename Types::ContentLayerPtrType layer( |
| 196 Types::CreateContentLayer(GetHost())); | 194 Types::CreateContentLayer(GetHost())); |
| 197 typename Types::ContentLayerType* layer_ptr = layer.get(); | 195 typename Types::ContentLayerType* layer_ptr = layer.get(); |
| 198 SetProperties(layer_ptr, transform, position, bounds); | 196 SetProperties(layer_ptr, transform, position, bounds); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 const gfx::Transform& transform, | 278 const gfx::Transform& transform, |
| 281 const gfx::PointF& position, | 279 const gfx::PointF& position, |
| 282 const gfx::Size& bounds, | 280 const gfx::Size& bounds, |
| 283 bool opaque) { | 281 bool opaque) { |
| 284 typename Types::ContentLayerType* layer = | 282 typename Types::ContentLayerType* layer = |
| 285 CreateDrawingLayer(parent, transform, position, bounds, opaque); | 283 CreateDrawingLayer(parent, transform, position, bounds, opaque); |
| 286 layer->SetForceRenderSurface(true); | 284 layer->SetForceRenderSurface(true); |
| 287 return layer; | 285 return layer; |
| 288 } | 286 } |
| 289 | 287 |
| 288 void DestroyLayers() { | |
| 289 Types::DestroyLayer(&root_); | |
| 290 render_surface_layer_list_.reset(); | |
| 291 render_surface_layer_list_impl_.clear(); | |
| 292 replica_layers_.clear(); | |
| 293 mask_layers_.clear(); | |
| 294 ResetLayerIterator(); | |
| 295 } | |
| 290 | 296 |
| 291 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} | 297 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} |
| 292 | 298 |
| 293 void AddCopyRequest(Layer* layer) { | 299 void AddCopyRequest(Layer* layer) { |
| 294 layer->RequestCopyOfOutput( | 300 layer->RequestCopyOfOutput( |
| 295 CopyOutputRequest::CreateBitmapRequest(base::Bind( | 301 CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 296 &OcclusionTrackerTest<Types>::CopyOutputCallback, | 302 &OcclusionTrackerTest<Types>::CopyOutputCallback, |
| 297 base::Unretained(this)))); | 303 base::Unretained(this)))); |
| 298 } | 304 } |
| 299 | 305 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 329 root, root->bounds(), render_surface_layer_list_.get()); | 335 root, root->bounds(), render_surface_layer_list_.get()); |
| 330 inputs.can_adjust_raster_scales = true; | 336 inputs.can_adjust_raster_scales = true; |
| 331 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 337 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 332 | 338 |
| 333 layer_iterator_ = layer_iterator_begin_ = | 339 layer_iterator_ = layer_iterator_begin_ = |
| 334 Types::TestLayerIterator::Begin(render_surface_layer_list_.get()); | 340 Types::TestLayerIterator::Begin(render_surface_layer_list_.get()); |
| 335 } | 341 } |
| 336 | 342 |
| 337 void EnterLayer(typename Types::LayerType* layer, | 343 void EnterLayer(typename Types::LayerType* layer, |
| 338 typename Types::OcclusionTrackerType* occlusion) { | 344 typename Types::OcclusionTrackerType* occlusion) { |
| 339 ASSERT_EQ(layer, *layer_iterator_); | 345 ASSERT_EQ(*layer_iterator_, layer); |
| 340 ASSERT_TRUE(layer_iterator_.represents_itself()); | 346 ASSERT_TRUE(layer_iterator_.represents_itself()); |
| 341 occlusion->EnterLayer(layer_iterator_); | 347 occlusion->EnterLayer(layer_iterator_); |
| 342 } | 348 } |
| 343 | 349 |
| 344 void LeaveLayer(typename Types::LayerType* layer, | 350 void LeaveLayer(typename Types::LayerType* layer, |
| 345 typename Types::OcclusionTrackerType* occlusion) { | 351 typename Types::OcclusionTrackerType* occlusion) { |
| 346 ASSERT_EQ(layer, *layer_iterator_); | 352 ASSERT_EQ(*layer_iterator_, layer); |
| 347 ASSERT_TRUE(layer_iterator_.represents_itself()); | 353 ASSERT_TRUE(layer_iterator_.represents_itself()); |
| 348 occlusion->LeaveLayer(layer_iterator_); | 354 occlusion->LeaveLayer(layer_iterator_); |
| 349 ++layer_iterator_; | 355 ++layer_iterator_; |
| 350 } | 356 } |
| 351 | 357 |
| 352 void VisitLayer(typename Types::LayerType* layer, | 358 void VisitLayer(typename Types::LayerType* layer, |
| 353 typename Types::OcclusionTrackerType* occlusion) { | 359 typename Types::OcclusionTrackerType* occlusion) { |
| 354 EnterLayer(layer, occlusion); | 360 EnterLayer(layer, occlusion); |
| 355 LeaveLayer(layer, occlusion); | 361 LeaveLayer(layer, occlusion); |
| 356 } | 362 } |
| 357 | 363 |
| 358 void EnterContributingSurface( | 364 void EnterContributingSurface( |
| 359 typename Types::LayerType* layer, | 365 typename Types::LayerType* layer, |
| 360 typename Types::OcclusionTrackerType* occlusion) { | 366 typename Types::OcclusionTrackerType* occlusion) { |
| 361 ASSERT_EQ(layer, *layer_iterator_); | 367 ASSERT_EQ(*layer_iterator_, layer); |
| 362 ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); | 368 ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); |
| 363 occlusion->EnterLayer(layer_iterator_); | 369 occlusion->EnterLayer(layer_iterator_); |
| 364 occlusion->LeaveLayer(layer_iterator_); | 370 occlusion->LeaveLayer(layer_iterator_); |
| 365 ++layer_iterator_; | 371 ++layer_iterator_; |
| 366 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); | 372 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
| 367 occlusion->EnterLayer(layer_iterator_); | 373 occlusion->EnterLayer(layer_iterator_); |
| 368 } | 374 } |
| 369 | 375 |
| 370 void LeaveContributingSurface( | 376 void LeaveContributingSurface( |
| 371 typename Types::LayerType* layer, | 377 typename Types::LayerType* layer, |
| 372 typename Types::OcclusionTrackerType* occlusion) { | 378 typename Types::OcclusionTrackerType* occlusion) { |
| 373 ASSERT_EQ(layer, *layer_iterator_); | 379 ASSERT_EQ(*layer_iterator_, layer); |
| 374 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); | 380 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
| 375 occlusion->LeaveLayer(layer_iterator_); | 381 occlusion->LeaveLayer(layer_iterator_); |
| 376 ++layer_iterator_; | 382 ++layer_iterator_; |
| 377 } | 383 } |
| 378 | 384 |
| 379 void VisitContributingSurface( | 385 void VisitContributingSurface( |
| 380 typename Types::LayerType* layer, | 386 typename Types::LayerType* layer, |
| 381 typename Types::OcclusionTrackerType* occlusion) { | 387 typename Types::OcclusionTrackerType* occlusion) { |
| 382 EnterContributingSurface(layer, occlusion); | 388 EnterContributingSurface(layer, occlusion); |
| 383 LeaveContributingSurface(layer, occlusion); | 389 LeaveContributingSurface(layer, occlusion); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 gfx::Rect(0, 0, 1000, 1000)); | 543 gfx::Rect(0, 0, 1000, 1000)); |
| 538 | 544 |
| 539 this->VisitLayer(layer, &occlusion); | 545 this->VisitLayer(layer, &occlusion); |
| 540 this->EnterLayer(parent, &occlusion); | 546 this->EnterLayer(parent, &occlusion); |
| 541 | 547 |
| 542 EXPECT_EQ(gfx::Rect().ToString(), | 548 EXPECT_EQ(gfx::Rect().ToString(), |
| 543 occlusion.occlusion_from_outside_target().ToString()); | 549 occlusion.occlusion_from_outside_target().ToString()); |
| 544 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), | 550 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 545 occlusion.occlusion_from_inside_target().ToString()); | 551 occlusion.occlusion_from_inside_target().ToString()); |
| 546 | 552 |
| 547 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); | |
| 548 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); | |
| 549 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); | |
| 550 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 69, 70))); | |
| 551 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 31, 70, 69))); | |
| 552 | |
| 553 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 553 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 554 parent, gfx::Rect(30, 30, 70, 70)).IsEmpty()); | 554 parent, gfx::Rect(30, 30, 70, 70)).IsEmpty()); |
| 555 EXPECT_RECT_EQ(gfx::Rect(29, 30, 1, 70), | 555 EXPECT_EQ(gfx::Rect(29, 30, 1, 70), |
| 556 occlusion.UnoccludedLayerContentRect( | 556 occlusion.UnoccludedLayerContentRect(parent, |
| 557 parent, gfx::Rect(29, 30, 70, 70))); | 557 gfx::Rect(29, 30, 70, 70))); |
| 558 EXPECT_RECT_EQ(gfx::Rect(29, 29, 70, 70), | 558 EXPECT_EQ(gfx::Rect(29, 29, 70, 70), |
| 559 occlusion.UnoccludedLayerContentRect( | 559 occlusion.UnoccludedLayerContentRect(parent, |
| 560 parent, gfx::Rect(29, 29, 70, 70))); | 560 gfx::Rect(29, 29, 70, 70))); |
| 561 EXPECT_RECT_EQ(gfx::Rect(30, 29, 70, 1), | 561 EXPECT_EQ(gfx::Rect(30, 29, 70, 1), |
| 562 occlusion.UnoccludedLayerContentRect( | 562 occlusion.UnoccludedLayerContentRect(parent, |
| 563 parent, gfx::Rect(30, 29, 70, 70))); | 563 gfx::Rect(30, 29, 70, 70))); |
| 564 EXPECT_RECT_EQ(gfx::Rect(31, 29, 69, 1), | 564 EXPECT_EQ(gfx::Rect(31, 29, 69, 1), |
| 565 occlusion.UnoccludedLayerContentRect( | 565 occlusion.UnoccludedLayerContentRect(parent, |
| 566 parent, gfx::Rect(31, 29, 69, 70))); | 566 gfx::Rect(31, 29, 69, 70))); |
| 567 EXPECT_RECT_EQ(gfx::Rect(), | 567 EXPECT_EQ(gfx::Rect(), |
| 568 occlusion.UnoccludedLayerContentRect( | 568 occlusion.UnoccludedLayerContentRect(parent, |
| 569 parent, gfx::Rect(31, 30, 69, 70))); | 569 gfx::Rect(31, 30, 69, 70))); |
| 570 EXPECT_RECT_EQ(gfx::Rect(), | 570 EXPECT_EQ(gfx::Rect(), |
| 571 occlusion.UnoccludedLayerContentRect( | 571 occlusion.UnoccludedLayerContentRect(parent, |
| 572 parent, gfx::Rect(31, 31, 69, 69))); | 572 gfx::Rect(31, 31, 69, 69))); |
| 573 EXPECT_RECT_EQ(gfx::Rect(), | 573 EXPECT_EQ(gfx::Rect(), |
| 574 occlusion.UnoccludedLayerContentRect( | 574 occlusion.UnoccludedLayerContentRect(parent, |
| 575 parent, gfx::Rect(30, 31, 70, 69))); | 575 gfx::Rect(30, 31, 70, 69))); |
| 576 EXPECT_RECT_EQ(gfx::Rect(29, 31, 1, 69), | 576 EXPECT_EQ(gfx::Rect(29, 31, 1, 69), |
| 577 occlusion.UnoccludedLayerContentRect( | 577 occlusion.UnoccludedLayerContentRect(parent, |
| 578 parent, gfx::Rect(29, 31, 70, 69))); | 578 gfx::Rect(29, 31, 70, 69))); |
| 579 } | 579 } |
| 580 }; | 580 }; |
| 581 | 581 |
| 582 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestIdentityTransforms); | 582 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestIdentityTransforms); |
| 583 | 583 |
| 584 template <class Types> | 584 template <class Types> |
| 585 class OcclusionTrackerTestQuadsMismatchLayer | 585 class OcclusionTrackerTestQuadsMismatchLayer |
| 586 : public OcclusionTrackerTest<Types> { | 586 : public OcclusionTrackerTest<Types> { |
| 587 protected: | 587 protected: |
| 588 explicit OcclusionTrackerTestQuadsMismatchLayer(bool opaque_layers) | 588 explicit OcclusionTrackerTestQuadsMismatchLayer(bool opaque_layers) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 612 | 612 |
| 613 // This checks cases where the quads don't match their "containing" | 613 // This checks cases where the quads don't match their "containing" |
| 614 // layers, e.g. in terms of transforms or clip rect. This is typical for | 614 // layers, e.g. in terms of transforms or clip rect. This is typical for |
| 615 // DelegatedRendererLayer. | 615 // DelegatedRendererLayer. |
| 616 | 616 |
| 617 gfx::Transform quad_transform; | 617 gfx::Transform quad_transform; |
| 618 quad_transform.Translate(30.0, 30.0); | 618 quad_transform.Translate(30.0, 30.0); |
| 619 | 619 |
| 620 EXPECT_TRUE(occlusion.UnoccludedContentRect(gfx::Rect(0, 0, 10, 10), | 620 EXPECT_TRUE(occlusion.UnoccludedContentRect(gfx::Rect(0, 0, 10, 10), |
| 621 quad_transform).IsEmpty()); | 621 quad_transform).IsEmpty()); |
| 622 EXPECT_RECT_EQ(gfx::Rect(40, 40, 10, 10), | 622 EXPECT_EQ(gfx::Rect(40, 40, 10, 10), |
| 623 occlusion.UnoccludedContentRect(gfx::Rect(40, 40, 10, 10), | 623 occlusion.UnoccludedContentRect(gfx::Rect(40, 40, 10, 10), |
| 624 quad_transform)); | 624 quad_transform)); |
| 625 EXPECT_RECT_EQ(gfx::Rect(40, 30, 5, 10), | 625 EXPECT_EQ(gfx::Rect(40, 30, 5, 10), |
| 626 occlusion.UnoccludedContentRect(gfx::Rect(35, 30, 10, 10), | 626 occlusion.UnoccludedContentRect(gfx::Rect(35, 30, 10, 10), |
| 627 quad_transform)); | 627 quad_transform)); |
| 628 } | 628 } |
| 629 }; | 629 }; |
| 630 | 630 |
| 631 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestQuadsMismatchLayer); | 631 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestQuadsMismatchLayer); |
| 632 | 632 |
| 633 template <class Types> | 633 template <class Types> |
| 634 class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest<Types> { | 634 class OcclusionTrackerTestRotatedChild : public OcclusionTrackerTest<Types> { |
| 635 protected: | 635 protected: |
| 636 explicit OcclusionTrackerTestRotatedChild(bool opaque_layers) | 636 explicit OcclusionTrackerTestRotatedChild(bool opaque_layers) |
| 637 : OcclusionTrackerTest<Types>(opaque_layers) {} | 637 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 658 gfx::Rect(0, 0, 1000, 1000)); | 658 gfx::Rect(0, 0, 1000, 1000)); |
| 659 | 659 |
| 660 this->VisitLayer(layer, &occlusion); | 660 this->VisitLayer(layer, &occlusion); |
| 661 this->EnterLayer(parent, &occlusion); | 661 this->EnterLayer(parent, &occlusion); |
| 662 | 662 |
| 663 EXPECT_EQ(gfx::Rect().ToString(), | 663 EXPECT_EQ(gfx::Rect().ToString(), |
| 664 occlusion.occlusion_from_outside_target().ToString()); | 664 occlusion.occlusion_from_outside_target().ToString()); |
| 665 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), | 665 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
| 666 occlusion.occlusion_from_inside_target().ToString()); | 666 occlusion.occlusion_from_inside_target().ToString()); |
| 667 | 667 |
| 668 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); | |
| 669 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); | |
| 670 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); | |
| 671 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 69, 70))); | |
| 672 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 31, 70, 69))); | |
| 673 | |
| 674 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 668 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 675 parent, gfx::Rect(30, 30, 70, 70)).IsEmpty()); | 669 parent, gfx::Rect(30, 30, 70, 70)).IsEmpty()); |
| 676 EXPECT_RECT_EQ(gfx::Rect(29, 30, 1, 70), | 670 EXPECT_EQ(gfx::Rect(29, 30, 1, 70), |
| 677 occlusion.UnoccludedLayerContentRect( | 671 occlusion.UnoccludedLayerContentRect(parent, |
| 678 parent, gfx::Rect(29, 30, 69, 70))); | 672 gfx::Rect(29, 30, 69, 70))); |
| 679 EXPECT_RECT_EQ(gfx::Rect(29, 29, 70, 70), | 673 EXPECT_EQ(gfx::Rect(29, 29, 70, 70), |
| 680 occlusion.UnoccludedLayerContentRect( | 674 occlusion.UnoccludedLayerContentRect(parent, |
| 681 parent, gfx::Rect(29, 29, 70, 70))); | 675 gfx::Rect(29, 29, 70, 70))); |
| 682 EXPECT_RECT_EQ(gfx::Rect(30, 29, 70, 1), | 676 EXPECT_EQ(gfx::Rect(30, 29, 70, 1), |
| 683 occlusion.UnoccludedLayerContentRect( | 677 occlusion.UnoccludedLayerContentRect(parent, |
| 684 parent, gfx::Rect(30, 29, 70, 70))); | 678 gfx::Rect(30, 29, 70, 70))); |
| 685 EXPECT_RECT_EQ(gfx::Rect(31, 29, 69, 1), | 679 EXPECT_EQ(gfx::Rect(31, 29, 69, 1), |
| 686 occlusion.UnoccludedLayerContentRect( | 680 occlusion.UnoccludedLayerContentRect(parent, |
| 687 parent, gfx::Rect(31, 29, 69, 70))); | 681 gfx::Rect(31, 29, 69, 70))); |
| 688 EXPECT_RECT_EQ(gfx::Rect(), | 682 EXPECT_EQ(gfx::Rect(), |
| 689 occlusion.UnoccludedLayerContentRect( | 683 occlusion.UnoccludedLayerContentRect(parent, |
| 690 parent, gfx::Rect(31, 30, 69, 70))); | 684 gfx::Rect(31, 30, 69, 70))); |
| 691 EXPECT_RECT_EQ(gfx::Rect(), | 685 EXPECT_EQ(gfx::Rect(), |
| 692 occlusion.UnoccludedLayerContentRect( | 686 occlusion.UnoccludedLayerContentRect(parent, |
| 693 parent, gfx::Rect(31, 31, 69, 69))); | 687 gfx::Rect(31, 31, 69, 69))); |
| 694 EXPECT_RECT_EQ(gfx::Rect(), | 688 EXPECT_EQ(gfx::Rect(), |
| 695 occlusion.UnoccludedLayerContentRect( | 689 occlusion.UnoccludedLayerContentRect(parent, |
| 696 parent, gfx::Rect(30, 31, 70, 69))); | 690 gfx::Rect(30, 31, 70, 69))); |
| 697 EXPECT_RECT_EQ(gfx::Rect(29, 31, 1, 69), | 691 EXPECT_EQ(gfx::Rect(29, 31, 1, 69), |
| 698 occlusion.UnoccludedLayerContentRect( | 692 occlusion.UnoccludedLayerContentRect(parent, |
| 699 parent, gfx::Rect(29, 31, 70, 69))); | 693 gfx::Rect(29, 31, 70, 69))); |
| 700 } | 694 } |
| 701 }; | 695 }; |
| 702 | 696 |
| 703 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRotatedChild); | 697 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestRotatedChild); |
| 704 | 698 |
| 705 template <class Types> | 699 template <class Types> |
| 706 class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest<Types> { | 700 class OcclusionTrackerTestTranslatedChild : public OcclusionTrackerTest<Types> { |
| 707 protected: | 701 protected: |
| 708 explicit OcclusionTrackerTestTranslatedChild(bool opaque_layers) | 702 explicit OcclusionTrackerTestTranslatedChild(bool opaque_layers) |
| 709 : OcclusionTrackerTest<Types>(opaque_layers) {} | 703 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 728 gfx::Rect(0, 0, 1000, 1000)); | 722 gfx::Rect(0, 0, 1000, 1000)); |
| 729 | 723 |
| 730 this->VisitLayer(layer, &occlusion); | 724 this->VisitLayer(layer, &occlusion); |
| 731 this->EnterLayer(parent, &occlusion); | 725 this->EnterLayer(parent, &occlusion); |
| 732 | 726 |
| 733 EXPECT_EQ(gfx::Rect().ToString(), | 727 EXPECT_EQ(gfx::Rect().ToString(), |
| 734 occlusion.occlusion_from_outside_target().ToString()); | 728 occlusion.occlusion_from_outside_target().ToString()); |
| 735 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), | 729 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), |
| 736 occlusion.occlusion_from_inside_target().ToString()); | 730 occlusion.occlusion_from_inside_target().ToString()); |
| 737 | 731 |
| 738 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(50, 50, 50, 50))); | |
| 739 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(49, 50, 50, 50))); | |
| 740 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(50, 49, 50, 50))); | |
| 741 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(51, 50, 49, 50))); | |
| 742 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(50, 51, 50, 49))); | |
| 743 | |
| 744 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 732 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 745 parent, gfx::Rect(50, 50, 50, 50)).IsEmpty()); | 733 parent, gfx::Rect(50, 50, 50, 50)).IsEmpty()); |
| 746 EXPECT_RECT_EQ(gfx::Rect(49, 50, 1, 50), | 734 EXPECT_EQ(gfx::Rect(49, 50, 1, 50), |
| 747 occlusion.UnoccludedLayerContentRect( | 735 occlusion.UnoccludedLayerContentRect(parent, |
| 748 parent, gfx::Rect(49, 50, 50, 50))); | 736 gfx::Rect(49, 50, 50, 50))); |
| 749 EXPECT_RECT_EQ(gfx::Rect(49, 49, 50, 50), | 737 EXPECT_EQ(gfx::Rect(49, 49, 50, 50), |
| 750 occlusion.UnoccludedLayerContentRect( | 738 occlusion.UnoccludedLayerContentRect(parent, |
| 751 parent, gfx::Rect(49, 49, 50, 50))); | 739 gfx::Rect(49, 49, 50, 50))); |
| 752 EXPECT_RECT_EQ(gfx::Rect(50, 49, 50, 1), | 740 EXPECT_EQ(gfx::Rect(50, 49, 50, 1), |
| 753 occlusion.UnoccludedLayerContentRect( | 741 occlusion.UnoccludedLayerContentRect(parent, |
| 754 parent, gfx::Rect(50, 49, 50, 50))); | 742 gfx::Rect(50, 49, 50, 50))); |
| 755 EXPECT_RECT_EQ(gfx::Rect(51, 49, 49, 1), | 743 EXPECT_EQ(gfx::Rect(51, 49, 49, 1), |
| 756 occlusion.UnoccludedLayerContentRect( | 744 occlusion.UnoccludedLayerContentRect(parent, |
| 757 parent, gfx::Rect(51, 49, 49, 50))); | 745 gfx::Rect(51, 49, 49, 50))); |
| 758 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 746 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 759 parent, gfx::Rect(51, 50, 49, 50)).IsEmpty()); | 747 parent, gfx::Rect(51, 50, 49, 50)).IsEmpty()); |
| 760 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 748 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 761 parent, gfx::Rect(51, 51, 49, 49)).IsEmpty()); | 749 parent, gfx::Rect(51, 51, 49, 49)).IsEmpty()); |
| 762 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 750 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 763 parent, gfx::Rect(50, 51, 50, 49)).IsEmpty()); | 751 parent, gfx::Rect(50, 51, 50, 49)).IsEmpty()); |
| 764 EXPECT_RECT_EQ(gfx::Rect(49, 51, 1, 49), | 752 EXPECT_EQ(gfx::Rect(49, 51, 1, 49), |
| 765 occlusion.UnoccludedLayerContentRect( | 753 occlusion.UnoccludedLayerContentRect(parent, |
| 766 parent, gfx::Rect(49, 51, 50, 49))); | 754 gfx::Rect(49, 51, 50, 49))); |
| 767 } | 755 } |
| 768 }; | 756 }; |
| 769 | 757 |
| 770 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTranslatedChild); | 758 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestTranslatedChild); |
| 771 | 759 |
| 772 template <class Types> | 760 template <class Types> |
| 773 class OcclusionTrackerTestChildInRotatedChild | 761 class OcclusionTrackerTestChildInRotatedChild |
| 774 : public OcclusionTrackerTest<Types> { | 762 : public OcclusionTrackerTest<Types> { |
| 775 protected: | 763 protected: |
| 776 explicit OcclusionTrackerTestChildInRotatedChild(bool opaque_layers) | 764 explicit OcclusionTrackerTestChildInRotatedChild(bool opaque_layers) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 807 occlusion.occlusion_from_inside_target().ToString()); | 795 occlusion.occlusion_from_inside_target().ToString()); |
| 808 | 796 |
| 809 this->LeaveContributingSurface(child, &occlusion); | 797 this->LeaveContributingSurface(child, &occlusion); |
| 810 this->EnterLayer(parent, &occlusion); | 798 this->EnterLayer(parent, &occlusion); |
| 811 | 799 |
| 812 EXPECT_EQ(gfx::Rect().ToString(), | 800 EXPECT_EQ(gfx::Rect().ToString(), |
| 813 occlusion.occlusion_from_outside_target().ToString()); | 801 occlusion.occlusion_from_outside_target().ToString()); |
| 814 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), | 802 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
| 815 occlusion.occlusion_from_inside_target().ToString()); | 803 occlusion.occlusion_from_inside_target().ToString()); |
| 816 | 804 |
| 817 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); | |
| 818 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); | |
| 819 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); | |
| 820 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 40, 69, 60))); | |
| 821 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 41, 70, 59))); | |
| 822 | |
| 823 /* Justification for the above occlusion from |layer|: | 805 /* Justification for the above occlusion from |layer|: |
| 824 100 | 806 100 |
| 825 +---------------------+ | 807 +---------------------+ |
| 826 | | | 808 | | |
| 827 | 30 | rotate(90) | 809 | 30 | rotate(90) |
| 828 | 30 + ---------------------------------+ | 810 | 30 + ---------------------------------+ |
| 829 100 | | 10 | | ==> | 811 100 | | 10 | | ==> |
| 830 | |10+---------------------------------+ | 812 | |10+---------------------------------+ |
| 831 | | | | | | | 813 | | | | | | |
| 832 | | | | | | | 814 | | | | | | |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 905 gfx::Rect(0, 0, 1000, 1000)); | 887 gfx::Rect(0, 0, 1000, 1000)); |
| 906 | 888 |
| 907 this->VisitLayer(occluder, &occlusion); | 889 this->VisitLayer(occluder, &occlusion); |
| 908 this->EnterLayer(layer2, &occlusion); | 890 this->EnterLayer(layer2, &occlusion); |
| 909 | 891 |
| 910 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), | 892 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
| 911 occlusion.occlusion_from_outside_target().ToString()); | 893 occlusion.occlusion_from_outside_target().ToString()); |
| 912 EXPECT_EQ(gfx::Rect().ToString(), | 894 EXPECT_EQ(gfx::Rect().ToString(), |
| 913 occlusion.occlusion_from_inside_target().ToString()); | 895 occlusion.occlusion_from_inside_target().ToString()); |
| 914 | 896 |
| 915 EXPECT_RECT_EQ( | 897 EXPECT_EQ( |
| 916 gfx::Rect(0, 0, 25, 25), | 898 gfx::Rect(0, 0, 25, 25), |
| 917 occlusion.UnoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25))); | 899 occlusion.UnoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25))); |
| 918 EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25), | 900 EXPECT_EQ(gfx::Rect(10, 25, 15, 25), |
| 919 occlusion.UnoccludedLayerContentRect( | 901 occlusion.UnoccludedLayerContentRect(layer2, |
| 920 layer2, gfx::Rect(10, 25, 25, 25))); | 902 gfx::Rect(10, 25, 25, 25))); |
| 921 EXPECT_RECT_EQ(gfx::Rect(25, 10, 25, 15), | 903 EXPECT_EQ(gfx::Rect(25, 10, 25, 15), |
| 922 occlusion.UnoccludedLayerContentRect( | 904 occlusion.UnoccludedLayerContentRect(layer2, |
| 923 layer2, gfx::Rect(25, 10, 25, 25))); | 905 gfx::Rect(25, 10, 25, 25))); |
| 924 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 906 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 925 layer2, gfx::Rect(25, 25, 25, 25)).IsEmpty()); | 907 layer2, gfx::Rect(25, 25, 25, 25)).IsEmpty()); |
| 926 } | 908 } |
| 927 }; | 909 }; |
| 928 | 910 |
| 929 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledRenderSurface); | 911 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledRenderSurface); |
| 930 | 912 |
| 931 template <class Types> | 913 template <class Types> |
| 932 class OcclusionTrackerTestVisitTargetTwoTimes | 914 class OcclusionTrackerTestVisitTargetTwoTimes |
| 933 : public OcclusionTrackerTest<Types> { | 915 : public OcclusionTrackerTest<Types> { |
| 934 protected: | 916 protected: |
| 935 explicit OcclusionTrackerTestVisitTargetTwoTimes(bool opaque_layers) | 917 explicit OcclusionTrackerTestVisitTargetTwoTimes(bool opaque_layers) |
| 936 : OcclusionTrackerTest<Types>(opaque_layers) {} | 918 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 937 void RunMyTest() { | 919 void RunMyTest() { |
| 938 gfx::Transform child_transform; | |
| 939 child_transform.Translate(250.0, 250.0); | |
| 940 child_transform.Rotate(90.0); | |
| 941 child_transform.Translate(-250.0, -250.0); | |
| 942 | |
| 943 typename Types::ContentLayerType* root = this->CreateRoot( | 920 typename Types::ContentLayerType* root = this->CreateRoot( |
| 944 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); | 921 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 945 typename Types::ContentLayerType* parent = this->CreateDrawingLayer( | 922 typename Types::LayerType* surface = this->CreateSurface( |
| 946 root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); | 923 root, this->identity_matrix, gfx::PointF(30.f, 30.f), gfx::Size()); |
| 947 parent->SetMasksToBounds(true); | 924 typename Types::ContentLayerType* surface_child = |
| 948 typename Types::LayerType* child = this->CreateSurface( | 925 this->CreateDrawingLayer(surface, |
| 949 parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500)); | |
| 950 child->SetMasksToBounds(true); | |
| 951 typename Types::ContentLayerType* layer = | |
| 952 this->CreateDrawingLayer(child, | |
| 953 this->identity_matrix, | 926 this->identity_matrix, |
| 954 gfx::PointF(10.f, 10.f), | 927 gfx::PointF(10.f, 10.f), |
| 955 gfx::Size(500, 500), | 928 gfx::Size(50, 50), |
| 956 true); | 929 true); |
| 957 // |child2| makes |parent|'s surface get considered by OcclusionTracker | 930 // |top_layer| makes |root|'s surface get considered by OcclusionTracker |
| 958 // first, instead of |child|'s. This exercises different code in | 931 // first, instead of |surface|'s. This exercises different code in |
| 959 // LeaveToRenderTarget, as the target surface has already been seen. | 932 // LeaveToRenderTarget, as the target surface has already been seen when |
| 960 typename Types::ContentLayerType* child2 = | 933 // leaving |surface| later. |
| 961 this->CreateDrawingLayer(parent, | 934 typename Types::ContentLayerType* top_layer = |
| 935 this->CreateDrawingLayer(root, | |
| 962 this->identity_matrix, | 936 this->identity_matrix, |
| 963 gfx::PointF(30.f, 30.f), | 937 gfx::PointF(40.f, 90.f), |
| 964 gfx::Size(60, 20), | 938 gfx::Size(50, 20), |
| 965 true); | 939 true); |
| 966 this->CalcDrawEtc(root); | 940 this->CalcDrawEtc(root); |
| 967 | 941 |
| 968 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 942 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 969 gfx::Rect(0, 0, 1000, 1000)); | 943 gfx::Rect(0, 0, 1000, 1000)); |
| 970 | 944 |
| 971 this->VisitLayer(child2, &occlusion); | 945 this->VisitLayer(top_layer, &occlusion); |
| 972 | 946 |
| 973 EXPECT_EQ(gfx::Rect().ToString(), | 947 EXPECT_EQ(gfx::Rect().ToString(), |
| 974 occlusion.occlusion_from_outside_target().ToString()); | 948 occlusion.occlusion_from_outside_target().ToString()); |
| 975 EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), | 949 EXPECT_EQ(gfx::Rect(40, 90, 50, 20).ToString(), |
| 976 occlusion.occlusion_from_inside_target().ToString()); | 950 occlusion.occlusion_from_inside_target().ToString()); |
| 977 | 951 |
| 978 this->VisitLayer(layer, &occlusion); | 952 this->VisitLayer(surface_child, &occlusion); |
| 979 | 953 |
| 980 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), | 954 EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(), |
| 981 occlusion.occlusion_from_outside_target().ToString()); | 955 occlusion.occlusion_from_outside_target().ToString()); |
| 982 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), | 956 EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
| 983 occlusion.occlusion_from_inside_target().ToString()); | 957 occlusion.occlusion_from_inside_target().ToString()); |
| 984 | 958 |
| 985 this->EnterContributingSurface(child, &occlusion); | 959 this->EnterContributingSurface(surface, &occlusion); |
| 986 | 960 |
| 987 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), | 961 EXPECT_EQ(gfx::Rect(10, 60, 50, 20).ToString(), |
| 988 occlusion.occlusion_from_outside_target().ToString()); | 962 occlusion.occlusion_from_outside_target().ToString()); |
| 989 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), | 963 EXPECT_EQ(gfx::Rect(10, 10, 50, 50).ToString(), |
| 990 occlusion.occlusion_from_inside_target().ToString()); | 964 occlusion.occlusion_from_inside_target().ToString()); |
| 991 | 965 |
| 992 // Occlusion in |child2| should get merged with the |child| surface we are | 966 // Occlusion from |top_layer| already in the root target should get merged |
| 993 // leaving now. | 967 // with the occlusion from the |surface| we are leaving now. |
| 994 this->LeaveContributingSurface(child, &occlusion); | 968 this->LeaveContributingSurface(surface, &occlusion); |
| 995 this->EnterLayer(parent, &occlusion); | 969 this->EnterLayer(root, &occlusion); |
| 996 | 970 |
| 997 EXPECT_EQ(gfx::Rect().ToString(), | 971 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 998 occlusion.occlusion_from_outside_target().ToString()); | 972 EXPECT_EQ(gfx::Rect(40, 40, 50, 70).ToString(), |
| 999 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)) | |
| 1000 .ToString(), | |
| 1001 occlusion.occlusion_from_inside_target().ToString()); | 973 occlusion.occlusion_from_inside_target().ToString()); |
| 1002 | |
| 1003 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); | |
| 1004 EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10), | |
| 1005 occlusion.UnoccludedLayerContentRect( | |
| 1006 parent, gfx::Rect(30, 30, 70, 70))); | |
| 1007 | |
| 1008 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 60, 10))); | |
| 1009 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 60, 10))); | |
| 1010 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 60, 10))); | |
| 1011 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 60, 10))); | |
| 1012 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 31, 60, 10))); | |
| 1013 | |
| 1014 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); | |
| 1015 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); | |
| 1016 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); | |
| 1017 | |
| 1018 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | |
| 1019 parent, gfx::Rect(30, 30, 60, 10)).IsEmpty()); | |
| 1020 EXPECT_RECT_EQ(gfx::Rect(29, 30, 1, 10), | |
| 1021 occlusion.UnoccludedLayerContentRect( | |
| 1022 parent, gfx::Rect(29, 30, 60, 10))); | |
| 1023 EXPECT_RECT_EQ(gfx::Rect(30, 29, 60, 1), | |
| 1024 occlusion.UnoccludedLayerContentRect( | |
| 1025 parent, gfx::Rect(30, 29, 60, 10))); | |
| 1026 EXPECT_RECT_EQ(gfx::Rect(90, 30, 1, 10), | |
| 1027 occlusion.UnoccludedLayerContentRect( | |
| 1028 parent, gfx::Rect(31, 30, 60, 10))); | |
| 1029 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | |
| 1030 parent, gfx::Rect(30, 31, 60, 10)).IsEmpty()); | |
| 1031 | |
| 1032 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | |
| 1033 parent, gfx::Rect(30, 40, 70, 60)).IsEmpty()); | |
| 1034 EXPECT_RECT_EQ(gfx::Rect(29, 40, 1, 60), | |
| 1035 occlusion.UnoccludedLayerContentRect( | |
| 1036 parent, gfx::Rect(29, 40, 70, 60))); | |
| 1037 // This rect is mostly occluded by |child2|. | |
| 1038 EXPECT_RECT_EQ(gfx::Rect(90, 39, 10, 1), | |
| 1039 occlusion.UnoccludedLayerContentRect( | |
| 1040 parent, gfx::Rect(30, 39, 70, 60))); | |
| 1041 // This rect extends past top/right ends of |child2|. | |
| 1042 EXPECT_RECT_EQ(gfx::Rect(30, 29, 70, 11), | |
| 1043 occlusion.UnoccludedLayerContentRect( | |
| 1044 parent, gfx::Rect(30, 29, 70, 70))); | |
| 1045 // This rect extends past left/right ends of |child2|. | |
| 1046 EXPECT_RECT_EQ(gfx::Rect(20, 39, 80, 60), | |
| 1047 occlusion.UnoccludedLayerContentRect( | |
| 1048 parent, gfx::Rect(20, 39, 80, 60))); | |
| 1049 EXPECT_RECT_EQ(gfx::Rect(), | |
| 1050 occlusion.UnoccludedLayerContentRect( | |
| 1051 parent, gfx::Rect(31, 40, 69, 60))); | |
| 1052 EXPECT_RECT_EQ(gfx::Rect(), | |
| 1053 occlusion.UnoccludedLayerContentRect( | |
| 1054 parent, gfx::Rect(30, 41, 70, 59))); | |
| 1055 | |
| 1056 /* Justification for the above occlusion from |layer|: | |
| 1057 100 | |
| 1058 +---------------------+ | |
|
enne (OOO)
2014/08/21 20:48:05
This beautiful ascii art diagram, nuoooo~!
danakj
2014/08/21 21:15:31
Don't worry there is more still xD
| |
| 1059 | | | |
| 1060 | 30 | rotate(90) | |
| 1061 | 30 + ------------+--------------------+ | |
| 1062 100 | | 10 | | | ==> | |
| 1063 | |10+----------|----------------------+ | |
| 1064 | + ------------+ | | | | |
| 1065 | | | | | | | |
| 1066 | | | | | | | |
| 1067 +----|--|-------------+ | | | |
| 1068 | | | | | |
| 1069 | | | | | |
| 1070 | | | |500 | |
| 1071 | | | | | |
| 1072 | | | | | |
| 1073 | | | | | |
| 1074 | | | | | |
| 1075 +--|-------------------------------+ | | |
| 1076 | | | |
| 1077 +---------------------------------+ | |
| 1078 500 | |
| 1079 | |
| 1080 | |
| 1081 +---------------------+ | |
| 1082 | |30 Visible region of |layer|: ///// | |
| 1083 | 30 60 | |child2|: \\\\\ | |
| 1084 | 30 +------------+--------------------+ | |
| 1085 | |\\\\\\\\\\\\| |10 | | |
| 1086 | +--|\\\\\\\\\\\\|-----------------+ | | |
| 1087 | | +------------+//| 420 | | | |
| 1088 | | |///////////////|60 | | | |
| 1089 | | |///////////////| | | | |
| 1090 +--|--|---------------+ | | | |
| 1091 20|10| 70 | | | |
| 1092 | | | | | |
| 1093 | | | | | |
| 1094 | | | | | |
| 1095 | | | | | |
| 1096 | | | | | |
| 1097 | | |10| | |
| 1098 | +------------------------------|--+ | |
| 1099 | 490 | | |
| 1100 +---------------------------------+ | |
| 1101 500 | |
| 1102 */ | |
| 1103 } | 974 } |
| 1104 }; | 975 }; |
| 1105 | 976 |
| 1106 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestVisitTargetTwoTimes); | 977 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestVisitTargetTwoTimes); |
| 1107 | 978 |
| 1108 template <class Types> | 979 template <class Types> |
| 1109 class OcclusionTrackerTestSurfaceRotatedOffAxis | 980 class OcclusionTrackerTestSurfaceRotatedOffAxis |
| 1110 : public OcclusionTrackerTest<Types> { | 981 : public OcclusionTrackerTest<Types> { |
| 1111 protected: | 982 protected: |
| 1112 explicit OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaque_layers) | 983 explicit OcclusionTrackerTestSurfaceRotatedOffAxis(bool opaque_layers) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1146 occlusion.occlusion_from_inside_target().ToString()); | 1017 occlusion.occlusion_from_inside_target().ToString()); |
| 1147 | 1018 |
| 1148 this->LeaveContributingSurface(child, &occlusion); | 1019 this->LeaveContributingSurface(child, &occlusion); |
| 1149 this->EnterLayer(parent, &occlusion); | 1020 this->EnterLayer(parent, &occlusion); |
| 1150 | 1021 |
| 1151 EXPECT_EQ(gfx::Rect().ToString(), | 1022 EXPECT_EQ(gfx::Rect().ToString(), |
| 1152 occlusion.occlusion_from_outside_target().ToString()); | 1023 occlusion.occlusion_from_outside_target().ToString()); |
| 1153 EXPECT_EQ(gfx::Rect().ToString(), | 1024 EXPECT_EQ(gfx::Rect().ToString(), |
| 1154 occlusion.occlusion_from_inside_target().ToString()); | 1025 occlusion.occlusion_from_inside_target().ToString()); |
| 1155 | 1026 |
| 1156 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(75, 55, 1, 1))); | 1027 EXPECT_EQ( |
| 1157 EXPECT_RECT_EQ( | |
| 1158 gfx::Rect(75, 55, 1, 1), | 1028 gfx::Rect(75, 55, 1, 1), |
| 1159 occlusion.UnoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1))); | 1029 occlusion.UnoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1))); |
| 1160 } | 1030 } |
| 1161 }; | 1031 }; |
| 1162 | 1032 |
| 1163 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis); | 1033 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceRotatedOffAxis); |
| 1164 | 1034 |
| 1165 template <class Types> | 1035 template <class Types> |
| 1166 class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren | 1036 class OcclusionTrackerTestSurfaceWithTwoOpaqueChildren |
| 1167 : public OcclusionTrackerTest<Types> { | 1037 : public OcclusionTrackerTest<Types> { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1206 this->VisitLayer(layer2, &occlusion); | 1076 this->VisitLayer(layer2, &occlusion); |
| 1207 this->VisitLayer(layer1, &occlusion); | 1077 this->VisitLayer(layer1, &occlusion); |
| 1208 this->VisitLayer(child, &occlusion); | 1078 this->VisitLayer(child, &occlusion); |
| 1209 this->EnterContributingSurface(child, &occlusion); | 1079 this->EnterContributingSurface(child, &occlusion); |
| 1210 | 1080 |
| 1211 EXPECT_EQ(gfx::Rect().ToString(), | 1081 EXPECT_EQ(gfx::Rect().ToString(), |
| 1212 occlusion.occlusion_from_outside_target().ToString()); | 1082 occlusion.occlusion_from_outside_target().ToString()); |
| 1213 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), | 1083 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
| 1214 occlusion.occlusion_from_inside_target().ToString()); | 1084 occlusion.occlusion_from_inside_target().ToString()); |
| 1215 | 1085 |
| 1216 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 430, 60, 70))); | |
| 1217 EXPECT_FALSE(occlusion.OccludedLayer(child, gfx::Rect(9, 430, 60, 70))); | |
| 1218 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(11, 430, 59, 70))); | |
| 1219 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 431, 60, 69))); | |
| 1220 | |
| 1221 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 1086 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 1222 child, gfx::Rect(10, 430, 60, 70)).IsEmpty()); | 1087 child, gfx::Rect(10, 430, 60, 70)).IsEmpty()); |
| 1223 EXPECT_RECT_EQ( | 1088 EXPECT_EQ( |
| 1224 gfx::Rect(9, 430, 1, 70), | 1089 gfx::Rect(9, 430, 1, 70), |
| 1225 occlusion.UnoccludedLayerContentRect(child, gfx::Rect(9, 430, 60, 70))); | 1090 occlusion.UnoccludedLayerContentRect(child, gfx::Rect(9, 430, 60, 70))); |
| 1226 EXPECT_RECT_EQ(gfx::Rect(), | 1091 EXPECT_EQ(gfx::Rect(), |
| 1227 occlusion.UnoccludedLayerContentRect( | 1092 occlusion.UnoccludedLayerContentRect(child, |
| 1228 child, gfx::Rect(11, 430, 59, 70))); | 1093 gfx::Rect(11, 430, 59, 70))); |
| 1229 EXPECT_RECT_EQ(gfx::Rect(), | 1094 EXPECT_EQ(gfx::Rect(), |
| 1230 occlusion.UnoccludedLayerContentRect( | 1095 occlusion.UnoccludedLayerContentRect(child, |
| 1231 child, gfx::Rect(10, 431, 60, 69))); | 1096 gfx::Rect(10, 431, 60, 69))); |
| 1232 | 1097 |
| 1233 this->LeaveContributingSurface(child, &occlusion); | 1098 this->LeaveContributingSurface(child, &occlusion); |
| 1234 this->EnterLayer(parent, &occlusion); | 1099 this->EnterLayer(parent, &occlusion); |
| 1235 | 1100 |
| 1236 EXPECT_EQ(gfx::Rect().ToString(), | 1101 EXPECT_EQ(gfx::Rect().ToString(), |
| 1237 occlusion.occlusion_from_outside_target().ToString()); | 1102 occlusion.occlusion_from_outside_target().ToString()); |
| 1238 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), | 1103 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
| 1239 occlusion.occlusion_from_inside_target().ToString()); | 1104 occlusion.occlusion_from_inside_target().ToString()); |
| 1240 | 1105 |
| 1241 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); | |
| 1242 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); | |
| 1243 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); | |
| 1244 | |
| 1245 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 1106 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
| 1246 parent, gfx::Rect(30, 40, 70, 60)).IsEmpty()); | 1107 parent, gfx::Rect(30, 40, 70, 60)).IsEmpty()); |
| 1247 EXPECT_RECT_EQ(gfx::Rect(29, 40, 1, 60), | 1108 EXPECT_EQ(gfx::Rect(29, 40, 1, 60), |
| 1248 occlusion.UnoccludedLayerContentRect( | 1109 occlusion.UnoccludedLayerContentRect(parent, |
| 1249 parent, gfx::Rect(29, 40, 70, 60))); | 1110 gfx::Rect(29, 40, 70, 60))); |
| 1250 EXPECT_RECT_EQ(gfx::Rect(30, 39, 70, 1), | 1111 EXPECT_EQ(gfx::Rect(30, 39, 70, 1), |
| 1251 occlusion.UnoccludedLayerContentRect( | 1112 occlusion.UnoccludedLayerContentRect(parent, |
| 1252 parent, gfx::Rect(30, 39, 70, 60))); | 1113 gfx::Rect(30, 39, 70, 60))); |
| 1253 EXPECT_RECT_EQ(gfx::Rect(), | 1114 EXPECT_EQ(gfx::Rect(), |
| 1254 occlusion.UnoccludedLayerContentRect( | 1115 occlusion.UnoccludedLayerContentRect(parent, |
| 1255 parent, gfx::Rect(31, 40, 69, 60))); | 1116 gfx::Rect(31, 40, 69, 60))); |
| 1256 EXPECT_RECT_EQ(gfx::Rect(), | 1117 EXPECT_EQ(gfx::Rect(), |
| 1257 occlusion.UnoccludedLayerContentRect( | 1118 occlusion.UnoccludedLayerContentRect(parent, |
| 1258 parent, gfx::Rect(30, 41, 70, 59))); | 1119 gfx::Rect(30, 41, 70, 59))); |
| 1259 | 1120 |
| 1260 /* Justification for the above occlusion from |layer1| and |layer2|: | 1121 /* Justification for the above occlusion from |layer1| and |layer2|: |
| 1261 | 1122 |
| 1262 +---------------------+ | 1123 +---------------------+ |
| 1263 | |30 Visible region of |layer1|: ///// | 1124 | |30 Visible region of |layer1|: ///// |
| 1264 | | Visible region of |layer2|: \\\\\ | 1125 | | Visible region of |layer2|: \\\\\ |
| 1265 | +---------------------------------+ | 1126 | +---------------------------------+ |
| 1266 | | |10 | | 1127 | | |10 | |
| 1267 | +---------------+-----------------+ | | 1128 | +---------------+-----------------+ | |
| 1268 | | |\\\\\\\\\\\\|//| 420 | | | 1129 | | |\\\\\\\\\\\\|//| 420 | | |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1286 | 1147 |
| 1287 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithTwoOpaqueChildren); | 1148 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithTwoOpaqueChildren); |
| 1288 | 1149 |
| 1289 template <class Types> | 1150 template <class Types> |
| 1290 class OcclusionTrackerTestOverlappingSurfaceSiblings | 1151 class OcclusionTrackerTestOverlappingSurfaceSiblings |
| 1291 : public OcclusionTrackerTest<Types> { | 1152 : public OcclusionTrackerTest<Types> { |
| 1292 protected: | 1153 protected: |
| 1293 explicit OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaque_layers) | 1154 explicit OcclusionTrackerTestOverlappingSurfaceSiblings(bool opaque_layers) |
| 1294 : OcclusionTrackerTest<Types>(opaque_layers) {} | 1155 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1295 void RunMyTest() { | 1156 void RunMyTest() { |
| 1296 gfx::Transform child_transform; | |
| 1297 child_transform.Translate(250.0, 250.0); | |
| 1298 child_transform.Rotate(90.0); | |
| 1299 child_transform.Translate(-250.0, -250.0); | |
| 1300 | |
| 1301 typename Types::ContentLayerType* parent = this->CreateRoot( | 1157 typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1302 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); | 1158 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); |
| 1303 parent->SetMasksToBounds(true); | 1159 parent->SetMasksToBounds(true); |
| 1304 typename Types::LayerType* child1 = this->CreateSurface( | 1160 typename Types::LayerType* child1 = this->CreateSurface( |
| 1305 parent, child_transform, gfx::PointF(30.f, 30.f), gfx::Size(10, 10)); | 1161 parent, this->identity_matrix, gfx::PointF(10.f, 0.f), gfx::Size()); |
| 1306 typename Types::LayerType* child2 = this->CreateSurface( | 1162 typename Types::LayerType* child2 = this->CreateSurface( |
| 1307 parent, child_transform, gfx::PointF(20.f, 40.f), gfx::Size(10, 10)); | 1163 parent, this->identity_matrix, gfx::PointF(30.f, 0.f), gfx::Size()); |
| 1308 typename Types::ContentLayerType* layer1 = | 1164 typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer( |
| 1309 this->CreateDrawingLayer(child1, | 1165 child1, this->identity_matrix, gfx::PointF(), gfx::Size(40, 50), true); |
| 1310 this->identity_matrix, | |
| 1311 gfx::PointF(-10.f, -10.f), | |
| 1312 gfx::Size(510, 510), | |
| 1313 true); | |
| 1314 typename Types::ContentLayerType* layer2 = | 1166 typename Types::ContentLayerType* layer2 = |
| 1315 this->CreateDrawingLayer(child2, | 1167 this->CreateDrawingLayer(child2, |
| 1316 this->identity_matrix, | 1168 this->identity_matrix, |
| 1317 gfx::PointF(-10.f, -10.f), | 1169 gfx::PointF(10.f, 0.f), |
| 1318 gfx::Size(510, 510), | 1170 gfx::Size(40, 50), |
| 1319 true); | 1171 true); |
| 1320 this->CalcDrawEtc(parent); | 1172 this->CalcDrawEtc(parent); |
| 1321 | 1173 |
| 1322 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1174 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1323 gfx::Rect(0, 0, 1000, 1000)); | 1175 gfx::Rect(0, 0, 1000, 1000)); |
| 1324 | 1176 |
| 1325 this->VisitLayer(layer2, &occlusion); | 1177 this->VisitLayer(layer2, &occlusion); |
| 1326 this->EnterContributingSurface(child2, &occlusion); | 1178 this->EnterContributingSurface(child2, &occlusion); |
| 1327 | 1179 |
| 1180 // layer2's occlusion. | |
| 1328 EXPECT_EQ(gfx::Rect().ToString(), | 1181 EXPECT_EQ(gfx::Rect().ToString(), |
| 1329 occlusion.occlusion_from_outside_target().ToString()); | 1182 occlusion.occlusion_from_outside_target().ToString()); |
| 1330 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), | 1183 EXPECT_EQ(gfx::Rect(10, 0, 40, 50).ToString(), |
| 1331 occlusion.occlusion_from_inside_target().ToString()); | 1184 occlusion.occlusion_from_inside_target().ToString()); |
| 1332 | 1185 |
| 1333 // There is nothing above child2's surface in the z-order. | |
| 1334 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), | |
| 1335 occlusion.UnoccludedSurfaceContentRect( | |
| 1336 child2, false, gfx::Rect(-10, 420, 70, 80))); | |
| 1337 | |
| 1338 this->LeaveContributingSurface(child2, &occlusion); | 1186 this->LeaveContributingSurface(child2, &occlusion); |
| 1339 this->VisitLayer(layer1, &occlusion); | 1187 this->VisitLayer(layer1, &occlusion); |
| 1340 this->EnterContributingSurface(child1, &occlusion); | 1188 this->EnterContributingSurface(child1, &occlusion); |
| 1341 | 1189 |
| 1342 EXPECT_EQ(gfx::Rect(0, 430, 70, 80).ToString(), | 1190 // layer2's occlusion in the target space of layer1. |
| 1191 EXPECT_EQ(gfx::Rect(30, 0, 40, 50).ToString(), | |
| 1343 occlusion.occlusion_from_outside_target().ToString()); | 1192 occlusion.occlusion_from_outside_target().ToString()); |
| 1344 EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(), | 1193 // layer1's occlusion. |
| 1194 EXPECT_EQ(gfx::Rect(0, 0, 40, 50).ToString(), | |
| 1345 occlusion.occlusion_from_inside_target().ToString()); | 1195 occlusion.occlusion_from_inside_target().ToString()); |
| 1346 | 1196 |
| 1347 // child2's contents will occlude child1 below it. | |
| 1348 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70), | |
| 1349 occlusion.UnoccludedSurfaceContentRect( | |
| 1350 child1, false, gfx::Rect(-10, 430, 80, 70))); | |
| 1351 | |
| 1352 this->LeaveContributingSurface(child1, &occlusion); | 1197 this->LeaveContributingSurface(child1, &occlusion); |
| 1353 this->EnterLayer(parent, &occlusion); | 1198 this->EnterLayer(parent, &occlusion); |
| 1354 | 1199 |
| 1355 EXPECT_EQ(gfx::Rect().ToString(), | 1200 // The occlusion from from layer1 and layer2 is merged. |
| 1356 occlusion.occlusion_from_outside_target().ToString()); | 1201 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1357 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)) | 1202 EXPECT_EQ(gfx::Rect(10, 0, 70, 50).ToString(), |
| 1358 .ToString(), | |
| 1359 occlusion.occlusion_from_inside_target().ToString()); | 1203 occlusion.occlusion_from_inside_target().ToString()); |
| 1360 | |
| 1361 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(20, 20, 80, 80))); | |
| 1362 | |
| 1363 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 20, 70, 80))); | |
| 1364 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 20, 70, 80))); | |
| 1365 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 19, 70, 80))); | |
| 1366 | |
| 1367 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(20, 30, 80, 70))); | |
| 1368 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(19, 30, 80, 70))); | |
| 1369 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(20, 29, 80, 70))); | |
| 1370 | |
| 1371 /* Justification for the above occlusion: | |
| 1372 100 | |
| 1373 +---------------------+ | |
| 1374 | 20 | layer1 | |
| 1375 | 30+ ---------------------------------+ | |
| 1376 100 | 30| | layer2 | | |
| 1377 |20+----------------------------------+ | | |
| 1378 | | | | | | | |
| 1379 | | | | | | | |
| 1380 | | | | | | | |
| 1381 +--|-|----------------+ | | | |
| 1382 | | | | 510 | |
| 1383 | | | | | |
| 1384 | | | | | |
| 1385 | | | | | |
| 1386 | | | | | |
| 1387 | | | | | |
| 1388 | | | | | |
| 1389 | +--------------------------------|-+ | |
| 1390 | | | |
| 1391 +----------------------------------+ | |
| 1392 510 | |
| 1393 */ | |
| 1394 } | 1204 } |
| 1395 }; | 1205 }; |
| 1396 | 1206 |
| 1397 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOverlappingSurfaceSiblings); | 1207 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOverlappingSurfaceSiblings); |
| 1398 | 1208 |
| 1399 template <class Types> | 1209 template <class Types> |
| 1400 class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms | 1210 class OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms |
| 1401 : public OcclusionTrackerTest<Types> { | 1211 : public OcclusionTrackerTest<Types> { |
| 1402 protected: | 1212 protected: |
| 1403 explicit OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms( | 1213 explicit OcclusionTrackerTestOverlappingSurfaceSiblingsWithTwoTransforms( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1447 | 1257 |
| 1448 EXPECT_EQ(gfx::Rect().ToString(), | 1258 EXPECT_EQ(gfx::Rect().ToString(), |
| 1449 occlusion.occlusion_from_outside_target().ToString()); | 1259 occlusion.occlusion_from_outside_target().ToString()); |
| 1450 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), | 1260 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), |
| 1451 occlusion.occlusion_from_inside_target().ToString()); | 1261 occlusion.occlusion_from_inside_target().ToString()); |
| 1452 | 1262 |
| 1453 this->LeaveLayer(child2, &occlusion); | 1263 this->LeaveLayer(child2, &occlusion); |
| 1454 this->EnterContributingSurface(child2, &occlusion); | 1264 this->EnterContributingSurface(child2, &occlusion); |
| 1455 | 1265 |
| 1456 // There is nothing above child2's surface in the z-order. | 1266 // There is nothing above child2's surface in the z-order. |
| 1457 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), | 1267 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80), |
| 1458 occlusion.UnoccludedSurfaceContentRect( | 1268 occlusion.UnoccludedSurfaceContentRect( |
| 1459 child2, false, gfx::Rect(-10, 420, 70, 80))); | 1269 child2, false, gfx::Rect(-10, 420, 70, 80))); |
| 1460 | 1270 |
| 1461 this->LeaveContributingSurface(child2, &occlusion); | 1271 this->LeaveContributingSurface(child2, &occlusion); |
| 1462 this->VisitLayer(layer1, &occlusion); | 1272 this->VisitLayer(layer1, &occlusion); |
| 1463 this->EnterContributingSurface(child1, &occlusion); | 1273 this->EnterContributingSurface(child1, &occlusion); |
| 1464 | 1274 |
| 1465 EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(), | 1275 EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(), |
| 1466 occlusion.occlusion_from_outside_target().ToString()); | 1276 occlusion.occlusion_from_outside_target().ToString()); |
| 1467 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), | 1277 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), |
| 1468 occlusion.occlusion_from_inside_target().ToString()); | 1278 occlusion.occlusion_from_inside_target().ToString()); |
| 1469 | 1279 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1613 | 1423 |
| 1614 template <class Types> | 1424 template <class Types> |
| 1615 class OcclusionTrackerTestReplicaDoesOcclude | 1425 class OcclusionTrackerTestReplicaDoesOcclude |
| 1616 : public OcclusionTrackerTest<Types> { | 1426 : public OcclusionTrackerTest<Types> { |
| 1617 protected: | 1427 protected: |
| 1618 explicit OcclusionTrackerTestReplicaDoesOcclude(bool opaque_layers) | 1428 explicit OcclusionTrackerTestReplicaDoesOcclude(bool opaque_layers) |
| 1619 : OcclusionTrackerTest<Types>(opaque_layers) {} | 1429 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1620 void RunMyTest() { | 1430 void RunMyTest() { |
| 1621 typename Types::ContentLayerType* parent = this->CreateRoot( | 1431 typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1622 this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); | 1432 this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); |
| 1623 typename Types::LayerType* surface = | 1433 typename Types::LayerType* surface = this->CreateDrawingSurface( |
| 1624 this->CreateDrawingSurface(parent, | 1434 parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), true); |
| 1625 this->identity_matrix, | |
| 1626 gfx::PointF(0.f, 100.f), | |
| 1627 gfx::Size(50, 50), | |
| 1628 true); | |
| 1629 this->CreateReplicaLayer( | 1435 this->CreateReplicaLayer( |
| 1630 surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); | 1436 surface, this->identity_matrix, gfx::PointF(0.f, 50.f), gfx::Size()); |
| 1631 this->CalcDrawEtc(parent); | 1437 this->CalcDrawEtc(parent); |
| 1632 | 1438 |
| 1633 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1439 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1634 gfx::Rect(0, 0, 1000, 1000)); | 1440 gfx::Rect(0, 0, 1000, 1000)); |
| 1635 | 1441 |
| 1636 this->VisitLayer(surface, &occlusion); | 1442 this->VisitLayer(surface, &occlusion); |
| 1637 | 1443 |
| 1638 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 1444 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 1639 occlusion.occlusion_from_inside_target().ToString()); | 1445 occlusion.occlusion_from_inside_target().ToString()); |
| 1640 | 1446 |
| 1641 this->VisitContributingSurface(surface, &occlusion); | 1447 this->VisitContributingSurface(surface, &occlusion); |
| 1642 this->EnterLayer(parent, &occlusion); | 1448 this->EnterLayer(parent, &occlusion); |
| 1643 | 1449 |
| 1644 // The surface and replica should both be occluding the parent. | 1450 // The surface and replica should both be occluding the parent. |
| 1645 EXPECT_EQ( | 1451 EXPECT_EQ(gfx::Rect(50, 100).ToString(), |
| 1646 UnionRegions(gfx::Rect(0, 100, 50, 50), | 1452 occlusion.occlusion_from_inside_target().ToString()); |
| 1647 gfx::Rect(50, 150, 50, 50)).ToString(), | |
| 1648 occlusion.occlusion_from_inside_target().ToString()); | |
| 1649 } | 1453 } |
| 1650 }; | 1454 }; |
| 1651 | 1455 |
| 1652 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude); | 1456 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude); |
| 1653 | 1457 |
| 1654 template <class Types> | 1458 template <class Types> |
| 1655 class OcclusionTrackerTestReplicaWithClipping | 1459 class OcclusionTrackerTestReplicaWithClipping |
| 1656 : public OcclusionTrackerTest<Types> { | 1460 : public OcclusionTrackerTest<Types> { |
| 1657 protected: | 1461 protected: |
| 1658 explicit OcclusionTrackerTestReplicaWithClipping(bool opaque_layers) | 1462 explicit OcclusionTrackerTestReplicaWithClipping(bool opaque_layers) |
| 1659 : OcclusionTrackerTest<Types>(opaque_layers) {} | 1463 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 1660 void RunMyTest() { | 1464 void RunMyTest() { |
| 1661 typename Types::ContentLayerType* parent = this->CreateRoot( | 1465 typename Types::ContentLayerType* parent = this->CreateRoot( |
| 1662 this->identity_matrix, gfx::PointF(), gfx::Size(100, 170)); | 1466 this->identity_matrix, gfx::PointF(), gfx::Size(100, 170)); |
| 1663 parent->SetMasksToBounds(true); | 1467 parent->SetMasksToBounds(true); |
| 1664 typename Types::LayerType* surface = | 1468 typename Types::LayerType* surface = |
| 1665 this->CreateDrawingSurface(parent, | 1469 this->CreateDrawingSurface(parent, |
| 1666 this->identity_matrix, | 1470 this->identity_matrix, |
| 1667 gfx::PointF(0.f, 100.f), | 1471 gfx::PointF(0.f, 100.f), |
| 1668 gfx::Size(50, 50), | 1472 gfx::Size(50, 50), |
| 1669 true); | 1473 true); |
| 1670 this->CreateReplicaLayer( | 1474 this->CreateReplicaLayer( |
| 1671 surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); | 1475 surface, this->identity_matrix, gfx::PointF(0.f, 50.f), gfx::Size()); |
| 1672 this->CalcDrawEtc(parent); | 1476 this->CalcDrawEtc(parent); |
| 1673 | 1477 |
| 1674 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1478 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1675 gfx::Rect(0, 0, 1000, 1000)); | 1479 gfx::Rect(0, 0, 1000, 1000)); |
| 1676 | 1480 |
| 1677 this->VisitLayer(surface, &occlusion); | 1481 this->VisitLayer(surface, &occlusion); |
| 1678 | 1482 |
| 1483 // The surface layer's occlusion in its own space. | |
| 1679 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 1484 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
| 1680 occlusion.occlusion_from_inside_target().ToString()); | 1485 occlusion.occlusion_from_inside_target().ToString()); |
| 1486 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | |
| 1681 | 1487 |
| 1682 this->VisitContributingSurface(surface, &occlusion); | 1488 this->VisitContributingSurface(surface, &occlusion); |
| 1683 this->EnterLayer(parent, &occlusion); | 1489 this->EnterLayer(parent, &occlusion); |
| 1684 | 1490 |
| 1685 // The surface and replica should both be occluding the parent. | 1491 // The surface and replica should both be occluding the parent, the |
| 1686 EXPECT_EQ( | 1492 // replica's occlusion is clipped by the parent. |
| 1687 UnionRegions(gfx::Rect(0, 100, 50, 50), | 1493 EXPECT_EQ(gfx::Rect(0, 100, 50, 70).ToString(), |
| 1688 gfx::Rect(50, 150, 50, 20)).ToString(), | 1494 occlusion.occlusion_from_inside_target().ToString()); |
| 1689 occlusion.occlusion_from_inside_target().ToString()); | 1495 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1690 } | 1496 } |
| 1691 }; | 1497 }; |
| 1692 | 1498 |
| 1693 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping); | 1499 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping); |
| 1694 | 1500 |
| 1695 template <class Types> | 1501 template <class Types> |
| 1696 class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> { | 1502 class OcclusionTrackerTestReplicaWithMask : public OcclusionTrackerTest<Types> { |
| 1697 protected: | 1503 protected: |
| 1698 explicit OcclusionTrackerTestReplicaWithMask(bool opaque_layers) | 1504 explicit OcclusionTrackerTestReplicaWithMask(bool opaque_layers) |
| 1699 : OcclusionTrackerTest<Types>(opaque_layers) {} | 1505 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1745 this->identity_matrix, | 1551 this->identity_matrix, |
| 1746 gfx::PointF(), | 1552 gfx::PointF(), |
| 1747 gfx::Size(200, 200), | 1553 gfx::Size(200, 200), |
| 1748 false); | 1554 false); |
| 1749 this->CalcDrawEtc(parent); | 1555 this->CalcDrawEtc(parent); |
| 1750 | 1556 |
| 1751 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1557 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1752 gfx::Rect(0, 0, 1000, 1000)); | 1558 gfx::Rect(0, 0, 1000, 1000)); |
| 1753 this->EnterLayer(layer, &occlusion); | 1559 this->EnterLayer(layer, &occlusion); |
| 1754 | 1560 |
| 1755 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); | 1561 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1756 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); | 1562 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
| 1757 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); | |
| 1758 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); | |
| 1759 | 1563 |
| 1760 this->LeaveLayer(layer, &occlusion); | 1564 this->LeaveLayer(layer, &occlusion); |
| 1761 this->VisitContributingSurface(layer, &occlusion); | 1565 this->VisitContributingSurface(layer, &occlusion); |
| 1762 this->EnterLayer(parent, &occlusion); | 1566 this->EnterLayer(parent, &occlusion); |
| 1763 | 1567 |
| 1764 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1568 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 1569 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | |
| 1765 } | 1570 } |
| 1766 }; | 1571 }; |
| 1767 | 1572 |
| 1768 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); | 1573 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); |
| 1769 | 1574 |
| 1770 template <class Types> | 1575 template <class Types> |
| 1771 class OcclusionTrackerTestOpaqueContentsRegionNonEmpty | 1576 class OcclusionTrackerTestOpaqueContentsRegionNonEmpty |
| 1772 : public OcclusionTrackerTest<Types> { | 1577 : public OcclusionTrackerTest<Types> { |
| 1773 protected: | 1578 protected: |
| 1774 explicit OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaque_layers) | 1579 explicit OcclusionTrackerTestOpaqueContentsRegionNonEmpty(bool opaque_layers) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1787 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1592 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1788 gfx::Rect(0, 0, 1000, 1000)); | 1593 gfx::Rect(0, 0, 1000, 1000)); |
| 1789 layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); | 1594 layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); |
| 1790 | 1595 |
| 1791 this->ResetLayerIterator(); | 1596 this->ResetLayerIterator(); |
| 1792 this->VisitLayer(layer, &occlusion); | 1597 this->VisitLayer(layer, &occlusion); |
| 1793 this->EnterLayer(parent, &occlusion); | 1598 this->EnterLayer(parent, &occlusion); |
| 1794 | 1599 |
| 1795 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), | 1600 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
| 1796 occlusion.occlusion_from_inside_target().ToString()); | 1601 occlusion.occlusion_from_inside_target().ToString()); |
| 1797 | |
| 1798 EXPECT_FALSE( | |
| 1799 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); | |
| 1800 EXPECT_TRUE( | |
| 1801 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); | |
| 1802 EXPECT_FALSE( | |
| 1803 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); | |
| 1804 } | 1602 } |
| 1805 { | 1603 { |
| 1806 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1604 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1807 gfx::Rect(0, 0, 1000, 1000)); | 1605 gfx::Rect(0, 0, 1000, 1000)); |
| 1808 layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); | 1606 layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); |
| 1809 | 1607 |
| 1810 this->ResetLayerIterator(); | 1608 this->ResetLayerIterator(); |
| 1811 this->VisitLayer(layer, &occlusion); | 1609 this->VisitLayer(layer, &occlusion); |
| 1812 this->EnterLayer(parent, &occlusion); | 1610 this->EnterLayer(parent, &occlusion); |
| 1813 | 1611 |
| 1814 EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), | 1612 EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), |
| 1815 occlusion.occlusion_from_inside_target().ToString()); | 1613 occlusion.occlusion_from_inside_target().ToString()); |
| 1816 | |
| 1817 EXPECT_FALSE( | |
| 1818 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); | |
| 1819 EXPECT_FALSE( | |
| 1820 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); | |
| 1821 EXPECT_TRUE( | |
| 1822 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); | |
| 1823 } | 1614 } |
| 1824 { | 1615 { |
| 1825 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1616 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1826 gfx::Rect(0, 0, 1000, 1000)); | 1617 gfx::Rect(0, 0, 1000, 1000)); |
| 1827 layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); | 1618 layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); |
| 1828 | 1619 |
| 1829 this->ResetLayerIterator(); | 1620 this->ResetLayerIterator(); |
| 1830 this->VisitLayer(layer, &occlusion); | 1621 this->VisitLayer(layer, &occlusion); |
| 1831 this->EnterLayer(parent, &occlusion); | 1622 this->EnterLayer(parent, &occlusion); |
| 1832 | 1623 |
| 1833 EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), | 1624 EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), |
| 1834 occlusion.occlusion_from_inside_target().ToString()); | 1625 occlusion.occlusion_from_inside_target().ToString()); |
| 1835 | |
| 1836 EXPECT_FALSE( | |
| 1837 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); | |
| 1838 EXPECT_FALSE( | |
| 1839 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); | |
| 1840 EXPECT_FALSE( | |
| 1841 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); | |
| 1842 } | 1626 } |
| 1843 } | 1627 } |
| 1844 }; | 1628 }; |
| 1845 | 1629 |
| 1846 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty); | 1630 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionNonEmpty); |
| 1847 | 1631 |
| 1848 template <class Types> | 1632 template <class Types> |
| 1849 class OcclusionTrackerTest3dTransform : public OcclusionTrackerTest<Types> { | 1633 class OcclusionTrackerTest3dTransform : public OcclusionTrackerTest<Types> { |
| 1850 protected: | 1634 protected: |
| 1851 explicit OcclusionTrackerTest3dTransform(bool opaque_layers) | 1635 explicit OcclusionTrackerTest3dTransform(bool opaque_layers) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1865 gfx::Size(200, 200), | 1649 gfx::Size(200, 200), |
| 1866 true); | 1650 true); |
| 1867 this->CalcDrawEtc(parent); | 1651 this->CalcDrawEtc(parent); |
| 1868 | 1652 |
| 1869 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1653 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1870 gfx::Rect(0, 0, 1000, 1000)); | 1654 gfx::Rect(0, 0, 1000, 1000)); |
| 1871 this->EnterLayer(layer, &occlusion); | 1655 this->EnterLayer(layer, &occlusion); |
| 1872 | 1656 |
| 1873 // The layer is rotated in 3d but without preserving 3d, so it only gets | 1657 // The layer is rotated in 3d but without preserving 3d, so it only gets |
| 1874 // resized. | 1658 // resized. |
| 1875 EXPECT_RECT_EQ( | 1659 EXPECT_EQ( |
| 1876 gfx::Rect(0, 0, 200, 200), | 1660 gfx::Rect(0, 0, 200, 200), |
| 1877 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); | 1661 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); |
| 1878 } | 1662 } |
| 1879 }; | 1663 }; |
| 1880 | 1664 |
| 1881 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTest3dTransform); | 1665 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTest3dTransform); |
| 1882 | 1666 |
| 1883 template <class Types> | 1667 template <class Types> |
| 1884 class OcclusionTrackerTestUnsorted3dLayers | 1668 class OcclusionTrackerTestUnsorted3dLayers |
| 1885 : public OcclusionTrackerTest<Types> { | 1669 : public OcclusionTrackerTest<Types> { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1959 container->Set3dSortingContextId(1); | 1743 container->Set3dSortingContextId(1); |
| 1960 layer->Set3dSortingContextId(1); | 1744 layer->Set3dSortingContextId(1); |
| 1961 layer->SetShouldFlattenTransform(false); | 1745 layer->SetShouldFlattenTransform(false); |
| 1962 | 1746 |
| 1963 this->CalcDrawEtc(parent); | 1747 this->CalcDrawEtc(parent); |
| 1964 | 1748 |
| 1965 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 1749 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 1966 gfx::Rect(0, 0, 1000, 1000)); | 1750 gfx::Rect(0, 0, 1000, 1000)); |
| 1967 this->EnterLayer(layer, &occlusion); | 1751 this->EnterLayer(layer, &occlusion); |
| 1968 | 1752 |
| 1969 EXPECT_RECT_EQ( | 1753 EXPECT_EQ( |
| 1970 gfx::Rect(0, 0, 200, 200), | 1754 gfx::Rect(0, 0, 200, 200), |
| 1971 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); | 1755 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); |
| 1972 } | 1756 } |
| 1973 }; | 1757 }; |
| 1974 | 1758 |
| 1975 // This test requires accumulating occlusion of 3d layers, which are skipped by | 1759 // This test requires accumulating occlusion of 3d layers, which are skipped by |
| 1976 // the occlusion tracker on the main thread. So this test should run on the impl | 1760 // the occlusion tracker on the main thread. So this test should run on the impl |
| 1977 // thread. | 1761 // thread. |
| 1978 IMPL_THREAD_TEST(OcclusionTrackerTestPerspectiveTransform); | 1762 IMPL_THREAD_TEST(OcclusionTrackerTestPerspectiveTransform); |
| 1979 template <class Types> | 1763 template <class Types> |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2188 occlusion.UnoccludedLayerContentRect( | 1972 occlusion.UnoccludedLayerContentRect( |
| 2189 parent2, gfx::Rect(0, 0, 300, 300)).ToString()); | 1973 parent2, gfx::Rect(0, 0, 300, 300)).ToString()); |
| 2190 this->LeaveLayer(parent2, &occlusion); | 1974 this->LeaveLayer(parent2, &occlusion); |
| 2191 | 1975 |
| 2192 this->VisitLayer(surface_child2, &occlusion); | 1976 this->VisitLayer(surface_child2, &occlusion); |
| 2193 this->EnterLayer(surface_child, &occlusion); | 1977 this->EnterLayer(surface_child, &occlusion); |
| 2194 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), | 1978 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
| 2195 occlusion.occlusion_from_inside_target().ToString()); | 1979 occlusion.occlusion_from_inside_target().ToString()); |
| 2196 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 1980 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2197 occlusion.occlusion_from_outside_target().ToString()); | 1981 occlusion.occlusion_from_outside_target().ToString()); |
| 2198 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), | 1982 EXPECT_EQ(gfx::Rect(100, 0, 100, 300), |
| 2199 occlusion.UnoccludedLayerContentRect( | 1983 occlusion.UnoccludedLayerContentRect(surface_child, |
| 2200 surface_child, gfx::Rect(0, 0, 200, 300))); | 1984 gfx::Rect(0, 0, 200, 300))); |
| 2201 this->LeaveLayer(surface_child, &occlusion); | 1985 this->LeaveLayer(surface_child, &occlusion); |
| 2202 this->EnterLayer(surface, &occlusion); | 1986 this->EnterLayer(surface, &occlusion); |
| 2203 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), | 1987 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), |
| 2204 occlusion.occlusion_from_inside_target().ToString()); | 1988 occlusion.occlusion_from_inside_target().ToString()); |
| 2205 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 1989 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2206 occlusion.occlusion_from_outside_target().ToString()); | 1990 occlusion.occlusion_from_outside_target().ToString()); |
| 2207 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), | 1991 EXPECT_EQ(gfx::Rect(200, 0, 50, 300), |
| 2208 occlusion.UnoccludedLayerContentRect( | 1992 occlusion.UnoccludedLayerContentRect(surface, |
| 2209 surface, gfx::Rect(0, 0, 300, 300))); | 1993 gfx::Rect(0, 0, 300, 300))); |
| 2210 this->LeaveLayer(surface, &occlusion); | 1994 this->LeaveLayer(surface, &occlusion); |
| 2211 | 1995 |
| 2212 this->EnterContributingSurface(surface, &occlusion); | 1996 this->EnterContributingSurface(surface, &occlusion); |
| 2213 // Occlusion within the surface is lost when leaving the animating surface. | 1997 // Occlusion within the surface is lost when leaving the animating surface. |
| 2214 EXPECT_EQ(gfx::Rect().ToString(), | 1998 EXPECT_EQ(gfx::Rect().ToString(), |
| 2215 occlusion.occlusion_from_inside_target().ToString()); | 1999 occlusion.occlusion_from_inside_target().ToString()); |
| 2216 EXPECT_EQ(gfx::Rect().ToString(), | 2000 EXPECT_EQ(gfx::Rect().ToString(), |
| 2217 occlusion.occlusion_from_outside_target().ToString()); | 2001 occlusion.occlusion_from_outside_target().ToString()); |
| 2218 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2002 EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2219 occlusion.UnoccludedSurfaceContentRect( | 2003 occlusion.UnoccludedSurfaceContentRect( |
| 2220 surface, false, gfx::Rect(0, 0, 300, 300))); | 2004 surface, false, gfx::Rect(0, 0, 300, 300))); |
| 2221 this->LeaveContributingSurface(surface, &occlusion); | 2005 this->LeaveContributingSurface(surface, &occlusion); |
| 2222 | 2006 |
| 2223 // Occlusion from outside the animating surface still exists. | 2007 // Occlusion from outside the animating surface still exists. |
| 2224 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2008 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2225 occlusion.occlusion_from_inside_target().ToString()); | 2009 occlusion.occlusion_from_inside_target().ToString()); |
| 2226 EXPECT_EQ(gfx::Rect().ToString(), | 2010 EXPECT_EQ(gfx::Rect().ToString(), |
| 2227 occlusion.occlusion_from_outside_target().ToString()); | 2011 occlusion.occlusion_from_outside_target().ToString()); |
| 2228 | 2012 |
| 2229 this->VisitLayer(layer, &occlusion); | 2013 this->VisitLayer(layer, &occlusion); |
| 2230 this->EnterLayer(parent, &occlusion); | 2014 this->EnterLayer(parent, &occlusion); |
| 2231 | 2015 |
| 2232 // Occlusion is not added for the animating |layer|. | 2016 // Occlusion is not added for the animating |layer|. |
| 2233 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2017 EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2234 occlusion.UnoccludedLayerContentRect( | 2018 occlusion.UnoccludedLayerContentRect(parent, |
| 2235 parent, gfx::Rect(0, 0, 300, 300))); | 2019 gfx::Rect(0, 0, 300, 300))); |
| 2236 } | 2020 } |
| 2237 }; | 2021 }; |
| 2238 | 2022 |
| 2239 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread); | 2023 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread); |
| 2240 | 2024 |
| 2241 template <class Types> | 2025 template <class Types> |
| 2242 class OcclusionTrackerTestAnimationOpacity0OnMainThread | 2026 class OcclusionTrackerTestAnimationOpacity0OnMainThread |
| 2243 : public OcclusionTrackerTest<Types> { | 2027 : public OcclusionTrackerTest<Types> { |
| 2244 protected: | 2028 protected: |
| 2245 explicit OcclusionTrackerTestAnimationOpacity0OnMainThread(bool opaque_layers) | 2029 explicit OcclusionTrackerTestAnimationOpacity0OnMainThread(bool opaque_layers) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2297 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 2081 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 2298 gfx::Rect(0, 0, 1000, 1000)); | 2082 gfx::Rect(0, 0, 1000, 1000)); |
| 2299 | 2083 |
| 2300 this->VisitLayer(topmost, &occlusion); | 2084 this->VisitLayer(topmost, &occlusion); |
| 2301 this->EnterLayer(parent2, &occlusion); | 2085 this->EnterLayer(parent2, &occlusion); |
| 2302 // This occlusion will affect all surfaces. | 2086 // This occlusion will affect all surfaces. |
| 2303 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2087 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2304 occlusion.occlusion_from_inside_target().ToString()); | 2088 occlusion.occlusion_from_inside_target().ToString()); |
| 2305 EXPECT_EQ(gfx::Rect().ToString(), | 2089 EXPECT_EQ(gfx::Rect().ToString(), |
| 2306 occlusion.occlusion_from_outside_target().ToString()); | 2090 occlusion.occlusion_from_outside_target().ToString()); |
| 2307 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2091 EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2308 occlusion.UnoccludedLayerContentRect( | 2092 occlusion.UnoccludedLayerContentRect(parent, |
| 2309 parent, gfx::Rect(0, 0, 300, 300))); | 2093 gfx::Rect(0, 0, 300, 300))); |
| 2310 this->LeaveLayer(parent2, &occlusion); | 2094 this->LeaveLayer(parent2, &occlusion); |
| 2311 | 2095 |
| 2312 this->VisitLayer(surface_child2, &occlusion); | 2096 this->VisitLayer(surface_child2, &occlusion); |
| 2313 this->EnterLayer(surface_child, &occlusion); | 2097 this->EnterLayer(surface_child, &occlusion); |
| 2314 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), | 2098 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
| 2315 occlusion.occlusion_from_inside_target().ToString()); | 2099 occlusion.occlusion_from_inside_target().ToString()); |
| 2316 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2100 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2317 occlusion.occlusion_from_outside_target().ToString()); | 2101 occlusion.occlusion_from_outside_target().ToString()); |
| 2318 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), | 2102 EXPECT_EQ(gfx::Rect(100, 0, 100, 300), |
| 2319 occlusion.UnoccludedLayerContentRect( | 2103 occlusion.UnoccludedLayerContentRect(surface_child, |
| 2320 surface_child, gfx::Rect(0, 0, 200, 300))); | 2104 gfx::Rect(0, 0, 200, 300))); |
| 2321 this->LeaveLayer(surface_child, &occlusion); | 2105 this->LeaveLayer(surface_child, &occlusion); |
| 2322 this->EnterLayer(surface, &occlusion); | 2106 this->EnterLayer(surface, &occlusion); |
| 2323 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), | 2107 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), |
| 2324 occlusion.occlusion_from_inside_target().ToString()); | 2108 occlusion.occlusion_from_inside_target().ToString()); |
| 2325 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2109 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2326 occlusion.occlusion_from_outside_target().ToString()); | 2110 occlusion.occlusion_from_outside_target().ToString()); |
| 2327 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), | 2111 EXPECT_EQ(gfx::Rect(200, 0, 50, 300), |
| 2328 occlusion.UnoccludedLayerContentRect( | 2112 occlusion.UnoccludedLayerContentRect(surface, |
| 2329 surface, gfx::Rect(0, 0, 300, 300))); | 2113 gfx::Rect(0, 0, 300, 300))); |
| 2330 this->LeaveLayer(surface, &occlusion); | 2114 this->LeaveLayer(surface, &occlusion); |
| 2331 | 2115 |
| 2332 this->EnterContributingSurface(surface, &occlusion); | 2116 this->EnterContributingSurface(surface, &occlusion); |
| 2333 // Occlusion within the surface is lost when leaving the animating surface. | 2117 // Occlusion within the surface is lost when leaving the animating surface. |
| 2334 EXPECT_EQ(gfx::Rect().ToString(), | 2118 EXPECT_EQ(gfx::Rect().ToString(), |
| 2335 occlusion.occlusion_from_inside_target().ToString()); | 2119 occlusion.occlusion_from_inside_target().ToString()); |
| 2336 EXPECT_EQ(gfx::Rect().ToString(), | 2120 EXPECT_EQ(gfx::Rect().ToString(), |
| 2337 occlusion.occlusion_from_outside_target().ToString()); | 2121 occlusion.occlusion_from_outside_target().ToString()); |
| 2338 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2122 EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2339 occlusion.UnoccludedSurfaceContentRect( | 2123 occlusion.UnoccludedSurfaceContentRect( |
| 2340 surface, false, gfx::Rect(0, 0, 300, 300))); | 2124 surface, false, gfx::Rect(0, 0, 300, 300))); |
| 2341 this->LeaveContributingSurface(surface, &occlusion); | 2125 this->LeaveContributingSurface(surface, &occlusion); |
| 2342 | 2126 |
| 2343 // Occlusion from outside the animating surface still exists. | 2127 // Occlusion from outside the animating surface still exists. |
| 2344 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2128 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
| 2345 occlusion.occlusion_from_inside_target().ToString()); | 2129 occlusion.occlusion_from_inside_target().ToString()); |
| 2346 EXPECT_EQ(gfx::Rect().ToString(), | 2130 EXPECT_EQ(gfx::Rect().ToString(), |
| 2347 occlusion.occlusion_from_outside_target().ToString()); | 2131 occlusion.occlusion_from_outside_target().ToString()); |
| 2348 | 2132 |
| 2349 this->VisitLayer(layer, &occlusion); | 2133 this->VisitLayer(layer, &occlusion); |
| 2350 this->EnterLayer(parent, &occlusion); | 2134 this->EnterLayer(parent, &occlusion); |
| 2351 | 2135 |
| 2352 // Occlusion is not added for the animating |layer|. | 2136 // Occlusion is not added for the animating |layer|. |
| 2353 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2137 EXPECT_EQ(gfx::Rect(0, 0, 250, 300), |
| 2354 occlusion.UnoccludedLayerContentRect( | 2138 occlusion.UnoccludedLayerContentRect(parent, |
| 2355 parent, gfx::Rect(0, 0, 300, 300))); | 2139 gfx::Rect(0, 0, 300, 300))); |
| 2356 } | 2140 } |
| 2357 }; | 2141 }; |
| 2358 | 2142 |
| 2359 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread); | 2143 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread); |
| 2360 | 2144 |
| 2361 template <class Types> | 2145 template <class Types> |
| 2362 class OcclusionTrackerTestAnimationTranslateOnMainThread | 2146 class OcclusionTrackerTestAnimationTranslateOnMainThread |
| 2363 : public OcclusionTrackerTest<Types> { | 2147 : public OcclusionTrackerTest<Types> { |
| 2364 protected: | 2148 protected: |
| 2365 explicit OcclusionTrackerTestAnimationTranslateOnMainThread( | 2149 explicit OcclusionTrackerTestAnimationTranslateOnMainThread( |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2520 | 2304 |
| 2521 this->VisitLayer(surface2, &occlusion); | 2305 this->VisitLayer(surface2, &occlusion); |
| 2522 this->VisitContributingSurface(surface2, &occlusion); | 2306 this->VisitContributingSurface(surface2, &occlusion); |
| 2523 | 2307 |
| 2524 EXPECT_EQ(gfx::Rect().ToString(), | 2308 EXPECT_EQ(gfx::Rect().ToString(), |
| 2525 occlusion.occlusion_from_outside_target().ToString()); | 2309 occlusion.occlusion_from_outside_target().ToString()); |
| 2526 EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), | 2310 EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), |
| 2527 occlusion.occlusion_from_inside_target().ToString()); | 2311 occlusion.occlusion_from_inside_target().ToString()); |
| 2528 | 2312 |
| 2529 // Clear any stored occlusion. | 2313 // Clear any stored occlusion. |
| 2530 occlusion.set_occlusion_from_outside_target(Region()); | 2314 occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); |
| 2531 occlusion.set_occlusion_from_inside_target(Region()); | 2315 occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); |
| 2532 | 2316 |
| 2533 this->VisitLayer(surface, &occlusion); | 2317 this->VisitLayer(surface, &occlusion); |
| 2534 this->VisitContributingSurface(surface, &occlusion); | 2318 this->VisitContributingSurface(surface, &occlusion); |
| 2535 | 2319 |
| 2536 EXPECT_EQ(gfx::Rect().ToString(), | 2320 EXPECT_EQ(gfx::Rect().ToString(), |
| 2537 occlusion.occlusion_from_outside_target().ToString()); | 2321 occlusion.occlusion_from_outside_target().ToString()); |
| 2538 EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), | 2322 EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), |
| 2539 occlusion.occlusion_from_inside_target().ToString()); | 2323 occlusion.occlusion_from_inside_target().ToString()); |
| 2540 } | 2324 } |
| 2541 }; | 2325 }; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2620 | 2404 |
| 2621 // Render target with replica ignores occlusion from outside. | 2405 // Render target with replica ignores occlusion from outside. |
| 2622 EXPECT_EQ(gfx::Rect().ToString(), | 2406 EXPECT_EQ(gfx::Rect().ToString(), |
| 2623 occlusion.occlusion_from_outside_target().ToString()); | 2407 occlusion.occlusion_from_outside_target().ToString()); |
| 2624 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 2408 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 2625 occlusion.occlusion_from_inside_target().ToString()); | 2409 occlusion.occlusion_from_inside_target().ToString()); |
| 2626 | 2410 |
| 2627 this->EnterContributingSurface(surface, &occlusion); | 2411 this->EnterContributingSurface(surface, &occlusion); |
| 2628 | 2412 |
| 2629 // Surface is not occluded so it shouldn't think it is. | 2413 // Surface is not occluded so it shouldn't think it is. |
| 2630 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), | 2414 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 2631 occlusion.UnoccludedSurfaceContentRect( | 2415 occlusion.UnoccludedSurfaceContentRect( |
| 2632 surface, false, gfx::Rect(0, 0, 100, 100))); | 2416 surface, false, gfx::Rect(0, 0, 100, 100))); |
| 2633 } | 2417 } |
| 2634 }; | 2418 }; |
| 2635 | 2419 |
| 2636 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); | 2420 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); |
| 2637 | 2421 |
| 2638 template <class Types> | 2422 template <class Types> |
| 2639 class OcclusionTrackerTestSurfaceWithReplicaUnoccluded | 2423 class OcclusionTrackerTestSurfaceWithReplicaUnoccluded |
| 2640 : public OcclusionTrackerTest<Types> { | 2424 : public OcclusionTrackerTest<Types> { |
| 2641 protected: | 2425 protected: |
| 2642 explicit OcclusionTrackerTestSurfaceWithReplicaUnoccluded(bool opaque_layers) | 2426 explicit OcclusionTrackerTestSurfaceWithReplicaUnoccluded(bool opaque_layers) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2677 | 2461 |
| 2678 // Render target with replica ignores occlusion from outside. | 2462 // Render target with replica ignores occlusion from outside. |
| 2679 EXPECT_EQ(gfx::Rect().ToString(), | 2463 EXPECT_EQ(gfx::Rect().ToString(), |
| 2680 occlusion.occlusion_from_outside_target().ToString()); | 2464 occlusion.occlusion_from_outside_target().ToString()); |
| 2681 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 2465 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 2682 occlusion.occlusion_from_inside_target().ToString()); | 2466 occlusion.occlusion_from_inside_target().ToString()); |
| 2683 | 2467 |
| 2684 this->EnterContributingSurface(surface, &occlusion); | 2468 this->EnterContributingSurface(surface, &occlusion); |
| 2685 | 2469 |
| 2686 // Surface is occluded, but only the top 10px of the replica. | 2470 // Surface is occluded, but only the top 10px of the replica. |
| 2687 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), | 2471 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| 2688 occlusion.UnoccludedSurfaceContentRect( | 2472 occlusion.UnoccludedSurfaceContentRect( |
| 2689 surface, false, gfx::Rect(0, 0, 100, 100))); | 2473 surface, false, gfx::Rect(0, 0, 100, 100))); |
| 2690 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90), | 2474 EXPECT_EQ(gfx::Rect(0, 10, 100, 90), |
| 2691 occlusion.UnoccludedSurfaceContentRect( | 2475 occlusion.UnoccludedSurfaceContentRect( |
| 2692 surface, true, gfx::Rect(0, 0, 100, 100))); | 2476 surface, true, gfx::Rect(0, 0, 100, 100))); |
| 2693 } | 2477 } |
| 2694 }; | 2478 }; |
| 2695 | 2479 |
| 2696 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded); | 2480 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded); |
| 2697 | 2481 |
| 2698 template <class Types> | 2482 template <class Types> |
| 2699 class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently | 2483 class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently |
| 2700 : public OcclusionTrackerTest<Types> { | 2484 : public OcclusionTrackerTest<Types> { |
| 2701 protected: | 2485 protected: |
| 2702 explicit OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently( | 2486 explicit OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently( |
| 2703 bool opaque_layers) | 2487 bool opaque_layers) |
| 2704 : OcclusionTrackerTest<Types>(opaque_layers) {} | 2488 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2705 void RunMyTest() { | 2489 void RunMyTest() { |
| 2706 typename Types::ContentLayerType* parent = this->CreateRoot( | 2490 typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2707 this->identity_matrix, gfx::PointF(), gfx::Size(100, 200)); | 2491 this->identity_matrix, gfx::PointF(), gfx::Size(200, 100)); |
| 2708 typename Types::LayerType* surface = | 2492 typename Types::LayerType* surface = |
| 2709 this->CreateDrawingSurface(parent, | 2493 this->CreateDrawingSurface(parent, |
| 2710 this->identity_matrix, | 2494 this->identity_matrix, |
| 2711 gfx::PointF(), | 2495 gfx::PointF(), |
| 2712 gfx::Size(100, 100), | 2496 gfx::Size(100, 100), |
| 2713 true); | 2497 true); |
| 2714 this->CreateReplicaLayer(surface, | 2498 this->CreateReplicaLayer(surface, |
| 2715 this->identity_matrix, | 2499 this->identity_matrix, |
| 2716 gfx::PointF(0.f, 100.f), | 2500 gfx::PointF(100.f, 0.f), |
| 2717 gfx::Size(100, 100)); | 2501 gfx::Size(100, 100)); |
| 2718 typename Types::LayerType* over_surface = this->CreateDrawingLayer( | 2502 typename Types::LayerType* over_surface = |
| 2719 parent, this->identity_matrix, gfx::PointF(), gfx::Size(40, 100), true); | 2503 this->CreateDrawingLayer(parent, |
| 2504 this->identity_matrix, | |
| 2505 gfx::PointF(60.f, 0.f), | |
| 2506 gfx::Size(40, 100), | |
| 2507 true); | |
| 2720 typename Types::LayerType* over_replica = | 2508 typename Types::LayerType* over_replica = |
| 2721 this->CreateDrawingLayer(parent, | 2509 this->CreateDrawingLayer(parent, |
| 2722 this->identity_matrix, | 2510 this->identity_matrix, |
| 2723 gfx::PointF(0.f, 100.f), | 2511 gfx::PointF(100.f, 0.f), |
| 2724 gfx::Size(50, 100), | 2512 gfx::Size(50, 100), |
| 2725 true); | 2513 true); |
| 2726 this->CalcDrawEtc(parent); | 2514 this->CalcDrawEtc(parent); |
| 2727 | 2515 |
| 2728 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 2516 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 2729 gfx::Rect(0, 0, 1000, 1000)); | 2517 gfx::Rect(0, 0, 1000, 1000)); |
| 2730 | 2518 |
| 2731 // These occlude the surface and replica differently, so we can test each | 2519 // These occlude the surface and replica differently, so we can test each |
| 2732 // one. | 2520 // one. |
| 2733 this->VisitLayer(over_replica, &occlusion); | 2521 this->VisitLayer(over_replica, &occlusion); |
| 2734 this->VisitLayer(over_surface, &occlusion); | 2522 this->VisitLayer(over_surface, &occlusion); |
| 2735 | 2523 |
| 2736 EXPECT_EQ(gfx::Rect().ToString(), | 2524 EXPECT_EQ(gfx::Rect().ToString(), |
| 2737 occlusion.occlusion_from_outside_target().ToString()); | 2525 occlusion.occlusion_from_outside_target().ToString()); |
| 2738 EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 100)) | 2526 EXPECT_EQ(gfx::Rect(60, 0, 90, 100).ToString(), |
| 2739 .ToString(), | |
| 2740 occlusion.occlusion_from_inside_target().ToString()); | 2527 occlusion.occlusion_from_inside_target().ToString()); |
| 2741 | 2528 |
| 2742 this->VisitLayer(surface, &occlusion); | 2529 this->VisitLayer(surface, &occlusion); |
| 2743 | 2530 |
| 2744 // Render target with replica ignores occlusion from outside. | 2531 // Render target with replica ignores occlusion from outside. |
| 2745 EXPECT_EQ(gfx::Rect().ToString(), | 2532 EXPECT_EQ(gfx::Rect().ToString(), |
| 2746 occlusion.occlusion_from_outside_target().ToString()); | 2533 occlusion.occlusion_from_outside_target().ToString()); |
| 2747 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 2534 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
| 2748 occlusion.occlusion_from_inside_target().ToString()); | 2535 occlusion.occlusion_from_inside_target().ToString()); |
| 2749 | 2536 |
| 2750 this->EnterContributingSurface(surface, &occlusion); | 2537 this->EnterContributingSurface(surface, &occlusion); |
| 2751 | 2538 |
| 2752 // Surface and replica are occluded different amounts. | 2539 // Surface and replica are occluded different amounts. |
| 2753 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100), | 2540 EXPECT_EQ(gfx::Rect(0, 0, 60, 100), |
| 2754 occlusion.UnoccludedSurfaceContentRect( | 2541 occlusion.UnoccludedSurfaceContentRect( |
| 2755 surface, false, gfx::Rect(0, 0, 100, 100))); | 2542 surface, false, gfx::Rect(0, 0, 100, 100))); |
| 2756 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100), | 2543 EXPECT_EQ(gfx::Rect(50, 0, 50, 100), |
| 2757 occlusion.UnoccludedSurfaceContentRect( | 2544 occlusion.UnoccludedSurfaceContentRect( |
| 2758 surface, true, gfx::Rect(0, 0, 100, 100))); | 2545 surface, true, gfx::Rect(0, 0, 100, 100))); |
| 2759 } | 2546 } |
| 2760 }; | 2547 }; |
| 2761 | 2548 |
| 2762 ALL_OCCLUSIONTRACKER_TEST( | 2549 ALL_OCCLUSIONTRACKER_TEST( |
| 2763 OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently); | 2550 OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently); |
| 2764 | 2551 |
| 2765 template <class Types> | 2552 template <class Types> |
| 2766 class OcclusionTrackerTestSurfaceChildOfSurface | 2553 class OcclusionTrackerTestSurfaceChildOfSurface |
| 2767 : public OcclusionTrackerTest<Types> { | 2554 : public OcclusionTrackerTest<Types> { |
| 2768 protected: | 2555 protected: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2814 // The root layer always has a clip rect. So the parent of |surface| has a | 2601 // The root layer always has a clip rect. So the parent of |surface| has a |
| 2815 // clip rect. However, the owning layer for |surface| does not mask to | 2602 // clip rect. However, the owning layer for |surface| does not mask to |
| 2816 // bounds, so it doesn't have a clip rect of its own. Thus the parent of | 2603 // bounds, so it doesn't have a clip rect of its own. Thus the parent of |
| 2817 // |surface_child| exercises different code paths as its parent does not | 2604 // |surface_child| exercises different code paths as its parent does not |
| 2818 // have a clip rect. | 2605 // have a clip rect. |
| 2819 | 2606 |
| 2820 this->EnterContributingSurface(surface_child, &occlusion); | 2607 this->EnterContributingSurface(surface_child, &occlusion); |
| 2821 // The surface_child's parent does not have a clip rect as it owns a render | 2608 // The surface_child's parent does not have a clip rect as it owns a render |
| 2822 // surface. Make sure the unoccluded rect does not get clipped away | 2609 // surface. Make sure the unoccluded rect does not get clipped away |
| 2823 // inappropriately. | 2610 // inappropriately. |
| 2824 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10), | 2611 EXPECT_EQ(gfx::Rect(0, 40, 100, 10), |
| 2825 occlusion.UnoccludedSurfaceContentRect( | 2612 occlusion.UnoccludedSurfaceContentRect( |
| 2826 surface_child, false, gfx::Rect(0, 0, 100, 50))); | 2613 surface_child, false, gfx::Rect(0, 0, 100, 50))); |
| 2827 this->LeaveContributingSurface(surface_child, &occlusion); | 2614 this->LeaveContributingSurface(surface_child, &occlusion); |
| 2828 | 2615 |
| 2829 // When the surface_child's occlusion is transformed up to its parent, make | 2616 // When the surface_child's occlusion is transformed up to its parent, make |
| 2830 // sure it is not clipped away inappropriately also. | 2617 // sure it is not clipped away inappropriately also. |
| 2831 this->EnterLayer(surface, &occlusion); | 2618 this->EnterLayer(surface, &occlusion); |
| 2832 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), | 2619 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
| 2833 occlusion.occlusion_from_outside_target().ToString()); | 2620 occlusion.occlusion_from_outside_target().ToString()); |
| 2834 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), | 2621 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), |
| 2835 occlusion.occlusion_from_inside_target().ToString()); | 2622 occlusion.occlusion_from_inside_target().ToString()); |
| 2836 this->LeaveLayer(surface, &occlusion); | 2623 this->LeaveLayer(surface, &occlusion); |
| 2837 | 2624 |
| 2838 this->EnterContributingSurface(surface, &occlusion); | 2625 this->EnterContributingSurface(surface, &occlusion); |
| 2839 // The surface's parent does have a clip rect as it is the root layer. | 2626 // The surface's parent does have a clip rect as it is the root layer. |
| 2840 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50), | 2627 EXPECT_EQ(gfx::Rect(0, 50, 100, 50), |
| 2841 occlusion.UnoccludedSurfaceContentRect( | 2628 occlusion.UnoccludedSurfaceContentRect( |
| 2842 surface, false, gfx::Rect(0, 0, 100, 100))); | 2629 surface, false, gfx::Rect(0, 0, 100, 100))); |
| 2843 } | 2630 } |
| 2844 }; | 2631 }; |
| 2845 | 2632 |
| 2846 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); | 2633 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); |
| 2847 | 2634 |
| 2848 template <class Types> | 2635 template <class Types> |
| 2849 class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter | 2636 class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter |
| 2850 : public OcclusionTrackerTest<Types> { | 2637 : public OcclusionTrackerTest<Types> { |
| 2851 protected: | 2638 protected: |
| 2852 explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter( | 2639 explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter( |
| 2853 bool opaque_layers) | 2640 bool opaque_layers) |
| 2854 : OcclusionTrackerTest<Types>(opaque_layers) {} | 2641 : OcclusionTrackerTest<Types>(opaque_layers) {} |
| 2855 void RunMyTest() { | 2642 void RunMyTest() { |
| 2856 gfx::Transform scale_by_half; | 2643 gfx::Transform scale_by_half; |
| 2857 scale_by_half.Scale(0.5, 0.5); | 2644 scale_by_half.Scale(0.5, 0.5); |
| 2858 | 2645 |
| 2859 // Make a 50x50 filtered surface that is completely surrounded by opaque | |
| 2860 // layers which are above it in the z-order. The surface is scaled to test | |
| 2861 // that the pixel moving is done in the target space, where the background | |
| 2862 // filter is applied. | |
| 2863 typename Types::ContentLayerType* parent = this->CreateRoot( | |
| 2864 this->identity_matrix, gfx::PointF(), gfx::Size(200, 150)); | |
| 2865 typename Types::LayerType* filtered_surface = | |
| 2866 this->CreateDrawingLayer(parent, | |
| 2867 scale_by_half, | |
| 2868 gfx::PointF(50.f, 50.f), | |
| 2869 gfx::Size(100, 100), | |
| 2870 false); | |
| 2871 typename Types::LayerType* occluding_layer1 = this->CreateDrawingLayer( | |
| 2872 parent, this->identity_matrix, gfx::PointF(), gfx::Size(200, 50), true); | |
| 2873 typename Types::LayerType* occluding_layer2 = | |
| 2874 this->CreateDrawingLayer(parent, | |
| 2875 this->identity_matrix, | |
| 2876 gfx::PointF(0.f, 100.f), | |
| 2877 gfx::Size(200, 50), | |
| 2878 true); | |
| 2879 typename Types::LayerType* occluding_layer3 = | |
| 2880 this->CreateDrawingLayer(parent, | |
| 2881 this->identity_matrix, | |
| 2882 gfx::PointF(0.f, 50.f), | |
| 2883 gfx::Size(50, 50), | |
| 2884 true); | |
| 2885 typename Types::LayerType* occluding_layer4 = | |
| 2886 this->CreateDrawingLayer(parent, | |
| 2887 this->identity_matrix, | |
| 2888 gfx::PointF(100.f, 50.f), | |
| 2889 gfx::Size(100, 50), | |
| 2890 true); | |
| 2891 | |
| 2892 // Filters make the layer own a surface. | |
| 2893 FilterOperations filters; | 2646 FilterOperations filters; |
| 2894 filters.Append(FilterOperation::CreateBlurFilter(10.f)); | 2647 filters.Append(FilterOperation::CreateBlurFilter(10.f)); |
| 2895 filtered_surface->SetBackgroundFilters(filters); | |
| 2896 | 2648 |
| 2897 // Save the distance of influence for the blur effect. | 2649 // Save the distance of influence for the blur effect. |
| 2898 int outset_top, outset_right, outset_bottom, outset_left; | 2650 int outset_top, outset_right, outset_bottom, outset_left; |
| 2899 filters.GetOutsets( | 2651 filters.GetOutsets( |
| 2900 &outset_top, &outset_right, &outset_bottom, &outset_left); | 2652 &outset_top, &outset_right, &outset_bottom, &outset_left); |
| 2901 | 2653 |
| 2902 this->CalcDrawEtc(parent); | 2654 enum Direction { |
| 2655 LEFT, | |
| 2656 RIGHT, | |
| 2657 TOP, | |
| 2658 BOTTOM, | |
| 2659 LAST_DIRECTION = BOTTOM, | |
| 2660 }; | |
| 2903 | 2661 |
| 2904 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 2662 for (int i = 0; i <= LAST_DIRECTION; ++i) { |
| 2905 gfx::Rect(0, 0, 1000, 1000)); | 2663 SCOPED_TRACE(i); |
| 2906 | 2664 |
| 2907 // These layers occlude pixels directly beside the filtered_surface. Because | 2665 // Make a 50x50 filtered surface that is adjacent to occluding layers |
| 2908 // filtered surface blends pixels in a radius, it will need to see some of | 2666 // which are above it in the z-order in various configurations. The |
| 2909 // the pixels (up to radius far) underneath the occluding layers. | 2667 // surface isscaled to test that the pixel moving is done in the target |
|
enne (OOO)
2014/08/21 20:48:05
typo?
danakj
2014/08/21 21:15:31
Done.
| |
| 2910 this->VisitLayer(occluding_layer4, &occlusion); | 2668 // space, where the background filter is applied. |
| 2911 this->VisitLayer(occluding_layer3, &occlusion); | 2669 typename Types::ContentLayerType* parent = this->CreateRoot( |
| 2912 this->VisitLayer(occluding_layer2, &occlusion); | 2670 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200)); |
| 2913 this->VisitLayer(occluding_layer1, &occlusion); | 2671 typename Types::LayerType* filtered_surface = |
| 2672 this->CreateDrawingLayer(parent, | |
| 2673 scale_by_half, | |
| 2674 gfx::PointF(50.f, 50.f), | |
| 2675 gfx::Size(100, 100), | |
| 2676 false); | |
| 2677 filtered_surface->SetBackgroundFilters(filters); | |
| 2914 | 2678 |
| 2915 Region expected_occlusion; | 2679 gfx::Rect occlusion_rect; |
| 2916 expected_occlusion.Union(gfx::Rect(0, 0, 200, 50)); | 2680 switch (i) { |
| 2917 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50)); | 2681 case LEFT: |
| 2918 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50)); | 2682 occlusion_rect = gfx::Rect(0, 0, 50, 200); |
| 2919 expected_occlusion.Union(gfx::Rect(0, 100, 200, 50)); | 2683 break; |
| 2684 case RIGHT: | |
| 2685 occlusion_rect = gfx::Rect(100, 0, 50, 200); | |
| 2686 break; | |
| 2687 case TOP: | |
| 2688 occlusion_rect = gfx::Rect(0, 0, 200, 50); | |
| 2689 break; | |
| 2690 case BOTTOM: | |
| 2691 occlusion_rect = gfx::Rect(0, 100, 200, 50); | |
| 2692 break; | |
| 2693 } | |
| 2920 | 2694 |
| 2921 EXPECT_EQ(expected_occlusion.ToString(), | 2695 typename Types::LayerType* occluding_layer = |
| 2922 occlusion.occlusion_from_inside_target().ToString()); | 2696 this->CreateDrawingLayer(parent, |
| 2923 EXPECT_EQ(gfx::Rect().ToString(), | 2697 this->identity_matrix, |
| 2924 occlusion.occlusion_from_outside_target().ToString()); | 2698 occlusion_rect.origin(), |
| 2699 occlusion_rect.size(), | |
| 2700 true); | |
| 2701 this->CalcDrawEtc(parent); | |
| 2925 | 2702 |
| 2926 this->VisitLayer(filtered_surface, &occlusion); | 2703 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 2704 gfx::Rect(0, 0, 200, 200)); | |
| 2927 | 2705 |
| 2928 // The filtered layer does not occlude. | 2706 // This layer occludes pixels directly beside the filtered_surface. |
| 2929 Region expected_occlusion_outside_surface; | 2707 // Because filtered surface blends pixels in a radius, it will need to see |
| 2930 expected_occlusion_outside_surface.Union(gfx::Rect(-50, -50, 200, 50)); | 2708 // some of the pixels (up to radius far) underneath the occluding layers. |
| 2931 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 0, 50, 50)); | 2709 this->VisitLayer(occluding_layer, &occlusion); |
| 2932 expected_occlusion_outside_surface.Union(gfx::Rect(50, 0, 100, 50)); | |
| 2933 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 50, 200, 50)); | |
| 2934 | 2710 |
| 2935 EXPECT_EQ(expected_occlusion_outside_surface.ToString(), | 2711 EXPECT_EQ(occlusion_rect.ToString(), |
| 2936 occlusion.occlusion_from_outside_target().ToString()); | 2712 occlusion.occlusion_from_inside_target().ToString()); |
| 2937 EXPECT_EQ(gfx::Rect().ToString(), | 2713 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 2938 occlusion.occlusion_from_inside_target().ToString()); | |
| 2939 | 2714 |
| 2940 // The surface has a background blur, so it needs pixels that are currently | 2715 this->VisitLayer(filtered_surface, &occlusion); |
| 2941 // considered occluded in order to be drawn. So the pixels it needs should | |
| 2942 // be removed some the occluded area so that when we get to the parent they | |
| 2943 // are drawn. | |
| 2944 this->VisitContributingSurface(filtered_surface, &occlusion); | |
| 2945 | 2716 |
| 2946 this->EnterLayer(parent, &occlusion); | 2717 // The occlusion is used fully inside the surface. |
| 2718 gfx::Rect occlusion_inside_surface = | |
| 2719 occlusion_rect - gfx::Vector2d(50, 50); | |
| 2720 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | |
| 2721 EXPECT_EQ(occlusion_inside_surface.ToString(), | |
| 2722 occlusion.occlusion_from_outside_target().ToString()); | |
| 2947 | 2723 |
| 2948 Region expected_blurred_occlusion; | 2724 // The surface has a background blur, so it needs pixels that are |
| 2949 expected_blurred_occlusion.Union(gfx::Rect(0, 0, 200, 50 - outset_top)); | 2725 // currently considered occluded in order to be drawn. So the pixels it |
| 2950 expected_blurred_occlusion.Union(gfx::Rect( | 2726 // needs should be removed some the occluded area so that when we get to |
| 2951 0, 50 - outset_top, 50 - outset_left, 50 + outset_top + outset_bottom)); | 2727 // the parent they are drawn. |
| 2952 expected_blurred_occlusion.Union( | 2728 this->VisitContributingSurface(filtered_surface, &occlusion); |
| 2953 gfx::Rect(100 + outset_right, | 2729 this->EnterLayer(parent, &occlusion); |
| 2954 50 - outset_top, | |
| 2955 100 - outset_right, | |
| 2956 50 + outset_top + outset_bottom)); | |
| 2957 expected_blurred_occlusion.Union( | |
| 2958 gfx::Rect(0, 100 + outset_bottom, 200, 50 - outset_bottom)); | |
| 2959 | 2730 |
| 2960 EXPECT_EQ(expected_blurred_occlusion.ToString(), | 2731 gfx::Rect expected_occlusion = occlusion_rect; |
| 2961 occlusion.occlusion_from_inside_target().ToString()); | 2732 switch (i) { |
| 2962 EXPECT_EQ(gfx::Rect().ToString(), | 2733 case LEFT: |
| 2963 occlusion.occlusion_from_outside_target().ToString()); | 2734 expected_occlusion.Inset(0, 0, outset_right, 0); |
| 2735 break; | |
| 2736 case RIGHT: | |
| 2737 expected_occlusion.Inset(outset_right, 0, 0, 0); | |
| 2738 break; | |
| 2739 case TOP: | |
| 2740 expected_occlusion.Inset(0, 0, 0, outset_right); | |
| 2741 break; | |
| 2742 case BOTTOM: | |
| 2743 expected_occlusion.Inset(0, outset_right, 0, 0); | |
| 2744 break; | |
| 2745 } | |
| 2964 | 2746 |
| 2965 gfx::Rect outset_rect; | 2747 EXPECT_EQ(expected_occlusion.ToString(), |
| 2966 gfx::Rect test_rect; | 2748 occlusion.occlusion_from_inside_target().ToString()); |
| 2749 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | |
| 2967 | 2750 |
| 2968 // Nothing in the blur outsets for the filtered_surface is occluded. | 2751 this->DestroyLayers(); |
| 2969 outset_rect = gfx::Rect(50 - outset_left, | 2752 } |
| 2970 50 - outset_top, | |
| 2971 50 + outset_left + outset_right, | |
| 2972 50 + outset_top + outset_bottom); | |
| 2973 test_rect = outset_rect; | |
| 2974 EXPECT_EQ( | |
| 2975 outset_rect.ToString(), | |
| 2976 occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); | |
| 2977 | |
| 2978 // Stuff outside the blur outsets is still occluded though. | |
| 2979 test_rect = outset_rect; | |
| 2980 test_rect.Inset(0, 0, -1, 0); | |
| 2981 EXPECT_EQ( | |
| 2982 outset_rect.ToString(), | |
| 2983 occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); | |
| 2984 test_rect = outset_rect; | |
| 2985 test_rect.Inset(0, 0, 0, -1); | |
| 2986 EXPECT_EQ( | |
| 2987 outset_rect.ToString(), | |
| 2988 occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); | |
| 2989 test_rect = outset_rect; | |
| 2990 test_rect.Inset(-1, 0, 0, 0); | |
| 2991 EXPECT_EQ( | |
| 2992 outset_rect.ToString(), | |
| 2993 occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); | |
| 2994 test_rect = outset_rect; | |
| 2995 test_rect.Inset(0, -1, 0, 0); | |
| 2996 EXPECT_EQ( | |
| 2997 outset_rect.ToString(), | |
| 2998 occlusion.UnoccludedLayerContentRect(parent, test_rect).ToString()); | |
| 2999 } | 2753 } |
| 3000 }; | 2754 }; |
| 3001 | 2755 |
| 3002 ALL_OCCLUSIONTRACKER_TEST( | 2756 ALL_OCCLUSIONTRACKER_TEST( |
| 3003 OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter); | 2757 OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter); |
| 3004 | 2758 |
| 3005 template <class Types> | 2759 template <class Types> |
| 3006 class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice | 2760 class OcclusionTrackerTestTwoBackgroundFiltersReduceOcclusionTwice |
| 3007 : public OcclusionTrackerTest<Types> { | 2761 : public OcclusionTrackerTest<Types> { |
| 3008 protected: | 2762 protected: |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3126 | 2880 |
| 3127 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | 2881 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( |
| 3128 gfx::Rect(0, 0, 1000, 1000)); | 2882 gfx::Rect(0, 0, 1000, 1000)); |
| 3129 | 2883 |
| 3130 // The surface has a background blur, so it blurs non-opaque pixels below | 2884 // The surface has a background blur, so it blurs non-opaque pixels below |
| 3131 // it. | 2885 // it. |
| 3132 this->VisitLayer(filtered_surface, &occlusion); | 2886 this->VisitLayer(filtered_surface, &occlusion); |
| 3133 this->VisitContributingSurface(filtered_surface, &occlusion); | 2887 this->VisitContributingSurface(filtered_surface, &occlusion); |
| 3134 | 2888 |
| 3135 this->VisitLayer(behind_replica_layer, &occlusion); | 2889 this->VisitLayer(behind_replica_layer, &occlusion); |
| 2890 | |
| 2891 // The layers behind the surface are not blurred, and their occlusion does | |
| 2892 // not change, until we leave the surface. So it should not be modified by | |
| 2893 // the filter here. | |
| 2894 gfx::Rect occlusion_behind_replica = gfx::Rect(210, 60, 30, 30); | |
| 2895 EXPECT_EQ(occlusion_behind_replica.ToString(), | |
| 2896 occlusion.occlusion_from_inside_target().ToString()); | |
| 2897 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | |
| 2898 | |
| 2899 // Clear the occlusion so the |behind_surface_layer| can add its occlusion | |
| 2900 // without existing occlusion interfering. | |
| 2901 occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); | |
| 2902 | |
| 3136 this->VisitLayer(behind_surface_layer, &occlusion); | 2903 this->VisitLayer(behind_surface_layer, &occlusion); |
| 3137 | 2904 |
| 3138 // The layers behind the surface are not blurred, and their occlusion does | 2905 // The layers behind the surface are not blurred, and their occlusion does |
| 3139 // not change, until we leave the surface. So it should not be modified by | 2906 // not change, until we leave the surface. So it should not be modified by |
| 3140 // the filter here. | 2907 // the filter here. |
| 3141 gfx::Rect occlusion_behind_surface = gfx::Rect(60, 60, 30, 30); | 2908 gfx::Rect occlusion_behind_surface = gfx::Rect(60, 60, 30, 30); |
| 3142 gfx::Rect occlusion_behind_replica = gfx::Rect(210, 60, 30, 30); | 2909 EXPECT_EQ(occlusion_behind_surface.ToString(), |
| 3143 | |
| 3144 Region expected_opaque_bounds = | |
| 3145 UnionRegions(occlusion_behind_surface, occlusion_behind_replica); | |
| 3146 EXPECT_EQ(expected_opaque_bounds.ToString(), | |
| 3147 occlusion.occlusion_from_inside_target().ToString()); | 2910 occlusion.occlusion_from_inside_target().ToString()); |
| 3148 | 2911 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 3149 EXPECT_EQ(gfx::Rect().ToString(), | |
| 3150 occlusion.occlusion_from_outside_target().ToString()); | |
| 3151 } | 2912 } |
| 3152 }; | 2913 }; |
| 3153 | 2914 |
| 3154 ALL_OCCLUSIONTRACKER_TEST( | 2915 ALL_OCCLUSIONTRACKER_TEST( |
| 3155 OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter); | 2916 OcclusionTrackerTestDontReduceOcclusionBelowBackgroundFilter); |
| 3156 | 2917 |
| 3157 template <class Types> | 2918 template <class Types> |
| 3158 class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded | 2919 class OcclusionTrackerTestDontReduceOcclusionIfBackgroundFilterIsOccluded |
| 3159 : public OcclusionTrackerTest<Types> { | 2920 : public OcclusionTrackerTest<Types> { |
| 3160 protected: | 2921 protected: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3311 // it will not touch occlusion_beside____ since that is not beside the | 3072 // it will not touch occlusion_beside____ since that is not beside the |
| 3312 // unoccluded part of the surface, even though it is beside the occluded | 3073 // unoccluded part of the surface, even though it is beside the occluded |
| 3313 // part of the surface. | 3074 // part of the surface. |
| 3314 gfx::Rect occlusion_above_surface = | 3075 gfx::Rect occlusion_above_surface = |
| 3315 gfx::Rect(70 + outset_right, 50, 30 - outset_right, 50); | 3076 gfx::Rect(70 + outset_right, 50, 30 - outset_right, 50); |
| 3316 gfx::Rect occlusion_above_replica = | 3077 gfx::Rect occlusion_above_replica = |
| 3317 gfx::Rect(200, 50, 30 - outset_left, 50); | 3078 gfx::Rect(200, 50, 30 - outset_left, 50); |
| 3318 gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10); | 3079 gfx::Rect occlusion_beside_surface = gfx::Rect(90, 40, 10, 10); |
| 3319 gfx::Rect occlusion_beside_replica = gfx::Rect(200, 40, 10, 10); | 3080 gfx::Rect occlusion_beside_replica = gfx::Rect(200, 40, 10, 10); |
| 3320 | 3081 |
| 3321 Region expected_occlusion; | 3082 SimpleEnclosedRegion expected_occlusion; |
| 3083 expected_occlusion.Union(occlusion_beside_replica); | |
| 3084 expected_occlusion.Union(occlusion_beside_surface); | |
| 3085 expected_occlusion.Union(occlusion_above_replica); | |
| 3322 expected_occlusion.Union(occlusion_above_surface); | 3086 expected_occlusion.Union(occlusion_above_surface); |
| 3323 expected_occlusion.Union(occlusion_above_replica); | |
| 3324 expected_occlusion.Union(occlusion_beside_surface); | |
| 3325 expected_occlusion.Union(occlusion_beside_replica); | |
| 3326 | 3087 |
| 3327 ASSERT_EQ(expected_occlusion.ToString(), | 3088 EXPECT_EQ(expected_occlusion.ToString(), |
| 3328 occlusion.occlusion_from_inside_target().ToString()); | 3089 occlusion.occlusion_from_inside_target().ToString()); |
| 3329 EXPECT_EQ(gfx::Rect().ToString(), | 3090 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
| 3330 occlusion.occlusion_from_outside_target().ToString()); | |
| 3331 | 3091 |
| 3332 Region::Iterator expected_rects(expected_occlusion); | 3092 const SimpleEnclosedRegion& actual_occlusion = |
| 3333 Region::Iterator target_surface_rects( | 3093 occlusion.occlusion_from_inside_target(); |
| 3334 occlusion.occlusion_from_inside_target()); | 3094 for (size_t i = 0; i < expected_occlusion.GetRegionComplexity(); ++i) { |
| 3335 for (; expected_rects.has_rect(); | 3095 ASSERT_LT(i, actual_occlusion.GetRegionComplexity()); |
| 3336 expected_rects.next(), target_surface_rects.next()) { | 3096 EXPECT_EQ(expected_occlusion.GetRect(i), actual_occlusion.GetRect(i)); |
| 3337 ASSERT_TRUE(target_surface_rects.has_rect()); | |
| 3338 EXPECT_EQ(expected_rects.rect(), target_surface_rects.rect()); | |
| 3339 } | 3097 } |
| 3340 } | 3098 } |
| 3341 }; | 3099 }; |
| 3342 | 3100 |
| 3343 ALL_OCCLUSIONTRACKER_TEST( | 3101 ALL_OCCLUSIONTRACKER_TEST( |
| 3344 OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded); | 3102 OcclusionTrackerTestReduceOcclusionWhenBackgroundFilterIsPartiallyOccluded); |
| 3345 | 3103 |
| 3346 template <class Types> | 3104 template <class Types> |
| 3347 class OcclusionTrackerTestMinimumTrackingSize | 3105 class OcclusionTrackerTestMinimumTrackingSize |
| 3348 : public OcclusionTrackerTest<Types> { | 3106 : public OcclusionTrackerTest<Types> { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3554 // The occlusion from the copy should be dropped since it is hidden. | 3312 // The occlusion from the copy should be dropped since it is hidden. |
| 3555 EXPECT_EQ(gfx::Rect().ToString(), | 3313 EXPECT_EQ(gfx::Rect().ToString(), |
| 3556 occlusion.occlusion_from_outside_target().ToString()); | 3314 occlusion.occlusion_from_outside_target().ToString()); |
| 3557 EXPECT_EQ(gfx::Rect().ToString(), | 3315 EXPECT_EQ(gfx::Rect().ToString(), |
| 3558 occlusion.occlusion_from_inside_target().ToString()); | 3316 occlusion.occlusion_from_inside_target().ToString()); |
| 3559 } | 3317 } |
| 3560 }; | 3318 }; |
| 3561 | 3319 |
| 3562 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) | 3320 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) |
| 3563 | 3321 |
| 3322 template <class Types> | |
| 3323 class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest<Types> { | |
| 3324 protected: | |
| 3325 explicit OcclusionTrackerTestOccludedLayer(bool opaque_layers) | |
| 3326 : OcclusionTrackerTest<Types>(opaque_layers) {} | |
| 3327 void RunMyTest() { | |
| 3328 gfx::Transform translate; | |
| 3329 translate.Translate(10.0, 20.0); | |
| 3330 typename Types::ContentLayerType* root = this->CreateRoot( | |
| 3331 this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); | |
| 3332 typename Types::LayerType* surface = this->CreateSurface( | |
| 3333 root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); | |
| 3334 typename Types::LayerType* layer = this->CreateDrawingLayer( | |
| 3335 surface, translate, gfx::Point(), gfx::Size(200, 200), false); | |
| 3336 typename Types::ContentLayerType* outside_layer = this->CreateDrawingLayer( | |
| 3337 root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false); | |
| 3338 this->CalcDrawEtc(root); | |
| 3339 | |
| 3340 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | |
| 3341 gfx::Rect(0, 0, 200, 200)); | |
| 3342 this->VisitLayer(outside_layer, &occlusion); | |
| 3343 this->EnterLayer(layer, &occlusion); | |
| 3344 | |
| 3345 // No occlusion, is not occluded. | |
| 3346 occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); | |
| 3347 occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); | |
| 3348 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100))); | |
| 3349 | |
| 3350 // Partial occlusion from outside, is not occluded. | |
| 3351 occlusion.set_occlusion_from_outside_target( | |
| 3352 SimpleEnclosedRegion(50, 50, 100, 100)); | |
| 3353 occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); | |
| 3354 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); | |
| 3355 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); | |
| 3356 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); | |
| 3357 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); | |
| 3358 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); | |
| 3359 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); | |
| 3360 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); | |
| 3361 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); | |
| 3362 | |
| 3363 // Full occlusion from outside, is occluded. | |
| 3364 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); | |
| 3365 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); | |
| 3366 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); | |
| 3367 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); | |
| 3368 | |
| 3369 // Partial occlusion from inside, is not occluded. | |
| 3370 occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); | |
| 3371 occlusion.set_occlusion_from_inside_target( | |
| 3372 SimpleEnclosedRegion(50, 50, 100, 100)); | |
| 3373 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); | |
| 3374 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); | |
| 3375 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); | |
| 3376 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); | |
| 3377 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); | |
| 3378 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); | |
| 3379 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); | |
| 3380 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); | |
| 3381 | |
| 3382 // Full occlusion from inside, is occluded. | |
| 3383 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); | |
| 3384 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); | |
| 3385 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); | |
| 3386 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); | |
| 3387 | |
| 3388 // Partial occlusion from both, is not occluded. | |
| 3389 occlusion.set_occlusion_from_outside_target( | |
| 3390 SimpleEnclosedRegion(50, 50, 100, 50)); | |
| 3391 occlusion.set_occlusion_from_inside_target( | |
| 3392 SimpleEnclosedRegion(50, 100, 100, 50)); | |
| 3393 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); | |
| 3394 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 30, 100, 100))); | |
| 3395 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 0, 100, 100))); | |
| 3396 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(40, 80, 100, 100))); | |
| 3397 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 80, 100))); | |
| 3398 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 80, 100, 100))); | |
| 3399 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 80, 100, 100))); | |
| 3400 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(90, 0, 100, 100))); | |
| 3401 | |
| 3402 // Full occlusion from both, is occluded. | |
| 3403 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 100, 100))); | |
| 3404 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(40, 30, 10, 10))); | |
| 3405 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(130, 120, 10, 10))); | |
| 3406 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(80, 70, 50, 50))); | |
| 3407 } | |
| 3408 }; | |
| 3409 | |
| 3410 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOccludedLayer) | |
| 3411 | |
| 3564 } // namespace | 3412 } // namespace |
| 3565 } // namespace cc | 3413 } // namespace cc |
| OLD | NEW |