| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | 144 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); |
| 145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 146 child->screen_space_transform()); | 146 child->screen_space_transform()); |
| 147 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 147 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 148 grand_child->draw_transform()); | 148 grand_child->draw_transform()); |
| 149 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 149 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 150 grand_child->screen_space_transform()); | 150 grand_child->screen_space_transform()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 TEST_F(LayerTreeHostCommonTest, DoNotSkipLayersWithHandlers) { | 153 TEST_F(LayerTreeHostCommonTest, |
| 154 ScreenSpaceTransformOfSkippedLayersWithHandlers) { |
| 155 // Even for layers that are skipped, we need to compute the correct screen |
| 156 // space transform because it is used during hit testing. |
| 154 LayerImpl* parent = root_layer(); | 157 LayerImpl* parent = root_layer(); |
| 155 LayerImpl* child = AddChild<LayerImpl>(parent); | 158 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 156 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 159 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 157 child->SetDrawsContent(true); | 160 child->SetDrawsContent(true); |
| 158 grand_child->SetDrawsContent(true); | 161 grand_child->SetDrawsContent(true); |
| 159 | 162 |
| 160 gfx::Transform identity_matrix; | 163 gfx::Transform identity_matrix; |
| 161 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 164 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 162 gfx::PointF(), gfx::Size(100, 100), true, false); | 165 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 163 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 166 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
| 164 gfx::PointF(10, 10), gfx::Size(100, 100), true, | 167 gfx::PointF(10, 10), gfx::Size(100, 100), true, |
| 165 false); | 168 false); |
| 166 // This would have previously caused us to skip our subtree, but this would be | 169 // This will cause the subtree to be skipped. |
| 167 // wrong; we need up-to-date draw properties to do hit testing on the layers | |
| 168 // with handlers. | |
| 169 child->SetOpacity(0.f); | 170 child->SetOpacity(0.f); |
| 170 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | 171 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), |
| 171 gfx::PointF(10, 10), gfx::Size(100, 100), true, | 172 gfx::PointF(10, 10), gfx::Size(100, 100), true, |
| 172 false); | 173 false); |
| 173 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 174 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
| 174 | 175 |
| 175 ExecuteCalculateDrawProperties(parent); | 176 ExecuteCalculateDrawProperties(parent); |
| 176 | 177 |
| 177 EXPECT_TRUE(child->has_render_surface()); | 178 EXPECT_TRUE(child->has_render_surface()); |
| 178 EXPECT_FALSE(grand_child->has_render_surface()); | 179 EXPECT_FALSE(grand_child->has_render_surface()); |
| 179 // Check that we've computed draw properties for the subtree rooted at | 180 // Check that we've computed draw properties for the subtree rooted at |
| 180 // |child|. | 181 // |child|. |
| 181 EXPECT_TRUE(child->draw_properties().target_space_transform.IsIdentity()); | 182 EXPECT_FALSE(child->render_surface()->screen_space_transform().IsIdentity()); |
| 182 EXPECT_FALSE(child->render_surface()->draw_transform().IsIdentity()); | 183 EXPECT_FALSE(grand_child->ScreenSpaceTransform().IsIdentity()); |
| 183 EXPECT_FALSE( | |
| 184 grand_child->draw_properties().target_space_transform.IsIdentity()); | |
| 185 } | 184 } |
| 186 | 185 |
| 187 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { | 186 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { |
| 188 // Tests that effect tree node gets a valid transform id when a layer | 187 // Tests that effect tree node gets a valid transform id when a layer |
| 189 // has opacity but doesn't create a render surface. | 188 // has opacity but doesn't create a render surface. |
| 190 LayerImpl* parent = root_layer(); | 189 LayerImpl* parent = root_layer(); |
| 191 LayerImpl* child = AddChild<LayerImpl>(parent); | 190 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 192 child->SetDrawsContent(true); | 191 child->SetDrawsContent(true); |
| 193 | 192 |
| 194 gfx::Transform identity_matrix; | 193 gfx::Transform identity_matrix; |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 1333 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 1335 gfx::PointF(), gfx::Size(10, 10), true, false, | 1334 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1336 true); | 1335 true); |
| 1337 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), | 1336 SetLayerPropertiesForTesting(render_surface1, identity_matrix, gfx::Point3F(), |
| 1338 gfx::PointF(), gfx::Size(10, 10), true, false, | 1337 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1339 true); | 1338 true); |
| 1340 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | 1339 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
| 1341 gfx::PointF(), gfx::Size(10, 10), true, false, | 1340 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 1342 false); | 1341 false); |
| 1343 render_surface1->SetOpacity(0.f); | 1342 render_surface1->SetOpacity(0.f); |
| 1343 render_surface1->SetDrawsContent(true); |
| 1344 child->SetDrawsContent(true); |
| 1344 FilterOperations filters; | 1345 FilterOperations filters; |
| 1345 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); | 1346 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); |
| 1346 render_surface1->SetBackgroundFilters(filters); | 1347 render_surface1->SetBackgroundFilters(filters); |
| 1347 | 1348 |
| 1348 LayerImplList render_surface_layer_list; | 1349 LayerImplList render_surface_layer_list; |
| 1349 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 1350 parent->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 1350 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1351 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1351 parent, parent->bounds(), &render_surface_layer_list, | 1352 parent, parent->bounds(), &render_surface_layer_list, |
| 1352 parent->layer_tree_impl()->current_render_surface_list_id()); | 1353 parent->layer_tree_impl()->current_render_surface_list_id()); |
| 1353 inputs.can_adjust_raster_scales = true; | 1354 inputs.can_adjust_raster_scales = true; |
| (...skipping 4025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5379 gfx::PointF(), gfx::Size(40, 40), true, false, | 5380 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 5380 false); | 5381 false); |
| 5381 child->SetDrawsContent(true); | 5382 child->SetDrawsContent(true); |
| 5382 | 5383 |
| 5383 scoped_ptr<LayerImpl> grand_child = | 5384 scoped_ptr<LayerImpl> grand_child = |
| 5384 LayerImpl::Create(host_impl.pending_tree(), 3); | 5385 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 5385 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 5386 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
| 5386 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5387 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5387 true, false, false); | 5388 true, false, false); |
| 5388 grand_child->SetDrawsContent(true); | 5389 grand_child->SetDrawsContent(true); |
| 5389 grand_child->SetHideLayerAndSubtree(true); | 5390 // Setting opacity to 0 will hide the subtree. |
| 5391 grand_child->SetOpacity(0.f); |
| 5390 | 5392 |
| 5391 child->AddChild(std::move(grand_child)); | 5393 child->AddChild(std::move(grand_child)); |
| 5392 root->AddChild(std::move(child)); | 5394 root->AddChild(std::move(child)); |
| 5393 root->SetHasRenderSurface(true); | 5395 root->SetHasRenderSurface(true); |
| 5394 | 5396 |
| 5395 LayerImplList render_surface_layer_list; | 5397 LayerImplList render_surface_layer_list; |
| 5396 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5398 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5397 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5399 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5398 root.get(), root->bounds(), &render_surface_layer_list, | 5400 root.get(), root->bounds(), &render_surface_layer_list, |
| 5399 root->layer_tree_impl()->current_render_surface_list_id()); | 5401 root->layer_tree_impl()->current_render_surface_list_id()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5421 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 5423 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
| 5422 gfx::PointF(), gfx::Size(50, 50), true, false, | 5424 gfx::PointF(), gfx::Size(50, 50), true, false, |
| 5423 true); | 5425 true); |
| 5424 root->SetDrawsContent(true); | 5426 root->SetDrawsContent(true); |
| 5425 | 5427 |
| 5426 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); | 5428 scoped_ptr<LayerImpl> child = LayerImpl::Create(host_impl.pending_tree(), 2); |
| 5427 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), | 5429 SetLayerPropertiesForTesting(child.get(), identity_matrix, gfx::Point3F(), |
| 5428 gfx::PointF(), gfx::Size(40, 40), true, false, | 5430 gfx::PointF(), gfx::Size(40, 40), true, false, |
| 5429 false); | 5431 false); |
| 5430 child->SetDrawsContent(true); | 5432 child->SetDrawsContent(true); |
| 5431 child->SetHideLayerAndSubtree(true); | 5433 // Setting opacity to 0 will hide the subtree. |
| 5434 child->SetOpacity(0.f); |
| 5432 | 5435 |
| 5433 scoped_ptr<LayerImpl> grand_child = | 5436 scoped_ptr<LayerImpl> grand_child = |
| 5434 LayerImpl::Create(host_impl.pending_tree(), 3); | 5437 LayerImpl::Create(host_impl.pending_tree(), 3); |
| 5435 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, | 5438 SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, |
| 5436 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 5439 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
| 5437 true, false, false); | 5440 true, false, false); |
| 5438 grand_child->SetDrawsContent(true); | 5441 grand_child->SetDrawsContent(true); |
| 5439 | 5442 |
| 5440 child->AddChild(std::move(grand_child)); | 5443 child->AddChild(std::move(grand_child)); |
| 5441 root->AddChild(std::move(child)); | 5444 root->AddChild(std::move(child)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5497 LayerImpl* copy_layer = copy_request.get(); | 5500 LayerImpl* copy_layer = copy_request.get(); |
| 5498 | 5501 |
| 5499 scoped_ptr<LayerImpl> copy_child = | 5502 scoped_ptr<LayerImpl> copy_child = |
| 5500 LayerImpl::Create(host_impl.pending_tree(), 5); | 5503 LayerImpl::Create(host_impl.pending_tree(), 5); |
| 5501 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, | 5504 SetLayerPropertiesForTesting(copy_child.get(), identity_matrix, |
| 5502 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), | 5505 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 5503 true, false, false); | 5506 true, false, false); |
| 5504 copy_child->SetDrawsContent(true); | 5507 copy_child->SetDrawsContent(true); |
| 5505 LayerImpl* copy_child_layer = copy_child.get(); | 5508 LayerImpl* copy_child_layer = copy_child.get(); |
| 5506 | 5509 |
| 5510 scoped_ptr<LayerImpl> copy_grand_child = |
| 5511 LayerImpl::Create(host_impl.pending_tree(), 6); |
| 5512 SetLayerPropertiesForTesting(copy_grand_child.get(), identity_matrix, |
| 5513 gfx::Point3F(), gfx::PointF(), gfx::Size(20, 20), |
| 5514 true, false, false); |
| 5515 copy_child->SetDrawsContent(true); |
| 5516 LayerImpl* copy_grand_child_layer = copy_grand_child.get(); |
| 5517 |
| 5507 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = | 5518 scoped_ptr<LayerImpl> copy_grand_parent_sibling_before = |
| 5508 LayerImpl::Create(host_impl.pending_tree(), 6); | 5519 LayerImpl::Create(host_impl.pending_tree(), 7); |
| 5509 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), | 5520 SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), |
| 5510 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5521 identity_matrix, gfx::Point3F(), gfx::PointF(), |
| 5511 gfx::Size(40, 40), true, false, false); | 5522 gfx::Size(40, 40), true, false, false); |
| 5512 copy_grand_parent_sibling_before->SetDrawsContent(true); | 5523 copy_grand_parent_sibling_before->SetDrawsContent(true); |
| 5513 LayerImpl* copy_grand_parent_sibling_before_layer = | 5524 LayerImpl* copy_grand_parent_sibling_before_layer = |
| 5514 copy_grand_parent_sibling_before.get(); | 5525 copy_grand_parent_sibling_before.get(); |
| 5515 | 5526 |
| 5516 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = | 5527 scoped_ptr<LayerImpl> copy_grand_parent_sibling_after = |
| 5517 LayerImpl::Create(host_impl.pending_tree(), 7); | 5528 LayerImpl::Create(host_impl.pending_tree(), 8); |
| 5518 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), | 5529 SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), |
| 5519 identity_matrix, gfx::Point3F(), gfx::PointF(), | 5530 identity_matrix, gfx::Point3F(), gfx::PointF(), |
| 5520 gfx::Size(40, 40), true, false, false); | 5531 gfx::Size(40, 40), true, false, false); |
| 5521 copy_grand_parent_sibling_after->SetDrawsContent(true); | 5532 copy_grand_parent_sibling_after->SetDrawsContent(true); |
| 5522 LayerImpl* copy_grand_parent_sibling_after_layer = | 5533 LayerImpl* copy_grand_parent_sibling_after_layer = |
| 5523 copy_grand_parent_sibling_after.get(); | 5534 copy_grand_parent_sibling_after.get(); |
| 5524 | 5535 |
| 5536 copy_child->AddChild(std::move(copy_grand_child)); |
| 5525 copy_request->AddChild(std::move(copy_child)); | 5537 copy_request->AddChild(std::move(copy_child)); |
| 5526 copy_parent->AddChild(std::move(copy_request)); | 5538 copy_parent->AddChild(std::move(copy_request)); |
| 5527 copy_grand_parent->AddChild(std::move(copy_parent)); | 5539 copy_grand_parent->AddChild(std::move(copy_parent)); |
| 5528 root->AddChild(std::move(copy_grand_parent_sibling_before)); | 5540 root->AddChild(std::move(copy_grand_parent_sibling_before)); |
| 5529 root->AddChild(std::move(copy_grand_parent)); | 5541 root->AddChild(std::move(copy_grand_parent)); |
| 5530 root->AddChild(std::move(copy_grand_parent_sibling_after)); | 5542 root->AddChild(std::move(copy_grand_parent_sibling_after)); |
| 5531 | 5543 |
| 5532 // Hide the copy_grand_parent and its subtree. But make a copy request in that | 5544 // Hide the copy_grand_parent and its subtree. But make a copy request in that |
| 5533 // hidden subtree on copy_layer. | 5545 // hidden subtree on copy_layer. Also hide the copy grand child and its |
| 5534 copy_grand_parent_layer->SetHideLayerAndSubtree(true); | 5546 // subtree. |
| 5535 copy_grand_parent_sibling_before_layer->SetHideLayerAndSubtree(true); | 5547 copy_grand_parent_layer->SetOpacity(0.f); |
| 5536 copy_grand_parent_sibling_after_layer->SetHideLayerAndSubtree(true); | 5548 copy_grand_parent_sibling_before_layer->SetOpacity(0.f); |
| 5549 copy_grand_parent_sibling_after_layer->SetOpacity(0.f); |
| 5550 copy_grand_child_layer->SetOpacity(0.f); |
| 5537 | 5551 |
| 5538 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; | 5552 std::vector<scoped_ptr<CopyOutputRequest>> copy_requests; |
| 5539 copy_requests.push_back( | 5553 copy_requests.push_back( |
| 5540 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 5554 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 5541 copy_layer->PassCopyRequests(©_requests); | 5555 copy_layer->PassCopyRequests(©_requests); |
| 5542 EXPECT_TRUE(copy_layer->HasCopyRequest()); | 5556 EXPECT_TRUE(copy_layer->HasCopyRequest()); |
| 5543 | 5557 |
| 5544 LayerImplList render_surface_layer_list; | 5558 LayerImplList render_surface_layer_list; |
| 5545 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 5559 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
| 5546 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 5560 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 5547 root.get(), root->bounds(), &render_surface_layer_list, | 5561 root.get(), root->bounds(), &render_surface_layer_list, |
| 5548 root->layer_tree_impl()->current_render_surface_list_id()); | 5562 root->layer_tree_impl()->current_render_surface_list_id()); |
| 5549 inputs.can_adjust_raster_scales = true; | 5563 inputs.can_adjust_raster_scales = true; |
| 5550 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 5564 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 5551 | 5565 |
| 5552 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | 5566 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); |
| 5553 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5567 EXPECT_GT(copy_grand_parent_layer->num_copy_requests_in_target_subtree(), 0); |
| 5554 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); | 5568 EXPECT_GT(copy_parent_layer->num_copy_requests_in_target_subtree(), 0); |
| 5555 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); | 5569 EXPECT_GT(copy_layer->num_copy_requests_in_target_subtree(), 0); |
| 5556 | 5570 |
| 5557 // We should have three render surfaces, one for the root, one for the parent | 5571 // We should have four render surfaces, one for the root, one for the grand |
| 5572 // parent since it has opacity and two drawing descendants, one for the parent |
| 5558 // since it owns a surface, and one for the copy_layer. | 5573 // since it owns a surface, and one for the copy_layer. |
| 5559 ASSERT_EQ(3u, render_surface_layer_list.size()); | 5574 ASSERT_EQ(4u, render_surface_layer_list.size()); |
| 5560 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); | 5575 EXPECT_EQ(root->id(), render_surface_layer_list.at(0)->id()); |
| 5561 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(1)->id()); | 5576 EXPECT_EQ(copy_grand_parent_layer->id(), |
| 5562 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(2)->id()); | 5577 render_surface_layer_list.at(1)->id()); |
| 5578 EXPECT_EQ(copy_parent_layer->id(), render_surface_layer_list.at(2)->id()); |
| 5579 EXPECT_EQ(copy_layer->id(), render_surface_layer_list.at(3)->id()); |
| 5563 | 5580 |
| 5564 // The root render surface should have 2 contributing layers. The | 5581 // The root render surface should have 2 contributing layers. |
| 5565 // copy_grand_parent is hidden along with its siblings, but the copy_parent | |
| 5566 // will appear since something in its subtree needs to be drawn for a copy | |
| 5567 // request. | |
| 5568 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); | 5582 ASSERT_EQ(2u, root->render_surface()->layer_list().size()); |
| 5569 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); | 5583 EXPECT_EQ(root->id(), root->render_surface()->layer_list().at(0)->id()); |
| 5570 EXPECT_EQ(copy_parent_layer->id(), | 5584 EXPECT_EQ(copy_grand_parent_layer->id(), |
| 5571 root->render_surface()->layer_list().at(1)->id()); | 5585 root->render_surface()->layer_list().at(1)->id()); |
| 5572 | 5586 |
| 5573 // Nothing actually draws into the copy parent, so only the copy_layer will | 5587 // Nothing actually draws into the copy parent, so only the copy_layer will |
| 5574 // appear in its list, since it needs to be drawn for the copy request. | 5588 // appear in its list, since it needs to be drawn for the copy request. |
| 5575 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); | 5589 ASSERT_EQ(1u, copy_parent_layer->render_surface()->layer_list().size()); |
| 5576 EXPECT_EQ(copy_layer->id(), | 5590 EXPECT_EQ(copy_layer->id(), |
| 5577 copy_parent_layer->render_surface()->layer_list().at(0)->id()); | 5591 copy_layer->render_surface()->layer_list().at(0)->id()); |
| 5578 | 5592 |
| 5579 // The copy_layer's render surface should have two contributing layers. | 5593 // The copy_layer's render surface should have two contributing layers. |
| 5580 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); | 5594 ASSERT_EQ(2u, copy_layer->render_surface()->layer_list().size()); |
| 5581 EXPECT_EQ(copy_layer->id(), | 5595 EXPECT_EQ(copy_layer->id(), |
| 5582 copy_layer->render_surface()->layer_list().at(0)->id()); | 5596 copy_layer->render_surface()->layer_list().at(0)->id()); |
| 5583 EXPECT_EQ(copy_child_layer->id(), | 5597 EXPECT_EQ(copy_child_layer->id(), |
| 5584 copy_layer->render_surface()->layer_list().at(1)->id()); | 5598 copy_layer->render_surface()->layer_list().at(1)->id()); |
| 5599 |
| 5600 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden, |
| 5601 // but the copy_layer and copy_child should be drawn for the copy request. |
| 5602 // copy grand child should not be drawn as its hidden even in the copy |
| 5603 // request. |
| 5604 EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree; |
| 5605 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index()); |
| 5606 EXPECT_FALSE(node->data.is_drawn); |
| 5607 node = tree.Node(copy_parent_layer->effect_tree_index()); |
| 5608 EXPECT_FALSE(node->data.is_drawn); |
| 5609 node = tree.Node(copy_layer->effect_tree_index()); |
| 5610 EXPECT_TRUE(node->data.is_drawn); |
| 5611 node = tree.Node(copy_child_layer->effect_tree_index()); |
| 5612 EXPECT_TRUE(node->data.is_drawn); |
| 5613 node = tree.Node(copy_grand_child_layer->effect_tree_index()); |
| 5614 EXPECT_FALSE(node->data.is_drawn); |
| 5615 |
| 5616 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its |
| 5617 // actually hidden. |
| 5618 EXPECT_FALSE(copy_layer->render_surface()->contributes_to_drawn_surface()); |
| 5585 } | 5619 } |
| 5586 | 5620 |
| 5587 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { | 5621 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { |
| 5588 FakeImplTaskRunnerProvider task_runner_provider; | 5622 FakeImplTaskRunnerProvider task_runner_provider; |
| 5589 TestSharedBitmapManager shared_bitmap_manager; | 5623 TestSharedBitmapManager shared_bitmap_manager; |
| 5590 TestTaskGraphRunner task_graph_runner; | 5624 TestTaskGraphRunner task_graph_runner; |
| 5591 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 5625 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 5592 &task_graph_runner); | 5626 &task_graph_runner); |
| 5593 host_impl.CreatePendingTree(); | 5627 host_impl.CreatePendingTree(); |
| 5594 const gfx::Transform identity_matrix; | 5628 const gfx::Transform identity_matrix; |
| (...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8676 // remain empty. | 8710 // remain empty. |
| 8677 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); | 8711 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); |
| 8678 gfx::Transform singular; | 8712 gfx::Transform singular; |
| 8679 singular.matrix().set(0, 0, 0); | 8713 singular.matrix().set(0, 0, 0); |
| 8680 | 8714 |
| 8681 child->SetTransform(singular); | 8715 child->SetTransform(singular); |
| 8682 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8716 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8683 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); | 8717 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); |
| 8684 child->SetTransform(identity); | 8718 child->SetTransform(identity); |
| 8685 | 8719 |
| 8686 child->SetHideLayerAndSubtree(true); | 8720 // Set opacity to 0 to hide subtree. |
| 8721 child->SetOpacity(0.f); |
| 8687 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8722 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8688 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); | 8723 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); |
| 8689 child->SetHideLayerAndSubtree(false); | 8724 child->SetOpacity(1.f); |
| 8690 | 8725 |
| 8691 gfx::Transform zero_z_scale; | 8726 gfx::Transform zero_z_scale; |
| 8692 zero_z_scale.Scale3d(1, 1, 0); | 8727 zero_z_scale.Scale3d(1, 1, 0); |
| 8693 child->SetTransform(zero_z_scale); | 8728 child->SetTransform(zero_z_scale); |
| 8694 | 8729 |
| 8695 // Add a transform animation with a start delay. Now, even though |child| has | 8730 // Add a transform animation with a start delay. Now, even though |child| has |
| 8696 // a singular transform, the subtree should still get processed. | 8731 // a singular transform, the subtree should still get processed. |
| 8697 int animation_id = 0; | 8732 int animation_id = 0; |
| 8698 scoped_ptr<Animation> animation = Animation::Create( | 8733 scoped_ptr<Animation> animation = Animation::Create( |
| 8699 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), | 8734 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8717 child->RemoveAnimation(animation_id); | 8752 child->RemoveAnimation(animation_id); |
| 8718 } | 8753 } |
| 8719 child->SetTransform(identity); | 8754 child->SetTransform(identity); |
| 8720 child->SetOpacity(0.f); | 8755 child->SetOpacity(0.f); |
| 8721 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8756 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8722 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); | 8757 EXPECT_EQ(gfx::Rect(0, 0), grandchild->visible_rect_from_property_trees()); |
| 8723 | 8758 |
| 8724 // Now, even though child has zero opacity, we will configure |grandchild| and | 8759 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8725 // |greatgrandchild| in several ways that should force the subtree to be | 8760 // |greatgrandchild| in several ways that should force the subtree to be |
| 8726 // processed anyhow. | 8761 // processed anyhow. |
| 8727 greatgrandchild->RequestCopyOfOutput( | 8762 grandchild->RequestCopyOfOutput( |
| 8728 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); | 8763 CopyOutputRequest::CreateBitmapRequest(base::Bind(&CopyOutputCallback))); |
| 8729 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8764 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8730 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); | 8765 EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_rect_from_property_trees()); |
| 8731 grandchild->set_visible_rect_from_property_trees(gfx::Rect()); | 8766 greatgrandchild->set_visible_rect_from_property_trees(gfx::Rect()); |
| 8732 | 8767 |
| 8733 // Add an opacity animation with a start delay. | 8768 // Add an opacity animation with a start delay. |
| 8734 animation_id = 1; | 8769 animation_id = 1; |
| 8735 animation = Animation::Create( | 8770 animation = Animation::Create( |
| 8736 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), | 8771 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), |
| 8737 animation_id, 1, Animation::OPACITY); | 8772 animation_id, 1, Animation::OPACITY); |
| 8738 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 8773 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
| 8739 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8774 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
| 8740 if (layer_settings().use_compositor_animation_timelines) { | 8775 if (layer_settings().use_compositor_animation_timelines) { |
| 8741 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), | 8776 AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 8769 | 8804 |
| 8770 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8805 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8771 gfx::PointF(), gfx::Size(100, 100), true, false, | 8806 gfx::PointF(), gfx::Size(100, 100), true, false, |
| 8772 true); | 8807 true); |
| 8773 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | 8808 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), |
| 8774 gfx::PointF(), gfx::Size(10, 10), true, false, | 8809 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 8775 false); | 8810 false); |
| 8776 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), | 8811 SetLayerPropertiesForTesting(grandchild.get(), identity, gfx::Point3F(), |
| 8777 gfx::PointF(), gfx::Size(10, 10), true, false, | 8812 gfx::PointF(), gfx::Size(10, 10), true, false, |
| 8778 false); | 8813 false); |
| 8779 SetLayerPropertiesForTesting(greatgrandchild.get(), identity, gfx::Point3F(), | |
| 8780 gfx::PointF(), gfx::Size(10, 10), true, false, | |
| 8781 true); | |
| 8782 | 8814 |
| 8783 LayerImpl* child_ptr = child.get(); | 8815 LayerImpl* child_ptr = child.get(); |
| 8784 LayerImpl* grandchild_ptr = grandchild.get(); | 8816 LayerImpl* grandchild_ptr = grandchild.get(); |
| 8785 LayerImpl* greatgrandchild_ptr = greatgrandchild.get(); | |
| 8786 | 8817 |
| 8787 grandchild->AddChild(std::move(greatgrandchild)); | |
| 8788 child->AddChild(std::move(grandchild)); | 8818 child->AddChild(std::move(grandchild)); |
| 8789 root->AddChild(std::move(child)); | 8819 root->AddChild(std::move(child)); |
| 8790 | 8820 |
| 8791 // Check the non-skipped case. | 8821 // Check the non-skipped case. |
| 8792 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8822 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8793 EXPECT_EQ(gfx::Rect(10, 10), | 8823 EXPECT_EQ(gfx::Rect(10, 10), |
| 8794 grandchild_ptr->visible_rect_from_property_trees()); | 8824 grandchild_ptr->visible_rect_from_property_trees()); |
| 8795 | 8825 |
| 8796 // Now we will reset the visible rect from property trees for the grandchild, | 8826 // Now we will reset the visible rect from property trees for the grandchild, |
| 8797 // and we will configure |child| in several ways that should force the subtree | 8827 // and we will configure |child| in several ways that should force the subtree |
| 8798 // to be skipped. The visible content rect for |grandchild| should, therefore, | 8828 // to be skipped. The visible content rect for |grandchild| should, therefore, |
| 8799 // remain empty. | 8829 // remain empty. |
| 8800 grandchild_ptr->set_visible_rect_from_property_trees(gfx::Rect()); | 8830 grandchild_ptr->set_visible_rect_from_property_trees(gfx::Rect()); |
| 8801 gfx::Transform singular; | 8831 gfx::Transform singular; |
| 8802 singular.matrix().set(0, 0, 0); | 8832 singular.matrix().set(0, 0, 0); |
| 8803 | 8833 |
| 8804 child_ptr->SetTransform(singular); | 8834 child_ptr->SetTransform(singular); |
| 8805 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8835 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8806 EXPECT_EQ(gfx::Rect(0, 0), | 8836 EXPECT_EQ(gfx::Rect(0, 0), |
| 8807 grandchild_ptr->visible_rect_from_property_trees()); | 8837 grandchild_ptr->visible_rect_from_property_trees()); |
| 8808 child_ptr->SetTransform(identity); | 8838 child_ptr->SetTransform(identity); |
| 8809 | 8839 |
| 8810 child_ptr->SetHideLayerAndSubtree(true); | |
| 8811 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | |
| 8812 EXPECT_EQ(gfx::Rect(0, 0), | |
| 8813 grandchild_ptr->visible_rect_from_property_trees()); | |
| 8814 child_ptr->SetHideLayerAndSubtree(false); | |
| 8815 | |
| 8816 child_ptr->SetOpacity(0.f); | 8840 child_ptr->SetOpacity(0.f); |
| 8817 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8841 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8818 EXPECT_EQ(gfx::Rect(0, 0), | 8842 EXPECT_EQ(gfx::Rect(0, 0), |
| 8819 grandchild_ptr->visible_rect_from_property_trees()); | 8843 grandchild_ptr->visible_rect_from_property_trees()); |
| 8820 | 8844 |
| 8821 // Now, even though child has zero opacity, we will configure |grandchild| and | 8845 // Now, even though child has zero opacity, we will configure |grandchild| and |
| 8822 // |greatgrandchild| in several ways that should force the subtree to be | 8846 // |greatgrandchild| in several ways that should force the subtree to be |
| 8823 // processed anyhow. | 8847 // processed anyhow. |
| 8824 std::vector<scoped_ptr<CopyOutputRequest>> requests; | 8848 std::vector<scoped_ptr<CopyOutputRequest>> requests; |
| 8825 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 8849 requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
| 8826 | 8850 |
| 8827 greatgrandchild_ptr->PassCopyRequests(&requests); | 8851 grandchild_ptr->PassCopyRequests(&requests); |
| 8828 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; | 8852 root.get()->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 8829 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8853 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8830 EXPECT_EQ(gfx::Rect(10, 10), | 8854 EXPECT_EQ(gfx::Rect(10, 10), |
| 8831 grandchild_ptr->visible_rect_from_property_trees()); | 8855 grandchild_ptr->visible_rect_from_property_trees()); |
| 8832 } | 8856 } |
| 8833 | 8857 |
| 8834 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { | 8858 TEST_F(LayerTreeHostCommonTest, SkippingLayer) { |
| 8835 gfx::Transform identity; | 8859 gfx::Transform identity; |
| 8836 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 8860 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 8837 FakeContentLayerClient client; | 8861 FakeContentLayerClient client; |
| 8838 client.set_bounds(root->bounds()); | 8862 client.set_bounds(root->bounds()); |
| 8839 scoped_refptr<LayerWithForcedDrawsContent> child = | 8863 scoped_refptr<LayerWithForcedDrawsContent> child = |
| 8840 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); | 8864 make_scoped_refptr(new LayerWithForcedDrawsContent(layer_settings())); |
| 8841 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), | 8865 SetLayerPropertiesForTesting(root.get(), identity, gfx::Point3F(), |
| 8842 gfx::PointF(), gfx::Size(100, 100), true, false); | 8866 gfx::PointF(), gfx::Size(100, 100), true, false); |
| 8843 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), | 8867 SetLayerPropertiesForTesting(child.get(), identity, gfx::Point3F(), |
| 8844 gfx::PointF(), gfx::Size(10, 10), true, false); | 8868 gfx::PointF(), gfx::Size(10, 10), true, false); |
| 8845 root->AddChild(child); | 8869 root->AddChild(child); |
| 8846 | 8870 |
| 8847 host()->SetRootLayer(root); | 8871 host()->SetRootLayer(root); |
| 8848 | 8872 |
| 8849 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8873 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8850 EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees()); | 8874 EXPECT_EQ(gfx::Rect(10, 10), child->visible_rect_from_property_trees()); |
| 8851 child->set_visible_rect_from_property_trees(gfx::Rect()); | 8875 child->set_visible_rect_from_property_trees(gfx::Rect()); |
| 8852 | 8876 |
| 8853 child->SetHideLayerAndSubtree(true); | 8877 // Set opacity to 0 to hide subtree. |
| 8878 child->SetOpacity(0.f); |
| 8854 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8879 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8855 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); | 8880 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); |
| 8856 child->SetHideLayerAndSubtree(false); | 8881 child->SetOpacity(1.f); |
| 8857 | 8882 |
| 8858 child->SetBounds(gfx::Size()); | 8883 child->SetBounds(gfx::Size()); |
| 8859 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); | 8884 ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); |
| 8860 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); | 8885 EXPECT_EQ(gfx::Rect(0, 0), child->visible_rect_from_property_trees()); |
| 8861 child->SetBounds(gfx::Size(10, 10)); | 8886 child->SetBounds(gfx::Size(10, 10)); |
| 8862 | 8887 |
| 8863 gfx::Transform rotate; | 8888 gfx::Transform rotate; |
| 8864 child->SetDoubleSided(false); | 8889 child->SetDoubleSided(false); |
| 8865 rotate.RotateAboutXAxis(180.f); | 8890 rotate.RotateAboutXAxis(180.f); |
| 8866 child->SetTransform(rotate); | 8891 child->SetTransform(rotate); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9409 LayerImpl* render_surface = AddChild<LayerImpl>(root); | 9434 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 9410 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); | 9435 LayerImpl* test_layer = AddChild<LayerImpl>(render_surface); |
| 9411 | 9436 |
| 9412 const gfx::Transform identity_matrix; | 9437 const gfx::Transform identity_matrix; |
| 9413 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9438 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9414 gfx::PointF(), gfx::Size(30, 30), true, false, | 9439 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9415 true); | 9440 true); |
| 9416 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), | 9441 SetLayerPropertiesForTesting(render_surface, identity_matrix, gfx::Point3F(), |
| 9417 gfx::PointF(), gfx::Size(30, 30), true, false, | 9442 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9418 true); | 9443 true); |
| 9419 SetLayerPropertiesForTesting(test_layer, identity_matrix, gfx::Point3F(), | 9444 gfx::Transform translation; |
| 9445 translation.Translate(10, 10); |
| 9446 SetLayerPropertiesForTesting(test_layer, translation, gfx::Point3F(), |
| 9420 gfx::PointF(), gfx::Size(20, 20), true, false, | 9447 gfx::PointF(), gfx::Size(20, 20), true, false, |
| 9421 false); | 9448 false); |
| 9422 | 9449 |
| 9423 render_surface->SetMasksToBounds(true); | 9450 render_surface->SetMasksToBounds(true); |
| 9424 test_layer->SetDrawsContent(true); | 9451 test_layer->SetDrawsContent(true); |
| 9425 test_layer->SetOpacity(0); | 9452 test_layer->SetOpacity(0); |
| 9426 test_layer->SetHaveWheelEventHandlers(true); | 9453 test_layer->SetHaveWheelEventHandlers(true); |
| 9427 | 9454 |
| 9428 ExecuteCalculateDrawProperties(root); | 9455 ExecuteCalculateDrawProperties(root); |
| 9429 EXPECT_EQ(gfx::Rect(20, 20), test_layer->drawable_content_rect()); | 9456 EXPECT_EQ(translation, test_layer->ScreenSpaceTransform()); |
| 9430 EXPECT_EQ(gfx::RectF(20, 20), | |
| 9431 render_surface->render_surface()->DrawableContentRect()); | |
| 9432 } | 9457 } |
| 9433 | 9458 |
| 9434 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 9459 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
| 9435 LayerImpl* root = root_layer(); | 9460 LayerImpl* root = root_layer(); |
| 9436 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 9461 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 9437 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 9462 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
| 9438 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 9463 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
| 9439 | 9464 |
| 9440 const gfx::Transform identity_matrix; | 9465 const gfx::Transform identity_matrix; |
| 9441 clip_parent->SetMasksToBounds(true); | 9466 clip_parent->SetMasksToBounds(true); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9502 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 9527 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 9503 gfx::PointF(), gfx::Size(30, 30), true, false, | 9528 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9504 true); | 9529 true); |
| 9505 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), | 9530 SetLayerPropertiesForTesting(hidden, identity_matrix, gfx::Point3F(), |
| 9506 gfx::PointF(10, 10), gfx::Size(30, 30), true, | 9531 gfx::PointF(10, 10), gfx::Size(30, 30), true, |
| 9507 false, true); | 9532 false, true); |
| 9508 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), | 9533 SetLayerPropertiesForTesting(test, identity_matrix, gfx::Point3F(), |
| 9509 gfx::PointF(), gfx::Size(30, 30), true, false, | 9534 gfx::PointF(), gfx::Size(30, 30), true, false, |
| 9510 true); | 9535 true); |
| 9511 | 9536 |
| 9512 hidden->SetHideLayerAndSubtree(true); | 9537 // Set opacity to 0 to hide subtree. |
| 9538 hidden->SetOpacity(0.f); |
| 9513 ExecuteCalculateDrawProperties(root); | 9539 ExecuteCalculateDrawProperties(root); |
| 9514 EXPECT_TRUE(test->LayerIsHidden()); | 9540 EXPECT_TRUE(test->IsHidden()); |
| 9515 | 9541 |
| 9516 hidden->SetHideLayerAndSubtree(false); | 9542 hidden->SetOpacity(1.f); |
| 9517 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 9543 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 9518 ExecuteCalculateDrawProperties(root); | 9544 ExecuteCalculateDrawProperties(root); |
| 9519 EXPECT_FALSE(test->LayerIsHidden()); | 9545 EXPECT_FALSE(test->IsHidden()); |
| 9520 } | 9546 } |
| 9521 | 9547 |
| 9522 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 9548 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
| 9523 LayerImpl* root = root_layer(); | 9549 LayerImpl* root = root_layer(); |
| 9524 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 9550 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); |
| 9525 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 9551 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
| 9526 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 9552 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
| 9527 | 9553 |
| 9528 const gfx::Transform identity_matrix; | 9554 const gfx::Transform identity_matrix; |
| 9529 clip_child->SetClipParent(root); | 9555 clip_child->SetClipParent(root); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9672 proto::ScrollAndScaleSet proto; | 9698 proto::ScrollAndScaleSet proto; |
| 9673 scroll_and_scale_set.ToProtobuf(&proto); | 9699 scroll_and_scale_set.ToProtobuf(&proto); |
| 9674 ScrollAndScaleSet new_scroll_and_scale_set; | 9700 ScrollAndScaleSet new_scroll_and_scale_set; |
| 9675 new_scroll_and_scale_set.FromProtobuf(proto); | 9701 new_scroll_and_scale_set.FromProtobuf(proto); |
| 9676 | 9702 |
| 9677 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); | 9703 EXPECT_TRUE(scroll_and_scale_set.EqualsForTesting(new_scroll_and_scale_set)); |
| 9678 } | 9704 } |
| 9679 | 9705 |
| 9680 } // namespace | 9706 } // namespace |
| 9681 } // namespace cc | 9707 } // namespace cc |
| OLD | NEW |