diff options
author | awoloszyn@chromium.org <awoloszyn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-11 17:39:54 +0000 |
---|---|---|
committer | awoloszyn@chromium.org <awoloszyn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-11 17:41:20 +0000 |
commit | ad63b2ffb295d0de395b83faeff6125475f0f5c4 (patch) | |
tree | 1d867e1db456fd4bb95f5e0a202e7005d5f6ae85 /cc/trees | |
parent | 6ebf79234c9c16a3611a05f481e845433ddd7271 (diff) | |
download | chromium_src-ad63b2ffb295d0de395b83faeff6125475f0f5c4.zip chromium_src-ad63b2ffb295d0de395b83faeff6125475f0f5c4.tar.gz chromium_src-ad63b2ffb295d0de395b83faeff6125475f0f5c4.tar.bz2 |
Keeping track of descendants that draw content instead of recalcualting
This is a required for removing Render Surface creation from CalcDrawProps.
BUG=386788
Review URL: https://codereview.chromium.org/373113003
Cr-Commit-Position: refs/heads/master@{#288740}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees')
-rw-r--r-- | cc/trees/damage_tracker_unittest.cc | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common.cc | 18 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 56 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl_unittest.cc | 50 | ||||
-rw-r--r-- | cc/trees/occlusion_tracker_unittest.cc | 7 |
7 files changed, 94 insertions, 43 deletions
diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc index 169eea4..b6a4409 100644 --- a/cc/trees/damage_tracker_unittest.cc +++ b/cc/trees/damage_tracker_unittest.cc @@ -30,6 +30,7 @@ void ExecuteCalculateDrawProperties(LayerImpl* root, ASSERT_TRUE(root->render_surface()); ASSERT_FALSE(render_surface_layer_list->size()); + FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root); LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( root, root->bounds(), render_surface_layer_list); LayerTreeHostCommon::CalculateDrawProperties(&inputs); diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 51fb080..840a32b 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -583,7 +583,7 @@ static bool SubtreeShouldRenderToSeparateSurface( } int num_descendants_that_draw_content = - layer->draw_properties().num_descendants_that_draw_content; + layer->NumDescendantsThatDrawContent(); // If the layer flattens its subtree, but it is treated as a 3D object by its // parent (i.e. parent participates in a 3D rendering context). @@ -1207,8 +1207,6 @@ template <typename LayerType> static void PreCalculateMetaInformation( LayerType* layer, PreCalculateMetaInformationRecursiveData* recursive_data) { - bool has_delegated_content = layer->HasDelegatedContent(); - int num_descendants_that_draw_content = 0; layer->draw_properties().sorted_for_recursion = false; layer->draw_properties().has_child_with_a_scroll_parent = false; @@ -1219,14 +1217,6 @@ static void PreCalculateMetaInformation( return; } - if (has_delegated_content) { - // Layers with delegated content need to be treated as if they have as - // many children as the number of layers they own delegated quads for. - // Since we don't know this number right now, we choose one that acts like - // infinity for our purposes. - num_descendants_that_draw_content = 1000; - } - if (layer->clip_parent()) recursive_data->num_unclipped_descendants++; @@ -1237,10 +1227,6 @@ static void PreCalculateMetaInformation( PreCalculateMetaInformationRecursiveData data_for_child; PreCalculateMetaInformation(child_layer, &data_for_child); - num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; - num_descendants_that_draw_content += - child_layer->draw_properties().num_descendants_that_draw_content; - if (child_layer->scroll_parent()) layer->draw_properties().has_child_with_a_scroll_parent = true; recursive_data->Merge(data_for_child); @@ -1259,8 +1245,6 @@ static void PreCalculateMetaInformation( layer->have_wheel_event_handlers()) recursive_data->layer_or_descendant_has_input_handler = true; - layer->draw_properties().num_descendants_that_draw_content = - num_descendants_that_draw_content; layer->draw_properties().num_unclipped_descendants = recursive_data->num_unclipped_descendants; layer->draw_properties().layer_or_descendant_has_copy_request = diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 6429e81..66b63a5 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -6945,6 +6945,7 @@ TEST_F(LayerTreeHostCommonTest, CanRenderToSeparateSurface) { { LayerImplList render_surface_layer_list; + FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root.get()); LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( root.get(), root->bounds(), &render_surface_layer_list); inputs.can_render_to_separate_surface = true; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index fe2a234..92166b9 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -1845,6 +1845,8 @@ TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { EXPECT_FALSE(layer2->did_draw_called()); LayerTreeHostImpl::FrameData frame; + FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( + host_impl_->active_tree()->root_layer()); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); host_impl_->DidDrawAllLayers(frame); @@ -3678,6 +3680,8 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) { layer1->SetUpdateRect(gfx::RectF(layer1->content_bounds())); layer2->SetExpectation(false, false); layer2->SetUpdateRect(gfx::RectF(layer1->content_bounds())); + FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( + host_impl_->active_tree()->root_layer()); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame, gfx::FrameTime::Now()); EXPECT_TRUE(layer1->quads_appended()); diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 94383da..2ddee12 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -2996,6 +2996,8 @@ class PushPropertiesCountingLayer : public Layer { PassAs<LayerImpl>(); } + void SetDrawsContent(bool draws_content) { SetIsDrawable(draws_content); } + size_t push_properties_count() const { return push_properties_count_; } void reset_push_properties_count() { push_properties_count_ = 0; } @@ -3007,7 +3009,6 @@ class PushPropertiesCountingLayer : public Layer { PushPropertiesCountingLayer() : push_properties_count_(0), persist_needs_push_properties_(false) { SetBounds(gfx::Size(1, 1)); - SetIsDrawable(true); } virtual ~PushPropertiesCountingLayer() {} @@ -3464,6 +3465,59 @@ class LayerTreeHostTestPropertyChangesDuringUpdateArePushed MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); +class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { + protected: + virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } + + virtual void SetupTree() OVERRIDE { + root_ = PushPropertiesCountingLayer::Create(); + child_ = PushPropertiesCountingLayer::Create(); + root_->AddChild(child_); + + layer_tree_host()->SetRootLayer(root_); + LayerTreeHostTest::SetupTree(); + } + + virtual void DidCommitAndDrawFrame() OVERRIDE { + switch (layer_tree_host()->source_frame_number()) { + case 0: + break; + case 1: { + // During update, the ignore_set_needs_commit_ bit is set to true to + // avoid causing a second commit to be scheduled. If a property change + // is made during this, however, it needs to be pushed in the upcoming + // commit. + EXPECT_FALSE(root_->needs_push_properties()); + EXPECT_FALSE(child_->needs_push_properties()); + EXPECT_EQ(0, root_->NumDescendantsThatDrawContent()); + root_->reset_push_properties_count(); + child_->reset_push_properties_count(); + child_->SetDrawsContent(true); + EXPECT_EQ(1, root_->NumDescendantsThatDrawContent()); + EXPECT_EQ(0u, root_->push_properties_count()); + EXPECT_EQ(0u, child_->push_properties_count()); + EXPECT_TRUE(root_->needs_push_properties()); + EXPECT_TRUE(child_->needs_push_properties()); + break; + } + case 2: + EXPECT_EQ(1u, root_->push_properties_count()); + EXPECT_EQ(1u, child_->push_properties_count()); + EXPECT_FALSE(root_->needs_push_properties()); + EXPECT_FALSE(child_->needs_push_properties()); + EndTest(); + break; + } + } + + virtual void AfterTest() OVERRIDE {} + + scoped_refptr<PushPropertiesCountingLayer> root_; + scoped_refptr<PushPropertiesCountingLayer> child_; +}; + +MULTI_THREAD_TEST_F(LayerTreeHostTestSetDrawableCausesCommit); + class LayerTreeHostTestCasePushPropertiesThreeGrandChildren : public LayerTreeHostTest { protected: diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index d215349..7c917e0 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -62,7 +62,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -128,7 +128,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayerAndHud) { host_impl().SetViewportSize(hud_bounds); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -186,7 +186,7 @@ TEST_F(LayerTreeImplTest, HitTestingForUninvertibleTransform) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); ASSERT_EQ(1u, root_layer()->render_surface()->layer_list().size()); @@ -252,7 +252,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePositionedLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -308,7 +308,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleRotatedLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -377,7 +377,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSinglePerspectiveLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -457,7 +457,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSingleLayerWithScaledContents) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. // The visible content rect for test_layer is actually 100x100, even though @@ -548,7 +548,7 @@ TEST_F(LayerTreeImplTest, HitTestingForSimpleClippedLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -673,7 +673,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultiClippedRotatedLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. // The grand_child is expected to create a render surface because it @@ -796,7 +796,7 @@ TEST_F(LayerTreeImplTest, HitTestingForNonClippingIntermediateLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -904,7 +904,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayers) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_TRUE(child1); @@ -1052,7 +1052,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayersAtVaryingDepths) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_TRUE(child1); @@ -1170,7 +1170,7 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsClipParents) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); gfx::Point test_point = gfx::Point(12, 52); LayerImpl* result_layer = @@ -1245,7 +1245,7 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); gfx::Point test_point = gfx::Point(12, 52); LayerImpl* result_layer = @@ -1338,7 +1338,7 @@ TEST_F(LayerTreeImplTest, HitTestingForMultipleLayerLists) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_TRUE(child1); @@ -1428,7 +1428,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSingleLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -1517,7 +1517,7 @@ TEST_F(LayerTreeImplTest, host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -1595,7 +1595,7 @@ TEST_F(LayerTreeImplTest, host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -1691,7 +1691,7 @@ TEST_F(LayerTreeImplTest, host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. // The visible content rect for test_layer is actually 100x100, even though @@ -1800,7 +1800,7 @@ TEST_F(LayerTreeImplTest, page_scale_factor, page_scale_factor, page_scale_factor); host_impl().active_tree()->SetRootLayer(root.Pass()); host_impl().active_tree()->SetViewportLayersFromIds(1, 1, Layer::INVALID_ID); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. // The visible content rect for test_layer is actually 100x100, even though @@ -1930,7 +1930,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerRegionsForSimpleClippedLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -2028,7 +2028,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -2090,7 +2090,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForSingleLayer) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -2191,7 +2191,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForPartialOccludedLayers) { host_impl().SetViewportSize(root->bounds()); host_impl().active_tree()->SetRootLayer(root.Pass()); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); @@ -2286,7 +2286,7 @@ TEST_F(LayerTreeImplTest, SelectionBoundsForScaledLayers) { page_scale_factor, page_scale_factor, page_scale_factor); host_impl().active_tree()->SetRootLayer(root.Pass()); host_impl().active_tree()->SetViewportLayersFromIds(1, 1, Layer::INVALID_ID); - host_impl().active_tree()->UpdateDrawProperties(); + host_impl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); // Sanity check the scenario we just created. ASSERT_EQ(1u, RenderSurfaceLayerList().size()); diff --git a/cc/trees/occlusion_tracker_unittest.cc b/cc/trees/occlusion_tracker_unittest.cc index 1a6529b..e6464a2 100644 --- a/cc/trees/occlusion_tracker_unittest.cc +++ b/cc/trees/occlusion_tracker_unittest.cc @@ -133,6 +133,8 @@ struct OcclusionTrackerTestMainThreadTypes { } static void DestroyLayer(LayerPtrType* layer) { *layer = NULL; } + + static void RecursiveUpdateNumChildren(LayerType* layerType) {} }; struct OcclusionTrackerTestImplThreadTypes { @@ -162,6 +164,10 @@ struct OcclusionTrackerTestImplThreadTypes { } static void DestroyLayer(LayerPtrType* layer) { layer->reset(); } + + static void RecursiveUpdateNumChildren(LayerType* layer) { + FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(layer); + } }; int OcclusionTrackerTestImplThreadTypes::next_layer_impl_id = 1; @@ -304,6 +310,7 @@ template <typename Types> class OcclusionTrackerTest : public testing::Test { DCHECK(root == root_.get()); DCHECK(!root->render_surface()); + Types::RecursiveUpdateNumChildren(root); LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( root, root->bounds(), &render_surface_layer_list_impl_); inputs.can_adjust_raster_scales = true; |