diff options
-rw-r--r-- | content/renderer/browser_plugin/guest_to_embedder_channel.cc | 1 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_platform_context_3d_impl.cc | 12 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_platform_context_3d_impl.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppb_graphics_3d_proxy.cc | 33 | ||||
-rw-r--r-- | ppapi/proxy/ppb_graphics_3d_proxy.h | 10 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.h | 7 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_graphics_3d_shared.cc | 8 | ||||
-rw-r--r-- | ppapi/shared_impl/ppb_graphics_3d_shared.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_3d_impl.cc | 47 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_3d_impl.h | 4 |
12 files changed, 96 insertions, 38 deletions
diff --git a/content/renderer/browser_plugin/guest_to_embedder_channel.cc b/content/renderer/browser_plugin/guest_to_embedder_channel.cc index ad82a68..1e5cec0 100644 --- a/content/renderer/browser_plugin/guest_to_embedder_channel.cc +++ b/content/renderer/browser_plugin/guest_to_embedder_channel.cc @@ -168,6 +168,7 @@ bool GuestToEmbedderChannel::CreateGraphicsContext( bool success = Send(new PpapiHostMsg_PPBGraphics3D_Create( ppapi::API_ID_PPB_GRAPHICS_3D, render_view->guest_pp_instance(), + ppapi::HostResource(), attribs, &resource)); if (!success || resource.is_null()) diff --git a/content/renderer/pepper/pepper_platform_context_3d_impl.cc b/content/renderer/pepper/pepper_platform_context_3d_impl.cc index 8e2f96a..670e9ab1 100644 --- a/content/renderer/pepper/pepper_platform_context_3d_impl.cc +++ b/content/renderer/pepper/pepper_platform_context_3d_impl.cc @@ -51,7 +51,8 @@ PlatformContext3DImpl::~PlatformContext3DImpl() { channel_ = NULL; } -bool PlatformContext3DImpl::Init(const int32* attrib_list) { +bool PlatformContext3DImpl::Init(const int32* attrib_list, + PlatformContext3D* share_context) { // Ignore initializing more than once. if (command_buffer_) return true; @@ -114,9 +115,16 @@ bool PlatformContext3DImpl::Init(const int32* attrib_list) { attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); } + CommandBufferProxy* share_buffer = NULL; + if (share_context) { + PlatformContext3DImpl* share_impl = + static_cast<PlatformContext3DImpl*>(share_context); + share_buffer = share_impl->command_buffer_; + } + command_buffer_ = channel_->CreateOffscreenCommandBuffer( surface_size, - NULL, + share_buffer, "*", attribs, GURL::EmptyGURL(), diff --git a/content/renderer/pepper/pepper_platform_context_3d_impl.h b/content/renderer/pepper/pepper_platform_context_3d_impl.h index 8d3a0f6..bee7505 100644 --- a/content/renderer/pepper/pepper_platform_context_3d_impl.h +++ b/content/renderer/pepper/pepper_platform_context_3d_impl.h @@ -36,7 +36,8 @@ class PlatformContext3DImpl PepperParentContextProvider* parent_context_provider); virtual ~PlatformContext3DImpl(); - virtual bool Init(const int32* attrib_list) OVERRIDE; + virtual bool Init(const int32* attrib_list, + PlatformContext3D* share_context) OVERRIDE; virtual unsigned GetBackingTextureId() OVERRIDE; virtual bool IsOpaque() OVERRIDE; virtual gpu::CommandBuffer* GetCommandBuffer() OVERRIDE; diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 82b9731..fa0c71c 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -787,8 +787,9 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBGraphics2D_Flush, ppapi::HostResource /* graphics_2d */) // PPB_Graphics3D. -IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBGraphics3D_Create, +IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBGraphics3D_Create, PP_Instance /* instance */, + ppapi::HostResource /* share_context */, std::vector<int32_t> /* attrib_list */, ppapi::HostResource /* result */) IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer, diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc index 2a708a3..25bcd44 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.cc +++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc @@ -69,7 +69,7 @@ Graphics3D::~Graphics3D() { DestroyGLES2Impl(); } -bool Graphics3D::Init() { +bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2) { PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); if (!dispatcher) return false; @@ -79,7 +79,8 @@ bool Graphics3D::Init() { if (!command_buffer_->Initialize()) return false; - return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); + return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, + share_gles2); } PP_Bool Graphics3D::InitCommandBuffer() { @@ -152,10 +153,18 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( if (!dispatcher) return PP_ERROR_BADARGUMENT; - // TODO(alokp): Support shared context. - DCHECK_EQ(0, share_context); - if (share_context != 0) - return 0; + HostResource share_host; + gpu::gles2::GLES2Implementation* share_gles2 = NULL; + if (share_context != 0) { + EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + + PPB_Graphics3D_Shared* share_graphics = + static_cast<PPB_Graphics3D_Shared*>(enter.object()); + share_host = share_graphics->host_resource(); + share_gles2 = share_graphics->gles2_impl(); + } std::vector<int32_t> attribs; if (attrib_list) { @@ -170,12 +179,12 @@ PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( HostResource result; dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( - API_ID_PPB_GRAPHICS_3D, instance, attribs, &result)); + API_ID_PPB_GRAPHICS_3D, instance, share_host, attribs, &result)); if (result.is_null()) return 0; scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); - if (!graphics_3d->Init()) + if (!graphics_3d->Init(share_gles2)) return 0; return graphics_3d->GetReference(); } @@ -214,16 +223,20 @@ bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { } void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, + HostResource share_context, const std::vector<int32_t>& attribs, HostResource* result) { if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) return; // Bad message. thunk::EnterResourceCreation enter(instance); + if (enter.succeeded()) { result->SetHostResource( - instance, - enter.functions()->CreateGraphics3DRaw(instance, 0, &attribs.front())); + instance, + enter.functions()->CreateGraphics3DRaw(instance, + share_context.host_resource(), + &attribs.front())); } } diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h index c6975bf..521d90e 100644 --- a/ppapi/proxy/ppb_graphics_3d_proxy.h +++ b/ppapi/proxy/ppb_graphics_3d_proxy.h @@ -28,7 +28,7 @@ class Graphics3D : public PPB_Graphics3D_Shared { explicit Graphics3D(const HostResource& resource); virtual ~Graphics3D(); - bool Init(); + bool Init(gpu::gles2::GLES2Implementation* share_gles2); // Graphics3DTrusted API. These are not implemented in the proxy. virtual PP_Bool InitCommandBuffer() OVERRIDE; @@ -61,9 +61,10 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy { PPB_Graphics3D_Proxy(Dispatcher* dispatcher); virtual ~PPB_Graphics3D_Proxy(); - static PP_Resource CreateProxyResource(PP_Instance instance, - PP_Resource share_context, - const int32_t* attrib_list); + static PP_Resource CreateProxyResource( + PP_Instance instance, + PP_Resource share_context, + const int32_t* attrib_list); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); @@ -72,6 +73,7 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy { private: void OnMsgCreate(PP_Instance instance, + HostResource share_context, const std::vector<int32_t>& attribs, HostResource* result); void OnMsgInitCommandBuffer(const HostResource& context); diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 138d16f..25243ef 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -120,9 +120,10 @@ class ResourceCreationProxy : public InterfaceProxy, virtual PP_Resource CreateGraphics3D(PP_Instance instance, PP_Resource share_context, const int32_t* attrib_list) OVERRIDE; - virtual PP_Resource CreateGraphics3DRaw(PP_Instance instance, - PP_Resource share_context, - const int32_t* attrib_list) OVERRIDE; + virtual PP_Resource CreateGraphics3DRaw( + PP_Instance instance, + PP_Resource share_context, + const int32_t* attrib_list) OVERRIDE; virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateNetworkMonitor( PP_Instance instance, diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.cc b/ppapi/shared_impl/ppb_graphics_3d_shared.cc index c539704..3a562f4 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.cc +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.cc @@ -97,8 +97,10 @@ bool PPB_Graphics3D_Shared::HasPendingSwap() const { return TrackedCallback::IsPending(swap_callback_); } -bool PPB_Graphics3D_Shared::CreateGLES2Impl(int32 command_buffer_size, - int32 transfer_buffer_size) { +bool PPB_Graphics3D_Shared::CreateGLES2Impl( + int32 command_buffer_size, + int32 transfer_buffer_size, + gpu::gles2::GLES2Implementation* share_gles2) { gpu::CommandBuffer* command_buffer = GetCommandBuffer(); DCHECK(command_buffer); @@ -116,7 +118,7 @@ bool PPB_Graphics3D_Shared::CreateGLES2Impl(int32 command_buffer_size, // Create the object exposing the OpenGL API. gles2_impl_.reset(new gpu::gles2::GLES2Implementation( gles2_helper_.get(), - NULL, + share_gles2 ? share_gles2->share_group() : NULL, transfer_buffer_.get(), false, true)); diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.h b/ppapi/shared_impl/ppb_graphics_3d_shared.h index ee72144..3369f29 100644 --- a/ppapi/shared_impl/ppb_graphics_3d_shared.h +++ b/ppapi/shared_impl/ppb_graphics_3d_shared.h @@ -65,7 +65,8 @@ class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared bool HasPendingSwap() const; bool CreateGLES2Impl(int32 command_buffer_size, - int32 transfer_buffer_size); + int32 transfer_buffer_size, + gpu::gles2::GLES2Implementation* share_gles2); void DestroyGLES2Impl(); private: 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. |