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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } | 52 bool LayerWithForcedDrawsContent::DrawsContent() const { return true; } |
53 | 53 |
54 class MockContentLayerClient : public ContentLayerClient { | 54 class MockContentLayerClient : public ContentLayerClient { |
55 public: | 55 public: |
56 MockContentLayerClient() {} | 56 MockContentLayerClient() {} |
57 ~MockContentLayerClient() override {} | 57 ~MockContentLayerClient() override {} |
58 void PaintContents( | 58 void PaintContents( |
59 SkCanvas* canvas, | 59 SkCanvas* canvas, |
60 const gfx::Rect& clip, | 60 const gfx::Rect& clip, |
61 ContentLayerClient::GraphicsContextStatus gc_status) override {} | 61 ContentLayerClient::GraphicsContextStatus gc_status) override {} |
| 62 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( |
| 63 const gfx::Rect& clip, |
| 64 GraphicsContextStatus gc_status) override { |
| 65 NOTIMPLEMENTED(); |
| 66 return DisplayItemList::Create(); |
| 67 } |
62 bool FillsBoundsCompletely() const override { return false; } | 68 bool FillsBoundsCompletely() const override { return false; } |
63 }; | 69 }; |
64 | 70 |
65 scoped_refptr<FakePictureLayer> CreateDrawablePictureLayer( | 71 scoped_refptr<FakePictureLayer> CreateDrawablePictureLayer( |
66 ContentLayerClient* delegate) { | 72 ContentLayerClient* delegate) { |
67 scoped_refptr<FakePictureLayer> to_return = | 73 scoped_refptr<FakePictureLayer> to_return = |
68 FakePictureLayer::Create(delegate); | 74 FakePictureLayer::Create(delegate); |
69 to_return->SetIsDrawable(true); | 75 to_return->SetIsDrawable(true); |
70 return to_return; | 76 return to_return; |
71 } | 77 } |
(...skipping 2741 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()); | 2819 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()); | 2820 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()); | 2821 EXPECT_RECT_EQ(gfx::Rect(0, 0, 50, 50), child3->visible_content_rect()); |
2816 | 2822 |
2817 EXPECT_RECT_EQ(gfx::Rect(5, 5, 50, 50), child1->drawable_content_rect()); | 2823 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()); | 2824 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()); | 2825 EXPECT_RECT_EQ(gfx::Rect(125, 125, 50, 50), child3->drawable_content_rect()); |
2820 } | 2826 } |
2821 | 2827 |
2822 TEST_F(LayerTreeHostCommonTest, | 2828 TEST_F(LayerTreeHostCommonTest, |
| 2829 VisibleContentRectsForClippedSurfaceWithEmptyClip) { |
| 2830 scoped_refptr<Layer> root = Layer::Create(); |
| 2831 scoped_refptr<LayerWithForcedDrawsContent> child1 = |
| 2832 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2833 scoped_refptr<LayerWithForcedDrawsContent> child2 = |
| 2834 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2835 scoped_refptr<LayerWithForcedDrawsContent> child3 = |
| 2836 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| 2837 root->AddChild(child1); |
| 2838 root->AddChild(child2); |
| 2839 root->AddChild(child3); |
| 2840 |
| 2841 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
| 2842 host->SetRootLayer(root); |
| 2843 |
| 2844 gfx::Transform identity_matrix; |
| 2845 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 2846 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 2847 SetLayerPropertiesForTesting(child1.get(), identity_matrix, gfx::Point3F(), |
| 2848 gfx::PointF(5.f, 5.f), gfx::Size(50, 50), true, |
| 2849 false); |
| 2850 SetLayerPropertiesForTesting(child2.get(), identity_matrix, gfx::Point3F(), |
| 2851 gfx::PointF(75.f, 75.f), gfx::Size(50, 50), true, |
| 2852 false); |
| 2853 SetLayerPropertiesForTesting(child3.get(), identity_matrix, gfx::Point3F(), |
| 2854 gfx::PointF(125.f, 125.f), gfx::Size(50, 50), |
| 2855 true, false); |
| 2856 |
| 2857 RenderSurfaceLayerList render_surface_layer_list; |
| 2858 // Now set the root render surface an empty clip. |
| 2859 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
| 2860 root.get(), gfx::Size(), &render_surface_layer_list); |
| 2861 |
| 2862 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 2863 ASSERT_TRUE(root->render_surface()); |
| 2864 EXPECT_FALSE(root->is_clipped()); |
| 2865 |
| 2866 gfx::Rect empty; |
| 2867 EXPECT_EQ(empty, root->render_surface()->clip_rect()); |
| 2868 EXPECT_TRUE(root->render_surface()->is_clipped()); |
| 2869 |
| 2870 // Visible content rect calculation will check if the target surface is |
| 2871 // clipped or not. An empty clip rect does not indicate the render surface |
| 2872 // is unclipped. |
| 2873 EXPECT_EQ(empty, child1->visible_content_rect()); |
| 2874 EXPECT_EQ(empty, child2->visible_content_rect()); |
| 2875 EXPECT_EQ(empty, child3->visible_content_rect()); |
| 2876 } |
| 2877 |
| 2878 TEST_F(LayerTreeHostCommonTest, |
2823 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { | 2879 DrawableAndVisibleContentRectsForLayersWithUninvertibleTransform) { |
2824 scoped_refptr<Layer> root = Layer::Create(); | 2880 scoped_refptr<Layer> root = Layer::Create(); |
2825 scoped_refptr<LayerWithForcedDrawsContent> child = | 2881 scoped_refptr<LayerWithForcedDrawsContent> child = |
2826 make_scoped_refptr(new LayerWithForcedDrawsContent()); | 2882 make_scoped_refptr(new LayerWithForcedDrawsContent()); |
2827 root->AddChild(child); | 2883 root->AddChild(child); |
2828 | 2884 |
2829 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); | 2885 scoped_ptr<FakeLayerTreeHost> host(CreateFakeLayerTreeHost()); |
2830 host->SetRootLayer(root); | 2886 host->SetRootLayer(root); |
2831 | 2887 |
2832 // Case 1: a truly degenerate matrix | 2888 // Case 1: a truly degenerate matrix |
(...skipping 5782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8615 // by the viewport. | 8671 // by the viewport. |
8616 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); | 8672 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), root->visible_content_rect()); |
8617 | 8673 |
8618 // Layers drawing to a child render surface should still have their visible | 8674 // Layers drawing to a child render surface should still have their visible |
8619 // content rect clipped by the viewport. | 8675 // content rect clipped by the viewport. |
8620 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); | 8676 EXPECT_EQ(gfx::Rect(768 / 2, 582 / 2), content->visible_content_rect()); |
8621 } | 8677 } |
8622 | 8678 |
8623 } // namespace | 8679 } // namespace |
8624 } // namespace cc | 8680 } // namespace cc |
OLD | NEW |