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/debug/overdraw_metrics.h" | 9 #include "cc/debug/overdraw_metrics.h" |
10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 void SetDrawsContent(LayerImpl* layer_impl, bool draws_content) { | 346 void SetDrawsContent(LayerImpl* layer_impl, bool draws_content) { |
347 layer_impl->SetDrawsContent(draws_content); | 347 layer_impl->SetDrawsContent(draws_content); |
348 } | 348 } |
349 | 349 |
350 void SetDrawsContent(Layer* layer, bool draws_content) { | 350 void SetDrawsContent(Layer* layer, bool draws_content) { |
351 layer->SetIsDrawable(draws_content); | 351 layer->SetIsDrawable(draws_content); |
352 } | 352 } |
353 | 353 |
354 void EnterLayer(typename Types::LayerType* layer, | 354 void EnterLayer(typename Types::LayerType* layer, |
355 typename Types::OcclusionTrackerType* occlusion, | 355 typename Types::OcclusionTrackerType* occlusion) { |
356 bool prevent_occlusion) { | |
357 ASSERT_EQ(layer, *layer_iterator_); | 356 ASSERT_EQ(layer, *layer_iterator_); |
358 ASSERT_TRUE(layer_iterator_.represents_itself()); | 357 ASSERT_TRUE(layer_iterator_.represents_itself()); |
359 occlusion->EnterLayer(layer_iterator_, prevent_occlusion); | 358 occlusion->EnterLayer(layer_iterator_); |
360 } | 359 } |
361 | 360 |
362 void LeaveLayer(typename Types::LayerType* layer, | 361 void LeaveLayer(typename Types::LayerType* layer, |
363 typename Types::OcclusionTrackerType* occlusion) { | 362 typename Types::OcclusionTrackerType* occlusion) { |
364 ASSERT_EQ(layer, *layer_iterator_); | 363 ASSERT_EQ(layer, *layer_iterator_); |
365 ASSERT_TRUE(layer_iterator_.represents_itself()); | 364 ASSERT_TRUE(layer_iterator_.represents_itself()); |
366 occlusion->LeaveLayer(layer_iterator_); | 365 occlusion->LeaveLayer(layer_iterator_); |
367 ++layer_iterator_; | 366 ++layer_iterator_; |
368 } | 367 } |
369 | 368 |
370 void VisitLayer(typename Types::LayerType* layer, | 369 void VisitLayer(typename Types::LayerType* layer, |
371 typename Types::OcclusionTrackerType* occlusion) { | 370 typename Types::OcclusionTrackerType* occlusion) { |
372 EnterLayer(layer, occlusion, false); | 371 EnterLayer(layer, occlusion); |
373 LeaveLayer(layer, occlusion); | 372 LeaveLayer(layer, occlusion); |
374 } | 373 } |
375 | 374 |
376 void EnterContributingSurface( | 375 void EnterContributingSurface( |
377 typename Types::LayerType* layer, | 376 typename Types::LayerType* layer, |
378 typename Types::OcclusionTrackerType* occlusion, | 377 typename Types::OcclusionTrackerType* occlusion) { |
379 bool prevent_occlusion) { | |
380 ASSERT_EQ(layer, *layer_iterator_); | 378 ASSERT_EQ(layer, *layer_iterator_); |
381 ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); | 379 ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); |
382 occlusion->EnterLayer(layer_iterator_, false); | 380 occlusion->EnterLayer(layer_iterator_); |
383 occlusion->LeaveLayer(layer_iterator_); | 381 occlusion->LeaveLayer(layer_iterator_); |
384 ++layer_iterator_; | 382 ++layer_iterator_; |
385 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); | 383 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
386 occlusion->EnterLayer(layer_iterator_, prevent_occlusion); | 384 occlusion->EnterLayer(layer_iterator_); |
387 } | 385 } |
388 | 386 |
389 void LeaveContributingSurface( | 387 void LeaveContributingSurface( |
390 typename Types::LayerType* layer, | 388 typename Types::LayerType* layer, |
391 typename Types::OcclusionTrackerType* occlusion) { | 389 typename Types::OcclusionTrackerType* occlusion) { |
392 ASSERT_EQ(layer, *layer_iterator_); | 390 ASSERT_EQ(layer, *layer_iterator_); |
393 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); | 391 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); |
394 occlusion->LeaveLayer(layer_iterator_); | 392 occlusion->LeaveLayer(layer_iterator_); |
395 ++layer_iterator_; | 393 ++layer_iterator_; |
396 } | 394 } |
397 | 395 |
398 void VisitContributingSurface( | 396 void VisitContributingSurface( |
399 typename Types::LayerType* layer, | 397 typename Types::LayerType* layer, |
400 typename Types::OcclusionTrackerType* occlusion) { | 398 typename Types::OcclusionTrackerType* occlusion) { |
401 EnterContributingSurface(layer, occlusion, false); | 399 EnterContributingSurface(layer, occlusion); |
402 LeaveContributingSurface(layer, occlusion); | 400 LeaveContributingSurface(layer, occlusion); |
403 } | 401 } |
404 | 402 |
405 void ResetLayerIterator() { layer_iterator_ = layer_iterator_begin_; } | 403 void ResetLayerIterator() { layer_iterator_ = layer_iterator_begin_; } |
406 | 404 |
407 const gfx::Transform identity_matrix; | 405 const gfx::Transform identity_matrix; |
408 | 406 |
409 private: | 407 private: |
410 void SetRootLayerOnMainThread(Layer* root) { | 408 void SetRootLayerOnMainThread(Layer* root) { |
411 host_->SetRootLayer(scoped_refptr<Layer>(root)); | 409 host_->SetRootLayer(scoped_refptr<Layer>(root)); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 gfx::Size(500, 500), | 550 gfx::Size(500, 500), |
553 true); | 551 true); |
554 parent->SetMasksToBounds(true); | 552 parent->SetMasksToBounds(true); |
555 this->CalcDrawEtc(root); | 553 this->CalcDrawEtc(root); |
556 | 554 |
557 TestOcclusionTrackerWithClip<typename Types::LayerType, | 555 TestOcclusionTrackerWithClip<typename Types::LayerType, |
558 typename Types::RenderSurfaceType> occlusion( | 556 typename Types::RenderSurfaceType> occlusion( |
559 gfx::Rect(0, 0, 1000, 1000), false); | 557 gfx::Rect(0, 0, 1000, 1000), false); |
560 | 558 |
561 this->VisitLayer(layer, &occlusion); | 559 this->VisitLayer(layer, &occlusion); |
562 this->EnterLayer(parent, &occlusion, false); | 560 this->EnterLayer(parent, &occlusion); |
563 | 561 |
564 EXPECT_EQ(gfx::Rect().ToString(), | 562 EXPECT_EQ(gfx::Rect().ToString(), |
565 occlusion.occlusion_from_outside_target().ToString()); | 563 occlusion.occlusion_from_outside_target().ToString()); |
566 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), | 564 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
567 occlusion.occlusion_from_inside_target().ToString()); | 565 occlusion.occlusion_from_inside_target().ToString()); |
568 | 566 |
569 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); | 567 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); |
570 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); | 568 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); |
571 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); | 569 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); |
572 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 69, 70))); | 570 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 69, 70))); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 parent, layer_transform, gfx::PointF(), gfx::Size(90, 90), true); | 617 parent, layer_transform, gfx::PointF(), gfx::Size(90, 90), true); |
620 typename Types::ContentLayerType* layer2 = this->CreateDrawingLayer( | 618 typename Types::ContentLayerType* layer2 = this->CreateDrawingLayer( |
621 layer1, layer_transform, gfx::PointF(), gfx::Size(50, 50), true); | 619 layer1, layer_transform, gfx::PointF(), gfx::Size(50, 50), true); |
622 this->CalcDrawEtc(parent); | 620 this->CalcDrawEtc(parent); |
623 | 621 |
624 TestOcclusionTrackerWithClip<typename Types::LayerType, | 622 TestOcclusionTrackerWithClip<typename Types::LayerType, |
625 typename Types::RenderSurfaceType> occlusion( | 623 typename Types::RenderSurfaceType> occlusion( |
626 gfx::Rect(0, 0, 1000, 1000)); | 624 gfx::Rect(0, 0, 1000, 1000)); |
627 | 625 |
628 this->VisitLayer(layer2, &occlusion); | 626 this->VisitLayer(layer2, &occlusion); |
629 this->EnterLayer(layer1, &occlusion, false); | 627 this->EnterLayer(layer1, &occlusion); |
630 | 628 |
631 EXPECT_EQ(gfx::Rect().ToString(), | 629 EXPECT_EQ(gfx::Rect().ToString(), |
632 occlusion.occlusion_from_outside_target().ToString()); | 630 occlusion.occlusion_from_outside_target().ToString()); |
633 EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), | 631 EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), |
634 occlusion.occlusion_from_inside_target().ToString()); | 632 occlusion.occlusion_from_inside_target().ToString()); |
635 | 633 |
636 // This checks cases where the quads don't match their "containing" | 634 // This checks cases where the quads don't match their "containing" |
637 // layers, e.g. in terms of transforms or clip rect. This is typical for | 635 // layers, e.g. in terms of transforms or clip rect. This is typical for |
638 // DelegatedRendererLayer. | 636 // DelegatedRendererLayer. |
639 | 637 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 gfx::Size(500, 500), | 684 gfx::Size(500, 500), |
687 true); | 685 true); |
688 parent->SetMasksToBounds(true); | 686 parent->SetMasksToBounds(true); |
689 this->CalcDrawEtc(root); | 687 this->CalcDrawEtc(root); |
690 | 688 |
691 TestOcclusionTrackerWithClip<typename Types::LayerType, | 689 TestOcclusionTrackerWithClip<typename Types::LayerType, |
692 typename Types::RenderSurfaceType> occlusion( | 690 typename Types::RenderSurfaceType> occlusion( |
693 gfx::Rect(0, 0, 1000, 1000)); | 691 gfx::Rect(0, 0, 1000, 1000)); |
694 | 692 |
695 this->VisitLayer(layer, &occlusion); | 693 this->VisitLayer(layer, &occlusion); |
696 this->EnterLayer(parent, &occlusion, false); | 694 this->EnterLayer(parent, &occlusion); |
697 | 695 |
698 EXPECT_EQ(gfx::Rect().ToString(), | 696 EXPECT_EQ(gfx::Rect().ToString(), |
699 occlusion.occlusion_from_outside_target().ToString()); | 697 occlusion.occlusion_from_outside_target().ToString()); |
700 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), | 698 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
701 occlusion.occlusion_from_inside_target().ToString()); | 699 occlusion.occlusion_from_inside_target().ToString()); |
702 | 700 |
703 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); | 701 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); |
704 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); | 702 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); |
705 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); | 703 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); |
706 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 69, 70))); | 704 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 69, 70))); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 gfx::Size(500, 500), | 755 gfx::Size(500, 500), |
758 true); | 756 true); |
759 parent->SetMasksToBounds(true); | 757 parent->SetMasksToBounds(true); |
760 this->CalcDrawEtc(root); | 758 this->CalcDrawEtc(root); |
761 | 759 |
762 TestOcclusionTrackerWithClip<typename Types::LayerType, | 760 TestOcclusionTrackerWithClip<typename Types::LayerType, |
763 typename Types::RenderSurfaceType> occlusion( | 761 typename Types::RenderSurfaceType> occlusion( |
764 gfx::Rect(0, 0, 1000, 1000)); | 762 gfx::Rect(0, 0, 1000, 1000)); |
765 | 763 |
766 this->VisitLayer(layer, &occlusion); | 764 this->VisitLayer(layer, &occlusion); |
767 this->EnterLayer(parent, &occlusion, false); | 765 this->EnterLayer(parent, &occlusion); |
768 | 766 |
769 EXPECT_EQ(gfx::Rect().ToString(), | 767 EXPECT_EQ(gfx::Rect().ToString(), |
770 occlusion.occlusion_from_outside_target().ToString()); | 768 occlusion.occlusion_from_outside_target().ToString()); |
771 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), | 769 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), |
772 occlusion.occlusion_from_inside_target().ToString()); | 770 occlusion.occlusion_from_inside_target().ToString()); |
773 | 771 |
774 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(50, 50, 50, 50))); | 772 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(50, 50, 50, 50))); |
775 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(49, 50, 50, 50))); | 773 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(49, 50, 50, 50))); |
776 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(50, 49, 50, 50))); | 774 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(50, 49, 50, 50))); |
777 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(51, 50, 49, 50))); | 775 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(51, 50, 49, 50))); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 gfx::PointF(10.f, 10.f), | 827 gfx::PointF(10.f, 10.f), |
830 gfx::Size(500, 500), | 828 gfx::Size(500, 500), |
831 true); | 829 true); |
832 this->CalcDrawEtc(parent); | 830 this->CalcDrawEtc(parent); |
833 | 831 |
834 TestOcclusionTrackerWithClip<typename Types::LayerType, | 832 TestOcclusionTrackerWithClip<typename Types::LayerType, |
835 typename Types::RenderSurfaceType> occlusion( | 833 typename Types::RenderSurfaceType> occlusion( |
836 gfx::Rect(0, 0, 1000, 1000)); | 834 gfx::Rect(0, 0, 1000, 1000)); |
837 | 835 |
838 this->VisitLayer(layer, &occlusion); | 836 this->VisitLayer(layer, &occlusion); |
839 this->EnterContributingSurface(child, &occlusion, false); | 837 this->EnterContributingSurface(child, &occlusion); |
840 | 838 |
841 EXPECT_EQ(gfx::Rect().ToString(), | 839 EXPECT_EQ(gfx::Rect().ToString(), |
842 occlusion.occlusion_from_outside_target().ToString()); | 840 occlusion.occlusion_from_outside_target().ToString()); |
843 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), | 841 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
844 occlusion.occlusion_from_inside_target().ToString()); | 842 occlusion.occlusion_from_inside_target().ToString()); |
845 | 843 |
846 this->LeaveContributingSurface(child, &occlusion); | 844 this->LeaveContributingSurface(child, &occlusion); |
847 this->EnterLayer(parent, &occlusion, false); | 845 this->EnterLayer(parent, &occlusion); |
848 | 846 |
849 EXPECT_EQ(gfx::Rect().ToString(), | 847 EXPECT_EQ(gfx::Rect().ToString(), |
850 occlusion.occlusion_from_outside_target().ToString()); | 848 occlusion.occlusion_from_outside_target().ToString()); |
851 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), | 849 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
852 occlusion.occlusion_from_inside_target().ToString()); | 850 occlusion.occlusion_from_inside_target().ToString()); |
853 | 851 |
854 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); | 852 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); |
855 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); | 853 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); |
856 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); | 854 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); |
857 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 40, 69, 60))); | 855 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 40, 69, 60))); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 gfx::PointF(100.f, 100.f), | 934 gfx::PointF(100.f, 100.f), |
937 gfx::Size(500, 500), | 935 gfx::Size(500, 500), |
938 true); | 936 true); |
939 this->CalcDrawEtc(parent); | 937 this->CalcDrawEtc(parent); |
940 | 938 |
941 TestOcclusionTrackerWithClip<typename Types::LayerType, | 939 TestOcclusionTrackerWithClip<typename Types::LayerType, |
942 typename Types::RenderSurfaceType> occlusion( | 940 typename Types::RenderSurfaceType> occlusion( |
943 gfx::Rect(0, 0, 1000, 1000)); | 941 gfx::Rect(0, 0, 1000, 1000)); |
944 | 942 |
945 this->VisitLayer(occluder, &occlusion); | 943 this->VisitLayer(occluder, &occlusion); |
946 this->EnterLayer(layer2, &occlusion, false); | 944 this->EnterLayer(layer2, &occlusion); |
947 | 945 |
948 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), | 946 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
949 occlusion.occlusion_from_outside_target().ToString()); | 947 occlusion.occlusion_from_outside_target().ToString()); |
950 EXPECT_EQ(gfx::Rect().ToString(), | 948 EXPECT_EQ(gfx::Rect().ToString(), |
951 occlusion.occlusion_from_inside_target().ToString()); | 949 occlusion.occlusion_from_inside_target().ToString()); |
952 | 950 |
953 EXPECT_RECT_EQ( | 951 EXPECT_RECT_EQ( |
954 gfx::Rect(0, 0, 25, 25), | 952 gfx::Rect(0, 0, 25, 25), |
955 occlusion.UnoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25))); | 953 occlusion.UnoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25))); |
956 EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25), | 954 EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), | 1012 EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), |
1015 occlusion.occlusion_from_inside_target().ToString()); | 1013 occlusion.occlusion_from_inside_target().ToString()); |
1016 | 1014 |
1017 this->VisitLayer(layer, &occlusion); | 1015 this->VisitLayer(layer, &occlusion); |
1018 | 1016 |
1019 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), | 1017 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), |
1020 occlusion.occlusion_from_outside_target().ToString()); | 1018 occlusion.occlusion_from_outside_target().ToString()); |
1021 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), | 1019 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
1022 occlusion.occlusion_from_inside_target().ToString()); | 1020 occlusion.occlusion_from_inside_target().ToString()); |
1023 | 1021 |
1024 this->EnterContributingSurface(child, &occlusion, false); | 1022 this->EnterContributingSurface(child, &occlusion); |
1025 | 1023 |
1026 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), | 1024 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), |
1027 occlusion.occlusion_from_outside_target().ToString()); | 1025 occlusion.occlusion_from_outside_target().ToString()); |
1028 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), | 1026 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
1029 occlusion.occlusion_from_inside_target().ToString()); | 1027 occlusion.occlusion_from_inside_target().ToString()); |
1030 | 1028 |
1031 // Occlusion in |child2| should get merged with the |child| surface we are | 1029 // Occlusion in |child2| should get merged with the |child| surface we are |
1032 // leaving now. | 1030 // leaving now. |
1033 this->LeaveContributingSurface(child, &occlusion); | 1031 this->LeaveContributingSurface(child, &occlusion); |
1034 this->EnterLayer(parent, &occlusion, false); | 1032 this->EnterLayer(parent, &occlusion); |
1035 | 1033 |
1036 EXPECT_EQ(gfx::Rect().ToString(), | 1034 EXPECT_EQ(gfx::Rect().ToString(), |
1037 occlusion.occlusion_from_outside_target().ToString()); | 1035 occlusion.occlusion_from_outside_target().ToString()); |
1038 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)) | 1036 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)) |
1039 .ToString(), | 1037 .ToString(), |
1040 occlusion.occlusion_from_inside_target().ToString()); | 1038 occlusion.occlusion_from_inside_target().ToString()); |
1041 | 1039 |
1042 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); | 1040 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); |
1043 EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10), | 1041 EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10), |
1044 occlusion.UnoccludedLayerContentRect( | 1042 occlusion.UnoccludedLayerContentRect( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 this->CalcDrawEtc(root); | 1169 this->CalcDrawEtc(root); |
1172 | 1170 |
1173 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1171 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1174 typename Types::RenderSurfaceType> occlusion( | 1172 typename Types::RenderSurfaceType> occlusion( |
1175 gfx::Rect(0, 0, 1000, 1000)); | 1173 gfx::Rect(0, 0, 1000, 1000)); |
1176 | 1174 |
1177 gfx::Rect clipped_layer_in_child = MathUtil::MapClippedRect( | 1175 gfx::Rect clipped_layer_in_child = MathUtil::MapClippedRect( |
1178 layer_transform, layer->visible_content_rect()); | 1176 layer_transform, layer->visible_content_rect()); |
1179 | 1177 |
1180 this->VisitLayer(layer, &occlusion); | 1178 this->VisitLayer(layer, &occlusion); |
1181 this->EnterContributingSurface(child, &occlusion, false); | 1179 this->EnterContributingSurface(child, &occlusion); |
1182 | 1180 |
1183 EXPECT_EQ(gfx::Rect().ToString(), | 1181 EXPECT_EQ(gfx::Rect().ToString(), |
1184 occlusion.occlusion_from_outside_target().ToString()); | 1182 occlusion.occlusion_from_outside_target().ToString()); |
1185 EXPECT_EQ(clipped_layer_in_child.ToString(), | 1183 EXPECT_EQ(clipped_layer_in_child.ToString(), |
1186 occlusion.occlusion_from_inside_target().ToString()); | 1184 occlusion.occlusion_from_inside_target().ToString()); |
1187 | 1185 |
1188 this->LeaveContributingSurface(child, &occlusion); | 1186 this->LeaveContributingSurface(child, &occlusion); |
1189 this->EnterLayer(parent, &occlusion, false); | 1187 this->EnterLayer(parent, &occlusion); |
1190 | 1188 |
1191 EXPECT_EQ(gfx::Rect().ToString(), | 1189 EXPECT_EQ(gfx::Rect().ToString(), |
1192 occlusion.occlusion_from_outside_target().ToString()); | 1190 occlusion.occlusion_from_outside_target().ToString()); |
1193 EXPECT_EQ(gfx::Rect().ToString(), | 1191 EXPECT_EQ(gfx::Rect().ToString(), |
1194 occlusion.occlusion_from_inside_target().ToString()); | 1192 occlusion.occlusion_from_inside_target().ToString()); |
1195 | 1193 |
1196 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(75, 55, 1, 1))); | 1194 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(75, 55, 1, 1))); |
1197 EXPECT_RECT_EQ( | 1195 EXPECT_RECT_EQ( |
1198 gfx::Rect(75, 55, 1, 1), | 1196 gfx::Rect(75, 55, 1, 1), |
1199 occlusion.UnoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1))); | 1197 occlusion.UnoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1))); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 true); | 1238 true); |
1241 this->CalcDrawEtc(root); | 1239 this->CalcDrawEtc(root); |
1242 | 1240 |
1243 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1241 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1244 typename Types::RenderSurfaceType> occlusion( | 1242 typename Types::RenderSurfaceType> occlusion( |
1245 gfx::Rect(0, 0, 1000, 1000)); | 1243 gfx::Rect(0, 0, 1000, 1000)); |
1246 | 1244 |
1247 this->VisitLayer(layer2, &occlusion); | 1245 this->VisitLayer(layer2, &occlusion); |
1248 this->VisitLayer(layer1, &occlusion); | 1246 this->VisitLayer(layer1, &occlusion); |
1249 this->VisitLayer(child, &occlusion); | 1247 this->VisitLayer(child, &occlusion); |
1250 this->EnterContributingSurface(child, &occlusion, false); | 1248 this->EnterContributingSurface(child, &occlusion); |
1251 | 1249 |
1252 EXPECT_EQ(gfx::Rect().ToString(), | 1250 EXPECT_EQ(gfx::Rect().ToString(), |
1253 occlusion.occlusion_from_outside_target().ToString()); | 1251 occlusion.occlusion_from_outside_target().ToString()); |
1254 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), | 1252 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), |
1255 occlusion.occlusion_from_inside_target().ToString()); | 1253 occlusion.occlusion_from_inside_target().ToString()); |
1256 | 1254 |
1257 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 430, 60, 70))); | 1255 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 430, 60, 70))); |
1258 EXPECT_FALSE(occlusion.OccludedLayer(child, gfx::Rect(9, 430, 60, 70))); | 1256 EXPECT_FALSE(occlusion.OccludedLayer(child, gfx::Rect(9, 430, 60, 70))); |
1259 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(11, 430, 59, 70))); | 1257 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(11, 430, 59, 70))); |
1260 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 431, 60, 69))); | 1258 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 431, 60, 69))); |
1261 | 1259 |
1262 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 1260 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
1263 child, gfx::Rect(10, 430, 60, 70)).IsEmpty()); | 1261 child, gfx::Rect(10, 430, 60, 70)).IsEmpty()); |
1264 EXPECT_RECT_EQ( | 1262 EXPECT_RECT_EQ( |
1265 gfx::Rect(9, 430, 1, 70), | 1263 gfx::Rect(9, 430, 1, 70), |
1266 occlusion.UnoccludedLayerContentRect(child, gfx::Rect(9, 430, 60, 70))); | 1264 occlusion.UnoccludedLayerContentRect(child, gfx::Rect(9, 430, 60, 70))); |
1267 EXPECT_RECT_EQ(gfx::Rect(), | 1265 EXPECT_RECT_EQ(gfx::Rect(), |
1268 occlusion.UnoccludedLayerContentRect( | 1266 occlusion.UnoccludedLayerContentRect( |
1269 child, gfx::Rect(11, 430, 59, 70))); | 1267 child, gfx::Rect(11, 430, 59, 70))); |
1270 EXPECT_RECT_EQ(gfx::Rect(), | 1268 EXPECT_RECT_EQ(gfx::Rect(), |
1271 occlusion.UnoccludedLayerContentRect( | 1269 occlusion.UnoccludedLayerContentRect( |
1272 child, gfx::Rect(10, 431, 60, 69))); | 1270 child, gfx::Rect(10, 431, 60, 69))); |
1273 | 1271 |
1274 this->LeaveContributingSurface(child, &occlusion); | 1272 this->LeaveContributingSurface(child, &occlusion); |
1275 this->EnterLayer(parent, &occlusion, false); | 1273 this->EnterLayer(parent, &occlusion); |
1276 | 1274 |
1277 EXPECT_EQ(gfx::Rect().ToString(), | 1275 EXPECT_EQ(gfx::Rect().ToString(), |
1278 occlusion.occlusion_from_outside_target().ToString()); | 1276 occlusion.occlusion_from_outside_target().ToString()); |
1279 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), | 1277 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), |
1280 occlusion.occlusion_from_inside_target().ToString()); | 1278 occlusion.occlusion_from_inside_target().ToString()); |
1281 | 1279 |
1282 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); | 1280 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); |
1283 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); | 1281 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); |
1284 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); | 1282 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); |
1285 | 1283 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 gfx::PointF(-10.f, -10.f), | 1356 gfx::PointF(-10.f, -10.f), |
1359 gfx::Size(510, 510), | 1357 gfx::Size(510, 510), |
1360 true); | 1358 true); |
1361 this->CalcDrawEtc(parent); | 1359 this->CalcDrawEtc(parent); |
1362 | 1360 |
1363 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1361 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1364 typename Types::RenderSurfaceType> occlusion( | 1362 typename Types::RenderSurfaceType> occlusion( |
1365 gfx::Rect(0, 0, 1000, 1000)); | 1363 gfx::Rect(0, 0, 1000, 1000)); |
1366 | 1364 |
1367 this->VisitLayer(layer2, &occlusion); | 1365 this->VisitLayer(layer2, &occlusion); |
1368 this->EnterContributingSurface(child2, &occlusion, false); | 1366 this->EnterContributingSurface(child2, &occlusion); |
1369 | 1367 |
1370 EXPECT_EQ(gfx::Rect().ToString(), | 1368 EXPECT_EQ(gfx::Rect().ToString(), |
1371 occlusion.occlusion_from_outside_target().ToString()); | 1369 occlusion.occlusion_from_outside_target().ToString()); |
1372 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), | 1370 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), |
1373 occlusion.occlusion_from_inside_target().ToString()); | 1371 occlusion.occlusion_from_inside_target().ToString()); |
1374 | 1372 |
1375 // There is nothing above child2's surface in the z-order. | 1373 // There is nothing above child2's surface in the z-order. |
1376 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), | 1374 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), |
1377 occlusion.UnoccludedContributingSurfaceContentRect( | 1375 occlusion.UnoccludedContributingSurfaceContentRect( |
1378 child2, false, gfx::Rect(-10, 420, 70, 80))); | 1376 child2, false, gfx::Rect(-10, 420, 70, 80))); |
1379 | 1377 |
1380 this->LeaveContributingSurface(child2, &occlusion); | 1378 this->LeaveContributingSurface(child2, &occlusion); |
1381 this->VisitLayer(layer1, &occlusion); | 1379 this->VisitLayer(layer1, &occlusion); |
1382 this->EnterContributingSurface(child1, &occlusion, false); | 1380 this->EnterContributingSurface(child1, &occlusion); |
1383 | 1381 |
1384 EXPECT_EQ(gfx::Rect(0, 430, 70, 80).ToString(), | 1382 EXPECT_EQ(gfx::Rect(0, 430, 70, 80).ToString(), |
1385 occlusion.occlusion_from_outside_target().ToString()); | 1383 occlusion.occlusion_from_outside_target().ToString()); |
1386 EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(), | 1384 EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(), |
1387 occlusion.occlusion_from_inside_target().ToString()); | 1385 occlusion.occlusion_from_inside_target().ToString()); |
1388 | 1386 |
1389 // child2's contents will occlude child1 below it. | 1387 // child2's contents will occlude child1 below it. |
1390 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70), | 1388 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70), |
1391 occlusion.UnoccludedContributingSurfaceContentRect( | 1389 occlusion.UnoccludedContributingSurfaceContentRect( |
1392 child1, false, gfx::Rect(-10, 430, 80, 70))); | 1390 child1, false, gfx::Rect(-10, 430, 80, 70))); |
1393 | 1391 |
1394 this->LeaveContributingSurface(child1, &occlusion); | 1392 this->LeaveContributingSurface(child1, &occlusion); |
1395 this->EnterLayer(parent, &occlusion, false); | 1393 this->EnterLayer(parent, &occlusion); |
1396 | 1394 |
1397 EXPECT_EQ(gfx::Rect().ToString(), | 1395 EXPECT_EQ(gfx::Rect().ToString(), |
1398 occlusion.occlusion_from_outside_target().ToString()); | 1396 occlusion.occlusion_from_outside_target().ToString()); |
1399 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)) | 1397 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)) |
1400 .ToString(), | 1398 .ToString(), |
1401 occlusion.occlusion_from_inside_target().ToString()); | 1399 occlusion.occlusion_from_inside_target().ToString()); |
1402 | 1400 |
1403 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(20, 20, 80, 80))); | 1401 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(20, 20, 80, 80))); |
1404 | 1402 |
1405 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 20, 70, 80))); | 1403 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 20, 70, 80))); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 gfx::PointF(-10.f, -10.f), | 1477 gfx::PointF(-10.f, -10.f), |
1480 gfx::Size(510, 510), | 1478 gfx::Size(510, 510), |
1481 true); | 1479 true); |
1482 this->CalcDrawEtc(parent); | 1480 this->CalcDrawEtc(parent); |
1483 | 1481 |
1484 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1482 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1485 typename Types::RenderSurfaceType> occlusion( | 1483 typename Types::RenderSurfaceType> occlusion( |
1486 gfx::Rect(0, 0, 1000, 1000)); | 1484 gfx::Rect(0, 0, 1000, 1000)); |
1487 | 1485 |
1488 this->VisitLayer(layer2, &occlusion); | 1486 this->VisitLayer(layer2, &occlusion); |
1489 this->EnterLayer(child2, &occlusion, false); | 1487 this->EnterLayer(child2, &occlusion); |
1490 | 1488 |
1491 EXPECT_EQ(gfx::Rect().ToString(), | 1489 EXPECT_EQ(gfx::Rect().ToString(), |
1492 occlusion.occlusion_from_outside_target().ToString()); | 1490 occlusion.occlusion_from_outside_target().ToString()); |
1493 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), | 1491 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), |
1494 occlusion.occlusion_from_inside_target().ToString()); | 1492 occlusion.occlusion_from_inside_target().ToString()); |
1495 | 1493 |
1496 this->LeaveLayer(child2, &occlusion); | 1494 this->LeaveLayer(child2, &occlusion); |
1497 this->EnterContributingSurface(child2, &occlusion, false); | 1495 this->EnterContributingSurface(child2, &occlusion); |
1498 | 1496 |
1499 // There is nothing above child2's surface in the z-order. | 1497 // There is nothing above child2's surface in the z-order. |
1500 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), | 1498 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), |
1501 occlusion.UnoccludedContributingSurfaceContentRect( | 1499 occlusion.UnoccludedContributingSurfaceContentRect( |
1502 child2, false, gfx::Rect(-10, 420, 70, 80))); | 1500 child2, false, gfx::Rect(-10, 420, 70, 80))); |
1503 | 1501 |
1504 this->LeaveContributingSurface(child2, &occlusion); | 1502 this->LeaveContributingSurface(child2, &occlusion); |
1505 this->VisitLayer(layer1, &occlusion); | 1503 this->VisitLayer(layer1, &occlusion); |
1506 this->EnterContributingSurface(child1, &occlusion, false); | 1504 this->EnterContributingSurface(child1, &occlusion); |
1507 | 1505 |
1508 EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(), | 1506 EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(), |
1509 occlusion.occlusion_from_outside_target().ToString()); | 1507 occlusion.occlusion_from_outside_target().ToString()); |
1510 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), | 1508 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), |
1511 occlusion.occlusion_from_inside_target().ToString()); | 1509 occlusion.occlusion_from_inside_target().ToString()); |
1512 | 1510 |
1513 // child2's contents will occlude child1 below it. | 1511 // child2's contents will occlude child1 below it. |
1514 EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90), | 1512 EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90), |
1515 occlusion.UnoccludedContributingSurfaceContentRect( | 1513 occlusion.UnoccludedContributingSurfaceContentRect( |
1516 child1, false, gfx::Rect(420, -20, 80, 90))); | 1514 child1, false, gfx::Rect(420, -20, 80, 90))); |
1517 EXPECT_RECT_EQ(gfx::Rect(490, -10, 10, 80), | 1515 EXPECT_RECT_EQ(gfx::Rect(490, -10, 10, 80), |
1518 occlusion.UnoccludedContributingSurfaceContentRect( | 1516 occlusion.UnoccludedContributingSurfaceContentRect( |
1519 child1, false, gfx::Rect(420, -10, 80, 90))); | 1517 child1, false, gfx::Rect(420, -10, 80, 90))); |
1520 EXPECT_RECT_EQ(gfx::Rect(420, -20, 70, 10), | 1518 EXPECT_RECT_EQ(gfx::Rect(420, -20, 70, 10), |
1521 occlusion.UnoccludedContributingSurfaceContentRect( | 1519 occlusion.UnoccludedContributingSurfaceContentRect( |
1522 child1, false, gfx::Rect(420, -20, 70, 90))); | 1520 child1, false, gfx::Rect(420, -20, 70, 90))); |
1523 | 1521 |
1524 this->LeaveContributingSurface(child1, &occlusion); | 1522 this->LeaveContributingSurface(child1, &occlusion); |
1525 this->EnterLayer(parent, &occlusion, false); | 1523 this->EnterLayer(parent, &occlusion); |
1526 | 1524 |
1527 EXPECT_EQ(gfx::Rect().ToString(), | 1525 EXPECT_EQ(gfx::Rect().ToString(), |
1528 occlusion.occlusion_from_outside_target().ToString()); | 1526 occlusion.occlusion_from_outside_target().ToString()); |
1529 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), | 1527 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), |
1530 occlusion.occlusion_from_inside_target().ToString()); | 1528 occlusion.occlusion_from_inside_target().ToString()); |
1531 | 1529 |
1532 /* Justification for the above occlusion: | 1530 /* Justification for the above occlusion: |
1533 100 | 1531 100 |
1534 +---------------------+ | 1532 +---------------------+ |
1535 |20 | layer1 | 1533 |20 | layer1 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 opacity_layer->SetFilters(filters); | 1602 opacity_layer->SetFilters(filters); |
1605 | 1603 |
1606 this->CalcDrawEtc(parent); | 1604 this->CalcDrawEtc(parent); |
1607 | 1605 |
1608 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1606 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1609 typename Types::RenderSurfaceType> occlusion( | 1607 typename Types::RenderSurfaceType> occlusion( |
1610 gfx::Rect(0, 0, 1000, 1000)); | 1608 gfx::Rect(0, 0, 1000, 1000)); |
1611 | 1609 |
1612 // Opacity layer won't contribute to occlusion. | 1610 // Opacity layer won't contribute to occlusion. |
1613 this->VisitLayer(opacity_layer, &occlusion); | 1611 this->VisitLayer(opacity_layer, &occlusion); |
1614 this->EnterContributingSurface(opacity_layer, &occlusion, false); | 1612 this->EnterContributingSurface(opacity_layer, &occlusion); |
1615 | 1613 |
1616 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1614 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1617 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | 1615 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
1618 | 1616 |
1619 // And has nothing to contribute to its parent surface. | 1617 // And has nothing to contribute to its parent surface. |
1620 this->LeaveContributingSurface(opacity_layer, &occlusion); | 1618 this->LeaveContributingSurface(opacity_layer, &occlusion); |
1621 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1619 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1622 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | 1620 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
1623 | 1621 |
1624 // Opaque layer will contribute to occlusion. | 1622 // Opaque layer will contribute to occlusion. |
1625 this->VisitLayer(opaque_layer, &occlusion); | 1623 this->VisitLayer(opaque_layer, &occlusion); |
1626 this->EnterContributingSurface(opaque_layer, &occlusion, false); | 1624 this->EnterContributingSurface(opaque_layer, &occlusion); |
1627 | 1625 |
1628 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1626 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1629 EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(), | 1627 EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(), |
1630 occlusion.occlusion_from_inside_target().ToString()); | 1628 occlusion.occlusion_from_inside_target().ToString()); |
1631 | 1629 |
1632 // And it gets translated to the parent surface. | 1630 // And it gets translated to the parent surface. |
1633 this->LeaveContributingSurface(opaque_layer, &occlusion); | 1631 this->LeaveContributingSurface(opaque_layer, &occlusion); |
1634 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1632 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1635 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), | 1633 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
1636 occlusion.occlusion_from_inside_target().ToString()); | 1634 occlusion.occlusion_from_inside_target().ToString()); |
1637 | 1635 |
1638 // The blur layer needs to throw away any occlusion from outside its | 1636 // The blur layer needs to throw away any occlusion from outside its |
1639 // subtree. | 1637 // subtree. |
1640 this->EnterLayer(blur_layer, &occlusion, false); | 1638 this->EnterLayer(blur_layer, &occlusion); |
1641 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1639 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1642 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | 1640 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
1643 | 1641 |
1644 // And it won't contribute to occlusion. | 1642 // And it won't contribute to occlusion. |
1645 this->LeaveLayer(blur_layer, &occlusion); | 1643 this->LeaveLayer(blur_layer, &occlusion); |
1646 this->EnterContributingSurface(blur_layer, &occlusion, false); | 1644 this->EnterContributingSurface(blur_layer, &occlusion); |
1647 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1645 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1648 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | 1646 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
1649 | 1647 |
1650 // But the opaque layer's occlusion is preserved on the parent. | 1648 // But the opaque layer's occlusion is preserved on the parent. |
1651 this->LeaveContributingSurface(blur_layer, &occlusion); | 1649 this->LeaveContributingSurface(blur_layer, &occlusion); |
1652 this->EnterLayer(parent, &occlusion, false); | 1650 this->EnterLayer(parent, &occlusion); |
1653 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1651 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1654 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), | 1652 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), |
1655 occlusion.occlusion_from_inside_target().ToString()); | 1653 occlusion.occlusion_from_inside_target().ToString()); |
1656 } | 1654 } |
1657 }; | 1655 }; |
1658 | 1656 |
1659 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters); | 1657 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters); |
1660 | 1658 |
1661 template <class Types> | 1659 template <class Types> |
1662 class OcclusionTrackerTestReplicaDoesOcclude | 1660 class OcclusionTrackerTestReplicaDoesOcclude |
(...skipping 17 matching lines...) Expand all Loading... |
1680 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1678 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1681 typename Types::RenderSurfaceType> occlusion( | 1679 typename Types::RenderSurfaceType> occlusion( |
1682 gfx::Rect(0, 0, 1000, 1000)); | 1680 gfx::Rect(0, 0, 1000, 1000)); |
1683 | 1681 |
1684 this->VisitLayer(surface, &occlusion); | 1682 this->VisitLayer(surface, &occlusion); |
1685 | 1683 |
1686 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 1684 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
1687 occlusion.occlusion_from_inside_target().ToString()); | 1685 occlusion.occlusion_from_inside_target().ToString()); |
1688 | 1686 |
1689 this->VisitContributingSurface(surface, &occlusion); | 1687 this->VisitContributingSurface(surface, &occlusion); |
1690 this->EnterLayer(parent, &occlusion, false); | 1688 this->EnterLayer(parent, &occlusion); |
1691 | 1689 |
1692 // The surface and replica should both be occluding the parent. | 1690 // The surface and replica should both be occluding the parent. |
1693 EXPECT_EQ( | 1691 EXPECT_EQ( |
1694 UnionRegions(gfx::Rect(0, 100, 50, 50), | 1692 UnionRegions(gfx::Rect(0, 100, 50, 50), |
1695 gfx::Rect(50, 150, 50, 50)).ToString(), | 1693 gfx::Rect(50, 150, 50, 50)).ToString(), |
1696 occlusion.occlusion_from_inside_target().ToString()); | 1694 occlusion.occlusion_from_inside_target().ToString()); |
1697 } | 1695 } |
1698 }; | 1696 }; |
1699 | 1697 |
1700 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude); | 1698 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude); |
(...skipping 21 matching lines...) Expand all Loading... |
1722 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1720 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1723 typename Types::RenderSurfaceType> occlusion( | 1721 typename Types::RenderSurfaceType> occlusion( |
1724 gfx::Rect(0, 0, 1000, 1000)); | 1722 gfx::Rect(0, 0, 1000, 1000)); |
1725 | 1723 |
1726 this->VisitLayer(surface, &occlusion); | 1724 this->VisitLayer(surface, &occlusion); |
1727 | 1725 |
1728 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 1726 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
1729 occlusion.occlusion_from_inside_target().ToString()); | 1727 occlusion.occlusion_from_inside_target().ToString()); |
1730 | 1728 |
1731 this->VisitContributingSurface(surface, &occlusion); | 1729 this->VisitContributingSurface(surface, &occlusion); |
1732 this->EnterLayer(parent, &occlusion, false); | 1730 this->EnterLayer(parent, &occlusion); |
1733 | 1731 |
1734 // The surface and replica should both be occluding the parent. | 1732 // The surface and replica should both be occluding the parent. |
1735 EXPECT_EQ( | 1733 EXPECT_EQ( |
1736 UnionRegions(gfx::Rect(0, 100, 50, 50), | 1734 UnionRegions(gfx::Rect(0, 100, 50, 50), |
1737 gfx::Rect(50, 150, 50, 20)).ToString(), | 1735 gfx::Rect(50, 150, 50, 20)).ToString(), |
1738 occlusion.occlusion_from_inside_target().ToString()); | 1736 occlusion.occlusion_from_inside_target().ToString()); |
1739 } | 1737 } |
1740 }; | 1738 }; |
1741 | 1739 |
1742 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping); | 1740 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping); |
(...skipping 20 matching lines...) Expand all Loading... |
1763 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1761 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1764 typename Types::RenderSurfaceType> occlusion( | 1762 typename Types::RenderSurfaceType> occlusion( |
1765 gfx::Rect(0, 0, 1000, 1000)); | 1763 gfx::Rect(0, 0, 1000, 1000)); |
1766 | 1764 |
1767 this->VisitLayer(surface, &occlusion); | 1765 this->VisitLayer(surface, &occlusion); |
1768 | 1766 |
1769 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), | 1767 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), |
1770 occlusion.occlusion_from_inside_target().ToString()); | 1768 occlusion.occlusion_from_inside_target().ToString()); |
1771 | 1769 |
1772 this->VisitContributingSurface(surface, &occlusion); | 1770 this->VisitContributingSurface(surface, &occlusion); |
1773 this->EnterLayer(parent, &occlusion, false); | 1771 this->EnterLayer(parent, &occlusion); |
1774 | 1772 |
1775 // The replica should not be occluding the parent, since it has a mask | 1773 // The replica should not be occluding the parent, since it has a mask |
1776 // applied to it. | 1774 // applied to it. |
1777 EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), | 1775 EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), |
1778 occlusion.occlusion_from_inside_target().ToString()); | 1776 occlusion.occlusion_from_inside_target().ToString()); |
1779 } | 1777 } |
1780 }; | 1778 }; |
1781 | 1779 |
1782 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask); | 1780 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask); |
1783 | 1781 |
(...skipping 10 matching lines...) Expand all Loading... |
1794 this->CreateDrawingSurface(parent, | 1792 this->CreateDrawingSurface(parent, |
1795 this->identity_matrix, | 1793 this->identity_matrix, |
1796 gfx::PointF(), | 1794 gfx::PointF(), |
1797 gfx::Size(200, 200), | 1795 gfx::Size(200, 200), |
1798 false); | 1796 false); |
1799 this->CalcDrawEtc(parent); | 1797 this->CalcDrawEtc(parent); |
1800 | 1798 |
1801 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1799 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1802 typename Types::RenderSurfaceType> occlusion( | 1800 typename Types::RenderSurfaceType> occlusion( |
1803 gfx::Rect(0, 0, 1000, 1000)); | 1801 gfx::Rect(0, 0, 1000, 1000)); |
1804 this->EnterLayer(layer, &occlusion, false); | 1802 this->EnterLayer(layer, &occlusion); |
1805 | 1803 |
1806 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); | 1804 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); |
1807 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); | 1805 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); |
1808 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); | 1806 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); |
1809 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); | 1807 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); |
1810 | 1808 |
1811 this->LeaveLayer(layer, &occlusion); | 1809 this->LeaveLayer(layer, &occlusion); |
1812 this->VisitContributingSurface(layer, &occlusion); | 1810 this->VisitContributingSurface(layer, &occlusion); |
1813 this->EnterLayer(parent, &occlusion, false); | 1811 this->EnterLayer(parent, &occlusion); |
1814 | 1812 |
1815 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1813 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1816 } | 1814 } |
1817 }; | 1815 }; |
1818 | 1816 |
1819 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); | 1817 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); |
1820 | 1818 |
1821 template <class Types> | 1819 template <class Types> |
1822 class OcclusionTrackerTestOpaqueContentsRegionNonEmpty | 1820 class OcclusionTrackerTestOpaqueContentsRegionNonEmpty |
1823 : public OcclusionTrackerTest<Types> { | 1821 : public OcclusionTrackerTest<Types> { |
(...skipping 11 matching lines...) Expand all Loading... |
1835 false); | 1833 false); |
1836 this->CalcDrawEtc(parent); | 1834 this->CalcDrawEtc(parent); |
1837 { | 1835 { |
1838 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1836 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1839 typename Types::RenderSurfaceType> occlusion( | 1837 typename Types::RenderSurfaceType> occlusion( |
1840 gfx::Rect(0, 0, 1000, 1000)); | 1838 gfx::Rect(0, 0, 1000, 1000)); |
1841 layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); | 1839 layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); |
1842 | 1840 |
1843 this->ResetLayerIterator(); | 1841 this->ResetLayerIterator(); |
1844 this->VisitLayer(layer, &occlusion); | 1842 this->VisitLayer(layer, &occlusion); |
1845 this->EnterLayer(parent, &occlusion, false); | 1843 this->EnterLayer(parent, &occlusion); |
1846 | 1844 |
1847 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), | 1845 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), |
1848 occlusion.occlusion_from_inside_target().ToString()); | 1846 occlusion.occlusion_from_inside_target().ToString()); |
1849 | 1847 |
1850 EXPECT_FALSE( | 1848 EXPECT_FALSE( |
1851 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); | 1849 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); |
1852 EXPECT_TRUE( | 1850 EXPECT_TRUE( |
1853 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); | 1851 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); |
1854 EXPECT_FALSE( | 1852 EXPECT_FALSE( |
1855 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); | 1853 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); |
1856 } | 1854 } |
1857 { | 1855 { |
1858 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1856 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1859 typename Types::RenderSurfaceType> occlusion( | 1857 typename Types::RenderSurfaceType> occlusion( |
1860 gfx::Rect(0, 0, 1000, 1000)); | 1858 gfx::Rect(0, 0, 1000, 1000)); |
1861 layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); | 1859 layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); |
1862 | 1860 |
1863 this->ResetLayerIterator(); | 1861 this->ResetLayerIterator(); |
1864 this->VisitLayer(layer, &occlusion); | 1862 this->VisitLayer(layer, &occlusion); |
1865 this->EnterLayer(parent, &occlusion, false); | 1863 this->EnterLayer(parent, &occlusion); |
1866 | 1864 |
1867 EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), | 1865 EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), |
1868 occlusion.occlusion_from_inside_target().ToString()); | 1866 occlusion.occlusion_from_inside_target().ToString()); |
1869 | 1867 |
1870 EXPECT_FALSE( | 1868 EXPECT_FALSE( |
1871 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); | 1869 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); |
1872 EXPECT_FALSE( | 1870 EXPECT_FALSE( |
1873 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); | 1871 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); |
1874 EXPECT_TRUE( | 1872 EXPECT_TRUE( |
1875 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); | 1873 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); |
1876 } | 1874 } |
1877 { | 1875 { |
1878 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1876 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1879 typename Types::RenderSurfaceType> occlusion( | 1877 typename Types::RenderSurfaceType> occlusion( |
1880 gfx::Rect(0, 0, 1000, 1000)); | 1878 gfx::Rect(0, 0, 1000, 1000)); |
1881 layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); | 1879 layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); |
1882 | 1880 |
1883 this->ResetLayerIterator(); | 1881 this->ResetLayerIterator(); |
1884 this->VisitLayer(layer, &occlusion); | 1882 this->VisitLayer(layer, &occlusion); |
1885 this->EnterLayer(parent, &occlusion, false); | 1883 this->EnterLayer(parent, &occlusion); |
1886 | 1884 |
1887 EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), | 1885 EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), |
1888 occlusion.occlusion_from_inside_target().ToString()); | 1886 occlusion.occlusion_from_inside_target().ToString()); |
1889 | 1887 |
1890 EXPECT_FALSE( | 1888 EXPECT_FALSE( |
1891 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); | 1889 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); |
1892 EXPECT_FALSE( | 1890 EXPECT_FALSE( |
1893 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); | 1891 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); |
1894 EXPECT_FALSE( | 1892 EXPECT_FALSE( |
1895 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); | 1893 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); |
(...skipping 20 matching lines...) Expand all Loading... |
1916 this->CreateDrawingLayer(container, | 1914 this->CreateDrawingLayer(container, |
1917 transform, | 1915 transform, |
1918 gfx::PointF(100.f, 100.f), | 1916 gfx::PointF(100.f, 100.f), |
1919 gfx::Size(200, 200), | 1917 gfx::Size(200, 200), |
1920 true); | 1918 true); |
1921 this->CalcDrawEtc(parent); | 1919 this->CalcDrawEtc(parent); |
1922 | 1920 |
1923 TestOcclusionTrackerWithClip<typename Types::LayerType, | 1921 TestOcclusionTrackerWithClip<typename Types::LayerType, |
1924 typename Types::RenderSurfaceType> occlusion( | 1922 typename Types::RenderSurfaceType> occlusion( |
1925 gfx::Rect(0, 0, 1000, 1000)); | 1923 gfx::Rect(0, 0, 1000, 1000)); |
1926 this->EnterLayer(layer, &occlusion, false); | 1924 this->EnterLayer(layer, &occlusion); |
1927 | 1925 |
1928 // The layer is rotated in 3d but without preserving 3d, so it only gets | 1926 // The layer is rotated in 3d but without preserving 3d, so it only gets |
1929 // resized. | 1927 // resized. |
1930 EXPECT_RECT_EQ( | 1928 EXPECT_RECT_EQ( |
1931 gfx::Rect(0, 0, 200, 200), | 1929 gfx::Rect(0, 0, 200, 200), |
1932 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); | 1930 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); |
1933 } | 1931 } |
1934 }; | 1932 }; |
1935 | 1933 |
1936 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTest3dTransform); | 1934 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTest3dTransform); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 gfx::PointF(100.f, 100.f), | 2006 gfx::PointF(100.f, 100.f), |
2009 gfx::Size(200, 200), | 2007 gfx::Size(200, 200), |
2010 true); | 2008 true); |
2011 container->SetPreserves3d(true); | 2009 container->SetPreserves3d(true); |
2012 layer->SetPreserves3d(true); | 2010 layer->SetPreserves3d(true); |
2013 this->CalcDrawEtc(parent); | 2011 this->CalcDrawEtc(parent); |
2014 | 2012 |
2015 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2013 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2016 typename Types::RenderSurfaceType> occlusion( | 2014 typename Types::RenderSurfaceType> occlusion( |
2017 gfx::Rect(0, 0, 1000, 1000)); | 2015 gfx::Rect(0, 0, 1000, 1000)); |
2018 this->EnterLayer(layer, &occlusion, false); | 2016 this->EnterLayer(layer, &occlusion); |
2019 | 2017 |
2020 EXPECT_RECT_EQ( | 2018 EXPECT_RECT_EQ( |
2021 gfx::Rect(0, 0, 200, 200), | 2019 gfx::Rect(0, 0, 200, 200), |
2022 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); | 2020 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); |
2023 } | 2021 } |
2024 }; | 2022 }; |
2025 | 2023 |
2026 // This test requires accumulating occlusion of 3d layers, which are skipped by | 2024 // This test requires accumulating occlusion of 3d layers, which are skipped by |
2027 // the occlusion tracker on the main thread. So this test should run on the impl | 2025 // the occlusion tracker on the main thread. So this test should run on the impl |
2028 // thread. | 2026 // thread. |
(...skipping 23 matching lines...) Expand all Loading... |
2052 parent, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500)); | 2050 parent, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500)); |
2053 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( | 2051 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( |
2054 container, transform, gfx::PointF(), gfx::Size(500, 500), true); | 2052 container, transform, gfx::PointF(), gfx::Size(500, 500), true); |
2055 container->SetPreserves3d(true); | 2053 container->SetPreserves3d(true); |
2056 layer->SetPreserves3d(true); | 2054 layer->SetPreserves3d(true); |
2057 this->CalcDrawEtc(parent); | 2055 this->CalcDrawEtc(parent); |
2058 | 2056 |
2059 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2057 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2060 typename Types::RenderSurfaceType> occlusion( | 2058 typename Types::RenderSurfaceType> occlusion( |
2061 gfx::Rect(0, 0, 1000, 1000)); | 2059 gfx::Rect(0, 0, 1000, 1000)); |
2062 this->EnterLayer(layer, &occlusion, false); | 2060 this->EnterLayer(layer, &occlusion); |
2063 | 2061 |
2064 // The bottom 11 pixel rows of this layer remain visible inside the | 2062 // The bottom 11 pixel rows of this layer remain visible inside the |
2065 // container, after translation to the target surface. When translated back, | 2063 // container, after translation to the target surface. When translated back, |
2066 // this will include many more pixels but must include at least the bottom | 2064 // this will include many more pixels but must include at least the bottom |
2067 // 11 rows. | 2065 // 11 rows. |
2068 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( | 2066 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( |
2069 layer, gfx::Rect(0, 26, 500, 474)). | 2067 layer, gfx::Rect(0, 26, 500, 474)). |
2070 Contains(gfx::Rect(0, 489, 500, 11))); | 2068 Contains(gfx::Rect(0, 489, 500, 11))); |
2071 } | 2069 } |
2072 }; | 2070 }; |
(...skipping 24 matching lines...) Expand all Loading... |
2097 parent->SetPreserves3d(true); | 2095 parent->SetPreserves3d(true); |
2098 layer->SetPreserves3d(true); | 2096 layer->SetPreserves3d(true); |
2099 this->CalcDrawEtc(parent); | 2097 this->CalcDrawEtc(parent); |
2100 | 2098 |
2101 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2099 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2102 typename Types::RenderSurfaceType> occlusion( | 2100 typename Types::RenderSurfaceType> occlusion( |
2103 gfx::Rect(0, 0, 1000, 1000)); | 2101 gfx::Rect(0, 0, 1000, 1000)); |
2104 | 2102 |
2105 // The |layer| is entirely behind the camera and should not occlude. | 2103 // The |layer| is entirely behind the camera and should not occlude. |
2106 this->VisitLayer(layer, &occlusion); | 2104 this->VisitLayer(layer, &occlusion); |
2107 this->EnterLayer(parent, &occlusion, false); | 2105 this->EnterLayer(parent, &occlusion); |
2108 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | 2106 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
2109 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 2107 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
2110 } | 2108 } |
2111 }; | 2109 }; |
2112 | 2110 |
2113 // This test requires accumulating occlusion of 3d layers, which are skipped by | 2111 // This test requires accumulating occlusion of 3d layers, which are skipped by |
2114 // the occlusion tracker on the main thread. So this test should run on the impl | 2112 // the occlusion tracker on the main thread. So this test should run on the impl |
2115 // thread. | 2113 // thread. |
2116 IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude); | 2114 IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude); |
2117 | 2115 |
(...skipping 21 matching lines...) Expand all Loading... |
2139 this->CalcDrawEtc(parent); | 2137 this->CalcDrawEtc(parent); |
2140 | 2138 |
2141 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2139 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2142 typename Types::RenderSurfaceType> occlusion( | 2140 typename Types::RenderSurfaceType> occlusion( |
2143 gfx::Rect(0, 0, 1000, 1000)); | 2141 gfx::Rect(0, 0, 1000, 1000)); |
2144 | 2142 |
2145 // This is very close to the camera, so pixels in its visible_content_rect() | 2143 // This is very close to the camera, so pixels in its visible_content_rect() |
2146 // will actually go outside of the layer's clip rect. Ensure that those | 2144 // will actually go outside of the layer's clip rect. Ensure that those |
2147 // pixels don't occlude things outside the clip rect. | 2145 // pixels don't occlude things outside the clip rect. |
2148 this->VisitLayer(layer, &occlusion); | 2146 this->VisitLayer(layer, &occlusion); |
2149 this->EnterLayer(parent, &occlusion, false); | 2147 this->EnterLayer(parent, &occlusion); |
2150 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 2148 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
2151 occlusion.occlusion_from_inside_target().ToString()); | 2149 occlusion.occlusion_from_inside_target().ToString()); |
2152 EXPECT_EQ(gfx::Rect().ToString(), | 2150 EXPECT_EQ(gfx::Rect().ToString(), |
2153 occlusion.occlusion_from_outside_target().ToString()); | 2151 occlusion.occlusion_from_outside_target().ToString()); |
2154 } | 2152 } |
2155 }; | 2153 }; |
2156 | 2154 |
2157 // This test requires accumulating occlusion of 3d layers, which are skipped by | 2155 // This test requires accumulating occlusion of 3d layers, which are skipped by |
2158 // the occlusion tracker on the main thread. So this test should run on the impl | 2156 // the occlusion tracker on the main thread. So this test should run on the impl |
2159 // thread. | 2157 // thread. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2221 | 2219 |
2222 EXPECT_TRUE(layer->draw_opacity_is_animating()); | 2220 EXPECT_TRUE(layer->draw_opacity_is_animating()); |
2223 EXPECT_FALSE(surface->draw_opacity_is_animating()); | 2221 EXPECT_FALSE(surface->draw_opacity_is_animating()); |
2224 EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); | 2222 EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); |
2225 | 2223 |
2226 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2224 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2227 typename Types::RenderSurfaceType> occlusion( | 2225 typename Types::RenderSurfaceType> occlusion( |
2228 gfx::Rect(0, 0, 1000, 1000)); | 2226 gfx::Rect(0, 0, 1000, 1000)); |
2229 | 2227 |
2230 this->VisitLayer(topmost, &occlusion); | 2228 this->VisitLayer(topmost, &occlusion); |
2231 this->EnterLayer(parent2, &occlusion, false); | 2229 this->EnterLayer(parent2, &occlusion); |
2232 // This occlusion will affect all surfaces. | 2230 // This occlusion will affect all surfaces. |
2233 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2231 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
2234 occlusion.occlusion_from_inside_target().ToString()); | 2232 occlusion.occlusion_from_inside_target().ToString()); |
2235 EXPECT_EQ(gfx::Rect().ToString(), | 2233 EXPECT_EQ(gfx::Rect().ToString(), |
2236 occlusion.occlusion_from_outside_target().ToString()); | 2234 occlusion.occlusion_from_outside_target().ToString()); |
2237 EXPECT_EQ(gfx::Rect(0, 0, 250, 300).ToString(), | 2235 EXPECT_EQ(gfx::Rect(0, 0, 250, 300).ToString(), |
2238 occlusion.UnoccludedLayerContentRect( | 2236 occlusion.UnoccludedLayerContentRect( |
2239 parent2, gfx::Rect(0, 0, 300, 300)).ToString()); | 2237 parent2, gfx::Rect(0, 0, 300, 300)).ToString()); |
2240 this->LeaveLayer(parent2, &occlusion); | 2238 this->LeaveLayer(parent2, &occlusion); |
2241 | 2239 |
2242 this->VisitLayer(surface_child2, &occlusion); | 2240 this->VisitLayer(surface_child2, &occlusion); |
2243 this->EnterLayer(surface_child, &occlusion, false); | 2241 this->EnterLayer(surface_child, &occlusion); |
2244 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), | 2242 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
2245 occlusion.occlusion_from_inside_target().ToString()); | 2243 occlusion.occlusion_from_inside_target().ToString()); |
2246 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2244 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
2247 occlusion.occlusion_from_outside_target().ToString()); | 2245 occlusion.occlusion_from_outside_target().ToString()); |
2248 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), | 2246 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), |
2249 occlusion.UnoccludedLayerContentRect( | 2247 occlusion.UnoccludedLayerContentRect( |
2250 surface_child, gfx::Rect(0, 0, 200, 300))); | 2248 surface_child, gfx::Rect(0, 0, 200, 300))); |
2251 this->LeaveLayer(surface_child, &occlusion); | 2249 this->LeaveLayer(surface_child, &occlusion); |
2252 this->EnterLayer(surface, &occlusion, false); | 2250 this->EnterLayer(surface, &occlusion); |
2253 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), | 2251 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), |
2254 occlusion.occlusion_from_inside_target().ToString()); | 2252 occlusion.occlusion_from_inside_target().ToString()); |
2255 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2253 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
2256 occlusion.occlusion_from_outside_target().ToString()); | 2254 occlusion.occlusion_from_outside_target().ToString()); |
2257 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), | 2255 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), |
2258 occlusion.UnoccludedLayerContentRect( | 2256 occlusion.UnoccludedLayerContentRect( |
2259 surface, gfx::Rect(0, 0, 300, 300))); | 2257 surface, gfx::Rect(0, 0, 300, 300))); |
2260 this->LeaveLayer(surface, &occlusion); | 2258 this->LeaveLayer(surface, &occlusion); |
2261 | 2259 |
2262 this->EnterContributingSurface(surface, &occlusion, false); | 2260 this->EnterContributingSurface(surface, &occlusion); |
2263 // Occlusion within the surface is lost when leaving the animating surface. | 2261 // Occlusion within the surface is lost when leaving the animating surface. |
2264 EXPECT_EQ(gfx::Rect().ToString(), | 2262 EXPECT_EQ(gfx::Rect().ToString(), |
2265 occlusion.occlusion_from_inside_target().ToString()); | 2263 occlusion.occlusion_from_inside_target().ToString()); |
2266 EXPECT_EQ(gfx::Rect().ToString(), | 2264 EXPECT_EQ(gfx::Rect().ToString(), |
2267 occlusion.occlusion_from_outside_target().ToString()); | 2265 occlusion.occlusion_from_outside_target().ToString()); |
2268 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2266 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
2269 occlusion.UnoccludedContributingSurfaceContentRect( | 2267 occlusion.UnoccludedContributingSurfaceContentRect( |
2270 surface, false, gfx::Rect(0, 0, 300, 300))); | 2268 surface, false, gfx::Rect(0, 0, 300, 300))); |
2271 this->LeaveContributingSurface(surface, &occlusion); | 2269 this->LeaveContributingSurface(surface, &occlusion); |
2272 | 2270 |
2273 // Occlusion from outside the animating surface still exists. | 2271 // Occlusion from outside the animating surface still exists. |
2274 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2272 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
2275 occlusion.occlusion_from_inside_target().ToString()); | 2273 occlusion.occlusion_from_inside_target().ToString()); |
2276 EXPECT_EQ(gfx::Rect().ToString(), | 2274 EXPECT_EQ(gfx::Rect().ToString(), |
2277 occlusion.occlusion_from_outside_target().ToString()); | 2275 occlusion.occlusion_from_outside_target().ToString()); |
2278 | 2276 |
2279 this->VisitLayer(layer, &occlusion); | 2277 this->VisitLayer(layer, &occlusion); |
2280 this->EnterLayer(parent, &occlusion, false); | 2278 this->EnterLayer(parent, &occlusion); |
2281 | 2279 |
2282 // Occlusion is not added for the animating |layer|. | 2280 // Occlusion is not added for the animating |layer|. |
2283 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2281 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
2284 occlusion.UnoccludedLayerContentRect( | 2282 occlusion.UnoccludedLayerContentRect( |
2285 parent, gfx::Rect(0, 0, 300, 300))); | 2283 parent, gfx::Rect(0, 0, 300, 300))); |
2286 } | 2284 } |
2287 }; | 2285 }; |
2288 | 2286 |
2289 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread); | 2287 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread); |
2290 | 2288 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2342 | 2340 |
2343 EXPECT_TRUE(layer->draw_opacity_is_animating()); | 2341 EXPECT_TRUE(layer->draw_opacity_is_animating()); |
2344 EXPECT_FALSE(surface->draw_opacity_is_animating()); | 2342 EXPECT_FALSE(surface->draw_opacity_is_animating()); |
2345 EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); | 2343 EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); |
2346 | 2344 |
2347 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2345 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2348 typename Types::RenderSurfaceType> occlusion( | 2346 typename Types::RenderSurfaceType> occlusion( |
2349 gfx::Rect(0, 0, 1000, 1000)); | 2347 gfx::Rect(0, 0, 1000, 1000)); |
2350 | 2348 |
2351 this->VisitLayer(topmost, &occlusion); | 2349 this->VisitLayer(topmost, &occlusion); |
2352 this->EnterLayer(parent2, &occlusion, false); | 2350 this->EnterLayer(parent2, &occlusion); |
2353 // This occlusion will affect all surfaces. | 2351 // This occlusion will affect all surfaces. |
2354 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2352 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
2355 occlusion.occlusion_from_inside_target().ToString()); | 2353 occlusion.occlusion_from_inside_target().ToString()); |
2356 EXPECT_EQ(gfx::Rect().ToString(), | 2354 EXPECT_EQ(gfx::Rect().ToString(), |
2357 occlusion.occlusion_from_outside_target().ToString()); | 2355 occlusion.occlusion_from_outside_target().ToString()); |
2358 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2356 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
2359 occlusion.UnoccludedLayerContentRect( | 2357 occlusion.UnoccludedLayerContentRect( |
2360 parent, gfx::Rect(0, 0, 300, 300))); | 2358 parent, gfx::Rect(0, 0, 300, 300))); |
2361 this->LeaveLayer(parent2, &occlusion); | 2359 this->LeaveLayer(parent2, &occlusion); |
2362 | 2360 |
2363 this->VisitLayer(surface_child2, &occlusion); | 2361 this->VisitLayer(surface_child2, &occlusion); |
2364 this->EnterLayer(surface_child, &occlusion, false); | 2362 this->EnterLayer(surface_child, &occlusion); |
2365 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), | 2363 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
2366 occlusion.occlusion_from_inside_target().ToString()); | 2364 occlusion.occlusion_from_inside_target().ToString()); |
2367 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2365 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
2368 occlusion.occlusion_from_outside_target().ToString()); | 2366 occlusion.occlusion_from_outside_target().ToString()); |
2369 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), | 2367 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), |
2370 occlusion.UnoccludedLayerContentRect( | 2368 occlusion.UnoccludedLayerContentRect( |
2371 surface_child, gfx::Rect(0, 0, 200, 300))); | 2369 surface_child, gfx::Rect(0, 0, 200, 300))); |
2372 this->LeaveLayer(surface_child, &occlusion); | 2370 this->LeaveLayer(surface_child, &occlusion); |
2373 this->EnterLayer(surface, &occlusion, false); | 2371 this->EnterLayer(surface, &occlusion); |
2374 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), | 2372 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), |
2375 occlusion.occlusion_from_inside_target().ToString()); | 2373 occlusion.occlusion_from_inside_target().ToString()); |
2376 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2374 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
2377 occlusion.occlusion_from_outside_target().ToString()); | 2375 occlusion.occlusion_from_outside_target().ToString()); |
2378 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), | 2376 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), |
2379 occlusion.UnoccludedLayerContentRect( | 2377 occlusion.UnoccludedLayerContentRect( |
2380 surface, gfx::Rect(0, 0, 300, 300))); | 2378 surface, gfx::Rect(0, 0, 300, 300))); |
2381 this->LeaveLayer(surface, &occlusion); | 2379 this->LeaveLayer(surface, &occlusion); |
2382 | 2380 |
2383 this->EnterContributingSurface(surface, &occlusion, false); | 2381 this->EnterContributingSurface(surface, &occlusion); |
2384 // Occlusion within the surface is lost when leaving the animating surface. | 2382 // Occlusion within the surface is lost when leaving the animating surface. |
2385 EXPECT_EQ(gfx::Rect().ToString(), | 2383 EXPECT_EQ(gfx::Rect().ToString(), |
2386 occlusion.occlusion_from_inside_target().ToString()); | 2384 occlusion.occlusion_from_inside_target().ToString()); |
2387 EXPECT_EQ(gfx::Rect().ToString(), | 2385 EXPECT_EQ(gfx::Rect().ToString(), |
2388 occlusion.occlusion_from_outside_target().ToString()); | 2386 occlusion.occlusion_from_outside_target().ToString()); |
2389 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2387 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
2390 occlusion.UnoccludedContributingSurfaceContentRect( | 2388 occlusion.UnoccludedContributingSurfaceContentRect( |
2391 surface, false, gfx::Rect(0, 0, 300, 300))); | 2389 surface, false, gfx::Rect(0, 0, 300, 300))); |
2392 this->LeaveContributingSurface(surface, &occlusion); | 2390 this->LeaveContributingSurface(surface, &occlusion); |
2393 | 2391 |
2394 // Occlusion from outside the animating surface still exists. | 2392 // Occlusion from outside the animating surface still exists. |
2395 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), | 2393 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), |
2396 occlusion.occlusion_from_inside_target().ToString()); | 2394 occlusion.occlusion_from_inside_target().ToString()); |
2397 EXPECT_EQ(gfx::Rect().ToString(), | 2395 EXPECT_EQ(gfx::Rect().ToString(), |
2398 occlusion.occlusion_from_outside_target().ToString()); | 2396 occlusion.occlusion_from_outside_target().ToString()); |
2399 | 2397 |
2400 this->VisitLayer(layer, &occlusion); | 2398 this->VisitLayer(layer, &occlusion); |
2401 this->EnterLayer(parent, &occlusion, false); | 2399 this->EnterLayer(parent, &occlusion); |
2402 | 2400 |
2403 // Occlusion is not added for the animating |layer|. | 2401 // Occlusion is not added for the animating |layer|. |
2404 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), | 2402 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), |
2405 occlusion.UnoccludedLayerContentRect( | 2403 occlusion.UnoccludedLayerContentRect( |
2406 parent, gfx::Rect(0, 0, 300, 300))); | 2404 parent, gfx::Rect(0, 0, 300, 300))); |
2407 } | 2405 } |
2408 }; | 2406 }; |
2409 | 2407 |
2410 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread); | 2408 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread); |
2411 | 2409 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 EXPECT_FALSE(surface->draw_transform_is_animating()); | 2462 EXPECT_FALSE(surface->draw_transform_is_animating()); |
2465 EXPECT_TRUE(surface->screen_space_transform_is_animating()); | 2463 EXPECT_TRUE(surface->screen_space_transform_is_animating()); |
2466 EXPECT_TRUE(surface_child->draw_transform_is_animating()); | 2464 EXPECT_TRUE(surface_child->draw_transform_is_animating()); |
2467 EXPECT_TRUE(surface_child->screen_space_transform_is_animating()); | 2465 EXPECT_TRUE(surface_child->screen_space_transform_is_animating()); |
2468 | 2466 |
2469 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2467 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2470 typename Types::RenderSurfaceType> occlusion( | 2468 typename Types::RenderSurfaceType> occlusion( |
2471 gfx::Rect(0, 0, 1000, 1000)); | 2469 gfx::Rect(0, 0, 1000, 1000)); |
2472 | 2470 |
2473 this->VisitLayer(surface2, &occlusion); | 2471 this->VisitLayer(surface2, &occlusion); |
2474 this->EnterContributingSurface(surface2, &occlusion, false); | 2472 this->EnterContributingSurface(surface2, &occlusion); |
2475 | 2473 |
2476 EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), | 2474 EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), |
2477 occlusion.occlusion_from_inside_target().ToString()); | 2475 occlusion.occlusion_from_inside_target().ToString()); |
2478 | 2476 |
2479 this->LeaveContributingSurface(surface2, &occlusion); | 2477 this->LeaveContributingSurface(surface2, &occlusion); |
2480 this->EnterLayer(surface_child2, &occlusion, false); | 2478 this->EnterLayer(surface_child2, &occlusion); |
2481 | 2479 |
2482 // surface_child2 is moving in screen space but not relative to its target, | 2480 // surface_child2 is moving in screen space but not relative to its target, |
2483 // so occlusion should happen in its target space only. It also means that | 2481 // so occlusion should happen in its target space only. It also means that |
2484 // things occluding from outside the target (e.g. surface2) cannot occlude | 2482 // things occluding from outside the target (e.g. surface2) cannot occlude |
2485 // this layer. | 2483 // this layer. |
2486 EXPECT_EQ(gfx::Rect().ToString(), | 2484 EXPECT_EQ(gfx::Rect().ToString(), |
2487 occlusion.occlusion_from_outside_target().ToString()); | 2485 occlusion.occlusion_from_outside_target().ToString()); |
2488 | 2486 |
2489 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), | 2487 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), |
2490 occlusion.UnoccludedLayerContentRect( | 2488 occlusion.UnoccludedLayerContentRect( |
2491 surface_child2, gfx::Rect(0, 0, 100, 300))); | 2489 surface_child2, gfx::Rect(0, 0, 100, 300))); |
2492 EXPECT_FALSE( | 2490 EXPECT_FALSE( |
2493 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 50, 300))); | 2491 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 50, 300))); |
2494 | 2492 |
2495 this->LeaveLayer(surface_child2, &occlusion); | 2493 this->LeaveLayer(surface_child2, &occlusion); |
2496 this->EnterLayer(surface_child, &occlusion, false); | 2494 this->EnterLayer(surface_child, &occlusion); |
2497 EXPECT_FALSE( | 2495 EXPECT_FALSE( |
2498 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 100, 300))); | 2496 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 100, 300))); |
2499 EXPECT_EQ(gfx::Rect().ToString(), | 2497 EXPECT_EQ(gfx::Rect().ToString(), |
2500 occlusion.occlusion_from_outside_target().ToString()); | 2498 occlusion.occlusion_from_outside_target().ToString()); |
2501 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), | 2499 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
2502 occlusion.occlusion_from_inside_target().ToString()); | 2500 occlusion.occlusion_from_inside_target().ToString()); |
2503 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), | 2501 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), |
2504 occlusion.UnoccludedLayerContentRect( | 2502 occlusion.UnoccludedLayerContentRect( |
2505 surface, gfx::Rect(0, 0, 300, 300))); | 2503 surface, gfx::Rect(0, 0, 300, 300))); |
2506 | 2504 |
2507 // The surface_child is occluded by the surface_child2, but is moving | 2505 // The surface_child is occluded by the surface_child2, but is moving |
2508 // relative its target, so it can't be occluded. | 2506 // relative its target, so it can't be occluded. |
2509 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 300), | 2507 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 300), |
2510 occlusion.UnoccludedLayerContentRect( | 2508 occlusion.UnoccludedLayerContentRect( |
2511 surface_child, gfx::Rect(0, 0, 200, 300))); | 2509 surface_child, gfx::Rect(0, 0, 200, 300))); |
2512 EXPECT_FALSE( | 2510 EXPECT_FALSE( |
2513 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 50, 300))); | 2511 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 50, 300))); |
2514 | 2512 |
2515 this->LeaveLayer(surface_child, &occlusion); | 2513 this->LeaveLayer(surface_child, &occlusion); |
2516 this->EnterLayer(surface, &occlusion, false); | 2514 this->EnterLayer(surface, &occlusion); |
2517 // The surface_child is moving in screen space but not relative to its | 2515 // The surface_child is moving in screen space but not relative to its |
2518 // target, so occlusion should happen from within the target only. | 2516 // target, so occlusion should happen from within the target only. |
2519 EXPECT_EQ(gfx::Rect().ToString(), | 2517 EXPECT_EQ(gfx::Rect().ToString(), |
2520 occlusion.occlusion_from_outside_target().ToString()); | 2518 occlusion.occlusion_from_outside_target().ToString()); |
2521 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), | 2519 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), |
2522 occlusion.occlusion_from_inside_target().ToString()); | 2520 occlusion.occlusion_from_inside_target().ToString()); |
2523 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), | 2521 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), |
2524 occlusion.UnoccludedLayerContentRect( | 2522 occlusion.UnoccludedLayerContentRect( |
2525 surface, gfx::Rect(0, 0, 300, 300))); | 2523 surface, gfx::Rect(0, 0, 300, 300))); |
2526 | 2524 |
2527 this->LeaveLayer(surface, &occlusion); | 2525 this->LeaveLayer(surface, &occlusion); |
2528 // The surface's owning layer is moving in screen space but not relative to | 2526 // The surface's owning layer is moving in screen space but not relative to |
2529 // its target, so occlusion should happen within the target only. | 2527 // its target, so occlusion should happen within the target only. |
2530 EXPECT_EQ(gfx::Rect().ToString(), | 2528 EXPECT_EQ(gfx::Rect().ToString(), |
2531 occlusion.occlusion_from_outside_target().ToString()); | 2529 occlusion.occlusion_from_outside_target().ToString()); |
2532 EXPECT_EQ(gfx::Rect(0, 0, 300, 300).ToString(), | 2530 EXPECT_EQ(gfx::Rect(0, 0, 300, 300).ToString(), |
2533 occlusion.occlusion_from_inside_target().ToString()); | 2531 occlusion.occlusion_from_inside_target().ToString()); |
2534 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), | 2532 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), |
2535 occlusion.UnoccludedLayerContentRect( | 2533 occlusion.UnoccludedLayerContentRect( |
2536 surface, gfx::Rect(0, 0, 300, 300))); | 2534 surface, gfx::Rect(0, 0, 300, 300))); |
2537 | 2535 |
2538 this->EnterContributingSurface(surface, &occlusion, false); | 2536 this->EnterContributingSurface(surface, &occlusion); |
2539 // The contributing |surface| is animating so it can't be occluded. | 2537 // The contributing |surface| is animating so it can't be occluded. |
2540 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 300), | 2538 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 300), |
2541 occlusion.UnoccludedContributingSurfaceContentRect( | 2539 occlusion.UnoccludedContributingSurfaceContentRect( |
2542 surface, false, gfx::Rect(0, 0, 300, 300))); | 2540 surface, false, gfx::Rect(0, 0, 300, 300))); |
2543 this->LeaveContributingSurface(surface, &occlusion); | 2541 this->LeaveContributingSurface(surface, &occlusion); |
2544 | 2542 |
2545 this->EnterLayer(layer, &occlusion, false); | 2543 this->EnterLayer(layer, &occlusion); |
2546 // The |surface| is moving in the screen and in its target, so all occlusion | 2544 // The |surface| is moving in the screen and in its target, so all occlusion |
2547 // within the surface is lost when leaving it. | 2545 // within the surface is lost when leaving it. |
2548 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300), | 2546 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300), |
2549 occlusion.UnoccludedLayerContentRect( | 2547 occlusion.UnoccludedLayerContentRect( |
2550 parent, gfx::Rect(0, 0, 300, 300))); | 2548 parent, gfx::Rect(0, 0, 300, 300))); |
2551 this->LeaveLayer(layer, &occlusion); | 2549 this->LeaveLayer(layer, &occlusion); |
2552 | 2550 |
2553 this->EnterLayer(parent, &occlusion, false); | 2551 this->EnterLayer(parent, &occlusion); |
2554 // The |layer| is animating in the screen and in its target, so no occlusion | 2552 // The |layer| is animating in the screen and in its target, so no occlusion |
2555 // is added. | 2553 // is added. |
2556 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300), | 2554 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300), |
2557 occlusion.UnoccludedLayerContentRect( | 2555 occlusion.UnoccludedLayerContentRect( |
2558 parent, gfx::Rect(0, 0, 300, 300))); | 2556 parent, gfx::Rect(0, 0, 300, 300))); |
2559 } | 2557 } |
2560 }; | 2558 }; |
2561 | 2559 |
2562 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationTranslateOnMainThread); | 2560 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationTranslateOnMainThread); |
2563 | 2561 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 occlusion.occlusion_from_inside_target().ToString()); | 2691 occlusion.occlusion_from_inside_target().ToString()); |
2694 | 2692 |
2695 this->VisitLayer(surface, &occlusion); | 2693 this->VisitLayer(surface, &occlusion); |
2696 | 2694 |
2697 // Render target with replica ignores occlusion from outside. | 2695 // Render target with replica ignores occlusion from outside. |
2698 EXPECT_EQ(gfx::Rect().ToString(), | 2696 EXPECT_EQ(gfx::Rect().ToString(), |
2699 occlusion.occlusion_from_outside_target().ToString()); | 2697 occlusion.occlusion_from_outside_target().ToString()); |
2700 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 2698 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
2701 occlusion.occlusion_from_inside_target().ToString()); | 2699 occlusion.occlusion_from_inside_target().ToString()); |
2702 | 2700 |
2703 this->EnterContributingSurface(surface, &occlusion, false); | 2701 this->EnterContributingSurface(surface, &occlusion); |
2704 | 2702 |
2705 // Surface is not occluded so it shouldn't think it is. | 2703 // Surface is not occluded so it shouldn't think it is. |
2706 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), | 2704 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), |
2707 occlusion.UnoccludedContributingSurfaceContentRect( | 2705 occlusion.UnoccludedContributingSurfaceContentRect( |
2708 surface, false, gfx::Rect(0, 0, 100, 100))); | 2706 surface, false, gfx::Rect(0, 0, 100, 100))); |
2709 } | 2707 } |
2710 }; | 2708 }; |
2711 | 2709 |
2712 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); | 2710 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); |
2713 | 2711 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 occlusion.occlusion_from_inside_target().ToString()); | 2749 occlusion.occlusion_from_inside_target().ToString()); |
2752 | 2750 |
2753 this->VisitLayer(surface, &occlusion); | 2751 this->VisitLayer(surface, &occlusion); |
2754 | 2752 |
2755 // Render target with replica ignores occlusion from outside. | 2753 // Render target with replica ignores occlusion from outside. |
2756 EXPECT_EQ(gfx::Rect().ToString(), | 2754 EXPECT_EQ(gfx::Rect().ToString(), |
2757 occlusion.occlusion_from_outside_target().ToString()); | 2755 occlusion.occlusion_from_outside_target().ToString()); |
2758 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 2756 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
2759 occlusion.occlusion_from_inside_target().ToString()); | 2757 occlusion.occlusion_from_inside_target().ToString()); |
2760 | 2758 |
2761 this->EnterContributingSurface(surface, &occlusion, false); | 2759 this->EnterContributingSurface(surface, &occlusion); |
2762 | 2760 |
2763 // Surface is occluded, but only the top 10px of the replica. | 2761 // Surface is occluded, but only the top 10px of the replica. |
2764 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), | 2762 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), |
2765 occlusion.UnoccludedContributingSurfaceContentRect( | 2763 occlusion.UnoccludedContributingSurfaceContentRect( |
2766 surface, false, gfx::Rect(0, 0, 100, 100))); | 2764 surface, false, gfx::Rect(0, 0, 100, 100))); |
2767 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90), | 2765 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90), |
2768 occlusion.UnoccludedContributingSurfaceContentRect( | 2766 occlusion.UnoccludedContributingSurfaceContentRect( |
2769 surface, true, gfx::Rect(0, 0, 100, 100))); | 2767 surface, true, gfx::Rect(0, 0, 100, 100))); |
2770 } | 2768 } |
2771 }; | 2769 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2818 occlusion.occlusion_from_inside_target().ToString()); | 2816 occlusion.occlusion_from_inside_target().ToString()); |
2819 | 2817 |
2820 this->VisitLayer(surface, &occlusion); | 2818 this->VisitLayer(surface, &occlusion); |
2821 | 2819 |
2822 // Render target with replica ignores occlusion from outside. | 2820 // Render target with replica ignores occlusion from outside. |
2823 EXPECT_EQ(gfx::Rect().ToString(), | 2821 EXPECT_EQ(gfx::Rect().ToString(), |
2824 occlusion.occlusion_from_outside_target().ToString()); | 2822 occlusion.occlusion_from_outside_target().ToString()); |
2825 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | 2823 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), |
2826 occlusion.occlusion_from_inside_target().ToString()); | 2824 occlusion.occlusion_from_inside_target().ToString()); |
2827 | 2825 |
2828 this->EnterContributingSurface(surface, &occlusion, false); | 2826 this->EnterContributingSurface(surface, &occlusion); |
2829 | 2827 |
2830 // Surface and replica are occluded different amounts. | 2828 // Surface and replica are occluded different amounts. |
2831 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100), | 2829 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100), |
2832 occlusion.UnoccludedContributingSurfaceContentRect( | 2830 occlusion.UnoccludedContributingSurfaceContentRect( |
2833 surface, false, gfx::Rect(0, 0, 100, 100))); | 2831 surface, false, gfx::Rect(0, 0, 100, 100))); |
2834 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100), | 2832 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100), |
2835 occlusion.UnoccludedContributingSurfaceContentRect( | 2833 occlusion.UnoccludedContributingSurfaceContentRect( |
2836 surface, true, gfx::Rect(0, 0, 100, 100))); | 2834 surface, true, gfx::Rect(0, 0, 100, 100))); |
2837 } | 2835 } |
2838 }; | 2836 }; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2889 // In its own surface, surface_child is at 0,0 as is its occlusion. | 2887 // In its own surface, surface_child is at 0,0 as is its occlusion. |
2890 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), | 2888 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
2891 occlusion.occlusion_from_inside_target().ToString()); | 2889 occlusion.occlusion_from_inside_target().ToString()); |
2892 | 2890 |
2893 // The root layer always has a clip rect. So the parent of |surface| has a | 2891 // The root layer always has a clip rect. So the parent of |surface| has a |
2894 // clip rect. However, the owning layer for |surface| does not mask to | 2892 // clip rect. However, the owning layer for |surface| does not mask to |
2895 // bounds, so it doesn't have a clip rect of its own. Thus the parent of | 2893 // bounds, so it doesn't have a clip rect of its own. Thus the parent of |
2896 // |surface_child| exercises different code paths as its parent does not | 2894 // |surface_child| exercises different code paths as its parent does not |
2897 // have a clip rect. | 2895 // have a clip rect. |
2898 | 2896 |
2899 this->EnterContributingSurface(surface_child, &occlusion, false); | 2897 this->EnterContributingSurface(surface_child, &occlusion); |
2900 // The surface_child's parent does not have a clip rect as it owns a render | 2898 // The surface_child's parent does not have a clip rect as it owns a render |
2901 // surface. Make sure the unoccluded rect does not get clipped away | 2899 // surface. Make sure the unoccluded rect does not get clipped away |
2902 // inappropriately. | 2900 // inappropriately. |
2903 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10), | 2901 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10), |
2904 occlusion.UnoccludedContributingSurfaceContentRect( | 2902 occlusion.UnoccludedContributingSurfaceContentRect( |
2905 surface_child, false, gfx::Rect(0, 0, 100, 50))); | 2903 surface_child, false, gfx::Rect(0, 0, 100, 50))); |
2906 this->LeaveContributingSurface(surface_child, &occlusion); | 2904 this->LeaveContributingSurface(surface_child, &occlusion); |
2907 | 2905 |
2908 // When the surface_child's occlusion is transformed up to its parent, make | 2906 // When the surface_child's occlusion is transformed up to its parent, make |
2909 // sure it is not clipped away inappropriately also. | 2907 // sure it is not clipped away inappropriately also. |
2910 this->EnterLayer(surface, &occlusion, false); | 2908 this->EnterLayer(surface, &occlusion); |
2911 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), | 2909 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), |
2912 occlusion.occlusion_from_outside_target().ToString()); | 2910 occlusion.occlusion_from_outside_target().ToString()); |
2913 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), | 2911 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), |
2914 occlusion.occlusion_from_inside_target().ToString()); | 2912 occlusion.occlusion_from_inside_target().ToString()); |
2915 this->LeaveLayer(surface, &occlusion); | 2913 this->LeaveLayer(surface, &occlusion); |
2916 | 2914 |
2917 this->EnterContributingSurface(surface, &occlusion, false); | 2915 this->EnterContributingSurface(surface, &occlusion); |
2918 // The surface's parent does have a clip rect as it is the root layer. | 2916 // The surface's parent does have a clip rect as it is the root layer. |
2919 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50), | 2917 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50), |
2920 occlusion.UnoccludedContributingSurfaceContentRect( | 2918 occlusion.UnoccludedContributingSurfaceContentRect( |
2921 surface, false, gfx::Rect(0, 0, 100, 100))); | 2919 surface, false, gfx::Rect(0, 0, 100, 100))); |
2922 } | 2920 } |
2923 }; | 2921 }; |
2924 | 2922 |
2925 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); | 2923 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); |
2926 | 2924 |
2927 template <class Types> | 2925 template <class Types> |
(...skipping 19 matching lines...) Expand all Loading... |
2947 { | 2945 { |
2948 // Make a viewport rect that is larger than the root layer. | 2946 // Make a viewport rect that is larger than the root layer. |
2949 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2947 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2950 typename Types::RenderSurfaceType> occlusion( | 2948 typename Types::RenderSurfaceType> occlusion( |
2951 gfx::Rect(0, 0, 1000, 1000)); | 2949 gfx::Rect(0, 0, 1000, 1000)); |
2952 | 2950 |
2953 this->VisitLayer(surface, &occlusion); | 2951 this->VisitLayer(surface, &occlusion); |
2954 | 2952 |
2955 // The root layer always has a clip rect. So the parent of |surface| has a | 2953 // The root layer always has a clip rect. So the parent of |surface| has a |
2956 // clip rect giving the surface itself a clip rect. | 2954 // clip rect giving the surface itself a clip rect. |
2957 this->EnterContributingSurface(surface, &occlusion, false); | 2955 this->EnterContributingSurface(surface, &occlusion); |
2958 // Make sure the parent's clip rect clips the unoccluded region of the | 2956 // Make sure the parent's clip rect clips the unoccluded region of the |
2959 // child surface. | 2957 // child surface. |
2960 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200), | 2958 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200), |
2961 occlusion.UnoccludedContributingSurfaceContentRect( | 2959 occlusion.UnoccludedContributingSurfaceContentRect( |
2962 surface, false, gfx::Rect(0, 0, 100, 300))); | 2960 surface, false, gfx::Rect(0, 0, 100, 300))); |
2963 } | 2961 } |
2964 this->ResetLayerIterator(); | 2962 this->ResetLayerIterator(); |
2965 { | 2963 { |
2966 // Make a viewport rect that is smaller than the root layer. | 2964 // Make a viewport rect that is smaller than the root layer. |
2967 TestOcclusionTrackerWithClip<typename Types::LayerType, | 2965 TestOcclusionTrackerWithClip<typename Types::LayerType, |
2968 typename Types::RenderSurfaceType> occlusion( | 2966 typename Types::RenderSurfaceType> occlusion( |
2969 gfx::Rect(0, 0, 100, 100)); | 2967 gfx::Rect(0, 0, 100, 100)); |
2970 | 2968 |
2971 this->VisitLayer(surface, &occlusion); | 2969 this->VisitLayer(surface, &occlusion); |
2972 | 2970 |
2973 // The root layer always has a clip rect. So the parent of |surface| has a | 2971 // The root layer always has a clip rect. So the parent of |surface| has a |
2974 // clip rect giving the surface itself a clip rect. | 2972 // clip rect giving the surface itself a clip rect. |
2975 this->EnterContributingSurface(surface, &occlusion, false); | 2973 this->EnterContributingSurface(surface, &occlusion); |
2976 // Make sure the viewport rect clips the unoccluded region of the child | 2974 // Make sure the viewport rect clips the unoccluded region of the child |
2977 // surface. | 2975 // surface. |
2978 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), | 2976 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), |
2979 occlusion.UnoccludedContributingSurfaceContentRect( | 2977 occlusion.UnoccludedContributingSurfaceContentRect( |
2980 surface, false, gfx::Rect(0, 0, 100, 300))); | 2978 surface, false, gfx::Rect(0, 0, 100, 300))); |
2981 } | 2979 } |
2982 } | 2980 } |
2983 }; | 2981 }; |
2984 | 2982 |
2985 ALL_OCCLUSIONTRACKER_TEST( | 2983 ALL_OCCLUSIONTRACKER_TEST( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3035 occlusion.occlusion_from_outside_target().ToString()); | 3033 occlusion.occlusion_from_outside_target().ToString()); |
3036 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), | 3034 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), |
3037 occlusion.occlusion_from_inside_target().ToString()); | 3035 occlusion.occlusion_from_inside_target().ToString()); |
3038 | 3036 |
3039 // The root layer always has a clip rect. So the parent of |surface| has a | 3037 // The root layer always has a clip rect. So the parent of |surface| has a |
3040 // clip rect. However, the owning layer for |surface| does not mask to | 3038 // clip rect. However, the owning layer for |surface| does not mask to |
3041 // bounds, so it doesn't have a clip rect of its own. Thus the parent of | 3039 // bounds, so it doesn't have a clip rect of its own. Thus the parent of |
3042 // |surface_child| exercises different code paths as its parent does not | 3040 // |surface_child| exercises different code paths as its parent does not |
3043 // have a clip rect. | 3041 // have a clip rect. |
3044 | 3042 |
3045 this->EnterContributingSurface(surface_child, &occlusion, false); | 3043 this->EnterContributingSurface(surface_child, &occlusion); |
3046 // The surface_child's parent does not have a clip rect as it owns a render | 3044 // The surface_child's parent does not have a clip rect as it owns a render |
3047 // surface. | 3045 // surface. |
3048 EXPECT_EQ( | 3046 EXPECT_EQ( |
3049 gfx::Rect(0, 50, 80, 50).ToString(), | 3047 gfx::Rect(0, 50, 80, 50).ToString(), |
3050 occlusion.UnoccludedContributingSurfaceContentRect( | 3048 occlusion.UnoccludedContributingSurfaceContentRect( |
3051 surface_child, false, gfx::Rect(0, 0, 100, 100)).ToString()); | 3049 surface_child, false, gfx::Rect(0, 0, 100, 100)).ToString()); |
3052 this->LeaveContributingSurface(surface_child, &occlusion); | 3050 this->LeaveContributingSurface(surface_child, &occlusion); |
3053 | 3051 |
3054 this->VisitLayer(surface, &occlusion); | 3052 this->VisitLayer(surface, &occlusion); |
3055 this->EnterContributingSurface(surface, &occlusion, false); | 3053 this->EnterContributingSurface(surface, &occlusion); |
3056 // The surface's parent does have a clip rect as it is the root layer. | 3054 // The surface's parent does have a clip rect as it is the root layer. |
3057 EXPECT_EQ(gfx::Rect(0, 50, 80, 50).ToString(), | 3055 EXPECT_EQ(gfx::Rect(0, 50, 80, 50).ToString(), |
3058 occlusion.UnoccludedContributingSurfaceContentRect( | 3056 occlusion.UnoccludedContributingSurfaceContentRect( |
3059 surface, false, gfx::Rect(0, 0, 100, 100)).ToString()); | 3057 surface, false, gfx::Rect(0, 0, 100, 100)).ToString()); |
3060 } | 3058 } |
3061 }; | 3059 }; |
3062 | 3060 |
3063 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfClippingSurface); | 3061 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfClippingSurface); |
3064 | 3062 |
3065 template <class Types> | 3063 template <class Types> |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3154 occlusion.occlusion_from_outside_target().ToString()); | 3152 occlusion.occlusion_from_outside_target().ToString()); |
3155 EXPECT_EQ(gfx::Rect().ToString(), | 3153 EXPECT_EQ(gfx::Rect().ToString(), |
3156 occlusion.occlusion_from_inside_target().ToString()); | 3154 occlusion.occlusion_from_inside_target().ToString()); |
3157 | 3155 |
3158 // The surface has a background blur, so it needs pixels that are currently | 3156 // The surface has a background blur, so it needs pixels that are currently |
3159 // considered occluded in order to be drawn. So the pixels it needs should | 3157 // considered occluded in order to be drawn. So the pixels it needs should |
3160 // be removed some the occluded area so that when we get to the parent they | 3158 // be removed some the occluded area so that when we get to the parent they |
3161 // are drawn. | 3159 // are drawn. |
3162 this->VisitContributingSurface(filtered_surface, &occlusion); | 3160 this->VisitContributingSurface(filtered_surface, &occlusion); |
3163 | 3161 |
3164 this->EnterLayer(parent, &occlusion, false); | 3162 this->EnterLayer(parent, &occlusion); |
3165 | 3163 |
3166 Region expected_blurred_occlusion; | 3164 Region expected_blurred_occlusion; |
3167 expected_blurred_occlusion.Union(gfx::Rect(0, 0, 200, 50 - outset_top)); | 3165 expected_blurred_occlusion.Union(gfx::Rect(0, 0, 200, 50 - outset_top)); |
3168 expected_blurred_occlusion.Union(gfx::Rect( | 3166 expected_blurred_occlusion.Union(gfx::Rect( |
3169 0, 50 - outset_top, 50 - outset_left, 50 + outset_top + outset_bottom)); | 3167 0, 50 - outset_top, 50 - outset_left, 50 + outset_top + outset_bottom)); |
3170 expected_blurred_occlusion.Union( | 3168 expected_blurred_occlusion.Union( |
3171 gfx::Rect(100 + outset_right, | 3169 gfx::Rect(100 + outset_right, |
3172 50 - outset_top, | 3170 50 - outset_top, |
3173 100 - outset_right, | 3171 100 - outset_right, |
3174 50 + outset_top + outset_bottom)); | 3172 50 + outset_top + outset_bottom)); |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3606 EXPECT_EQ(gfx::Rect().ToString(), | 3604 EXPECT_EQ(gfx::Rect().ToString(), |
3607 occlusion.occlusion_from_outside_target().ToString()); | 3605 occlusion.occlusion_from_outside_target().ToString()); |
3608 EXPECT_EQ(gfx::Rect(tracking_size).ToString(), | 3606 EXPECT_EQ(gfx::Rect(tracking_size).ToString(), |
3609 occlusion.occlusion_from_inside_target().ToString()); | 3607 occlusion.occlusion_from_inside_target().ToString()); |
3610 } | 3608 } |
3611 }; | 3609 }; |
3612 | 3610 |
3613 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize); | 3611 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize); |
3614 | 3612 |
3615 template <class Types> | 3613 template <class Types> |
3616 class OcclusionTrackerTestPreventOcclusionOnLayer | |
3617 : public OcclusionTrackerTest<Types> { | |
3618 protected: | |
3619 explicit OcclusionTrackerTestPreventOcclusionOnLayer(bool opaque_layers) | |
3620 : OcclusionTrackerTest<Types>(opaque_layers) {} | |
3621 void RunMyTest() { | |
3622 typename Types::ContentLayerType* parent = this->CreateRoot( | |
3623 this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); | |
3624 typename Types::LayerType* unprevented = this->CreateDrawingLayer( | |
3625 parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), false); | |
3626 typename Types::LayerType* prevented = this->CreateDrawingLayer( | |
3627 parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), false); | |
3628 typename Types::LayerType* occluding = this->CreateDrawingLayer( | |
3629 parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), true); | |
3630 this->CalcDrawEtc(parent); | |
3631 | |
3632 TestOcclusionTrackerWithClip<typename Types::LayerType, | |
3633 typename Types::RenderSurfaceType> occlusion( | |
3634 gfx::Rect(0, 0, 1000, 1000)); | |
3635 | |
3636 this->VisitLayer(occluding, &occlusion); | |
3637 this->EnterLayer(prevented, &occlusion, true); | |
3638 | |
3639 // This layer is not occluded because it is prevented. | |
3640 EXPECT_FALSE(occlusion.OccludedLayer(prevented, | |
3641 gfx::Rect(50, 50))); | |
3642 | |
3643 EXPECT_EQ(gfx::Rect(50, 50).ToString(), | |
3644 occlusion.UnoccludedLayerContentRect( | |
3645 prevented, | |
3646 gfx::Rect(50, 50)).ToString()); | |
3647 | |
3648 this->LeaveLayer(prevented, &occlusion); | |
3649 this->EnterLayer(unprevented, &occlusion, false); | |
3650 | |
3651 // This layer is fully occluded. | |
3652 EXPECT_TRUE(occlusion.OccludedLayer(unprevented, | |
3653 gfx::Rect(50, 50))); | |
3654 | |
3655 EXPECT_EQ(gfx::Rect().ToString(), | |
3656 occlusion.UnoccludedLayerContentRect( | |
3657 unprevented, | |
3658 gfx::Rect(50, 50)).ToString()); | |
3659 | |
3660 this->LeaveLayer(unprevented, &occlusion); | |
3661 } | |
3662 }; | |
3663 | |
3664 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestPreventOcclusionOnLayer) | |
3665 | |
3666 template <class Types> | |
3667 class OcclusionTrackerTestPreventOcclusionOnContributingSurface | |
3668 : public OcclusionTrackerTest<Types> { | |
3669 protected: | |
3670 explicit OcclusionTrackerTestPreventOcclusionOnContributingSurface( | |
3671 bool opaque_layers) | |
3672 : OcclusionTrackerTest<Types>(opaque_layers) {} | |
3673 void RunMyTest() { | |
3674 typename Types::ContentLayerType* parent = this->CreateRoot( | |
3675 this->identity_matrix, gfx::PointF(), gfx::Size(400, 400)); | |
3676 typename Types::LayerType* unprevented = this->CreateDrawingSurface( | |
3677 parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), false); | |
3678 typename Types::LayerType* prevented = this->CreateDrawingSurface( | |
3679 parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), false); | |
3680 typename Types::LayerType* occluding = this->CreateDrawingLayer( | |
3681 parent, this->identity_matrix, gfx::PointF(), gfx::Size(50, 50), true); | |
3682 this->CalcDrawEtc(parent); | |
3683 | |
3684 TestOcclusionTrackerWithClip<typename Types::LayerType, | |
3685 typename Types::RenderSurfaceType> occlusion( | |
3686 gfx::Rect(0, 0, 1000, 1000)); | |
3687 | |
3688 this->VisitLayer(occluding, &occlusion); | |
3689 this->EnterLayer(prevented, &occlusion, true); | |
3690 | |
3691 // This layer is not occluded because it is prevented. | |
3692 EXPECT_EQ(gfx::Rect(50, 50).ToString(), | |
3693 occlusion.UnoccludedLayerContentRect( | |
3694 prevented, | |
3695 gfx::Rect(50, 50)).ToString()); | |
3696 | |
3697 this->LeaveLayer(prevented, &occlusion); | |
3698 this->EnterContributingSurface(prevented, &occlusion, true); | |
3699 | |
3700 // This contributing surface is not occluded because it is prevented. | |
3701 EXPECT_EQ(gfx::Rect(50, 50).ToString(), | |
3702 occlusion.UnoccludedContributingSurfaceContentRect( | |
3703 prevented, | |
3704 false, // is_replica | |
3705 gfx::Rect(50, 50)).ToString()); | |
3706 | |
3707 this->LeaveContributingSurface(prevented, &occlusion); | |
3708 this->EnterLayer(unprevented, &occlusion, false); | |
3709 | |
3710 // This layer is fully occluded from outside its surface. | |
3711 EXPECT_EQ(gfx::Rect().ToString(), | |
3712 occlusion.UnoccludedLayerContentRect( | |
3713 unprevented, | |
3714 gfx::Rect(50, 50)).ToString()); | |
3715 | |
3716 this->LeaveLayer(unprevented, &occlusion); | |
3717 this->EnterContributingSurface(unprevented, &occlusion, false); | |
3718 | |
3719 // This contributing surface is fully occluded. | |
3720 EXPECT_EQ(gfx::Rect().ToString(), | |
3721 occlusion.UnoccludedContributingSurfaceContentRect( | |
3722 unprevented, | |
3723 false, // is_replica | |
3724 gfx::Rect(50, 50)).ToString()); | |
3725 | |
3726 this->LeaveContributingSurface(unprevented, &occlusion); | |
3727 } | |
3728 }; | |
3729 | |
3730 ALL_OCCLUSIONTRACKER_TEST( | |
3731 OcclusionTrackerTestPreventOcclusionOnContributingSurface) | |
3732 | |
3733 template <class Types> | |
3734 class OcclusionTrackerTestScaledLayerIsClipped | 3614 class OcclusionTrackerTestScaledLayerIsClipped |
3735 : public OcclusionTrackerTest<Types> { | 3615 : public OcclusionTrackerTest<Types> { |
3736 protected: | 3616 protected: |
3737 explicit OcclusionTrackerTestScaledLayerIsClipped(bool opaque_layers) | 3617 explicit OcclusionTrackerTestScaledLayerIsClipped(bool opaque_layers) |
3738 : OcclusionTrackerTest<Types>(opaque_layers) {} | 3618 : OcclusionTrackerTest<Types>(opaque_layers) {} |
3739 void RunMyTest() { | 3619 void RunMyTest() { |
3740 gfx::Transform scale_transform; | 3620 gfx::Transform scale_transform; |
3741 scale_transform.Scale(512.0, 512.0); | 3621 scale_transform.Scale(512.0, 512.0); |
3742 | 3622 |
3743 typename Types::ContentLayerType* parent = this->CreateRoot( | 3623 typename Types::ContentLayerType* parent = this->CreateRoot( |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3933 occlusion.occlusion_from_outside_target().ToString()); | 3813 occlusion.occlusion_from_outside_target().ToString()); |
3934 EXPECT_EQ(gfx::Rect().ToString(), | 3814 EXPECT_EQ(gfx::Rect().ToString(), |
3935 occlusion.occlusion_from_inside_target().ToString()); | 3815 occlusion.occlusion_from_inside_target().ToString()); |
3936 } | 3816 } |
3937 }; | 3817 }; |
3938 | 3818 |
3939 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestEmptyEventLayerDoesNotOcclude) | 3819 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestEmptyEventLayerDoesNotOcclude) |
3940 | 3820 |
3941 } // namespace | 3821 } // namespace |
3942 } // namespace cc | 3822 } // namespace cc |
OLD | NEW |