Index: webkit/plugins/ppapi/ppb_graphics_3d_impl.cc |
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc |
index ce43dedeaa226afe23027a4db38955d0f033b615..19748b621fab9b85277e09cb64bc82df6950fc85 100644 |
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc |
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc |
@@ -8,6 +8,7 @@ |
#include "base/message_loop.h" |
#include "base/utf_string_conversions.h" |
#include "gpu/command_buffer/client/gles2_implementation.h" |
+#include "gpu/ipc/command_buffer_proxy.h" |
#include "ppapi/c/ppp_graphics_3d.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
@@ -76,7 +77,7 @@ PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { |
// static |
PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance instance, |
- PP_Resource share_context, |
+ PPB_Graphics3D_API* share_context, |
const int32_t* attrib_list) { |
scoped_refptr<PPB_Graphics3D_Impl> graphics_3d( |
new PPB_Graphics3D_Impl(instance)); |
@@ -86,7 +87,7 @@ PP_Resource PPB_Graphics3D_Impl::Create(PP_Instance instance, |
} |
PP_Resource PPB_Graphics3D_Impl::CreateRaw(PP_Instance instance, |
- PP_Resource share_context, |
+ PPB_Graphics3D_API* share_context, |
const int32_t* attrib_list) { |
scoped_refptr<PPB_Graphics3D_Impl> graphics_3d( |
new PPB_Graphics3D_Impl(instance)); |
@@ -199,7 +200,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 +209,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( |