OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/occlusion_tracker.h" | 5 #include "cc/trees/occlusion_tracker.h" |
6 | 6 |
7 #include "cc/animation/layer_animation_controller.h" | 7 #include "cc/animation/layer_animation_controller.h" |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 gfx::Rect(0, 0, 1000, 1000)); | 1532 gfx::Rect(0, 0, 1000, 1000)); |
1533 | 1533 |
1534 // The |layer| is entirely behind the camera and should not occlude. | 1534 // The |layer| is entirely behind the camera and should not occlude. |
1535 this->VisitLayer(layer, &occlusion); | 1535 this->VisitLayer(layer, &occlusion); |
1536 this->EnterLayer(parent, &occlusion); | 1536 this->EnterLayer(parent, &occlusion); |
1537 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); | 1537 EXPECT_TRUE(occlusion.occlusion_from_inside_target().IsEmpty()); |
1538 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); | 1538 EXPECT_TRUE(occlusion.occlusion_from_outside_target().IsEmpty()); |
1539 } | 1539 } |
1540 }; | 1540 }; |
1541 | 1541 |
1542 // This test requires accumulating occlusion of 3d layers, which are skipped by | |
1543 // the occlusion tracker on the main thread. So this test should run on the impl | |
1544 // thread. | |
1545 IMPL_THREAD_TEST(OcclusionTrackerTestLayerBehindCameraDoesNotOcclude); | |
1546 | |
1547 template <class Types> | |
1548 class OcclusionTrackerTestLargePixelsOccludeInsideClipRect | |
1549 : public OcclusionTrackerTest<Types> { | |
1550 protected: | |
1551 explicit OcclusionTrackerTestLargePixelsOccludeInsideClipRect( | |
1552 bool opaque_layers) | |
1553 : OcclusionTrackerTest<Types>(opaque_layers) {} | |
1554 void RunMyTest() override { | |
1555 gfx::Transform transform; | |
1556 transform.Translate(50.0, 50.0); | |
1557 transform.ApplyPerspectiveDepth(100.0); | |
1558 transform.Translate3d(0.0, 0.0, 99.0); | |
1559 transform.Translate(-50.0, -50.0); | |
1560 | |
1561 typename Types::ContentLayerType* parent = this->CreateRoot( | |
1562 this->identity_matrix, gfx::PointF(), gfx::Size(100, 100)); | |
1563 parent->SetMasksToBounds(true); | |
1564 typename Types::ContentLayerType* layer = this->CreateDrawingLayer( | |
1565 parent, transform, gfx::PointF(), gfx::Size(100, 100), true); | |
1566 parent->SetShouldFlattenTransform(false); | |
1567 parent->Set3dSortingContextId(1); | |
1568 layer->SetShouldFlattenTransform(false); | |
1569 layer->Set3dSortingContextId(1); | |
1570 this->CalcDrawEtc(parent); | |
1571 | |
1572 TestOcclusionTrackerWithClip<typename Types::LayerType> occlusion( | |
1573 gfx::Rect(0, 0, 1000, 1000)); | |
1574 | |
1575 // This is very close to the camera, so pixels in its visible_content_rect() | |
1576 // will actually go outside of the layer's clip rect. Ensure that those | |
1577 // pixels don't occlude things outside the clip rect. | |
1578 this->VisitLayer(layer, &occlusion); | |
1579 this->EnterLayer(parent, &occlusion); | |
1580 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), | |
1581 occlusion.occlusion_from_inside_target().ToString()); | |
1582 EXPECT_EQ(gfx::Rect().ToString(), | |
1583 occlusion.occlusion_from_outside_target().ToString()); | |
1584 } | |
1585 }; | |
1586 | |
1587 // This test requires accumulating occlusion of 3d layers, which are skipped by | |
1588 // the occlusion tracker on the main thread. So this test should run on the impl | |
1589 // thread. | |
1590 IMPL_THREAD_TEST(OcclusionTrackerTestLargePixelsOccludeInsideClipRect); | |
1591 | |
1592 template <class Types> | 1542 template <class Types> |
1593 class OcclusionTrackerTestAnimationOpacity1OnMainThread | 1543 class OcclusionTrackerTestAnimationOpacity1OnMainThread |
1594 : public OcclusionTrackerTest<Types> { | 1544 : public OcclusionTrackerTest<Types> { |
1595 protected: | 1545 protected: |
1596 explicit OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaque_layers) | 1546 explicit OcclusionTrackerTestAnimationOpacity1OnMainThread(bool opaque_layers) |
1597 : OcclusionTrackerTest<Types>(opaque_layers) {} | 1547 : OcclusionTrackerTest<Types>(opaque_layers) {} |
1598 void RunMyTest() override { | 1548 void RunMyTest() override { |
1599 // parent | 1549 // parent |
1600 // +--layer | 1550 // +--layer |
1601 // +--surface | 1551 // +--surface |
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3315 EXPECT_EQ(gfx::Rect(), | 3265 EXPECT_EQ(gfx::Rect(), |
3316 occlusion.UnoccludedSurfaceContentRect( | 3266 occlusion.UnoccludedSurfaceContentRect( |
3317 surface, gfx::Rect(80, 70, 50, 50))); | 3267 surface, gfx::Rect(80, 70, 50, 50))); |
3318 } | 3268 } |
3319 }; | 3269 }; |
3320 | 3270 |
3321 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) | 3271 ALL_OCCLUSIONTRACKER_TEST(OcclusionTrackerTestUnoccludedSurfaceQuery) |
3322 | 3272 |
3323 } // namespace | 3273 } // namespace |
3324 } // namespace cc | 3274 } // namespace cc |
OLD | NEW |