summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorscshunt@google.com <scshunt@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 21:54:55 +0000
committerscshunt@google.com <scshunt@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 21:54:55 +0000
commit9ed07f8831639f9d6c74b9633262710af532df5b (patch)
tree3df992da5b2e95a9b09ab4661c5a9352e4fac2d9 /webkit
parentbdfa236676485f88c951929a7e5e2622541f9348 (diff)
downloadchromium_src-9ed07f8831639f9d6c74b9633262710af532df5b.zip
chromium_src-9ed07f8831639f9d6c74b9633262710af532df5b.tar.gz
chromium_src-9ed07f8831639f9d6c74b9633262710af532df5b.tar.bz2
Add the necessary plumbing mechanisms to ensure proper WebGL support inside the <browser> tag, which is a separate patch.
Known bugs: Not all aspects of context sharing work properly; in no models would render although the background animated properly. Requires a separate WebKit patch: https://bugs.webkit.org/show_bug.cgi?id=86504 R=fsamuel@chromium.org,piman@chromium.org,brettw@chromium.org BUG=None TEST=compiles Review URL: https://chromiumcodereview.appspot.com/10386145 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139385 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h3
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.cc47
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.h4
3 files changed, 41 insertions, 13 deletions
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index 9229143..c9bf986 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -171,7 +171,8 @@ class PluginDelegate {
virtual ~PlatformContext3D() {}
// Initialize the context.
- virtual bool Init(const int32* attrib_list) = 0;
+ virtual bool Init(const int32* attrib_list,
+ PlatformContext3D* share_context) = 0;
// If the plugin instance is backed by an OpenGL, return its ID in the
// compositors namespace. Otherwise return 0. Returns 0 by default.
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
index ce43ded..9696f60 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
@@ -9,6 +9,7 @@
#include "base/utf_string_conversions.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "ppapi/c/ppp_graphics_3d.h"
+#include "ppapi/thunk/enter.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
@@ -19,6 +20,7 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_helper.h"
+using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_Graphics3D_API;
using WebKit::WebConsoleMessage;
using WebKit::WebFrame;
@@ -78,9 +80,18 @@ PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance instance,
PP_Resource share_context,
const int32_t* attrib_list) {
+ PPB_Graphics3D_API* share_api = NULL;
+ if (share_context) {
+ EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true);
+ if (enter.failed())
+ return 0;
+ share_api = enter.object();
+ }
+
scoped_refptr<PPB_Graphics3D_Impl> graphics_3d(
new PPB_Graphics3D_Impl(instance));
- if (!graphics_3d->Init(share_context, attrib_list))
+
+ if (!graphics_3d->Init(share_api, attrib_list))
return 0;
return graphics_3d->GetReference();
}
@@ -88,9 +99,16 @@ PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance instance,
PP_Resource PPB_Graphics3D_Impl::CreateRaw(PP_Instance instance,
PP_Resource share_context,
const int32_t* attrib_list) {
+ PPB_Graphics3D_API* share_api = NULL;
+ if (share_context) {
+ EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true);
+ if (enter.failed())
+ return 0;
+ share_api = enter.object();
+ }
scoped_refptr<PPB_Graphics3D_Impl> graphics_3d(
new PPB_Graphics3D_Impl(instance));
- if (!graphics_3d->InitRaw(share_context, attrib_list))
+ if (!graphics_3d->InitRaw(share_api, attrib_list))
return 0;
return graphics_3d->GetReference();
}
@@ -199,7 +217,7 @@ int32 PPB_Graphics3D_Impl::DoSwapBuffers() {
return PP_OK_COMPLETIONPENDING;
}
-bool PPB_Graphics3D_Impl::Init(PP_Resource share_context,
+bool PPB_Graphics3D_Impl::Init(PPB_Graphics3D_API* share_context,
const int32_t* attrib_list) {
if (!InitRaw(share_context, attrib_list))
return false;
@@ -208,25 +226,34 @@ bool PPB_Graphics3D_Impl::Init(PP_Resource share_context,
if (!command_buffer->Initialize())
return false;
- return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize);
+ gpu::gles2::GLES2Implementation* share_gles2 = NULL;
+ if (share_context) {
+ share_gles2 =
+ static_cast<PPB_Graphics3D_Shared*>(share_context)->gles2_impl();
+ }
+
+ return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize,
+ share_gles2);
}
-bool PPB_Graphics3D_Impl::InitRaw(PP_Resource share_context,
+bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context,
const int32_t* attrib_list) {
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
return false;
- // TODO(alokp): Support shared context.
- DCHECK_EQ(0, share_context);
- if (share_context != 0)
- return false;
+ PluginDelegate::PlatformContext3D* share_platform_context = NULL;
+ if (share_context) {
+ PPB_Graphics3D_Impl* share_graphics =
+ static_cast<PPB_Graphics3D_Impl*>(share_context);
+ share_platform_context = share_graphics->platform_context();
+ }
platform_context_.reset(plugin_instance->CreateContext3D());
if (!platform_context_.get())
return false;
- if (!platform_context_->Init(attrib_list))
+ if (!platform_context_->Init(attrib_list, share_platform_context))
return false;
platform_context_->SetContextLostCallback(
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
index 62c7055..02ab912 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
@@ -67,9 +67,9 @@ class PPB_Graphics3D_Impl : public ::ppapi::PPB_Graphics3D_Shared {
private:
explicit PPB_Graphics3D_Impl(PP_Instance instance);
- bool Init(PP_Resource share_context,
+ bool Init(PPB_Graphics3D_API* share_context,
const int32_t* attrib_list);
- bool InitRaw(PP_Resource share_context,
+ bool InitRaw(PPB_Graphics3D_API* share_context,
const int32_t* attrib_list);
// Notifications received from the GPU process.