| 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 <set> | 10 #include <set> |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | 142 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); |
| 143 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 143 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 144 child->screen_space_transform()); | 144 child->screen_space_transform()); |
| 145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 146 grand_child->draw_transform()); | 146 grand_child->draw_transform()); |
| 147 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 147 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 148 grand_child->screen_space_transform()); | 148 grand_child->screen_space_transform()); |
| 149 } | 149 } |
| 150 | 150 |
| 151 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { | 151 TEST_F(LayerTreeHostCommonTest, |
| 152 ScreenSpaceTransformOfSkippedLayersWithHandlers) { |
| 153 // Even for layers that are skipped, we need to compute the correct screen |
| 154 // space transform because it is used during hit testing. |
| 152 LayerImpl* parent = root_layer(); | 155 LayerImpl* parent = root_layer(); |
| 153 LayerImpl* child = AddChild<LayerImpl>(parent); | 156 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 154 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 157 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 155 child->SetDrawsContent(true); | 158 child->SetDrawsContent(true); |
| 156 grand_child->SetDrawsContent(true); | 159 grand_child->SetDrawsContent(true); |
| 157 | 160 |
| 158 gfx::Transform identity_matrix; | 161 gfx::Transform identity_matrix; |
| 159 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 162 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 160 gfx::PointF(), gfx::Size(100, 100), true, false); | 163 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 161 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 164 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
| 162 gfx::PointF(10, 10), gfx::Size(100, 100), true, | 165 gfx::PointF(10, 10), gfx::Size(100, 100), true, |
| 163 false); | 166 false); |
| 164 // This would have previously caused us to skip our subtree, but this would be | 167 // This will cause the subtree to be skipped. |
| 165 // wrong; we need up-to-date draw properties to do hit testing on the layers | |
| 166 // with handlers. | |
| 167 child->SetOpacity(0.f); | 168 child->SetOpacity(0.f); |
| 168 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | 169 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), |
| 169 gfx::PointF(10, 10), gfx::Size(100, 100), true, | 170 gfx::PointF(10, 10), gfx::Size(100, 100), true, |
| 170 false); | 171 false); |
| 171 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 172 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
| 172 | 173 |
| 173 ExecuteCalculateDrawProperties(parent); | 174 ExecuteCalculateDrawProperties(parent); |
| 174 | 175 |
| 175 EXPECT_TRUE(child->has_render_surface()); | 176 EXPECT_TRUE(child->has_render_surface()); |
| 176 EXPECT_FALSE(grand_child->has_render_surface()); | 177 EXPECT_FALSE(grand_child->has_render_surface()); |
| 177 // Check that we've computed draw properties for the subtree rooted at | 178 // Check that we've computed draw properties for the subtree rooted at |
| 178 // |child|. | 179 // |child|. |
| 179 EXPECT_TRUE(child->draw_properties().target_space_transform.IsIdentity()); | 180 EXPECT_FALSE(child->render_surface()->screen_space_transform().IsIdentity()); |
| 180 EXPECT_FALSE(child->render_surface()->draw_transform().IsIdentity()); | 181 EXPECT_FALSE(grand_child->ScreenSpaceTransform().IsIdentity()); |
| 181 EXPECT_FALSE( | |
| 182 grand_child->draw_properties().target_space_transform.IsIdentity()); | |
| 183 } | 182 } |
| 184 | 183 |
| 185 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { | 184 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { |
| 186 // Tests that effect tree node gets a valid transform id when a layer | 185 // Tests that effect tree node gets a valid transform id when a layer |
| 187 // has opacity but doesn't create a render surface. | 186 // has opacity but doesn't create a render surface. |
| 188 LayerImpl* parent = root_layer(); | 187 LayerImpl* parent = root_layer(); |
| 189 LayerImpl* child = AddChild<LayerImpl>(parent); | 188 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 190 child->SetDrawsContent(true); | 189 child->SetDrawsContent(true); |
| 191 | 190 |
| 192 gfx::Transform identity_matrix; | 191 gfx::Transform identity_matrix; |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 1291 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 1293 gfx::PointF(), gfx::Size(10, 10), true, false, | 1292 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1294 true); | 1293 true); |
| 1295 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), | 1294 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), |
| 1296 gfx::PointF(), gfx::Size(10, 10), true, false, | 1295 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1297 true); | 1296 true); |
| 1298 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 1297 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
| 1299 gfx::PointF(), gfx::Size(10, 10), true, false, | 1298 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1300 false); | 1299 false); |
| 1301 render_surface1->SetOpacity(0.f); | 1300 render_surface1->SetOpacity(0.f); |
| 1301 render_surface1->SetDrawsContent(true); |
| 1302 child->SetDrawsContent(true); |
| 1302 FilterOperations filters; | 1303 FilterOperations filters; |
| 1303 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); | 1304 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); |
| 1304 render_surface1->SetBackgroundFilters(filters); | 1305 render_surface1->SetBackgroundFilters(filters); |
| 1305 | 1306 |
| 1306 LayerImplList render_surface_layer_list; | 1307 LayerImplList render_surface_layer_list; |
| 1307 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 1308 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 1308 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1309 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1309 parent, parent->bounds(), &render_surface_layer_list, | 1310 parent, parent->bounds(), &render_surface_layer_list, |
| 1310 parent->layer_tree_impl()->current_render_surface_list_id()); | 1311 parent->layer_tree_impl()->current_render_surface_list_id()); |
| 1311 inputs.can_adjust_raster_scales = true; | 1312 inputs.can_adjust_raster_scales = true; |
| (...skipping 4025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5337 gfx::PointF(), gfx::Size(40, 40), true, false, | 5338 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 5338 false); | 5339 false); |
| 5339 child->SetDrawsContent(true); | 5340 child->SetDrawsContent(true); |
| 5340 | 5341 |
| 5341 scoped_ptr<LayerImpl> grand_child = | 5342 scoped_ptr<LayerImpl> grand_child = |
| 5342 LayerImpl::Create(host_impl.pending_tree(), 3); | 5343 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 5343 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 5344 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
| 5344 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5345 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5345 true, false, false); | 5346 true, false, false); |
| 5346 grand_child->SetDrawsContent(true); | 5347 grand_child->SetDrawsContent(true); |
| 5347 grand_child->SetHideLayerAndSubtree(true); | 5348 // Setting opacity to 0 will hide the subtree. |
| 5349 grand_child->SetOpacity(0.f); |
| 5348 | 5350 |
| 5349 child->AddChild(std::move(grand_child)); | 5351 child->AddChild(std::move(grand_child)); |
| 5350 root->AddChild(std::move(child)); | 5352 root->AddChild(std::move(child)); |
| 5351 root->SetHasRenderSurface(true); | 5353 root->SetHasRenderSurface(true); |
| 5352 | 5354 |
| 5353 LayerImplList render_surface_layer_list; | 5355 LayerImplList render_surface_layer_list; |
| 5354 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5356 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5355 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5357 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5356 root.get(), root->bounds(), &render_surface_layer_list, | 5358 root.get(), root->bounds(), &render_surface_layer_list, |
| 5357 root->layer_tree_impl()->current_render_surface_list_id()); | 5359 root->layer_tree_impl()->current_render_surface_list_id()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5379 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5381 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 5380 gfx::PointF(), gfx::Size(50, 50), true, false, | 5382 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5381 true); | 5383 true); |
| 5382 root->SetDrawsContent(true); | 5384 root->SetDrawsContent(true); |
| 5383 | 5385 |
| 5384 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); | 5386 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
| 5385 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | 5387 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| 5386 gfx::PointF(), gfx::Size(40, 40), true, false, | 5388 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 5387 false); | 5389 false); |
| 5388 child->SetDrawsContent(true); | 5390 child->SetDrawsContent(true); |
| 5389 child->SetHideLayerAndSubtree(true); | 5391 // Setting opacity to 0 will hide the subtree. |
| 5392 child->SetOpacity(0.f); |
| 5390 | 5393 |
| 5391 scoped_ptr<LayerImpl> grand_child = | 5394 scoped_ptr<LayerImpl> grand_child = |
| 5392 LayerImpl::Create(host_impl.pending_tree(), 3); | 5395 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 5393 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 5396 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
| 5394 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5397 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5395 true, false, false); | 5398 true, false, false); |
| 5396 grand_child->SetDrawsContent(true); | 5399 grand_child->SetDrawsContent(true); |
| 5397 | 5400 |
| 5398 child->AddChild(std::move(grand_child)); | 5401 child->AddChild(std::move(grand_child)); |
| 5399 root->AddChild(std::move(child)); | 5402 root->AddChild(std::move(child)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5455 LayerImpl* copy_layer = copy_request.get(); | 5458 LayerImpl* copy_layer = copy_request.get(); |
| 5456 | 5459 |
| 5457 scoped_ptr<LayerImpl> copy_child = | 5460 scoped_ptr<LayerImpl> copy_child = |
| 5458 LayerImpl::Create(host_impl.pending_tree(), 5); | 5461 LayerImpl::Create(host_impl.pending_tree(), 5); |
| 5459 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, | 5462 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
| 5460 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5463 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 5461 true, false, false); | 5464 true, false, false); |
| 5462 copy_child->SetDrawsContent(true); | 5465 copy_child->SetDrawsContent(true); |
| 5463 LayerImpl* copy_child_layer = copy_child.get(); | 5466 LayerImpl* copy_child_layer = copy_child.get(); |
| 5464 | 5467 |
| 5468 scoped_ptr<LayerImpl> copy_grand_child = |
| 5469 LayerImpl::Create(host_impl.pending_tree(), 6); |
| 5470 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix, |
| 5471 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 5472 true, false, false); |
| 5473 copy_child->SetDrawsContent(true); |
| 5474 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); |
| 5475 |
| 5465 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = | 5476 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = |
| 5466 LayerImpl::Create(host_impl.pending_tree(), 6); | 5477 LayerImpl::Create(host_impl.pending_tree(), 7); |
| 5467 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), | 5478 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), |
| 5468 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5479 identity_matrix, gfx::Point3F(), gfx::PointF(), |
| 5469 gfx::Size(40, 40), true, false, false); | 5480 gfx::Size(40, 40), true, false, false); |
| 5470 copy_grand_parent_sibling_before->SetDrawsContent(true); | 5481 copy_grand_parent_sibling_before->SetDrawsContent(true); |
| 5471 LayerImpl* copy_grand_parent_sibling_before_layer = | 5482 LayerImpl* copy_grand_parent_sibling_before_layer = |
| 5472 copy_grand_parent_sibling_before.get(); | 5483 copy_grand_parent_sibling_before.get(); |
| 5473 | 5484 |
| 5474 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = | 5485 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = |
| 5475 LayerImpl::Create(host_impl.pending_tree(), 7); | 5486 LayerImpl::Create(host_impl.pending_tree(), 8); |
| 5476 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), | 5487 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), |
| 5477 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5488 identity_matrix, gfx::Point3F(), gfx::PointF(), |
| 5478 gfx::Size(40, 40), true, false, false); | 5489 gfx::Size(40, 40), true, false, false); |
| 5479 copy_grand_parent_sibling_after->SetDrawsContent(true); | 5490 copy_grand_parent_sibling_after->SetDrawsContent(true); |
| 5480 LayerImpl* copy_grand_parent_sibling_after_layer = | 5491 LayerImpl* copy_grand_parent_sibling_after_layer = |
| 5481 copy_grand_parent_sibling_after.get(); | 5492 copy_grand_parent_sibling_after.get(); |
| 5482 | 5493 |
| 5494 copy_child->AddChild(std::move(copy_grand_child)); |
| 5483 copy_request->AddChild(std::move(copy_child)); | 5495 copy_request->AddChild(std::move(copy_child)); |
| 5484 copy_parent->AddChild(std::move(copy_request)); | 5496 copy_parent->AddChild(std::move(copy_request)); |
| 5485 copy_grand_parent->AddChild(std::move(copy_parent)); | 5497 copy_grand_parent->AddChild(std::move(copy_parent)); |
| 5486 root->AddChild(std::move(copy_grand_parent_sibling_before)); | 5498 root->AddChild(std::move(copy_grand_parent_sibling_before)); |
| 5487 root->AddChild(std::move(copy_grand_parent)); | 5499 root->AddChild(std::move(copy_grand_parent)); |
| 5488 root->AddChild(std::move(copy_grand_parent_sibling_after)); | 5500 root->AddChild(std::move(copy_grand_parent_sibling_after)); |
| 5489 | 5501 |
| 5490 // Hide the copy_grand_parent and its subtree. But make a copy request in that | 5502 // Hide the copy_grand_parent and its subtree. But make a copy request in that |
| 5491 // hidden subtree on copy_layer. | 5503 // hidden subtree on copy_layer. Also hide the copy grand child and its |
| 5492 copy_grand_parent_layer->SetHideLayerAndSubtree(true); | 5504 // subtree. |
| 5493 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); | 5505 copy_grand_parent_layer->SetOpacity(0.f); |
| 5494 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); | 5506 copy_grand_parent_sibling_before_layer->SetOpacity(0.f); |
| 5507 copy_grand_parent_sibling_after_layer->SetOpacity(0.f); |
| 5508 copy_grand_child_layer->SetOpacity(0.f); |
| 5495 | 5509 |
| 5496 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; | 5510 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
| 5497 copy_requests.push_back( | 5511 copy_requests.push_back( |
| 5498 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5512 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 5499 copy_layer->PassCopyRequests(©_requests); | 5513 copy_layer->PassCopyRequests(©_requests); |
| 5500 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5514 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
| 5501 | 5515 |
| 5502 LayerImplList render_surface_layer_list; | 5516 LayerImplList render_surface_layer_list; |
| 5503 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5517 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5504 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5518 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5505 root.get(), root->bounds(), &render_surface_layer_list, | 5519 root.get(), root->bounds(), &render_surface_layer_list, |
| 5506 root->layer_tree_impl()->current_render_surface_list_id()); | 5520 root->layer_tree_impl()->current_render_surface_list_id()); |
| 5507 inputs.can_adjust_raster_scales = true; | 5521 inputs.can_adjust_raster_scales = true; |
| 5508 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5522 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 5509 | 5523 |
| 5510 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | 5524 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); |
| 5511 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5525 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); |
| 5512 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5526 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); |
| 5513 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); | 5527 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); |
| 5514 | 5528 |
| 5515 // We should have three render surfaces, one for the root, one for the parent | 5529 // We should have four render surfaces, one for the root, one for the grand |
| 5530 // parent since it has opacity and two drawing descendants, one for the parent |
| 5516 // since it owns a surface, and one for the copy_layer. | 5531 // since it owns a surface, and one for the copy_layer. |
| 5517 ASSERT_EQ(3u, render_surface_layer_list.size()); | 5532 ASSERT_EQ(4u, render_surface_layer_list.size()); |
| 5518 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 5533 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); |
| 5519 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(1)->id()); | 5534 EXPECT_EQ(copy_grand_parent_layer->id(), |
| 5520 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(2)->id()); | 5535 render_surface_layer_list.at(1)->id()); |
| 5536 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); |
| 5537 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id()); |
| 5521 | 5538 |
| 5522 // The root render surface should have 2 contributing layers. The | 5539 // The root render surface should have 2 contributing layers. |
| 5523 // copy_grand_parent is hidden along with its siblings, but the copy_parent | |
| 5524 // will appear since something in its subtree needs to be drawn for a copy | |
| 5525 // request. | |
| 5526 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5540 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 5527 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5541 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); |
| 5528 EXPECT_EQ(copy_parent_layer->id(), | 5542 EXPECT_EQ(copy_grand_parent_layer->id(), |
| 5529 root->render_surface()->layer_list().at(1)->id()); | 5543 root->render_surface()->layer_list().at(1)->id()); |
| 5530 | 5544 |
| 5531 // Nothing actually draws into the copy parent, so only the copy_layer will | 5545 // Nothing actually draws into the copy parent, so only the copy_layer will |
| 5532 // appear in its list, since it needs to be drawn for the copy request. | 5546 // appear in its list, since it needs to be drawn for the copy request. |
| 5533 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); | 5547 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); |
| 5534 EXPECT_EQ(copy_layer->id(), | 5548 EXPECT_EQ(copy_layer->id(), |
| 5535 copy_parent_layer->render_surface()->layer_list().at(0)->id()); | 5549 copy_layer->render_surface()->layer_list().at(0)->id()); |
| 5536 | 5550 |
| 5537 // The copy_layer's render surface should have two contributing layers. | 5551 // The copy_layer's render surface should have two contributing layers. |
| 5538 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); | 5552 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); |
| 5539 EXPECT_EQ(copy_layer->id(), | 5553 EXPECT_EQ(copy_layer->id(), |
| 5540 copy_layer->render_surface()->layer_list().at(0)->id()); | 5554 copy_layer->render_surface()->layer_list().at(0)->id()); |
| 5541 EXPECT_EQ(copy_child_layer->id(), | 5555 EXPECT_EQ(copy_child_layer->id(), |
| 5542 copy_layer->render_surface()->layer_list().at(1)->id()); | 5556 copy_layer->render_surface()->layer_list().at(1)->id()); |
| 5557 |
| 5558 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, |
| 5559 // but the copy_layer and copy_child should be drawn for the copy request. |
| 5560 // copy grand child should not be drawn as its hidden even in the copy |
| 5561 // request. |
| 5562 EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree; |
| 5563 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); |
| 5564 EXPECT_FALSE(node->data.is_drawn); |
| 5565 node = tree.Node(copy_parent_layer->effect_tree_index()); |
| 5566 EXPECT_FALSE(node->data.is_drawn); |
| 5567 node = tree.Node(copy_layer->effect_tree_index()); |
| 5568 EXPECT_TRUE(node->data.is_drawn); |
| 5569 node = tree.Node(copy_child_layer->effect_tree_index()); |
| 5570 EXPECT_TRUE(node->data.is_drawn); |
| 5571 node = tree.Node(copy_grand_child_layer->effect_tree_index()); |
| 5572 EXPECT_FALSE(node->data.is_drawn); |
| 5573 |
| 5574 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its |
| 5575 // actually hidden. |
| 5576 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface()); |
| 5543 } | 5577 } |
| 5544 | 5578 |
| 5545 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 5579 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
| 5546 FakeImplTaskRunnerProvider task_runner_provider; | 5580 FakeImplTaskRunnerProvider task_runner_provider; |
| 5547 TestSharedBitmapManager shared_bitmap_manager; | 5581 TestSharedBitmapManager shared_bitmap_manager; |
| 5548 TestTaskGraphRunner task_graph_runner; | 5582 TestTaskGraphRunner task_graph_runner; |
| 5549 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5583 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5550 &task_graph_runner); | 5584 &task_graph_runner); |
| 5551 host_impl.CreatePendingTree(); | 5585 host_impl.CreatePendingTree(); |
| 5552 const gfx::Transform identity_matrix; | 5586 const gfx::Transform identity_matrix; |
| (...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8634 // remain empty. | 8668 // remain empty. |
| 8635 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); | 8669 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); |
| 8636 gfx::Transform singular; | 8670 gfx::Transform singular; |
| 8637 singular.matrix().set(0, 0, 0); | 8671 singular.matrix().set(0, 0, 0); |
| 8638 | 8672 |
| 8639 child->SetTransform(singular); | 8673 child->SetTransform(singular); |
| 8640 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8674 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8641 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); | 8675 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); |
| 8642 child->SetTransform(identity); | 8676 child->SetTransform(identity); |
| 8643 | 8677 |
| 8644 child->SetHideLayerAndSubtree(true); | 8678 // Set opacity to 0 to hide subtree. |
| 8679 child->SetOpacity(0.f); |
| 8645 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8680 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8646 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); | 8681 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); |
| 8647 child->SetHideLayerAndSubtree(false); | 8682 child->SetOpacity(1.f); |
| 8648 | 8683 |
| 8649 gfx::Transform zero_z_scale; | 8684 gfx::Transform zero_z_scale; |
| 8650 zero_z_scale.Scale3d(1, 1, 0); | 8685 zero_z_scale.Scale3d(1, 1, 0); |
| 8651 child->SetTransform(zero_z_scale); | 8686 child->SetTransform(zero_z_scale); |
| 8652 | 8687 |
| 8653 // Add a transform animation with a start delay. Now, even though |child| has | 8688 // Add a transform animation with a start delay. Now, even though |child| has |
| 8654 // a singular transform, the subtree should still get processed. | 8689 // a singular transform, the subtree should still get processed. |
| 8655 int animation_id = 0; | 8690 int animation_id = 0; |
| 8656 scoped_ptr<Animation> animation = Animation::Create( | 8691 scoped_ptr<Animation> animation = Animation::Create( |
| 8657 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), | 8692 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8675 child->RemoveAnimation(animation_id); | 8710 child->RemoveAnimation(animation_id); |
| 8676 } | 8711 } |
| 8677 child->SetTransform(identity); | 8712 child->SetTransform(identity); |
| 8678 child->SetOpacity(0.f); | 8713 child->SetOpacity(0.f); |
| 8679 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8714 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8680 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); | 8715 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); |
| 8681 | 8716 |
| 8682 // Now, even though child has zero opacity, we will configure |grandchild| and | 8717 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8683 // |greatgrandchild| in several ways that should force the subtree to be | 8718 // |greatgrandchild| in several ways that should force the subtree to be |
| 8684 // processed anyhow. | 8719 // processed anyhow. |
| 8685 greatgrandchild->RequestCopyOfOutput( | 8720 grandchild->RequestCopyOfOutput( |
| 8686 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8721 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
| 8687 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8722 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8688 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); | 8723 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); |
| 8689 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); | 8724 greatgrandchild->set_visible_rect_from_property_trees(gfx::Rect()); |
| 8690 | 8725 |
| 8691 // Add an opacity animation with a start delay. | 8726 // Add an opacity animation with a start delay. |
| 8692 animation_id = 1; | 8727 animation_id = 1; |
| 8693 animation = Animation::Create( | 8728 animation = Animation::Create( |
| 8694 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8729 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 8695 animation_id, 1, Animation::OPACITY); | 8730 animation_id, 1, Animation::OPACITY); |
| 8696 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 8731 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
| 8697 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8732 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8698 if (layer_settings().use_compositor_animation_timelines) { | 8733 if (layer_settings().use_compositor_animation_timelines) { |
| 8699 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), | 8734 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 8727 | 8762 |
| 8728 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8763 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8729 gfx::PointF(), gfx::Size(100, 100), true, false, | 8764 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 8730 true); | 8765 true); |
| 8731 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | 8766 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), |
| 8732 gfx::PointF(), gfx::Size(10, 10), true, false, | 8767 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 8733 false); | 8768 false); |
| 8734 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), | 8769 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), |
| 8735 gfx::PointF(), gfx::Size(10, 10), true, false, | 8770 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 8736 false); | 8771 false); |
| 8737 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), | |
| 8738 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 8739 true); | |
| 8740 | 8772 |
| 8741 LayerImpl* child_ptr = child.get(); | 8773 LayerImpl* child_ptr = child.get(); |
| 8742 LayerImpl* grandchild_ptr = grandchild.get(); | 8774 LayerImpl* grandchild_ptr = grandchild.get(); |
| 8743 LayerImpl* greatgrandchild_ptr = greatgrandchild.get(); | |
| 8744 | 8775 |
| 8745 grandchild->AddChild(std::move(greatgrandchild)); | |
| 8746 child->AddChild(std::move(grandchild)); | 8776 child->AddChild(std::move(grandchild)); |
| 8747 root->AddChild(std::move(child)); | 8777 root->AddChild(std::move(child)); |
| 8748 | 8778 |
| 8749 // Check the non-skipped case. | 8779 // Check the non-skipped case. |
| 8750 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8780 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8751 EXPECT_EQ(gfx::Rect(10, 10), | 8781 EXPECT_EQ(gfx::Rect(10, 10), |
| 8752 grandchild_ptr->visible_rect_from_property_trees()); | 8782 grandchild_ptr->visible_rect_from_property_trees()); |
| 8753 | 8783 |
| 8754 // Now we will reset the visible rect from property trees for the grandchild, | 8784 // Now we will reset the visible rect from property trees for the grandchild, |
| 8755 // and we will configure |child| in several ways that should force the subtree | 8785 // and we will configure |child| in several ways that should force the subtree |
| 8756 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8786 // to be skipped. The visible content rect for |grandchild| should, therefore, |
| 8757 // remain empty. | 8787 // remain empty. |
| 8758 grandchild_ptr->set_visible_rect_from_property_trees(gfx::Rect()); | 8788 grandchild_ptr->set_visible_rect_from_property_trees(gfx::Rect()); |
| 8759 gfx::Transform singular; | 8789 gfx::Transform singular; |
| 8760 singular.matrix().set(0, 0, 0); | 8790 singular.matrix().set(0, 0, 0); |
| 8761 | 8791 |
| 8762 child_ptr->SetTransform(singular); | 8792 child_ptr->SetTransform(singular); |
| 8763 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8793 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8764 EXPECT_EQ(gfx::Rect(0, 0), | 8794 EXPECT_EQ(gfx::Rect(0, 0), |
| 8765 grandchild_ptr->visible_rect_from_property_trees()); | 8795 grandchild_ptr->visible_rect_from_property_trees()); |
| 8766 child_ptr->SetTransform(identity); | 8796 child_ptr->SetTransform(identity); |
| 8767 | 8797 |
| 8768 child_ptr->SetHideLayerAndSubtree(true); | |
| 8769 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | |
| 8770 EXPECT_EQ(gfx::Rect(0, 0), | |
| 8771 grandchild_ptr->visible_rect_from_property_trees()); | |
| 8772 child_ptr->SetHideLayerAndSubtree(false); | |
| 8773 | |
| 8774 child_ptr->SetOpacity(0.f); | 8798 child_ptr->SetOpacity(0.f); |
| 8775 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8799 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8776 EXPECT_EQ(gfx::Rect(0, 0), | 8800 EXPECT_EQ(gfx::Rect(0, 0), |
| 8777 grandchild_ptr->visible_rect_from_property_trees()); | 8801 grandchild_ptr->visible_rect_from_property_trees()); |
| 8778 | 8802 |
| 8779 // Now, even though child has zero opacity, we will configure |grandchild| and | 8803 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8780 // |greatgrandchild| in several ways that should force the subtree to be | 8804 // |greatgrandchild| in several ways that should force the subtree to be |
| 8781 // processed anyhow. | 8805 // processed anyhow. |
| 8782 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 8806 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
| 8783 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 8807 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
| 8784 | 8808 |
| 8785 greatgrandchild_ptr->PassCopyRequests(&requests); | 8809 grandchild_ptr->PassCopyRequests(&requests); |
| 8786 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8810 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8787 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8811 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8788 EXPECT_EQ(gfx::Rect(10, 10), | 8812 EXPECT_EQ(gfx::Rect(10, 10), |
| 8789 grandchild_ptr->visible_rect_from_property_trees()); | 8813 grandchild_ptr->visible_rect_from_property_trees()); |
| 8790 } | 8814 } |
| 8791 | 8815 |
| 8792 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8816 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
| 8793 gfx::Transform identity; | 8817 gfx::Transform identity; |
| 8794 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 8818 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 8795 FakeContentLayerClient client; | 8819 FakeContentLayerClient client; |
| 8796 client.set_bounds(root->bounds()); | 8820 client.set_bounds(root->bounds()); |
| 8797 scoped_refptr<LayerWithForcedDrawsContent> child = | 8821 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 8798 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); | 8822 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 8799 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8823 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8800 gfx::PointF(), gfx::Size(100, 100), true, false); | 8824 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 8801 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | 8825 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), |
| 8802 gfx::PointF(), gfx::Size(10, 10), true, false); | 8826 gfx::PointF(), gfx::Size(10, 10), true, false); |
| 8803 root->AddChild(child); | 8827 root->AddChild(child); |
| 8804 | 8828 |
| 8805 host()->SetRootLayer(root); | 8829 host()->SetRootLayer(root); |
| 8806 | 8830 |
| 8807 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8831 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8808 EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees()); | 8832 EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees()); |
| 8809 child->set_visible_rect_from_property_trees(gfx::Rect()); | 8833 child->set_visible_rect_from_property_trees(gfx::Rect()); |
| 8810 | 8834 |
| 8811 child->SetHideLayerAndSubtree(true); | 8835 // Set opacity to 0 to hide subtree. |
| 8836 child->SetOpacity(0.f); |
| 8812 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8837 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8813 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); | 8838 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); |
| 8814 child->SetHideLayerAndSubtree(false); | 8839 child->SetOpacity(1.f); |
| 8815 | 8840 |
| 8816 child->SetBounds(gfx::Size()); | 8841 child->SetBounds(gfx::Size()); |
| 8817 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8842 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8818 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); | 8843 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); |
| 8819 child->SetBounds(gfx::Size(10, 10)); | 8844 child->SetBounds(gfx::Size(10, 10)); |
| 8820 | 8845 |
| 8821 gfx::Transform rotate; | 8846 gfx::Transform rotate; |
| 8822 child->SetDoubleSided(false); | 8847 child->SetDoubleSided(false); |
| 8823 rotate.RotateAboutXAxis(180.f); | 8848 rotate.RotateAboutXAxis(180.f); |
| 8824 child->SetTransform(rotate); | 8849 child->SetTransform(rotate); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9367 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 9392 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 9368 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 9393 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 9369 | 9394 |
| 9370 const gfx::Transform identity_matrix; | 9395 const gfx::Transform identity_matrix; |
| 9371 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9396 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9372 gfx::PointF(), gfx::Size(30, 30), true, false, | 9397 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9373 true); | 9398 true); |
| 9374 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | 9399 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), |
| 9375 gfx::PointF(), gfx::Size(30, 30), true, false, | 9400 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9376 true); | 9401 true); |
| 9377 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | 9402 gfx::Transform translation; |
| 9403 translation.Translate(10, 10); |
| 9404 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), |
| 9378 gfx::PointF(), gfx::Size(20, 20), true, false, | 9405 gfx::PointF(), gfx::Size(20, 20), true, false, |
| 9379 false); | 9406 false); |
| 9380 | 9407 |
| 9381 render_surface->SetMasksToBounds(true); | 9408 render_surface->SetMasksToBounds(true); |
| 9382 test_layer->SetDrawsContent(true); | 9409 test_layer->SetDrawsContent(true); |
| 9383 test_layer->SetOpacity(0); | 9410 test_layer->SetOpacity(0); |
| 9384 test_layer->SetHaveWheelEventHandlers(true); | 9411 test_layer->SetHaveWheelEventHandlers(true); |
| 9385 | 9412 |
| 9386 ExecuteCalculateDrawProperties(root); | 9413 ExecuteCalculateDrawProperties(root); |
| 9387 EXPECT_EQ(gfx::Rect(20, 20), test_layer->drawable_content_rect()); | 9414 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform()); |
| 9388 EXPECT_EQ(gfx::RectF(20, 20), | |
| 9389 render_surface->render_surface()->DrawableContentRect()); | |
| 9390 } | 9415 } |
| 9391 | 9416 |
| 9392 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 9417 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
| 9393 LayerImpl* root = root_layer(); | 9418 LayerImpl* root = root_layer(); |
| 9394 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 9419 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 9395 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 9420 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
| 9396 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 9421 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
| 9397 | 9422 |
| 9398 const gfx::Transform identity_matrix; | 9423 const gfx::Transform identity_matrix; |
| 9399 clip_parent->SetMasksToBounds(true); | 9424 clip_parent->SetMasksToBounds(true); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9460 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9485 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9461 gfx::PointF(), gfx::Size(30, 30), true, false, | 9486 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9462 true); | 9487 true); |
| 9463 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), | 9488 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), |
| 9464 gfx::PointF(10, 10), gfx::Size(30, 30), true, | 9489 gfx::PointF(10, 10), gfx::Size(30, 30), true, |
| 9465 false, true); | 9490 false, true); |
| 9466 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), | 9491 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), |
| 9467 gfx::PointF(), gfx::Size(30, 30), true, false, | 9492 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9468 true); | 9493 true); |
| 9469 | 9494 |
| 9470 hidden->SetHideLayerAndSubtree(true); | 9495 // Set opacity to 0 to hide subtree. |
| 9496 hidden->SetOpacity(0.f); |
| 9471 ExecuteCalculateDrawProperties(root); | 9497 ExecuteCalculateDrawProperties(root); |
| 9472 EXPECT_TRUE(test->LayerIsHidden()); | 9498 EXPECT_TRUE(test->IsHidden()); |
| 9473 | 9499 |
| 9474 hidden->SetHideLayerAndSubtree(false); | 9500 hidden->SetOpacity(1.f); |
| 9475 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9501 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9476 ExecuteCalculateDrawProperties(root); | 9502 ExecuteCalculateDrawProperties(root); |
| 9477 EXPECT_FALSE(test->LayerIsHidden()); | 9503 EXPECT_FALSE(test->IsHidden()); |
| 9478 } | 9504 } |
| 9479 | 9505 |
| 9480 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 9506 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
| 9481 LayerImpl* root = root_layer(); | 9507 LayerImpl* root = root_layer(); |
| 9482 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9508 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9483 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 9509 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
| 9484 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 9510 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
| 9485 | 9511 |
| 9486 const gfx::Transform identity_matrix; | 9512 const gfx::Transform identity_matrix; |
| 9487 clip_child->SetClipParent(root); | 9513 clip_child->SetClipParent(root); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9593 bool root_in_rsll = | 9619 bool root_in_rsll = |
| 9594 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); | 9620 std::find(rsll->begin(), rsll->end(), root) != rsll->end(); |
| 9595 EXPECT_TRUE(root_in_rsll); | 9621 EXPECT_TRUE(root_in_rsll); |
| 9596 bool render_surface2_in_rsll = | 9622 bool render_surface2_in_rsll = |
| 9597 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); | 9623 std::find(rsll->begin(), rsll->end(), render_surface2) != rsll->end(); |
| 9598 EXPECT_FALSE(render_surface2_in_rsll); | 9624 EXPECT_FALSE(render_surface2_in_rsll); |
| 9599 } | 9625 } |
| 9600 | 9626 |
| 9601 } // namespace | 9627 } // namespace |
| 9602 } // namespace cc | 9628 } // namespace cc |
| OLD | NEW |