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

Side by Side Diff: cc/trees/occlusion_tracker_unittest.cc

Issue 12912010: cc: Convert non-const reference arguments to pointers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ui/compositor Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/quad_culler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 1.f, 339 1.f,
340 dummy_max_texture_size, 340 dummy_max_texture_size,
341 false, 341 false,
342 &render_surface_layer_list_); 342 &render_surface_layer_list_);
343 343
344 layer_iterator_ = layer_iterator_begin_ = 344 layer_iterator_ = layer_iterator_begin_ =
345 Types::TestLayerIterator::Begin(&render_surface_layer_list_); 345 Types::TestLayerIterator::Begin(&render_surface_layer_list_);
346 } 346 }
347 347
348 void EnterLayer(typename Types::LayerType* layer, 348 void EnterLayer(typename Types::LayerType* layer,
349 typename Types::OcclusionTrackerType& occlusion) { 349 typename Types::OcclusionTrackerType* occlusion) {
350 ASSERT_EQ(layer, *layer_iterator_); 350 ASSERT_EQ(layer, *layer_iterator_);
351 ASSERT_TRUE(layer_iterator_.represents_itself()); 351 ASSERT_TRUE(layer_iterator_.represents_itself());
352 occlusion.EnterLayer(layer_iterator_); 352 occlusion->EnterLayer(layer_iterator_);
353 } 353 }
354 354
355 void LeaveLayer(typename Types::LayerType* layer, 355 void LeaveLayer(typename Types::LayerType* layer,
356 typename Types::OcclusionTrackerType& occlusion) { 356 typename Types::OcclusionTrackerType* occlusion) {
357 ASSERT_EQ(layer, *layer_iterator_); 357 ASSERT_EQ(layer, *layer_iterator_);
358 ASSERT_TRUE(layer_iterator_.represents_itself()); 358 ASSERT_TRUE(layer_iterator_.represents_itself());
359 occlusion.LeaveLayer(layer_iterator_); 359 occlusion->LeaveLayer(layer_iterator_);
360 ++layer_iterator_; 360 ++layer_iterator_;
361 } 361 }
362 362
363 void VisitLayer(typename Types::LayerType* layer, 363 void VisitLayer(typename Types::LayerType* layer,
364 typename Types::OcclusionTrackerType& occlusion) { 364 typename Types::OcclusionTrackerType* occlusion) {
365 EnterLayer(layer, occlusion); 365 EnterLayer(layer, occlusion);
366 LeaveLayer(layer, occlusion); 366 LeaveLayer(layer, occlusion);
367 } 367 }
368 368
369 void EnterContributingSurface( 369 void EnterContributingSurface(
370 typename Types::LayerType* layer, 370 typename Types::LayerType* layer,
371 typename Types::OcclusionTrackerType& occlusion) { 371 typename Types::OcclusionTrackerType* occlusion) {
372 ASSERT_EQ(layer, *layer_iterator_); 372 ASSERT_EQ(layer, *layer_iterator_);
373 ASSERT_TRUE(layer_iterator_.represents_target_render_surface()); 373 ASSERT_TRUE(layer_iterator_.represents_target_render_surface());
374 occlusion.EnterLayer(layer_iterator_); 374 occlusion->EnterLayer(layer_iterator_);
375 occlusion.LeaveLayer(layer_iterator_); 375 occlusion->LeaveLayer(layer_iterator_);
376 ++layer_iterator_; 376 ++layer_iterator_;
377 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); 377 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface());
378 occlusion.EnterLayer(layer_iterator_); 378 occlusion->EnterLayer(layer_iterator_);
379 } 379 }
380 380
381 void LeaveContributingSurface( 381 void LeaveContributingSurface(
382 typename Types::LayerType* layer, 382 typename Types::LayerType* layer,
383 typename Types::OcclusionTrackerType& occlusion) { 383 typename Types::OcclusionTrackerType* occlusion) {
384 ASSERT_EQ(layer, *layer_iterator_); 384 ASSERT_EQ(layer, *layer_iterator_);
385 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface()); 385 ASSERT_TRUE(layer_iterator_.represents_contributing_render_surface());
386 occlusion.LeaveLayer(layer_iterator_); 386 occlusion->LeaveLayer(layer_iterator_);
387 ++layer_iterator_; 387 ++layer_iterator_;
388 } 388 }
389 389
390 void VisitContributingSurface( 390 void VisitContributingSurface(
391 typename Types::LayerType* layer, 391 typename Types::LayerType* layer,
392 typename Types::OcclusionTrackerType& occlusion) { 392 typename Types::OcclusionTrackerType* occlusion) {
393 EnterContributingSurface(layer, occlusion); 393 EnterContributingSurface(layer, occlusion);
394 LeaveContributingSurface(layer, occlusion); 394 LeaveContributingSurface(layer, occlusion);
395 } 395 }
396 396
397 void ResetLayerIterator() { layer_iterator_ = layer_iterator_begin_; } 397 void ResetLayerIterator() { layer_iterator_ = layer_iterator_begin_; }
398 398
399 const gfx::Transform identity_matrix; 399 const gfx::Transform identity_matrix;
400 400
401 private: 401 private:
402 void SetBaseProperties(typename Types::LayerType* layer, 402 void SetBaseProperties(typename Types::LayerType* layer,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 gfx::PointF(30.f, 30.f), 538 gfx::PointF(30.f, 30.f),
539 gfx::Size(500, 500), 539 gfx::Size(500, 500),
540 true); 540 true);
541 parent->SetMasksToBounds(true); 541 parent->SetMasksToBounds(true);
542 this->CalcDrawEtc(root); 542 this->CalcDrawEtc(root);
543 543
544 TestOcclusionTrackerWithClip<typename Types::LayerType, 544 TestOcclusionTrackerWithClip<typename Types::LayerType,
545 typename Types::RenderSurfaceType> occlusion( 545 typename Types::RenderSurfaceType> occlusion(
546 gfx::Rect(0, 0, 1000, 1000), false); 546 gfx::Rect(0, 0, 1000, 1000), false);
547 547
548 this->VisitLayer(layer, occlusion); 548 this->VisitLayer(layer, &occlusion);
549 this->EnterLayer(parent, occlusion); 549 this->EnterLayer(parent, &occlusion);
550 550
551 EXPECT_EQ(gfx::Rect().ToString(), 551 EXPECT_EQ(gfx::Rect().ToString(),
552 occlusion.occlusion_from_outside_target().ToString()); 552 occlusion.occlusion_from_outside_target().ToString());
553 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), 553 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(),
554 occlusion.occlusion_from_inside_target().ToString()); 554 occlusion.occlusion_from_inside_target().ToString());
555 555
556 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); 556 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
557 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); 557 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70)));
558 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); 558 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70)));
559 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 70, 70))); 559 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 70, 70)));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer( 605 typename Types::ContentLayerType* layer1 = this->CreateDrawingLayer(
606 parent, layer_transform, gfx::PointF(), gfx::Size(90, 90), true); 606 parent, layer_transform, gfx::PointF(), gfx::Size(90, 90), true);
607 typename Types::ContentLayerType* layer2 = this->CreateDrawingLayer( 607 typename Types::ContentLayerType* layer2 = this->CreateDrawingLayer(
608 layer1, layer_transform, gfx::PointF(), gfx::Size(50, 50), true); 608 layer1, layer_transform, gfx::PointF(), gfx::Size(50, 50), true);
609 this->CalcDrawEtc(parent); 609 this->CalcDrawEtc(parent);
610 610
611 TestOcclusionTrackerWithClip<typename Types::LayerType, 611 TestOcclusionTrackerWithClip<typename Types::LayerType,
612 typename Types::RenderSurfaceType> occlusion( 612 typename Types::RenderSurfaceType> occlusion(
613 gfx::Rect(0, 0, 1000, 1000)); 613 gfx::Rect(0, 0, 1000, 1000));
614 614
615 this->VisitLayer(layer2, occlusion); 615 this->VisitLayer(layer2, &occlusion);
616 this->EnterLayer(layer1, occlusion); 616 this->EnterLayer(layer1, &occlusion);
617 617
618 EXPECT_EQ(gfx::Rect().ToString(), 618 EXPECT_EQ(gfx::Rect().ToString(),
619 occlusion.occlusion_from_outside_target().ToString()); 619 occlusion.occlusion_from_outside_target().ToString());
620 EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(), 620 EXPECT_EQ(gfx::Rect(20, 20, 50, 50).ToString(),
621 occlusion.occlusion_from_inside_target().ToString()); 621 occlusion.occlusion_from_inside_target().ToString());
622 622
623 // This checks cases where the quads don't match their "containing" 623 // This checks cases where the quads don't match their "containing"
624 // layers, e.g. in terms of transforms or clip rect. This is typical for 624 // layers, e.g. in terms of transforms or clip rect. This is typical for
625 // DelegatedRendererLayer. 625 // DelegatedRendererLayer.
626 626
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 gfx::PointF(30.f, 30.f), 693 gfx::PointF(30.f, 30.f),
694 gfx::Size(500, 500), 694 gfx::Size(500, 500),
695 true); 695 true);
696 parent->SetMasksToBounds(true); 696 parent->SetMasksToBounds(true);
697 this->CalcDrawEtc(root); 697 this->CalcDrawEtc(root);
698 698
699 TestOcclusionTrackerWithClip<typename Types::LayerType, 699 TestOcclusionTrackerWithClip<typename Types::LayerType,
700 typename Types::RenderSurfaceType> occlusion( 700 typename Types::RenderSurfaceType> occlusion(
701 gfx::Rect(0, 0, 1000, 1000)); 701 gfx::Rect(0, 0, 1000, 1000));
702 702
703 this->VisitLayer(layer, occlusion); 703 this->VisitLayer(layer, &occlusion);
704 this->EnterLayer(parent, occlusion); 704 this->EnterLayer(parent, &occlusion);
705 705
706 EXPECT_EQ(gfx::Rect().ToString(), 706 EXPECT_EQ(gfx::Rect().ToString(),
707 occlusion.occlusion_from_outside_target().ToString()); 707 occlusion.occlusion_from_outside_target().ToString());
708 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), 708 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(),
709 occlusion.occlusion_from_inside_target().ToString()); 709 occlusion.occlusion_from_inside_target().ToString());
710 710
711 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); 711 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
712 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70))); 712 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 30, 70, 70)));
713 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70))); 713 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 29, 70, 70)));
714 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 70, 70))); 714 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 30, 70, 70)));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 gfx::PointF(30.f, 30.f), 764 gfx::PointF(30.f, 30.f),
765 gfx::Size(500, 500), 765 gfx::Size(500, 500),
766 true); 766 true);
767 parent->SetMasksToBounds(true); 767 parent->SetMasksToBounds(true);
768 this->CalcDrawEtc(root); 768 this->CalcDrawEtc(root);
769 769
770 TestOcclusionTrackerWithClip<typename Types::LayerType, 770 TestOcclusionTrackerWithClip<typename Types::LayerType,
771 typename Types::RenderSurfaceType> occlusion( 771 typename Types::RenderSurfaceType> occlusion(
772 gfx::Rect(0, 0, 1000, 1000)); 772 gfx::Rect(0, 0, 1000, 1000));
773 773
774 this->VisitLayer(layer, occlusion); 774 this->VisitLayer(layer, &occlusion);
775 this->EnterLayer(parent, occlusion); 775 this->EnterLayer(parent, &occlusion);
776 776
777 EXPECT_EQ(gfx::Rect().ToString(), 777 EXPECT_EQ(gfx::Rect().ToString(),
778 occlusion.occlusion_from_outside_target().ToString()); 778 occlusion.occlusion_from_outside_target().ToString());
779 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(), 779 EXPECT_EQ(gfx::Rect(50, 50, 50, 50).ToString(),
780 occlusion.occlusion_from_inside_target().ToString()); 780 occlusion.occlusion_from_inside_target().ToString());
781 781
782 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(50, 50, 50, 50))); 782 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(50, 50, 50, 50)));
783 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(49, 50, 50, 50))); 783 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(49, 50, 50, 50)));
784 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(50, 49, 50, 50))); 784 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(50, 49, 50, 50)));
785 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(51, 50, 50, 50))); 785 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(51, 50, 50, 50)));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 this->identity_matrix, 836 this->identity_matrix,
837 gfx::PointF(10.f, 10.f), 837 gfx::PointF(10.f, 10.f),
838 gfx::Size(500, 500), 838 gfx::Size(500, 500),
839 true); 839 true);
840 this->CalcDrawEtc(parent); 840 this->CalcDrawEtc(parent);
841 841
842 TestOcclusionTrackerWithClip<typename Types::LayerType, 842 TestOcclusionTrackerWithClip<typename Types::LayerType,
843 typename Types::RenderSurfaceType> occlusion( 843 typename Types::RenderSurfaceType> occlusion(
844 gfx::Rect(0, 0, 1000, 1000)); 844 gfx::Rect(0, 0, 1000, 1000));
845 845
846 this->VisitLayer(layer, occlusion); 846 this->VisitLayer(layer, &occlusion);
847 this->EnterContributingSurface(child, occlusion); 847 this->EnterContributingSurface(child, &occlusion);
848 848
849 EXPECT_EQ(gfx::Rect().ToString(), 849 EXPECT_EQ(gfx::Rect().ToString(),
850 occlusion.occlusion_from_outside_target().ToString()); 850 occlusion.occlusion_from_outside_target().ToString());
851 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), 851 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(),
852 occlusion.occlusion_from_inside_target().ToString()); 852 occlusion.occlusion_from_inside_target().ToString());
853 853
854 this->LeaveContributingSurface(child, occlusion); 854 this->LeaveContributingSurface(child, &occlusion);
855 this->EnterLayer(parent, occlusion); 855 this->EnterLayer(parent, &occlusion);
856 856
857 EXPECT_EQ(gfx::Rect().ToString(), 857 EXPECT_EQ(gfx::Rect().ToString(),
858 occlusion.occlusion_from_outside_target().ToString()); 858 occlusion.occlusion_from_outside_target().ToString());
859 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), 859 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(),
860 occlusion.occlusion_from_inside_target().ToString()); 860 occlusion.occlusion_from_inside_target().ToString());
861 861
862 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); 862 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60)));
863 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); 863 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60)));
864 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); 864 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60)));
865 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 40, 70, 60))); 865 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(31, 40, 70, 60)));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 this->identity_matrix, 943 this->identity_matrix,
944 gfx::PointF(100.f, 100.f), 944 gfx::PointF(100.f, 100.f),
945 gfx::Size(500, 500), 945 gfx::Size(500, 500),
946 true); 946 true);
947 this->CalcDrawEtc(parent); 947 this->CalcDrawEtc(parent);
948 948
949 TestOcclusionTrackerWithClip<typename Types::LayerType, 949 TestOcclusionTrackerWithClip<typename Types::LayerType,
950 typename Types::RenderSurfaceType> occlusion( 950 typename Types::RenderSurfaceType> occlusion(
951 gfx::Rect(0, 0, 1000, 1000)); 951 gfx::Rect(0, 0, 1000, 1000));
952 952
953 this->VisitLayer(occluder, occlusion); 953 this->VisitLayer(occluder, &occlusion);
954 this->EnterLayer(layer2, occlusion); 954 this->EnterLayer(layer2, &occlusion);
955 955
956 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), 956 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(),
957 occlusion.occlusion_from_outside_target().ToString()); 957 occlusion.occlusion_from_outside_target().ToString());
958 EXPECT_EQ(gfx::Rect().ToString(), 958 EXPECT_EQ(gfx::Rect().ToString(),
959 occlusion.occlusion_from_inside_target().ToString()); 959 occlusion.occlusion_from_inside_target().ToString());
960 960
961 EXPECT_RECT_EQ( 961 EXPECT_RECT_EQ(
962 gfx::Rect(0, 0, 25, 25), 962 gfx::Rect(0, 0, 25, 25),
963 occlusion.UnoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25))); 963 occlusion.UnoccludedLayerContentRect(layer2, gfx::Rect(0, 0, 25, 25)));
964 EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25), 964 EXPECT_RECT_EQ(gfx::Rect(10, 25, 15, 25),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 this->identity_matrix, 1008 this->identity_matrix,
1009 gfx::PointF(30.f, 30.f), 1009 gfx::PointF(30.f, 30.f),
1010 gfx::Size(60, 20), 1010 gfx::Size(60, 20),
1011 true); 1011 true);
1012 this->CalcDrawEtc(root); 1012 this->CalcDrawEtc(root);
1013 1013
1014 TestOcclusionTrackerWithClip<typename Types::LayerType, 1014 TestOcclusionTrackerWithClip<typename Types::LayerType,
1015 typename Types::RenderSurfaceType> occlusion( 1015 typename Types::RenderSurfaceType> occlusion(
1016 gfx::Rect(0, 0, 1000, 1000)); 1016 gfx::Rect(0, 0, 1000, 1000));
1017 1017
1018 this->VisitLayer(child2, occlusion); 1018 this->VisitLayer(child2, &occlusion);
1019 1019
1020 EXPECT_EQ(gfx::Rect().ToString(), 1020 EXPECT_EQ(gfx::Rect().ToString(),
1021 occlusion.occlusion_from_outside_target().ToString()); 1021 occlusion.occlusion_from_outside_target().ToString());
1022 EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(), 1022 EXPECT_EQ(gfx::Rect(30, 30, 60, 20).ToString(),
1023 occlusion.occlusion_from_inside_target().ToString()); 1023 occlusion.occlusion_from_inside_target().ToString());
1024 1024
1025 this->VisitLayer(layer, occlusion); 1025 this->VisitLayer(layer, &occlusion);
1026 1026
1027 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), 1027 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(),
1028 occlusion.occlusion_from_outside_target().ToString()); 1028 occlusion.occlusion_from_outside_target().ToString());
1029 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), 1029 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(),
1030 occlusion.occlusion_from_inside_target().ToString()); 1030 occlusion.occlusion_from_inside_target().ToString());
1031 1031
1032 this->EnterContributingSurface(child, occlusion); 1032 this->EnterContributingSurface(child, &occlusion);
1033 1033
1034 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(), 1034 EXPECT_EQ(gfx::Rect(0, 440, 20, 60).ToString(),
1035 occlusion.occlusion_from_outside_target().ToString()); 1035 occlusion.occlusion_from_outside_target().ToString());
1036 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), 1036 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(),
1037 occlusion.occlusion_from_inside_target().ToString()); 1037 occlusion.occlusion_from_inside_target().ToString());
1038 1038
1039 // Occlusion in |child2| should get merged with the |child| surface we are 1039 // Occlusion in |child2| should get merged with the |child| surface we are
1040 // leaving now. 1040 // leaving now.
1041 this->LeaveContributingSurface(child, occlusion); 1041 this->LeaveContributingSurface(child, &occlusion);
1042 this->EnterLayer(parent, occlusion); 1042 this->EnterLayer(parent, &occlusion);
1043 1043
1044 EXPECT_EQ(gfx::Rect().ToString(), 1044 EXPECT_EQ(gfx::Rect().ToString(),
1045 occlusion.occlusion_from_outside_target().ToString()); 1045 occlusion.occlusion_from_outside_target().ToString());
1046 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60)) 1046 EXPECT_EQ(UnionRegions(gfx::Rect(30, 30, 60, 10), gfx::Rect(30, 40, 70, 60))
1047 .ToString(), 1047 .ToString(),
1048 occlusion.occlusion_from_inside_target().ToString()); 1048 occlusion.occlusion_from_inside_target().ToString());
1049 1049
1050 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70))); 1050 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 30, 70, 70)));
1051 EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10), 1051 EXPECT_RECT_EQ(gfx::Rect(90, 30, 10, 10),
1052 occlusion.UnoccludedLayerContentRect( 1052 occlusion.UnoccludedLayerContentRect(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 child, layer_transform, gfx::PointF(), gfx::Size(500, 500), true); 1178 child, layer_transform, gfx::PointF(), gfx::Size(500, 500), true);
1179 this->CalcDrawEtc(root); 1179 this->CalcDrawEtc(root);
1180 1180
1181 TestOcclusionTrackerWithClip<typename Types::LayerType, 1181 TestOcclusionTrackerWithClip<typename Types::LayerType,
1182 typename Types::RenderSurfaceType> occlusion( 1182 typename Types::RenderSurfaceType> occlusion(
1183 gfx::Rect(0, 0, 1000, 1000)); 1183 gfx::Rect(0, 0, 1000, 1000));
1184 1184
1185 gfx::Rect clipped_layer_in_child = MathUtil::MapClippedRect( 1185 gfx::Rect clipped_layer_in_child = MathUtil::MapClippedRect(
1186 layer_transform, layer->visible_content_rect()); 1186 layer_transform, layer->visible_content_rect());
1187 1187
1188 this->VisitLayer(layer, occlusion); 1188 this->VisitLayer(layer, &occlusion);
1189 this->EnterContributingSurface(child, occlusion); 1189 this->EnterContributingSurface(child, &occlusion);
1190 1190
1191 EXPECT_EQ(gfx::Rect().ToString(), 1191 EXPECT_EQ(gfx::Rect().ToString(),
1192 occlusion.occlusion_from_outside_target().ToString()); 1192 occlusion.occlusion_from_outside_target().ToString());
1193 EXPECT_EQ(clipped_layer_in_child.ToString(), 1193 EXPECT_EQ(clipped_layer_in_child.ToString(),
1194 occlusion.occlusion_from_inside_target().ToString()); 1194 occlusion.occlusion_from_inside_target().ToString());
1195 1195
1196 this->LeaveContributingSurface(child, occlusion); 1196 this->LeaveContributingSurface(child, &occlusion);
1197 this->EnterLayer(parent, occlusion); 1197 this->EnterLayer(parent, &occlusion);
1198 1198
1199 EXPECT_EQ(gfx::Rect().ToString(), 1199 EXPECT_EQ(gfx::Rect().ToString(),
1200 occlusion.occlusion_from_outside_target().ToString()); 1200 occlusion.occlusion_from_outside_target().ToString());
1201 EXPECT_EQ(gfx::Rect().ToString(), 1201 EXPECT_EQ(gfx::Rect().ToString(),
1202 occlusion.occlusion_from_inside_target().ToString()); 1202 occlusion.occlusion_from_inside_target().ToString());
1203 1203
1204 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(75, 55, 1, 1))); 1204 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(75, 55, 1, 1)));
1205 EXPECT_RECT_EQ( 1205 EXPECT_RECT_EQ(
1206 gfx::Rect(75, 55, 1, 1), 1206 gfx::Rect(75, 55, 1, 1),
1207 occlusion.UnoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1))); 1207 occlusion.UnoccludedLayerContentRect(parent, gfx::Rect(75, 55, 1, 1)));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 this->identity_matrix, 1245 this->identity_matrix,
1246 gfx::PointF(10.f, 450.f), 1246 gfx::PointF(10.f, 450.f),
1247 gfx::Size(500, 60), 1247 gfx::Size(500, 60),
1248 true); 1248 true);
1249 this->CalcDrawEtc(root); 1249 this->CalcDrawEtc(root);
1250 1250
1251 TestOcclusionTrackerWithClip<typename Types::LayerType, 1251 TestOcclusionTrackerWithClip<typename Types::LayerType,
1252 typename Types::RenderSurfaceType> occlusion( 1252 typename Types::RenderSurfaceType> occlusion(
1253 gfx::Rect(0, 0, 1000, 1000)); 1253 gfx::Rect(0, 0, 1000, 1000));
1254 1254
1255 this->VisitLayer(layer2, occlusion); 1255 this->VisitLayer(layer2, &occlusion);
1256 this->VisitLayer(layer1, occlusion); 1256 this->VisitLayer(layer1, &occlusion);
1257 this->VisitLayer(child, occlusion); 1257 this->VisitLayer(child, &occlusion);
1258 this->EnterContributingSurface(child, occlusion); 1258 this->EnterContributingSurface(child, &occlusion);
1259 1259
1260 EXPECT_EQ(gfx::Rect().ToString(), 1260 EXPECT_EQ(gfx::Rect().ToString(),
1261 occlusion.occlusion_from_outside_target().ToString()); 1261 occlusion.occlusion_from_outside_target().ToString());
1262 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(), 1262 EXPECT_EQ(gfx::Rect(10, 430, 60, 70).ToString(),
1263 occlusion.occlusion_from_inside_target().ToString()); 1263 occlusion.occlusion_from_inside_target().ToString());
1264 1264
1265 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 430, 60, 70))); 1265 EXPECT_TRUE(occlusion.OccludedLayer(child, gfx::Rect(10, 430, 60, 70)));
1266 EXPECT_FALSE(occlusion.OccludedLayer(child, gfx::Rect(9, 430, 60, 70))); 1266 EXPECT_FALSE(occlusion.OccludedLayer(child, gfx::Rect(9, 430, 60, 70)));
1267 // These rects are occluded except for the part outside the bounds of the 1267 // These rects are occluded except for the part outside the bounds of the
1268 // target surface. 1268 // target surface.
(...skipping 11 matching lines...) Expand all
1280 EXPECT_RECT_EQ(gfx::Rect(), 1280 EXPECT_RECT_EQ(gfx::Rect(),
1281 occlusion.UnoccludedLayerContentRect( 1281 occlusion.UnoccludedLayerContentRect(
1282 child, gfx::Rect(10, 429, 60, 70))); 1282 child, gfx::Rect(10, 429, 60, 70)));
1283 EXPECT_RECT_EQ(gfx::Rect(), 1283 EXPECT_RECT_EQ(gfx::Rect(),
1284 occlusion.UnoccludedLayerContentRect( 1284 occlusion.UnoccludedLayerContentRect(
1285 child, gfx::Rect(11, 430, 60, 70))); 1285 child, gfx::Rect(11, 430, 60, 70)));
1286 EXPECT_RECT_EQ(gfx::Rect(), 1286 EXPECT_RECT_EQ(gfx::Rect(),
1287 occlusion.UnoccludedLayerContentRect( 1287 occlusion.UnoccludedLayerContentRect(
1288 child, gfx::Rect(10, 431, 60, 70))); 1288 child, gfx::Rect(10, 431, 60, 70)));
1289 1289
1290 this->LeaveContributingSurface(child, occlusion); 1290 this->LeaveContributingSurface(child, &occlusion);
1291 this->EnterLayer(parent, occlusion); 1291 this->EnterLayer(parent, &occlusion);
1292 1292
1293 EXPECT_EQ(gfx::Rect().ToString(), 1293 EXPECT_EQ(gfx::Rect().ToString(),
1294 occlusion.occlusion_from_outside_target().ToString()); 1294 occlusion.occlusion_from_outside_target().ToString());
1295 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(), 1295 EXPECT_EQ(gfx::Rect(30, 40, 70, 60).ToString(),
1296 occlusion.occlusion_from_inside_target().ToString()); 1296 occlusion.occlusion_from_inside_target().ToString());
1297 1297
1298 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60))); 1298 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 40, 70, 60)));
1299 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60))); 1299 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(29, 40, 70, 60)));
1300 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60))); 1300 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(30, 39, 70, 60)));
1301 1301
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 this->identity_matrix, 1373 this->identity_matrix,
1374 gfx::PointF(-10.f, -10.f), 1374 gfx::PointF(-10.f, -10.f),
1375 gfx::Size(510, 510), 1375 gfx::Size(510, 510),
1376 true); 1376 true);
1377 this->CalcDrawEtc(parent); 1377 this->CalcDrawEtc(parent);
1378 1378
1379 TestOcclusionTrackerWithClip<typename Types::LayerType, 1379 TestOcclusionTrackerWithClip<typename Types::LayerType,
1380 typename Types::RenderSurfaceType> occlusion( 1380 typename Types::RenderSurfaceType> occlusion(
1381 gfx::Rect(0, 0, 1000, 1000)); 1381 gfx::Rect(0, 0, 1000, 1000));
1382 1382
1383 this->VisitLayer(layer2, occlusion); 1383 this->VisitLayer(layer2, &occlusion);
1384 this->EnterContributingSurface(child2, occlusion); 1384 this->EnterContributingSurface(child2, &occlusion);
1385 1385
1386 EXPECT_EQ(gfx::Rect().ToString(), 1386 EXPECT_EQ(gfx::Rect().ToString(),
1387 occlusion.occlusion_from_outside_target().ToString()); 1387 occlusion.occlusion_from_outside_target().ToString());
1388 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), 1388 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(),
1389 occlusion.occlusion_from_inside_target().ToString()); 1389 occlusion.occlusion_from_inside_target().ToString());
1390 1390
1391 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-10, 420, 70, 80))); 1391 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-10, 420, 70, 80)));
1392 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-11, 420, 70, 80))); 1392 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-11, 420, 70, 80)));
1393 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-10, 419, 70, 80))); 1393 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-10, 419, 70, 80)));
1394 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-10, 420, 71, 80))); 1394 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-10, 420, 71, 80)));
1395 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-10, 420, 70, 81))); 1395 EXPECT_TRUE(occlusion.OccludedLayer(child2, gfx::Rect(-10, 420, 70, 81)));
1396 1396
1397 // There is nothing above child2's surface in the z-order. 1397 // There is nothing above child2's surface in the z-order.
1398 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), 1398 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80),
1399 occlusion.UnoccludedContributingSurfaceContentRect( 1399 occlusion.UnoccludedContributingSurfaceContentRect(
1400 child2, false, gfx::Rect(-10, 420, 70, 80), NULL)); 1400 child2, false, gfx::Rect(-10, 420, 70, 80), NULL));
1401 1401
1402 this->LeaveContributingSurface(child2, occlusion); 1402 this->LeaveContributingSurface(child2, &occlusion);
1403 this->VisitLayer(layer1, occlusion); 1403 this->VisitLayer(layer1, &occlusion);
1404 this->EnterContributingSurface(child1, occlusion); 1404 this->EnterContributingSurface(child1, &occlusion);
1405 1405
1406 EXPECT_EQ(gfx::Rect(0, 430, 70, 80).ToString(), 1406 EXPECT_EQ(gfx::Rect(0, 430, 70, 80).ToString(),
1407 occlusion.occlusion_from_outside_target().ToString()); 1407 occlusion.occlusion_from_outside_target().ToString());
1408 EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(), 1408 EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(),
1409 occlusion.occlusion_from_inside_target().ToString()); 1409 occlusion.occlusion_from_inside_target().ToString());
1410 1410
1411 // child2's contents will occlude child1 below it. 1411 // child2's contents will occlude child1 below it.
1412 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70), 1412 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70),
1413 occlusion.UnoccludedContributingSurfaceContentRect( 1413 occlusion.UnoccludedContributingSurfaceContentRect(
1414 child1, false, gfx::Rect(-10, 430, 80, 70), NULL)); 1414 child1, false, gfx::Rect(-10, 430, 80, 70), NULL));
1415 1415
1416 this->LeaveContributingSurface(child1, occlusion); 1416 this->LeaveContributingSurface(child1, &occlusion);
1417 this->EnterLayer(parent, occlusion); 1417 this->EnterLayer(parent, &occlusion);
1418 1418
1419 EXPECT_EQ(gfx::Rect().ToString(), 1419 EXPECT_EQ(gfx::Rect().ToString(),
1420 occlusion.occlusion_from_outside_target().ToString()); 1420 occlusion.occlusion_from_outside_target().ToString());
1421 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)) 1421 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70))
1422 .ToString(), 1422 .ToString(),
1423 occlusion.occlusion_from_inside_target().ToString()); 1423 occlusion.occlusion_from_inside_target().ToString());
1424 1424
1425 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(20, 20, 80, 80))); 1425 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(20, 20, 80, 80)));
1426 1426
1427 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 20, 70, 80))); 1427 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(30, 20, 70, 80)));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 this->identity_matrix, 1500 this->identity_matrix,
1501 gfx::PointF(-10.f, -10.f), 1501 gfx::PointF(-10.f, -10.f),
1502 gfx::Size(510, 510), 1502 gfx::Size(510, 510),
1503 true); 1503 true);
1504 this->CalcDrawEtc(parent); 1504 this->CalcDrawEtc(parent);
1505 1505
1506 TestOcclusionTrackerWithClip<typename Types::LayerType, 1506 TestOcclusionTrackerWithClip<typename Types::LayerType,
1507 typename Types::RenderSurfaceType> occlusion( 1507 typename Types::RenderSurfaceType> occlusion(
1508 gfx::Rect(0, 0, 1000, 1000)); 1508 gfx::Rect(0, 0, 1000, 1000));
1509 1509
1510 this->VisitLayer(layer2, occlusion); 1510 this->VisitLayer(layer2, &occlusion);
1511 this->EnterLayer(child2, occlusion); 1511 this->EnterLayer(child2, &occlusion);
1512 1512
1513 EXPECT_EQ(gfx::Rect().ToString(), 1513 EXPECT_EQ(gfx::Rect().ToString(),
1514 occlusion.occlusion_from_outside_target().ToString()); 1514 occlusion.occlusion_from_outside_target().ToString());
1515 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), 1515 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(),
1516 occlusion.occlusion_from_inside_target().ToString()); 1516 occlusion.occlusion_from_inside_target().ToString());
1517 1517
1518 this->LeaveLayer(child2, occlusion); 1518 this->LeaveLayer(child2, &occlusion);
1519 this->EnterContributingSurface(child2, occlusion); 1519 this->EnterContributingSurface(child2, &occlusion);
1520 1520
1521 // There is nothing above child2's surface in the z-order. 1521 // There is nothing above child2's surface in the z-order.
1522 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), 1522 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80),
1523 occlusion.UnoccludedContributingSurfaceContentRect( 1523 occlusion.UnoccludedContributingSurfaceContentRect(
1524 child2, false, gfx::Rect(-10, 420, 70, 80), NULL)); 1524 child2, false, gfx::Rect(-10, 420, 70, 80), NULL));
1525 1525
1526 this->LeaveContributingSurface(child2, occlusion); 1526 this->LeaveContributingSurface(child2, &occlusion);
1527 this->VisitLayer(layer1, occlusion); 1527 this->VisitLayer(layer1, &occlusion);
1528 this->EnterContributingSurface(child1, occlusion); 1528 this->EnterContributingSurface(child1, &occlusion);
1529 1529
1530 EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(), 1530 EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(),
1531 occlusion.occlusion_from_outside_target().ToString()); 1531 occlusion.occlusion_from_outside_target().ToString());
1532 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), 1532 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(),
1533 occlusion.occlusion_from_inside_target().ToString()); 1533 occlusion.occlusion_from_inside_target().ToString());
1534 1534
1535 // child2's contents will occlude child1 below it. 1535 // child2's contents will occlude child1 below it.
1536 EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90), 1536 EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90),
1537 occlusion.UnoccludedContributingSurfaceContentRect( 1537 occlusion.UnoccludedContributingSurfaceContentRect(
1538 child1, false, gfx::Rect(420, -20, 80, 90), NULL)); 1538 child1, false, gfx::Rect(420, -20, 80, 90), NULL));
1539 EXPECT_RECT_EQ(gfx::Rect(490, -10, 10, 80), 1539 EXPECT_RECT_EQ(gfx::Rect(490, -10, 10, 80),
1540 occlusion.UnoccludedContributingSurfaceContentRect( 1540 occlusion.UnoccludedContributingSurfaceContentRect(
1541 child1, false, gfx::Rect(420, -10, 80, 90), NULL)); 1541 child1, false, gfx::Rect(420, -10, 80, 90), NULL));
1542 EXPECT_RECT_EQ(gfx::Rect(420, -20, 70, 10), 1542 EXPECT_RECT_EQ(gfx::Rect(420, -20, 70, 10),
1543 occlusion.UnoccludedContributingSurfaceContentRect( 1543 occlusion.UnoccludedContributingSurfaceContentRect(
1544 child1, false, gfx::Rect(420, -20, 70, 90), NULL)); 1544 child1, false, gfx::Rect(420, -20, 70, 90), NULL));
1545 1545
1546 this->LeaveContributingSurface(child1, occlusion); 1546 this->LeaveContributingSurface(child1, &occlusion);
1547 this->EnterLayer(parent, occlusion); 1547 this->EnterLayer(parent, &occlusion);
1548 1548
1549 EXPECT_EQ(gfx::Rect().ToString(), 1549 EXPECT_EQ(gfx::Rect().ToString(),
1550 occlusion.occlusion_from_outside_target().ToString()); 1550 occlusion.occlusion_from_outside_target().ToString());
1551 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), 1551 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(),
1552 occlusion.occlusion_from_inside_target().ToString()); 1552 occlusion.occlusion_from_inside_target().ToString());
1553 1553
1554 /* Justification for the above occlusion: 1554 /* Justification for the above occlusion:
1555 100 1555 100
1556 +---------------------+ 1556 +---------------------+
1557 |20 | layer1 1557 |20 | layer1
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 filters.append(WebKit::WebFilterOperation::createOpacityFilter(0.5f)); 1625 filters.append(WebKit::WebFilterOperation::createOpacityFilter(0.5f));
1626 opacity_layer->SetFilters(filters); 1626 opacity_layer->SetFilters(filters);
1627 1627
1628 this->CalcDrawEtc(parent); 1628 this->CalcDrawEtc(parent);
1629 1629
1630 TestOcclusionTrackerWithClip<typename Types::LayerType, 1630 TestOcclusionTrackerWithClip<typename Types::LayerType,
1631 typename Types::RenderSurfaceType> occlusion( 1631 typename Types::RenderSurfaceType> occlusion(
1632 gfx::Rect(0, 0, 1000, 1000)); 1632 gfx::Rect(0, 0, 1000, 1000));
1633 1633
1634 // Opacity layer won't contribute to occlusion. 1634 // Opacity layer won't contribute to occlusion.
1635 this->VisitLayer(opacity_layer, occlusion); 1635 this->VisitLayer(opacity_layer, &occlusion);
1636 this->EnterContributingSurface(opacity_layer, occlusion); 1636 this->EnterContributingSurface(opacity_layer, &occlusion);
1637 1637
1638 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1638 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1639 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 1639 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
1640 1640
1641 // And has nothing to contribute to its parent surface. 1641 // And has nothing to contribute to its parent surface.
1642 this->LeaveContributingSurface(opacity_layer, occlusion); 1642 this->LeaveContributingSurface(opacity_layer, &occlusion);
1643 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1643 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1644 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 1644 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
1645 1645
1646 // Opaque layer will contribute to occlusion. 1646 // Opaque layer will contribute to occlusion.
1647 this->VisitLayer(opaque_layer, occlusion); 1647 this->VisitLayer(opaque_layer, &occlusion);
1648 this->EnterContributingSurface(opaque_layer, occlusion); 1648 this->EnterContributingSurface(opaque_layer, &occlusion);
1649 1649
1650 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1650 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1651 EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(), 1651 EXPECT_EQ(gfx::Rect(0, 430, 70, 70).ToString(),
1652 occlusion.occlusion_from_inside_target().ToString()); 1652 occlusion.occlusion_from_inside_target().ToString());
1653 1653
1654 // And it gets translated to the parent surface. 1654 // And it gets translated to the parent surface.
1655 this->LeaveContributingSurface(opaque_layer, occlusion); 1655 this->LeaveContributingSurface(opaque_layer, &occlusion);
1656 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1656 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1657 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), 1657 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(),
1658 occlusion.occlusion_from_inside_target().ToString()); 1658 occlusion.occlusion_from_inside_target().ToString());
1659 1659
1660 // The blur layer needs to throw away any occlusion from outside its 1660 // The blur layer needs to throw away any occlusion from outside its
1661 // subtree. 1661 // subtree.
1662 this->EnterLayer(blur_layer, occlusion); 1662 this->EnterLayer(blur_layer, &occlusion);
1663 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1663 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1664 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 1664 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
1665 1665
1666 // And it won't contribute to occlusion. 1666 // And it won't contribute to occlusion.
1667 this->LeaveLayer(blur_layer, occlusion); 1667 this->LeaveLayer(blur_layer, &occlusion);
1668 this->EnterContributingSurface(blur_layer, occlusion); 1668 this->EnterContributingSurface(blur_layer, &occlusion);
1669 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1669 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1670 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 1670 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
1671 1671
1672 // But the opaque layer's occlusion is preserved on the parent. 1672 // But the opaque layer's occlusion is preserved on the parent.
1673 this->LeaveContributingSurface(blur_layer, occlusion); 1673 this->LeaveContributingSurface(blur_layer, &occlusion);
1674 this->EnterLayer(parent, occlusion); 1674 this->EnterLayer(parent, &occlusion);
1675 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1675 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1676 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(), 1676 EXPECT_EQ(gfx::Rect(30, 30, 70, 70).ToString(),
1677 occlusion.occlusion_from_inside_target().ToString()); 1677 occlusion.occlusion_from_inside_target().ToString());
1678 } 1678 }
1679 }; 1679 };
1680 1680
1681 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters); 1681 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestFilters);
1682 1682
1683 template <class Types> 1683 template <class Types>
1684 class OcclusionTrackerTestReplicaDoesOcclude : 1684 class OcclusionTrackerTestReplicaDoesOcclude :
(...skipping 11 matching lines...) Expand all
1696 gfx::Size(50, 50), 1696 gfx::Size(50, 50),
1697 true); 1697 true);
1698 this->CreateReplicaLayer( 1698 this->CreateReplicaLayer(
1699 surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); 1699 surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size());
1700 this->CalcDrawEtc(parent); 1700 this->CalcDrawEtc(parent);
1701 1701
1702 TestOcclusionTrackerWithClip<typename Types::LayerType, 1702 TestOcclusionTrackerWithClip<typename Types::LayerType,
1703 typename Types::RenderSurfaceType> occlusion( 1703 typename Types::RenderSurfaceType> occlusion(
1704 gfx::Rect(0, 0, 1000, 1000)); 1704 gfx::Rect(0, 0, 1000, 1000));
1705 1705
1706 this->VisitLayer(surface, occlusion); 1706 this->VisitLayer(surface, &occlusion);
1707 1707
1708 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 1708 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
1709 occlusion.occlusion_from_inside_target().ToString()); 1709 occlusion.occlusion_from_inside_target().ToString());
1710 1710
1711 this->VisitContributingSurface(surface, occlusion); 1711 this->VisitContributingSurface(surface, &occlusion);
1712 this->EnterLayer(parent, occlusion); 1712 this->EnterLayer(parent, &occlusion);
1713 1713
1714 // The surface and replica should both be occluding the parent. 1714 // The surface and replica should both be occluding the parent.
1715 EXPECT_EQ( 1715 EXPECT_EQ(
1716 UnionRegions(gfx::Rect(0, 100, 50, 50), 1716 UnionRegions(gfx::Rect(0, 100, 50, 50),
1717 gfx::Rect(50, 150, 50, 50)).ToString(), 1717 gfx::Rect(50, 150, 50, 50)).ToString(),
1718 occlusion.occlusion_from_inside_target().ToString()); 1718 occlusion.occlusion_from_inside_target().ToString());
1719 } 1719 }
1720 }; 1720 };
1721 1721
1722 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude); 1722 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaDoesOcclude);
(...skipping 15 matching lines...) Expand all
1738 gfx::Size(50, 50), 1738 gfx::Size(50, 50),
1739 true); 1739 true);
1740 this->CreateReplicaLayer( 1740 this->CreateReplicaLayer(
1741 surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); 1741 surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size());
1742 this->CalcDrawEtc(parent); 1742 this->CalcDrawEtc(parent);
1743 1743
1744 TestOcclusionTrackerWithClip<typename Types::LayerType, 1744 TestOcclusionTrackerWithClip<typename Types::LayerType,
1745 typename Types::RenderSurfaceType> occlusion( 1745 typename Types::RenderSurfaceType> occlusion(
1746 gfx::Rect(0, 0, 1000, 1000)); 1746 gfx::Rect(0, 0, 1000, 1000));
1747 1747
1748 this->VisitLayer(surface, occlusion); 1748 this->VisitLayer(surface, &occlusion);
1749 1749
1750 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 1750 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
1751 occlusion.occlusion_from_inside_target().ToString()); 1751 occlusion.occlusion_from_inside_target().ToString());
1752 1752
1753 this->VisitContributingSurface(surface, occlusion); 1753 this->VisitContributingSurface(surface, &occlusion);
1754 this->EnterLayer(parent, occlusion); 1754 this->EnterLayer(parent, &occlusion);
1755 1755
1756 // The surface and replica should both be occluding the parent. 1756 // The surface and replica should both be occluding the parent.
1757 EXPECT_EQ( 1757 EXPECT_EQ(
1758 UnionRegions(gfx::Rect(0, 100, 50, 50), 1758 UnionRegions(gfx::Rect(0, 100, 50, 50),
1759 gfx::Rect(50, 150, 50, 20)).ToString(), 1759 gfx::Rect(50, 150, 50, 20)).ToString(),
1760 occlusion.occlusion_from_inside_target().ToString()); 1760 occlusion.occlusion_from_inside_target().ToString());
1761 } 1761 }
1762 }; 1762 };
1763 1763
1764 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping); 1764 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithClipping);
(...skipping 14 matching lines...) Expand all
1779 true); 1779 true);
1780 typename Types::LayerType* replica = this->CreateReplicaLayer( 1780 typename Types::LayerType* replica = this->CreateReplicaLayer(
1781 surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size()); 1781 surface, this->identity_matrix, gfx::PointF(50.f, 50.f), gfx::Size());
1782 this->CreateMaskLayer(replica, gfx::Size(10, 10)); 1782 this->CreateMaskLayer(replica, gfx::Size(10, 10));
1783 this->CalcDrawEtc(parent); 1783 this->CalcDrawEtc(parent);
1784 1784
1785 TestOcclusionTrackerWithClip<typename Types::LayerType, 1785 TestOcclusionTrackerWithClip<typename Types::LayerType,
1786 typename Types::RenderSurfaceType> occlusion( 1786 typename Types::RenderSurfaceType> occlusion(
1787 gfx::Rect(0, 0, 1000, 1000)); 1787 gfx::Rect(0, 0, 1000, 1000));
1788 1788
1789 this->VisitLayer(surface, occlusion); 1789 this->VisitLayer(surface, &occlusion);
1790 1790
1791 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(), 1791 EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
1792 occlusion.occlusion_from_inside_target().ToString()); 1792 occlusion.occlusion_from_inside_target().ToString());
1793 1793
1794 this->VisitContributingSurface(surface, occlusion); 1794 this->VisitContributingSurface(surface, &occlusion);
1795 this->EnterLayer(parent, occlusion); 1795 this->EnterLayer(parent, &occlusion);
1796 1796
1797 // The replica should not be occluding the parent, since it has a mask 1797 // The replica should not be occluding the parent, since it has a mask
1798 // applied to it. 1798 // applied to it.
1799 EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(), 1799 EXPECT_EQ(gfx::Rect(0, 100, 50, 50).ToString(),
1800 occlusion.occlusion_from_inside_target().ToString()); 1800 occlusion.occlusion_from_inside_target().ToString());
1801 } 1801 }
1802 }; 1802 };
1803 1803
1804 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask); 1804 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaWithMask);
1805 1805
(...skipping 18 matching lines...) Expand all
1824 this->identity_matrix, 1824 this->identity_matrix,
1825 gfx::PointF(-200.f, -100.f), 1825 gfx::PointF(-200.f, -100.f),
1826 gfx::Size(200, 200), 1826 gfx::Size(200, 200),
1827 false); 1827 false);
1828 this->CalcDrawEtc(parent); 1828 this->CalcDrawEtc(parent);
1829 1829
1830 TestOcclusionTrackerWithClip<typename Types::LayerType, 1830 TestOcclusionTrackerWithClip<typename Types::LayerType,
1831 typename Types::RenderSurfaceType> occlusion( 1831 typename Types::RenderSurfaceType> occlusion(
1832 gfx::Rect(0, 0, 1000, 1000)); 1832 gfx::Rect(0, 0, 1000, 1000));
1833 1833
1834 this->EnterLayer(layer, occlusion); 1834 this->EnterLayer(layer, &occlusion);
1835 1835
1836 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 1836 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
1837 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 1837 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
1838 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 1838 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
1839 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 1839 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
1840 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(200, 100, 100, 100))); 1840 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(200, 100, 100, 100)));
1841 1841
1842 this->LeaveLayer(layer, occlusion); 1842 this->LeaveLayer(layer, &occlusion);
1843 this->EnterLayer(clip, occlusion); 1843 this->EnterLayer(clip, &occlusion);
1844 1844
1845 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(-100, 0, 100, 100))); 1845 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(-100, 0, 100, 100)));
1846 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, -100, 100, 100))); 1846 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, -100, 100, 100)));
1847 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(100, 0, 100, 100))); 1847 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(100, 0, 100, 100)));
1848 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, 100, 100, 100))); 1848 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, 100, 100, 100)));
1849 EXPECT_FALSE(occlusion.OccludedLayer(clip, gfx::Rect(0, 0, 100, 100))); 1849 EXPECT_FALSE(occlusion.OccludedLayer(clip, gfx::Rect(0, 0, 100, 100)));
1850 1850
1851 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 1851 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
1852 occlusion.UnoccludedLayerContentRect( 1852 occlusion.UnoccludedLayerContentRect(
1853 clip, gfx::Rect(-100, -100, 300, 300))); 1853 clip, gfx::Rect(-100, -100, 300, 300)));
(...skipping 16 matching lines...) Expand all
1870 this->identity_matrix, 1870 this->identity_matrix,
1871 gfx::PointF(), 1871 gfx::PointF(),
1872 gfx::Size(200, 200), 1872 gfx::Size(200, 200),
1873 true); 1873 true);
1874 this->CalcDrawEtc(parent); 1874 this->CalcDrawEtc(parent);
1875 1875
1876 TestOcclusionTrackerWithClip<typename Types::LayerType, 1876 TestOcclusionTrackerWithClip<typename Types::LayerType,
1877 typename Types::RenderSurfaceType> occlusion( 1877 typename Types::RenderSurfaceType> occlusion(
1878 gfx::Rect(200, 100, 100, 100)); 1878 gfx::Rect(200, 100, 100, 100));
1879 1879
1880 this->EnterLayer(layer, occlusion); 1880 this->EnterLayer(layer, &occlusion);
1881 1881
1882 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 1882 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
1883 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 1883 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
1884 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 1884 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
1885 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 1885 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
1886 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(200, 100, 100, 100))); 1886 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(200, 100, 100, 100)));
1887 1887
1888 this->LeaveLayer(layer, occlusion); 1888 this->LeaveLayer(layer, &occlusion);
1889 this->VisitContributingSurface(layer, occlusion); 1889 this->VisitContributingSurface(layer, &occlusion);
1890 this->EnterLayer(parent, occlusion); 1890 this->EnterLayer(parent, &occlusion);
1891 1891
1892 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 0, 100, 100))); 1892 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 0, 100, 100)));
1893 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 1893 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
1894 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 0, 100, 100))); 1894 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 0, 100, 100)));
1895 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 1895 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
1896 EXPECT_FALSE( 1896 EXPECT_FALSE(
1897 occlusion.OccludedLayer(parent, gfx::Rect(200, 100, 100, 100))); 1897 occlusion.OccludedLayer(parent, gfx::Rect(200, 100, 100, 100)));
1898 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 0, 100, 100))); 1898 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 0, 100, 100)));
1899 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 200, 100, 100))); 1899 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 200, 100, 100)));
1900 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 200, 100, 100))); 1900 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 200, 100, 100)));
(...skipping 28 matching lines...) Expand all
1929 this->identity_matrix, 1929 this->identity_matrix,
1930 gfx::PointF(-100.f, -100.f), 1930 gfx::PointF(-100.f, -100.f),
1931 gfx::Size(200, 200), 1931 gfx::Size(200, 200),
1932 true); 1932 true);
1933 this->CalcDrawEtc(parent); 1933 this->CalcDrawEtc(parent);
1934 1934
1935 TestOcclusionTrackerWithClip<typename Types::LayerType, 1935 TestOcclusionTrackerWithClip<typename Types::LayerType,
1936 typename Types::RenderSurfaceType> occlusion( 1936 typename Types::RenderSurfaceType> occlusion(
1937 gfx::Rect(0, 0, 1000, 1000)); 1937 gfx::Rect(0, 0, 1000, 1000));
1938 1938
1939 this->EnterLayer(layer, occlusion); 1939 this->EnterLayer(layer, &occlusion);
1940 1940
1941 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 1941 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
1942 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 1942 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
1943 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 1943 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
1944 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 1944 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
1945 1945
1946 this->LeaveLayer(layer, occlusion); 1946 this->LeaveLayer(layer, &occlusion);
1947 this->VisitContributingSurface(layer, occlusion); 1947 this->VisitContributingSurface(layer, &occlusion);
1948 1948
1949 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), 1949 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(),
1950 occlusion.occlusion_from_inside_target().ToString()); 1950 occlusion.occlusion_from_inside_target().ToString());
1951 1951
1952 this->EnterLayer(clip, occlusion); 1952 this->EnterLayer(clip, &occlusion);
1953 1953
1954 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, 0, 100, 100))); 1954 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, 0, 100, 100)));
1955 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, 100, 100, 100))); 1955 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, 100, 100, 100)));
1956 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(100, 0, 100, 100))); 1956 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(100, 0, 100, 100)));
1957 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(100, 100, 100, 100))); 1957 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(100, 100, 100, 100)));
1958 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(200, 100, 100, 100))); 1958 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(200, 100, 100, 100)));
1959 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(200, 0, 100, 100))); 1959 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(200, 0, 100, 100)));
1960 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, 200, 100, 100))); 1960 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(0, 200, 100, 100)));
1961 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(100, 200, 100, 100))); 1961 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(100, 200, 100, 100)));
1962 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(200, 200, 100, 100))); 1962 EXPECT_TRUE(occlusion.OccludedLayer(clip, gfx::Rect(200, 200, 100, 100)));
(...skipping 19 matching lines...) Expand all
1982 this->identity_matrix, 1982 this->identity_matrix,
1983 gfx::PointF(), 1983 gfx::PointF(),
1984 gfx::Size(200, 200), 1984 gfx::Size(200, 200),
1985 true); 1985 true);
1986 this->CalcDrawEtc(parent); 1986 this->CalcDrawEtc(parent);
1987 1987
1988 TestOcclusionTrackerWithClip<typename Types::LayerType, 1988 TestOcclusionTrackerWithClip<typename Types::LayerType,
1989 typename Types::RenderSurfaceType> occlusion( 1989 typename Types::RenderSurfaceType> occlusion(
1990 gfx::Rect(100, 100, 100, 100)); 1990 gfx::Rect(100, 100, 100, 100));
1991 1991
1992 this->EnterLayer(layer, occlusion); 1992 this->EnterLayer(layer, &occlusion);
1993 1993
1994 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 1994 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
1995 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 1995 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
1996 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 1996 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
1997 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 1997 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
1998 1998
1999 this->LeaveLayer(layer, occlusion); 1999 this->LeaveLayer(layer, &occlusion);
2000 this->VisitContributingSurface(layer, occlusion); 2000 this->VisitContributingSurface(layer, &occlusion);
2001 this->EnterLayer(parent, occlusion); 2001 this->EnterLayer(parent, &occlusion);
2002 2002
2003 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 0, 100, 100))); 2003 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 0, 100, 100)));
2004 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 2004 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
2005 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 0, 100, 100))); 2005 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 0, 100, 100)));
2006 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); 2006 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
2007 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 100, 100, 100))); 2007 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 100, 100, 100)));
2008 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 0, 100, 100))); 2008 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 0, 100, 100)));
2009 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 200, 100, 100))); 2009 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 200, 100, 100)));
2010 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 200, 100, 100))); 2010 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 200, 100, 100)));
2011 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); 2011 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100)));
(...skipping 26 matching lines...) Expand all
2038 this->identity_matrix, 2038 this->identity_matrix,
2039 gfx::PointF(-50.f, -50.f), 2039 gfx::PointF(-50.f, -50.f),
2040 gfx::Size(200, 200), 2040 gfx::Size(200, 200),
2041 true); 2041 true);
2042 this->CalcDrawEtc(parent); 2042 this->CalcDrawEtc(parent);
2043 2043
2044 TestOcclusionTrackerWithClip<typename Types::LayerType, 2044 TestOcclusionTrackerWithClip<typename Types::LayerType,
2045 typename Types::RenderSurfaceType> occlusion( 2045 typename Types::RenderSurfaceType> occlusion(
2046 gfx::Rect(0, 0, 1000, 1000)); 2046 gfx::Rect(0, 0, 1000, 1000));
2047 2047
2048 this->EnterLayer(layer, occlusion); 2048 this->EnterLayer(layer, &occlusion);
2049 2049
2050 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 2050 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
2051 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 2051 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
2052 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 2052 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
2053 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 2053 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
2054 2054
2055 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 50))); 2055 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 50)));
2056 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 50, 100))); 2056 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 50, 100)));
2057 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 50))); 2057 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 50)));
2058 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 50, 100))); 2058 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 50, 100)));
2059 2059
2060 this->LeaveLayer(layer, occlusion); 2060 this->LeaveLayer(layer, &occlusion);
2061 this->VisitContributingSurface(layer, occlusion); 2061 this->VisitContributingSurface(layer, &occlusion);
2062 this->EnterLayer(clip, occlusion); 2062 this->EnterLayer(clip, &occlusion);
2063 2063
2064 EXPECT_EQ(gfx::Rect(50, 50, 150, 150).ToString(), 2064 EXPECT_EQ(gfx::Rect(50, 50, 150, 150).ToString(),
2065 occlusion.occlusion_from_inside_target().ToString()); 2065 occlusion.occlusion_from_inside_target().ToString());
2066 } 2066 }
2067 }; 2067 };
2068 2068
2069 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipRectPartlyOverChild); 2069 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipRectPartlyOverChild);
2070 2070
2071 template <class Types> 2071 template <class Types>
2072 class OcclusionTrackerTestViewportRectPartlyOverChild : 2072 class OcclusionTrackerTestViewportRectPartlyOverChild :
2073 public OcclusionTrackerTest<Types> { 2073 public OcclusionTrackerTest<Types> {
2074 protected: 2074 protected:
2075 OcclusionTrackerTestViewportRectPartlyOverChild(bool opaque_layers) 2075 OcclusionTrackerTestViewportRectPartlyOverChild(bool opaque_layers)
2076 : OcclusionTrackerTest<Types>(opaque_layers) {} 2076 : OcclusionTrackerTest<Types>(opaque_layers) {}
2077 void RunMyTest() { 2077 void RunMyTest() {
2078 typename Types::ContentLayerType* parent = this->CreateRoot( 2078 typename Types::ContentLayerType* parent = this->CreateRoot(
2079 this->identity_matrix, gfx::PointF(), gfx::Size(300, 300)); 2079 this->identity_matrix, gfx::PointF(), gfx::Size(300, 300));
2080 typename Types::ContentLayerType* layer = 2080 typename Types::ContentLayerType* layer =
2081 this->CreateDrawingSurface(parent, 2081 this->CreateDrawingSurface(parent,
2082 this->identity_matrix, 2082 this->identity_matrix,
2083 gfx::PointF(), 2083 gfx::PointF(),
2084 gfx::Size(200, 200), 2084 gfx::Size(200, 200),
2085 true); 2085 true);
2086 this->CalcDrawEtc(parent); 2086 this->CalcDrawEtc(parent);
2087 2087
2088 TestOcclusionTrackerWithClip<typename Types::LayerType, 2088 TestOcclusionTrackerWithClip<typename Types::LayerType,
2089 typename Types::RenderSurfaceType> occlusion( 2089 typename Types::RenderSurfaceType> occlusion(
2090 gfx::Rect(50, 50, 200, 200)); 2090 gfx::Rect(50, 50, 200, 200));
2091 2091
2092 this->EnterLayer(layer, occlusion); 2092 this->EnterLayer(layer, &occlusion);
2093 2093
2094 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 2094 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
2095 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 2095 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
2096 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 2096 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
2097 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 2097 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
2098 2098
2099 this->LeaveLayer(layer, occlusion); 2099 this->LeaveLayer(layer, &occlusion);
2100 this->VisitContributingSurface(layer, occlusion); 2100 this->VisitContributingSurface(layer, &occlusion);
2101 this->EnterLayer(parent, occlusion); 2101 this->EnterLayer(parent, &occlusion);
2102 2102
2103 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 0, 100, 100))); 2103 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 0, 100, 100)));
2104 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 2104 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
2105 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 0, 100, 100))); 2105 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 0, 100, 100)));
2106 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); 2106 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
2107 EXPECT_FALSE( 2107 EXPECT_FALSE(
2108 occlusion.OccludedLayer(parent, gfx::Rect(200, 100, 100, 100))); 2108 occlusion.OccludedLayer(parent, gfx::Rect(200, 100, 100, 100)));
2109 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(200, 0, 100, 100))); 2109 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(200, 0, 100, 100)));
2110 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(0, 200, 100, 100))); 2110 EXPECT_FALSE(occlusion.OccludedLayer(parent, gfx::Rect(0, 200, 100, 100)));
2111 EXPECT_FALSE( 2111 EXPECT_FALSE(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 this->identity_matrix, 2147 this->identity_matrix,
2148 gfx::PointF(), 2148 gfx::PointF(),
2149 gfx::Size(200, 200), 2149 gfx::Size(200, 200),
2150 true); 2150 true);
2151 this->CalcDrawEtc(parent); 2151 this->CalcDrawEtc(parent);
2152 2152
2153 TestOcclusionTrackerWithClip<typename Types::LayerType, 2153 TestOcclusionTrackerWithClip<typename Types::LayerType,
2154 typename Types::RenderSurfaceType> occlusion( 2154 typename Types::RenderSurfaceType> occlusion(
2155 gfx::Rect(500, 500, 100, 100)); 2155 gfx::Rect(500, 500, 100, 100));
2156 2156
2157 this->EnterLayer(layer, occlusion); 2157 this->EnterLayer(layer, &occlusion);
2158 2158
2159 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 2159 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
2160 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 2160 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
2161 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 2161 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
2162 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 2162 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
2163 2163
2164 this->LeaveLayer(layer, occlusion); 2164 this->LeaveLayer(layer, &occlusion);
2165 this->VisitContributingSurface(layer, occlusion); 2165 this->VisitContributingSurface(layer, &occlusion);
2166 this->EnterLayer(parent, occlusion); 2166 this->EnterLayer(parent, &occlusion);
2167 2167
2168 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 0, 100, 100))); 2168 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 0, 100, 100)));
2169 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 2169 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
2170 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 0, 100, 100))); 2170 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 0, 100, 100)));
2171 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); 2171 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
2172 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 100, 100, 100))); 2172 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 100, 100, 100)));
2173 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 0, 100, 100))); 2173 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 0, 100, 100)));
2174 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 200, 100, 100))); 2174 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(0, 200, 100, 100)));
2175 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 200, 100, 100))); 2175 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(100, 200, 100, 100)));
2176 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); 2176 EXPECT_TRUE(occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100)));
(...skipping 26 matching lines...) Expand all
2203 this->CreateDrawingSurface(parent, 2203 this->CreateDrawingSurface(parent,
2204 this->identity_matrix, 2204 this->identity_matrix,
2205 gfx::PointF(), 2205 gfx::PointF(),
2206 gfx::Size(200, 200), 2206 gfx::Size(200, 200),
2207 true); 2207 true);
2208 this->CalcDrawEtc(parent); 2208 this->CalcDrawEtc(parent);
2209 2209
2210 TestOcclusionTrackerWithClip<typename Types::LayerType, 2210 TestOcclusionTrackerWithClip<typename Types::LayerType,
2211 typename Types::RenderSurfaceType> occlusion( 2211 typename Types::RenderSurfaceType> occlusion(
2212 gfx::Rect(0, 0, 1000, 1000)); 2212 gfx::Rect(0, 0, 1000, 1000));
2213 this->EnterLayer(layer, occlusion); 2213 this->EnterLayer(layer, &occlusion);
2214 2214
2215 // This layer is translated when drawn into its target. So if the clip rect 2215 // This layer is translated when drawn into its target. So if the clip rect
2216 // given from the target surface is not in that target space, then after 2216 // given from the target surface is not in that target space, then after
2217 // translating these query rects into the target, they will fall outside the 2217 // translating these query rects into the target, they will fall outside the
2218 // clip and be considered occluded. 2218 // clip and be considered occluded.
2219 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 2219 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
2220 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 2220 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
2221 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 2221 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
2222 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 2222 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
2223 } 2223 }
(...skipping 14 matching lines...) Expand all
2238 this->CreateDrawingSurface(parent, 2238 this->CreateDrawingSurface(parent,
2239 this->identity_matrix, 2239 this->identity_matrix,
2240 gfx::PointF(), 2240 gfx::PointF(),
2241 gfx::Size(200, 200), 2241 gfx::Size(200, 200),
2242 false); 2242 false);
2243 this->CalcDrawEtc(parent); 2243 this->CalcDrawEtc(parent);
2244 2244
2245 TestOcclusionTrackerWithClip<typename Types::LayerType, 2245 TestOcclusionTrackerWithClip<typename Types::LayerType,
2246 typename Types::RenderSurfaceType> occlusion( 2246 typename Types::RenderSurfaceType> occlusion(
2247 gfx::Rect(0, 0, 1000, 1000)); 2247 gfx::Rect(0, 0, 1000, 1000));
2248 this->EnterLayer(layer, occlusion); 2248 this->EnterLayer(layer, &occlusion);
2249 2249
2250 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100))); 2250 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 0, 100, 100)));
2251 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100))); 2251 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 0, 100, 100)));
2252 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100))); 2252 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(0, 100, 100, 100)));
2253 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100))); 2253 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100, 100, 100)));
2254 2254
2255 // Occluded since its outside the surface bounds. 2255 // Occluded since its outside the surface bounds.
2256 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(200, 100, 100, 100))); 2256 EXPECT_TRUE(occlusion.OccludedLayer(layer, gfx::Rect(200, 100, 100, 100)));
2257 2257
2258 this->LeaveLayer(layer, occlusion); 2258 this->LeaveLayer(layer, &occlusion);
2259 this->VisitContributingSurface(layer, occlusion); 2259 this->VisitContributingSurface(layer, &occlusion);
2260 this->EnterLayer(parent, occlusion); 2260 this->EnterLayer(parent, &occlusion);
2261 2261
2262 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 2262 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
2263 } 2263 }
2264 }; 2264 };
2265 2265
2266 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty); 2266 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTestOpaqueContentsRegionEmpty);
2267 2267
2268 template <class Types> 2268 template <class Types>
2269 class OcclusionTrackerTestOpaqueContentsRegionNonEmpty : 2269 class OcclusionTrackerTestOpaqueContentsRegionNonEmpty :
2270 public OcclusionTrackerTest<Types> { 2270 public OcclusionTrackerTest<Types> {
(...skipping 10 matching lines...) Expand all
2281 gfx::Size(200, 200), 2281 gfx::Size(200, 200),
2282 false); 2282 false);
2283 this->CalcDrawEtc(parent); 2283 this->CalcDrawEtc(parent);
2284 { 2284 {
2285 TestOcclusionTrackerWithClip<typename Types::LayerType, 2285 TestOcclusionTrackerWithClip<typename Types::LayerType,
2286 typename Types::RenderSurfaceType> occlusion( 2286 typename Types::RenderSurfaceType> occlusion(
2287 gfx::Rect(0, 0, 1000, 1000)); 2287 gfx::Rect(0, 0, 1000, 1000));
2288 layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100)); 2288 layer->SetOpaqueContentsRect(gfx::Rect(0, 0, 100, 100));
2289 2289
2290 this->ResetLayerIterator(); 2290 this->ResetLayerIterator();
2291 this->VisitLayer(layer, occlusion); 2291 this->VisitLayer(layer, &occlusion);
2292 this->EnterLayer(parent, occlusion); 2292 this->EnterLayer(parent, &occlusion);
2293 2293
2294 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(), 2294 EXPECT_EQ(gfx::Rect(100, 100, 100, 100).ToString(),
2295 occlusion.occlusion_from_inside_target().ToString()); 2295 occlusion.occlusion_from_inside_target().ToString());
2296 2296
2297 EXPECT_FALSE( 2297 EXPECT_FALSE(
2298 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 2298 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
2299 EXPECT_TRUE( 2299 EXPECT_TRUE(
2300 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); 2300 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
2301 EXPECT_FALSE( 2301 EXPECT_FALSE(
2302 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); 2302 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100)));
2303 } 2303 }
2304 { 2304 {
2305 TestOcclusionTrackerWithClip<typename Types::LayerType, 2305 TestOcclusionTrackerWithClip<typename Types::LayerType,
2306 typename Types::RenderSurfaceType> occlusion( 2306 typename Types::RenderSurfaceType> occlusion(
2307 gfx::Rect(0, 0, 1000, 1000)); 2307 gfx::Rect(0, 0, 1000, 1000));
2308 layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180)); 2308 layer->SetOpaqueContentsRect(gfx::Rect(20, 20, 180, 180));
2309 2309
2310 this->ResetLayerIterator(); 2310 this->ResetLayerIterator();
2311 this->VisitLayer(layer, occlusion); 2311 this->VisitLayer(layer, &occlusion);
2312 this->EnterLayer(parent, occlusion); 2312 this->EnterLayer(parent, &occlusion);
2313 2313
2314 EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(), 2314 EXPECT_EQ(gfx::Rect(120, 120, 180, 180).ToString(),
2315 occlusion.occlusion_from_inside_target().ToString()); 2315 occlusion.occlusion_from_inside_target().ToString());
2316 2316
2317 EXPECT_FALSE( 2317 EXPECT_FALSE(
2318 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 2318 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
2319 EXPECT_FALSE( 2319 EXPECT_FALSE(
2320 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); 2320 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
2321 EXPECT_TRUE( 2321 EXPECT_TRUE(
2322 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); 2322 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100)));
2323 } 2323 }
2324 { 2324 {
2325 TestOcclusionTrackerWithClip<typename Types::LayerType, 2325 TestOcclusionTrackerWithClip<typename Types::LayerType,
2326 typename Types::RenderSurfaceType> occlusion( 2326 typename Types::RenderSurfaceType> occlusion(
2327 gfx::Rect(0, 0, 1000, 1000)); 2327 gfx::Rect(0, 0, 1000, 1000));
2328 layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100)); 2328 layer->SetOpaqueContentsRect(gfx::Rect(150, 150, 100, 100));
2329 2329
2330 this->ResetLayerIterator(); 2330 this->ResetLayerIterator();
2331 this->VisitLayer(layer, occlusion); 2331 this->VisitLayer(layer, &occlusion);
2332 this->EnterLayer(parent, occlusion); 2332 this->EnterLayer(parent, &occlusion);
2333 2333
2334 EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(), 2334 EXPECT_EQ(gfx::Rect(250, 250, 50, 50).ToString(),
2335 occlusion.occlusion_from_inside_target().ToString()); 2335 occlusion.occlusion_from_inside_target().ToString());
2336 2336
2337 EXPECT_FALSE( 2337 EXPECT_FALSE(
2338 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100))); 2338 occlusion.OccludedLayer(parent, gfx::Rect(0, 100, 100, 100)));
2339 EXPECT_FALSE( 2339 EXPECT_FALSE(
2340 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100))); 2340 occlusion.OccludedLayer(parent, gfx::Rect(100, 100, 100, 100)));
2341 EXPECT_FALSE( 2341 EXPECT_FALSE(
2342 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100))); 2342 occlusion.OccludedLayer(parent, gfx::Rect(200, 200, 100, 100)));
(...skipping 20 matching lines...) Expand all
2363 this->CreateDrawingLayer(container, 2363 this->CreateDrawingLayer(container,
2364 transform, 2364 transform,
2365 gfx::PointF(100.f, 100.f), 2365 gfx::PointF(100.f, 100.f),
2366 gfx::Size(200, 200), 2366 gfx::Size(200, 200),
2367 true); 2367 true);
2368 this->CalcDrawEtc(parent); 2368 this->CalcDrawEtc(parent);
2369 2369
2370 TestOcclusionTrackerWithClip<typename Types::LayerType, 2370 TestOcclusionTrackerWithClip<typename Types::LayerType,
2371 typename Types::RenderSurfaceType> occlusion( 2371 typename Types::RenderSurfaceType> occlusion(
2372 gfx::Rect(0, 0, 1000, 1000)); 2372 gfx::Rect(0, 0, 1000, 1000));
2373 this->EnterLayer(layer, occlusion); 2373 this->EnterLayer(layer, &occlusion);
2374 2374
2375 // The layer is rotated in 3d but without preserving 3d, so it only gets 2375 // The layer is rotated in 3d but without preserving 3d, so it only gets
2376 // resized. 2376 // resized.
2377 EXPECT_RECT_EQ( 2377 EXPECT_RECT_EQ(
2378 gfx::Rect(0, 0, 200, 200), 2378 gfx::Rect(0, 0, 200, 200),
2379 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); 2379 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200)));
2380 } 2380 }
2381 }; 2381 };
2382 2382
2383 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTest3dTransform); 2383 MAIN_AND_IMPL_THREAD_TEST(OcclusionTrackerTest3dTransform);
(...skipping 27 matching lines...) Expand all
2411 gfx::PointF(50.f, 50.f), 2411 gfx::PointF(50.f, 50.f),
2412 gfx::Size(100, 100), 2412 gfx::Size(100, 100),
2413 true); 2413 true);
2414 parent->SetPreserves3d(true); 2414 parent->SetPreserves3d(true);
2415 2415
2416 this->CalcDrawEtc(parent); 2416 this->CalcDrawEtc(parent);
2417 2417
2418 TestOcclusionTrackerWithClip<typename Types::LayerType, 2418 TestOcclusionTrackerWithClip<typename Types::LayerType,
2419 typename Types::RenderSurfaceType> occlusion( 2419 typename Types::RenderSurfaceType> occlusion(
2420 gfx::Rect(0, 0, 1000, 1000)); 2420 gfx::Rect(0, 0, 1000, 1000));
2421 this->VisitLayer(child2, occlusion); 2421 this->VisitLayer(child2, &occlusion);
2422 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 2422 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
2423 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 2423 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
2424 2424
2425 this->VisitLayer(child1, occlusion); 2425 this->VisitLayer(child1, &occlusion);
2426 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 2426 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
2427 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 2427 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
2428 } 2428 }
2429 }; 2429 };
2430 2430
2431 // This test will have different layer ordering on the impl thread; the test 2431 // This test will have different layer ordering on the impl thread; the test
2432 // will only work on the main thread. 2432 // will only work on the main thread.
2433 MAIN_THREAD_TEST(OcclusionTrackerTestUnsorted3dLayers); 2433 MAIN_THREAD_TEST(OcclusionTrackerTestUnsorted3dLayers);
2434 2434
2435 template <class Types> 2435 template <class Types>
(...skipping 19 matching lines...) Expand all
2455 gfx::PointF(100.f, 100.f), 2455 gfx::PointF(100.f, 100.f),
2456 gfx::Size(200, 200), 2456 gfx::Size(200, 200),
2457 true); 2457 true);
2458 container->SetPreserves3d(true); 2458 container->SetPreserves3d(true);
2459 layer->SetPreserves3d(true); 2459 layer->SetPreserves3d(true);
2460 this->CalcDrawEtc(parent); 2460 this->CalcDrawEtc(parent);
2461 2461
2462 TestOcclusionTrackerWithClip<typename Types::LayerType, 2462 TestOcclusionTrackerWithClip<typename Types::LayerType,
2463 typename Types::RenderSurfaceType> occlusion( 2463 typename Types::RenderSurfaceType> occlusion(
2464 gfx::Rect(0, 0, 1000, 1000)); 2464 gfx::Rect(0, 0, 1000, 1000));
2465 this->EnterLayer(layer, occlusion); 2465 this->EnterLayer(layer, &occlusion);
2466 2466
2467 EXPECT_RECT_EQ( 2467 EXPECT_RECT_EQ(
2468 gfx::Rect(0, 0, 200, 200), 2468 gfx::Rect(0, 0, 200, 200),
2469 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200))); 2469 occlusion.UnoccludedLayerContentRect(layer, gfx::Rect(0, 0, 200, 200)));
2470 } 2470 }
2471 }; 2471 };
2472 2472
2473 // This test requires accumulating occlusion of 3d layers, which are skipped by 2473 // This test requires accumulating occlusion of 3d layers, which are skipped by
2474 // the occlusion tracker on the main thread. So this test should run on the impl 2474 // the occlusion tracker on the main thread. So this test should run on the impl
2475 // thread. 2475 // thread.
(...skipping 22 matching lines...) Expand all
2498 parent, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500)); 2498 parent, this->identity_matrix, gfx::PointF(), gfx::Size(500, 500));
2499 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( 2499 typename Types::ContentLayerType* layer = this->CreateDrawingLayer(
2500 container, transform, gfx::PointF(), gfx::Size(500, 500), true); 2500 container, transform, gfx::PointF(), gfx::Size(500, 500), true);
2501 container->SetPreserves3d(true); 2501 container->SetPreserves3d(true);
2502 layer->SetPreserves3d(true); 2502 layer->SetPreserves3d(true);
2503 this->CalcDrawEtc(parent); 2503 this->CalcDrawEtc(parent);
2504 2504
2505 TestOcclusionTrackerWithClip<typename Types::LayerType, 2505 TestOcclusionTrackerWithClip<typename Types::LayerType,
2506 typename Types::RenderSurfaceType> occlusion( 2506 typename Types::RenderSurfaceType> occlusion(
2507 gfx::Rect(0, 0, 1000, 1000)); 2507 gfx::Rect(0, 0, 1000, 1000));
2508 this->EnterLayer(layer, occlusion); 2508 this->EnterLayer(layer, &occlusion);
2509 2509
2510 // The bottom 11 pixel rows of this layer remain visible inside the 2510 // The bottom 11 pixel rows of this layer remain visible inside the
2511 // container, after translation to the target surface. When translated back, 2511 // container, after translation to the target surface. When translated back,
2512 // this will include many more pixels but must include at least the bottom 2512 // this will include many more pixels but must include at least the bottom
2513 // 11 rows. 2513 // 11 rows.
2514 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect( 2514 EXPECT_TRUE(occlusion.UnoccludedLayerContentRect(
2515 layer, gfx::Rect(0, 0, 500, 500)).Contains(gfx::Rect(0, 489, 500, 11))); 2515 layer, gfx::Rect(0, 0, 500, 500)).Contains(gfx::Rect(0, 489, 500, 11)));
2516 } 2516 }
2517 }; 2517 };
2518 2518
(...skipping 21 matching lines...) Expand all
2540 parent, transform, gfx::PointF(), gfx::Size(100, 100), true); 2540 parent, transform, gfx::PointF(), gfx::Size(100, 100), true);
2541 parent->SetPreserves3d(true); 2541 parent->SetPreserves3d(true);
2542 layer->SetPreserves3d(true); 2542 layer->SetPreserves3d(true);
2543 this->CalcDrawEtc(parent); 2543 this->CalcDrawEtc(parent);
2544 2544
2545 TestOcclusionTrackerWithClip<typename Types::LayerType, 2545 TestOcclusionTrackerWithClip<typename Types::LayerType,
2546 typename Types::RenderSurfaceType> occlusion( 2546 typename Types::RenderSurfaceType> occlusion(
2547 gfx::Rect(0, 0, 1000, 1000)); 2547 gfx::Rect(0, 0, 1000, 1000));
2548 2548
2549 // The |layer| is entirely behind the camera and should not occlude. 2549 // The |layer| is entirely behind the camera and should not occlude.
2550 this->VisitLayer(layer, occlusion); 2550 this->VisitLayer(layer, &occlusion);
2551 this->EnterLayer(parent, occlusion); 2551 this->EnterLayer(parent, &occlusion);
2552 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 2552 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
2553 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 2553 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
2554 } 2554 }
2555 }; 2555 };
2556 2556
2557 // This test requires accumulating occlusion of 3d layers, which are skipped by 2557 // This test requires accumulating occlusion of 3d layers, which are skipped by
2558 // the occlusion tracker on the main thread. So this test should run on the impl 2558 // the occlusion tracker on the main thread. So this test should run on the impl
2559 // thread. 2559 // thread.
2560 IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude); 2560 IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude);
2561 2561
(...skipping 19 matching lines...) Expand all
2581 layer->SetPreserves3d(true); 2581 layer->SetPreserves3d(true);
2582 this->CalcDrawEtc(parent); 2582 this->CalcDrawEtc(parent);
2583 2583
2584 TestOcclusionTrackerWithClip<typename Types::LayerType, 2584 TestOcclusionTrackerWithClip<typename Types::LayerType,
2585 typename Types::RenderSurfaceType> occlusion( 2585 typename Types::RenderSurfaceType> occlusion(
2586 gfx::Rect(0, 0, 1000, 1000)); 2586 gfx::Rect(0, 0, 1000, 1000));
2587 2587
2588 // This is very close to the camera, so pixels in its visible_content_rect() 2588 // This is very close to the camera, so pixels in its visible_content_rect()
2589 // will actually go outside of the layer's clip rect. Ensure that those 2589 // will actually go outside of the layer's clip rect. Ensure that those
2590 // pixels don't occlude things outside the clip rect. 2590 // pixels don't occlude things outside the clip rect.
2591 this->VisitLayer(layer, occlusion); 2591 this->VisitLayer(layer, &occlusion);
2592 this->EnterLayer(parent, occlusion); 2592 this->EnterLayer(parent, &occlusion);
2593 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 2593 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
2594 occlusion.occlusion_from_inside_target().ToString()); 2594 occlusion.occlusion_from_inside_target().ToString());
2595 EXPECT_EQ(gfx::Rect().ToString(), 2595 EXPECT_EQ(gfx::Rect().ToString(),
2596 occlusion.occlusion_from_outside_target().ToString()); 2596 occlusion.occlusion_from_outside_target().ToString());
2597 } 2597 }
2598 }; 2598 };
2599 2599
2600 // This test requires accumulating occlusion of 3d layers, which are skipped by 2600 // This test requires accumulating occlusion of 3d layers, which are skipped by
2601 // the occlusion tracker on the main thread. So this test should run on the impl 2601 // the occlusion tracker on the main thread. So this test should run on the impl
2602 // thread. 2602 // thread.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 this->CalcDrawEtc(parent); 2663 this->CalcDrawEtc(parent);
2664 2664
2665 EXPECT_TRUE(layer->draw_opacity_is_animating()); 2665 EXPECT_TRUE(layer->draw_opacity_is_animating());
2666 EXPECT_FALSE(surface->draw_opacity_is_animating()); 2666 EXPECT_FALSE(surface->draw_opacity_is_animating());
2667 EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); 2667 EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating());
2668 2668
2669 TestOcclusionTrackerWithClip<typename Types::LayerType, 2669 TestOcclusionTrackerWithClip<typename Types::LayerType,
2670 typename Types::RenderSurfaceType> occlusion( 2670 typename Types::RenderSurfaceType> occlusion(
2671 gfx::Rect(0, 0, 1000, 1000)); 2671 gfx::Rect(0, 0, 1000, 1000));
2672 2672
2673 this->VisitLayer(topmost, occlusion); 2673 this->VisitLayer(topmost, &occlusion);
2674 this->EnterLayer(parent2, occlusion); 2674 this->EnterLayer(parent2, &occlusion);
2675 // This occlusion will affect all surfaces. 2675 // This occlusion will affect all surfaces.
2676 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2676 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2677 occlusion.occlusion_from_inside_target().ToString()); 2677 occlusion.occlusion_from_inside_target().ToString());
2678 EXPECT_EQ(gfx::Rect().ToString(), 2678 EXPECT_EQ(gfx::Rect().ToString(),
2679 occlusion.occlusion_from_outside_target().ToString()); 2679 occlusion.occlusion_from_outside_target().ToString());
2680 EXPECT_EQ(gfx::Rect(0, 0, 250, 300).ToString(), 2680 EXPECT_EQ(gfx::Rect(0, 0, 250, 300).ToString(),
2681 occlusion.UnoccludedLayerContentRect( 2681 occlusion.UnoccludedLayerContentRect(
2682 parent2, gfx::Rect(0, 0, 300, 300)).ToString()); 2682 parent2, gfx::Rect(0, 0, 300, 300)).ToString());
2683 this->LeaveLayer(parent2, occlusion); 2683 this->LeaveLayer(parent2, &occlusion);
2684 2684
2685 this->VisitLayer(surface_child2, occlusion); 2685 this->VisitLayer(surface_child2, &occlusion);
2686 this->EnterLayer(surface_child, occlusion); 2686 this->EnterLayer(surface_child, &occlusion);
2687 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), 2687 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
2688 occlusion.occlusion_from_inside_target().ToString()); 2688 occlusion.occlusion_from_inside_target().ToString());
2689 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2689 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2690 occlusion.occlusion_from_outside_target().ToString()); 2690 occlusion.occlusion_from_outside_target().ToString());
2691 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), 2691 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300),
2692 occlusion.UnoccludedLayerContentRect( 2692 occlusion.UnoccludedLayerContentRect(
2693 surface_child, gfx::Rect(0, 0, 200, 300))); 2693 surface_child, gfx::Rect(0, 0, 200, 300)));
2694 this->LeaveLayer(surface_child, occlusion); 2694 this->LeaveLayer(surface_child, &occlusion);
2695 this->EnterLayer(surface, occlusion); 2695 this->EnterLayer(surface, &occlusion);
2696 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), 2696 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(),
2697 occlusion.occlusion_from_inside_target().ToString()); 2697 occlusion.occlusion_from_inside_target().ToString());
2698 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2698 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2699 occlusion.occlusion_from_outside_target().ToString()); 2699 occlusion.occlusion_from_outside_target().ToString());
2700 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), 2700 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300),
2701 occlusion.UnoccludedLayerContentRect( 2701 occlusion.UnoccludedLayerContentRect(
2702 surface, gfx::Rect(0, 0, 300, 300))); 2702 surface, gfx::Rect(0, 0, 300, 300)));
2703 this->LeaveLayer(surface, occlusion); 2703 this->LeaveLayer(surface, &occlusion);
2704 2704
2705 this->EnterContributingSurface(surface, occlusion); 2705 this->EnterContributingSurface(surface, &occlusion);
2706 // Occlusion within the surface is lost when leaving the animating surface. 2706 // Occlusion within the surface is lost when leaving the animating surface.
2707 EXPECT_EQ(gfx::Rect().ToString(), 2707 EXPECT_EQ(gfx::Rect().ToString(),
2708 occlusion.occlusion_from_inside_target().ToString()); 2708 occlusion.occlusion_from_inside_target().ToString());
2709 EXPECT_EQ(gfx::Rect().ToString(), 2709 EXPECT_EQ(gfx::Rect().ToString(),
2710 occlusion.occlusion_from_outside_target().ToString()); 2710 occlusion.occlusion_from_outside_target().ToString());
2711 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), 2711 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300),
2712 occlusion.UnoccludedContributingSurfaceContentRect( 2712 occlusion.UnoccludedContributingSurfaceContentRect(
2713 surface, false, gfx::Rect(0, 0, 300, 300), NULL)); 2713 surface, false, gfx::Rect(0, 0, 300, 300), NULL));
2714 this->LeaveContributingSurface(surface, occlusion); 2714 this->LeaveContributingSurface(surface, &occlusion);
2715 2715
2716 // Occlusion from outside the animating surface still exists. 2716 // Occlusion from outside the animating surface still exists.
2717 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2717 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2718 occlusion.occlusion_from_inside_target().ToString()); 2718 occlusion.occlusion_from_inside_target().ToString());
2719 EXPECT_EQ(gfx::Rect().ToString(), 2719 EXPECT_EQ(gfx::Rect().ToString(),
2720 occlusion.occlusion_from_outside_target().ToString()); 2720 occlusion.occlusion_from_outside_target().ToString());
2721 2721
2722 this->VisitLayer(layer, occlusion); 2722 this->VisitLayer(layer, &occlusion);
2723 this->EnterLayer(parent, occlusion); 2723 this->EnterLayer(parent, &occlusion);
2724 2724
2725 // Occlusion is not added for the animating |layer|. 2725 // Occlusion is not added for the animating |layer|.
2726 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), 2726 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300),
2727 occlusion.UnoccludedLayerContentRect( 2727 occlusion.UnoccludedLayerContentRect(
2728 parent, gfx::Rect(0, 0, 300, 300))); 2728 parent, gfx::Rect(0, 0, 300, 300)));
2729 } 2729 }
2730 }; 2730 };
2731 2731
2732 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread); 2732 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity1OnMainThread);
2733 2733
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 this->CalcDrawEtc(parent); 2784 this->CalcDrawEtc(parent);
2785 2785
2786 EXPECT_TRUE(layer->draw_opacity_is_animating()); 2786 EXPECT_TRUE(layer->draw_opacity_is_animating());
2787 EXPECT_FALSE(surface->draw_opacity_is_animating()); 2787 EXPECT_FALSE(surface->draw_opacity_is_animating());
2788 EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating()); 2788 EXPECT_TRUE(surface->render_surface()->draw_opacity_is_animating());
2789 2789
2790 TestOcclusionTrackerWithClip<typename Types::LayerType, 2790 TestOcclusionTrackerWithClip<typename Types::LayerType,
2791 typename Types::RenderSurfaceType> occlusion( 2791 typename Types::RenderSurfaceType> occlusion(
2792 gfx::Rect(0, 0, 1000, 1000)); 2792 gfx::Rect(0, 0, 1000, 1000));
2793 2793
2794 this->VisitLayer(topmost, occlusion); 2794 this->VisitLayer(topmost, &occlusion);
2795 this->EnterLayer(parent2, occlusion); 2795 this->EnterLayer(parent2, &occlusion);
2796 // This occlusion will affect all surfaces. 2796 // This occlusion will affect all surfaces.
2797 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2797 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2798 occlusion.occlusion_from_inside_target().ToString()); 2798 occlusion.occlusion_from_inside_target().ToString());
2799 EXPECT_EQ(gfx::Rect().ToString(), 2799 EXPECT_EQ(gfx::Rect().ToString(),
2800 occlusion.occlusion_from_outside_target().ToString()); 2800 occlusion.occlusion_from_outside_target().ToString());
2801 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), 2801 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300),
2802 occlusion.UnoccludedLayerContentRect( 2802 occlusion.UnoccludedLayerContentRect(
2803 parent, gfx::Rect(0, 0, 300, 300))); 2803 parent, gfx::Rect(0, 0, 300, 300)));
2804 this->LeaveLayer(parent2, occlusion); 2804 this->LeaveLayer(parent2, &occlusion);
2805 2805
2806 this->VisitLayer(surface_child2, occlusion); 2806 this->VisitLayer(surface_child2, &occlusion);
2807 this->EnterLayer(surface_child, occlusion); 2807 this->EnterLayer(surface_child, &occlusion);
2808 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), 2808 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
2809 occlusion.occlusion_from_inside_target().ToString()); 2809 occlusion.occlusion_from_inside_target().ToString());
2810 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2810 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2811 occlusion.occlusion_from_outside_target().ToString()); 2811 occlusion.occlusion_from_outside_target().ToString());
2812 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300), 2812 EXPECT_RECT_EQ(gfx::Rect(100, 0, 100, 300),
2813 occlusion.UnoccludedLayerContentRect( 2813 occlusion.UnoccludedLayerContentRect(
2814 surface_child, gfx::Rect(0, 0, 200, 300))); 2814 surface_child, gfx::Rect(0, 0, 200, 300)));
2815 this->LeaveLayer(surface_child, occlusion); 2815 this->LeaveLayer(surface_child, &occlusion);
2816 this->EnterLayer(surface, occlusion); 2816 this->EnterLayer(surface, &occlusion);
2817 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(), 2817 EXPECT_EQ(gfx::Rect(0, 0, 200, 300).ToString(),
2818 occlusion.occlusion_from_inside_target().ToString()); 2818 occlusion.occlusion_from_inside_target().ToString());
2819 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2819 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2820 occlusion.occlusion_from_outside_target().ToString()); 2820 occlusion.occlusion_from_outside_target().ToString());
2821 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300), 2821 EXPECT_RECT_EQ(gfx::Rect(200, 0, 50, 300),
2822 occlusion.UnoccludedLayerContentRect( 2822 occlusion.UnoccludedLayerContentRect(
2823 surface, gfx::Rect(0, 0, 300, 300))); 2823 surface, gfx::Rect(0, 0, 300, 300)));
2824 this->LeaveLayer(surface, occlusion); 2824 this->LeaveLayer(surface, &occlusion);
2825 2825
2826 this->EnterContributingSurface(surface, occlusion); 2826 this->EnterContributingSurface(surface, &occlusion);
2827 // Occlusion within the surface is lost when leaving the animating surface. 2827 // Occlusion within the surface is lost when leaving the animating surface.
2828 EXPECT_EQ(gfx::Rect().ToString(), 2828 EXPECT_EQ(gfx::Rect().ToString(),
2829 occlusion.occlusion_from_inside_target().ToString()); 2829 occlusion.occlusion_from_inside_target().ToString());
2830 EXPECT_EQ(gfx::Rect().ToString(), 2830 EXPECT_EQ(gfx::Rect().ToString(),
2831 occlusion.occlusion_from_outside_target().ToString()); 2831 occlusion.occlusion_from_outside_target().ToString());
2832 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), 2832 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300),
2833 occlusion.UnoccludedContributingSurfaceContentRect( 2833 occlusion.UnoccludedContributingSurfaceContentRect(
2834 surface, false, gfx::Rect(0, 0, 300, 300), NULL)); 2834 surface, false, gfx::Rect(0, 0, 300, 300), NULL));
2835 this->LeaveContributingSurface(surface, occlusion); 2835 this->LeaveContributingSurface(surface, &occlusion);
2836 2836
2837 // Occlusion from outside the animating surface still exists. 2837 // Occlusion from outside the animating surface still exists.
2838 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2838 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2839 occlusion.occlusion_from_inside_target().ToString()); 2839 occlusion.occlusion_from_inside_target().ToString());
2840 EXPECT_EQ(gfx::Rect().ToString(), 2840 EXPECT_EQ(gfx::Rect().ToString(),
2841 occlusion.occlusion_from_outside_target().ToString()); 2841 occlusion.occlusion_from_outside_target().ToString());
2842 2842
2843 this->VisitLayer(layer, occlusion); 2843 this->VisitLayer(layer, &occlusion);
2844 this->EnterLayer(parent, occlusion); 2844 this->EnterLayer(parent, &occlusion);
2845 2845
2846 // Occlusion is not added for the animating |layer|. 2846 // Occlusion is not added for the animating |layer|.
2847 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), 2847 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300),
2848 occlusion.UnoccludedLayerContentRect( 2848 occlusion.UnoccludedLayerContentRect(
2849 parent, gfx::Rect(0, 0, 300, 300))); 2849 parent, gfx::Rect(0, 0, 300, 300)));
2850 } 2850 }
2851 }; 2851 };
2852 2852
2853 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread); 2853 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationOpacity0OnMainThread);
2854 2854
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 // The surface owning layer doesn't animate against its own surface. 2905 // The surface owning layer doesn't animate against its own surface.
2906 EXPECT_FALSE(surface->draw_transform_is_animating()); 2906 EXPECT_FALSE(surface->draw_transform_is_animating());
2907 EXPECT_TRUE(surface->screen_space_transform_is_animating()); 2907 EXPECT_TRUE(surface->screen_space_transform_is_animating());
2908 EXPECT_TRUE(surface_child->draw_transform_is_animating()); 2908 EXPECT_TRUE(surface_child->draw_transform_is_animating());
2909 EXPECT_TRUE(surface_child->screen_space_transform_is_animating()); 2909 EXPECT_TRUE(surface_child->screen_space_transform_is_animating());
2910 2910
2911 TestOcclusionTrackerWithClip<typename Types::LayerType, 2911 TestOcclusionTrackerWithClip<typename Types::LayerType,
2912 typename Types::RenderSurfaceType> occlusion( 2912 typename Types::RenderSurfaceType> occlusion(
2913 gfx::Rect(0, 0, 1000, 1000)); 2913 gfx::Rect(0, 0, 1000, 1000));
2914 2914
2915 this->VisitLayer(surface2, occlusion); 2915 this->VisitLayer(surface2, &occlusion);
2916 this->EnterContributingSurface(surface2, occlusion); 2916 this->EnterContributingSurface(surface2, &occlusion);
2917 2917
2918 EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(), 2918 EXPECT_EQ(gfx::Rect(0, 0, 50, 300).ToString(),
2919 occlusion.occlusion_from_inside_target().ToString()); 2919 occlusion.occlusion_from_inside_target().ToString());
2920 2920
2921 this->LeaveContributingSurface(surface2, occlusion); 2921 this->LeaveContributingSurface(surface2, &occlusion);
2922 this->EnterLayer(surface_child2, occlusion); 2922 this->EnterLayer(surface_child2, &occlusion);
2923 2923
2924 // surface_child2 is moving in screen space but not relative to its target, 2924 // surface_child2 is moving in screen space but not relative to its target,
2925 // so occlusion should happen in its target space only. It also means that 2925 // so occlusion should happen in its target space only. It also means that
2926 // things occluding from outside the target (e.g. surface2) cannot occlude 2926 // things occluding from outside the target (e.g. surface2) cannot occlude
2927 // this layer. 2927 // this layer.
2928 EXPECT_EQ(gfx::Rect().ToString(), 2928 EXPECT_EQ(gfx::Rect().ToString(),
2929 occlusion.occlusion_from_outside_target().ToString()); 2929 occlusion.occlusion_from_outside_target().ToString());
2930 2930
2931 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300), 2931 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 300),
2932 occlusion.UnoccludedLayerContentRect( 2932 occlusion.UnoccludedLayerContentRect(
2933 surface_child2, gfx::Rect(0, 0, 100, 300))); 2933 surface_child2, gfx::Rect(0, 0, 100, 300)));
2934 EXPECT_FALSE( 2934 EXPECT_FALSE(
2935 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 50, 300))); 2935 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 50, 300)));
2936 2936
2937 this->LeaveLayer(surface_child2, occlusion); 2937 this->LeaveLayer(surface_child2, &occlusion);
2938 this->EnterLayer(surface_child, occlusion); 2938 this->EnterLayer(surface_child, &occlusion);
2939 EXPECT_FALSE( 2939 EXPECT_FALSE(
2940 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 100, 300))); 2940 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 100, 300)));
2941 EXPECT_EQ(gfx::Rect().ToString(), 2941 EXPECT_EQ(gfx::Rect().ToString(),
2942 occlusion.occlusion_from_outside_target().ToString()); 2942 occlusion.occlusion_from_outside_target().ToString());
2943 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), 2943 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
2944 occlusion.occlusion_from_inside_target().ToString()); 2944 occlusion.occlusion_from_inside_target().ToString());
2945 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), 2945 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300),
2946 occlusion.UnoccludedLayerContentRect( 2946 occlusion.UnoccludedLayerContentRect(
2947 surface, gfx::Rect(0, 0, 300, 300))); 2947 surface, gfx::Rect(0, 0, 300, 300)));
2948 2948
2949 // The surface_child is occluded by the surface_child2, but is moving 2949 // The surface_child is occluded by the surface_child2, but is moving
2950 // relative its target, so it can't be occluded. 2950 // relative its target, so it can't be occluded.
2951 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 300), 2951 EXPECT_RECT_EQ(gfx::Rect(0, 0, 200, 300),
2952 occlusion.UnoccludedLayerContentRect( 2952 occlusion.UnoccludedLayerContentRect(
2953 surface_child, gfx::Rect(0, 0, 200, 300))); 2953 surface_child, gfx::Rect(0, 0, 200, 300)));
2954 EXPECT_FALSE( 2954 EXPECT_FALSE(
2955 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 50, 300))); 2955 occlusion.OccludedLayer(surface_child, gfx::Rect(0, 0, 50, 300)));
2956 2956
2957 this->LeaveLayer(surface_child, occlusion); 2957 this->LeaveLayer(surface_child, &occlusion);
2958 this->EnterLayer(surface, occlusion); 2958 this->EnterLayer(surface, &occlusion);
2959 // The surface_child is moving in screen space but not relative to its 2959 // The surface_child is moving in screen space but not relative to its
2960 // target, so occlusion should happen from within the target only. 2960 // target, so occlusion should happen from within the target only.
2961 EXPECT_EQ(gfx::Rect().ToString(), 2961 EXPECT_EQ(gfx::Rect().ToString(),
2962 occlusion.occlusion_from_outside_target().ToString()); 2962 occlusion.occlusion_from_outside_target().ToString());
2963 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(), 2963 EXPECT_EQ(gfx::Rect(0, 0, 100, 300).ToString(),
2964 occlusion.occlusion_from_inside_target().ToString()); 2964 occlusion.occlusion_from_inside_target().ToString());
2965 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300), 2965 EXPECT_RECT_EQ(gfx::Rect(100, 0, 200, 300),
2966 occlusion.UnoccludedLayerContentRect( 2966 occlusion.UnoccludedLayerContentRect(
2967 surface, gfx::Rect(0, 0, 300, 300))); 2967 surface, gfx::Rect(0, 0, 300, 300)));
2968 2968
2969 this->LeaveLayer(surface, occlusion); 2969 this->LeaveLayer(surface, &occlusion);
2970 // The surface's owning layer is moving in screen space but not relative to 2970 // The surface's owning layer is moving in screen space but not relative to
2971 // its target, so occlusion should happen within the target only. 2971 // its target, so occlusion should happen within the target only.
2972 EXPECT_EQ(gfx::Rect().ToString(), 2972 EXPECT_EQ(gfx::Rect().ToString(),
2973 occlusion.occlusion_from_outside_target().ToString()); 2973 occlusion.occlusion_from_outside_target().ToString());
2974 EXPECT_EQ(gfx::Rect(0, 0, 300, 300).ToString(), 2974 EXPECT_EQ(gfx::Rect(0, 0, 300, 300).ToString(),
2975 occlusion.occlusion_from_inside_target().ToString()); 2975 occlusion.occlusion_from_inside_target().ToString());
2976 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), 2976 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0),
2977 occlusion.UnoccludedLayerContentRect( 2977 occlusion.UnoccludedLayerContentRect(
2978 surface, gfx::Rect(0, 0, 300, 300))); 2978 surface, gfx::Rect(0, 0, 300, 300)));
2979 2979
2980 this->EnterContributingSurface(surface, occlusion); 2980 this->EnterContributingSurface(surface, &occlusion);
2981 // The contributing |surface| is animating so it can't be occluded. 2981 // The contributing |surface| is animating so it can't be occluded.
2982 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 300), 2982 EXPECT_RECT_EQ(gfx::Rect(0, 0, 300, 300),
2983 occlusion.UnoccludedContributingSurfaceContentRect( 2983 occlusion.UnoccludedContributingSurfaceContentRect(
2984 surface, false, gfx::Rect(0, 0, 300, 300), NULL)); 2984 surface, false, gfx::Rect(0, 0, 300, 300), NULL));
2985 this->LeaveContributingSurface(surface, occlusion); 2985 this->LeaveContributingSurface(surface, &occlusion);
2986 2986
2987 this->EnterLayer(layer, occlusion); 2987 this->EnterLayer(layer, &occlusion);
2988 // The |surface| is moving in the screen and in its target, so all occlusion 2988 // The |surface| is moving in the screen and in its target, so all occlusion
2989 // within the surface is lost when leaving it. 2989 // within the surface is lost when leaving it.
2990 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300), 2990 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300),
2991 occlusion.UnoccludedLayerContentRect( 2991 occlusion.UnoccludedLayerContentRect(
2992 parent, gfx::Rect(0, 0, 300, 300))); 2992 parent, gfx::Rect(0, 0, 300, 300)));
2993 this->LeaveLayer(layer, occlusion); 2993 this->LeaveLayer(layer, &occlusion);
2994 2994
2995 this->EnterLayer(parent, occlusion); 2995 this->EnterLayer(parent, &occlusion);
2996 // The |layer| is animating in the screen and in its target, so no occlusion 2996 // The |layer| is animating in the screen and in its target, so no occlusion
2997 // is added. 2997 // is added.
2998 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300), 2998 EXPECT_RECT_EQ(gfx::Rect(50, 0, 250, 300),
2999 occlusion.UnoccludedLayerContentRect( 2999 occlusion.UnoccludedLayerContentRect(
3000 parent, gfx::Rect(0, 0, 300, 300))); 3000 parent, gfx::Rect(0, 0, 300, 300)));
3001 } 3001 }
3002 }; 3002 };
3003 3003
3004 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationTranslateOnMainThread); 3004 MAIN_THREAD_TEST(OcclusionTrackerTestAnimationTranslateOnMainThread);
3005 3005
(...skipping 20 matching lines...) Expand all
3026 gfx::Size(300, 300), 3026 gfx::Size(300, 300),
3027 false); 3027 false);
3028 surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); 3028 surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200));
3029 surface2->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200)); 3029 surface2->SetOpaqueContentsRect(gfx::Rect(0, 0, 200, 200));
3030 this->CalcDrawEtc(parent); 3030 this->CalcDrawEtc(parent);
3031 3031
3032 TestOcclusionTrackerWithClip<typename Types::LayerType, 3032 TestOcclusionTrackerWithClip<typename Types::LayerType,
3033 typename Types::RenderSurfaceType> occlusion( 3033 typename Types::RenderSurfaceType> occlusion(
3034 gfx::Rect(0, 0, 1000, 1000)); 3034 gfx::Rect(0, 0, 1000, 1000));
3035 3035
3036 this->VisitLayer(surface2, occlusion); 3036 this->VisitLayer(surface2, &occlusion);
3037 this->VisitContributingSurface(surface2, occlusion); 3037 this->VisitContributingSurface(surface2, &occlusion);
3038 3038
3039 EXPECT_EQ(gfx::Rect().ToString(), 3039 EXPECT_EQ(gfx::Rect().ToString(),
3040 occlusion.occlusion_from_outside_target().ToString()); 3040 occlusion.occlusion_from_outside_target().ToString());
3041 EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(), 3041 EXPECT_EQ(gfx::Rect(50, 50, 200, 200).ToString(),
3042 occlusion.occlusion_from_inside_target().ToString()); 3042 occlusion.occlusion_from_inside_target().ToString());
3043 3043
3044 // Clear any stored occlusion. 3044 // Clear any stored occlusion.
3045 occlusion.set_occlusion_from_outside_target(Region()); 3045 occlusion.set_occlusion_from_outside_target(Region());
3046 occlusion.set_occlusion_from_inside_target(Region()); 3046 occlusion.set_occlusion_from_inside_target(Region());
3047 3047
3048 this->VisitLayer(surface, occlusion); 3048 this->VisitLayer(surface, &occlusion);
3049 this->VisitContributingSurface(surface, occlusion); 3049 this->VisitContributingSurface(surface, &occlusion);
3050 3050
3051 EXPECT_EQ(gfx::Rect().ToString(), 3051 EXPECT_EQ(gfx::Rect().ToString(),
3052 occlusion.occlusion_from_outside_target().ToString()); 3052 occlusion.occlusion_from_outside_target().ToString());
3053 EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(), 3053 EXPECT_EQ(gfx::Rect(0, 0, 400, 400).ToString(),
3054 occlusion.occlusion_from_inside_target().ToString()); 3054 occlusion.occlusion_from_inside_target().ToString());
3055 } 3055 }
3056 }; 3056 };
3057 3057
3058 MAIN_AND_IMPL_THREAD_TEST( 3058 MAIN_AND_IMPL_THREAD_TEST(
3059 OcclusionTrackerTestSurfaceOcclusionTranslatesToParent); 3059 OcclusionTrackerTestSurfaceOcclusionTranslatesToParent);
(...skipping 14 matching lines...) Expand all
3074 gfx::PointF(), 3074 gfx::PointF(),
3075 gfx::Size(500, 300), 3075 gfx::Size(500, 300),
3076 false); 3076 false);
3077 surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 400, 200)); 3077 surface->SetOpaqueContentsRect(gfx::Rect(0, 0, 400, 200));
3078 this->CalcDrawEtc(parent); 3078 this->CalcDrawEtc(parent);
3079 3079
3080 TestOcclusionTrackerWithClip<typename Types::LayerType, 3080 TestOcclusionTrackerWithClip<typename Types::LayerType,
3081 typename Types::RenderSurfaceType> occlusion( 3081 typename Types::RenderSurfaceType> occlusion(
3082 gfx::Rect(0, 0, 1000, 1000)); 3082 gfx::Rect(0, 0, 1000, 1000));
3083 3083
3084 this->VisitLayer(surface, occlusion); 3084 this->VisitLayer(surface, &occlusion);
3085 this->VisitContributingSurface(surface, occlusion); 3085 this->VisitContributingSurface(surface, &occlusion);
3086 3086
3087 EXPECT_EQ(gfx::Rect().ToString(), 3087 EXPECT_EQ(gfx::Rect().ToString(),
3088 occlusion.occlusion_from_outside_target().ToString()); 3088 occlusion.occlusion_from_outside_target().ToString());
3089 EXPECT_EQ(gfx::Rect(0, 0, 300, 200).ToString(), 3089 EXPECT_EQ(gfx::Rect(0, 0, 300, 200).ToString(),
3090 occlusion.occlusion_from_inside_target().ToString()); 3090 occlusion.occlusion_from_inside_target().ToString());
3091 } 3091 }
3092 }; 3092 };
3093 3093
3094 MAIN_AND_IMPL_THREAD_TEST( 3094 MAIN_AND_IMPL_THREAD_TEST(
3095 OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping); 3095 OcclusionTrackerTestSurfaceOcclusionTranslatesWithClipping);
(...skipping 22 matching lines...) Expand all
3118 gfx::PointF(0.f, 100.f), 3118 gfx::PointF(0.f, 100.f),
3119 gfx::Size(100, 100), 3119 gfx::Size(100, 100),
3120 true); 3120 true);
3121 this->CalcDrawEtc(parent); 3121 this->CalcDrawEtc(parent);
3122 3122
3123 TestOcclusionTrackerWithClip<typename Types::LayerType, 3123 TestOcclusionTrackerWithClip<typename Types::LayerType,
3124 typename Types::RenderSurfaceType> occlusion( 3124 typename Types::RenderSurfaceType> occlusion(
3125 gfx::Rect(0, 0, 1000, 1000)); 3125 gfx::Rect(0, 0, 1000, 1000));
3126 3126
3127 // |topmost| occludes the replica, but not the surface itself. 3127 // |topmost| occludes the replica, but not the surface itself.
3128 this->VisitLayer(topmost, occlusion); 3128 this->VisitLayer(topmost, &occlusion);
3129 3129
3130 EXPECT_EQ(gfx::Rect().ToString(), 3130 EXPECT_EQ(gfx::Rect().ToString(),
3131 occlusion.occlusion_from_outside_target().ToString()); 3131 occlusion.occlusion_from_outside_target().ToString());
3132 EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(), 3132 EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(),
3133 occlusion.occlusion_from_inside_target().ToString()); 3133 occlusion.occlusion_from_inside_target().ToString());
3134 3134
3135 this->VisitLayer(surface, occlusion); 3135 this->VisitLayer(surface, &occlusion);
3136 3136
3137 EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(), 3137 EXPECT_EQ(gfx::Rect(0, 100, 100, 100).ToString(),
3138 occlusion.occlusion_from_outside_target().ToString()); 3138 occlusion.occlusion_from_outside_target().ToString());
3139 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 3139 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
3140 occlusion.occlusion_from_inside_target().ToString()); 3140 occlusion.occlusion_from_inside_target().ToString());
3141 3141
3142 this->EnterContributingSurface(surface, occlusion); 3142 this->EnterContributingSurface(surface, &occlusion);
3143 3143
3144 // Surface is not occluded so it shouldn't think it is. 3144 // Surface is not occluded so it shouldn't think it is.
3145 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 3145 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
3146 occlusion.UnoccludedContributingSurfaceContentRect( 3146 occlusion.UnoccludedContributingSurfaceContentRect(
3147 surface, false, gfx::Rect(0, 0, 100, 100), NULL)); 3147 surface, false, gfx::Rect(0, 0, 100, 100), NULL));
3148 } 3148 }
3149 }; 3149 };
3150 3150
3151 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); 3151 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded);
3152 3152
(...skipping 22 matching lines...) Expand all
3175 gfx::PointF(), 3175 gfx::PointF(),
3176 gfx::Size(100, 110), 3176 gfx::Size(100, 110),
3177 true); 3177 true);
3178 this->CalcDrawEtc(parent); 3178 this->CalcDrawEtc(parent);
3179 3179
3180 TestOcclusionTrackerWithClip<typename Types::LayerType, 3180 TestOcclusionTrackerWithClip<typename Types::LayerType,
3181 typename Types::RenderSurfaceType> occlusion( 3181 typename Types::RenderSurfaceType> occlusion(
3182 gfx::Rect(0, 0, 1000, 1000)); 3182 gfx::Rect(0, 0, 1000, 1000));
3183 3183
3184 // |topmost| occludes the surface, but not the entire surface's replica. 3184 // |topmost| occludes the surface, but not the entire surface's replica.
3185 this->VisitLayer(topmost, occlusion); 3185 this->VisitLayer(topmost, &occlusion);
3186 3186
3187 EXPECT_EQ(gfx::Rect().ToString(), 3187 EXPECT_EQ(gfx::Rect().ToString(),
3188 occlusion.occlusion_from_outside_target().ToString()); 3188 occlusion.occlusion_from_outside_target().ToString());
3189 EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), 3189 EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(),
3190 occlusion.occlusion_from_inside_target().ToString()); 3190 occlusion.occlusion_from_inside_target().ToString());
3191 3191
3192 this->VisitLayer(surface, occlusion); 3192 this->VisitLayer(surface, &occlusion);
3193 3193
3194 EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(), 3194 EXPECT_EQ(gfx::Rect(0, 0, 100, 110).ToString(),
3195 occlusion.occlusion_from_outside_target().ToString()); 3195 occlusion.occlusion_from_outside_target().ToString());
3196 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 3196 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
3197 occlusion.occlusion_from_inside_target().ToString()); 3197 occlusion.occlusion_from_inside_target().ToString());
3198 3198
3199 this->EnterContributingSurface(surface, occlusion); 3199 this->EnterContributingSurface(surface, &occlusion);
3200 3200
3201 // Surface is occluded, but only the top 10px of the replica. 3201 // Surface is occluded, but only the top 10px of the replica.
3202 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), 3202 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0),
3203 occlusion.UnoccludedContributingSurfaceContentRect( 3203 occlusion.UnoccludedContributingSurfaceContentRect(
3204 surface, false, gfx::Rect(0, 0, 100, 100), NULL)); 3204 surface, false, gfx::Rect(0, 0, 100, 100), NULL));
3205 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90), 3205 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90),
3206 occlusion.UnoccludedContributingSurfaceContentRect( 3206 occlusion.UnoccludedContributingSurfaceContentRect(
3207 surface, true, gfx::Rect(0, 0, 100, 100), NULL)); 3207 surface, true, gfx::Rect(0, 0, 100, 100), NULL));
3208 } 3208 }
3209 }; 3209 };
(...skipping 28 matching lines...) Expand all
3238 gfx::Size(50, 100), 3238 gfx::Size(50, 100),
3239 true); 3239 true);
3240 this->CalcDrawEtc(parent); 3240 this->CalcDrawEtc(parent);
3241 3241
3242 TestOcclusionTrackerWithClip<typename Types::LayerType, 3242 TestOcclusionTrackerWithClip<typename Types::LayerType,
3243 typename Types::RenderSurfaceType> occlusion( 3243 typename Types::RenderSurfaceType> occlusion(
3244 gfx::Rect(0, 0, 1000, 1000)); 3244 gfx::Rect(0, 0, 1000, 1000));
3245 3245
3246 // These occlude the surface and replica differently, so we can test each 3246 // These occlude the surface and replica differently, so we can test each
3247 // one. 3247 // one.
3248 this->VisitLayer(over_replica, occlusion); 3248 this->VisitLayer(over_replica, &occlusion);
3249 this->VisitLayer(over_surface, occlusion); 3249 this->VisitLayer(over_surface, &occlusion);
3250 3250
3251 EXPECT_EQ(gfx::Rect().ToString(), 3251 EXPECT_EQ(gfx::Rect().ToString(),
3252 occlusion.occlusion_from_outside_target().ToString()); 3252 occlusion.occlusion_from_outside_target().ToString());
3253 EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 100)) 3253 EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 100))
3254 .ToString(), 3254 .ToString(),
3255 occlusion.occlusion_from_inside_target().ToString()); 3255 occlusion.occlusion_from_inside_target().ToString());
3256 3256
3257 this->VisitLayer(surface, occlusion); 3257 this->VisitLayer(surface, &occlusion);
3258 3258
3259 EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 100)) 3259 EXPECT_EQ(UnionRegions(gfx::Rect(0, 0, 40, 100), gfx::Rect(0, 100, 50, 100))
3260 .ToString(), 3260 .ToString(),
3261 occlusion.occlusion_from_outside_target().ToString()); 3261 occlusion.occlusion_from_outside_target().ToString());
3262 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 3262 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
3263 occlusion.occlusion_from_inside_target().ToString()); 3263 occlusion.occlusion_from_inside_target().ToString());
3264 3264
3265 this->EnterContributingSurface(surface, occlusion); 3265 this->EnterContributingSurface(surface, &occlusion);
3266 3266
3267 // Surface and replica are occluded different amounts. 3267 // Surface and replica are occluded different amounts.
3268 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100), 3268 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100),
3269 occlusion.UnoccludedContributingSurfaceContentRect( 3269 occlusion.UnoccludedContributingSurfaceContentRect(
3270 surface, false, gfx::Rect(0, 0, 100, 100), NULL)); 3270 surface, false, gfx::Rect(0, 0, 100, 100), NULL));
3271 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100), 3271 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100),
3272 occlusion.UnoccludedContributingSurfaceContentRect( 3272 occlusion.UnoccludedContributingSurfaceContentRect(
3273 surface, true, gfx::Rect(0, 0, 100, 100), NULL)); 3273 surface, true, gfx::Rect(0, 0, 100, 100), NULL));
3274 } 3274 }
3275 }; 3275 };
(...skipping 28 matching lines...) Expand all
3304 typename Types::LayerType* topmost = this->CreateDrawingLayer( 3304 typename Types::LayerType* topmost = this->CreateDrawingLayer(
3305 parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true); 3305 parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true);
3306 this->CalcDrawEtc(parent); 3306 this->CalcDrawEtc(parent);
3307 3307
3308 TestOcclusionTrackerWithClip<typename Types::LayerType, 3308 TestOcclusionTrackerWithClip<typename Types::LayerType,
3309 typename Types::RenderSurfaceType> occlusion( 3309 typename Types::RenderSurfaceType> occlusion(
3310 gfx::Rect(-100, -100, 1000, 1000)); 3310 gfx::Rect(-100, -100, 1000, 1000));
3311 3311
3312 // |topmost| occludes everything partially so we know occlusion is happening 3312 // |topmost| occludes everything partially so we know occlusion is happening
3313 // at all. 3313 // at all.
3314 this->VisitLayer(topmost, occlusion); 3314 this->VisitLayer(topmost, &occlusion);
3315 3315
3316 EXPECT_EQ(gfx::Rect().ToString(), 3316 EXPECT_EQ(gfx::Rect().ToString(),
3317 occlusion.occlusion_from_outside_target().ToString()); 3317 occlusion.occlusion_from_outside_target().ToString());
3318 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 3318 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
3319 occlusion.occlusion_from_inside_target().ToString()); 3319 occlusion.occlusion_from_inside_target().ToString());
3320 3320
3321 this->VisitLayer(surface_child, occlusion); 3321 this->VisitLayer(surface_child, &occlusion);
3322 3322
3323 // surface_child increases the occlusion in the screen by a narrow sliver. 3323 // surface_child increases the occlusion in the screen by a narrow sliver.
3324 EXPECT_EQ(gfx::Rect(0, -10, 100, 50).ToString(), 3324 EXPECT_EQ(gfx::Rect(0, -10, 100, 50).ToString(),
3325 occlusion.occlusion_from_outside_target().ToString()); 3325 occlusion.occlusion_from_outside_target().ToString());
3326 // In its own surface, surface_child is at 0,0 as is its occlusion. 3326 // In its own surface, surface_child is at 0,0 as is its occlusion.
3327 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 3327 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
3328 occlusion.occlusion_from_inside_target().ToString()); 3328 occlusion.occlusion_from_inside_target().ToString());
3329 3329
3330 // The root layer always has a clip rect. So the parent of |surface| has a 3330 // The root layer always has a clip rect. So the parent of |surface| has a
3331 // clip rect. However, the owning layer for |surface| does not mask to 3331 // clip rect. However, the owning layer for |surface| does not mask to
3332 // bounds, so it doesn't have a clip rect of its own. Thus the parent of 3332 // bounds, so it doesn't have a clip rect of its own. Thus the parent of
3333 // |surface_child| exercises different code paths as its parent does not 3333 // |surface_child| exercises different code paths as its parent does not
3334 // have a clip rect. 3334 // have a clip rect.
3335 3335
3336 this->EnterContributingSurface(surface_child, occlusion); 3336 this->EnterContributingSurface(surface_child, &occlusion);
3337 // The surface_child's parent does not have a clip rect as it owns a render 3337 // The surface_child's parent does not have a clip rect as it owns a render
3338 // surface. Make sure the unoccluded rect does not get clipped away 3338 // surface. Make sure the unoccluded rect does not get clipped away
3339 // inappropriately. 3339 // inappropriately.
3340 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10), 3340 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10),
3341 occlusion.UnoccludedContributingSurfaceContentRect( 3341 occlusion.UnoccludedContributingSurfaceContentRect(
3342 surface_child, false, gfx::Rect(0, 0, 100, 50), NULL)); 3342 surface_child, false, gfx::Rect(0, 0, 100, 50), NULL));
3343 this->LeaveContributingSurface(surface_child, occlusion); 3343 this->LeaveContributingSurface(surface_child, &occlusion);
3344 3344
3345 // When the surface_child's occlusion is transformed up to its parent, make 3345 // When the surface_child's occlusion is transformed up to its parent, make
3346 // sure it is not clipped away inappropriately also. 3346 // sure it is not clipped away inappropriately also.
3347 this->EnterLayer(surface, occlusion); 3347 this->EnterLayer(surface, &occlusion);
3348 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 3348 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
3349 occlusion.occlusion_from_outside_target().ToString()); 3349 occlusion.occlusion_from_outside_target().ToString());
3350 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), 3350 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(),
3351 occlusion.occlusion_from_inside_target().ToString()); 3351 occlusion.occlusion_from_inside_target().ToString());
3352 this->LeaveLayer(surface, occlusion); 3352 this->LeaveLayer(surface, &occlusion);
3353 3353
3354 this->EnterContributingSurface(surface, occlusion); 3354 this->EnterContributingSurface(surface, &occlusion);
3355 // The surface's parent does have a clip rect as it is the root layer. 3355 // The surface's parent does have a clip rect as it is the root layer.
3356 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50), 3356 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50),
3357 occlusion.UnoccludedContributingSurfaceContentRect( 3357 occlusion.UnoccludedContributingSurfaceContentRect(
3358 surface, false, gfx::Rect(0, 0, 100, 100), NULL)); 3358 surface, false, gfx::Rect(0, 0, 100, 100), NULL));
3359 } 3359 }
3360 }; 3360 };
3361 3361
3362 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); 3362 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface);
3363 3363
3364 template <class Types> 3364 template <class Types>
(...skipping 14 matching lines...) Expand all
3379 gfx::PointF(), 3379 gfx::PointF(),
3380 gfx::Size(100, 300), 3380 gfx::Size(100, 300),
3381 true); 3381 true);
3382 this->CalcDrawEtc(parent); 3382 this->CalcDrawEtc(parent);
3383 { 3383 {
3384 // Make a viewport rect that is larger than the root layer. 3384 // Make a viewport rect that is larger than the root layer.
3385 TestOcclusionTrackerWithClip<typename Types::LayerType, 3385 TestOcclusionTrackerWithClip<typename Types::LayerType,
3386 typename Types::RenderSurfaceType> occlusion( 3386 typename Types::RenderSurfaceType> occlusion(
3387 gfx::Rect(0, 0, 1000, 1000)); 3387 gfx::Rect(0, 0, 1000, 1000));
3388 3388
3389 this->VisitLayer(surface, occlusion); 3389 this->VisitLayer(surface, &occlusion);
3390 3390
3391 // The root layer always has a clip rect. So the parent of |surface| has a 3391 // The root layer always has a clip rect. So the parent of |surface| has a
3392 // clip rect giving the surface itself a clip rect. 3392 // clip rect giving the surface itself a clip rect.
3393 this->EnterContributingSurface(surface, occlusion); 3393 this->EnterContributingSurface(surface, &occlusion);
3394 // Make sure the parent's clip rect clips the unoccluded region of the 3394 // Make sure the parent's clip rect clips the unoccluded region of the
3395 // child surface. 3395 // child surface.
3396 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200), 3396 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200),
3397 occlusion.UnoccludedContributingSurfaceContentRect( 3397 occlusion.UnoccludedContributingSurfaceContentRect(
3398 surface, false, gfx::Rect(0, 0, 100, 300), NULL)); 3398 surface, false, gfx::Rect(0, 0, 100, 300), NULL));
3399 } 3399 }
3400 this->ResetLayerIterator(); 3400 this->ResetLayerIterator();
3401 { 3401 {
3402 // Make a viewport rect that is smaller than the root layer. 3402 // Make a viewport rect that is smaller than the root layer.
3403 TestOcclusionTrackerWithClip<typename Types::LayerType, 3403 TestOcclusionTrackerWithClip<typename Types::LayerType,
3404 typename Types::RenderSurfaceType> occlusion( 3404 typename Types::RenderSurfaceType> occlusion(
3405 gfx::Rect(0, 0, 100, 100)); 3405 gfx::Rect(0, 0, 100, 100));
3406 3406
3407 this->VisitLayer(surface, occlusion); 3407 this->VisitLayer(surface, &occlusion);
3408 3408
3409 // The root layer always has a clip rect. So the parent of |surface| has a 3409 // The root layer always has a clip rect. So the parent of |surface| has a
3410 // clip rect giving the surface itself a clip rect. 3410 // clip rect giving the surface itself a clip rect.
3411 this->EnterContributingSurface(surface, occlusion); 3411 this->EnterContributingSurface(surface, &occlusion);
3412 // Make sure the viewport rect clips the unoccluded region of the child 3412 // Make sure the viewport rect clips the unoccluded region of the child
3413 // surface. 3413 // surface.
3414 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 3414 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
3415 occlusion.UnoccludedContributingSurfaceContentRect( 3415 occlusion.UnoccludedContributingSurfaceContentRect(
3416 surface, false, gfx::Rect(0, 0, 100, 300), NULL)); 3416 surface, false, gfx::Rect(0, 0, 100, 300), NULL));
3417 } 3417 }
3418 } 3418 }
3419 }; 3419 };
3420 3420
3421 ALL_OCCLUSIONTRACKER_TEST( 3421 ALL_OCCLUSIONTRACKER_TEST(
(...skipping 27 matching lines...) Expand all
3449 typename Types::LayerType* topmost = this->CreateDrawingLayer( 3449 typename Types::LayerType* topmost = this->CreateDrawingLayer(
3450 parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true); 3450 parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true);
3451 this->CalcDrawEtc(parent); 3451 this->CalcDrawEtc(parent);
3452 3452
3453 TestOcclusionTrackerWithClip<typename Types::LayerType, 3453 TestOcclusionTrackerWithClip<typename Types::LayerType,
3454 typename Types::RenderSurfaceType> occlusion( 3454 typename Types::RenderSurfaceType> occlusion(
3455 gfx::Rect(0, 0, 1000, 1000)); 3455 gfx::Rect(0, 0, 1000, 1000));
3456 3456
3457 // |topmost| occludes everything partially so we know occlusion is happening 3457 // |topmost| occludes everything partially so we know occlusion is happening
3458 // at all. 3458 // at all.
3459 this->VisitLayer(topmost, occlusion); 3459 this->VisitLayer(topmost, &occlusion);
3460 3460
3461 EXPECT_EQ(gfx::Rect().ToString(), 3461 EXPECT_EQ(gfx::Rect().ToString(),
3462 occlusion.occlusion_from_outside_target().ToString()); 3462 occlusion.occlusion_from_outside_target().ToString());
3463 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(), 3463 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(),
3464 occlusion.occlusion_from_inside_target().ToString()); 3464 occlusion.occlusion_from_inside_target().ToString());
3465 3465
3466 // surface_child is not opaque and does not occlude, so we have a non-empty 3466 // surface_child is not opaque and does not occlude, so we have a non-empty
3467 // unoccluded area on surface. 3467 // unoccluded area on surface.
3468 this->VisitLayer(surface_child, occlusion); 3468 this->VisitLayer(surface_child, &occlusion);
3469 3469
3470 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(), 3470 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(),
3471 occlusion.occlusion_from_outside_target().ToString()); 3471 occlusion.occlusion_from_outside_target().ToString());
3472 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(), 3472 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(),
3473 occlusion.occlusion_from_inside_target().ToString()); 3473 occlusion.occlusion_from_inside_target().ToString());
3474 3474
3475 // The root layer always has a clip rect. So the parent of |surface| has a 3475 // The root layer always has a clip rect. So the parent of |surface| has a
3476 // clip rect. However, the owning layer for |surface| does not mask to 3476 // clip rect. However, the owning layer for |surface| does not mask to
3477 // bounds, so it doesn't have a clip rect of its own. Thus the parent of 3477 // bounds, so it doesn't have a clip rect of its own. Thus the parent of
3478 // |surface_child| exercises different code paths as its parent does not 3478 // |surface_child| exercises different code paths as its parent does not
3479 // have a clip rect. 3479 // have a clip rect.
3480 3480
3481 this->EnterContributingSurface(surface_child, occlusion); 3481 this->EnterContributingSurface(surface_child, &occlusion);
3482 // The surface_child's parent does not have a clip rect as it owns a render 3482 // The surface_child's parent does not have a clip rect as it owns a render
3483 // surface. 3483 // surface.
3484 EXPECT_EQ( 3484 EXPECT_EQ(
3485 gfx::Rect(0, 50, 80, 50).ToString(), 3485 gfx::Rect(0, 50, 80, 50).ToString(),
3486 occlusion.UnoccludedContributingSurfaceContentRect( 3486 occlusion.UnoccludedContributingSurfaceContentRect(
3487 surface_child, false, gfx::Rect(0, 0, 100, 100), NULL).ToString()); 3487 surface_child, false, gfx::Rect(0, 0, 100, 100), NULL).ToString());
3488 this->LeaveContributingSurface(surface_child, occlusion); 3488 this->LeaveContributingSurface(surface_child, &occlusion);
3489 3489
3490 this->VisitLayer(surface, occlusion); 3490 this->VisitLayer(surface, &occlusion);
3491 this->EnterContributingSurface(surface, occlusion); 3491 this->EnterContributingSurface(surface, &occlusion);
3492 // The surface's parent does have a clip rect as it is the root layer. 3492 // The surface's parent does have a clip rect as it is the root layer.
3493 EXPECT_EQ(gfx::Rect(0, 50, 80, 50).ToString(), 3493 EXPECT_EQ(gfx::Rect(0, 50, 80, 50).ToString(),
3494 occlusion.UnoccludedContributingSurfaceContentRect( 3494 occlusion.UnoccludedContributingSurfaceContentRect(
3495 surface, false, gfx::Rect(0, 0, 100, 100), NULL).ToString()); 3495 surface, false, gfx::Rect(0, 0, 100, 100), NULL).ToString());
3496 } 3496 }
3497 }; 3497 };
3498 3498
3499 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfClippingSurface); 3499 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfClippingSurface);
3500 3500
3501 template <class Types> 3501 template <class Types>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 3564
3565 this->CalcDrawEtc(parent); 3565 this->CalcDrawEtc(parent);
3566 3566
3567 TestOcclusionTrackerWithClip<typename Types::LayerType, 3567 TestOcclusionTrackerWithClip<typename Types::LayerType,
3568 typename Types::RenderSurfaceType> occlusion( 3568 typename Types::RenderSurfaceType> occlusion(
3569 gfx::Rect(0, 0, 1000, 1000)); 3569 gfx::Rect(0, 0, 1000, 1000));
3570 3570
3571 // These layers occlude pixels directly beside the filtered_surface. Because 3571 // These layers occlude pixels directly beside the filtered_surface. Because
3572 // filtered surface blends pixels in a radius, it will need to see some of 3572 // filtered surface blends pixels in a radius, it will need to see some of
3573 // the pixels (up to radius far) underneath the occluding layers. 3573 // the pixels (up to radius far) underneath the occluding layers.
3574 this->VisitLayer(occluding_layer5, occlusion); 3574 this->VisitLayer(occluding_layer5, &occlusion);
3575 this->VisitLayer(occluding_layer4, occlusion); 3575 this->VisitLayer(occluding_layer4, &occlusion);
3576 this->VisitLayer(occluding_layer3, occlusion); 3576 this->VisitLayer(occluding_layer3, &occlusion);
3577 this->VisitLayer(occluding_layer2, occlusion); 3577 this->VisitLayer(occluding_layer2, &occlusion);
3578 this->VisitLayer(occluding_layer1, occlusion); 3578 this->VisitLayer(occluding_layer1, &occlusion);
3579 3579
3580 Region expected_occlusion; 3580 Region expected_occlusion;
3581 expected_occlusion.Union(gfx::Rect(0, 0, 300, 50)); 3581 expected_occlusion.Union(gfx::Rect(0, 0, 300, 50));
3582 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50)); 3582 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50));
3583 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50)); 3583 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50));
3584 expected_occlusion.Union(gfx::Rect(250, 50, 50, 50)); 3584 expected_occlusion.Union(gfx::Rect(250, 50, 50, 50));
3585 expected_occlusion.Union(gfx::Rect(0, 100, 300, 50)); 3585 expected_occlusion.Union(gfx::Rect(0, 100, 300, 50));
3586 3586
3587 EXPECT_EQ(expected_occlusion.ToString(), 3587 EXPECT_EQ(expected_occlusion.ToString(),
3588 occlusion.occlusion_from_inside_target().ToString()); 3588 occlusion.occlusion_from_inside_target().ToString());
3589 EXPECT_EQ(gfx::Rect().ToString(), 3589 EXPECT_EQ(gfx::Rect().ToString(),
3590 occlusion.occlusion_from_outside_target().ToString()); 3590 occlusion.occlusion_from_outside_target().ToString());
3591 3591
3592 this->VisitLayer(filtered_surface, occlusion); 3592 this->VisitLayer(filtered_surface, &occlusion);
3593 3593
3594 // The filtered layer/replica does not occlude. 3594 // The filtered layer/replica does not occlude.
3595 Region expected_occlusion_outside_surface; 3595 Region expected_occlusion_outside_surface;
3596 expected_occlusion_outside_surface.Union(gfx::Rect(-50, -50, 300, 50)); 3596 expected_occlusion_outside_surface.Union(gfx::Rect(-50, -50, 300, 50));
3597 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 0, 50, 50)); 3597 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 0, 50, 50));
3598 expected_occlusion_outside_surface.Union(gfx::Rect(50, 0, 100, 50)); 3598 expected_occlusion_outside_surface.Union(gfx::Rect(50, 0, 100, 50));
3599 expected_occlusion_outside_surface.Union(gfx::Rect(200, 0, 50, 50)); 3599 expected_occlusion_outside_surface.Union(gfx::Rect(200, 0, 50, 50));
3600 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 50, 300, 50)); 3600 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 50, 300, 50));
3601 3601
3602 EXPECT_EQ(expected_occlusion_outside_surface.ToString(), 3602 EXPECT_EQ(expected_occlusion_outside_surface.ToString(),
3603 occlusion.occlusion_from_outside_target().ToString()); 3603 occlusion.occlusion_from_outside_target().ToString());
3604 EXPECT_EQ(gfx::Rect().ToString(), 3604 EXPECT_EQ(gfx::Rect().ToString(),
3605 occlusion.occlusion_from_inside_target().ToString()); 3605 occlusion.occlusion_from_inside_target().ToString());
3606 3606
3607 // The surface has a background blur, so it needs pixels that are currently 3607 // The surface has a background blur, so it needs pixels that are currently
3608 // considered occluded in order to be drawn. So the pixels it needs should 3608 // considered occluded in order to be drawn. So the pixels it needs should
3609 // be removed some the occluded area so that when we get to the parent they 3609 // be removed some the occluded area so that when we get to the parent they
3610 // are drawn. 3610 // are drawn.
3611 this->VisitContributingSurface(filtered_surface, occlusion); 3611 this->VisitContributingSurface(filtered_surface, &occlusion);
3612 3612
3613 this->EnterLayer(parent, occlusion); 3613 this->EnterLayer(parent, &occlusion);
3614 3614
3615 Region expected_blurred_occlusion; 3615 Region expected_blurred_occlusion;
3616 expected_blurred_occlusion.Union(gfx::Rect(0, 0, 300, 50 - outset_top)); 3616 expected_blurred_occlusion.Union(gfx::Rect(0, 0, 300, 50 - outset_top));
3617 expected_blurred_occlusion.Union(gfx::Rect( 3617 expected_blurred_occlusion.Union(gfx::Rect(
3618 0, 50 - outset_top, 50 - outset_left, 50 + outset_top + outset_bottom)); 3618 0, 50 - outset_top, 50 - outset_left, 50 + outset_top + outset_bottom));
3619 expected_blurred_occlusion.Union( 3619 expected_blurred_occlusion.Union(
3620 gfx::Rect(100 + outset_right, 3620 gfx::Rect(100 + outset_right,
3621 50 - outset_top, 3621 50 - outset_top,
3622 100 - outset_right - outset_left, 3622 100 - outset_right - outset_left,
3623 50 + outset_top + outset_bottom)); 3623 50 + outset_top + outset_bottom));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3745 // Save the distance of influence for the blur effect. 3745 // Save the distance of influence for the blur effect.
3746 int outset_top, outset_right, outset_bottom, outset_left; 3746 int outset_top, outset_right, outset_bottom, outset_left;
3747 filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); 3747 filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left);
3748 3748
3749 this->CalcDrawEtc(root); 3749 this->CalcDrawEtc(root);
3750 3750
3751 TestOcclusionTrackerWithClip<typename Types::LayerType, 3751 TestOcclusionTrackerWithClip<typename Types::LayerType,
3752 typename Types::RenderSurfaceType> occlusion( 3752 typename Types::RenderSurfaceType> occlusion(
3753 gfx::Rect(0, 0, 1000, 1000)); 3753 gfx::Rect(0, 0, 1000, 1000));
3754 3754
3755 this->VisitLayer(occluding_layer_above, occlusion); 3755 this->VisitLayer(occluding_layer_above, &occlusion);
3756 EXPECT_EQ(gfx::Rect().ToString(), 3756 EXPECT_EQ(gfx::Rect().ToString(),
3757 occlusion.occlusion_from_outside_target().ToString()); 3757 occlusion.occlusion_from_outside_target().ToString());
3758 EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(), 3758 EXPECT_EQ(gfx::Rect(100 / 2, 100 / 2, 50 / 2, 50 / 2).ToString(),
3759 occlusion.occlusion_from_inside_target().ToString()); 3759 occlusion.occlusion_from_inside_target().ToString());
3760 3760
3761 this->VisitLayer(filtered_surface2, occlusion); 3761 this->VisitLayer(filtered_surface2, &occlusion);
3762 this->VisitContributingSurface(filtered_surface2, occlusion); 3762 this->VisitContributingSurface(filtered_surface2, &occlusion);
3763 this->VisitLayer(filtered_surface1, occlusion); 3763 this->VisitLayer(filtered_surface1, &occlusion);
3764 this->VisitContributingSurface(filtered_surface1, occlusion); 3764 this->VisitContributingSurface(filtered_surface1, &occlusion);
3765 3765
3766 // Test expectations in the target. 3766 // Test expectations in the target.
3767 gfx::Rect expected_occlusion = 3767 gfx::Rect expected_occlusion =
3768 gfx::Rect(100 / 2 + outset_right * 2, 3768 gfx::Rect(100 / 2 + outset_right * 2,
3769 100 / 2 + outset_bottom * 2, 3769 100 / 2 + outset_bottom * 2,
3770 50 / 2 - (outset_left + outset_right) * 2, 3770 50 / 2 - (outset_left + outset_right) * 2,
3771 50 / 2 - (outset_top + outset_bottom) * 2); 3771 50 / 2 - (outset_top + outset_bottom) * 2);
3772 EXPECT_EQ(expected_occlusion.ToString(), 3772 EXPECT_EQ(expected_occlusion.ToString(),
3773 occlusion.occlusion_from_inside_target().ToString()); 3773 occlusion.occlusion_from_inside_target().ToString());
3774 3774
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3853 3853
3854 this->CalcDrawEtc(parent); 3854 this->CalcDrawEtc(parent);
3855 3855
3856 TestOcclusionTrackerWithClip<typename Types::LayerType, 3856 TestOcclusionTrackerWithClip<typename Types::LayerType,
3857 typename Types::RenderSurfaceType> occlusion( 3857 typename Types::RenderSurfaceType> occlusion(
3858 gfx::Rect(0, 0, 1000, 1000)); 3858 gfx::Rect(0, 0, 1000, 1000));
3859 3859
3860 // These layers occlude pixels directly beside the filtered_surface. Because 3860 // These layers occlude pixels directly beside the filtered_surface. Because
3861 // filtered surface blends pixels in a radius, it will need to see some of 3861 // filtered surface blends pixels in a radius, it will need to see some of
3862 // the pixels (up to radius far) underneath the occluding layers. 3862 // the pixels (up to radius far) underneath the occluding layers.
3863 this->VisitLayer(occluding_layer5, occlusion); 3863 this->VisitLayer(occluding_layer5, &occlusion);
3864 this->VisitLayer(occluding_layer4, occlusion); 3864 this->VisitLayer(occluding_layer4, &occlusion);
3865 this->VisitLayer(occluding_layer3, occlusion); 3865 this->VisitLayer(occluding_layer3, &occlusion);
3866 this->VisitLayer(occluding_layer2, occlusion); 3866 this->VisitLayer(occluding_layer2, &occlusion);
3867 this->VisitLayer(occluding_layer1, occlusion); 3867 this->VisitLayer(occluding_layer1, &occlusion);
3868 3868
3869 Region expected_occlusion; 3869 Region expected_occlusion;
3870 expected_occlusion.Union(gfx::Rect(0, 0, 300, 50)); 3870 expected_occlusion.Union(gfx::Rect(0, 0, 300, 50));
3871 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50)); 3871 expected_occlusion.Union(gfx::Rect(0, 50, 50, 50));
3872 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50)); 3872 expected_occlusion.Union(gfx::Rect(100, 50, 100, 50));
3873 expected_occlusion.Union(gfx::Rect(250, 50, 50, 50)); 3873 expected_occlusion.Union(gfx::Rect(250, 50, 50, 50));
3874 expected_occlusion.Union(gfx::Rect(0, 100, 300, 50)); 3874 expected_occlusion.Union(gfx::Rect(0, 100, 300, 50));
3875 3875
3876 EXPECT_EQ(expected_occlusion.ToString(), 3876 EXPECT_EQ(expected_occlusion.ToString(),
3877 occlusion.occlusion_from_inside_target().ToString()); 3877 occlusion.occlusion_from_inside_target().ToString());
3878 EXPECT_EQ(gfx::Rect().ToString(), 3878 EXPECT_EQ(gfx::Rect().ToString(),
3879 occlusion.occlusion_from_outside_target().ToString()); 3879 occlusion.occlusion_from_outside_target().ToString());
3880 3880
3881 // Everything outside the surface/replica is occluded but the 3881 // Everything outside the surface/replica is occluded but the
3882 // surface/replica itself is not. 3882 // surface/replica itself is not.
3883 this->VisitLayer(filtered_surface, occlusion); 3883 this->VisitLayer(filtered_surface, &occlusion);
3884 3884
3885 // The filtered layer/replica does not occlude. 3885 // The filtered layer/replica does not occlude.
3886 Region expected_occlusion_outside_surface; 3886 Region expected_occlusion_outside_surface;
3887 expected_occlusion_outside_surface.Union(gfx::Rect(-50, -50, 300, 50)); 3887 expected_occlusion_outside_surface.Union(gfx::Rect(-50, -50, 300, 50));
3888 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 0, 50, 50)); 3888 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 0, 50, 50));
3889 expected_occlusion_outside_surface.Union(gfx::Rect(50, 0, 100, 50)); 3889 expected_occlusion_outside_surface.Union(gfx::Rect(50, 0, 100, 50));
3890 expected_occlusion_outside_surface.Union(gfx::Rect(200, 0, 50, 50)); 3890 expected_occlusion_outside_surface.Union(gfx::Rect(200, 0, 50, 50));
3891 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 50, 300, 50)); 3891 expected_occlusion_outside_surface.Union(gfx::Rect(-50, 50, 300, 50));
3892 3892
3893 EXPECT_EQ(expected_occlusion_outside_surface.ToString(), 3893 EXPECT_EQ(expected_occlusion_outside_surface.ToString(),
3894 occlusion.occlusion_from_outside_target().ToString()); 3894 occlusion.occlusion_from_outside_target().ToString());
3895 EXPECT_EQ(gfx::Rect().ToString(), 3895 EXPECT_EQ(gfx::Rect().ToString(),
3896 occlusion.occlusion_from_inside_target().ToString()); 3896 occlusion.occlusion_from_inside_target().ToString());
3897 3897
3898 // The surface has a background blur, so it needs pixels that are currently 3898 // The surface has a background blur, so it needs pixels that are currently
3899 // considered occluded in order to be drawn. So the pixels it needs should 3899 // considered occluded in order to be drawn. So the pixels it needs should
3900 // be removed some the occluded area so that when we get to the parent they 3900 // be removed some the occluded area so that when we get to the parent they
3901 // are drawn. 3901 // are drawn.
3902 this->VisitContributingSurface(filtered_surface, occlusion); 3902 this->VisitContributingSurface(filtered_surface, &occlusion);
3903 3903
3904 this->VisitLayer(clipping_surface, occlusion); 3904 this->VisitLayer(clipping_surface, &occlusion);
3905 this->EnterContributingSurface(clipping_surface, occlusion); 3905 this->EnterContributingSurface(clipping_surface, &occlusion);
3906 3906
3907 Region expected_blurred_occlusion; 3907 Region expected_blurred_occlusion;
3908 expected_blurred_occlusion.Union(gfx::Rect(0, 0, 300, 50 - outset_top)); 3908 expected_blurred_occlusion.Union(gfx::Rect(0, 0, 300, 50 - outset_top));
3909 expected_blurred_occlusion.Union(gfx::Rect( 3909 expected_blurred_occlusion.Union(gfx::Rect(
3910 0, 50 - outset_top, 50 - outset_left, 20 + outset_top + outset_bottom)); 3910 0, 50 - outset_top, 50 - outset_left, 20 + outset_top + outset_bottom));
3911 expected_blurred_occlusion.Union( 3911 expected_blurred_occlusion.Union(
3912 gfx::Rect(100 + outset_right, 3912 gfx::Rect(100 + outset_right,
3913 50 - outset_top, 3913 50 - outset_top,
3914 100 - outset_right - outset_left, 3914 100 - outset_right - outset_left,
3915 20 + outset_top + outset_bottom)); 3915 20 + outset_top + outset_bottom));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
4058 filtered_surface->SetBackgroundFilters(filters); 4058 filtered_surface->SetBackgroundFilters(filters);
4059 4059
4060 this->CalcDrawEtc(parent); 4060 this->CalcDrawEtc(parent);
4061 4061
4062 TestOcclusionTrackerWithClip<typename Types::LayerType, 4062 TestOcclusionTrackerWithClip<typename Types::LayerType,
4063 typename Types::RenderSurfaceType> occlusion( 4063 typename Types::RenderSurfaceType> occlusion(
4064 gfx::Rect(0, 0, 1000, 1000)); 4064 gfx::Rect(0, 0, 1000, 1000));
4065 4065
4066 // The surface has a background blur, so it blurs non-opaque pixels below 4066 // The surface has a background blur, so it blurs non-opaque pixels below
4067 // it. 4067 // it.
4068 this->VisitLayer(filtered_surface, occlusion); 4068 this->VisitLayer(filtered_surface, &occlusion);
4069 this->VisitContributingSurface(filtered_surface, occlusion); 4069 this->VisitContributingSurface(filtered_surface, &occlusion);
4070 4070
4071 this->VisitLayer(behind_replica_layer, occlusion); 4071 this->VisitLayer(behind_replica_layer, &occlusion);
4072 this->VisitLayer(behind_surface_layer, occlusion); 4072 this->VisitLayer(behind_surface_layer, &occlusion);
4073 4073
4074 // The layers behind the surface are not blurred, and their occlusion does 4074 // The layers behind the surface are not blurred, and their occlusion does
4075 // not change, until we leave the surface. So it should not be modified by 4075 // not change, until we leave the surface. So it should not be modified by
4076 // the filter here. 4076 // the filter here.
4077 gfx::Rect occlusion_behind_surface = gfx::Rect(60, 60, 30, 30); 4077 gfx::Rect occlusion_behind_surface = gfx::Rect(60, 60, 30, 30);
4078 gfx::Rect occlusion_behind_replica = gfx::Rect(210, 60, 30, 30); 4078 gfx::Rect occlusion_behind_replica = gfx::Rect(210, 60, 30, 30);
4079 4079
4080 Region expected_opaque_bounds = 4080 Region expected_opaque_bounds =
4081 UnionRegions(occlusion_behind_surface, occlusion_behind_replica); 4081 UnionRegions(occlusion_behind_surface, occlusion_behind_replica);
4082 EXPECT_EQ(expected_opaque_bounds.ToString(), 4082 EXPECT_EQ(expected_opaque_bounds.ToString(),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 WebKit::WebFilterOperations filters; 4135 WebKit::WebFilterOperations filters;
4136 filters.append(WebKit::WebFilterOperation::createBlurFilter(3.f)); 4136 filters.append(WebKit::WebFilterOperation::createBlurFilter(3.f));
4137 filtered_surface->SetBackgroundFilters(filters); 4137 filtered_surface->SetBackgroundFilters(filters);
4138 4138
4139 this->CalcDrawEtc(parent); 4139 this->CalcDrawEtc(parent);
4140 4140
4141 TestOcclusionTrackerWithClip<typename Types::LayerType, 4141 TestOcclusionTrackerWithClip<typename Types::LayerType,
4142 typename Types::RenderSurfaceType> occlusion( 4142 typename Types::RenderSurfaceType> occlusion(
4143 gfx::Rect(0, 0, 1000, 1000)); 4143 gfx::Rect(0, 0, 1000, 1000));
4144 4144
4145 this->VisitLayer(above_replica_layer, occlusion); 4145 this->VisitLayer(above_replica_layer, &occlusion);
4146 this->VisitLayer(above_surface_layer, occlusion); 4146 this->VisitLayer(above_surface_layer, &occlusion);
4147 4147
4148 this->VisitLayer(filtered_surface, occlusion); 4148 this->VisitLayer(filtered_surface, &occlusion);
4149 { 4149 {
4150 // The layers above the filtered surface occlude from outside. 4150 // The layers above the filtered surface occlude from outside.
4151 gfx::Rect occlusion_above_surface = gfx::Rect(0, 0, 50, 50); 4151 gfx::Rect occlusion_above_surface = gfx::Rect(0, 0, 50, 50);
4152 gfx::Rect occlusion_above_replica = gfx::Rect(150, 0, 50, 50); 4152 gfx::Rect occlusion_above_replica = gfx::Rect(150, 0, 50, 50);
4153 Region expected_opaque_region = 4153 Region expected_opaque_region =
4154 UnionRegions(occlusion_above_surface, occlusion_above_replica); 4154 UnionRegions(occlusion_above_surface, occlusion_above_replica);
4155 4155
4156 EXPECT_EQ(gfx::Rect().ToString(), 4156 EXPECT_EQ(gfx::Rect().ToString(),
4157 occlusion.occlusion_from_inside_target().ToString()); 4157 occlusion.occlusion_from_inside_target().ToString());
4158 EXPECT_EQ(expected_opaque_region.ToString(), 4158 EXPECT_EQ(expected_opaque_region.ToString(),
4159 occlusion.occlusion_from_outside_target().ToString()); 4159 occlusion.occlusion_from_outside_target().ToString());
4160 } 4160 }
4161 4161
4162 // The surface has a background blur, so it blurs non-opaque pixels below 4162 // The surface has a background blur, so it blurs non-opaque pixels below
4163 // it. 4163 // it.
4164 this->VisitContributingSurface(filtered_surface, occlusion); 4164 this->VisitContributingSurface(filtered_surface, &occlusion);
4165 { 4165 {
4166 // The filter is completely occluded, so it should not blur anything and 4166 // The filter is completely occluded, so it should not blur anything and
4167 // reduce any occlusion. 4167 // reduce any occlusion.
4168 gfx::Rect occlusion_above_surface = gfx::Rect(50, 50, 50, 50); 4168 gfx::Rect occlusion_above_surface = gfx::Rect(50, 50, 50, 50);
4169 gfx::Rect occlusion_above_replica = gfx::Rect(200, 50, 50, 50); 4169 gfx::Rect occlusion_above_replica = gfx::Rect(200, 50, 50, 50);
4170 Region expected_opaque_region = 4170 Region expected_opaque_region =
4171 UnionRegions(occlusion_above_surface, occlusion_above_replica); 4171 UnionRegions(occlusion_above_surface, occlusion_above_replica);
4172 4172
4173 EXPECT_EQ(expected_opaque_region.ToString(), 4173 EXPECT_EQ(expected_opaque_region.ToString(),
4174 occlusion.occlusion_from_inside_target().ToString()); 4174 occlusion.occlusion_from_inside_target().ToString());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 // Save the distance of influence for the blur effect. 4243 // Save the distance of influence for the blur effect.
4244 int outset_top, outset_right, outset_bottom, outset_left; 4244 int outset_top, outset_right, outset_bottom, outset_left;
4245 filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); 4245 filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left);
4246 4246
4247 this->CalcDrawEtc(parent); 4247 this->CalcDrawEtc(parent);
4248 4248
4249 TestOcclusionTrackerWithClip<typename Types::LayerType, 4249 TestOcclusionTrackerWithClip<typename Types::LayerType,
4250 typename Types::RenderSurfaceType> occlusion( 4250 typename Types::RenderSurfaceType> occlusion(
4251 gfx::Rect(0, 0, 1000, 1000)); 4251 gfx::Rect(0, 0, 1000, 1000));
4252 4252
4253 this->VisitLayer(beside_replica_layer, occlusion); 4253 this->VisitLayer(beside_replica_layer, &occlusion);
4254 this->VisitLayer(beside_surface_layer, occlusion); 4254 this->VisitLayer(beside_surface_layer, &occlusion);
4255 this->VisitLayer(above_replica_layer, occlusion); 4255 this->VisitLayer(above_replica_layer, &occlusion);
4256 this->VisitLayer(above_surface_layer, occlusion); 4256 this->VisitLayer(above_surface_layer, &occlusion);
4257 4257
4258 // The surface has a background blur, so it blurs non-opaque pixels below 4258 // The surface has a background blur, so it blurs non-opaque pixels below
4259 // it. 4259 // it.
4260 this->VisitLayer(filtered_surface, occlusion); 4260 this->VisitLayer(filtered_surface, &occlusion);
4261 this->VisitContributingSurface(filtered_surface, occlusion); 4261 this->VisitContributingSurface(filtered_surface, &occlusion);
4262 4262
4263 // The filter in the surface and replica are partially unoccluded. Only the 4263 // The filter in the surface and replica are partially unoccluded. Only the
4264 // unoccluded parts should reduce occlusion. This means it will push back 4264 // unoccluded parts should reduce occlusion. This means it will push back
4265 // the occlusion that touches the unoccluded part (occlusion_above___), but 4265 // the occlusion that touches the unoccluded part (occlusion_above___), but
4266 // it will not touch occlusion_beside____ since that is not beside the 4266 // it will not touch occlusion_beside____ since that is not beside the
4267 // unoccluded part of the surface, even though it is beside the occluded 4267 // unoccluded part of the surface, even though it is beside the occluded
4268 // part of the surface. 4268 // part of the surface.
4269 gfx::Rect occlusion_above_surface = 4269 gfx::Rect occlusion_above_surface =
4270 gfx::Rect(70 + outset_right, 50, 30 - outset_right, 50); 4270 gfx::Rect(70 + outset_right, 50, 30 - outset_right, 50);
4271 gfx::Rect occlusion_above_replica = 4271 gfx::Rect occlusion_above_replica =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4319 below_tracking_size, 4319 below_tracking_size,
4320 true); 4320 true);
4321 this->CalcDrawEtc(parent); 4321 this->CalcDrawEtc(parent);
4322 4322
4323 TestOcclusionTrackerWithClip<typename Types::LayerType, 4323 TestOcclusionTrackerWithClip<typename Types::LayerType,
4324 typename Types::RenderSurfaceType> occlusion( 4324 typename Types::RenderSurfaceType> occlusion(
4325 gfx::Rect(0, 0, 1000, 1000)); 4325 gfx::Rect(0, 0, 1000, 1000));
4326 occlusion.set_minimum_tracking_size(tracking_size); 4326 occlusion.set_minimum_tracking_size(tracking_size);
4327 4327
4328 // The small layer is not tracked because it is too small. 4328 // The small layer is not tracked because it is too small.
4329 this->VisitLayer(small, occlusion); 4329 this->VisitLayer(small, &occlusion);
4330 4330
4331 EXPECT_EQ(gfx::Rect().ToString(), 4331 EXPECT_EQ(gfx::Rect().ToString(),
4332 occlusion.occlusion_from_outside_target().ToString()); 4332 occlusion.occlusion_from_outside_target().ToString());
4333 EXPECT_EQ(gfx::Rect().ToString(), 4333 EXPECT_EQ(gfx::Rect().ToString(),
4334 occlusion.occlusion_from_inside_target().ToString()); 4334 occlusion.occlusion_from_inside_target().ToString());
4335 4335
4336 // The large layer is tracked as it is large enough. 4336 // The large layer is tracked as it is large enough.
4337 this->VisitLayer(large, occlusion); 4337 this->VisitLayer(large, &occlusion);
4338 4338
4339 EXPECT_EQ(gfx::Rect().ToString(), 4339 EXPECT_EQ(gfx::Rect().ToString(),
4340 occlusion.occlusion_from_outside_target().ToString()); 4340 occlusion.occlusion_from_outside_target().ToString());
4341 EXPECT_EQ(gfx::Rect(tracking_size).ToString(), 4341 EXPECT_EQ(gfx::Rect(tracking_size).ToString(),
4342 occlusion.occlusion_from_inside_target().ToString()); 4342 occlusion.occlusion_from_inside_target().ToString());
4343 } 4343 }
4344 }; 4344 };
4345 4345
4346 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize); 4346 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestMinimumTrackingSize);
4347 4347
(...skipping 18 matching lines...) Expand all
4366 gfx::PointF(), 4366 gfx::PointF(),
4367 gfx::Size(400, 400), 4367 gfx::Size(400, 400),
4368 false); 4368 false);
4369 small->SetMasksToBounds(true); 4369 small->SetMasksToBounds(true);
4370 this->CalcDrawEtc(parent); 4370 this->CalcDrawEtc(parent);
4371 4371
4372 TestOcclusionTrackerWithClip<typename Types::LayerType, 4372 TestOcclusionTrackerWithClip<typename Types::LayerType,
4373 typename Types::RenderSurfaceType> occlusion( 4373 typename Types::RenderSurfaceType> occlusion(
4374 gfx::Rect(0, 0, 100, 100)); 4374 gfx::Rect(0, 0, 100, 100));
4375 4375
4376 this->EnterLayer(large, occlusion); 4376 this->EnterLayer(large, &occlusion);
4377 4377
4378 bool has_occlusion_from_outside_target_surface = false; 4378 bool has_occlusion_from_outside_target_surface = false;
4379 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 4379 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
4380 occlusion.UnoccludedLayerContentRect( 4380 occlusion.UnoccludedLayerContentRect(
4381 large, 4381 large,
4382 gfx::Rect(0, 0, 400, 400), 4382 gfx::Rect(0, 0, 400, 400),
4383 &has_occlusion_from_outside_target_surface)); 4383 &has_occlusion_from_outside_target_surface));
4384 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4384 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4385 4385
4386 has_occlusion_from_outside_target_surface = false; 4386 has_occlusion_from_outside_target_surface = false;
4387 EXPECT_FALSE( 4387 EXPECT_FALSE(
4388 occlusion.OccludedLayer(large, 4388 occlusion.OccludedLayer(large,
4389 gfx::Rect(0, 0, 400, 400), 4389 gfx::Rect(0, 0, 400, 400),
4390 &has_occlusion_from_outside_target_surface)); 4390 &has_occlusion_from_outside_target_surface));
4391 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4391 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4392 4392
4393 this->LeaveLayer(large, occlusion); 4393 this->LeaveLayer(large, &occlusion);
4394 this->VisitLayer(small, occlusion); 4394 this->VisitLayer(small, &occlusion);
4395 4395
4396 has_occlusion_from_outside_target_surface = false; 4396 has_occlusion_from_outside_target_surface = false;
4397 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 4397 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
4398 occlusion.UnoccludedLayerContentRect( 4398 occlusion.UnoccludedLayerContentRect(
4399 small, 4399 small,
4400 gfx::Rect(0, 0, 200, 200), 4400 gfx::Rect(0, 0, 200, 200),
4401 &has_occlusion_from_outside_target_surface)); 4401 &has_occlusion_from_outside_target_surface));
4402 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4402 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4403 4403
4404 has_occlusion_from_outside_target_surface = false; 4404 has_occlusion_from_outside_target_surface = false;
4405 EXPECT_FALSE( 4405 EXPECT_FALSE(
4406 occlusion.OccludedLayer(small, 4406 occlusion.OccludedLayer(small,
4407 gfx::Rect(0, 0, 200, 200), 4407 gfx::Rect(0, 0, 200, 200),
4408 &has_occlusion_from_outside_target_surface)); 4408 &has_occlusion_from_outside_target_surface));
4409 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4409 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4410 4410
4411 this->EnterContributingSurface(small, occlusion); 4411 this->EnterContributingSurface(small, &occlusion);
4412 4412
4413 has_occlusion_from_outside_target_surface = false; 4413 has_occlusion_from_outside_target_surface = false;
4414 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 4414 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
4415 occlusion.UnoccludedContributingSurfaceContentRect( 4415 occlusion.UnoccludedContributingSurfaceContentRect(
4416 small, 4416 small,
4417 false, 4417 false,
4418 gfx::Rect(0, 0, 200, 200), 4418 gfx::Rect(0, 0, 200, 200),
4419 &has_occlusion_from_outside_target_surface)); 4419 &has_occlusion_from_outside_target_surface));
4420 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4420 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4421 } 4421 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4453 false); 4453 false);
4454 smallest->SetMasksToBounds(true); 4454 smallest->SetMasksToBounds(true);
4455 smaller->SetMasksToBounds(true); 4455 smaller->SetMasksToBounds(true);
4456 small->SetMasksToBounds(true); 4456 small->SetMasksToBounds(true);
4457 this->CalcDrawEtc(parent); 4457 this->CalcDrawEtc(parent);
4458 4458
4459 TestOcclusionTrackerWithClip<typename Types::LayerType, 4459 TestOcclusionTrackerWithClip<typename Types::LayerType,
4460 typename Types::RenderSurfaceType> occlusion( 4460 typename Types::RenderSurfaceType> occlusion(
4461 gfx::Rect(0, 0, 1000, 1000)); 4461 gfx::Rect(0, 0, 1000, 1000));
4462 4462
4463 this->EnterLayer(large, occlusion); 4463 this->EnterLayer(large, &occlusion);
4464 4464
4465 // Clipping from the smaller layer is from outside the target surface. 4465 // Clipping from the smaller layer is from outside the target surface.
4466 bool has_occlusion_from_outside_target_surface = false; 4466 bool has_occlusion_from_outside_target_surface = false;
4467 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 4467 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
4468 occlusion.UnoccludedLayerContentRect( 4468 occlusion.UnoccludedLayerContentRect(
4469 large, 4469 large,
4470 gfx::Rect(0, 0, 400, 400), 4470 gfx::Rect(0, 0, 400, 400),
4471 &has_occlusion_from_outside_target_surface)); 4471 &has_occlusion_from_outside_target_surface));
4472 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4472 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4473 4473
4474 has_occlusion_from_outside_target_surface = false; 4474 has_occlusion_from_outside_target_surface = false;
4475 EXPECT_FALSE( 4475 EXPECT_FALSE(
4476 occlusion.OccludedLayer(large, 4476 occlusion.OccludedLayer(large,
4477 gfx::Rect(0, 0, 400, 400), 4477 gfx::Rect(0, 0, 400, 400),
4478 &has_occlusion_from_outside_target_surface)); 4478 &has_occlusion_from_outside_target_surface));
4479 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4479 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4480 4480
4481 this->LeaveLayer(large, occlusion); 4481 this->LeaveLayer(large, &occlusion);
4482 this->VisitLayer(small, occlusion); 4482 this->VisitLayer(small, &occlusion);
4483 4483
4484 // Clipping from the smaller layer is from outside the target surface. 4484 // Clipping from the smaller layer is from outside the target surface.
4485 has_occlusion_from_outside_target_surface = false; 4485 has_occlusion_from_outside_target_surface = false;
4486 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 4486 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
4487 occlusion.UnoccludedLayerContentRect( 4487 occlusion.UnoccludedLayerContentRect(
4488 small, 4488 small,
4489 gfx::Rect(0, 0, 200, 200), 4489 gfx::Rect(0, 0, 200, 200),
4490 &has_occlusion_from_outside_target_surface)); 4490 &has_occlusion_from_outside_target_surface));
4491 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4491 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4492 4492
4493 has_occlusion_from_outside_target_surface = false; 4493 has_occlusion_from_outside_target_surface = false;
4494 EXPECT_FALSE( 4494 EXPECT_FALSE(
4495 occlusion.OccludedLayer(small, 4495 occlusion.OccludedLayer(small,
4496 gfx::Rect(0, 0, 200, 200), 4496 gfx::Rect(0, 0, 200, 200),
4497 &has_occlusion_from_outside_target_surface)); 4497 &has_occlusion_from_outside_target_surface));
4498 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4498 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4499 4499
4500 this->EnterContributingSurface(small, occlusion); 4500 this->EnterContributingSurface(small, &occlusion);
4501 4501
4502 // The |small| surface is clipped from outside its target by |smallest|. 4502 // The |small| surface is clipped from outside its target by |smallest|.
4503 has_occlusion_from_outside_target_surface = false; 4503 has_occlusion_from_outside_target_surface = false;
4504 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), 4504 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50),
4505 occlusion.UnoccludedContributingSurfaceContentRect( 4505 occlusion.UnoccludedContributingSurfaceContentRect(
4506 small, 4506 small,
4507 false, 4507 false,
4508 gfx::Rect(0, 0, 200, 200), 4508 gfx::Rect(0, 0, 200, 200),
4509 &has_occlusion_from_outside_target_surface)); 4509 &has_occlusion_from_outside_target_surface));
4510 EXPECT_TRUE(has_occlusion_from_outside_target_surface); 4510 EXPECT_TRUE(has_occlusion_from_outside_target_surface);
4511 4511
4512 this->LeaveContributingSurface(small, occlusion); 4512 this->LeaveContributingSurface(small, &occlusion);
4513 this->VisitLayer(smaller, occlusion); 4513 this->VisitLayer(smaller, &occlusion);
4514 this->EnterContributingSurface(smaller, occlusion); 4514 this->EnterContributingSurface(smaller, &occlusion);
4515 4515
4516 // The |smaller| surface is clipped from inside its target by |smallest|. 4516 // The |smaller| surface is clipped from inside its target by |smallest|.
4517 has_occlusion_from_outside_target_surface = false; 4517 has_occlusion_from_outside_target_surface = false;
4518 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), 4518 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50),
4519 occlusion.UnoccludedContributingSurfaceContentRect( 4519 occlusion.UnoccludedContributingSurfaceContentRect(
4520 smaller, 4520 smaller,
4521 false, 4521 false,
4522 gfx::Rect(0, 0, 100, 100), 4522 gfx::Rect(0, 0, 100, 100),
4523 &has_occlusion_from_outside_target_surface)); 4523 &has_occlusion_from_outside_target_surface));
4524 EXPECT_FALSE(has_occlusion_from_outside_target_surface); 4524 EXPECT_FALSE(has_occlusion_from_outside_target_surface);
4525 } 4525 }
4526 }; 4526 };
4527 4527
4528 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipIsExternalOcclusion) 4528 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestLayerClipIsExternalOcclusion)
4529 4529
4530 } // namespace 4530 } // namespace
4531 } // namespace cc 4531 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/quad_culler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698