Index: cc/trees/layer_tree_host_impl.cc |
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc |
index 057228f03699434e3c2d73d7b314b3d602e538b9..f6204ce06b6c4c894ccfb97683d02d87f65790ce 100644 |
--- a/cc/trees/layer_tree_host_impl.cc |
+++ b/cc/trees/layer_tree_host_impl.cc |
@@ -225,7 +225,9 @@ LayerTreeHostImpl::LayerTreeHostImpl( |
shared_bitmap_manager_(shared_bitmap_manager), |
gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
task_graph_runner_(task_graph_runner), |
+ mutator_(nullptr), |
id_(id), |
+ is_scrolling_(false), |
requires_high_res_to_draw_(false), |
is_likely_to_require_a_draw_(false), |
frame_timing_tracker_(FrameTimingTracker::Create(this)) { |
@@ -327,7 +329,7 @@ void LayerTreeHostImpl::BeginCommit() { |
} |
void LayerTreeHostImpl::CommitComplete() { |
- TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
+ TRACE_EVENT0("cc,compositor-worker", "LayerTreeHostImpl::CommitComplete"); |
if (CommitToActiveTree()) { |
// We have to activate animations here or "IsActive()" is true on the layers |
@@ -458,6 +460,8 @@ void LayerTreeHostImpl::AnimateInternal(bool active_tree) { |
did_animate |= AnimateTopControls(monotonic_time); |
if (active_tree) { |
+ did_animate |= Mutate(monotonic_time); |
+ |
// Animating stuff can change the root scroll offset, so inform the |
// synchronous input handler. |
UpdateRootLayerStateForSynchronousInputHandler(); |
@@ -469,6 +473,20 @@ void LayerTreeHostImpl::AnimateInternal(bool active_tree) { |
} |
} |
+bool LayerTreeHostImpl::Mutate(base::TimeTicks monotonic_time) { |
+ if (!mutator_) |
+ return false; |
+ TRACE_EVENT0("compositor-worker", "LayerTreeHostImpl::Mutate"); |
+ if (mutator_->Mutate(monotonic_time, active_tree_.get())) |
+ client_->SetNeedsOneBeginImplFrameOnImplThread(); |
+ return true; |
+} |
+ |
+void LayerTreeHostImpl::SetNeedsMutate() { |
+ TRACE_EVENT0("compositor-worker", "LayerTreeHostImpl::SetNeedsMutate"); |
+ client_->SetNeedsOneBeginImplFrameOnImplThread(); |
+} |
+ |
bool LayerTreeHostImpl::PrepareTiles() { |
if (!tile_priorities_dirty_) |
return false; |
@@ -2057,6 +2075,7 @@ void LayerTreeHostImpl::ActivateSyncTree() { |
// If we commit to the active tree directly, this is already done during |
// commit. |
ActivateAnimations(); |
+ Mutate(CurrentBeginFrameArgs().frame_time); |
} else { |
active_tree_->ProcessUIResourceRequestQueue(); |
} |
@@ -2307,6 +2326,14 @@ void LayerTreeHostImpl::PostFrameTimingEvents( |
std::move(main_frame_events)); |
} |
+void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { |
+ if (mutator == mutator_) |
+ return; |
+ TRACE_EVENT0("compositor-worker", "LayerTreeHostImpl::SetLayerTreeMutator"); |
+ mutator_ = mutator; |
+ mutator_->SetClient(this); |
+} |
+ |
void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
ClearUIResources(); |
tile_manager_->FinishTasksAndCleanUp(); |
@@ -2778,6 +2805,7 @@ gfx::Vector2dF LayerTreeHostImpl::ScrollLayer(LayerImpl* layer_impl, |
// screen (such as wheel events) represent a fixed amount of scrolling so we |
// can just apply them directly, but the page scale factor is applied to the |
// scroll delta. |
+ base::AutoReset<bool> reset(&is_scrolling_, true); |
if (is_direct_manipulation) { |
return ScrollLayerWithViewportSpaceDelta( |
layer_impl, gfx::PointF(viewport_point), delta); |
@@ -2864,6 +2892,7 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
DCHECK(scroll_state); |
TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); |
+ base::AutoReset<bool> reset(&is_scrolling_, true); |
if (!CurrentlyScrollingLayer()) |
return InputHandlerScrollResult(); |
@@ -2929,6 +2958,9 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( |
UpdateRootLayerStateForSynchronousInputHandler(); |
} |
+ // Update compositor worker mutations which may respond to scrolling. |
+ Mutate(CurrentBeginFrameArgs().frame_time); |
+ |
return scroll_result; |
} |