summaryrefslogtreecommitdiffstats
path: root/cc/surfaces/surface.cc
diff options
context:
space:
mode:
authorjbauman <jbauman@chromium.org>2014-08-23 15:10:23 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-23 22:11:22 +0000
commit878e9535344a864efec4c5137e3b1363f911f378 (patch)
treedb49794dd511d715d608144356c06c6d19a8faa7 /cc/surfaces/surface.cc
parentef468cde5048721e27faa4265f70f2fd0e424618 (diff)
downloadchromium_src-878e9535344a864efec4c5137e3b1363f911f378.zip
chromium_src-878e9535344a864efec4c5137e3b1363f911f378.tar.gz
chromium_src-878e9535344a864efec4c5137e3b1363f911f378.tar.bz2
Add callback when queueing frame on Surface to create backpressure.
When a frame is queued on a surface, a callback can queued that will be called when that surface is used to draw a frame. This can be used to create backpressure on renderers or the browser compositor. BUG= Review URL: https://codereview.chromium.org/465673003 Cr-Commit-Position: refs/heads/master@{#291605}
Diffstat (limited to 'cc/surfaces/surface.cc')
-rw-r--r--cc/surfaces/surface.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/cc/surfaces/surface.cc b/cc/surfaces/surface.cc
index 55c7392..32d6395 100644
--- a/cc/surfaces/surface.cc
+++ b/cc/surfaces/surface.cc
@@ -23,7 +23,8 @@ Surface::~Surface() {
}
}
-void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame) {
+void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame,
+ const base::Closure& callback) {
scoped_ptr<CompositorFrame> previous_frame = current_frame_.Pass();
current_frame_ = frame.Pass();
factory_->ReceiveFromChild(
@@ -36,10 +37,21 @@ void Surface::QueueFrame(scoped_ptr<CompositorFrame> frame) {
&previous_resources);
factory_->UnrefResources(previous_resources);
}
+ if (!draw_callback_.is_null())
+ draw_callback_.Run();
+ draw_callback_ = callback;
}
const CompositorFrame* Surface::GetEligibleFrame() {
return current_frame_.get();
}
+void Surface::RunDrawCallbacks() {
+ if (!draw_callback_.is_null()) {
+ base::Closure callback = draw_callback_;
+ draw_callback_ = base::Closure();
+ callback.Run();
+ }
+}
+
} // namespace cc