| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "gpu/command_buffer/client/gles2_implementation.h" | 8 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 9 #include "webkit/plugins/ppapi/plugin_module.h" | 9 #include "webkit/plugins/ppapi/plugin_module.h" |
| 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 10 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 commit_pending_(false), | 55 commit_pending_(false), |
| 56 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 56 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 57 } | 57 } |
| 58 | 58 |
| 59 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { | 59 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { |
| 60 DestroyGLES2Impl(); | 60 DestroyGLES2Impl(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // static | 63 // static |
| 64 PP_Resource PPB_Graphics3D_Impl::Create(PluginInstance* instance, | 64 PP_Resource PPB_Graphics3D_Impl::Create(PluginInstance* instance, |
| 65 PP_Config3D_Dev config, | |
| 66 PP_Resource share_context, | 65 PP_Resource share_context, |
| 67 const int32_t* attrib_list) { | 66 const int32_t* attrib_list) { |
| 68 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d( | 67 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d( |
| 69 new PPB_Graphics3D_Impl(instance)); | 68 new PPB_Graphics3D_Impl(instance)); |
| 70 | 69 |
| 71 if (!graphics_3d->Init(config, share_context, attrib_list)) | 70 if (!graphics_3d->Init(share_context, attrib_list)) |
| 72 return 0; | 71 return 0; |
| 73 | 72 |
| 74 return graphics_3d->GetReference(); | 73 return graphics_3d->GetReference(); |
| 75 } | 74 } |
| 76 | 75 |
| 77 PP_Resource PPB_Graphics3D_Impl::CreateRaw(PluginInstance* instance, | 76 PP_Resource PPB_Graphics3D_Impl::CreateRaw(PluginInstance* instance, |
| 78 PP_Config3D_Dev config, | |
| 79 PP_Resource share_context, | 77 PP_Resource share_context, |
| 80 const int32_t* attrib_list) { | 78 const int32_t* attrib_list) { |
| 81 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d( | 79 scoped_refptr<PPB_Graphics3D_Impl> graphics_3d( |
| 82 new PPB_Graphics3D_Impl(instance)); | 80 new PPB_Graphics3D_Impl(instance)); |
| 83 | 81 |
| 84 if (!graphics_3d->InitRaw(config, share_context, attrib_list)) | 82 if (!graphics_3d->InitRaw(share_context, attrib_list)) |
| 85 return 0; | 83 return 0; |
| 86 | 84 |
| 87 return graphics_3d->GetReference(); | 85 return graphics_3d->GetReference(); |
| 88 } | 86 } |
| 89 | 87 |
| 90 PPB_Graphics3D_API* PPB_Graphics3D_Impl::AsPPB_Graphics3D_API() { | 88 PPB_Graphics3D_API* PPB_Graphics3D_Impl::AsPPB_Graphics3D_API() { |
| 91 return this; | 89 return this; |
| 92 } | 90 } |
| 93 | 91 |
| 94 PP_Bool PPB_Graphics3D_Impl::InitCommandBuffer(int32_t size) { | 92 PP_Bool PPB_Graphics3D_Impl::InitCommandBuffer(int32_t size) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 int32 PPB_Graphics3D_Impl::DoSwapBuffers() { | 163 int32 PPB_Graphics3D_Impl::DoSwapBuffers() { |
| 166 // We do not have a GLES2 implementation when using an OOP proxy. | 164 // We do not have a GLES2 implementation when using an OOP proxy. |
| 167 // The plugin-side proxy is responsible for adding the SwapBuffers command | 165 // The plugin-side proxy is responsible for adding the SwapBuffers command |
| 168 // to the command buffer in that case. | 166 // to the command buffer in that case. |
| 169 if (gles2_impl()) | 167 if (gles2_impl()) |
| 170 gles2_impl()->SwapBuffers(); | 168 gles2_impl()->SwapBuffers(); |
| 171 | 169 |
| 172 return PP_OK_COMPLETIONPENDING; | 170 return PP_OK_COMPLETIONPENDING; |
| 173 } | 171 } |
| 174 | 172 |
| 175 bool PPB_Graphics3D_Impl::Init(PP_Config3D_Dev config, | 173 bool PPB_Graphics3D_Impl::Init(PP_Resource share_context, |
| 176 PP_Resource share_context, | |
| 177 const int32_t* attrib_list) { | 174 const int32_t* attrib_list) { |
| 178 if (!InitRaw(config, share_context, attrib_list)) | 175 if (!InitRaw(share_context, attrib_list)) |
| 179 return false; | 176 return false; |
| 180 | 177 |
| 181 gpu::CommandBuffer* command_buffer = GetCommandBuffer(); | 178 gpu::CommandBuffer* command_buffer = GetCommandBuffer(); |
| 182 if (!command_buffer->Initialize(kCommandBufferSize)) | 179 if (!command_buffer->Initialize(kCommandBufferSize)) |
| 183 return false; | 180 return false; |
| 184 | 181 |
| 185 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); | 182 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); |
| 186 } | 183 } |
| 187 | 184 |
| 188 bool PPB_Graphics3D_Impl::InitRaw(PP_Config3D_Dev config, | 185 bool PPB_Graphics3D_Impl::InitRaw(PP_Resource share_context, |
| 189 PP_Resource share_context, | |
| 190 const int32_t* attrib_list) { | 186 const int32_t* attrib_list) { |
| 191 // TODO(alokp): Support shared context. | 187 // TODO(alokp): Support shared context. |
| 192 DCHECK_EQ(0, share_context); | 188 DCHECK_EQ(0, share_context); |
| 193 if (share_context != 0) | 189 if (share_context != 0) |
| 194 return 0; | 190 return 0; |
| 195 | 191 |
| 196 platform_context_.reset(instance()->CreateContext3D()); | 192 platform_context_.reset(instance()->CreateContext3D()); |
| 197 if (!platform_context_.get()) | 193 if (!platform_context_.get()) |
| 198 return false; | 194 return false; |
| 199 | 195 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 const PPP_Graphics3D_Dev* ppp_graphics_3d = | 239 const PPP_Graphics3D_Dev* ppp_graphics_3d = |
| 244 static_cast<const PPP_Graphics3D_Dev*>( | 240 static_cast<const PPP_Graphics3D_Dev*>( |
| 245 instance()->module()->GetPluginInterface( | 241 instance()->module()->GetPluginInterface( |
| 246 PPP_GRAPHICS_3D_DEV_INTERFACE)); | 242 PPP_GRAPHICS_3D_DEV_INTERFACE)); |
| 247 if (ppp_graphics_3d) | 243 if (ppp_graphics_3d) |
| 248 ppp_graphics_3d->Graphics3DContextLost(instance()->pp_instance()); | 244 ppp_graphics_3d->Graphics3DContextLost(instance()->pp_instance()); |
| 249 } | 245 } |
| 250 | 246 |
| 251 } // namespace ppapi | 247 } // namespace ppapi |
| 252 } // namespace webkit | 248 } // namespace webkit |
| OLD | NEW |