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

Unified Diff: webkit/plugins/ppapi/ppb_surface_3d_impl.cc

Issue 5944001: Make Graphics3D::SwapBuffers take a completion callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update to Alok's Context3D/Surface3D changes Created 9 years, 12 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_surface_3d_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_surface_3d_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
index 0283d3b47c59bc270ea6530e835b595e4e3a9b96..5b42cf926c030e6d286dae06ba569d4555870ce4 100644
--- a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
@@ -51,7 +51,7 @@ int32_t SwapBuffers(PP_Resource surface_id,
PP_CompletionCallback callback) {
scoped_refptr<PPB_Surface3D_Impl> surface(
Resource::GetAs<PPB_Surface3D_Impl>(surface_id));
- return surface->SwapBuffers();
+ return surface->SwapBuffers(callback);
}
const PPB_Surface3D_Dev ppb_surface3d = {
@@ -68,6 +68,8 @@ PPB_Surface3D_Impl::PPB_Surface3D_Impl(PluginInstance* instance)
: Resource(instance->module()),
instance_(instance),
bound_to_instance_(false),
+ swap_initiated_(false),
+ swap_callback_(PP_BlockUntilComplete()),
context_(NULL) {
}
@@ -121,8 +123,35 @@ bool PPB_Surface3D_Impl::BindToContext(
return true;
}
-bool PPB_Surface3D_Impl::SwapBuffers() {
- return context_ && context_->SwapBuffers();
+bool PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) {
+ if (!context_)
+ return false;
+
+ if (swap_callback_.func) {
+ // Already a pending SwapBuffers that hasn't returned yet.
+ return false;
+ }
+
+ swap_callback_ = callback;
+ return context_->SwapBuffers();
+}
+
+void PPB_Surface3D_Impl::ViewInitiatedPaint() {
+ if (swap_callback_.func) {
+ swap_initiated_ = true;
+ }
+}
+
+void PPB_Surface3D_Impl::ViewFlushedPaint() {
+ if (swap_initiated_ && swap_callback_.func) {
+ // We must clear swap_callback_ before issuing the callback. It will be
+ // common for the plugin to issue another SwapBuffers in response to the
+ // callback, and we don't want to think that a callback is already pending.
+ PP_CompletionCallback callback = PP_BlockUntilComplete();
+ std::swap(callback, swap_callback_);
+ swap_initiated_ = false;
+ PP_RunCompletionCallback(&callback, PP_OK);
+ }
}
unsigned int PPB_Surface3D_Impl::GetBackingTextureId() {
« no previous file with comments | « webkit/plugins/ppapi/ppb_surface_3d_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698