summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-01 17:48:07 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-01 17:48:07 +0000
commit23bd2afd6cc61d9efe90addd84332280eaa13a7f (patch)
tree9790454a87b2ff16034eff20783d7f67e0aa47b0
parentfa76b46928cdc24202f8e91adc957abf24059627 (diff)
downloadchromium_src-23bd2afd6cc61d9efe90addd84332280eaa13a7f.zip
chromium_src-23bd2afd6cc61d9efe90addd84332280eaa13a7f.tar.gz
chromium_src-23bd2afd6cc61d9efe90addd84332280eaa13a7f.tar.bz2
Added PPB_Graphics3D_Dev::Resize to let plugins resize the backing surface.
BUG=62383 Review URL: http://codereview.chromium.org/7530010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94930 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/renderer/gpu/renderer_gl_context.h2
-rw-r--r--content/renderer/pepper_platform_context_3d_impl.cc39
-rw-r--r--content/renderer/pepper_platform_context_3d_impl.h2
-rw-r--r--ppapi/c/dev/ppb_graphics_3d_dev.h16
-rw-r--r--ppapi/cpp/dev/graphics_3d_dev.cc8
-rw-r--r--ppapi/cpp/dev/graphics_3d_dev.h2
-rw-r--r--ppapi/shared_impl/graphics_3d_impl.cc9
-rw-r--r--ppapi/shared_impl/graphics_3d_impl.h1
-rw-r--r--ppapi/thunk/ppb_graphics_3d_api.h1
-rw-r--r--ppapi/thunk/ppb_graphics_3d_thunk.cc8
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h2
-rw-r--r--webkit/plugins/ppapi/ppb_context_3d_impl.cc14
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.cc8
13 files changed, 88 insertions, 24 deletions
diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h
index 911e0c6..9fa3315 100644
--- a/content/renderer/gpu/renderer_gl_context.h
+++ b/content/renderer/gpu/renderer_gl_context.h
@@ -53,6 +53,8 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> {
STENCIL_SIZE = 0x3026,
SAMPLES = 0x3031,
SAMPLE_BUFFERS = 0x3032,
+ HEIGHT = 0x3056,
+ WIDTH = 0x3057,
NONE = 0x3038 // Attrib list = terminator
};
diff --git a/content/renderer/pepper_platform_context_3d_impl.cc b/content/renderer/pepper_platform_context_3d_impl.cc
index 5daa1b5..60c9603 100644
--- a/content/renderer/pepper_platform_context_3d_impl.cc
+++ b/content/renderer/pepper_platform_context_3d_impl.cc
@@ -40,7 +40,7 @@ PlatformContext3DImpl::~PlatformContext3DImpl() {
channel_ = NULL;
}
-bool PlatformContext3DImpl::Init() {
+bool PlatformContext3DImpl::Init(const int32* attrib_list) {
// Ignore initializing more than once.
if (command_buffer_)
return true;
@@ -66,20 +66,35 @@ bool PlatformContext3DImpl::Init() {
parent_gles2->helper()->CommandBufferHelper::Finish();
parent_texture_id_ = parent_gles2->MakeTextureId();
- // TODO(apatrick): Let Pepper plugins configure their back buffer surface.
- static const int32 kAttribs[] = {
- RendererGLContext::ALPHA_SIZE, 8,
- RendererGLContext::DEPTH_SIZE, 24,
- RendererGLContext::STENCIL_SIZE, 8,
- RendererGLContext::SAMPLES, 0,
- RendererGLContext::SAMPLE_BUFFERS, 0,
- RendererGLContext::NONE,
- };
- std::vector<int32> attribs(kAttribs, kAttribs + ARRAYSIZE_UNSAFE(kAttribs));
+ gfx::Size surface_size;
+ std::vector<int32> attribs;
+ // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer()
+ // interface to accept width and height in the attrib_list so that
+ // we do not need to filter for width and height here.
+ if (attrib_list) {
+ for (const int32_t* attr = attrib_list;
+ attr[0] != RendererGLContext::NONE;
+ attr += 2) {
+ switch (attr[0]) {
+ case RendererGLContext::WIDTH:
+ surface_size.set_width(attr[1]);
+ break;
+ case RendererGLContext::HEIGHT:
+ surface_size.set_height(attr[1]);
+ break;
+ default:
+ attribs.push_back(attr[0]);
+ attribs.push_back(attr[1]);
+ break;
+ }
+ }
+ attribs.push_back(RendererGLContext::NONE);
+ }
+
CommandBufferProxy* parent_command_buffer =
parent_context_->GetCommandBufferProxy();
command_buffer_ = channel_->CreateOffscreenCommandBuffer(
- gfx::Size(1, 1),
+ surface_size,
"*",
attribs,
GURL::EmptyGURL());
diff --git a/content/renderer/pepper_platform_context_3d_impl.h b/content/renderer/pepper_platform_context_3d_impl.h
index c1a34aa..a81e48b 100644
--- a/content/renderer/pepper_platform_context_3d_impl.h
+++ b/content/renderer/pepper_platform_context_3d_impl.h
@@ -28,7 +28,7 @@ class PlatformContext3DImpl
explicit PlatformContext3DImpl(RendererGLContext* parent_context);
virtual ~PlatformContext3DImpl();
- virtual bool Init();
+ virtual bool Init(const int32* attrib_list);
virtual void SetSwapBuffersCallback(Callback0::Type* callback);
virtual unsigned GetBackingTextureId();
virtual gpu::CommandBuffer* GetCommandBuffer();
diff --git a/ppapi/c/dev/ppb_graphics_3d_dev.h b/ppapi/c/dev/ppb_graphics_3d_dev.h
index 6e53328..dfcf566 100644
--- a/ppapi/c/dev/ppb_graphics_3d_dev.h
+++ b/ppapi/c/dev/ppb_graphics_3d_dev.h
@@ -31,8 +31,8 @@
// // Shutdown.
// core->ReleaseResource(context);
-#define PPB_GRAPHICS_3D_DEV_INTERFACE_0_5 "PPB_Graphics3D(Dev);0.5"
-#define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_5
+#define PPB_GRAPHICS_3D_DEV_INTERFACE_0_6 "PPB_Graphics3D(Dev);0.6"
+#define PPB_GRAPHICS_3D_DEV_INTERFACE PPB_GRAPHICS_3D_DEV_INTERFACE_0_6
struct PPB_Graphics3D_Dev {
// TODO(alokp): Do these functions need module argument?
@@ -196,6 +196,18 @@ struct PPB_Graphics3D_Dev {
int32_t (*SetAttribs)(PP_Resource context,
int32_t* attrib_list);
+ // Resizes the backing surface for context.
+ //
+ // On failure the following error codes may be returned:
+ // - PP_ERROR_BADRESOURCE if context is invalid.
+ // - PP_ERROR_BADARGUMENT if the value specified for width or height
+ // is less than zero.
+ //
+ // If the surface could not be resized due to insufficient resources,
+ // PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback.
+ int32_t (*ResizeBuffers)(PP_Resource context,
+ int32_t width, int32_t height);
+
// Makes the contents of the color buffer available for compositing.
// This function has no effect on off-screen surfaces - ones not bound
// to any plugin instance. The contents of ancillary buffers are always
diff --git a/ppapi/cpp/dev/graphics_3d_dev.cc b/ppapi/cpp/dev/graphics_3d_dev.cc
index 021669f..3e6736f 100644
--- a/ppapi/cpp/dev/graphics_3d_dev.cc
+++ b/ppapi/cpp/dev/graphics_3d_dev.cc
@@ -87,6 +87,14 @@ int32_t Graphics3D_Dev::SetAttribs(int32_t* attrib_list) {
attrib_list);
}
+int32_t Graphics3D_Dev::ResizeBuffers(int32_t width, int32_t height) {
+ if (!has_interface<PPB_Graphics3D_Dev>())
+ return PP_ERROR_NOINTERFACE;
+
+ return get_interface<PPB_Graphics3D_Dev>()->ResizeBuffers(
+ pp_resource(), width, height);
+}
+
int32_t Graphics3D_Dev::SwapBuffers(const CompletionCallback& cc) {
if (!has_interface<PPB_Graphics3D_Dev>())
return PP_ERROR_NOINTERFACE;
diff --git a/ppapi/cpp/dev/graphics_3d_dev.h b/ppapi/cpp/dev/graphics_3d_dev.h
index 0b967ad..6961c78 100644
--- a/ppapi/cpp/dev/graphics_3d_dev.h
+++ b/ppapi/cpp/dev/graphics_3d_dev.h
@@ -38,6 +38,8 @@ class Graphics3D_Dev : public Resource {
int32_t GetAttribs(int32_t* attrib_list) const;
int32_t SetAttribs(int32_t* attrib_list);
+ int32_t ResizeBuffers(int32_t width, int32_t height);
+
int32_t SwapBuffers(const CompletionCallback& cc);
};
diff --git a/ppapi/shared_impl/graphics_3d_impl.cc b/ppapi/shared_impl/graphics_3d_impl.cc
index a01b763..0299f5f 100644
--- a/ppapi/shared_impl/graphics_3d_impl.cc
+++ b/ppapi/shared_impl/graphics_3d_impl.cc
@@ -33,6 +33,15 @@ int32_t Graphics3DImpl::SetAttribs(int32_t* attrib_list) {
return PP_ERROR_FAILED;
}
+int32_t Graphics3DImpl::ResizeBuffers(int32_t width, int32_t height) {
+ if ((width < 0) || (height < 0))
+ return PP_ERROR_BADARGUMENT;
+
+ gles2_impl()->ResizeCHROMIUM(width, height);
+ // TODO(alokp): Check if resize succeeded and return appropriate error code.
+ return PP_OK;
+}
+
int32_t Graphics3DImpl::SwapBuffers(PP_CompletionCallback callback) {
if (!callback.func) {
// Blocking SwapBuffers isn't supported (since we have to be on the main
diff --git a/ppapi/shared_impl/graphics_3d_impl.h b/ppapi/shared_impl/graphics_3d_impl.h
index 41a71af..781f33f 100644
--- a/ppapi/shared_impl/graphics_3d_impl.h
+++ b/ppapi/shared_impl/graphics_3d_impl.h
@@ -25,6 +25,7 @@ class Graphics3DImpl : public thunk::PPB_Graphics3D_API {
// PPB_Graphics3D_API implementation.
virtual int32_t GetAttribs(int32_t* attrib_list) OVERRIDE;
virtual int32_t SetAttribs(int32_t* attrib_list) OVERRIDE;
+ virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE;
virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE;
gpu::gles2::GLES2Implementation* gles2_impl() {
diff --git a/ppapi/thunk/ppb_graphics_3d_api.h b/ppapi/thunk/ppb_graphics_3d_api.h
index 8871d6b..f513b17 100644
--- a/ppapi/thunk/ppb_graphics_3d_api.h
+++ b/ppapi/thunk/ppb_graphics_3d_api.h
@@ -18,6 +18,7 @@ class PPB_Graphics3D_API {
// Graphics3D API.
virtual int32_t GetAttribs(int32_t* attrib_list) = 0;
virtual int32_t SetAttribs(int32_t* attrib_list) = 0;
+ virtual int32_t ResizeBuffers(int32_t width, int32_t height) = 0;
virtual int32_t SwapBuffers(PP_CompletionCallback callback) = 0;
// Graphics3DTrusted API.
diff --git a/ppapi/thunk/ppb_graphics_3d_thunk.cc b/ppapi/thunk/ppb_graphics_3d_thunk.cc
index c3363f20..1ea23cd 100644
--- a/ppapi/thunk/ppb_graphics_3d_thunk.cc
+++ b/ppapi/thunk/ppb_graphics_3d_thunk.cc
@@ -64,6 +64,13 @@ int32_t SetAttribs(PP_Resource graphics_3d, int32_t* attrib_list) {
return enter.object()->SetAttribs(attrib_list);
}
+int32_t ResizeBuffers(PP_Resource graphics_3d, int32_t width, int32_t height) {
+ EnterGraphics3D enter(graphics_3d, true);
+ if (enter.failed())
+ return PP_ERROR_BADRESOURCE;
+ return enter.object()->ResizeBuffers(width, height);
+}
+
int32_t SwapBuffers(PP_Resource graphics_3d, PP_CompletionCallback callback) {
EnterGraphics3D enter(graphics_3d, true);
if (enter.failed())
@@ -80,6 +87,7 @@ const PPB_Graphics3D_Dev g_ppb_graphics_3d_thunk = {
&IsGraphics3D,
&GetAttribs,
&SetAttribs,
+ &ResizeBuffers,
&SwapBuffers
};
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index 58b1066..a776ea2 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -159,7 +159,7 @@ class PluginDelegate {
virtual ~PlatformContext3D() {}
// Initialize the context.
- virtual bool Init() = 0;
+ virtual bool Init(const int32* attrib_list) = 0;
// Set an optional callback that will be invoked when the side effects of
// a SwapBuffers call become visible to the compositor. Takes ownership
diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.cc b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
index 6014bde..acf60cf 100644
--- a/webkit/plugins/ppapi/ppb_context_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
@@ -293,10 +293,22 @@ bool PPB_Context3D_Impl::InitRaw(PP_Config3D_Dev config,
Destroy();
return false;
}
- if (!platform_context_->Init()) {
+
+ static const int32 kAttribs[] = {
+ PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
+ PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
+ PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8,
+ PP_GRAPHICS3DATTRIB_SAMPLES, 0,
+ PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0,
+ PP_GRAPHICS3DATTRIB_HEIGHT, 1,
+ PP_GRAPHICS3DATTRIB_WIDTH, 1,
+ PP_GRAPHICS3DATTRIBVALUE_NONE,
+ };
+ if (!platform_context_->Init(kAttribs)) {
Destroy();
return false;
}
+
platform_context_->SetContextLostCallback(
callback_factory_.NewCallback(&PPB_Context3D_Impl::OnContextLost));
return true;
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
index e38d66c..671a85f 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
@@ -141,12 +141,6 @@ PP_Graphics3DTrustedState PPB_Graphics3D_Impl::FlushSyncFast(
bool PPB_Graphics3D_Impl::BindToInstance(bool bind) {
bound_to_instance_ = bind;
- if (bind && gles2_impl()) {
- // Resize the backing texture to the size of the instance when it is bound.
- // TODO(alokp): This should be the responsibility of plugins.
- const gfx::Size& size = instance()->position().size();
- gles2_impl()->ResizeCHROMIUM(size.width(), size.height());
- }
return true;
}
@@ -203,7 +197,7 @@ bool PPB_Graphics3D_Impl::InitRaw(PP_Config3D_Dev config,
if (!platform_context_.get())
return false;
- if (!platform_context_->Init())
+ if (!platform_context_->Init(attrib_list))
return false;
platform_context_->SetContextLostCallback(