OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
(...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2669 | 2669 |
2670 // Only the corner of the layer is not visible on the surface because of being | 2670 // Only the corner of the layer is not visible on the surface because of being |
2671 // clipped. But, the net result of rounding visible region to an axis-aligned | 2671 // clipped. But, the net result of rounding visible region to an axis-aligned |
2672 // rect is that the entire layer should still be considered visible. | 2672 // rect is that the entire layer should still be considered visible. |
2673 gfx::Rect expected = gfx::Rect(-10, -10, 20, 20); | 2673 gfx::Rect expected = gfx::Rect(-10, -10, 20, 20); |
2674 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( | 2674 gfx::Rect actual = LayerTreeHostCommon::CalculateVisibleRect( |
2675 target_surface_rect, layer_content_rect, layer_to_surface_transform); | 2675 target_surface_rect, layer_content_rect, layer_to_surface_transform); |
2676 EXPECT_EQ(expected, actual); | 2676 EXPECT_EQ(expected, actual); |
2677 } | 2677 } |
2678 | 2678 |
| 2679 TEST_F(LayerTreeHostCommonTest, |
| 2680 VisibleRectsForPositionedRootLayerClippedByViewport) { |
| 2681 scoped_refptr<Layer> root = |
| 2682 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 2683 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
| 2684 host->SetRootLayer(root); |
| 2685 |
| 2686 gfx::Transform identity_matrix; |
| 2687 // Root layer is positioned at (60, 70). The default device viewport size |
| 2688 // is (0, 0, 100x100) in target space. So the root layer's visible rect |
| 2689 // will be clipped by the viewport to be (0, 0, 40x30) in layer's space. |
| 2690 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 2691 gfx::PointF(60, 70), gfx::Size(100, 100), true, |
| 2692 false); |
| 2693 ExecuteCalculateDrawProperties(root.get()); |
| 2694 |
| 2695 EXPECT_EQ(gfx::Rect(0, 0, 100, 100), |
| 2696 root->render_surface()->DrawableContentRect()); |
| 2697 // In target space, not clipped. |
| 2698 EXPECT_EQ(gfx::Rect(60, 70, 100, 100), root->drawable_content_rect()); |
| 2699 // In layer space, clipped. |
| 2700 EXPECT_EQ(gfx::Rect(0, 0, 40, 30), root->visible_content_rect()); |
| 2701 } |
| 2702 |
2679 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { | 2703 TEST_F(LayerTreeHostCommonTest, DrawableAndVisibleContentRectsForSimpleLayers) { |
2680 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 2704 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
2681 scoped_refptr<LayerWithForcedDrawsContent> child1 = | 2705 scoped_refptr<LayerWithForcedDrawsContent> child1 = |
2682 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); | 2706 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
2683 scoped_refptr<LayerWithForcedDrawsContent> child2 = | 2707 scoped_refptr<LayerWithForcedDrawsContent> child2 = |
2684 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); | 2708 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
2685 scoped_refptr<LayerWithForcedDrawsContent> child3 = | 2709 scoped_refptr<LayerWithForcedDrawsContent> child3 = |
2686 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); | 2710 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
2687 root->AddChild(child1); | 2711 root->AddChild(child1); |
2688 root->AddChild(child2); | 2712 root->AddChild(child2); |
(...skipping 6996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9685 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); | 9709 EXPECT_FALSE(root->layer_or_descendant_is_drawn()); |
9686 EXPECT_FALSE(root->visited()); | 9710 EXPECT_FALSE(root->visited()); |
9687 EXPECT_FALSE(root->sorted_for_recursion()); | 9711 EXPECT_FALSE(root->sorted_for_recursion()); |
9688 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); | 9712 EXPECT_FALSE(child->layer_or_descendant_is_drawn()); |
9689 EXPECT_FALSE(child->visited()); | 9713 EXPECT_FALSE(child->visited()); |
9690 EXPECT_FALSE(child->sorted_for_recursion()); | 9714 EXPECT_FALSE(child->sorted_for_recursion()); |
9691 } | 9715 } |
9692 | 9716 |
9693 } // namespace | 9717 } // namespace |
9694 } // namespace cc | 9718 } // namespace cc |
OLD | NEW |