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 "ppapi/proxy/ppb_graphics_3d_proxy.h" | 5 #include "ppapi/proxy/ppb_graphics_3d_proxy.h" |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/proxy/enter_proxy.h" | 9 #include "ppapi/proxy/enter_proxy.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
12 #include "ppapi/thunk/enter.h" | 12 #include "ppapi/thunk/enter.h" |
13 #include "ppapi/thunk/resource_creation_api.h" | 13 #include "ppapi/thunk/resource_creation_api.h" |
14 #include "ppapi/thunk/thunk.h" | 14 #include "ppapi/thunk/thunk.h" |
15 | 15 |
16 using ppapi::HostResource; | 16 using ppapi::HostResource; |
| 17 using ppapi::Resource; |
17 using ppapi::thunk::EnterFunctionNoLock; | 18 using ppapi::thunk::EnterFunctionNoLock; |
18 using ppapi::thunk::EnterResourceNoLock; | 19 using ppapi::thunk::EnterResourceNoLock; |
19 using ppapi::thunk::PPB_Graphics3D_API; | 20 using ppapi::thunk::PPB_Graphics3D_API; |
20 using ppapi::thunk::ResourceCreationAPI; | 21 using ppapi::thunk::ResourceCreationAPI; |
21 | 22 |
22 namespace pp { | 23 namespace pp { |
23 namespace proxy { | 24 namespace proxy { |
24 | 25 |
25 namespace { | 26 namespace { |
26 const int32 kCommandBufferSize = 1024 * 1024; | 27 const int32 kCommandBufferSize = 1024 * 1024; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 return state; | 318 return state; |
318 } | 319 } |
319 | 320 |
320 InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher, | 321 InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher, |
321 const void* target_interface) { | 322 const void* target_interface) { |
322 return new PPB_Graphics3D_Proxy(dispatcher, target_interface); | 323 return new PPB_Graphics3D_Proxy(dispatcher, target_interface); |
323 } | 324 } |
324 } // namespace | 325 } // namespace |
325 | 326 |
326 Graphics3D::Graphics3D(const HostResource& resource) | 327 Graphics3D::Graphics3D(const HostResource& resource) |
327 : PluginResource(resource) { | 328 : Resource(resource) { |
328 } | 329 } |
329 | 330 |
330 Graphics3D::~Graphics3D() { | 331 Graphics3D::~Graphics3D() { |
331 DestroyGLES2Impl(); | 332 DestroyGLES2Impl(); |
332 } | 333 } |
333 | 334 |
334 bool Graphics3D::Init() { | 335 bool Graphics3D::Init() { |
335 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance()); | 336 PluginDispatcher* dispatcher = |
| 337 PluginDispatcher::GetForInstance(pp_instance()); |
336 if (!dispatcher) | 338 if (!dispatcher) |
337 return false; | 339 return false; |
338 | 340 |
339 command_buffer_.reset(new CommandBuffer(host_resource(), dispatcher)); | 341 command_buffer_.reset(new CommandBuffer(host_resource(), dispatcher)); |
340 if (!command_buffer_->Initialize(kCommandBufferSize)) | 342 if (!command_buffer_->Initialize(kCommandBufferSize)) |
341 return false; | 343 return false; |
342 | 344 |
343 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); | 345 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize); |
344 } | 346 } |
345 | 347 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } | 385 } |
384 | 386 |
385 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { | 387 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { |
386 return command_buffer_.get(); | 388 return command_buffer_.get(); |
387 } | 389 } |
388 | 390 |
389 int32 Graphics3D::DoSwapBuffers() { | 391 int32 Graphics3D::DoSwapBuffers() { |
390 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( | 392 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( |
391 INTERFACE_ID_PPB_GRAPHICS_3D, host_resource()); | 393 INTERFACE_ID_PPB_GRAPHICS_3D, host_resource()); |
392 msg->set_unblock(true); | 394 msg->set_unblock(true); |
393 GetDispatcher()->Send(msg); | 395 PluginDispatcher::GetForResource(this)->Send(msg); |
394 | 396 |
395 gles2_impl()->SwapBuffers(); | 397 gles2_impl()->SwapBuffers(); |
396 return PP_OK_COMPLETIONPENDING; | 398 return PP_OK_COMPLETIONPENDING; |
397 } | 399 } |
398 | 400 |
399 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher, | 401 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher, |
400 const void* target_interface) | 402 const void* target_interface) |
401 : InterfaceProxy(dispatcher, target_interface), | 403 : InterfaceProxy(dispatcher, target_interface), |
402 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 404 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
403 } | 405 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 | 446 |
445 HostResource result; | 447 HostResource result; |
446 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( | 448 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( |
447 INTERFACE_ID_PPB_GRAPHICS_3D, instance, attribs, &result)); | 449 INTERFACE_ID_PPB_GRAPHICS_3D, instance, attribs, &result)); |
448 if (result.is_null()) | 450 if (result.is_null()) |
449 return 0; | 451 return 0; |
450 | 452 |
451 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); | 453 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); |
452 if (!graphics_3d->Init()) | 454 if (!graphics_3d->Init()) |
453 return 0; | 455 return 0; |
454 | 456 return graphics_3d->GetReference(); |
455 return PluginResourceTracker::GetInstance()->AddResource(graphics_3d); | |
456 } | 457 } |
457 | 458 |
458 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { | 459 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
459 bool handled = true; | 460 bool handled = true; |
460 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) | 461 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) |
461 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, | 462 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, |
462 OnMsgCreate) | 463 OnMsgCreate) |
463 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer, | 464 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer, |
464 OnMsgInitCommandBuffer) | 465 OnMsgInitCommandBuffer) |
465 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetState, | 466 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetState, |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 603 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
603 int32_t result, | 604 int32_t result, |
604 const HostResource& context) { | 605 const HostResource& context) { |
605 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 606 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
606 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); | 607 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); |
607 } | 608 } |
608 | 609 |
609 } // namespace proxy | 610 } // namespace proxy |
610 } // namespace pp | 611 } // namespace pp |
611 | 612 |
OLD | NEW |