diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 00:23:32 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 00:23:32 +0000 |
commit | 8f7f29882ae400ad26b9ce946902c31203e8ab82 (patch) | |
tree | 2279498f58d10f7db73b10271d82c57f574c3977 /cc | |
parent | 58866edd73b250c8ea710be74144b22a5d35e2cc (diff) | |
download | chromium_src-8f7f29882ae400ad26b9ce946902c31203e8ab82.zip chromium_src-8f7f29882ae400ad26b9ce946902c31203e8ab82.tar.gz chromium_src-8f7f29882ae400ad26b9ce946902c31203e8ab82.tar.bz2 |
cc: Remove EnsureRenderSurfaceLayerList, do UpdateDrawProps when needed.
Hit testing is done directly on the layer tree, it doesn't use the
render surface layer list, but it does require draw properties. So,
remove EnsureRenderSurfaceLayerList and have the FindLayer* public
methods on LayerTreeImpl just do UpdateDrawProperties() if it is needed.
Since we update draw properties there, we only need to update them in
PrepareToDraw when they are dirty as well.
R=enne, vollick@chromium.org
Review URL: https://codereview.chromium.org/332433003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276864 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/layer_impl.cc | 4 | ||||
-rw-r--r-- | cc/layers/layer_impl.h | 2 | ||||
-rw-r--r-- | cc/layers/picture_image_layer_impl_unittest.cc | 27 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 33 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 2 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.cc | 22 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.h | 4 |
8 files changed, 29 insertions, 66 deletions
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 79e64aa..7668bec 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -479,10 +479,6 @@ skia::RefPtr<SkPicture> LayerImpl::GetPicture() { return skia::RefPtr<SkPicture>(); } -bool LayerImpl::AreVisibleResourcesReady() const { - return true; -} - scoped_ptr<LayerImpl> LayerImpl::CreateLayerImpl(LayerTreeImpl* tree_impl) { return LayerImpl::Create(tree_impl, layer_id_); } diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 2ce6eac..2ad1047 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -515,8 +515,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, virtual skia::RefPtr<SkPicture> GetPicture(); - virtual bool AreVisibleResourcesReady() const; - virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl); virtual void PushPropertiesTo(LayerImpl* layer); diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc index 97d522a..e8c993f 100644 --- a/cc/layers/picture_image_layer_impl_unittest.cc +++ b/cc/layers/picture_image_layer_impl_unittest.cc @@ -66,10 +66,6 @@ class PictureImageLayerImplTest : public testing::Test { return make_scoped_ptr(layer); } - void UpdateDrawProperties() { - host_impl_.pending_tree()->UpdateDrawProperties(); - } - protected: FakeImplProxy proxy_; FakeLayerTreeHostImpl host_impl_; @@ -97,29 +93,6 @@ TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { EXPECT_EQ(layer->bounds(), content_bounds); } -TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) { - scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); - layer->SetBounds(gfx::Size(100, 200)); - layer->SetDrawsContent(true); - - UpdateDrawProperties(); - - float contents_scale_x; - float contents_scale_y; - gfx::Size content_bounds; - layer->CalculateContentsScale(2.f, - 3.f, - 4.f, - 1.f, - false, - &contents_scale_x, - &contents_scale_y, - &content_bounds); - layer->UpdateTilePriorities(); - - EXPECT_TRUE(layer->AreVisibleResourcesReady()); -} - TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { scoped_ptr<TestablePictureImageLayerImpl> pending_layer( CreateLayer(1, PENDING_TREE)); diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 309f874..e648bc2 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -154,17 +154,17 @@ class LayerTreeHostImplTimeSourceAdapter : public TimeSourceClient { new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); } - // TODO(enne): This should probably happen post-animate. - if (layer_tree_host_impl_->pending_tree()) { - layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); - layer_tree_host_impl_->ManageTiles(); - } - layer_tree_host_impl_->Animate( layer_tree_host_impl_->CurrentFrameTimeTicks()); layer_tree_host_impl_->UpdateBackgroundAnimateTicking(true); bool start_ready_animations = true; layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); + + if (layer_tree_host_impl_->pending_tree()) { + layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); + layer_tree_host_impl_->ManageTiles(); + } + layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); } @@ -474,9 +474,6 @@ bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( if (!CurrentlyScrollingLayer()) return false; - if (!EnsureRenderSurfaceLayerList()) - return false; - gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, device_scale_factor_); @@ -493,8 +490,6 @@ bool LayerTreeHostImpl::HaveTouchEventHandlersAt( const gfx::Point& viewport_point) { if (!settings_.touch_hit_testing) return true; - if (!EnsureRenderSurfaceLayerList()) - return false; gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, device_scale_factor_); @@ -1094,7 +1089,8 @@ DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { } need_to_update_visible_tiles_before_draw_ = true; - active_tree_->UpdateDrawProperties(); + bool ok = active_tree_->UpdateDrawProperties(); + DCHECK(ok) << "UpdateDrawProperties failed during draw"; frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); frame->render_passes.clear(); @@ -2134,11 +2130,6 @@ void LayerTreeHostImpl::DidChangeTopControlsPosition() { SetFullRootLayerDamage(); } -bool LayerTreeHostImpl::EnsureRenderSurfaceLayerList() { - active_tree_->UpdateDrawProperties(); - return !active_tree_->RenderSurfaceLayerList().empty(); -} - void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { DCHECK(input_handler_client_ == NULL); input_handler_client_ = client; @@ -2159,7 +2150,7 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( DCHECK(scroll_on_main_thread); // Walk up the hierarchy and look for a scrollable layer. - LayerImpl* potentially_scrolling_layer_impl = 0; + LayerImpl* potentially_scrolling_layer_impl = NULL; for (; layer_impl; layer_impl = NextScrollLayer(layer_impl)) { // The content layer can also block attempts to scroll outside the main // thread. @@ -2221,9 +2212,6 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBegin( DCHECK(!CurrentlyScrollingLayer()); ClearCurrentlyScrollingLayer(); - if (!EnsureRenderSurfaceLayerList()) - return ScrollIgnored; - gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, device_scale_factor_); LayerImpl* layer_impl = @@ -2587,9 +2575,6 @@ float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( } void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { - if (!EnsureRenderSurfaceLayerList()) - return; - gfx::PointF device_viewport_point = gfx::ScalePoint(viewport_point, device_scale_factor_); LayerImpl* layer_impl = diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 7921df8..86eaf1d 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -522,7 +522,6 @@ class CC_EXPORT LayerTreeHostImpl // the frame should be drawn. DrawResult CalculateRenderPasses(FrameData* frame); - bool EnsureRenderSurfaceLayerList(); void ClearCurrentlyScrollingLayer(); bool HandleMouseOverScrollbar(LayerImpl* layer_impl, diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 45d533b..91f98ae 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -538,7 +538,7 @@ TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { // We should not crash when trying to scroll after the renderer initialization // fails. - EXPECT_EQ(InputHandler::ScrollIgnored, + EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); } diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 947e817..eef2554 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -435,16 +435,19 @@ void LayerTreeImpl::ClearViewportLayers() { outer_viewport_scroll_layer_ = NULL; } -void LayerTreeImpl::UpdateDrawProperties() { - needs_update_draw_properties_ = false; - render_surface_layer_list_.clear(); +bool LayerTreeImpl::UpdateDrawProperties() { + if (!needs_update_draw_properties_) + return true; // For max_texture_size. if (!layer_tree_host_impl_->renderer()) - return; + return false; if (!root_layer()) - return; + return false; + + needs_update_draw_properties_ = false; + render_surface_layer_list_.clear(); { TRACE_EVENT2("cc", @@ -507,6 +510,7 @@ void LayerTreeImpl::UpdateDrawProperties() { DCHECK(!needs_update_draw_properties_) << "CalcDrawProperties should not set_needs_update_draw_properties()"; + return true; } const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { @@ -1224,6 +1228,10 @@ struct HitTestVisibleScrollableOrTouchableFunctor { LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( const gfx::PointF& screen_space_point) { + if (!root_layer()) + return NULL; + if (!UpdateDrawProperties()) + return NULL; FindClosestMatchingLayerDataForRecursion data_for_recursion; FindClosestMatchingLayer(screen_space_point, root_layer(), @@ -1263,6 +1271,10 @@ struct FindTouchEventLayerFunctor { LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( const gfx::PointF& screen_space_point) { + if (!root_layer()) + return NULL; + if (!UpdateDrawProperties()) + return NULL; FindTouchEventLayerFunctor func = {screen_space_point}; FindClosestMatchingLayerDataForRecursion data_for_recursion; FindClosestMatchingLayer( diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index b29229a1..3b3c6cf 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -171,8 +171,8 @@ class CC_EXPORT LayerTreeImpl { float sent_page_scale_delta() const { return sent_page_scale_delta_; } // Updates draw properties and render surface layer list, as well as tile - // priorities. - void UpdateDrawProperties(); + // priorities. Returns false if it was unable to update. + bool UpdateDrawProperties(); void set_needs_update_draw_properties() { needs_update_draw_properties_ = true; |