summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/render_view.h2
-rw-r--r--chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc5
-rw-r--r--ppapi/c/dev/ppb_graphics_3d_dev.h11
-rw-r--r--ppapi/cpp/dev/graphics_3d_dev.cc5
-rw-r--r--ppapi/cpp/dev/graphics_3d_dev.h3
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc6
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.cc36
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.h15
8 files changed, 67 insertions, 16 deletions
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index d7589dc..ae7bc6a 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -669,13 +669,13 @@ class RenderView : public RenderWidget,
// appropriate section, add it there. If not, there are some random functions
// nearer to the top you can add it to.
+ virtual void DidFlushPaint();
protected:
// RenderWidget overrides:
virtual void Close();
virtual void OnResize(const gfx::Size& new_size,
const gfx::Rect& resizer_rect);
virtual void DidInitiatePaint();
- virtual void DidFlushPaint();
virtual bool GetBitmapForOptimizedPluginPaint(
const gfx::Rect& paint_bounds,
TransportDIB** dib,
diff --git a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc
index 659c8be..1be5461 100644
--- a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc
+++ b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc
@@ -116,6 +116,11 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize(
renderview->routing_id(),
kWebGraphicsContext3DPerferredGLExtensions,
attribs);
+ if (context_) {
+ ggl::SetSwapBuffersCallback(
+ context_,
+ NewCallback(renderview, &RenderView::DidFlushPaint));
+ }
} else {
bool compositing_enabled = !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableAcceleratedCompositing);
diff --git a/ppapi/c/dev/ppb_graphics_3d_dev.h b/ppapi/c/dev/ppb_graphics_3d_dev.h
index 7bd739b..eb8c150 100644
--- a/ppapi/c/dev/ppb_graphics_3d_dev.h
+++ b/ppapi/c/dev/ppb_graphics_3d_dev.h
@@ -6,6 +6,7 @@
#define PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_
#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
@@ -20,12 +21,12 @@
// CHECK(device->MakeCurrent(context));
// glClear(GL_COLOR_BUFFER);
// CHECK(device->MakeCurrent(NULL));
-// CHECK(device->SwapBuffers(context));
+// CHECK(device->SwapBuffers(context, callback));
//
// // Shutdown.
// core->ReleaseResource(context);
-#define PPB_GRAPHICS_3D_DEV_INTERFACE "PPB_Graphics3D(Dev);0.3"
+#define PPB_GRAPHICS_3D_DEV_INTERFACE "PPB_Graphics3D(Dev);0.4"
// These are the same error codes as used by EGL.
enum {
@@ -89,11 +90,15 @@ struct PPB_Graphics3D_Dev {
// Snapshots the rendered frame and makes it available for composition with
// the rest of the page. The alpha channel is used for translucency effects.
// One means fully opaque. Zero means fully transparent. Any thread.
+ // The callback will be called when SwapBuffers completes. While a SwapBuffers
+ // call is pending, all subsequent SwapBuffers calls will fail. Specifying a
+ // NULL callback means blocking but this is not legal on the main thread.
// TODO(apatrick): premultiplied alpha or linear alpha? Premultiplied alpha is
// better for correct alpha blending effect. Most existing OpenGL code assumes
// linear. I could convert from linear to premultiplied during the copy from
// back-buffer to offscreen "front-buffer".
- PP_Bool (*SwapBuffers)(PP_Resource context);
+ PP_Bool (*SwapBuffers)(PP_Resource context,
+ struct PP_CompletionCallback callback);
// Returns the current error for this thread. This is not associated with a
// particular context. It is distinct from the GL error returned by
diff --git a/ppapi/cpp/dev/graphics_3d_dev.cc b/ppapi/cpp/dev/graphics_3d_dev.cc
index a15417c..b1fa037 100644
--- a/ppapi/cpp/dev/graphics_3d_dev.cc
+++ b/ppapi/cpp/dev/graphics_3d_dev.cc
@@ -119,8 +119,9 @@ bool Graphics3D_Dev::MakeCurrent() const {
return graphics_3d_f && graphics_3d_f->MakeCurent(pp_resource());
}
-bool Graphics3D_Dev::SwapBuffers() const {
- return graphics_3d_f && graphics_3d_f->SwapBuffers(pp_resource());
+bool Graphics3D_Dev::SwapBuffers(const CompletionCallback& cc) const {
+ return graphics_3d_f && graphics_3d_f->SwapBuffers(
+ pp_resource(), cc.pp_completion_callback());
}
} // namespace pp
diff --git a/ppapi/cpp/dev/graphics_3d_dev.h b/ppapi/cpp/dev/graphics_3d_dev.h
index 88fe47d..ac9406b 100644
--- a/ppapi/cpp/dev/graphics_3d_dev.h
+++ b/ppapi/cpp/dev/graphics_3d_dev.h
@@ -7,6 +7,7 @@
#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
#include "ppapi/c/dev/ppb_opengles_dev.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/resource.h"
@@ -41,7 +42,7 @@ class Graphics3D_Dev : public Resource {
const int32_t* attrib_list);
bool MakeCurrent() const;
- bool SwapBuffers() const;
+ bool SwapBuffers(const CompletionCallback& cc) const;
protected:
explicit Graphics3D_Dev(PP_Resource resource_id) : Resource(resource_id) {}
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 3b7aff9..6f8cbeb 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -591,7 +591,7 @@ void PluginInstance::ViewChanged(const gfx::Rect& position,
// potentially been rendered. Plan is to embed resize commands in the
// command buffer just before ViewChanged is called.
bound_graphics_3d()->ResizeBackingTexture(position.size());
- bound_graphics_3d()->SwapBuffers();
+ bound_graphics_3d()->SwapBuffers(PP_BlockUntilComplete());
}
position_ = position;
@@ -639,11 +639,15 @@ void PluginInstance::SetContentAreaFocus(bool has_focus) {
void PluginInstance::ViewInitiatedPaint() {
if (bound_graphics_2d())
bound_graphics_2d()->ViewInitiatedPaint();
+ if (bound_graphics_3d())
+ bound_graphics_3d()->ViewInitiatedPaint();
}
void PluginInstance::ViewFlushedPaint() {
if (bound_graphics_2d())
bound_graphics_2d()->ViewFlushedPaint();
+ if (bound_graphics_3d())
+ bound_graphics_3d()->ViewFlushedPaint();
}
bool PluginInstance::GetBitmapForOptimizedPluginPaint(
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
index 0355262..118c570 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
@@ -97,10 +97,10 @@ 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<PPB_Graphics3D_Impl> context(
Resource::GetAs<PPB_Graphics3D_Impl>(graphics3d));
- return BoolToPPBool(context && context->SwapBuffers());
+ return BoolToPPBool(context && context->SwapBuffers(callback));
}
uint32_t GetError() {
@@ -132,7 +132,9 @@ const PPB_Graphics3D_Dev ppb_graphics3d = {
PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginModule* module)
: Resource(module),
- bound_instance_(NULL) {
+ bound_instance_(NULL),
+ swap_initiated_(false),
+ swap_callback_(PP_BlockUntilComplete()) {
}
const PPB_Graphics3D_Dev* PPB_Graphics3D_Impl::GetInterface() {
@@ -213,10 +215,16 @@ bool PPB_Graphics3D_Impl::MakeCurrent() {
return true;
}
-bool PPB_Graphics3D_Impl::SwapBuffers() {
+bool PPB_Graphics3D_Impl::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();
}
@@ -241,6 +249,26 @@ void PPB_Graphics3D_Impl::SetSwapBuffersCallback(Callback0::Type* callback) {
platform_context_->SetSwapBuffersCallback(callback);
}
+void PPB_Graphics3D_Impl::ViewInitiatedPaint() {
+ if (swap_callback_.func) {
+ swap_initiated_ = true;
+ }
+}
+
+void PPB_Graphics3D_Impl::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 PPB_Graphics3D_Impl::GetBackingTextureId() {
if (!platform_context_.get())
return 0;
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
index 8124979..98c8885 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
@@ -48,15 +48,15 @@ class PPB_Graphics3D_Impl : public Resource {
bool Init(PP_Instance instance_id, int32_t config,
const int32_t* attrib_list);
- // Associates this PPB_Graphics3D_Impl with the given plugin instance. You can pass
- // NULL to clear the existing device. Returns true on success. In this case,
- // the last rendered frame is displayed.
+ // Associates this PPB_Graphics3D_Impl with the given plugin instance. You can
+ // pass NULL to clear the existing device. Returns true on success. In this
+ // case, the last rendered frame is displayed.
// TODO(apatrick): Figure out the best semantics here.
bool BindToInstance(PluginInstance* new_instance);
bool MakeCurrent();
- bool SwapBuffers();
+ bool SwapBuffers(PP_CompletionCallback callback);
unsigned GetError();
@@ -64,6 +64,9 @@ class PPB_Graphics3D_Impl : public Resource {
void SetSwapBuffersCallback(Callback0::Type* callback);
+ void ViewInitiatedPaint();
+ void ViewFlushedPaint();
+
unsigned GetBackingTextureId();
gpu::gles2::GLES2Implementation* impl() {
@@ -77,6 +80,10 @@ class PPB_Graphics3D_Impl : public Resource {
// to, if any. If the context is currently unbound, this will be NULL.
PluginInstance* bound_instance_;
+ // True when the page's SwapBuffers has been issued but not returned yet.
+ bool swap_initiated_;
+ PP_CompletionCallback swap_callback_;
+
// PluginDelegate's 3D Context. Responsible for providing the command buffer.
scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_;