Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 // Verify occlusion is set on the layer draw properties. | 28 // Verify occlusion is set on the layer draw properties. |
| 29 class LayerTreeHostOcclusionTestDrawPropertiesOnLayer | 29 class LayerTreeHostOcclusionTestDrawPropertiesOnLayer |
| 30 : public LayerTreeHostOcclusionTest { | 30 : public LayerTreeHostOcclusionTest { |
| 31 public: | 31 public: |
| 32 void SetupTree() override { | 32 void SetupTree() override { |
| 33 scoped_refptr<Layer> root = Layer::Create(); | 33 scoped_refptr<Layer> root = Layer::Create(); |
| 34 root->SetBounds(gfx::Size(100, 100)); | 34 root->SetBounds(gfx::Size(100, 100)); |
| 35 root->SetIsDrawable(true); | 35 root->SetIsDrawable(true); |
| 36 | 36 |
| 37 scoped_refptr<Layer> child = Layer::Create(); | 37 scoped_refptr<Layer> child = Layer::Create(); |
| 38 child_ = child.get(); | |
| 38 child->SetBounds(gfx::Size(50, 60)); | 39 child->SetBounds(gfx::Size(50, 60)); |
| 39 child->SetPosition(gfx::PointF(10.f, 5.5f)); | 40 child->SetPosition(gfx::PointF(10.f, 5.5f)); |
| 40 child->SetContentsOpaque(true); | 41 child->SetContentsOpaque(true); |
| 41 child->SetIsDrawable(true); | 42 child->SetIsDrawable(true); |
| 42 root->AddChild(child); | 43 root->AddChild(child); |
| 43 | 44 |
| 44 layer_tree_host()->SetRootLayer(root); | 45 layer_tree_host()->SetRootLayer(root); |
| 45 LayerTreeTest::SetupTree(); | 46 LayerTreeTest::SetupTree(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 49 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 49 | 50 |
| 50 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 51 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 51 LayerImpl* root = impl->active_tree()->root_layer(); | 52 LayerImpl* root = impl->active_tree()->root_layer(); |
| 52 LayerImpl* child = root->children()[0]; | 53 LayerImpl* child = impl->active_tree()->LayerById(child_->id()); |
| 53 | 54 |
| 54 // Verify the draw properties are valid. | 55 // Verify the draw properties are valid. |
| 55 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); | 56 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); |
| 56 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); | 57 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); |
| 57 | 58 |
| 58 EXPECT_OCCLUSION_EQ( | 59 EXPECT_OCCLUSION_EQ( |
| 59 Occlusion(child->DrawTransform(), SimpleEnclosedRegion(), | 60 Occlusion(child->DrawTransform(), SimpleEnclosedRegion(), |
| 60 SimpleEnclosedRegion()), | 61 SimpleEnclosedRegion()), |
| 61 child->draw_properties().occlusion_in_content_space); | 62 child->draw_properties().occlusion_in_content_space); |
| 62 EXPECT_OCCLUSION_EQ( | 63 EXPECT_OCCLUSION_EQ( |
| 63 Occlusion(root->DrawTransform(), SimpleEnclosedRegion(), | 64 Occlusion(root->DrawTransform(), SimpleEnclosedRegion(), |
| 64 SimpleEnclosedRegion(gfx::Rect(10, 6, 50, 59))), | 65 SimpleEnclosedRegion(gfx::Rect(10, 6, 50, 59))), |
| 65 root->draw_properties().occlusion_in_content_space); | 66 root->draw_properties().occlusion_in_content_space); |
| 66 EndTest(); | 67 EndTest(); |
| 67 } | 68 } |
| 68 | 69 |
| 69 void AfterTest() override {} | 70 void AfterTest() override {} |
| 71 | |
| 72 private: | |
| 73 Layer* child_; | |
|
ajuma
2016/04/20 21:40:52
scoped_refptr
sunxd
2016/04/21 17:31:15
Done.
| |
| 70 }; | 74 }; |
| 71 | 75 |
| 72 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestDrawPropertiesOnLayer); | 76 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestDrawPropertiesOnLayer); |
| 73 | 77 |
| 74 // Verify occlusion is set on the render surfaces. | 78 // Verify occlusion is set on the render surfaces. |
| 75 class LayerTreeHostOcclusionTestDrawPropertiesOnSurface | 79 class LayerTreeHostOcclusionTestDrawPropertiesOnSurface |
| 76 : public LayerTreeHostOcclusionTest { | 80 : public LayerTreeHostOcclusionTest { |
| 77 public: | 81 public: |
| 78 void SetupTree() override { | 82 void SetupTree() override { |
| 79 scoped_refptr<Layer> root = Layer::Create(); | 83 scoped_refptr<Layer> root = Layer::Create(); |
| 80 root->SetBounds(gfx::Size(100, 100)); | 84 root->SetBounds(gfx::Size(100, 100)); |
| 81 root->SetIsDrawable(true); | 85 root->SetIsDrawable(true); |
| 82 | 86 |
| 83 scoped_refptr<Layer> child = Layer::Create(); | 87 scoped_refptr<Layer> child = Layer::Create(); |
| 88 child_ = child.get(); | |
| 84 child->SetBounds(gfx::Size(1, 1)); | 89 child->SetBounds(gfx::Size(1, 1)); |
| 85 child->SetPosition(gfx::PointF(10.f, 5.5f)); | 90 child->SetPosition(gfx::PointF(10.f, 5.5f)); |
| 86 child->SetIsDrawable(true); | 91 child->SetIsDrawable(true); |
| 87 child->SetForceRenderSurface(true); | 92 child->SetForceRenderSurface(true); |
| 88 root->AddChild(child); | 93 root->AddChild(child); |
| 89 | 94 |
| 90 scoped_refptr<Layer> child2 = Layer::Create(); | 95 scoped_refptr<Layer> child2 = Layer::Create(); |
| 91 child2->SetBounds(gfx::Size(10, 12)); | 96 child2->SetBounds(gfx::Size(10, 12)); |
| 92 child2->SetPosition(gfx::PointF(13.f, 8.5f)); | 97 child2->SetPosition(gfx::PointF(13.f, 8.5f)); |
| 93 child2->SetContentsOpaque(true); | 98 child2->SetContentsOpaque(true); |
| 94 child2->SetIsDrawable(true); | 99 child2->SetIsDrawable(true); |
| 95 root->AddChild(child2); | 100 root->AddChild(child2); |
| 96 | 101 |
| 97 layer_tree_host()->SetRootLayer(root); | 102 layer_tree_host()->SetRootLayer(root); |
| 98 LayerTreeTest::SetupTree(); | 103 LayerTreeTest::SetupTree(); |
| 99 } | 104 } |
| 100 | 105 |
| 101 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 106 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 102 | 107 |
| 103 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 108 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 104 LayerImpl* root = impl->active_tree()->root_layer(); | 109 LayerImpl* root = impl->active_tree()->root_layer(); |
| 105 LayerImpl* child = root->children()[0]; | 110 LayerImpl* child = impl->active_tree()->LayerById(child_->id()); |
| 106 RenderSurfaceImpl* surface = child->render_surface(); | 111 RenderSurfaceImpl* surface = child->render_surface(); |
| 107 | 112 |
| 108 // Verify the draw properties are valid. | 113 // Verify the draw properties are valid. |
| 109 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); | 114 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); |
| 110 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); | 115 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); |
| 111 EXPECT_TRUE(child->has_render_surface()); | 116 EXPECT_TRUE(child->has_render_surface()); |
| 112 EXPECT_EQ(child->render_surface(), child->render_target()); | 117 EXPECT_EQ(child->render_surface(), child->render_target()); |
| 113 | 118 |
| 114 EXPECT_OCCLUSION_EQ( | 119 EXPECT_OCCLUSION_EQ( |
| 115 Occlusion(surface->draw_transform(), SimpleEnclosedRegion(), | 120 Occlusion(surface->draw_transform(), SimpleEnclosedRegion(), |
| 116 SimpleEnclosedRegion(gfx::Rect(13, 9, 10, 11))), | 121 SimpleEnclosedRegion(gfx::Rect(13, 9, 10, 11))), |
| 117 surface->occlusion_in_content_space()); | 122 surface->occlusion_in_content_space()); |
| 118 EndTest(); | 123 EndTest(); |
| 119 } | 124 } |
| 120 | 125 |
| 121 void AfterTest() override {} | 126 void AfterTest() override {} |
| 127 | |
| 128 private: | |
| 129 Layer* child_; | |
|
ajuma
2016/04/20 21:40:52
scoped_refptr
sunxd
2016/04/21 17:31:15
Done.
| |
| 122 }; | 130 }; |
| 123 | 131 |
| 124 SINGLE_AND_MULTI_THREAD_TEST_F( | 132 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 125 LayerTreeHostOcclusionTestDrawPropertiesOnSurface); | 133 LayerTreeHostOcclusionTestDrawPropertiesOnSurface); |
| 126 | 134 |
| 127 // Verify occlusion is set on mask layers. | 135 // Verify occlusion is set on mask layers. |
| 128 class LayerTreeHostOcclusionTestDrawPropertiesOnMask | 136 class LayerTreeHostOcclusionTestDrawPropertiesOnMask |
| 129 : public LayerTreeHostOcclusionTest { | 137 : public LayerTreeHostOcclusionTest { |
| 130 public: | 138 public: |
| 131 void SetupTree() override { | 139 void SetupTree() override { |
| 132 scoped_refptr<Layer> root = Layer::Create(); | 140 scoped_refptr<Layer> root = Layer::Create(); |
| 133 root->SetBounds(gfx::Size(100, 100)); | 141 root->SetBounds(gfx::Size(100, 100)); |
| 134 root->SetIsDrawable(true); | 142 root->SetIsDrawable(true); |
| 135 | 143 |
| 136 scoped_refptr<Layer> child = Layer::Create(); | 144 scoped_refptr<Layer> child = Layer::Create(); |
| 145 child_ = child.get(); | |
| 137 child->SetBounds(gfx::Size(30, 40)); | 146 child->SetBounds(gfx::Size(30, 40)); |
| 138 child->SetPosition(gfx::PointF(10.f, 5.5f)); | 147 child->SetPosition(gfx::PointF(10.f, 5.5f)); |
| 139 child->SetIsDrawable(true); | 148 child->SetIsDrawable(true); |
| 140 root->AddChild(child); | 149 root->AddChild(child); |
| 141 | 150 |
| 142 scoped_refptr<Layer> make_surface_bigger = Layer::Create(); | 151 scoped_refptr<Layer> make_surface_bigger = Layer::Create(); |
| 143 make_surface_bigger->SetBounds(gfx::Size(100, 100)); | 152 make_surface_bigger->SetBounds(gfx::Size(100, 100)); |
| 144 make_surface_bigger->SetPosition(gfx::PointF(-10.f, -15.f)); | 153 make_surface_bigger->SetPosition(gfx::PointF(-10.f, -15.f)); |
| 145 make_surface_bigger->SetIsDrawable(true); | 154 make_surface_bigger->SetIsDrawable(true); |
| 146 child->AddChild(make_surface_bigger); | 155 child->AddChild(make_surface_bigger); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 159 | 168 |
| 160 layer_tree_host()->SetRootLayer(root); | 169 layer_tree_host()->SetRootLayer(root); |
| 161 LayerTreeTest::SetupTree(); | 170 LayerTreeTest::SetupTree(); |
| 162 client_.set_bounds(root->bounds()); | 171 client_.set_bounds(root->bounds()); |
| 163 } | 172 } |
| 164 | 173 |
| 165 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 174 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 166 | 175 |
| 167 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 176 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 168 LayerImpl* root = impl->active_tree()->root_layer(); | 177 LayerImpl* root = impl->active_tree()->root_layer(); |
| 169 LayerImpl* child = root->children()[0]; | 178 LayerImpl* child = impl->active_tree()->LayerById(child_->id()); |
| 170 RenderSurfaceImpl* surface = child->render_surface(); | 179 RenderSurfaceImpl* surface = child->render_surface(); |
| 171 LayerImpl* mask = child->mask_layer(); | 180 LayerImpl* mask = child->mask_layer(); |
| 172 | 181 |
| 173 // Verify the draw properties are valid. | 182 // Verify the draw properties are valid. |
| 174 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); | 183 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); |
| 175 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); | 184 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); |
| 176 EXPECT_TRUE(child->has_render_surface()); | 185 EXPECT_TRUE(child->has_render_surface()); |
| 177 EXPECT_EQ(child->render_surface(), child->render_target()); | 186 EXPECT_EQ(child->render_surface(), child->render_target()); |
| 178 | 187 |
| 179 gfx::Transform transform = surface->draw_transform(); | 188 gfx::Transform transform = surface->draw_transform(); |
| 180 transform.PreconcatTransform(child->DrawTransform()); | 189 transform.PreconcatTransform(child->DrawTransform()); |
| 181 | 190 |
| 182 EXPECT_OCCLUSION_EQ( | 191 EXPECT_OCCLUSION_EQ( |
| 183 Occlusion(transform, SimpleEnclosedRegion(), | 192 Occlusion(transform, SimpleEnclosedRegion(), |
| 184 SimpleEnclosedRegion(gfx::Rect(13, 9, 10, 11))), | 193 SimpleEnclosedRegion(gfx::Rect(13, 9, 10, 11))), |
| 185 mask->draw_properties().occlusion_in_content_space); | 194 mask->draw_properties().occlusion_in_content_space); |
| 186 EndTest(); | 195 EndTest(); |
| 187 } | 196 } |
| 188 | 197 |
| 189 void AfterTest() override {} | 198 void AfterTest() override {} |
| 190 | 199 |
| 200 private: | |
| 191 FakeContentLayerClient client_; | 201 FakeContentLayerClient client_; |
| 202 Layer* child_; | |
|
ajuma
2016/04/20 21:40:52
scoped_refptr
sunxd
2016/04/21 17:31:15
Done.
| |
| 192 }; | 203 }; |
| 193 | 204 |
| 194 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestDrawPropertiesOnMask); | 205 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostOcclusionTestDrawPropertiesOnMask); |
| 195 | 206 |
| 196 // Verify occlusion is correctly set on scaled mask layers. | 207 // Verify occlusion is correctly set on scaled mask layers. |
| 197 class LayerTreeHostOcclusionTestDrawPropertiesOnScaledMask | 208 class LayerTreeHostOcclusionTestDrawPropertiesOnScaledMask |
| 198 : public LayerTreeHostOcclusionTest { | 209 : public LayerTreeHostOcclusionTest { |
| 199 public: | 210 public: |
| 200 void SetupTree() override { | 211 void SetupTree() override { |
| 201 scoped_refptr<Layer> root = Layer::Create(); | 212 scoped_refptr<Layer> root = Layer::Create(); |
| 202 root->SetBounds(gfx::Size(100, 100)); | 213 root->SetBounds(gfx::Size(100, 100)); |
| 203 root->SetIsDrawable(true); | 214 root->SetIsDrawable(true); |
| 204 | 215 |
| 205 gfx::Transform scale; | 216 gfx::Transform scale; |
| 206 scale.Scale(2, 2); | 217 scale.Scale(2, 2); |
| 207 | 218 |
| 208 scoped_refptr<Layer> child = Layer::Create(); | 219 scoped_refptr<Layer> child = Layer::Create(); |
| 220 child_ = child.get(); | |
| 209 child->SetBounds(gfx::Size(30, 40)); | 221 child->SetBounds(gfx::Size(30, 40)); |
| 210 child->SetTransform(scale); | 222 child->SetTransform(scale); |
| 211 root->AddChild(child); | 223 root->AddChild(child); |
| 212 | 224 |
| 213 scoped_refptr<Layer> grand_child = Layer::Create(); | 225 scoped_refptr<Layer> grand_child = Layer::Create(); |
| 214 grand_child->SetBounds(gfx::Size(100, 100)); | 226 grand_child->SetBounds(gfx::Size(100, 100)); |
| 215 grand_child->SetPosition(gfx::PointF(-10.f, -15.f)); | 227 grand_child->SetPosition(gfx::PointF(-10.f, -15.f)); |
| 216 grand_child->SetIsDrawable(true); | 228 grand_child->SetIsDrawable(true); |
| 217 child->AddChild(grand_child); | 229 child->AddChild(grand_child); |
| 218 | 230 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 229 root->AddChild(child2); | 241 root->AddChild(child2); |
| 230 | 242 |
| 231 layer_tree_host()->SetRootLayer(root); | 243 layer_tree_host()->SetRootLayer(root); |
| 232 LayerTreeTest::SetupTree(); | 244 LayerTreeTest::SetupTree(); |
| 233 client_.set_bounds(root->bounds()); | 245 client_.set_bounds(root->bounds()); |
| 234 } | 246 } |
| 235 | 247 |
| 236 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 248 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 237 | 249 |
| 238 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 250 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 239 LayerImpl* root = impl->active_tree()->root_layer(); | 251 LayerImpl* child = impl->active_tree()->LayerById(child_->id()); |
| 240 LayerImpl* child = root->children()[0]; | |
| 241 LayerImpl* mask = child->mask_layer(); | 252 LayerImpl* mask = child->mask_layer(); |
| 242 | 253 |
| 243 gfx::Transform scale; | 254 gfx::Transform scale; |
| 244 scale.Scale(2, 2); | 255 scale.Scale(2, 2); |
| 245 | 256 |
| 246 EXPECT_OCCLUSION_EQ( | 257 EXPECT_OCCLUSION_EQ( |
| 247 Occlusion(scale, SimpleEnclosedRegion(), | 258 Occlusion(scale, SimpleEnclosedRegion(), |
| 248 SimpleEnclosedRegion(gfx::Rect(13, 15, 10, 11))), | 259 SimpleEnclosedRegion(gfx::Rect(13, 15, 10, 11))), |
| 249 mask->draw_properties().occlusion_in_content_space); | 260 mask->draw_properties().occlusion_in_content_space); |
| 250 EndTest(); | 261 EndTest(); |
| 251 } | 262 } |
| 252 | 263 |
| 253 void AfterTest() override {} | 264 void AfterTest() override {} |
| 254 | 265 |
| 266 private: | |
| 255 FakeContentLayerClient client_; | 267 FakeContentLayerClient client_; |
| 268 Layer* child_; | |
|
ajuma
2016/04/20 21:40:52
scoped_refptr
sunxd
2016/04/21 17:31:16
Done.
| |
| 256 }; | 269 }; |
| 257 | 270 |
| 258 SINGLE_AND_MULTI_THREAD_TEST_F( | 271 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 259 LayerTreeHostOcclusionTestDrawPropertiesOnScaledMask); | 272 LayerTreeHostOcclusionTestDrawPropertiesOnScaledMask); |
| 260 | 273 |
| 261 // Verify occlusion is set to empty inside the subtree of a replica. This is | 274 // Verify occlusion is set to empty inside the subtree of a replica. This is |
| 262 // done because the tile system does not know about replicas, and so would not | 275 // done because the tile system does not know about replicas, and so would not |
| 263 // know that something is unoccluded on the replica even though it's occluded on | 276 // know that something is unoccluded on the replica even though it's occluded on |
| 264 // the original. | 277 // the original. |
| 265 class LayerTreeHostOcclusionTestDrawPropertiesInsideReplica | 278 class LayerTreeHostOcclusionTestDrawPropertiesInsideReplica |
| 266 : public LayerTreeHostOcclusionTest { | 279 : public LayerTreeHostOcclusionTest { |
| 267 public: | 280 public: |
| 268 void SetupTree() override { | 281 void SetupTree() override { |
| 269 scoped_refptr<Layer> root = Layer::Create(); | 282 scoped_refptr<Layer> root = Layer::Create(); |
| 270 root->SetBounds(gfx::Size(100, 100)); | 283 root->SetBounds(gfx::Size(100, 100)); |
| 271 root->SetIsDrawable(true); | 284 root->SetIsDrawable(true); |
| 272 | 285 |
| 273 scoped_refptr<Layer> child = Layer::Create(); | 286 scoped_refptr<Layer> child = Layer::Create(); |
| 287 child_ = child.get(); | |
| 274 child->SetBounds(gfx::Size(1, 1)); | 288 child->SetBounds(gfx::Size(1, 1)); |
| 275 child->SetPosition(gfx::PointF(10.f, 5.5f)); | 289 child->SetPosition(gfx::PointF(10.f, 5.5f)); |
| 276 child->SetIsDrawable(true); | 290 child->SetIsDrawable(true); |
| 277 child->SetForceRenderSurface(true); | 291 child->SetForceRenderSurface(true); |
| 278 root->AddChild(child); | 292 root->AddChild(child); |
| 279 | 293 |
| 280 scoped_refptr<Layer> replica = Layer::Create(); | 294 scoped_refptr<Layer> replica = Layer::Create(); |
| 281 gfx::Transform translate; | 295 gfx::Transform translate; |
| 282 translate.Translate(20.f, 4.f); | 296 translate.Translate(20.f, 4.f); |
| 283 replica->SetTransform(translate); | 297 replica->SetTransform(translate); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 297 | 311 |
| 298 layer_tree_host()->SetRootLayer(root); | 312 layer_tree_host()->SetRootLayer(root); |
| 299 LayerTreeTest::SetupTree(); | 313 LayerTreeTest::SetupTree(); |
| 300 client_.set_bounds(root->bounds()); | 314 client_.set_bounds(root->bounds()); |
| 301 } | 315 } |
| 302 | 316 |
| 303 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 317 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 304 | 318 |
| 305 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 319 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 306 LayerImpl* root = impl->active_tree()->root_layer(); | 320 LayerImpl* root = impl->active_tree()->root_layer(); |
| 307 LayerImpl* child = root->children()[0]; | 321 LayerImpl* child = impl->active_tree()->LayerById(child_->id()); |
| 308 RenderSurfaceImpl* surface = child->render_surface(); | 322 RenderSurfaceImpl* surface = child->render_surface(); |
| 309 LayerImpl* mask = child->mask_layer(); | 323 LayerImpl* mask = child->mask_layer(); |
| 310 | 324 |
| 311 // Verify the draw properties are valid. | 325 // Verify the draw properties are valid. |
| 312 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); | 326 EXPECT_TRUE(root->IsDrawnRenderSurfaceLayerListMember()); |
| 313 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); | 327 EXPECT_TRUE(child->IsDrawnRenderSurfaceLayerListMember()); |
| 314 EXPECT_TRUE(child->has_render_surface()); | 328 EXPECT_TRUE(child->has_render_surface()); |
| 315 EXPECT_EQ(child->render_surface(), child->render_target()); | 329 EXPECT_EQ(child->render_surface(), child->render_target()); |
| 316 | 330 |
| 317 // No occlusion from on child, which is part of the replica. | 331 // No occlusion from on child, which is part of the replica. |
| 318 EXPECT_OCCLUSION_EQ(Occlusion(), | 332 EXPECT_OCCLUSION_EQ(Occlusion(), |
| 319 child->draw_properties().occlusion_in_content_space); | 333 child->draw_properties().occlusion_in_content_space); |
| 320 // Occlusion on the surface is okay. | 334 // Occlusion on the surface is okay. |
| 321 EXPECT_OCCLUSION_EQ( | 335 EXPECT_OCCLUSION_EQ( |
| 322 Occlusion(surface->draw_transform(), SimpleEnclosedRegion(), | 336 Occlusion(surface->draw_transform(), SimpleEnclosedRegion(), |
| 323 SimpleEnclosedRegion(gfx::Rect(13, 9, 10, 11))), | 337 SimpleEnclosedRegion(gfx::Rect(13, 9, 10, 11))), |
| 324 surface->occlusion_in_content_space()); | 338 surface->occlusion_in_content_space()); |
| 325 // No occlusion on the replica'd mask. | 339 // No occlusion on the replica'd mask. |
| 326 EXPECT_OCCLUSION_EQ(Occlusion(), | 340 EXPECT_OCCLUSION_EQ(Occlusion(), |
| 327 mask->draw_properties().occlusion_in_content_space); | 341 mask->draw_properties().occlusion_in_content_space); |
| 328 EndTest(); | 342 EndTest(); |
| 329 } | 343 } |
| 330 | 344 |
| 331 void AfterTest() override {} | 345 void AfterTest() override {} |
| 332 | 346 |
| 347 private: | |
| 333 FakeContentLayerClient client_; | 348 FakeContentLayerClient client_; |
| 349 Layer* child_; | |
|
ajuma
2016/04/20 21:40:52
scoped_refptr
sunxd
2016/04/21 17:31:16
Done.
| |
| 334 }; | 350 }; |
| 335 | 351 |
| 336 SINGLE_AND_MULTI_THREAD_TEST_F( | 352 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 337 LayerTreeHostOcclusionTestDrawPropertiesInsideReplica); | 353 LayerTreeHostOcclusionTestDrawPropertiesInsideReplica); |
| 338 | 354 |
| 339 } // namespace | 355 } // namespace |
| 340 } // namespace cc | 356 } // namespace cc |
| OLD | NEW |