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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 447 |
446 HostResource result; | 448 HostResource result; |
447 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( | 449 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( |
448 INTERFACE_ID_PPB_GRAPHICS_3D, instance, config, attribs, &result)); | 450 INTERFACE_ID_PPB_GRAPHICS_3D, instance, config, attribs, &result)); |
449 if (result.is_null()) | 451 if (result.is_null()) |
450 return 0; | 452 return 0; |
451 | 453 |
452 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); | 454 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); |
453 if (!graphics_3d->Init()) | 455 if (!graphics_3d->Init()) |
454 return 0; | 456 return 0; |
455 | 457 return graphics_3d->GetReference(); |
456 return PluginResourceTracker::GetInstance()->AddResource(graphics_3d); | |
457 } | 458 } |
458 | 459 |
459 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { | 460 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
460 bool handled = true; | 461 bool handled = true; |
461 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) | 462 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) |
462 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, | 463 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, |
463 OnMsgCreate) | 464 OnMsgCreate) |
464 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer, | 465 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer, |
465 OnMsgInitCommandBuffer) | 466 OnMsgInitCommandBuffer) |
466 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetState, | 467 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetState, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 606 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
606 int32_t result, | 607 int32_t result, |
607 const HostResource& context) { | 608 const HostResource& context) { |
608 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 609 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
609 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); | 610 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); |
610 } | 611 } |
611 | 612 |
612 } // namespace proxy | 613 } // namespace proxy |
613 } // namespace pp | 614 } // namespace pp |
614 | 615 |
OLD | NEW |