diff options
author | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 06:06:22 +0000 |
---|---|---|
committer | alokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-13 06:06:22 +0000 |
commit | 12a63dac960d6714b9d6d863117ac4d734f283d4 (patch) | |
tree | 814395822f7b26f31136249f130ece554e29738c /cc/trees | |
parent | 5ca468240c6889a1744993a337909ecce7c53f51 (diff) | |
download | chromium_src-12a63dac960d6714b9d6d863117ac4d734f283d4.zip chromium_src-12a63dac960d6714b9d6d863117ac4d734f283d4.tar.gz chromium_src-12a63dac960d6714b9d6d863117ac4d734f283d4.tar.bz2 |
cc: LTHI decides which tree is used for commit.
LTH should not do anything special based on whether impl-side painting
is enabled or not. It should just get a tree from LTHI and commit to it.
This will allow us to get rid of pending tree when rasterization happens
synchronously on the compositor thread.
BUG=383157
Review URL: https://codereview.chromium.org/321223005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/trees')
-rw-r--r-- | cc/trees/layer_tree_host.cc | 63 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 23 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.cc | 10 |
4 files changed, 50 insertions, 54 deletions
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 2dacd03..51b9b4f 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -271,28 +271,15 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { contents_texture_manager_->UpdateBackingsState( host_impl->resource_provider()); - } - - // In impl-side painting, synchronize to the pending tree so that it has - // time to raster before being displayed. If no pending tree is needed, - // synchronization can happen directly to the active tree and - // unlinked contents resources can be reclaimed immediately. - LayerTreeImpl* sync_tree; - if (settings_.impl_side_painting) { - // Commits should not occur while there is already a pending tree. - DCHECK(!host_impl->pending_tree()); - host_impl->CreatePendingTree(); - sync_tree = host_impl->pending_tree(); - if (next_commit_forces_redraw_) - sync_tree->ForceRedrawNextActivation(); - } else { - if (next_commit_forces_redraw_) - host_impl->SetFullRootLayerDamage(); contents_texture_manager_->ReduceMemory(host_impl->resource_provider()); - sync_tree = host_impl->active_tree(); } - next_commit_forces_redraw_ = false; + LayerTreeImpl* sync_tree = host_impl->sync_tree(); + + if (next_commit_forces_redraw_) { + sync_tree->ForceRedrawNextActivation(); + next_commit_forces_redraw_ = false; + } sync_tree->set_source_frame_number(source_frame_number()); @@ -328,25 +315,13 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { sync_tree->ClearViewportLayers(); } - float page_scale_delta, sent_page_scale_delta; - if (settings_.impl_side_painting) { - // Update the delta from the active tree, which may have - // adjusted its delta prior to the pending tree being created. - // This code is equivalent to that in LayerTreeImpl::SetPageScaleDelta. - DCHECK_EQ(1.f, sync_tree->sent_page_scale_delta()); - page_scale_delta = host_impl->active_tree()->page_scale_delta(); - sent_page_scale_delta = host_impl->active_tree()->sent_page_scale_delta(); - } else { - page_scale_delta = sync_tree->page_scale_delta(); - sent_page_scale_delta = sync_tree->sent_page_scale_delta(); - sync_tree->set_sent_page_scale_delta(1.f); - } - - sync_tree->SetPageScaleValues( - page_scale_factor_, - min_page_scale_factor_, - max_page_scale_factor_, - page_scale_delta / sent_page_scale_delta); + float page_scale_delta = + sync_tree->page_scale_delta() / sync_tree->sent_page_scale_delta(); + sync_tree->SetPageScaleValues(page_scale_factor_, + min_page_scale_factor_, + max_page_scale_factor_, + page_scale_delta); + sync_tree->set_sent_page_scale_delta(1.f); sync_tree->PassSwapPromises(&swap_promise_list_); @@ -369,10 +344,6 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { if (!ui_resource_request_queue_.empty()) { sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); ui_resource_request_queue_.clear(); - // Process any ui resource requests in the queue. For impl-side-painting, - // the queue is processed in LayerTreeHostImpl::ActivatePendingTree. - if (!settings_.impl_side_painting) - sync_tree->ProcessUIResourceRequestQueue(); } if (overhang_ui_resource_) { host_impl->SetOverhangUIResource( @@ -387,14 +358,6 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { sync_tree->ResetContentsTexturesPurged(); } - if (!settings_.impl_side_painting) { - // If we're not in impl-side painting, the tree is immediately - // considered active. - sync_tree->DidBecomeActive(); - host_impl->ActivateAnimations(); - devtools_instrumentation::DidActivateLayerTree(id_, source_frame_number_); - } - micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); } diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index e648bc2..352ba19 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -315,7 +315,12 @@ void LayerTreeHostImpl::BeginMainFrameAborted(bool did_handle) { } } -void LayerTreeHostImpl::BeginCommit() {} +void LayerTreeHostImpl::BeginCommit() { + TRACE_EVENT0("cc", "LayerTreeHostImpl::BeginCommit"); + + if (settings_.impl_side_painting) + CreatePendingTree(); +} void LayerTreeHostImpl::CommitComplete() { TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); @@ -333,6 +338,13 @@ void LayerTreeHostImpl::CommitComplete() { else ManageTiles(); } 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()); @@ -1686,6 +1698,13 @@ void LayerTreeHostImpl::CreatePendingTree() { recycle_tree_.swap(pending_tree_); else pending_tree_ = LayerTreeImpl::create(this); + + // Update the delta from the active tree, which may have + // adjusted its delta prior to the pending tree being created. + DCHECK_EQ(1.f, pending_tree_->sent_page_scale_delta()); + pending_tree_->SetPageScaleDelta(active_tree_->page_scale_delta() / + active_tree_->sent_page_scale_delta()); + client_->OnCanDrawStateChanged(CanDraw()); TRACE_EVENT_ASYNC_BEGIN0("cc", "PendingTree:waiting", pending_tree_.get()); } @@ -1750,8 +1769,6 @@ void LayerTreeHostImpl::ActivatePendingTree() { if (time_source_client_adapter_ && time_source_client_adapter_->Active()) DCHECK(active_tree_->root_layer()); - devtools_instrumentation::DidActivateLayerTree( - id_, active_tree_->source_frame_number()); } void LayerTreeHostImpl::SetVisible(bool visible) { diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 86eaf1d..db9c325 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -265,6 +265,7 @@ class CC_EXPORT LayerTreeHostImpl void OnCanDrawStateChangedForTree(); // Implementation. + int id() const { return id_; } bool CanDraw() const; OutputSurface* output_surface() const { return output_surface_.get(); } @@ -295,6 +296,13 @@ class CC_EXPORT LayerTreeHostImpl LayerTreeImpl* pending_tree() { return pending_tree_.get(); } const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } 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(); + } virtual void CreatePendingTree(); virtual void UpdateVisibleTiles(); virtual void ActivatePendingTree(); diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index eef2554..2a38d89 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -14,6 +14,7 @@ #include "cc/animation/scrollbar_animation_controller_thinning.h" #include "cc/base/math_util.h" #include "cc/base/util.h" +#include "cc/debug/devtools_instrumentation.h" #include "cc/debug/traced_value.h" #include "cc/layers/heads_up_display_layer_impl.h" #include "cc/layers/layer.h" @@ -188,7 +189,7 @@ void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { DCHECK_EQ(ui_resource_request_queue_.size(), 0u); if (next_activation_forces_redraw_) { - layer_tree_host_impl_->SetFullRootLayerDamage(); + target_tree->ForceRedrawNextActivation(); next_activation_forces_redraw_ = false; } @@ -559,12 +560,19 @@ void LayerTreeImpl::DidBecomeActive() { if (!root_layer()) return; + if (next_activation_forces_redraw_) { + layer_tree_host_impl_->SetFullRootLayerDamage(); + next_activation_forces_redraw_ = false; + } + if (scrolling_layer_id_from_previous_tree_) { currently_scrolling_layer_ = LayerTreeHostCommon::FindLayerInSubtree( root_layer_.get(), scrolling_layer_id_from_previous_tree_); } DidBecomeActiveRecursive(root_layer()); + devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), + source_frame_number_); } bool LayerTreeImpl::ContentsTexturesPurged() const { |