| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 10119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10130 | 10130 |
| 10131 root->SetBounds(gfx::Size(100, 100)); | 10131 root->SetBounds(gfx::Size(100, 100)); |
| 10132 clip_layer->SetBounds(gfx::Size(20, 20)); | 10132 clip_layer->SetBounds(gfx::Size(20, 20)); |
| 10133 clip_layer->SetMasksToBounds(true); | 10133 clip_layer->SetMasksToBounds(true); |
| 10134 clip_parent->SetBounds(gfx::Size(50, 50)); | 10134 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 10135 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); | 10135 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 10136 unclipped_desc_surface->SetDrawsContent(true); | 10136 unclipped_desc_surface->SetDrawsContent(true); |
| 10137 unclipped_desc_surface->test_properties()->force_render_surface = true; | 10137 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 10138 clip_child->SetBounds(gfx::Size(100, 100)); | 10138 clip_child->SetBounds(gfx::Size(100, 100)); |
| 10139 clip_child->SetDrawsContent(true); | 10139 clip_child->SetDrawsContent(true); |
| 10140 gfx::Transform translate; |
| 10141 translate.Translate(10, 10); |
| 10142 unclipped_desc_surface->test_properties()->transform = translate; |
| 10140 | 10143 |
| 10141 clip_child->test_properties()->clip_parent = clip_parent; | 10144 clip_child->test_properties()->clip_parent = clip_parent; |
| 10142 clip_parent->test_properties()->clip_children = | 10145 clip_parent->test_properties()->clip_children = |
| 10143 base::MakeUnique<std::set<LayerImpl*>>(); | 10146 base::MakeUnique<std::set<LayerImpl*>>(); |
| 10144 clip_parent->test_properties()->clip_children->insert(clip_child); | 10147 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 10145 | 10148 |
| 10146 float device_scale_factor = 1.f; | 10149 float device_scale_factor = 1.f; |
| 10147 ExecuteCalculateDrawProperties(root, device_scale_factor); | 10150 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 10148 EXPECT_EQ(gfx::Rect(20, 20), clip_child->clip_rect()); | 10151 EXPECT_EQ(gfx::Rect(-10, -10, 20, 20), clip_child->clip_rect()); |
| 10149 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); | 10152 EXPECT_EQ(gfx::Rect(10, 10), clip_child->visible_layer_rect()); |
| 10150 | 10153 |
| 10151 device_scale_factor = 2.f; | 10154 device_scale_factor = 2.f; |
| 10152 ExecuteCalculateDrawProperties(root, device_scale_factor); | 10155 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 10153 EXPECT_EQ(gfx::Rect(40, 40), clip_child->clip_rect()); | 10156 EXPECT_EQ(gfx::Rect(-20, -20, 40, 40), clip_child->clip_rect()); |
| 10154 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); | 10157 EXPECT_EQ(gfx::Rect(10, 10), clip_child->visible_layer_rect()); |
| 10155 } | 10158 } |
| 10156 | 10159 |
| 10157 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 10160 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
| 10158 LayerImpl* root = root_layer_for_testing(); | 10161 LayerImpl* root = root_layer_for_testing(); |
| 10159 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 10162 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 10160 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 10163 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
| 10161 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 10164 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
| 10162 | 10165 |
| 10163 root->SetBounds(gfx::Size(30, 30)); | 10166 root->SetBounds(gfx::Size(30, 30)); |
| 10164 clip_parent->SetBounds(gfx::Size(40, 40)); | 10167 clip_parent->SetBounds(gfx::Size(40, 40)); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10758 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10761 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10759 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10762 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10760 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10763 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10761 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10764 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10762 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10765 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10763 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10766 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10764 } | 10767 } |
| 10765 | 10768 |
| 10766 } // namespace | 10769 } // namespace |
| 10767 } // namespace cc | 10770 } // namespace cc |
| OLD | NEW |