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) { |