Index: cc/trees/single_thread_proxy.cc |
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc |
index acf481e39df83111c333b788f171d5205ae6dc94..6a920f140ac1861d6535368e40be779141e6cf1a 100644 |
--- a/cc/trees/single_thread_proxy.cc |
+++ b/cc/trees/single_thread_proxy.cc |
@@ -47,10 +47,6 @@ SingleThreadProxy::SingleThreadProxy( |
TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
DCHECK(Proxy::IsMainThread()); |
DCHECK(layer_tree_host); |
- |
- // Impl-side painting not supported without threaded compositing. |
- CHECK(!layer_tree_host->settings().impl_side_painting) |
- << "Threaded compositing must be enabled to use impl-side painting."; |
} |
void SingleThreadProxy::Start() { |
@@ -234,6 +230,23 @@ void SingleThreadProxy::DoCommit(const BeginFrameArgs& begin_frame_args) { |
stats_instrumentation->main_thread_rendering_stats()); |
stats_instrumentation->AccumulateAndClearMainThreadStats(); |
} |
+ |
+ if (layer_tree_host_->settings().impl_side_painting) { |
+ // TODO(enne): just commit directly to the active tree. |
+ // |
+ // Synchronously activate during commit to satisfy any potential |
+ // SetNextCommitWaitsForActivation calls. Unfortunately, the tree |
+ // might not be ready to draw, so DidActivateSyncTree must set |
+ // the flag to force the tree to not draw until textures are ready. |
+ NotifyReadyToActivate(); |
enne (OOO)
2014/08/27 23:53:38
Unfortunateness #1: This works, but feels unsafe.
danakj
2014/09/03 17:01:32
I'm confused, NotifyReadyToActivate won't cause it
enne (OOO)
2014/09/03 19:41:28
Yes, that's exactly it. NotifyReadyToActivate wil
|
+ } else { |
+ CommitComplete(); |
+ } |
+} |
+ |
+void SingleThreadProxy::CommitComplete() { |
+ DebugScopedSetMainThread main(this); |
+ |
layer_tree_host_->CommitComplete(); |
layer_tree_host_->DidBeginMainFrame(); |
timing_history_.DidCommit(); |
@@ -259,7 +272,7 @@ void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
} |
void SingleThreadProxy::SetNextCommitWaitsForActivation() { |
- // There is no activation here other than commit. So do nothing. |
+ // Activation always forced in commit, so nothing to do. |
DCHECK(Proxy::IsMainThread()); |
} |
@@ -327,8 +340,10 @@ void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
} |
void SingleThreadProxy::NotifyReadyToActivate() { |
- // Impl-side painting only. |
- NOTREACHED(); |
+ TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); |
+ DebugScopedSetImplThread impl(this); |
+ if (scheduler_on_impl_thread_) |
+ scheduler_on_impl_thread_->NotifyReadyToActivate(); |
} |
void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
@@ -342,8 +357,9 @@ void SingleThreadProxy::SetNeedsAnimateOnImplThread() { |
} |
void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { |
- // Impl-side painting only. |
- NOTREACHED(); |
+ TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsManageTilesOnImplThread"); |
+ if (scheduler_on_impl_thread_) |
+ scheduler_on_impl_thread_->SetNeedsManageTiles(); |
} |
void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( |
@@ -353,8 +369,9 @@ void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( |
} |
void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { |
- // Impl-side painting only. |
- NOTREACHED(); |
+ TRACE_EVENT0("cc", "SingleThreadProxy::DidInitializeVisibleTileOnImplThread"); |
+ if (scheduler_on_impl_thread_) |
+ scheduler_on_impl_thread_->SetNeedsRedraw(); |
} |
void SingleThreadProxy::SetNeedsCommitOnImplThread() { |
@@ -391,17 +408,48 @@ bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread( |
bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } |
+void SingleThreadProxy::RenewTreePriority() { |
+ // TODO(enne): Sync directly to the active tree in the future |
+ // so that there isn't two trees. |
+ if (scheduler_on_impl_thread_) |
+ scheduler_on_impl_thread_->SetSmoothnessTakesPriority(false); |
danakj
2014/09/03 17:01:32
Is there really any need to do this? Should we jus
enne (OOO)
2014/09/03 19:41:28
Done.
|
+} |
+ |
+void SingleThreadProxy::DidActivateSyncTree() { |
+ // Non-impl-side painting finishes commit in DoCommit. Impl-side painting |
+ // defers until here to simulate SetNextCommitWaitsForActivation. |
+ if (layer_tree_host_impl_->settings().impl_side_painting) { |
+ // This is required because NotifyReadyToActivate gets called when |
+ // the pending tree is not actually ready in the SingleThreadProxy. |
+ layer_tree_host_impl_->active_tree()->SetRequiresHighResToDraw(); |
danakj
2014/09/03 17:01:32
This is going to be bad when we are OOM? We will s
enne (OOO)
2014/09/03 19:41:28
I think the discussion we had today about raster-o
danakj
2014/09/03 19:49:30
Hm, can you explain how? I can see how that would
enne (OOO)
2014/09/03 20:02:48
Looking at TileManager, we only set RasterOnDemand
|
+ |
+ // Since activation could cause tasks to run, post CommitComplete |
+ // separately so that it runs after these tasks. This is the loose |
+ // equivalent of blocking commit until activation and also running |
+ // all tasks posted during commit/activation before CommitComplete. |
+ MainThreadTaskRunner()->PostTask( |
enne (OOO)
2014/08/27 23:53:39
Unfortunateness #2: Because activation is controll
danakj
2014/09/03 17:01:32
Ya, creating a CaptureTasks and holding it thru th
enne (OOO)
2014/09/03 19:41:28
Done.
|
+ FROM_HERE, |
+ base::Bind(&SingleThreadProxy::CommitComplete, |
+ weak_factory_.GetWeakPtr())); |
+ } |
+ |
+ UpdateBackgroundAnimateTicking(); |
+ timing_history_.DidActivateSyncTree(); |
+} |
+ |
+void SingleThreadProxy::DidManageTiles() { |
+ DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
+ DCHECK(Proxy::IsImplThread()); |
+ if (scheduler_on_impl_thread_) |
+ scheduler_on_impl_thread_->DidManageTiles(); |
+} |
+ |
void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
DCHECK(IsImplThread()); |
renderer_capabilities_for_main_thread_ = |
layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); |
} |
-void SingleThreadProxy::DidManageTiles() { |
- // Impl-side painting only. |
- NOTREACHED(); |
-} |
- |
void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
{ |
@@ -444,6 +492,9 @@ void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
frame_begin_time, base::TimeTicks(), BeginFrameArgs::DefaultInterval()); |
DoCommit(begin_frame_args); |
+ DCHECK(!layer_tree_host_impl_->settings().impl_side_painting) |
+ << "Impl-side painting and synchronous compositing are not supported."; |
+ |
LayerTreeHostImpl::FrameData frame; |
DoComposite(frame_begin_time, &frame); |
} |
@@ -644,11 +695,13 @@ void SingleThreadProxy::ScheduledActionAnimate() { |
} |
void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { |
- // Impl-side painting only. |
- NOTREACHED(); |
+ DebugScopedSetImplThread impl(this); |
+ layer_tree_host_impl_->UpdateVisibleTiles(); |
} |
void SingleThreadProxy::ScheduledActionActivateSyncTree() { |
+ DebugScopedSetImplThread impl(this); |
+ layer_tree_host_impl_->ActivateSyncTree(); |
} |
void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
@@ -669,8 +722,10 @@ void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
} |
void SingleThreadProxy::ScheduledActionManageTiles() { |
- // Impl-side painting only. |
- NOTREACHED(); |
+ TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionManageTiles"); |
+ DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
+ DebugScopedSetImplThread impl(this); |
+ layer_tree_host_impl_->ManageTiles(); |
} |
void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |