diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-12 23:45:53 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-12 23:45:53 +0000 |
commit | ac020129be0065b57436bba5c8ff5c8f56eab343 (patch) | |
tree | 5150548d8cc4c6ba49d8e6eaa2901e9932619e57 | |
parent | 6695bb247a80188f0ac7272d069b9872dc9b1559 (diff) | |
download | chromium_src-ac020129be0065b57436bba5c8ff5c8f56eab343.zip chromium_src-ac020129be0065b57436bba5c8ff5c8f56eab343.tar.gz chromium_src-ac020129be0065b57436bba5c8ff5c8f56eab343.tar.bz2 |
cc: layer_or_descendant_has_copy_request is inherited by siblings.
If a layer has this value to be true, it should not be also set
on siblings that follow it.
Tests:
LayerTreeHostCommonTest.SubtreeHiddenWithCopyRequest
R=enne, piman
BUG=242572
Review URL: https://chromiumcodereview.appspot.com/19075002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211487 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 23 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 43 |
2 files changed, 57 insertions, 9 deletions
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 2af828a..405652a 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -769,10 +769,15 @@ static inline void RemoveSurfaceForEarlyExit( } struct PreCalculateMetaInformationRecursiveData { - bool layer_or_descendent_has_copy_request; + bool layer_or_descendant_has_copy_request; PreCalculateMetaInformationRecursiveData() - : layer_or_descendent_has_copy_request(false) {} + : layer_or_descendant_has_copy_request(false) {} + + void Merge(const PreCalculateMetaInformationRecursiveData& data) { + layer_or_descendant_has_copy_request |= + data.layer_or_descendant_has_copy_request; + } }; // Recursively walks the layer tree to compute any information that is needed @@ -797,7 +802,9 @@ static void PreCalculateMetaInformation( for (size_t i = 0; i < layer->children().size(); ++i) { LayerType* child_layer = LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); - PreCalculateMetaInformation<LayerType>(child_layer, recursive_data); + + PreCalculateMetaInformationRecursiveData data_for_child; + PreCalculateMetaInformation(child_layer, &data_for_child); if (!has_delegated_content) { bool sublayer_transform_prevents_clip = @@ -813,17 +820,19 @@ static void PreCalculateMetaInformation( !child_layer->transform().IsPositiveScaleOrTranslation()) descendants_can_clip_selves = false; } + + recursive_data->Merge(data_for_child); } if (layer->HasCopyRequest()) - recursive_data->layer_or_descendent_has_copy_request = true; + recursive_data->layer_or_descendant_has_copy_request = true; layer->draw_properties().num_descendants_that_draw_content = num_descendants_that_draw_content; layer->draw_properties().descendants_can_clip_selves = descendants_can_clip_selves; layer->draw_properties().layer_or_descendant_has_copy_request = - recursive_data->layer_or_descendent_has_copy_request; + recursive_data->layer_or_descendant_has_copy_request; } static void RoundTranslationComponents(gfx::Transform* transform) { @@ -1609,7 +1618,7 @@ void LayerTreeHostCommon::CalculateDrawProperties( DCHECK(IsRootLayer(root_layer)); PreCalculateMetaInformationRecursiveData recursive_data; - PreCalculateMetaInformation<Layer>(root_layer, &recursive_data); + PreCalculateMetaInformation(root_layer, &recursive_data); CalculateDrawPropertiesInternal<Layer, LayerList, RenderSurface>( root_layer, @@ -1670,7 +1679,7 @@ void LayerTreeHostCommon::CalculateDrawProperties( DCHECK(IsRootLayer(root_layer)); PreCalculateMetaInformationRecursiveData recursive_data; - PreCalculateMetaInformation<LayerImpl>(root_layer, &recursive_data); + PreCalculateMetaInformation(root_layer, &recursive_data); CalculateDrawPropertiesInternal<LayerImpl, LayerImplList, diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 3365721..5b607c8 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -8205,14 +8205,38 @@ TEST(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { false); copy_child->SetIsDrawable(true); + scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create(); + SetLayerPropertiesForTesting(copy_grand_parent_sibling_before.get(), + identity_matrix, + identity_matrix, + gfx::PointF(), + gfx::PointF(), + gfx::Size(40, 40), + false); + copy_grand_parent_sibling_before->SetIsDrawable(true); + + scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create(); + SetLayerPropertiesForTesting(copy_grand_parent_sibling_after.get(), + identity_matrix, + identity_matrix, + gfx::PointF(), + gfx::PointF(), + gfx::Size(40, 40), + false); + copy_grand_parent_sibling_after->SetIsDrawable(true); + copy_layer->AddChild(copy_child); copy_parent->AddChild(copy_layer); copy_grand_parent->AddChild(copy_parent); + root->AddChild(copy_grand_parent_sibling_before); root->AddChild(copy_grand_parent); + root->AddChild(copy_grand_parent_sibling_after); // Hide the copy_grand_parent and its subtree. But make a copy request in that // hidden subtree on copy_layer. copy_grand_parent->SetHideLayerAndSubtree(true); + copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true); + copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true); copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateRequest( base::Bind(&EmptyCopyOutputCallback))); EXPECT_TRUE(copy_layer->HasCopyRequest()); @@ -8230,6 +8254,20 @@ TEST(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { true, // can_adjust_raster_scale &render_surface_layer_list); + EXPECT_TRUE(root->draw_properties().layer_or_descendant_has_copy_request); + EXPECT_TRUE(copy_grand_parent->draw_properties(). + layer_or_descendant_has_copy_request); + EXPECT_TRUE(copy_parent->draw_properties(). + layer_or_descendant_has_copy_request); + EXPECT_TRUE(copy_layer->draw_properties(). + layer_or_descendant_has_copy_request); + EXPECT_FALSE(copy_child->draw_properties(). + layer_or_descendant_has_copy_request); + EXPECT_FALSE(copy_grand_parent_sibling_before->draw_properties(). + layer_or_descendant_has_copy_request); + EXPECT_FALSE(copy_grand_parent_sibling_after->draw_properties(). + layer_or_descendant_has_copy_request); + // We should have three render surfaces, one for the root, one for the parent // since it owns a surface, and one for the copy_layer. ASSERT_EQ(3u, render_surface_layer_list.size()); @@ -8238,8 +8276,9 @@ TEST(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { EXPECT_EQ(copy_layer->id(), render_surface_layer_list[2]->id()); // The root render surface should have 2 contributing layers. The - // copy_grand_parent is hidden, but the copy_parent will appear since - // something in its subtree needs to be drawn for a copy request. + // copy_grand_parent is hidden along with its siblings, but the copy_parent + // will appear since something in its subtree needs to be drawn for a copy + // request. ASSERT_EQ(2u, root->render_surface()->layer_list().size()); EXPECT_EQ(root->id(), root->render_surface()->layer_list()[0]->id()); EXPECT_EQ(copy_parent->id(), root->render_surface()->layer_list()[1]->id()); |