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

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: rework SwapPromise() interface to have virtual DidSwap() & DidNotSwap() interface 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/single_thread_proxy.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 b25f8c23a16c819caffa216eb4fa67a3f1eaaab5..ff8b9a3aa3e92d05a08a143c9c7b3d450f964ed6 100644
--- a/cc/trees/thread_proxy.cc
+++ b/cc/trees/thread_proxy.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/debug/trace_event.h"
#include "base/metrics/histogram.h"
+#include "cc/base/swap_promise.h"
#include "cc/debug/benchmark_instrumentation.h"
#include "cc/input/input_handler.h"
#include "cc/output/context_provider.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())
danakj 2013/11/13 23:23:35 Do you even need this? You could just always call
Yufeng Shen (Slow to review) 2013/11/14 22:09:55 Done.
+ layer_tree_host_->BreakSwapPromise(cc::SwapPromise::COMMIT_FAILS);
+ }
+
+ private:
+ cc::LayerTreeHost* layer_tree_host_;
+};
+
+} // namespace
+
namespace cc {
struct ThreadProxy::ReadbackRequest {
@@ -730,6 +749,11 @@ void ThreadProxy::BeginMainFrame(
return;
}
+ // If the commit finishes, LTH will transfer its swap promises to LTI.
danakj 2013/11/13 23:22:09 Spell out LayerTreeHost and LayerTreeImpl
Yufeng Shen (Slow to review) 2013/11/14 22:09:55 Done.
+ // The dtor of SwapPromiseChecker will check LTH's swap promises, and
danakj 2013/11/13 23:22:09 destructor check the LayerTreeHost's swap promise
Yufeng Shen (Slow to review) 2013/11/14 22:09:55 Done.
+ // break those swap promises if the commit ever aborts.
+ SwapPromiseChecker swap_promise_checker(layer_tree_host_);
+
// 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 +1133,11 @@ 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(
+ SwapPromise::SWAP_FAILS);
// We don't know if we have incomplete tiles if we didn't actually swap.
if (result.did_swap) {
« cc/trees/single_thread_proxy.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