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

Unified Diff: cc/trees/thread_proxy.cc

Issue 60513007: Add SwapPromise support to LayerTreeHost and LayerTreeImpl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add comments for when to use QueueSwapPromise() Created 7 years, 1 month 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.cc ('K') | « cc/trees/single_thread_proxy.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/thread_proxy.cc
diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc
index 4f2f488eae8e5805ee2caff3dbda557bcc8709da..ae5a02564e4173ce68f5baba9baccb4971c91f86 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -5,6 +5,7 @@
#include "cc/trees/thread_proxy.h"
#include <string>
+#include <vector>
#include "base/auto_reset.h"
#include "base/bind.h"
@@ -24,6 +25,8 @@
#include "cc/trees/layer_tree_impl.h"
#include "ui/gfx/frame_time.h"
+namespace {
+
// Measured in seconds.
const double kSmoothnessTakesPriorityExpirationDelay = 0.25;
@@ -32,6 +35,22 @@ const double kCommitAndActivationDurationEstimationPercentile = 50.0;
const double kDrawDurationEstimationPercentile = 100.0;
const int kDrawDurationEstimatePaddingInMicroseconds = 0;
+class SwapPromiseChecker {
+ public:
+ explicit SwapPromiseChecker(cc::LayerTreeHost* layer_tree_host)
+ : layer_tree_host_(layer_tree_host) {}
+
+ ~SwapPromiseChecker() {
+ if (layer_tree_host_->HasQueuedSwapPromise())
+ layer_tree_host_->BreakSwapPromise("COMMIT ABORTED");
+ }
+
+ private:
+ cc::LayerTreeHost* layer_tree_host_;
+};
+
+} // namespace
+
namespace cc {
struct ThreadProxy::ReadbackRequest {
@@ -730,6 +749,12 @@ void ThreadProxy::BeginMainFrame(
return;
}
+ // If the commit finishes, LTH will transfer its swap promises to LTI.
+ // The dtor of SwapPromiseChecker will check LTH's swap promises, and
+ // call the swap aborted callback of the swap promises if the commit
+ // ever aborts.
+ SwapPromiseChecker swap_promise_checker(layer_tree_host_);
jamesr 2013/11/12 03:15:04 it looks like this will invoke the aborted callbac
Yufeng Shen (Slow to review) 2013/11/13 21:05:04 See comments below.
+
// Do not notify the impl thread of commit requests that occur during
// the apply/animate/layout part of the BeginMainFrameAndCommit process since
// those commit requests will get painted immediately. Once we have done
@@ -1109,6 +1134,10 @@ DrawSwapReadbackResult ThreadProxy::DrawSwapReadbackInternal(
} else if (draw_frame) {
DCHECK(swap_requested);
result.did_swap = layer_tree_host_impl_->SwapBuffers(frame);
+ if (result.did_swap)
+ layer_tree_host_impl_->active_tree()->FinishSwapPromise();
+ else
+ layer_tree_host_impl_->active_tree()->BreakSwapPromise("DID NOT SWAP");
jamesr 2013/11/12 03:15:04 whereas these calls will invoke callbacks from the
Yufeng Shen (Slow to review) 2013/11/13 21:05:04 Right. I have in the new patch set changed the in
// We don't know if we have incomplete tiles if we didn't actually swap.
if (result.did_swap) {
« cc/trees/layer_tree_host.cc ('K') | « cc/trees/single_thread_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698