| Index: webkit/glue/plugins/pepper_graphics_3d.cc
|
| diff --git a/webkit/glue/plugins/pepper_graphics_3d.cc b/webkit/glue/plugins/pepper_graphics_3d.cc
|
| index 3a5f129501c2b908cf816d2b17823b77681da457..31b41737586b61ee6a4ae1ec944cd66fab5753f1 100644
|
| --- a/webkit/glue/plugins/pepper_graphics_3d.cc
|
| +++ b/webkit/glue/plugins/pepper_graphics_3d.cc
|
| @@ -94,9 +94,9 @@ PP_Resource GetCurrentContext() {
|
| return current_context ? current_context->GetReference() : 0;
|
| }
|
|
|
| -PP_Bool SwapBuffers(PP_Resource graphics3d) {
|
| +PP_Bool SwapBuffers(PP_Resource graphics3d, PP_CompletionCallback callback) {
|
| scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d));
|
| - return BoolToPPBool(context && context->SwapBuffers());
|
| + return BoolToPPBool(context && context->SwapBuffers(callback));
|
| }
|
|
|
| uint32_t GetError() {
|
| @@ -128,7 +128,9 @@ const PPB_Graphics3D_Dev ppb_graphics3d = {
|
|
|
| Graphics3D::Graphics3D(PluginModule* module)
|
| : Resource(module),
|
| - bound_instance_(NULL) {
|
| + bound_instance_(NULL),
|
| + swap_initiated_(false),
|
| + swap_callback_(PP_BlockUntilComplete()) {
|
| }
|
|
|
| const PPB_Graphics3D_Dev* Graphics3D::GetInterface() {
|
| @@ -209,10 +211,16 @@ bool Graphics3D::MakeCurrent() {
|
| return true;
|
| }
|
|
|
| -bool Graphics3D::SwapBuffers() {
|
| +bool Graphics3D::SwapBuffers(PP_CompletionCallback callback) {
|
| if (!platform_context_.get())
|
| return false;
|
|
|
| + if (swap_callback_.func) {
|
| + // Already a pending SwapBuffers that hasn't returned yet.
|
| + return false;
|
| + }
|
| +
|
| + swap_callback_ = callback;
|
| return platform_context_->SwapBuffers();
|
| }
|
|
|
| @@ -237,6 +245,26 @@ void Graphics3D::SetSwapBuffersCallback(Callback0::Type* callback) {
|
| platform_context_->SetSwapBuffersCallback(callback);
|
| }
|
|
|
| +void Graphics3D::ViewInitiatedPaint() {
|
| + if (swap_callback_.func) {
|
| + swap_initiated_ = true;
|
| + }
|
| +}
|
| +
|
| +void Graphics3D::ViewFlushedPaint() {
|
| + // Notify any "painted" callback. See |unpainted_flush_callback_| in the
|
| + // header for more.
|
| + 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 Graphics3D::GetBackingTextureId() {
|
| if (!platform_context_.get())
|
| return 0;
|
|
|