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

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

Issue 998023002: Revert of Splitting of layers for correct intersections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « cc/trees/occlusion_tracker.cc ('k') | ui/gfx/geometry/quad_f.h » ('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/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 gfx::Rect(0, 0, 1000, 1000)); 1533 gfx::Rect(0, 0, 1000, 1000));
1534 1534
1535 // The |layer| is entirely behind the camera and should not occlude. 1535 // The |layer| is entirely behind the camera and should not occlude.
1536 this->VisitLayer(layer, &occlusion); 1536 this->VisitLayer(layer, &occlusion);
1537 this->EnterLayer(parent, &occlusion); 1537 this->EnterLayer(parent, &occlusion);
1538 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); 1538 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty());
1539 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); 1539 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty());
1540 } 1540 }
1541 }; 1541 };
1542 1542
1543 // This test requires accumulating occlusion of 3d layers, which are skipped by
1544 // the occlusion tracker on the main thread. So this test should run on the impl
1545 // thread.
1546 IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude);
1547
1548 template <class Types>
1549 class OcclusionTrackerTestLargePixelsOccludeInsideClipRect
1550 : public OcclusionTrackerTest<Types> {
1551 protected:
1552 explicit OcclusionTrackerTestLargePixelsOccludeInsideClipRect(
1553 bool opaque_layers)
1554 : OcclusionTrackerTest<Types>(opaque_layers) {}
1555 void RunMyTest() override {
1556 gfx::Transform transform;
1557 transform.Translate(50.0, 50.0);
1558 transform.ApplyPerspectiveDepth(100.0);
1559 transform.Translate3d(0.0, 0.0, 99.0);
1560 transform.Translate(-50.0, -50.0);
1561
1562 typename Types::ContentLayerType* parent = this->CreateRoot(
1563 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100));
1564 parent->SetMasksToBounds(true);
1565 typename Types::ContentLayerType* layer = this->CreateDrawingLayer(
1566 parent, transform, gfx::PointF(), gfx::Size(100, 100), true);
1567 parent->SetShouldFlattenTransform(false);
1568 parent->Set3dSortingContextId(1);
1569 layer->SetShouldFlattenTransform(false);
1570 layer->Set3dSortingContextId(1);
1571 this->CalcDrawEtc(parent);
1572
1573 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion(
1574 gfx::Rect(0, 0, 1000, 1000));
1575
1576 // This is very close to the camera, so pixels in its visible_content_rect()
1577 // will actually go outside of the layer's clip rect. Ensure that those
1578 // pixels don't occlude things outside the clip rect.
1579 this->VisitLayer(layer, &occlusion);
1580 this->EnterLayer(parent, &occlusion);
1581 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
1582 occlusion.occlusion_from_inside_target().ToString());
1583 EXPECT_EQ(gfx::Rect().ToString(),
1584 occlusion.occlusion_from_outside_target().ToString());
1585 }
1586 };
1587
1588 // This test requires accumulating occlusion of 3d layers, which are skipped by
1589 // the occlusion tracker on the main thread. So this test should run on the impl
1590 // thread.
1591 IMPL_THREAD_TEST(OcclusionTrackerTestLargePixelsOccludeInsideClipRect);
1592
1543 template <class Types> 1593 template <class Types>
1544 class OcclusionTrackerTestAnimationOpacity1OnMainThread 1594 class OcclusionTrackerTestAnimationOpacity1OnMainThread
1545 : public OcclusionTrackerTest<Types> { 1595 : public OcclusionTrackerTest<Types> {
1546 protected: 1596 protected:
1547 explicit OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaque_layers) 1597 explicit OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaque_layers)
1548 : OcclusionTrackerTest<Types>(opaque_layers) {} 1598 : OcclusionTrackerTest<Types>(opaque_layers) {}
1549 void RunMyTest() override { 1599 void RunMyTest() override {
1550 // parent 1600 // parent
1551 // +--layer 1601 // +--layer
1552 // +--surface 1602 // +--surface
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
3323 EXPECT_EQ(gfx::Rect(), 3373 EXPECT_EQ(gfx::Rect(),
3324 occlusion.UnoccludedSurfaceContentRect( 3374 occlusion.UnoccludedSurfaceContentRect(
3325 surface, gfx::Rect(80, 70, 50, 50))); 3375 surface, gfx::Rect(80, 70, 50, 50)));
3326 } 3376 }
3327 }; 3377 };
3328 3378
3329 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) 3379 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery)
3330 3380
3331 } // namespace 3381 } // namespace
3332 } // namespace cc 3382 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/occlusion_tracker.cc ('k') | ui/gfx/geometry/quad_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698