diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-01 00:49:15 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-01 00:49:15 +0000 |
commit | fc20d140327d42ddccf94cc5cb698b4705f7294d (patch) | |
tree | 39eed208f91a29e0de0289d3591fae7adb94a078 /cc | |
parent | 425f6470a5339763301edc0b5af3601dd91ed313 (diff) | |
download | chromium_src-fc20d140327d42ddccf94cc5cb698b4705f7294d.zip chromium_src-fc20d140327d42ddccf94cc5cb698b4705f7294d.tar.gz chromium_src-fc20d140327d42ddccf94cc5cb698b4705f7294d.tar.bz2 |
cc: Activate sync tree instead of pending tree.
This patch does not change anything functionally. It prepares
us to skip pending tree for commit. It essentially unifies
the activation for both impl-side and non-impl-side painting
paths.
BUG=383157
Review URL: https://codereview.chromium.org/345563011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280717 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/picture_image_layer_impl_unittest.cc | 2 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 6 | ||||
-rw-r--r-- | cc/resources/tile_manager_perftest.cc | 2 | ||||
-rw-r--r-- | cc/resources/tile_manager_unittest.cc | 4 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_impl.h | 2 | ||||
-rw-r--r-- | cc/test/fake_layer_tree_host_impl_client.h | 2 | ||||
-rw-r--r-- | cc/test/layer_tree_test.cc | 14 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 103 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 10 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 16 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.h | 2 | ||||
-rw-r--r-- | cc/trees/thread_proxy.cc | 7 | ||||
-rw-r--r-- | cc/trees/thread_proxy.h | 2 |
13 files changed, 81 insertions, 91 deletions
diff --git a/cc/layers/picture_image_layer_impl_unittest.cc b/cc/layers/picture_image_layer_impl_unittest.cc index 00fc475..c7b801a 100644 --- a/cc/layers/picture_image_layer_impl_unittest.cc +++ b/cc/layers/picture_image_layer_impl_unittest.cc @@ -127,7 +127,7 @@ TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { // Push to active layer. host_impl_.pending_tree()->SetRootLayer(pending_layer.PassAs<LayerImpl>()); - host_impl_.ActivatePendingTree(); + host_impl_.ActivateSyncTree(); TestablePictureImageLayerImpl* active_layer = static_cast<TestablePictureImageLayerImpl*>( host_impl_.active_tree()->root_layer()); diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 2053c9d..401df7e 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -81,7 +81,7 @@ class PictureLayerImplTest : public testing::Test { } void ActivateTree() { - host_impl_.ActivatePendingTree(); + host_impl_.ActivateSyncTree(); CHECK(!host_impl_.pending_tree()); pending_layer_ = NULL; active_layer_ = static_cast<FakePictureLayerImpl*>( @@ -1480,7 +1480,7 @@ TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { pending_layer_->set_raster_page_scale(raster_page_scale); EXPECT_TRUE(pending_layer_->needs_post_commit_initialization()); - host_impl_.ActivatePendingTree(); + host_impl_.ActivateSyncTree(); active_layer_ = static_cast<FakePictureLayerImpl*>( host_impl_.active_tree()->LayerById(id_)); @@ -1495,7 +1495,7 @@ TEST_F(PictureLayerImplTest, RemoveInvalidTilesOnActivation) { AddDefaultTilingsWithInvalidation(gfx::Rect(0, 0, 1, 1)); FakePictureLayerImpl* recycled_layer = pending_layer_; - host_impl_.ActivatePendingTree(); + host_impl_.ActivateSyncTree(); active_layer_ = static_cast<FakePictureLayerImpl*>( host_impl_.active_tree()->LayerById(id_)); diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index e17c661..3b2df2a 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -130,7 +130,7 @@ class TileManagerPerfTest : public testing::Test { } void ActivateTree() { - host_impl_.ActivatePendingTree(); + host_impl_.ActivateSyncTree(); CHECK(!host_impl_.pending_tree()); pending_root_layer_ = NULL; active_root_layer_ = static_cast<FakePictureLayerImpl*>( diff --git a/cc/resources/tile_manager_unittest.cc b/cc/resources/tile_manager_unittest.cc index 024ca20..d62c360 100644 --- a/cc/resources/tile_manager_unittest.cc +++ b/cc/resources/tile_manager_unittest.cc @@ -476,7 +476,7 @@ class TileManagerTileIteratorTest : public testing::Test { } void ActivateTree() { - host_impl_.ActivatePendingTree(); + host_impl_.ActivateSyncTree(); CHECK(!host_impl_.pending_tree()); pending_layer_ = NULL; active_layer_ = static_cast<FakePictureLayerImpl*>( @@ -539,7 +539,7 @@ class TileManagerTileIteratorTest : public testing::Test { TEST_F(TileManagerTileIteratorTest, PairedPictureLayers) { host_impl_.CreatePendingTree(); - host_impl_.ActivatePendingTree(); + host_impl_.ActivateSyncTree(); host_impl_.CreatePendingTree(); LayerTreeImpl* active_tree = host_impl_.active_tree(); diff --git a/cc/test/fake_layer_tree_host_impl.h b/cc/test/fake_layer_tree_host_impl.h index 5963baa..38957a8 100644 --- a/cc/test/fake_layer_tree_host_impl.h +++ b/cc/test/fake_layer_tree_host_impl.h @@ -31,7 +31,7 @@ class FakeLayerTreeHostImpl : public LayerTreeHostImpl { virtual base::TimeTicks CurrentFrameTimeTicks() OVERRIDE; void SetCurrentFrameTimeTicks(base::TimeTicks current_frame_time_ticks); - using LayerTreeHostImpl::ActivatePendingTree; + using LayerTreeHostImpl::ActivateSyncTree; using LayerTreeHostImpl::manage_tiles_needed; private: diff --git a/cc/test/fake_layer_tree_host_impl_client.h b/cc/test/fake_layer_tree_host_impl_client.h index 1499047..3886a3e 100644 --- a/cc/test/fake_layer_tree_host_impl_client.h +++ b/cc/test/fake_layer_tree_host_impl_client.h @@ -41,7 +41,7 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient { virtual void PostDelayedScrollbarFadeOnImplThread( const base::Closure& start_fade, base::TimeDelta delay) OVERRIDE {} - virtual void DidActivatePendingTree() OVERRIDE {} + virtual void DidActivateSyncTree() OVERRIDE {} virtual void DidManageTiles() OVERRIDE {} }; diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index 3437f8c..51ab193 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -159,16 +159,6 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl { virtual void CommitComplete() OVERRIDE { LayerTreeHostImpl::CommitComplete(); - - // A few tests count the number of times pending tree is activated. - // When not using impl-side painting, ActivatePendingTree is not called, - // so call these test hooks functions explicitly so that they do need - // to handle non-impl-side path explicitly. - if (!settings().impl_side_painting) { - test_hooks_->WillActivateTreeOnThread(this); - test_hooks_->DidActivateTreeOnThread(this); - } - test_hooks_->CommitCompleteOnThread(this); } @@ -218,9 +208,9 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl { } } - virtual void ActivatePendingTree() OVERRIDE { + virtual void ActivateSyncTree() OVERRIDE { test_hooks_->WillActivateTreeOnThread(this); - LayerTreeHostImpl::ActivatePendingTree(); + LayerTreeHostImpl::ActivateSyncTree(); DCHECK(!pending_tree()); test_hooks_->DidActivateTreeOnThread(this); } diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index caa380e..88c4f5a 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -315,36 +315,31 @@ void LayerTreeHostImpl::BeginMainFrameAborted(bool did_handle) { void LayerTreeHostImpl::BeginCommit() { TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); - if (settings_.impl_side_painting) + if (UsePendingTreeForSync()) CreatePendingTree(); } void LayerTreeHostImpl::CommitComplete() { TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); + if (pending_tree_) + pending_tree_->ApplyScrollDeltasSinceBeginMainFrame(); + sync_tree()->set_needs_update_draw_properties(); + if (settings_.impl_side_painting) { // Impl-side painting needs an update immediately post-commit to have the // opportunity to create tilings. Other paths can call UpdateDrawProperties // more lazily when needed prior to drawing. - pending_tree()->ApplyScrollDeltasSinceBeginMainFrame(); - pending_tree_->set_needs_update_draw_properties(); - pending_tree_->UpdateDrawProperties(); + sync_tree()->UpdateDrawProperties(); // Start working on newly created tiles immediately if needed. - if (!tile_manager_ || !tile_priorities_dirty_) - NotifyReadyToActivate(); - else + if (tile_manager_ && tile_priorities_dirty_) ManageTiles(); + else + NotifyReadyToActivate(); } else { // If we're not in impl-side painting, the tree is immediately considered // active. - active_tree_->ProcessUIResourceRequestQueue(); - active_tree_->DidBecomeActive(); - - ActivateAnimations(); - - active_tree_->set_needs_update_draw_properties(); - if (time_source_client_adapter_ && time_source_client_adapter_->Active()) - DCHECK(active_tree_->root_layer()); + ActivateSyncTree(); } micro_benchmark_controller_.DidCompleteCommit(); @@ -1705,44 +1700,51 @@ void LayerTreeHostImpl::UpdateVisibleTiles() { need_to_update_visible_tiles_before_draw_ = false; } -void LayerTreeHostImpl::ActivatePendingTree() { - CHECK(pending_tree_); - TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); - +void LayerTreeHostImpl::ActivateSyncTree() { need_to_update_visible_tiles_before_draw_ = true; - active_tree_->SetRootLayerScrollOffsetDelegate(NULL); - active_tree_->PushPersistedState(pending_tree_.get()); - if (pending_tree_->needs_full_tree_sync()) { - active_tree_->SetRootLayer( - TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), - active_tree_->DetachLayerTree(), - active_tree_.get())); + if (pending_tree_) { + TRACE_EVENT_ASYNC_END0("cc", "PendingTree:waiting", pending_tree_.get()); + + active_tree_->SetRootLayerScrollOffsetDelegate(NULL); + active_tree_->PushPersistedState(pending_tree_.get()); + // Process any requests in the UI resource queue. The request queue is + // given in LayerTreeHost::FinishCommitOnImplThread. This must take place + // before the swap. + pending_tree_->ProcessUIResourceRequestQueue(); + + if (pending_tree_->needs_full_tree_sync()) { + active_tree_->SetRootLayer( + TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), + active_tree_->DetachLayerTree(), + active_tree_.get())); + } + TreeSynchronizer::PushProperties(pending_tree_->root_layer(), + active_tree_->root_layer()); + pending_tree_->PushPropertiesTo(active_tree_.get()); + + // Now that we've synced everything from the pending tree to the active + // tree, rename the pending tree the recycle tree so we can reuse it on the + // next sync. + DCHECK(!recycle_tree_); + pending_tree_.swap(recycle_tree_); + + active_tree_->SetRootLayerScrollOffsetDelegate( + root_layer_scroll_offset_delegate_); + UpdateInnerViewportContainerSize(); + } else { + active_tree_->ProcessUIResourceRequestQueue(); } - TreeSynchronizer::PushProperties(pending_tree_->root_layer(), - active_tree_->root_layer()); - DCHECK(!recycle_tree_); - - // Process any requests in the UI resource queue. The request queue is given - // in LayerTreeHost::FinishCommitOnImplThread. This must take place before - // the swap. - pending_tree_->ProcessUIResourceRequestQueue(); - - pending_tree_->PushPropertiesTo(active_tree_.get()); - - // Now that we've synced everything from the pending tree to the active - // tree, rename the pending tree the recycle tree so we can reuse it on the - // next sync. - pending_tree_.swap(recycle_tree_); active_tree_->DidBecomeActive(); - active_tree_->SetRootLayerScrollOffsetDelegate( - root_layer_scroll_offset_delegate_); ActivateAnimations(); + if (settings_.impl_side_painting) + client_->RenewTreePriority(); client_->OnCanDrawStateChanged(CanDraw()); - SetNeedsRedraw(); - client_->RenewTreePriority(); + client_->DidActivateSyncTree(); + if (!tree_activation_callback_.is_null()) + tree_activation_callback_.Run(); if (debug_state_.continuous_painting) { const RenderingStats& stats = @@ -1752,11 +1754,6 @@ void LayerTreeHostImpl::ActivatePendingTree() { stats.impl_stats.rasterize_time); } - UpdateInnerViewportContainerSize(); - client_->DidActivatePendingTree(); - if (!tree_activation_callback_.is_null()) - tree_activation_callback_.Run(); - if (time_source_client_adapter_ && time_source_client_adapter_->Active()) DCHECK(active_tree_->root_layer()); } @@ -1950,6 +1947,12 @@ void LayerTreeHostImpl::DestroyTileManager() { raster_worker_pool_.reset(); } +bool LayerTreeHostImpl::UsePendingTreeForSync() const { + // In impl-side painting, synchronize to the pending tree so that it has + // time to raster before being displayed. + return settings_.impl_side_painting; +} + bool LayerTreeHostImpl::UseZeroCopyTextureUpload() const { // Note: we use zero-copy by default when the renderer is using // shared memory resources. diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index fe9afc2..96e580f 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -94,7 +94,7 @@ class LayerTreeHostImplClient { virtual void PostDelayedScrollbarFadeOnImplThread( const base::Closure& start_fade, base::TimeDelta delay) = 0; - virtual void DidActivatePendingTree() = 0; + virtual void DidActivateSyncTree() = 0; virtual void DidManageTiles() = 0; protected: @@ -298,14 +298,11 @@ class CC_EXPORT LayerTreeHostImpl const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } // Returns the tree LTH synchronizes with. LayerTreeImpl* sync_tree() { - // In impl-side painting, synchronize to the pending tree so that it has - // time to raster before being displayed. - return settings_.impl_side_painting ? pending_tree_.get() - : active_tree_.get(); + return pending_tree_ ? pending_tree_.get() : active_tree_.get(); } virtual void CreatePendingTree(); virtual void UpdateVisibleTiles(); - virtual void ActivatePendingTree(); + virtual void ActivateSyncTree(); // Shortcuts to layers on the active tree. LayerImpl* RootLayer() const; @@ -500,6 +497,7 @@ class CC_EXPORT LayerTreeHostImpl void ReleaseTreeResources(); void EnforceZeroBudget(bool zero_budget); + bool UsePendingTreeForSync() const; bool UseZeroCopyTextureUpload() const; bool UseOneCopyTextureUpload() const; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index ed38144..12bd88b 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -122,7 +122,7 @@ class LayerTreeHostImplTest : public testing::Test, } virtual void NotifyReadyToActivate() OVERRIDE { did_notify_ready_to_activate_ = true; - host_impl_->ActivatePendingTree(); + host_impl_->ActivateSyncTree(); } virtual void SetNeedsRedrawOnImplThread() OVERRIDE { did_request_redraw_ = true; @@ -159,7 +159,7 @@ class LayerTreeHostImplTest : public testing::Test, scrollbar_fade_start_ = start_fade; requested_scrollbar_animation_delay_ = delay; } - virtual void DidActivatePendingTree() OVERRIDE {} + virtual void DidActivateSyncTree() OVERRIDE {} virtual void DidManageTiles() OVERRIDE {} void set_reduce_memory_result(bool reduce_memory_result) { @@ -3160,7 +3160,7 @@ TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { gfx::Size new_size(42, 24); host_impl_->CreatePendingTree(); CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); - host_impl_->ActivatePendingTree(); + host_impl_->ActivateSyncTree(); EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); // Un-setting the delegate should propagate the delegate's current offset to @@ -3892,7 +3892,7 @@ class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { host_impl_->DidDrawAllLayers(frame); } - virtual void DidActivatePendingTree() OVERRIDE { + virtual void DidActivateSyncTree() OVERRIDE { did_activate_pending_tree_ = true; } @@ -4050,7 +4050,7 @@ TEST_F(LayerTreeHostImplViewportCoveredTest, ActiveTreeShrinkViewportInvalid) { viewport_size_.height() + 100); host_impl_->SetViewportSize(DipSizeToPixelSize(larger_viewport)); EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); - host_impl_->ActivatePendingTree(); + host_impl_->ActivateSyncTree(); EXPECT_TRUE(did_activate_pending_tree_); EXPECT_FALSE(host_impl_->active_tree()->ViewportSizeInvalid()); @@ -5487,7 +5487,7 @@ TEST_F(LayerTreeHostImplTest, FarAwayQuadsDontNeedAA) { scrolling_layer->SetScrollClipLayer(root->id()); scrolling_layer->SetScrollOffset(scroll_offset); - host_impl_->ActivatePendingTree(); + host_impl_->ActivateSyncTree(); host_impl_->active_tree()->UpdateDrawProperties(); ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); @@ -5777,7 +5777,7 @@ TEST_F(LayerTreeHostImplTest, RequireHighResWhenVisible) { EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); host_impl_->CreatePendingTree(); - host_impl_->ActivatePendingTree(); + host_impl_->ActivateSyncTree(); EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); host_impl_->SetVisible(true); @@ -5797,7 +5797,7 @@ TEST_F(LayerTreeHostImplTest, RequireHighResAfterGpuRasterizationToggles) { EXPECT_TRUE(host_impl_->active_tree()->RequiresHighResToDraw()); host_impl_->CreatePendingTree(); - host_impl_->ActivatePendingTree(); + host_impl_->ActivateSyncTree(); EXPECT_FALSE(host_impl_->active_tree()->RequiresHighResToDraw()); host_impl_->SetUseGpuRasterization(true); diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 7ad48b4..4b95331 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -79,7 +79,7 @@ class CC_EXPORT SingleThreadProxy : public Proxy, virtual void PostDelayedScrollbarFadeOnImplThread( const base::Closure& start_fade, base::TimeDelta delay) OVERRIDE {} - virtual void DidActivatePendingTree() OVERRIDE {} + virtual void DidActivateSyncTree() OVERRIDE {} virtual void DidManageTiles() OVERRIDE {} virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index e16adb9..d62b96e 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -1017,7 +1017,7 @@ void ThreadProxy::ScheduledActionUpdateVisibleTiles() { void ThreadProxy::ScheduledActionActivatePendingTree() { TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivatePendingTree"); DCHECK(IsImplThread()); - impl().layer_tree_host_impl->ActivatePendingTree(); + impl().layer_tree_host_impl->ActivateSyncTree(); } void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { @@ -1419,10 +1419,9 @@ void ThreadProxy::PostDelayedScrollbarFadeOnImplThread( Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, start_fade, delay); } -void ThreadProxy::DidActivatePendingTree() { - TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); +void ThreadProxy::DidActivateSyncTree() { + TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); DCHECK(IsImplThread()); - DCHECK(!impl().layer_tree_host_impl->pending_tree()); if (impl().completion_event_for_commit_held_on_tree_activation) { TRACE_EVENT_INSTANT0( diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index 8d4348e..390116c 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -203,7 +203,7 @@ class CC_EXPORT ThreadProxy : public Proxy, virtual void PostDelayedScrollbarFadeOnImplThread( const base::Closure& start_fade, base::TimeDelta delay) OVERRIDE; - virtual void DidActivatePendingTree() OVERRIDE; + virtual void DidActivateSyncTree() OVERRIDE; virtual void DidManageTiles() OVERRIDE; // SchedulerClient implementation |