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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "cc/layers/picture_layer.h" | 8 #include "cc/layers/picture_layer.h" |
9 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
10 #include "cc/test/layer_tree_test.h" | 10 #include "cc/test/layer_tree_test.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 50 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
51 LayerImpl* root = impl->active_tree()->root_layer(); | 51 LayerImpl* root = impl->active_tree()->root_layer(); |
52 LayerImpl* child = root->children()[0].get(); | 52 LayerImpl* child = root->children()[0].get(); |
53 | 53 |
54 // Verify the draw properties are valid. | 54 // Verify the draw properties are valid. |
55 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); | 55 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); |
56 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); | 56 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); |
57 | 57 |
58 EXPECT_OCCLUSION_EQ( | 58 EXPECT_OCCLUSION_EQ( |
59 Occlusion(child->draw_transform(), SimpleEnclosedRegion(), | 59 Occlusion(child->DrawTransform(), SimpleEnclosedRegion(), |
60 SimpleEnclosedRegion()), | 60 SimpleEnclosedRegion()), |
61 child->draw_properties().occlusion_in_content_space); | 61 child->draw_properties().occlusion_in_content_space); |
62 EXPECT_OCCLUSION_EQ( | 62 EXPECT_OCCLUSION_EQ( |
63 Occlusion(root->draw_transform(), SimpleEnclosedRegion(), | 63 Occlusion(root->DrawTransform(), SimpleEnclosedRegion(), |
64 SimpleEnclosedRegion(gfx::Rect(10, 6, 50, 59))), | 64 SimpleEnclosedRegion(gfx::Rect(10, 6, 50, 59))), |
65 root->draw_properties().occlusion_in_content_space); | 65 root->draw_properties().occlusion_in_content_space); |
66 EndTest(); | 66 EndTest(); |
67 } | 67 } |
68 | 68 |
69 void AfterTest() override {} | 69 void AfterTest() override {} |
70 }; | 70 }; |
71 | 71 |
72 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestDrawPropertiesOnLayer); | 72 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestDrawPropertiesOnLayer); |
73 | 73 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 LayerImpl* child = root->children()[0].get(); | 169 LayerImpl* child = root->children()[0].get(); |
170 RenderSurfaceImpl* surface = child->render_surface(); | 170 RenderSurfaceImpl* surface = child->render_surface(); |
171 LayerImpl* mask = child->mask_layer(); | 171 LayerImpl* mask = child->mask_layer(); |
172 | 172 |
173 // Verify the draw properties are valid. | 173 // Verify the draw properties are valid. |
174 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); | 174 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); |
175 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); | 175 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); |
176 EXPECT_EQ(child, child->render_target()); | 176 EXPECT_EQ(child, child->render_target()); |
177 | 177 |
178 gfx::Transform transform = surface->draw_transform(); | 178 gfx::Transform transform = surface->draw_transform(); |
179 transform.PreconcatTransform(child->draw_transform()); | 179 transform.PreconcatTransform(child->DrawTransform()); |
180 | 180 |
181 EXPECT_OCCLUSION_EQ( | 181 EXPECT_OCCLUSION_EQ( |
182 Occlusion(transform, SimpleEnclosedRegion(), | 182 Occlusion(transform, SimpleEnclosedRegion(), |
183 SimpleEnclosedRegion(gfx::Rect(13, 9, 10, 11))), | 183 SimpleEnclosedRegion(gfx::Rect(13, 9, 10, 11))), |
184 mask->draw_properties().occlusion_in_content_space); | 184 mask->draw_properties().occlusion_in_content_space); |
185 EndTest(); | 185 EndTest(); |
186 } | 186 } |
187 | 187 |
188 void AfterTest() override {} | 188 void AfterTest() override {} |
189 | 189 |
190 FakeContentLayerClient client_; | 190 FakeContentLayerClient client_; |
191 }; | 191 }; |
192 | 192 |
193 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestDrawPropertiesOnMask); | 193 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestDrawPropertiesOnMask); |
194 | 194 |
| 195 // Verify occlusion is correctly set on scaled mask layers. |
| 196 class LayerTreeHostOcclusionTestDrawPropertiesOnScaledMask |
| 197 : public LayerTreeHostOcclusionTest { |
| 198 public: |
| 199 void SetupTree() override { |
| 200 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 201 root->SetBounds(gfx::Size(100, 100)); |
| 202 root->SetIsDrawable(true); |
| 203 |
| 204 gfx::Transform scale; |
| 205 scale.Scale(2, 2); |
| 206 |
| 207 scoped_refptr<Layer> child = Layer::Create(layer_settings()); |
| 208 child->SetBounds(gfx::Size(30, 40)); |
| 209 child->SetTransform(scale); |
| 210 root->AddChild(child); |
| 211 |
| 212 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings()); |
| 213 grand_child->SetBounds(gfx::Size(100, 100)); |
| 214 grand_child->SetPosition(gfx::PointF(-10.f, -15.f)); |
| 215 grand_child->SetIsDrawable(true); |
| 216 child->AddChild(grand_child); |
| 217 |
| 218 scoped_refptr<Layer> mask = |
| 219 PictureLayer::Create(layer_settings(), &client_); |
| 220 mask->SetBounds(gfx::Size(30, 40)); |
| 221 mask->SetIsDrawable(true); |
| 222 child->SetMaskLayer(mask.get()); |
| 223 |
| 224 scoped_refptr<Layer> child2 = Layer::Create(layer_settings()); |
| 225 child2->SetBounds(gfx::Size(10, 11)); |
| 226 child2->SetPosition(gfx::PointF(13.f, 15.f)); |
| 227 child2->SetContentsOpaque(true); |
| 228 child2->SetIsDrawable(true); |
| 229 root->AddChild(child2); |
| 230 |
| 231 layer_tree_host()->SetRootLayer(root); |
| 232 LayerTreeTest::SetupTree(); |
| 233 client_.set_bounds(root->bounds()); |
| 234 } |
| 235 |
| 236 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 237 |
| 238 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 239 LayerImpl* root = impl->active_tree()->root_layer(); |
| 240 LayerImpl* child = root->children()[0].get(); |
| 241 LayerImpl* mask = child->mask_layer(); |
| 242 |
| 243 gfx::Transform scale; |
| 244 scale.Scale(2, 2); |
| 245 |
| 246 EXPECT_OCCLUSION_EQ( |
| 247 Occlusion(scale, SimpleEnclosedRegion(), |
| 248 SimpleEnclosedRegion(gfx::Rect(13, 15, 10, 11))), |
| 249 mask->draw_properties().occlusion_in_content_space); |
| 250 EndTest(); |
| 251 } |
| 252 |
| 253 void AfterTest() override {} |
| 254 |
| 255 FakeContentLayerClient client_; |
| 256 }; |
| 257 |
| 258 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 259 LayerTreeHostOcclusionTestDrawPropertiesOnScaledMask); |
| 260 |
195 // Verify occlusion is set to empty inside the subtree of a replica. This is | 261 // Verify occlusion is set to empty inside the subtree of a replica. This is |
196 // done because the tile system does not know about replicas, and so would not | 262 // done because the tile system does not know about replicas, and so would not |
197 // know that something is unoccluded on the replica even though it's occluded on | 263 // know that something is unoccluded on the replica even though it's occluded on |
198 // the original. | 264 // the original. |
199 class LayerTreeHostOcclusionTestDrawPropertiesInsideReplica | 265 class LayerTreeHostOcclusionTestDrawPropertiesInsideReplica |
200 : public LayerTreeHostOcclusionTest { | 266 : public LayerTreeHostOcclusionTest { |
201 public: | 267 public: |
202 void SetupTree() override { | 268 void SetupTree() override { |
203 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 269 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
204 root->SetBounds(gfx::Size(100, 100)); | 270 root->SetBounds(gfx::Size(100, 100)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 void AfterTest() override {} | 331 void AfterTest() override {} |
266 | 332 |
267 FakeContentLayerClient client_; | 333 FakeContentLayerClient client_; |
268 }; | 334 }; |
269 | 335 |
270 SINGLE_AND_MULTI_THREAD_TEST_F( | 336 SINGLE_AND_MULTI_THREAD_TEST_F( |
271 LayerTreeHostOcclusionTestDrawPropertiesInsideReplica); | 337 LayerTreeHostOcclusionTestDrawPropertiesInsideReplica); |
272 | 338 |
273 } // namespace | 339 } // namespace |
274 } // namespace cc | 340 } // namespace cc |
OLD | NEW |