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

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

Issue 205443002: Do not clip inside OcclusionTracker: Contributing Surfaces Edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: occlusion-surface: Created 6 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
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/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 // Gives an unoccluded sub-rect of |content_rect| in the content space of the 88 // Gives an unoccluded sub-rect of |content_rect| in the content space of the
89 // layer. Simple wrapper around UnoccludedContentRect. 89 // layer. Simple wrapper around UnoccludedContentRect.
90 gfx::Rect UnoccludedLayerContentRect(const LayerType* layer, 90 gfx::Rect UnoccludedLayerContentRect(const LayerType* layer,
91 const gfx::Rect& content_rect) const { 91 const gfx::Rect& content_rect) const {
92 DCHECK(layer->visible_content_rect().Contains(content_rect)); 92 DCHECK(layer->visible_content_rect().Contains(content_rect));
93 return this->UnoccludedContentRect( 93 return this->UnoccludedContentRect(
94 layer->render_target(), content_rect, layer->draw_transform()); 94 layer->render_target(), content_rect, layer->draw_transform());
95 } 95 }
96
97 gfx::Rect UnoccludedSurfaceContentRect(const LayerType* layer,
98 bool for_replica,
99 const gfx::Rect& content_rect) const {
100 typename LayerType::RenderSurfaceType* surface = layer->render_surface();
101 gfx::Transform draw_transform = for_replica
102 ? surface->replica_draw_transform()
103 : surface->draw_transform();
104 return this->UnoccludedContributingSurfaceContentRect(
105 layer, content_rect, draw_transform);
106 }
96 }; 107 };
97 108
98 struct OcclusionTrackerTestMainThreadTypes { 109 struct OcclusionTrackerTestMainThreadTypes {
99 typedef Layer LayerType; 110 typedef Layer LayerType;
100 typedef FakeLayerTreeHost HostType; 111 typedef FakeLayerTreeHost HostType;
101 typedef RenderSurface RenderSurfaceType; 112 typedef RenderSurface RenderSurfaceType;
102 typedef TestContentLayer ContentLayerType; 113 typedef TestContentLayer ContentLayerType;
103 typedef scoped_refptr<Layer> LayerPtrType; 114 typedef scoped_refptr<Layer> LayerPtrType;
104 typedef scoped_refptr<ContentLayerType> ContentLayerPtrType; 115 typedef scoped_refptr<ContentLayerType> ContentLayerPtrType;
105 typedef LayerIterator<Layer> TestLayerIterator; 116 typedef LayerIterator<Layer> TestLayerIterator;
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 this->VisitLayer(layer2, &occlusion); 1329 this->VisitLayer(layer2, &occlusion);
1319 this->EnterContributingSurface(child2, &occlusion); 1330 this->EnterContributingSurface(child2, &occlusion);
1320 1331
1321 EXPECT_EQ(gfx::Rect().ToString(), 1332 EXPECT_EQ(gfx::Rect().ToString(),
1322 occlusion.occlusion_from_outside_target().ToString()); 1333 occlusion.occlusion_from_outside_target().ToString());
1323 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), 1334 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(),
1324 occlusion.occlusion_from_inside_target().ToString()); 1335 occlusion.occlusion_from_inside_target().ToString());
1325 1336
1326 // There is nothing above child2's surface in the z-order. 1337 // There is nothing above child2's surface in the z-order.
1327 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), 1338 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80),
1328 occlusion.UnoccludedContributingSurfaceContentRect( 1339 occlusion.UnoccludedSurfaceContentRect(
1329 child2, false, gfx::Rect(-10, 420, 70, 80))); 1340 child2, false, gfx::Rect(-10, 420, 70, 80)));
1330 1341
1331 this->LeaveContributingSurface(child2, &occlusion); 1342 this->LeaveContributingSurface(child2, &occlusion);
1332 this->VisitLayer(layer1, &occlusion); 1343 this->VisitLayer(layer1, &occlusion);
1333 this->EnterContributingSurface(child1, &occlusion); 1344 this->EnterContributingSurface(child1, &occlusion);
1334 1345
1335 EXPECT_EQ(gfx::Rect(0, 430, 70, 80).ToString(), 1346 EXPECT_EQ(gfx::Rect(0, 430, 70, 80).ToString(),
1336 occlusion.occlusion_from_outside_target().ToString()); 1347 occlusion.occlusion_from_outside_target().ToString());
1337 EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(), 1348 EXPECT_EQ(gfx::Rect(-10, 430, 80, 70).ToString(),
1338 occlusion.occlusion_from_inside_target().ToString()); 1349 occlusion.occlusion_from_inside_target().ToString());
1339 1350
1340 // child2's contents will occlude child1 below it. 1351 // child2's contents will occlude child1 below it.
1341 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70), 1352 EXPECT_RECT_EQ(gfx::Rect(-10, 430, 10, 70),
1342 occlusion.UnoccludedContributingSurfaceContentRect( 1353 occlusion.UnoccludedSurfaceContentRect(
1343 child1, false, gfx::Rect(-10, 430, 80, 70))); 1354 child1, false, gfx::Rect(-10, 430, 80, 70)));
1344 1355
1345 this->LeaveContributingSurface(child1, &occlusion); 1356 this->LeaveContributingSurface(child1, &occlusion);
1346 this->EnterLayer(parent, &occlusion); 1357 this->EnterLayer(parent, &occlusion);
1347 1358
1348 EXPECT_EQ(gfx::Rect().ToString(), 1359 EXPECT_EQ(gfx::Rect().ToString(),
1349 occlusion.occlusion_from_outside_target().ToString()); 1360 occlusion.occlusion_from_outside_target().ToString());
1350 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70)) 1361 EXPECT_EQ(UnionRegions(gfx::Rect(30, 20, 70, 10), gfx::Rect(20, 30, 80, 70))
1351 .ToString(), 1362 .ToString(),
1352 occlusion.occlusion_from_inside_target().ToString()); 1363 occlusion.occlusion_from_inside_target().ToString());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 EXPECT_EQ(gfx::Rect().ToString(), 1452 EXPECT_EQ(gfx::Rect().ToString(),
1442 occlusion.occlusion_from_outside_target().ToString()); 1453 occlusion.occlusion_from_outside_target().ToString());
1443 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(), 1454 EXPECT_EQ(gfx::Rect(-10, 420, 70, 80).ToString(),
1444 occlusion.occlusion_from_inside_target().ToString()); 1455 occlusion.occlusion_from_inside_target().ToString());
1445 1456
1446 this->LeaveLayer(child2, &occlusion); 1457 this->LeaveLayer(child2, &occlusion);
1447 this->EnterContributingSurface(child2, &occlusion); 1458 this->EnterContributingSurface(child2, &occlusion);
1448 1459
1449 // There is nothing above child2's surface in the z-order. 1460 // There is nothing above child2's surface in the z-order.
1450 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80), 1461 EXPECT_RECT_EQ(gfx::Rect(-10, 420, 70, 80),
1451 occlusion.UnoccludedContributingSurfaceContentRect( 1462 occlusion.UnoccludedSurfaceContentRect(
1452 child2, false, gfx::Rect(-10, 420, 70, 80))); 1463 child2, false, gfx::Rect(-10, 420, 70, 80)));
1453 1464
1454 this->LeaveContributingSurface(child2, &occlusion); 1465 this->LeaveContributingSurface(child2, &occlusion);
1455 this->VisitLayer(layer1, &occlusion); 1466 this->VisitLayer(layer1, &occlusion);
1456 this->EnterContributingSurface(child1, &occlusion); 1467 this->EnterContributingSurface(child1, &occlusion);
1457 1468
1458 EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(), 1469 EXPECT_EQ(gfx::Rect(420, -10, 70, 80).ToString(),
1459 occlusion.occlusion_from_outside_target().ToString()); 1470 occlusion.occlusion_from_outside_target().ToString());
1460 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(), 1471 EXPECT_EQ(gfx::Rect(420, -20, 80, 90).ToString(),
1461 occlusion.occlusion_from_inside_target().ToString()); 1472 occlusion.occlusion_from_inside_target().ToString());
1462 1473
1463 // child2's contents will occlude child1 below it. 1474 // child2's contents will occlude child1 below it.
1464 EXPECT_RECT_EQ(gfx::Rect(420, -20, 80, 90), 1475 EXPECT_EQ(gfx::Rect(20, 30, 80, 70).ToString(),
1465 occlusion.UnoccludedContributingSurfaceContentRect( 1476 occlusion.occlusion_on_contributing_surface_from_inside_target()
1466 child1, false, gfx::Rect(420, -20, 80, 90))); 1477 .ToString());
1467 EXPECT_RECT_EQ(gfx::Rect(490, -10, 10, 80), 1478 EXPECT_EQ(gfx::Rect().ToString(),
1468 occlusion.UnoccludedContributingSurfaceContentRect( 1479 occlusion.occlusion_on_contributing_surface_from_outside_target()
1469 child1, false, gfx::Rect(420, -10, 80, 90))); 1480 .ToString());
1470 EXPECT_RECT_EQ(gfx::Rect(420, -20, 70, 10),
1471 occlusion.UnoccludedContributingSurfaceContentRect(
1472 child1, false, gfx::Rect(420, -20, 70, 90)));
1473 1481
1474 this->LeaveContributingSurface(child1, &occlusion); 1482 this->LeaveContributingSurface(child1, &occlusion);
1475 this->EnterLayer(parent, &occlusion); 1483 this->EnterLayer(parent, &occlusion);
1476 1484
1477 EXPECT_EQ(gfx::Rect().ToString(), 1485 EXPECT_EQ(gfx::Rect().ToString(),
1478 occlusion.occlusion_from_outside_target().ToString()); 1486 occlusion.occlusion_from_outside_target().ToString());
1479 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(), 1487 EXPECT_EQ(gfx::Rect(10, 20, 90, 80).ToString(),
1480 occlusion.occlusion_from_inside_target().ToString()); 1488 occlusion.occlusion_from_inside_target().ToString());
1481 1489
1482 /* Justification for the above occlusion: 1490 /* Justification for the above occlusion:
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
2205 surface, gfx::Rect(0, 0, 300, 300))); 2213 surface, gfx::Rect(0, 0, 300, 300)));
2206 this->LeaveLayer(surface, &occlusion); 2214 this->LeaveLayer(surface, &occlusion);
2207 2215
2208 this->EnterContributingSurface(surface, &occlusion); 2216 this->EnterContributingSurface(surface, &occlusion);
2209 // Occlusion within the surface is lost when leaving the animating surface. 2217 // Occlusion within the surface is lost when leaving the animating surface.
2210 EXPECT_EQ(gfx::Rect().ToString(), 2218 EXPECT_EQ(gfx::Rect().ToString(),
2211 occlusion.occlusion_from_inside_target().ToString()); 2219 occlusion.occlusion_from_inside_target().ToString());
2212 EXPECT_EQ(gfx::Rect().ToString(), 2220 EXPECT_EQ(gfx::Rect().ToString(),
2213 occlusion.occlusion_from_outside_target().ToString()); 2221 occlusion.occlusion_from_outside_target().ToString());
2214 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), 2222 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300),
2215 occlusion.UnoccludedContributingSurfaceContentRect( 2223 occlusion.UnoccludedSurfaceContentRect(
2216 surface, false, gfx::Rect(0, 0, 300, 300))); 2224 surface, false, gfx::Rect(0, 0, 300, 300)));
2217 this->LeaveContributingSurface(surface, &occlusion); 2225 this->LeaveContributingSurface(surface, &occlusion);
2218 2226
2219 // Occlusion from outside the animating surface still exists. 2227 // Occlusion from outside the animating surface still exists.
2220 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2228 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2221 occlusion.occlusion_from_inside_target().ToString()); 2229 occlusion.occlusion_from_inside_target().ToString());
2222 EXPECT_EQ(gfx::Rect().ToString(), 2230 EXPECT_EQ(gfx::Rect().ToString(),
2223 occlusion.occlusion_from_outside_target().ToString()); 2231 occlusion.occlusion_from_outside_target().ToString());
2224 2232
2225 this->VisitLayer(layer, &occlusion); 2233 this->VisitLayer(layer, &occlusion);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 surface, gfx::Rect(0, 0, 300, 300))); 2333 surface, gfx::Rect(0, 0, 300, 300)));
2326 this->LeaveLayer(surface, &occlusion); 2334 this->LeaveLayer(surface, &occlusion);
2327 2335
2328 this->EnterContributingSurface(surface, &occlusion); 2336 this->EnterContributingSurface(surface, &occlusion);
2329 // Occlusion within the surface is lost when leaving the animating surface. 2337 // Occlusion within the surface is lost when leaving the animating surface.
2330 EXPECT_EQ(gfx::Rect().ToString(), 2338 EXPECT_EQ(gfx::Rect().ToString(),
2331 occlusion.occlusion_from_inside_target().ToString()); 2339 occlusion.occlusion_from_inside_target().ToString());
2332 EXPECT_EQ(gfx::Rect().ToString(), 2340 EXPECT_EQ(gfx::Rect().ToString(),
2333 occlusion.occlusion_from_outside_target().ToString()); 2341 occlusion.occlusion_from_outside_target().ToString());
2334 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300), 2342 EXPECT_RECT_EQ(gfx::Rect(0, 0, 250, 300),
2335 occlusion.UnoccludedContributingSurfaceContentRect( 2343 occlusion.UnoccludedSurfaceContentRect(
2336 surface, false, gfx::Rect(0, 0, 300, 300))); 2344 surface, false, gfx::Rect(0, 0, 300, 300)));
2337 this->LeaveContributingSurface(surface, &occlusion); 2345 this->LeaveContributingSurface(surface, &occlusion);
2338 2346
2339 // Occlusion from outside the animating surface still exists. 2347 // Occlusion from outside the animating surface still exists.
2340 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(), 2348 EXPECT_EQ(gfx::Rect(250, 0, 50, 300).ToString(),
2341 occlusion.occlusion_from_inside_target().ToString()); 2349 occlusion.occlusion_from_inside_target().ToString());
2342 EXPECT_EQ(gfx::Rect().ToString(), 2350 EXPECT_EQ(gfx::Rect().ToString(),
2343 occlusion.occlusion_from_outside_target().ToString()); 2351 occlusion.occlusion_from_outside_target().ToString());
2344 2352
2345 this->VisitLayer(layer, &occlusion); 2353 this->VisitLayer(layer, &occlusion);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 // Render target with replica ignores occlusion from outside. 2625 // Render target with replica ignores occlusion from outside.
2618 EXPECT_EQ(gfx::Rect().ToString(), 2626 EXPECT_EQ(gfx::Rect().ToString(),
2619 occlusion.occlusion_from_outside_target().ToString()); 2627 occlusion.occlusion_from_outside_target().ToString());
2620 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 2628 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
2621 occlusion.occlusion_from_inside_target().ToString()); 2629 occlusion.occlusion_from_inside_target().ToString());
2622 2630
2623 this->EnterContributingSurface(surface, &occlusion); 2631 this->EnterContributingSurface(surface, &occlusion);
2624 2632
2625 // Surface is not occluded so it shouldn't think it is. 2633 // Surface is not occluded so it shouldn't think it is.
2626 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100), 2634 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
2627 occlusion.UnoccludedContributingSurfaceContentRect( 2635 occlusion.UnoccludedSurfaceContentRect(
2628 surface, false, gfx::Rect(0, 0, 100, 100))); 2636 surface, false, gfx::Rect(0, 0, 100, 100)));
2629 } 2637 }
2630 }; 2638 };
2631 2639
2632 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded); 2640 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestReplicaOccluded);
2633 2641
2634 template <class Types> 2642 template <class Types>
2635 class OcclusionTrackerTestSurfaceWithReplicaUnoccluded 2643 class OcclusionTrackerTestSurfaceWithReplicaUnoccluded
2636 : public OcclusionTrackerTest<Types> { 2644 : public OcclusionTrackerTest<Types> {
2637 protected: 2645 protected:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 // Render target with replica ignores occlusion from outside. 2682 // Render target with replica ignores occlusion from outside.
2675 EXPECT_EQ(gfx::Rect().ToString(), 2683 EXPECT_EQ(gfx::Rect().ToString(),
2676 occlusion.occlusion_from_outside_target().ToString()); 2684 occlusion.occlusion_from_outside_target().ToString());
2677 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 2685 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
2678 occlusion.occlusion_from_inside_target().ToString()); 2686 occlusion.occlusion_from_inside_target().ToString());
2679 2687
2680 this->EnterContributingSurface(surface, &occlusion); 2688 this->EnterContributingSurface(surface, &occlusion);
2681 2689
2682 // Surface is occluded, but only the top 10px of the replica. 2690 // Surface is occluded, but only the top 10px of the replica.
2683 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), 2691 EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0),
2684 occlusion.UnoccludedContributingSurfaceContentRect( 2692 occlusion.UnoccludedSurfaceContentRect(
2685 surface, false, gfx::Rect(0, 0, 100, 100))); 2693 surface, false, gfx::Rect(0, 0, 100, 100)));
2686 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90), 2694 EXPECT_RECT_EQ(gfx::Rect(0, 10, 100, 90),
2687 occlusion.UnoccludedContributingSurfaceContentRect( 2695 occlusion.UnoccludedSurfaceContentRect(
2688 surface, true, gfx::Rect(0, 0, 100, 100))); 2696 surface, true, gfx::Rect(0, 0, 100, 100)));
2689 } 2697 }
2690 }; 2698 };
2691 2699
2692 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded); 2700 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceWithReplicaUnoccluded);
2693 2701
2694 template <class Types> 2702 template <class Types>
2695 class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently 2703 class OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently
2696 : public OcclusionTrackerTest<Types> { 2704 : public OcclusionTrackerTest<Types> {
2697 protected: 2705 protected:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 // Render target with replica ignores occlusion from outside. 2748 // Render target with replica ignores occlusion from outside.
2741 EXPECT_EQ(gfx::Rect().ToString(), 2749 EXPECT_EQ(gfx::Rect().ToString(),
2742 occlusion.occlusion_from_outside_target().ToString()); 2750 occlusion.occlusion_from_outside_target().ToString());
2743 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), 2751 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
2744 occlusion.occlusion_from_inside_target().ToString()); 2752 occlusion.occlusion_from_inside_target().ToString());
2745 2753
2746 this->EnterContributingSurface(surface, &occlusion); 2754 this->EnterContributingSurface(surface, &occlusion);
2747 2755
2748 // Surface and replica are occluded different amounts. 2756 // Surface and replica are occluded different amounts.
2749 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100), 2757 EXPECT_RECT_EQ(gfx::Rect(40, 0, 60, 100),
2750 occlusion.UnoccludedContributingSurfaceContentRect( 2758 occlusion.UnoccludedSurfaceContentRect(
2751 surface, false, gfx::Rect(0, 0, 100, 100))); 2759 surface, false, gfx::Rect(0, 0, 100, 100)));
2752 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100), 2760 EXPECT_RECT_EQ(gfx::Rect(50, 0, 50, 100),
2753 occlusion.UnoccludedContributingSurfaceContentRect( 2761 occlusion.UnoccludedSurfaceContentRect(
2754 surface, true, gfx::Rect(0, 0, 100, 100))); 2762 surface, true, gfx::Rect(0, 0, 100, 100)));
2755 } 2763 }
2756 }; 2764 };
2757 2765
2758 ALL_OCCLUSIONTRACKER_TEST( 2766 ALL_OCCLUSIONTRACKER_TEST(
2759 OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently); 2767 OcclusionTrackerTestSurfaceAndReplicaOccludedDifferently);
2760 2768
2761 template <class Types> 2769 template <class Types>
2762 class OcclusionTrackerTestSurfaceChildOfSurface 2770 class OcclusionTrackerTestSurfaceChildOfSurface
2763 : public OcclusionTrackerTest<Types> { 2771 : public OcclusionTrackerTest<Types> {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 // clip rect. However, the owning layer for |surface| does not mask to 2819 // clip rect. However, the owning layer for |surface| does not mask to
2812 // bounds, so it doesn't have a clip rect of its own. Thus the parent of 2820 // bounds, so it doesn't have a clip rect of its own. Thus the parent of
2813 // |surface_child| exercises different code paths as its parent does not 2821 // |surface_child| exercises different code paths as its parent does not
2814 // have a clip rect. 2822 // have a clip rect.
2815 2823
2816 this->EnterContributingSurface(surface_child, &occlusion); 2824 this->EnterContributingSurface(surface_child, &occlusion);
2817 // The surface_child's parent does not have a clip rect as it owns a render 2825 // The surface_child's parent does not have a clip rect as it owns a render
2818 // surface. Make sure the unoccluded rect does not get clipped away 2826 // surface. Make sure the unoccluded rect does not get clipped away
2819 // inappropriately. 2827 // inappropriately.
2820 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10), 2828 EXPECT_RECT_EQ(gfx::Rect(0, 40, 100, 10),
2821 occlusion.UnoccludedContributingSurfaceContentRect( 2829 occlusion.UnoccludedSurfaceContentRect(
2822 surface_child, false, gfx::Rect(0, 0, 100, 50))); 2830 surface_child, false, gfx::Rect(0, 0, 100, 50)));
2823 this->LeaveContributingSurface(surface_child, &occlusion); 2831 this->LeaveContributingSurface(surface_child, &occlusion);
2824 2832
2825 // When the surface_child's occlusion is transformed up to its parent, make 2833 // When the surface_child's occlusion is transformed up to its parent, make
2826 // sure it is not clipped away inappropriately also. 2834 // sure it is not clipped away inappropriately also.
2827 this->EnterLayer(surface, &occlusion); 2835 this->EnterLayer(surface, &occlusion);
2828 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(), 2836 EXPECT_EQ(gfx::Rect(0, 0, 100, 50).ToString(),
2829 occlusion.occlusion_from_outside_target().ToString()); 2837 occlusion.occlusion_from_outside_target().ToString());
2830 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(), 2838 EXPECT_EQ(gfx::Rect(0, 10, 100, 50).ToString(),
2831 occlusion.occlusion_from_inside_target().ToString()); 2839 occlusion.occlusion_from_inside_target().ToString());
2832 this->LeaveLayer(surface, &occlusion); 2840 this->LeaveLayer(surface, &occlusion);
2833 2841
2834 this->EnterContributingSurface(surface, &occlusion); 2842 this->EnterContributingSurface(surface, &occlusion);
2835 // The surface's parent does have a clip rect as it is the root layer. 2843 // The surface's parent does have a clip rect as it is the root layer.
2836 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50), 2844 EXPECT_RECT_EQ(gfx::Rect(0, 50, 100, 50),
2837 occlusion.UnoccludedContributingSurfaceContentRect( 2845 occlusion.UnoccludedSurfaceContentRect(
2838 surface, false, gfx::Rect(0, 0, 100, 100))); 2846 surface, false, gfx::Rect(0, 0, 100, 100)));
2839 } 2847 }
2840 }; 2848 };
2841 2849
2842 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface); 2850 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfSurface);
2843 2851
2844 template <class Types> 2852 template <class Types>
2845 class OcclusionTrackerTestTopmostSurfaceIsClippedToViewport
2846 : public OcclusionTrackerTest<Types> {
2847 protected:
2848 explicit OcclusionTrackerTestTopmostSurfaceIsClippedToViewport(
2849 bool opaque_layers)
2850 : OcclusionTrackerTest<Types>(opaque_layers) {}
2851 void RunMyTest() {
2852 // This test verifies that the top-most surface is considered occluded
2853 // outside of its target's clip rect and outside the viewport rect.
2854
2855 typename Types::ContentLayerType* parent = this->CreateRoot(
2856 this->identity_matrix, gfx::PointF(), gfx::Size(100, 200));
2857 typename Types::LayerType* surface =
2858 this->CreateDrawingSurface(parent,
2859 this->identity_matrix,
2860 gfx::PointF(),
2861 gfx::Size(100, 300),
2862 true);
2863 this->CalcDrawEtc(parent);
2864 {
2865 // Make a viewport rect that is larger than the root layer.
2866 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
2867 gfx::Rect(0, 0, 1000, 1000));
2868
2869 this->VisitLayer(surface, &occlusion);
2870
2871 // The root layer always has a clip rect. So the parent of |surface| has a
2872 // clip rect giving the surface itself a clip rect.
2873 this->EnterContributingSurface(surface, &occlusion);
2874 // Make sure the parent's clip rect clips the unoccluded region of the
2875 // child surface.
2876 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 200),
2877 occlusion.UnoccludedContributingSurfaceContentRect(
2878 surface, false, gfx::Rect(0, 0, 100, 300)));
2879 }
2880 this->ResetLayerIterator();
2881 {
2882 // Make a viewport rect that is smaller than the root layer.
2883 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
2884 gfx::Rect(0, 0, 100, 100));
2885
2886 this->VisitLayer(surface, &occlusion);
2887
2888 // The root layer always has a clip rect. So the parent of |surface| has a
2889 // clip rect giving the surface itself a clip rect.
2890 this->EnterContributingSurface(surface, &occlusion);
2891 // Make sure the viewport rect clips the unoccluded region of the child
2892 // surface.
2893 EXPECT_RECT_EQ(gfx::Rect(0, 0, 100, 100),
2894 occlusion.UnoccludedContributingSurfaceContentRect(
2895 surface, false, gfx::Rect(0, 0, 100, 300)));
2896 }
2897 }
2898 };
2899
2900 ALL_OCCLUSIONTRACKER_TEST(
2901 OcclusionTrackerTestTopmostSurfaceIsClippedToViewport);
2902
2903 template <class Types>
2904 class OcclusionTrackerTestSurfaceChildOfClippingSurface
2905 : public OcclusionTrackerTest<Types> {
2906 protected:
2907 explicit OcclusionTrackerTestSurfaceChildOfClippingSurface(bool opaque_layers)
2908 : OcclusionTrackerTest<Types>(opaque_layers) {}
2909 void RunMyTest() {
2910 // This test verifies that the surface cliprect does not end up empty and
2911 // clip away the entire unoccluded rect.
2912
2913 typename Types::ContentLayerType* parent = this->CreateRoot(
2914 this->identity_matrix, gfx::PointF(), gfx::Size(80, 200));
2915 parent->SetMasksToBounds(true);
2916 typename Types::LayerType* surface =
2917 this->CreateDrawingSurface(parent,
2918 this->identity_matrix,
2919 gfx::PointF(),
2920 gfx::Size(100, 100),
2921 true);
2922 typename Types::LayerType* surface_child =
2923 this->CreateDrawingSurface(surface,
2924 this->identity_matrix,
2925 gfx::PointF(),
2926 gfx::Size(100, 100),
2927 false);
2928 typename Types::LayerType* topmost = this->CreateDrawingLayer(
2929 parent, this->identity_matrix, gfx::PointF(), gfx::Size(100, 50), true);
2930 this->CalcDrawEtc(parent);
2931
2932 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
2933 gfx::Rect(0, 0, 1000, 1000));
2934
2935 // |topmost| occludes everything partially so we know occlusion is happening
2936 // at all.
2937 this->VisitLayer(topmost, &occlusion);
2938
2939 EXPECT_EQ(gfx::Rect().ToString(),
2940 occlusion.occlusion_from_outside_target().ToString());
2941 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(),
2942 occlusion.occlusion_from_inside_target().ToString());
2943
2944 // surface_child is not opaque and does not occlude, so we have a non-empty
2945 // unoccluded area on surface.
2946 this->VisitLayer(surface_child, &occlusion);
2947
2948 EXPECT_EQ(gfx::Rect(0, 0, 80, 50).ToString(),
2949 occlusion.occlusion_from_outside_target().ToString());
2950 EXPECT_EQ(gfx::Rect(0, 0, 0, 0).ToString(),
2951 occlusion.occlusion_from_inside_target().ToString());
2952
2953 // The root layer always has a clip rect. So the parent of |surface| has a
2954 // clip rect. However, the owning layer for |surface| does not mask to
2955 // bounds, so it doesn't have a clip rect of its own. Thus the parent of
2956 // |surface_child| exercises different code paths as its parent does not
2957 // have a clip rect.
2958
2959 this->EnterContributingSurface(surface_child, &occlusion);
2960 // The surface_child's parent does not have a clip rect as it owns a render
2961 // surface.
2962 EXPECT_EQ(
2963 gfx::Rect(0, 50, 80, 50).ToString(),
2964 occlusion.UnoccludedContributingSurfaceContentRect(
2965 surface_child, false, gfx::Rect(0, 0, 100, 100)).ToString());
2966 this->LeaveContributingSurface(surface_child, &occlusion);
2967
2968 this->VisitLayer(surface, &occlusion);
2969 this->EnterContributingSurface(surface, &occlusion);
2970 // The surface's parent does have a clip rect as it is the root layer.
2971 EXPECT_EQ(gfx::Rect(0, 50, 80, 50).ToString(),
2972 occlusion.UnoccludedContributingSurfaceContentRect(
2973 surface, false, gfx::Rect(0, 0, 100, 100)).ToString());
2974 }
2975 };
2976
2977 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestSurfaceChildOfClippingSurface);
2978
2979 template <class Types>
2980 class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter 2853 class OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter
2981 : public OcclusionTrackerTest<Types> { 2854 : public OcclusionTrackerTest<Types> {
2982 protected: 2855 protected:
2983 explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter( 2856 explicit OcclusionTrackerTestDontOccludePixelsNeededForBackgroundFilter(
2984 bool opaque_layers) 2857 bool opaque_layers)
2985 : OcclusionTrackerTest<Types>(opaque_layers) {} 2858 : OcclusionTrackerTest<Types>(opaque_layers) {}
2986 void RunMyTest() { 2859 void RunMyTest() {
2987 gfx::Transform scale_by_half; 2860 gfx::Transform scale_by_half;
2988 scale_by_half.Scale(0.5, 0.5); 2861 scale_by_half.Scale(0.5, 0.5);
2989 2862
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 occlusion.occlusion_from_outside_target().ToString()); 3591 occlusion.occlusion_from_outside_target().ToString());
3719 EXPECT_EQ(gfx::Rect().ToString(), 3592 EXPECT_EQ(gfx::Rect().ToString(),
3720 occlusion.occlusion_from_inside_target().ToString()); 3593 occlusion.occlusion_from_inside_target().ToString());
3721 } 3594 }
3722 }; 3595 };
3723 3596
3724 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestEmptyEventLayerDoesNotOcclude) 3597 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestEmptyEventLayerDoesNotOcclude)
3725 3598
3726 } // namespace 3599 } // namespace
3727 } // namespace cc 3600 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/occlusion_tracker.cc ('k') | cc/trees/quad_culler.cc » ('j') | cc/trees/quad_culler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698