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

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: Address review comments 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..999a72eb6c70533138975d2edb679e7440b42cdf 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) {
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.
@@ -219,6 +225,7 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) {
void SingleThreadProxy::SetNeedsCommit() {
DCHECK(Proxy::IsMainThread());
+ can_cancel_commit_ = false;
layer_tree_host_->ScheduleComposite();
}
@@ -262,6 +269,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 +410,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");
+ // From the perspective of the embedder, this commit still occurred.
brianderson 2013/07/15 23:11:06 Do you also need to call ApplySentScrollAndScaleDe
enne (OOO) 2013/07/16 00:15:18 I don't think so. For the single threaded case, s
+ layer_tree_host_->CommitComplete();
+ layer_tree_host_->DidBeginFrame();
+ return false;
+ }
+
DoCommit(queue.Pass());
bool result = DoComposite(offscreen_context_provider,
frame_begin_time,
@@ -413,6 +437,7 @@ bool SingleThreadProxy::CommitAndComposite(
for_readback,
frame);
layer_tree_host_->DidBeginFrame();
+
return result;
}

Powered by Google App Engine
This is Rietveld 408576698