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

Unified Diff: cc/trees/single_thread_proxy.cc

Issue 19106007: cc: Allow the main thread to cancel commits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix scheduler tests Created 7 years, 5 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
Index: cc/trees/single_thread_proxy.cc
diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc
index 484acb6486f6591c6b48225440b8d5f8cc15703b..1d28b0383b8dda335162147c09b7047fe3a08717 100644
--- a/cc/trees/single_thread_proxy.cc
+++ b/cc/trees/single_thread_proxy.cc
@@ -26,7 +26,8 @@ SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host)
layer_tree_host_(layer_tree_host),
created_offscreen_context_provider_(false),
next_frame_is_newly_committed_frame_(false),
- inside_draw_(false) {
+ inside_draw_(false),
+ can_cancel_commit_(false) {
danakj 2013/07/17 20:53:24 Init this to true? (We start without a SNC schedul
enne (OOO) 2013/07/18 17:36:37 Done.
TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
DCHECK(Proxy::IsMainThread());
DCHECK(layer_tree_host);
@@ -171,6 +172,11 @@ void SingleThreadProxy::SetNeedsAnimate() {
NOTREACHED();
}
+void SingleThreadProxy::SetNeedsUpdateLayers() {
+ DCHECK(Proxy::IsMainThread());
+ layer_tree_host_->ScheduleComposite();
+}
+
void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) {
DCHECK(Proxy::IsMainThread());
// Commit immediately.
@@ -208,6 +214,7 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) {
scoped_ptr<ScrollAndScaleSet> scroll_info =
layer_tree_host_impl_->ProcessScrollDeltas();
DCHECK(!scroll_info->scrolls.size());
+ DCHECK_EQ(1.f, scroll_info->page_scale_delta);
#endif
base::TimeDelta duration = stats_instrumentation->EndRecording(start_time);
@@ -219,6 +226,7 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) {
void SingleThreadProxy::SetNeedsCommit() {
DCHECK(Proxy::IsMainThread());
+ can_cancel_commit_ = false;
layer_tree_host_->ScheduleComposite();
}
@@ -262,6 +270,9 @@ void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) {
}
void SingleThreadProxy::SetNeedsRedrawOnImplThread() {
+ // Since commit+draw happens in a single pass for this proxy,
+ // this also prevents cancelling a commit.
+ can_cancel_commit_ = false;
layer_tree_host_->ScheduleComposite();
}
@@ -400,12 +411,26 @@ bool SingleThreadProxy::CommitAndComposite(
->UnlinkAndClearEvictedBackings();
}
+ // Reset this flag for the next commit. It's possible that UpdateLayers
+ // will force another commit, so record this flag.
+ bool can_cancel_this_commit = can_cancel_commit_ && !for_readback;
+ can_cancel_commit_ = true;
+
scoped_ptr<ResourceUpdateQueue> queue =
make_scoped_ptr(new ResourceUpdateQueue);
- layer_tree_host_->UpdateLayers(
+ bool updated = layer_tree_host_->UpdateLayers(
queue.get(), layer_tree_host_impl_->memory_allocation_limit_bytes());
layer_tree_host_->WillCommit();
+
+ if (!updated && can_cancel_this_commit) {
+ TRACE_EVENT0("cc", "EarlyOut_NoUpdates");
danakj 2013/07/17 20:53:24 nit: SingleThreadProxy::CommitAndComposite::EarlyO
enne (OOO) 2013/07/18 17:36:37 Removed with the rest of the changes to single thr
+ // From the perspective of the embedder, this commit still occurred.
+ layer_tree_host_->CommitComplete();
+ layer_tree_host_->DidBeginFrame();
+ return false;
+ }
+
DoCommit(queue.Pass());
bool result = DoComposite(offscreen_context_provider,
frame_begin_time,
@@ -413,6 +438,7 @@ bool SingleThreadProxy::CommitAndComposite(
for_readback,
frame);
layer_tree_host_->DidBeginFrame();
+
return result;
}

Powered by Google App Engine
This is Rietveld 408576698