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

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

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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
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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 protected: 368 protected:
369 explicit OcclusionTrackerTestRotatedChild(bool opaque_layers) 369 explicit OcclusionTrackerTestRotatedChild(bool opaque_layers)
370 : OcclusionTrackerTest(opaque_layers) {} 370 : OcclusionTrackerTest(opaque_layers) {}
371 void RunMyTest() override { 371 void RunMyTest() override {
372 gfx::Transform layer_transform; 372 gfx::Transform layer_transform;
373 layer_transform.Translate(250.0, 250.0); 373 layer_transform.Translate(250.0, 250.0);
374 layer_transform.Rotate(90.0); 374 layer_transform.Rotate(90.0);
375 layer_transform.Translate(-250.0, -250.0); 375 layer_transform.Translate(-250.0, -250.0);
376 376
377 TestContentLayerImpl* root = this->CreateRoot( 377 TestContentLayerImpl* root = this->CreateRoot(
378 this->identity_matrix, gfx::Point(0, 0), gfx::Size(200, 200)); 378 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
379 TestContentLayerImpl* parent = this->CreateDrawingLayer( 379 TestContentLayerImpl* parent = this->CreateDrawingLayer(
380 root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true); 380 root, this->identity_matrix, gfx::PointF(), gfx::Size(100, 100), true);
381 TestContentLayerImpl* layer = this->CreateDrawingLayer( 381 TestContentLayerImpl* layer = this->CreateDrawingLayer(
382 parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500), 382 parent, layer_transform, gfx::PointF(30.f, 30.f), gfx::Size(500, 500),
383 true); 383 true);
384 parent->SetMasksToBounds(true); 384 parent->SetMasksToBounds(true);
385 this->CalcDrawEtc(root); 385 this->CalcDrawEtc(root);
386 386
387 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); 387 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
388 388
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 break; 1469 break;
1470 case TOP: 1470 case TOP:
1471 occlusion_rect = gfx::Rect(0, 0, 200, 50); 1471 occlusion_rect = gfx::Rect(0, 0, 200, 50);
1472 break; 1472 break;
1473 case BOTTOM: 1473 case BOTTOM:
1474 occlusion_rect = gfx::Rect(0, 100, 200, 50); 1474 occlusion_rect = gfx::Rect(0, 100, 200, 50);
1475 break; 1475 break;
1476 } 1476 }
1477 1477
1478 LayerImpl* occluding_layer = this->CreateDrawingLayer( 1478 LayerImpl* occluding_layer = this->CreateDrawingLayer(
1479 parent, this->identity_matrix, occlusion_rect.origin(), 1479 parent, this->identity_matrix, gfx::PointF(occlusion_rect.origin()),
1480 occlusion_rect.size(), true); 1480 occlusion_rect.size(), true);
1481 this->CalcDrawEtc(parent); 1481 this->CalcDrawEtc(parent);
1482 1482
1483 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); 1483 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
1484 1484
1485 // This layer occludes pixels directly beside the filtered_surface. 1485 // This layer occludes pixels directly beside the filtered_surface.
1486 // Because filtered surface blends pixels in a radius, it will need to see 1486 // Because filtered surface blends pixels in a radius, it will need to see
1487 // some of the pixels (up to radius far) underneath the occluding layers. 1487 // some of the pixels (up to radius far) underneath the occluding layers.
1488 this->VisitLayer(occluding_layer, &occlusion); 1488 this->VisitLayer(occluding_layer, &occlusion);
1489 1489
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 }; 1998 };
1999 1999
2000 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerInSurfaceIsClipped) 2000 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestScaledLayerInSurfaceIsClipped)
2001 2001
2002 class OcclusionTrackerTestCopyRequestDoesOcclude : public OcclusionTrackerTest { 2002 class OcclusionTrackerTestCopyRequestDoesOcclude : public OcclusionTrackerTest {
2003 protected: 2003 protected:
2004 explicit OcclusionTrackerTestCopyRequestDoesOcclude(bool opaque_layers) 2004 explicit OcclusionTrackerTestCopyRequestDoesOcclude(bool opaque_layers)
2005 : OcclusionTrackerTest(opaque_layers) {} 2005 : OcclusionTrackerTest(opaque_layers) {}
2006 void RunMyTest() override { 2006 void RunMyTest() override {
2007 TestContentLayerImpl* root = this->CreateRoot( 2007 TestContentLayerImpl* root = this->CreateRoot(
2008 this->identity_matrix, gfx::Point(), gfx::Size(400, 400)); 2008 this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
2009 TestContentLayerImpl* parent = this->CreateDrawingLayer( 2009 TestContentLayerImpl* parent = this->CreateDrawingLayer(
2010 root, this->identity_matrix, gfx::Point(), gfx::Size(400, 400), true); 2010 root, this->identity_matrix, gfx::PointF(), gfx::Size(400, 400), true);
2011 LayerImpl* copy = this->CreateLayer( 2011 LayerImpl* copy =
2012 parent, this->identity_matrix, gfx::Point(100, 0), gfx::Size(200, 400)); 2012 this->CreateLayer(parent, this->identity_matrix, gfx::PointF(100, 0),
2013 gfx::Size(200, 400));
2013 this->AddCopyRequest(copy); 2014 this->AddCopyRequest(copy);
2014 LayerImpl* copy_child = this->CreateDrawingLayer( 2015 LayerImpl* copy_child = this->CreateDrawingLayer(
2015 copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true); 2016 copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true);
2016 LayerImpl* top_layer = 2017 LayerImpl* top_layer =
2017 this->CreateDrawingLayer(root, this->identity_matrix, 2018 this->CreateDrawingLayer(root, this->identity_matrix,
2018 gfx::PointF(50, 0), gfx::Size(50, 400), true); 2019 gfx::PointF(50, 0), gfx::Size(50, 400), true);
2019 this->CalcDrawEtc(root); 2020 this->CalcDrawEtc(root);
2020 2021
2021 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000)); 2022 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 1000, 1000));
2022 2023
(...skipping 24 matching lines...) Expand all
2047 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestCopyRequestDoesOcclude) 2048 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestCopyRequestDoesOcclude)
2048 2049
2049 class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude 2050 class OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude
2050 : public OcclusionTrackerTest { 2051 : public OcclusionTrackerTest {
2051 protected: 2052 protected:
2052 explicit OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude( 2053 explicit OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude(
2053 bool opaque_layers) 2054 bool opaque_layers)
2054 : OcclusionTrackerTest(opaque_layers) {} 2055 : OcclusionTrackerTest(opaque_layers) {}
2055 void RunMyTest() override { 2056 void RunMyTest() override {
2056 TestContentLayerImpl* root = this->CreateRoot( 2057 TestContentLayerImpl* root = this->CreateRoot(
2057 this->identity_matrix, gfx::Point(), gfx::Size(400, 400)); 2058 this->identity_matrix, gfx::PointF(), gfx::Size(400, 400));
2058 TestContentLayerImpl* parent = this->CreateDrawingLayer( 2059 TestContentLayerImpl* parent = this->CreateDrawingLayer(
2059 root, this->identity_matrix, gfx::Point(), gfx::Size(400, 400), true); 2060 root, this->identity_matrix, gfx::PointF(), gfx::Size(400, 400), true);
2060 LayerImpl* hide = this->CreateLayer(parent, this->identity_matrix, 2061 LayerImpl* hide = this->CreateLayer(parent, this->identity_matrix,
2061 gfx::Point(), gfx::Size()); 2062 gfx::PointF(), gfx::Size());
2062 LayerImpl* copy = this->CreateLayer( 2063 LayerImpl* copy =
2063 hide, this->identity_matrix, gfx::Point(100, 0), gfx::Size(200, 400)); 2064 this->CreateLayer(hide, this->identity_matrix, gfx::PointF(100.f, 0.f),
2065 gfx::Size(200, 400));
2064 this->AddCopyRequest(copy); 2066 this->AddCopyRequest(copy);
2065 LayerImpl* copy_child = this->CreateDrawingLayer( 2067 LayerImpl* copy_child = this->CreateDrawingLayer(
2066 copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true); 2068 copy, this->identity_matrix, gfx::PointF(), gfx::Size(200, 400), true);
2067 2069
2068 // The |copy| layer is hidden but since it is being copied, it will be 2070 // The |copy| layer is hidden but since it is being copied, it will be
2069 // drawn. 2071 // drawn.
2070 hide->SetHideLayerAndSubtree(true); 2072 hide->SetHideLayerAndSubtree(true);
2071 2073
2072 this->CalcDrawEtc(root); 2074 this->CalcDrawEtc(root);
2073 2075
(...skipping 19 matching lines...) Expand all
2093 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude) 2095 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestHiddenCopyRequestDoesNotOcclude)
2094 2096
2095 class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest { 2097 class OcclusionTrackerTestOccludedLayer : public OcclusionTrackerTest {
2096 protected: 2098 protected:
2097 explicit OcclusionTrackerTestOccludedLayer(bool opaque_layers) 2099 explicit OcclusionTrackerTestOccludedLayer(bool opaque_layers)
2098 : OcclusionTrackerTest(opaque_layers) {} 2100 : OcclusionTrackerTest(opaque_layers) {}
2099 void RunMyTest() override { 2101 void RunMyTest() override {
2100 gfx::Transform translate; 2102 gfx::Transform translate;
2101 translate.Translate(10.0, 20.0); 2103 translate.Translate(10.0, 20.0);
2102 TestContentLayerImpl* root = this->CreateRoot( 2104 TestContentLayerImpl* root = this->CreateRoot(
2103 this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); 2105 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
2104 LayerImpl* surface = this->CreateSurface(root, this->identity_matrix, 2106 LayerImpl* surface = this->CreateSurface(
2105 gfx::Point(), gfx::Size(200, 200)); 2107 root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
2106 LayerImpl* layer = this->CreateDrawingLayer( 2108 LayerImpl* layer = this->CreateDrawingLayer(
2107 surface, translate, gfx::Point(), gfx::Size(200, 200), false); 2109 surface, translate, gfx::PointF(), gfx::Size(200, 200), false);
2108 TestContentLayerImpl* outside_layer = this->CreateDrawingLayer( 2110 TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
2109 root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false); 2111 root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false);
2110 this->CalcDrawEtc(root); 2112 this->CalcDrawEtc(root);
2111 2113
2112 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); 2114 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
2113 this->VisitLayer(outside_layer, &occlusion); 2115 this->VisitLayer(outside_layer, &occlusion);
2114 this->EnterLayer(layer, &occlusion); 2116 this->EnterLayer(layer, &occlusion);
2115 2117
2116 // No occlusion, is not occluded. 2118 // No occlusion, is not occluded.
2117 occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); 2119 occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion());
2118 occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); 2120 occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion());
2119 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100))); 2121 EXPECT_FALSE(occlusion.OccludedLayer(layer, gfx::Rect(100, 100)));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2181 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOccludedLayer) 2183 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestOccludedLayer)
2182 2184
2183 class OcclusionTrackerTestUnoccludedLayerQuery : public OcclusionTrackerTest { 2185 class OcclusionTrackerTestUnoccludedLayerQuery : public OcclusionTrackerTest {
2184 protected: 2186 protected:
2185 explicit OcclusionTrackerTestUnoccludedLayerQuery(bool opaque_layers) 2187 explicit OcclusionTrackerTestUnoccludedLayerQuery(bool opaque_layers)
2186 : OcclusionTrackerTest(opaque_layers) {} 2188 : OcclusionTrackerTest(opaque_layers) {}
2187 void RunMyTest() override { 2189 void RunMyTest() override {
2188 gfx::Transform translate; 2190 gfx::Transform translate;
2189 translate.Translate(10.0, 20.0); 2191 translate.Translate(10.0, 20.0);
2190 TestContentLayerImpl* root = this->CreateRoot( 2192 TestContentLayerImpl* root = this->CreateRoot(
2191 this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); 2193 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
2192 LayerImpl* surface = this->CreateSurface(root, this->identity_matrix, 2194 LayerImpl* surface = this->CreateSurface(
2193 gfx::Point(), gfx::Size(200, 200)); 2195 root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
2194 LayerImpl* layer = this->CreateDrawingLayer( 2196 LayerImpl* layer = this->CreateDrawingLayer(
2195 surface, translate, gfx::Point(), gfx::Size(200, 200), false); 2197 surface, translate, gfx::PointF(), gfx::Size(200, 200), false);
2196 TestContentLayerImpl* outside_layer = this->CreateDrawingLayer( 2198 TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
2197 root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false); 2199 root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false);
2198 this->CalcDrawEtc(root); 2200 this->CalcDrawEtc(root);
2199 2201
2200 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); 2202 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
2201 this->VisitLayer(outside_layer, &occlusion); 2203 this->VisitLayer(outside_layer, &occlusion);
2202 this->EnterLayer(layer, &occlusion); 2204 this->EnterLayer(layer, &occlusion);
2203 2205
2204 // No occlusion, is not occluded. 2206 // No occlusion, is not occluded.
2205 occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion()); 2207 occlusion.set_occlusion_from_outside_target(SimpleEnclosedRegion());
2206 occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion()); 2208 occlusion.set_occlusion_from_inside_target(SimpleEnclosedRegion());
2207 EXPECT_EQ(gfx::Rect(100, 100), 2209 EXPECT_EQ(gfx::Rect(100, 100),
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedLayerQuery) 2346 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedLayerQuery)
2345 2347
2346 class OcclusionTrackerTestUnoccludedSurfaceQuery : public OcclusionTrackerTest { 2348 class OcclusionTrackerTestUnoccludedSurfaceQuery : public OcclusionTrackerTest {
2347 protected: 2349 protected:
2348 explicit OcclusionTrackerTestUnoccludedSurfaceQuery(bool opaque_layers) 2350 explicit OcclusionTrackerTestUnoccludedSurfaceQuery(bool opaque_layers)
2349 : OcclusionTrackerTest(opaque_layers) {} 2351 : OcclusionTrackerTest(opaque_layers) {}
2350 void RunMyTest() override { 2352 void RunMyTest() override {
2351 gfx::Transform translate; 2353 gfx::Transform translate;
2352 translate.Translate(10.0, 20.0); 2354 translate.Translate(10.0, 20.0);
2353 TestContentLayerImpl* root = this->CreateRoot( 2355 TestContentLayerImpl* root = this->CreateRoot(
2354 this->identity_matrix, gfx::Point(), gfx::Size(200, 200)); 2356 this->identity_matrix, gfx::PointF(), gfx::Size(200, 200));
2355 LayerImpl* surface = 2357 LayerImpl* surface = this->CreateSurface(root, translate, gfx::PointF(),
2356 this->CreateSurface(root, translate, gfx::Point(), gfx::Size(200, 200)); 2358 gfx::Size(200, 200));
2357 LayerImpl* layer = 2359 LayerImpl* layer =
2358 this->CreateDrawingLayer(surface, this->identity_matrix, gfx::Point(), 2360 this->CreateDrawingLayer(surface, this->identity_matrix, gfx::PointF(),
2359 gfx::Size(200, 200), false); 2361 gfx::Size(200, 200), false);
2360 TestContentLayerImpl* outside_layer = this->CreateDrawingLayer( 2362 TestContentLayerImpl* outside_layer = this->CreateDrawingLayer(
2361 root, this->identity_matrix, gfx::Point(), gfx::Size(200, 200), false); 2363 root, this->identity_matrix, gfx::PointF(), gfx::Size(200, 200), false);
2362 this->CalcDrawEtc(root); 2364 this->CalcDrawEtc(root);
2363 2365
2364 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200)); 2366 TestOcclusionTrackerWithClip occlusion(gfx::Rect(0, 0, 200, 200));
2365 this->VisitLayer(outside_layer, &occlusion); 2367 this->VisitLayer(outside_layer, &occlusion);
2366 this->VisitLayer(layer, &occlusion); 2368 this->VisitLayer(layer, &occlusion);
2367 this->EnterContributingSurface(surface, &occlusion); 2369 this->EnterContributingSurface(surface, &occlusion);
2368 2370
2369 // No occlusion, is not occluded. 2371 // No occlusion, is not occluded.
2370 occlusion.set_occlusion_on_contributing_surface_from_outside_target( 2372 occlusion.set_occlusion_on_contributing_surface_from_outside_target(
2371 SimpleEnclosedRegion()); 2373 SimpleEnclosedRegion());
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 EXPECT_EQ(gfx::Rect(), 2510 EXPECT_EQ(gfx::Rect(),
2509 occlusion.UnoccludedSurfaceContentRect( 2511 occlusion.UnoccludedSurfaceContentRect(
2510 surface, gfx::Rect(80, 70, 50, 50))); 2512 surface, gfx::Rect(80, 70, 50, 50)));
2511 } 2513 }
2512 }; 2514 };
2513 2515
2514 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) 2516 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery)
2515 2517
2516 } // namespace 2518 } // namespace
2517 } // namespace cc 2519 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698