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/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "gpu/command_buffer/client/gles2_implementation.h" | 10 #include "gpu/command_buffer/client/gles2_implementation.h" |
11 #include "gpu/ipc/command_buffer_proxy.h" | |
11 #include "ppapi/c/ppp_graphics_3d.h" | 12 #include "ppapi/c/ppp_graphics_3d.h" |
13 #include "ppapi/thunk/enter.h" | |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
18 #include "webkit/plugins/ppapi/plugin_module.h" | 20 #include "webkit/plugins/ppapi/plugin_module.h" |
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
20 #include "webkit/plugins/ppapi/resource_helper.h" | 22 #include "webkit/plugins/ppapi/resource_helper.h" |
21 | 23 |
24 using ppapi::thunk::EnterResourceNoLock; | |
22 using ppapi::thunk::PPB_Graphics3D_API; | 25 using ppapi::thunk::PPB_Graphics3D_API; |
23 using WebKit::WebConsoleMessage; | 26 using WebKit::WebConsoleMessage; |
24 using WebKit::WebFrame; | 27 using WebKit::WebFrame; |
25 using WebKit::WebPluginContainer; | 28 using WebKit::WebPluginContainer; |
26 using WebKit::WebString; | 29 using WebKit::WebString; |
27 | 30 |
28 namespace webkit { | 31 namespace webkit { |
29 namespace ppapi { | 32 namespace ppapi { |
30 | 33 |
31 namespace { | 34 namespace { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 | 213 |
211 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); | 214 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); |
212 } | 215 } |
213 | 216 |
214 bool PPB_Graphics3D_Impl::InitRaw(PP_Resource share_context, | 217 bool PPB_Graphics3D_Impl::InitRaw(PP_Resource share_context, |
215 const int32_t* attrib_list) { | 218 const int32_t* attrib_list) { |
216 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); | 219 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); |
217 if (!plugin_instance) | 220 if (!plugin_instance) |
218 return false; | 221 return false; |
219 | 222 |
220 // TODO(alokp): Support shared context. | 223 CommandBufferProxy *share_buffer = 0; |
221 DCHECK_EQ(0, share_context); | 224 if (share_context != 0) { |
222 if (share_context != 0) | 225 EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, false); |
piman
2012/05/15 20:59:17
It'd be nicer to do the EnterResource thing in the
(scshunt)
2012/05/16 16:39:43
Which is the thunk layer?
piman
2012/05/16 17:12:00
ppapi/thunk/ppb_graphics_3d_thunk.cc
| |
223 return false; | 226 DCHECK(enter.succeeded()); |
227 PPB_Graphics3D_Impl* graphics3d_impl = | |
228 static_cast<PPB_Graphics3D_Impl*>(enter.object()); | |
229 share_buffer = | |
230 static_cast<CommandBufferProxy*>(graphics3d_impl->GetCommandBuffer()); | |
231 } | |
224 | 232 |
225 platform_context_.reset(plugin_instance->CreateContext3D()); | 233 platform_context_.reset(plugin_instance->CreateContext3D()); |
226 if (!platform_context_.get()) | 234 if (!platform_context_.get()) |
227 return false; | 235 return false; |
228 | 236 |
229 if (!platform_context_->Init(attrib_list)) | 237 if (!platform_context_->Init(attrib_list, share_buffer)) |
230 return false; | 238 return false; |
231 | 239 |
232 platform_context_->SetContextLostCallback( | 240 platform_context_->SetContextLostCallback( |
233 base::Bind(&PPB_Graphics3D_Impl::OnContextLost, | 241 base::Bind(&PPB_Graphics3D_Impl::OnContextLost, |
234 weak_ptr_factory_.GetWeakPtr())); | 242 weak_ptr_factory_.GetWeakPtr())); |
235 | 243 |
236 platform_context_->SetOnConsoleMessageCallback( | 244 platform_context_->SetOnConsoleMessageCallback( |
237 base::Bind(&PPB_Graphics3D_Impl::OnConsoleMessage, | 245 base::Bind(&PPB_Graphics3D_Impl::OnConsoleMessage, |
238 weak_ptr_factory_.GetWeakPtr())); | 246 weak_ptr_factory_.GetWeakPtr())); |
239 return true; | 247 return true; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 const PPP_Graphics3D* ppp_graphics_3d = | 295 const PPP_Graphics3D* ppp_graphics_3d = |
288 static_cast<const PPP_Graphics3D*>( | 296 static_cast<const PPP_Graphics3D*>( |
289 instance->module()->GetPluginInterface( | 297 instance->module()->GetPluginInterface( |
290 PPP_GRAPHICS_3D_INTERFACE)); | 298 PPP_GRAPHICS_3D_INTERFACE)); |
291 if (ppp_graphics_3d) | 299 if (ppp_graphics_3d) |
292 ppp_graphics_3d->Graphics3DContextLost(pp_instance()); | 300 ppp_graphics_3d->Graphics3DContextLost(pp_instance()); |
293 } | 301 } |
294 | 302 |
295 } // namespace ppapi | 303 } // namespace ppapi |
296 } // namespace webkit | 304 } // namespace webkit |
OLD | NEW |