| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "gpu/command_buffer/client/gles2_implementation.h" | 11 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 12 #include "ppapi/c/ppp_graphics_3d.h" | 12 #include "ppapi/c/ppp_graphics_3d.h" |
| 13 #include "ppapi/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
| 14 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
| 15 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 15 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 16 #include "third_party/WebKit/public/web/WebDocument.h" | 16 #include "third_party/WebKit/public/web/WebDocument.h" |
| 17 #include "third_party/WebKit/public/web/WebElement.h" | 17 #include "third_party/WebKit/public/web/WebElement.h" |
| 18 #include "third_party/WebKit/public/web/WebFrame.h" | 18 #include "third_party/WebKit/public/web/WebFrame.h" |
| 19 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 19 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 20 #include "webkit/plugins/plugin_switches.h" | 20 #include "webkit/plugins/plugin_switches.h" |
| 21 #include "webkit/plugins/ppapi/plugin_module.h" | 21 #include "webkit/plugins/ppapi/plugin_module.h" |
| 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance_impl.h" |
| 23 #include "webkit/plugins/ppapi/resource_helper.h" | 23 #include "webkit/plugins/ppapi/resource_helper.h" |
| 24 | 24 |
| 25 using ppapi::thunk::EnterResourceNoLock; | 25 using ppapi::thunk::EnterResourceNoLock; |
| 26 using ppapi::thunk::PPB_Graphics3D_API; | 26 using ppapi::thunk::PPB_Graphics3D_API; |
| 27 using WebKit::WebConsoleMessage; | 27 using WebKit::WebConsoleMessage; |
| 28 using WebKit::WebFrame; | 28 using WebKit::WebFrame; |
| 29 using WebKit::WebPluginContainer; | 29 using WebKit::WebPluginContainer; |
| 30 using WebKit::WebString; | 30 using WebKit::WebString; |
| 31 | 31 |
| 32 namespace webkit { | 32 namespace webkit { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 share_gles2 = | 229 share_gles2 = |
| 230 static_cast<PPB_Graphics3D_Shared*>(share_context)->gles2_impl(); | 230 static_cast<PPB_Graphics3D_Shared*>(share_context)->gles2_impl(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, | 233 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, |
| 234 share_gles2); | 234 share_gles2); |
| 235 } | 235 } |
| 236 | 236 |
| 237 bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context, | 237 bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context, |
| 238 const int32_t* attrib_list) { | 238 const int32_t* attrib_list) { |
| 239 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 239 PluginInstanceImpl* plugin_instance = ResourceHelper::GetPluginInstance(this); |
| 240 if (!plugin_instance) | 240 if (!plugin_instance) |
| 241 return false; | 241 return false; |
| 242 | 242 |
| 243 PluginDelegate::PlatformContext3D* share_platform_context = NULL; | 243 PluginDelegate::PlatformContext3D* share_platform_context = NULL; |
| 244 if (share_context) { | 244 if (share_context) { |
| 245 PPB_Graphics3D_Impl* share_graphics = | 245 PPB_Graphics3D_Impl* share_graphics = |
| 246 static_cast<PPB_Graphics3D_Impl*>(share_context); | 246 static_cast<PPB_Graphics3D_Impl*>(share_context); |
| 247 share_platform_context = share_graphics->platform_context(); | 247 share_platform_context = share_graphics->platform_context(); |
| 248 } | 248 } |
| 249 | 249 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 base::MessageLoop::current()->PostTask( | 300 base::MessageLoop::current()->PostTask( |
| 301 FROM_HERE, | 301 FROM_HERE, |
| 302 base::Bind(&PPB_Graphics3D_Impl::SendContextLost, | 302 base::Bind(&PPB_Graphics3D_Impl::SendContextLost, |
| 303 weak_ptr_factory_.GetWeakPtr())); | 303 weak_ptr_factory_.GetWeakPtr())); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void PPB_Graphics3D_Impl::SendContextLost() { | 306 void PPB_Graphics3D_Impl::SendContextLost() { |
| 307 // By the time we run this, the instance may have been deleted, or in the | 307 // By the time we run this, the instance may have been deleted, or in the |
| 308 // process of being deleted. Even in the latter case, we don't want to send a | 308 // process of being deleted. Even in the latter case, we don't want to send a |
| 309 // callback after DidDestroy. | 309 // callback after DidDestroy. |
| 310 PluginInstance* instance = ResourceHelper::GetPluginInstance(this); | 310 PluginInstanceImpl* instance = ResourceHelper::GetPluginInstance(this); |
| 311 if (!instance || !instance->container()) | 311 if (!instance || !instance->container()) |
| 312 return; | 312 return; |
| 313 | 313 |
| 314 // This PPB_Graphics3D_Impl could be deleted during the call to | 314 // This PPB_Graphics3D_Impl could be deleted during the call to |
| 315 // GetPluginInterface (which sends a sync message in some cases). We still | 315 // GetPluginInterface (which sends a sync message in some cases). We still |
| 316 // send the Graphics3DContextLost to the plugin; the instance may care about | 316 // send the Graphics3DContextLost to the plugin; the instance may care about |
| 317 // that event even though this context has been destroyed. | 317 // that event even though this context has been destroyed. |
| 318 PP_Instance this_pp_instance = pp_instance(); | 318 PP_Instance this_pp_instance = pp_instance(); |
| 319 const PPP_Graphics3D* ppp_graphics_3d = | 319 const PPP_Graphics3D* ppp_graphics_3d = |
| 320 static_cast<const PPP_Graphics3D*>( | 320 static_cast<const PPP_Graphics3D*>( |
| 321 instance->module()->GetPluginInterface( | 321 instance->module()->GetPluginInterface( |
| 322 PPP_GRAPHICS_3D_INTERFACE)); | 322 PPP_GRAPHICS_3D_INTERFACE)); |
| 323 if (ppp_graphics_3d) | 323 if (ppp_graphics_3d) |
| 324 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); | 324 ppp_graphics_3d->Graphics3DContextLost(this_pp_instance); |
| 325 } | 325 } |
| 326 | 326 |
| 327 } // namespace ppapi | 327 } // namespace ppapi |
| 328 } // namespace webkit | 328 } // namespace webkit |
| OLD | NEW |