summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc3
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc30
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h8
-rw-r--r--webkit/plugins/ppapi/ppb_context_3d_impl.cc115
-rw-r--r--webkit/plugins/ppapi/ppb_context_3d_impl.h42
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.cc139
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.h71
-rw-r--r--webkit/plugins/ppapi/resource.h1
8 files changed, 292 insertions, 117 deletions
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index a21cbf7..250261b 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -87,6 +87,7 @@
#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_opengles_impl.h"
+#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
#endif // ENABLE_GPU
namespace webkit {
@@ -290,6 +291,8 @@ const void* GetInterface(const char* name) {
return PPB_Context3D_Impl::GetInterface();
if (strcmp(name, PPB_OPENGLES2_DEV_INTERFACE) == 0)
return PPB_OpenGLES_Impl::GetInterface();
+ if (strcmp(name, PPB_SURFACE_3D_DEV_INTERFACE) == 0)
+ return PPB_Surface3D_Impl::GetInterface();
}
#endif // ENABLE_GPU
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index e0c8343..2682ac7 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -45,9 +45,9 @@
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
-#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
+#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/ppp_pdf.h"
#include "webkit/plugins/ppapi/string.h"
@@ -430,8 +430,7 @@ bool PluginInstance::BindGraphics(PP_Resource graphics_id) {
if (bound_graphics_2d()) {
bound_graphics_2d()->BindToInstance(NULL);
} else if (bound_graphics_.get()) {
- bound_graphics_3d()->SetSwapBuffersCallback(NULL);
- bound_graphics_3d()->BindToInstance(NULL);
+ bound_graphics_3d()->BindToInstance(false);
}
InvalidateRect(gfx::Rect());
}
@@ -441,8 +440,8 @@ bool PluginInstance::BindGraphics(PP_Resource graphics_id) {
scoped_refptr<PPB_Graphics2D_Impl> graphics_2d =
Resource::GetAs<PPB_Graphics2D_Impl>(graphics_id);
- scoped_refptr<PPB_Context3D_Impl> graphics_3d =
- Resource::GetAs<PPB_Context3D_Impl>(graphics_id);
+ scoped_refptr<PPB_Surface3D_Impl> graphics_3d =
+ Resource::GetAs<PPB_Surface3D_Impl>(graphics_id);
if (graphics_2d) {
if (!graphics_2d->BindToInstance(this))
@@ -470,12 +469,14 @@ bool PluginInstance::BindGraphics(PP_Resource graphics_id) {
bound_graphics_ = graphics_2d;
// BindToInstance will have invalidated the plugin if necessary.
} else if (graphics_3d) {
- if (!graphics_3d->BindToInstance(this))
+ // Make sure graphics can only be bound to the instance it is
+ // associated with.
+ if (graphics_3d->instance() != this)
+ return false;
+ if (!graphics_3d->BindToInstance(true))
return false;
bound_graphics_ = graphics_3d;
- bound_graphics_3d()->SetSwapBuffersCallback(
- NewCallback(this, &PluginInstance::CommitBackingTexture));
}
return true;
@@ -585,15 +586,6 @@ PP_Var PluginInstance::GetInstanceObject() {
void PluginInstance::ViewChanged(const gfx::Rect& position,
const gfx::Rect& clip) {
- if (position.size() != position_.size() && bound_graphics_3d()) {
- // TODO(apatrick): This is a hack to force the back buffer to resize.
- // It is obviously wrong to call SwapBuffers when a partial frame has
- // 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();
- }
-
position_ = position;
if (clip.IsEmpty()) {
@@ -1174,11 +1166,11 @@ PPB_Graphics2D_Impl* PluginInstance::bound_graphics_2d() const {
return bound_graphics_->Cast<PPB_Graphics2D_Impl>();
}
-PPB_Context3D_Impl* PluginInstance::bound_graphics_3d() const {
+PPB_Surface3D_Impl* PluginInstance::bound_graphics_3d() const {
if (bound_graphics_.get() == NULL)
return NULL;
- return bound_graphics_->Cast<PPB_Context3D_Impl>();
+ return bound_graphics_->Cast<PPB_Surface3D_Impl>();
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 801eca6..71a9fe2 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -53,8 +53,8 @@ class FullscreenContainer;
class PluginDelegate;
class PluginModule;
class PPB_Graphics2D_Impl;
-class PPB_Context3D_Impl;
class PPB_ImageData_Impl;
+class PPB_Surface3D_Impl;
class PPB_URLLoader_Impl;
class Resource;
@@ -225,9 +225,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// null if the context is not 2D.
PPB_Graphics2D_Impl* bound_graphics_2d() const;
- // Get the bound graphics context as a concrete 3D graphics context or returns
- // null if the context is not 3D.
- PPB_Context3D_Impl* bound_graphics_3d() const;
+ // Get the bound 3D graphics surface.
+ // Returns NULL if bound graphics is not a 3D surface.
+ PPB_Surface3D_Impl* bound_graphics_3d() const;
PluginDelegate* delegate_;
scoped_refptr<PluginModule> module_;
diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.cc b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
index 4a7c961..0da5dca 100644
--- a/webkit/plugins/ppapi/ppb_context_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
@@ -5,9 +5,9 @@
#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
#include "gpu/command_buffer/common/command_buffer.h"
-#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
namespace webkit {
namespace ppapi {
@@ -31,8 +31,8 @@ PP_Resource Create(PP_Instance instance_id,
return 0;
scoped_refptr<PPB_Context3D_Impl> context(
- new PPB_Context3D_Impl(instance->module()));
- if (!context->Init(instance, config, share_context, attrib_list))
+ new PPB_Context3D_Impl(instance));
+ if (!context->Init(config, share_context, attrib_list))
return 0;
return context->GetReference();
@@ -49,11 +49,25 @@ int32_t GetAttrib(PP_Resource context,
return 0;
}
-int32_t BindSurfaces(PP_Resource context,
+int32_t BindSurfaces(PP_Resource context_id,
PP_Resource draw,
PP_Resource read) {
- // TODO(alokp): Implement me.
- return 0;
+ scoped_refptr<PPB_Context3D_Impl> context(
+ Resource::GetAs<PPB_Context3D_Impl>(context_id));
+ if (!context.get())
+ return PP_ERROR_BADRESOURCE;
+
+ scoped_refptr<PPB_Surface3D_Impl> draw_surface(
+ Resource::GetAs<PPB_Surface3D_Impl>(draw));
+ if (!draw_surface.get())
+ return PP_ERROR_BADRESOURCE;
+
+ scoped_refptr<PPB_Surface3D_Impl> read_surface(
+ Resource::GetAs<PPB_Surface3D_Impl>(read));
+ if (!read_surface.get())
+ return PP_ERROR_BADRESOURCE;
+
+ return context->BindSurfaces(draw_surface.get(), read_surface.get());
}
int32_t GetBoundSurfaces(PP_Resource context,
@@ -63,28 +77,22 @@ int32_t GetBoundSurfaces(PP_Resource context,
return 0;
}
-int32_t SwapBuffers(PP_Resource context_id,
- PP_CompletionCallback callback) {
- scoped_refptr<PPB_Context3D_Impl> context(
- Resource::GetAs<PPB_Context3D_Impl>(context_id));
- return context->SwapBuffers();
-}
-
const PPB_Context3D_Dev ppb_context3d = {
&Create,
&IsContext3D,
&GetAttrib,
&BindSurfaces,
&GetBoundSurfaces,
- &SwapBuffers
};
} // namespace
-PPB_Context3D_Impl::PPB_Context3D_Impl(PluginModule* module)
- : Resource(module),
- bound_instance_(NULL),
- gles2_impl_(NULL) {
+PPB_Context3D_Impl::PPB_Context3D_Impl(PluginInstance* instance)
+ : Resource(instance->module()),
+ instance_(instance),
+ gles2_impl_(NULL),
+ draw_surface_(NULL),
+ read_surface_(NULL) {
}
PPB_Context3D_Impl::~PPB_Context3D_Impl() {
@@ -99,13 +107,11 @@ PPB_Context3D_Impl* PPB_Context3D_Impl::AsPPB_Context3D_Impl() {
return this;
}
-bool PPB_Context3D_Impl::Init(PluginInstance* instance,
- PP_Config3D_Dev config,
+bool PPB_Context3D_Impl::Init(PP_Config3D_Dev config,
PP_Resource share_context,
const int32_t* attrib_list) {
- DCHECK(instance);
// Create and initialize the objects required to issue GLES2 calls.
- platform_context_.reset(instance->delegate()->CreateContext3D());
+ platform_context_.reset(instance()->delegate()->CreateContext3D());
if (!platform_context_.get()) {
Destroy();
return false;
@@ -121,58 +127,33 @@ bool PPB_Context3D_Impl::Init(PluginInstance* instance,
return true;
}
-bool PPB_Context3D_Impl::BindToInstance(PluginInstance* new_instance) {
- if (bound_instance_ == new_instance)
- return true; // Rebinding the same device, nothing to do.
- if (bound_instance_ && new_instance)
- return false; // Can't change a bound device.
-
- if (new_instance) {
- // Resize the backing texture to the size of the instance when it is bound.
- platform_context_->ResizeBackingTexture(new_instance->position().size());
-
- // This is a temporary hack. The SwapBuffers is issued to force the resize
- // to take place before any subsequent rendering. This might lead to a
- // partially rendered frame being displayed. It is also not thread safe
- // since the SwapBuffers is written to the command buffer and that command
- // buffer might be written to by another thread.
- // TODO(apatrick): Figure out the semantics of binding and resizing.
- platform_context_->SwapBuffers();
- }
+int32_t PPB_Context3D_Impl::BindSurfaces(PPB_Surface3D_Impl* draw,
+ PPB_Surface3D_Impl* read) {
+ // TODO(alokp): Support separate draw-read surfaces.
+ DCHECK_EQ(draw, read);
+ if (draw != read)
+ return PP_GRAPHICS3DERROR_BAD_MATCH;
- bound_instance_ = new_instance;
- return true;
-}
-
-bool PPB_Context3D_Impl::SwapBuffers() {
- if (!platform_context_.get())
- return false;
-
- return platform_context_->SwapBuffers();
-}
-
-void PPB_Context3D_Impl::SetSwapBuffersCallback(Callback0::Type* callback) {
- if (!platform_context_.get())
- return;
+ if (draw == draw_surface_)
+ return PP_OK;
- platform_context_->SetSwapBuffersCallback(callback);
-}
-
-unsigned int PPB_Context3D_Impl::GetBackingTextureId() {
- if (!platform_context_.get())
- return 0;
+ if (draw && draw->context())
+ return PP_GRAPHICS3DERROR_BAD_ACCESS;
- return platform_context_->GetBackingTextureId();
-}
-
-void PPB_Context3D_Impl::ResizeBackingTexture(const gfx::Size& size) {
- if (!platform_context_.get())
- return;
+ if (draw_surface_)
+ draw_surface_->BindToContext(NULL);
+ if (draw && !draw->BindToContext(platform_context_.get()))
+ return PP_ERROR_NOMEMORY;
- platform_context_->ResizeBackingTexture(size);
+ draw_surface_ = draw;
+ read_surface_ = read;
+ return PP_OK;
}
void PPB_Context3D_Impl::Destroy() {
+ if (draw_surface_)
+ draw_surface_->BindToContext(NULL);
+
gles2_impl_ = NULL;
platform_context_.reset();
}
diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.h b/webkit/plugins/ppapi/ppb_context_3d_impl.h
index f111005..9046368 100644
--- a/webkit/plugins/ppapi/ppb_context_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_context_3d_impl.h
@@ -5,16 +5,11 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_
-#include "base/callback.h"
#include "base/scoped_ptr.h"
#include "ppapi/c/dev/ppb_context_3d_dev.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/resource.h"
-namespace gfx {
-class Size;
-}
-
namespace gpu {
namespace gles2 {
class GLES2Implementation;
@@ -24,9 +19,11 @@ class GLES2Implementation;
namespace webkit {
namespace ppapi {
+class PPB_Surface3D_Impl;
+
class PPB_Context3D_Impl : public Resource {
public:
- explicit PPB_Context3D_Impl(PluginModule* module);
+ explicit PPB_Context3D_Impl(PluginInstance* instance);
virtual ~PPB_Context3D_Impl();
static const PPB_Context3D_Dev* GetInterface();
@@ -34,38 +31,26 @@ class PPB_Context3D_Impl : public Resource {
// Resource override.
virtual PPB_Context3D_Impl* AsPPB_Context3D_Impl();
- bool Init(PluginInstance* instance,
- PP_Config3D_Dev config,
+ bool Init(PP_Config3D_Dev config,
PP_Resource share_context,
const int32_t* attrib_list);
- // Associates this PPB_Context3D_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(alokp): This is confusing. This context is already associated with
- // an instance. This function should rather be called BindToInstanceGraphics
- // or something similar which means from this point on, anything drawn with
- // this context appears on instance window. This function should also not
- // take any argument. But this means modifying PPB_Instance::BindGraphics.
- bool BindToInstance(PluginInstance* new_instance);
-
- bool SwapBuffers();
- void SetSwapBuffersCallback(Callback0::Type* callback);
-
- unsigned int GetBackingTextureId();
- void ResizeBackingTexture(const gfx::Size& size);
+ PluginInstance* instance() {
+ return instance_;
+ }
gpu::gles2::GLES2Implementation* gles2_impl() {
return gles2_impl_;
}
+ int32_t BindSurfaces(PPB_Surface3D_Impl* draw,
+ PPB_Surface3D_Impl* read);
+
private:
void Destroy();
- // Non-owning pointer to the plugin instance this context is currently bound
- // to, if any. If the context is currently unbound, this will be NULL.
- PluginInstance* bound_instance_;
+ // Plugin instance this context is associated with.
+ PluginInstance* instance_;
// PluginDelegate's 3D Context. Responsible for providing the command buffer.
scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_;
@@ -73,6 +58,9 @@ class PPB_Context3D_Impl : public Resource {
// GLES2 Implementation instance. Owned by the platform context's GGL context.
gpu::gles2::GLES2Implementation* gles2_impl_;
+ PPB_Surface3D_Impl* draw_surface_;
+ PPB_Surface3D_Impl* read_surface_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_Context3D_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
new file mode 100644
index 0000000..0283d3b
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
@@ -0,0 +1,139 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
+
+#include "gpu/command_buffer/common/command_buffer.h"
+#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+
+namespace webkit {
+namespace ppapi {
+
+namespace {
+
+PP_Resource Create(PP_Instance instance_id,
+ PP_Config3D_Dev config,
+ const int32_t* attrib_list) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return 0;
+
+ scoped_refptr<PPB_Surface3D_Impl> surface(
+ new PPB_Surface3D_Impl(instance));
+ if (!surface->Init(config, attrib_list))
+ return 0;
+
+ return surface->GetReference();
+}
+
+PP_Bool IsSurface3D(PP_Resource resource) {
+ return BoolToPPBool(!!Resource::GetAs<PPB_Surface3D_Impl>(resource));
+}
+
+int32_t SetAttrib(PP_Resource surface_id,
+ int32_t attribute,
+ int32_t value) {
+ // TODO(alokp): Implement me.
+ return 0;
+}
+
+int32_t GetAttrib(PP_Resource surface_id,
+ int32_t attribute,
+ int32_t* value) {
+ // TODO(alokp): Implement me.
+ return 0;
+}
+
+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();
+}
+
+const PPB_Surface3D_Dev ppb_surface3d = {
+ &Create,
+ &IsSurface3D,
+ &SetAttrib,
+ &GetAttrib,
+ &SwapBuffers
+};
+
+} // namespace
+
+PPB_Surface3D_Impl::PPB_Surface3D_Impl(PluginInstance* instance)
+ : Resource(instance->module()),
+ instance_(instance),
+ bound_to_instance_(false),
+ context_(NULL) {
+}
+
+PPB_Surface3D_Impl::~PPB_Surface3D_Impl() {
+}
+
+const PPB_Surface3D_Dev* PPB_Surface3D_Impl::GetInterface() {
+ return &ppb_surface3d;
+}
+
+PPB_Surface3D_Impl* PPB_Surface3D_Impl::AsPPB_Surface3D_Impl() {
+ return this;
+}
+
+bool PPB_Surface3D_Impl::Init(PP_Config3D_Dev config,
+ const int32_t* attrib_list) {
+ return true;
+}
+
+bool PPB_Surface3D_Impl::BindToInstance(bool bind) {
+ bound_to_instance_ = bind;
+ return true;
+}
+
+bool PPB_Surface3D_Impl::BindToContext(
+ PluginDelegate::PlatformContext3D* context) {
+ if (context == context_)
+ return true;
+
+ // Unbind from the current context.
+ if (context_) {
+ context_->SetSwapBuffersCallback(NULL);
+ }
+ if (context) {
+ // Resize the backing texture to the size of the instance when it is bound.
+ // TODO(alokp): This should be the responsibility of plugins.
+ context->ResizeBackingTexture(instance()->position().size());
+
+ // This is a temporary hack. The SwapBuffers is issued to force the resize
+ // to take place before any subsequent rendering. This might lead to a
+ // partially rendered frame being displayed. It is also not thread safe
+ // since the SwapBuffers is written to the command buffer and that command
+ // buffer might be written to by another thread.
+ // TODO(apatrick): Figure out the semantics of binding and resizing.
+ context->SwapBuffers();
+
+ context->SetSwapBuffersCallback(
+ NewCallback(this, &PPB_Surface3D_Impl::OnSwapBuffers));
+ }
+ context_ = context;
+ return true;
+}
+
+bool PPB_Surface3D_Impl::SwapBuffers() {
+ return context_ && context_->SwapBuffers();
+}
+
+unsigned int PPB_Surface3D_Impl::GetBackingTextureId() {
+ return context_ ? context_->GetBackingTextureId() : 0;
+}
+
+void PPB_Surface3D_Impl::OnSwapBuffers() {
+ if (bound_to_instance_)
+ instance()->CommitBackingTexture();
+}
+
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.h b/webkit/plugins/ppapi/ppb_surface_3d_impl.h
new file mode 100644
index 0000000..d09689e
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_PLUGINS_PPAPI_PPB_SURFACE_3D_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_SURFACE_3D_IMPL_H_
+
+#include "base/callback.h"
+#include "ppapi/c/dev/ppb_surface_3d_dev.h"
+#include "webkit/plugins/ppapi/plugin_delegate.h"
+#include "webkit/plugins/ppapi/resource.h"
+
+namespace gfx {
+class Size;
+}
+
+namespace webkit {
+namespace ppapi {
+
+class PPB_Surface3D_Impl : public Resource {
+ public:
+ explicit PPB_Surface3D_Impl(PluginInstance* instance);
+ virtual ~PPB_Surface3D_Impl();
+
+ static const PPB_Surface3D_Dev* GetInterface();
+
+ // Resource override.
+ virtual PPB_Surface3D_Impl* AsPPB_Surface3D_Impl();
+
+ bool Init(PP_Config3D_Dev config,
+ const int32_t* attrib_list);
+
+ PluginInstance* instance() const {
+ return instance_;
+ }
+ PluginDelegate::PlatformContext3D* context() const {
+ return context_;
+ }
+
+ // Binds/unbinds the graphics of this surface with the associated instance.
+ // If the surface is bound, anything drawn on the surface appears on instance
+ // window. Returns true if binding/unbinding is successful.
+ bool BindToInstance(bool bind);
+
+ // Binds the context such that all draw calls to context
+ // affect this surface. To unbind call this function will NULL context.
+ // Returns true if successful.
+ bool BindToContext(PluginDelegate::PlatformContext3D* context);
+
+ unsigned int GetBackingTextureId();
+
+ bool SwapBuffers();
+
+ private:
+ // Called when SwapBuffers is complete.
+ void OnSwapBuffers();
+
+ // Plugin instance this surface is associated with.
+ PluginInstance* instance_;
+ bool bound_to_instance_;
+
+ // The context this surface is currently bound to.
+ PluginDelegate::PlatformContext3D* context_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_Surface3D_Impl);
+};
+
+} // namespace ppapi
+} // namespace webkit
+
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_SURFACE_3D_IMPL_H_
diff --git a/webkit/plugins/ppapi/resource.h b/webkit/plugins/ppapi/resource.h
index be79136..28f19e3 100644
--- a/webkit/plugins/ppapi/resource.h
+++ b/webkit/plugins/ppapi/resource.h
@@ -31,6 +31,7 @@ namespace ppapi {
F(PPB_Graphics3D_Impl) \
F(PPB_ImageData_Impl) \
F(PPB_Scrollbar_Impl) \
+ F(PPB_Surface3D_Impl) \
F(PPB_Transport_Impl) \
F(PPB_URLLoader_Impl) \
F(PPB_URLRequestInfo_Impl) \