Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3315)

Unified Diff: cc/trees/single_thread_proxy.cc

Issue 508373002: cc: Single-threaded impl-side painting for unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: danakj review Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cc/trees/layer_tree_host_unittest.cc ('K') | « cc/trees/single_thread_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f585dc67d3160887eb50d33ec2d0ac45af91d0fe 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -12,7 +12,6 @@
#include "cc/quads/draw_quad.h"
#include "cc/resources/prioritized_resource_manager.h"
#include "cc/resources/resource_update_controller.h"
-#include "cc/trees/blocking_task_runner.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_host_single_thread_client.h"
#include "cc/trees/layer_tree_impl.h"
@@ -47,10 +46,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() {
@@ -94,6 +89,7 @@ void SingleThreadProxy::SetLayerTreeHostClientReady() {
MainThreadTaskRunner());
scheduler_on_impl_thread_->SetCanStart();
scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
+ scheduler_on_impl_thread_->SetSmoothnessTakesPriority(false);
}
}
@@ -192,7 +188,8 @@ void SingleThreadProxy::DoCommit(const BeginFrameArgs& begin_frame_args) {
// This CapturePostTasks should be destroyed before CommitComplete() is
// called since that goes out to the embedder, and we want the embedder
// to receive its callbacks before that.
- BlockingTaskRunner::CapturePostTasks blocked;
+ commit_blocking_task_runner_.reset(
+ new BlockingTaskRunner::CapturePostTasks);
layer_tree_host_impl_->BeginCommit();
@@ -234,6 +231,27 @@ 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();
+ } else {
+ CommitComplete();
+ }
+}
+
+void SingleThreadProxy::CommitComplete() {
+ DCHECK(!layer_tree_host_impl_->pending_tree())
+ << "Activation is expected to have synchronously occurred by now.";
+ DCHECK(commit_blocking_task_runner_.get());
danakj 2014/09/03 21:14:24 nit: don't need .get() to check scoped_ptr for NUL
enne (OOO) 2014/09/03 21:36:25 Done.
+ commit_blocking_task_runner_.reset();
+
+ DebugScopedSetMainThread main(this);
danakj 2014/09/03 21:14:24 Can you do this before the reset? To indicate main
enne (OOO) 2014/09/03 21:36:25 Done.
layer_tree_host_->CommitComplete();
layer_tree_host_->DidBeginMainFrame();
timing_history_.DidCommit();
@@ -259,7 +277,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 +345,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 +362,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 +374,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 +413,41 @@ bool SingleThreadProxy::ReduceContentsTextureMemoryOnImplThread(
bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; }
+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();
+
+ // 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(
+ 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 +490,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 +693,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 +720,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) {
« cc/trees/layer_tree_host_unittest.cc ('K') | « cc/trees/single_thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698