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 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2813 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); | 2813 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child1->visible_content_rect()); |
2814 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); | 2814 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child2->visible_content_rect()); |
2815 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); | 2815 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); |
2816 | 2816 |
2817 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); | 2817 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); |
2818 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); | 2818 EXPECT_RECT_EQ(gfx::Rect(75, 75, 50, 50), child2->drawable_content_rect()); |
2819 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); | 2819 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); |
2820 } | 2820 } |
2821 | 2821 |
2822 TEST_F(LayerTreeHostCommonTest, | 2822 TEST_F(LayerTreeHostCommonTest, |
2823 VisibleContentRectsForClippedSurfaceWithEmptyClip) { | |
2824 scoped_refptr<Layer> root = Layer::Create(); | |
2825 scoped_refptr<LayerWithForcedDrawsContent> child1 = | |
2826 make_scoped_refptr(new LayerWithForcedDrawsContent()); | |
2827 scoped_refptr<LayerWithForcedDrawsContent> child2 = | |
2828 make_scoped_refptr(new LayerWithForcedDrawsContent()); | |
2829 scoped_refptr<LayerWithForcedDrawsContent> child3 = | |
2830 make_scoped_refptr(new LayerWithForcedDrawsContent()); | |
2831 root->AddChild(child1); | |
2832 root->AddChild(child2); | |
2833 root->AddChild(child3); | |
2834 | |
2835 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | |
2836 host->SetRootLayer(root); | |
2837 | |
2838 gfx::Transform identity_matrix; | |
2839 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | |
2840 gfx::PointF(), gfx::Size(100, 100), true, false); | |
2841 SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(), | |
2842 gfx::PointF(5.f, 5.f), gfx::Size(50, 50), true, | |
2843 false); | |
2844 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), | |
2845 gfx::PointF(75.f, 75.f), gfx::Size(50, 50), true, | |
2846 false); | |
2847 SetLayerPropertiesForTesting(child3.get(), identity_matrix, gfx::Point3F(), | |
2848 gfx::PointF(125.f, 125.f), gfx::Size(50, 50), | |
2849 true, false); | |
2850 | |
2851 RenderSurfaceLayerList render_surface_layer_list; | |
2852 // Now set the root render surface an empty clip. | |
2853 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | |
2854 root.get(), gfx::Size(0, 0), &render_surface_layer_list); | |
danakj
2014/12/02 17:27:16
nit: gfx::Size()
hush (inactive)
2014/12/02 18:12:36
Done.
| |
2855 | |
2856 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | |
2857 ASSERT_TRUE(root->render_surface()); | |
2858 EXPECT_FALSE(root->is_clipped()); | |
2859 | |
2860 const gfx::Rect empty(0, 0, 0, 0); | |
danakj
2014/12/02 17:27:16
nit: no const, or kEmpty. I prefer no const in thi
| |
2861 EXPECT_RECT_EQ(empty, root->render_surface()->clip_rect()); | |
danakj
2014/12/02 17:27:16
just use EXPECT_EQ please, it knows about rects no
hush (inactive)
2014/12/02 18:12:36
Done.
And there is a bunch of other places that u
| |
2862 EXPECT_TRUE(root->render_surface()->is_clipped()); | |
2863 | |
2864 // Visible content rect calculation will check if the target surface is | |
2865 // clipped or not. An empty clip rect does not indicate the render surface | |
2866 // is unclipped. | |
2867 EXPECT_RECT_EQ(empty, child1->visible_content_rect()); | |
danakj
2014/12/02 17:27:16
expect_eq etc
hush (inactive)
2014/12/02 18:12:36
Done.
| |
2868 EXPECT_RECT_EQ(empty, child2->visible_content_rect()); | |
2869 EXPECT_RECT_EQ(empty, child3->visible_content_rect()); | |
2870 } | |
2871 | |
2872 TEST_F(LayerTreeHostCommonTest, | |
2823 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { | 2873 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { |
2824 scoped_refptr<Layer> root = Layer::Create(); | 2874 scoped_refptr<Layer> root = Layer::Create(); |
2825 scoped_refptr<LayerWithForcedDrawsContent> child = | 2875 scoped_refptr<LayerWithForcedDrawsContent> child = |
2826 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2876 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2827 root->AddChild(child); | 2877 root->AddChild(child); |
2828 | 2878 |
2829 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 2879 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
2830 host->SetRootLayer(root); | 2880 host->SetRootLayer(root); |
2831 | 2881 |
2832 // Case 1: a truly degenerate matrix | 2882 // Case 1: a truly degenerate matrix |
(...skipping 5782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8615 // by the viewport. | 8665 // by the viewport. |
8616 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); | 8666 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); |
8617 | 8667 |
8618 // Layers drawing to a child render surface should still have their visible | 8668 // Layers drawing to a child render surface should still have their visible |
8619 // content rect clipped by the viewport. | 8669 // content rect clipped by the viewport. |
8620 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); | 8670 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); |
8621 } | 8671 } |
8622 | 8672 |
8623 } // namespace | 8673 } // namespace |
8624 } // namespace cc | 8674 } // namespace cc |
OLD | NEW |