From fac82b6338c8c7b49e5c97fda5f5a68af121170a Mon Sep 17 00:00:00 2001 From: dpranke Date: Mon, 13 Jul 2015 11:52:02 -0700 Subject: [PATCH] Revert of Compute if a layer is clipped outside CalcDrawProps (patchset #9 id:160001 of https://codereview.chromium.org/1231453002/) Reason for revert: It looks like this is causing MSAN failures from an uninitialized variable in the webkit_tests: http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Linux%20MSAN/builds/4378/steps/webkit_tests/logs/stdio 10:00:36.214 29049 ==29058==WARNING: MemorySanitizer: use-of-uninitialized-value 10:00:36.214 29049 #0 0x7f620bf62c3e in set_is_clipped cc/layers/layer.h:503:9 10:00:36.214 29049 #1 0x7f620bf62c3e in AddClipNodeIfNeeded cc/trees/property_tree_builder.cc:149:0 10:00:36.214 29049 #2 0x7f620bf62c3e in void cc::(anonymous namespace)::BuildPropertyTreesInternal(cc::Layer*, cc::(anonymous namespace)::DataForRecursion const&) cc/trees/property_tree_builder.cc:386:0 10:00:36.214 29049 #3 0x7f620bf5d128 in void cc::BuildPropertyTreesTopLevelInternal(cc::Layer*, cc::Layer const*, cc::Layer const*, cc::Layer const*, float, float, gfx::Rect const&, gfx::Transform const&, cc::PropertyTrees*) cc/trees/property_tree_builder.cc:466:3 10:00:36.214 29049 #4 0x7f620c206ee6 in cc::BuildPropertyTreesAndComputeVisibleRects(cc::Layer*, cc::Layer const*, cc::Layer const*, cc::Layer const*, float, float, gfx::Rect const&, gfx::Transform const&, cc::PropertyTrees*, std::__1::vector, std::__1::allocator > >*) cc/trees/draw_property_utils.cc:473:3 10:00:36.214 29049 #5 0x7f620be94a2f in cc::LayerTreeHost::DoUpdateLayers(cc::Layer*) cc/trees/layer_tree_host.cc:789:5 on pretty much every test. So I'm reverting this. Sorry! Original issue's description: > Compute if a layer is clipped outside CalcDrawProps > > We need to know if a layer is clipped to compute its drawable > visible rect. So, we need to compute it outside CalcDrawProps to move > drawable visible rect computation outside CalcDrawProps. > > Committed: https://crrev.com/2af7226e29be65a8ea4a279b9358a6fcfada5cd3 > Cr-Commit-Position: refs/heads/master@{#338515} TBR=ajuma@chromium.org,enne@chromium.org,vollick@chromium.org,jaydasika@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1236943002 Cr-Commit-Position: refs/heads/master@{#338542} --- .../delegated_renderer_layer_impl_unittest.cc | 4 --- cc/layers/draw_properties.h | 4 +++ cc/layers/layer.cc | 2 -- cc/layers/layer.h | 10 +----- cc/layers/layer_impl.cc | 6 ++-- cc/layers/layer_impl.h | 8 +---- cc/layers/layer_impl_unittest.cc | 1 - cc/layers/picture_layer_impl_unittest.cc | 2 -- cc/test/fake_layer_tree_host_impl.cc | 1 - cc/trees/layer_tree_host_common.cc | 38 ++++++++++------------ cc/trees/layer_tree_host_common_unittest.cc | 2 -- cc/trees/layer_tree_host_impl_unittest.cc | 2 -- cc/trees/layer_tree_impl.cc | 1 - cc/trees/layer_tree_impl_unittest.cc | 3 -- cc/trees/property_tree_builder.cc | 5 +-- 15 files changed, 27 insertions(+), 62 deletions(-) diff --git a/cc/layers/delegated_renderer_layer_impl_unittest.cc b/cc/layers/delegated_renderer_layer_impl_unittest.cc index daaaa274caf4..a2e8d7047252 100644 --- a/cc/layers/delegated_renderer_layer_impl_unittest.cc +++ b/cc/layers/delegated_renderer_layer_impl_unittest.cc @@ -1250,7 +1250,6 @@ TEST_F(DelegatedRendererLayerImplTestClip, SetUpTest(); LayerTreeHostImpl::FrameData frame; - host_impl_->active_tree()->BuildPropertyTreesForTesting(); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); ASSERT_EQ(2u, frame.render_passes.size()); @@ -1281,7 +1280,6 @@ TEST_F(DelegatedRendererLayerImplTestClip, SetUpTest(); LayerTreeHostImpl::FrameData frame; - host_impl_->active_tree()->BuildPropertyTreesForTesting(); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); ASSERT_EQ(2u, frame.render_passes.size()); @@ -1372,7 +1370,6 @@ TEST_F(DelegatedRendererLayerImplTestClip, delegated_renderer_layer_->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; - host_impl_->active_tree()->BuildPropertyTreesForTesting(); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); ASSERT_EQ(3u, frame.render_passes.size()); @@ -1401,7 +1398,6 @@ TEST_F(DelegatedRendererLayerImplTestClip, QuadsClipped_LayerClipped_Surface) { delegated_renderer_layer_->SetHasRenderSurface(true); LayerTreeHostImpl::FrameData frame; - host_impl_->active_tree()->BuildPropertyTreesForTesting(); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); ASSERT_EQ(3u, frame.render_passes.size()); diff --git a/cc/layers/draw_properties.h b/cc/layers/draw_properties.h index 4dcd85e2a8b1..5a07af04e32d 100644 --- a/cc/layers/draw_properties.h +++ b/cc/layers/draw_properties.h @@ -25,6 +25,7 @@ struct CC_EXPORT DrawProperties { target_space_transform_is_animating(false), screen_space_transform_is_animating(false), can_use_lcd_text(false), + is_clipped(false), render_target(nullptr), num_unclipped_descendants(0), layer_or_descendant_has_copy_request(false), @@ -69,6 +70,9 @@ struct CC_EXPORT DrawProperties { // True if the layer can use LCD text. bool can_use_lcd_text; + // True if the layer needs to be clipped by clip_rect. + bool is_clipped; + // The layer whose coordinate space this layer draws into. This can be // either the same layer (draw_properties_.render_target == this) or an // ancestor of this layer. diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index e085802076eb..b9867d6217c8 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -1215,7 +1215,6 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { layer->SetShouldFlattenTransform(should_flatten_transform_); layer->set_should_flatten_transform_from_property_tree( should_flatten_transform_from_property_tree_); - layer->set_is_clipped(is_clipped_); layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); @@ -1417,7 +1416,6 @@ void Layer::SetHasRenderSurface(bool has_render_surface) { // We do not need SetNeedsCommit here, since this is only ever called // during a commit, from CalculateDrawProperties. SetNeedsPushProperties(); - layer_tree_host_->property_trees()->needs_rebuild = true; } void Layer::CreateRenderSurface() { diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 2d4d1edc71d8..3ff2810c9d63 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -252,6 +252,7 @@ class CC_EXPORT Layer : public base::RefCounted, bool screen_space_opacity_is_animating() const { return draw_properties_.screen_space_opacity_is_animating; } + bool is_clipped() const { return draw_properties_.is_clipped; } gfx::Rect clip_rect() const { return draw_properties_.clip_rect; } gfx::Rect drawable_content_rect() const { return draw_properties_.drawable_content_rect; @@ -499,14 +500,6 @@ class CC_EXPORT Layer : public base::RefCounted, return should_flatten_transform_from_property_tree_; } - void set_is_clipped(bool is_clipped) { - if (is_clipped_ == is_clipped) - return; - is_clipped_ = is_clipped; - SetNeedsPushProperties(); - } - bool is_clipped() const { return is_clipped_; } - // TODO(vollick): These values are temporary and will be removed as soon as // render surface determinations are moved out of CDP. They only exist because // certain logic depends on whether or not a layer would render to a separate @@ -705,7 +698,6 @@ class CC_EXPORT Layer : public base::RefCounted, int num_children_with_scroll_parent_; gfx::Vector2dF offset_to_transform_parent_; bool should_flatten_transform_from_property_tree_ : 1; - bool is_clipped_ : 1; bool should_scroll_on_main_thread_ : 1; bool have_wheel_event_handlers_ : 1; bool have_scroll_event_handlers_ : 1; diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 0a987334752c..75e5b0394cd8 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -60,7 +60,6 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, double_sided_(true), should_flatten_transform_(true), should_flatten_transform_from_property_tree_(false), - is_clipped_(false), layer_property_changed_(false), masks_to_bounds_(false), contents_opaque_(false), @@ -291,7 +290,7 @@ void LayerImpl::ClearRenderSurfaceLayerList() { void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { state->SetAll(draw_properties_.target_space_transform, bounds(), draw_properties_.visible_layer_rect, draw_properties_.clip_rect, - is_clipped_, draw_properties_.opacity, + draw_properties_.is_clipped, draw_properties_.opacity, draw_properties_.blend_mode, sorting_context_id_); } @@ -306,7 +305,7 @@ void LayerImpl::PopulateScaledSharedQuadState(SharedQuadState* state, scaled_visible_layer_rect.Intersect(gfx::Rect(scaled_bounds)); state->SetAll(scaled_draw_transform, scaled_bounds, scaled_visible_layer_rect, - draw_properties().clip_rect, is_clipped_, + draw_properties().clip_rect, draw_properties().is_clipped, draw_properties().opacity, draw_properties().blend_mode, sorting_context_id_); } @@ -547,7 +546,6 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { layer->SetShouldFlattenTransform(should_flatten_transform_); layer->set_should_flatten_transform_from_property_tree( should_flatten_transform_from_property_tree_); - layer->set_is_clipped(is_clipped_); layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index abad79f1b5a4..f26921c05f8e 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -183,12 +183,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, return should_flatten_transform_from_property_tree_; } - void set_is_clipped(bool is_clipped) { - is_clipped_ = is_clipped; - SetNeedsPushProperties(); - } - bool is_clipped() const { return is_clipped_; } - void UpdatePropertyTreeTransform(); void UpdatePropertyTreeOpacity(); void UpdatePropertyTreeScrollOffset(); @@ -399,6 +393,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, return draw_properties_.screen_space_opacity_is_animating; } bool can_use_lcd_text() const { return draw_properties_.can_use_lcd_text; } + bool is_clipped() const { return draw_properties_.is_clipped; } gfx::Rect clip_rect() const { return draw_properties_.clip_rect; } gfx::Rect drawable_content_rect() const { return draw_properties_.drawable_content_rect; @@ -776,7 +771,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, bool double_sided_ : 1; bool should_flatten_transform_ : 1; bool should_flatten_transform_from_property_tree_ : 1; - bool is_clipped_ : 1; // Tracks if drawing-related properties have changed since last redraw. bool layer_property_changed_ : 1; diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc index 0676597eb760..964b9994085e 100644 --- a/cc/layers/layer_impl_unittest.cc +++ b/cc/layers/layer_impl_unittest.cc @@ -310,7 +310,6 @@ TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { // Unrelated functions, always set to new values, always set needs update. VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( layer->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 4))); - host_impl.active_tree()->BuildPropertyTreesForTesting(); VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index ce0956e61048..6e89caa802a7 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -1333,7 +1333,6 @@ TEST_F(PictureLayerImplTest, HugeMasksGetScaledDown) { pending_layer_->SetMaskLayer(mask_ptr.Pass()); pending_layer_->SetHasRenderSurface(true); - host_impl_.pending_tree()->BuildPropertyTreesForTesting(); host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); @@ -1463,7 +1462,6 @@ TEST_F(PictureLayerImplTest, ScaledMaskLayer) { pending_layer_->SetMaskLayer(mask_ptr.Pass()); pending_layer_->SetHasRenderSurface(true); - host_impl_.pending_tree()->BuildPropertyTreesForTesting(); host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); bool update_lcd_text = false; host_impl_.pending_tree()->UpdateDrawProperties(update_lcd_text); diff --git a/cc/test/fake_layer_tree_host_impl.cc b/cc/test/fake_layer_tree_host_impl.cc index fba9a99dce29..fe316a79b3f0 100644 --- a/cc/test/fake_layer_tree_host_impl.cc +++ b/cc/test/fake_layer_tree_host_impl.cc @@ -91,7 +91,6 @@ void FakeLayerTreeHostImpl::UpdateNumChildrenAndDrawProperties( LayerTreeImpl* layerTree) { RecursiveUpdateNumChildren(layerTree->root_layer()); bool update_lcd_text = false; - layerTree->BuildPropertyTreesForTesting(); layerTree->UpdateDrawProperties(update_lcd_text); } diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index 9989031d74c8..427a3c825e11 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -2047,7 +2047,7 @@ static void CalculateDrawPropertiesInternal( // reduce how much would be drawn, and instead it would create unnecessary // changes to scissor state affecting GPU performance. Our clip information // is used in the recursion below, so we must set it beforehand. - DCHECK_EQ(layer_or_ancestor_clips_descendants, layer->is_clipped()); + layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; if (layer_or_ancestor_clips_descendants) { layer_draw_properties.clip_rect = clip_rect_in_target_space; } else { @@ -2487,7 +2487,6 @@ void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer, << "expected: " << current_layer->draw_opacity() << " actual: " << DrawOpacityFromPropertyTrees( current_layer, property_trees->opacity_tree); - const bool can_use_lcd_text_match = CanUseLcdTextFromPropertyTrees( current_layer, layers_always_allowed_lcd_text, can_use_lcd_text, @@ -2537,6 +2536,22 @@ void CalculateDrawPropertiesAndVerify(LayerTreeHostCommon::CalcDrawPropsInputs< inputs->verify_property_trees && (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); + if (should_measure_property_tree_performance) { + TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), + "LayerTreeHostCommon::CalculateDrawProperties"); + } + + std::vector> accumulated_surface_state; + CalculateDrawPropertiesInternal( + inputs->root_layer, globals, data_for_recursion, + inputs->render_surface_layer_list, &dummy_layer_list, + &accumulated_surface_state, inputs->current_render_surface_layer_list_id); + + if (should_measure_property_tree_performance) { + TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), + "LayerTreeHostCommon::CalculateDrawProperties"); + } + if (inputs->verify_property_trees) { typename LayerType::LayerListType update_layer_list; @@ -2579,26 +2594,9 @@ void CalculateDrawPropertiesAndVerify(LayerTreeHostCommon::CalcDrawPropsInputs< break; } } - } - if (should_measure_property_tree_performance) { - TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), - "LayerTreeHostCommon::CalculateDrawProperties"); - } - - std::vector> accumulated_surface_state; - CalculateDrawPropertiesInternal( - inputs->root_layer, globals, data_for_recursion, - inputs->render_surface_layer_list, &dummy_layer_list, - &accumulated_surface_state, inputs->current_render_surface_layer_list_id); - - if (should_measure_property_tree_performance) { - TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), - "LayerTreeHostCommon::CalculateDrawProperties"); - } - - if (inputs->verify_property_trees) VerifyPropertyTreeValues(inputs); + } // The dummy layer list should not have been used. DCHECK_EQ(0u, dummy_layer_list.size()); diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 8d6a65921d70..43e2bb021234 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -7176,7 +7176,6 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { // Add a mask layer to child. child_raw->SetMaskLayer(LayerImpl::Create(host_impl.active_tree(), 6).Pass()); - child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; ExecuteCalculateDrawProperties(grand_parent_raw); member_id = render_surface_layer_list_count(); @@ -7268,7 +7267,6 @@ TEST_F(LayerTreeHostCommonTest, RenderSurfaceLayerListMembership) { EXPECT_EQ(expected, actual); child_raw->TakeMaskLayer(); - child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; // Now everyone's a member! grand_parent_raw->SetDrawsContent(true); diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index e02990ff898a..daa179f62ebf 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -2310,7 +2310,6 @@ TEST_F(LayerTreeHostImplTest, DidDrawNotCalledOnHiddenLayer) { EXPECT_FALSE(layer->will_draw_called()); EXPECT_FALSE(layer->did_draw_called()); - host_impl_->active_tree()->BuildPropertyTreesForTesting(); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); host_impl_->DidDrawAllLayers(frame); @@ -5633,7 +5632,6 @@ TEST_F(LayerTreeHostImplTest, NoPartialSwap) { harness.MustSetScissor(0, 0, 10, 10); { LayerTreeHostImpl::FrameData frame; - host_impl_->active_tree()->BuildPropertyTreesForTesting(); EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); host_impl_->DrawLayers(&frame); host_impl_->DidDrawAllLayers(frame); diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 14e9dc5fa949..8f351f0738c3 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -751,7 +751,6 @@ bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) { } void LayerTreeImpl::BuildPropertyTreesForTesting() { - LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer_.get()); PropertyTreeBuilder::BuildPropertyTrees( root_layer_.get(), page_scale_layer_, inner_viewport_scroll_layer_, outer_viewport_scroll_layer_, current_page_scale_factor(), diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index 9e8fee5ab53d..81a566fe7f32 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -972,9 +972,6 @@ TEST_F(LayerTreeImplTest, HitTestingRespectsScrollParents) { // This should cause scroll child and its descendants to be affected by // |child|'s clip. scroll_child->SetScrollParent(child.get()); - scoped_ptr> scroll_children(new std::set); - scroll_children->insert(scroll_child.get()); - child->SetScrollChildren(scroll_children.release()); SetLayerPropertiesForTesting(grand_child.get(), identity_matrix, transform_origin, position, bounds, true, diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc index 8ad44070ec7f..28ad43f30911 100644 --- a/cc/trees/property_tree_builder.cc +++ b/cc/trees/property_tree_builder.cc @@ -100,8 +100,7 @@ void AddClipNodeIfNeeded(const DataForRecursion& data_from_ancestor, int parent_id = parent->id; bool ancestor_clips_subtree = - data_from_ancestor.ancestor_clips_subtree || - (layer->clip_parent() && layer->clip_parent()->is_clipped()); + data_from_ancestor.ancestor_clips_subtree || layer->clip_parent(); data_for_children->ancestor_clips_subtree = false; bool has_unclipped_surface = false; @@ -146,8 +145,6 @@ void AddClipNodeIfNeeded(const DataForRecursion& data_from_ancestor, layer->SetClipTreeIndex( has_unclipped_surface ? 0 : data_for_children->clip_tree_parent); - layer->set_is_clipped(data_for_children->ancestor_clips_subtree); - // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the // clip for all children since we may need to draw. We need to figure out a // better way, since we will need both the clipped and unclipped versions. -- 2.11.4.GIT