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" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 INTERFACE_ID_PPB_GRAPHICS_3D, | 412 INTERFACE_ID_PPB_GRAPHICS_3D, |
413 false, | 413 false, |
414 &CreateGraphics3DProxy, | 414 &CreateGraphics3DProxy, |
415 }; | 415 }; |
416 return &info; | 416 return &info; |
417 } | 417 } |
418 | 418 |
419 // static | 419 // static |
420 PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( | 420 PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( |
421 PP_Instance instance, | 421 PP_Instance instance, |
422 PP_Config3D_Dev config, | |
423 PP_Resource share_context, | 422 PP_Resource share_context, |
424 const int32_t* attrib_list) { | 423 const int32_t* attrib_list) { |
425 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 424 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
426 if (!dispatcher) | 425 if (!dispatcher) |
427 return PP_ERROR_BADARGUMENT; | 426 return PP_ERROR_BADARGUMENT; |
428 | 427 |
429 // TODO(alokp): Support shared context. | 428 // TODO(alokp): Support shared context. |
430 DCHECK_EQ(0, share_context); | 429 DCHECK_EQ(0, share_context); |
431 if (share_context != 0) | 430 if (share_context != 0) |
432 return 0; | 431 return 0; |
433 | 432 |
434 std::vector<int32_t> attribs; | 433 std::vector<int32_t> attribs; |
435 if (attrib_list) { | 434 if (attrib_list) { |
436 for (const int32_t* attr = attrib_list; | 435 for (const int32_t* attr = attrib_list; |
437 attr[0] != PP_GRAPHICS3DATTRIB_NONE; | 436 attr[0] != PP_GRAPHICS3DATTRIB_NONE; |
438 attr += 2) { | 437 attr += 2) { |
439 attribs.push_back(attr[0]); | 438 attribs.push_back(attr[0]); |
440 attribs.push_back(attr[1]); | 439 attribs.push_back(attr[1]); |
441 } | 440 } |
442 } | 441 } |
443 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); | 442 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); |
444 | 443 |
445 HostResource result; | 444 HostResource result; |
446 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( | 445 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( |
447 INTERFACE_ID_PPB_GRAPHICS_3D, instance, config, attribs, &result)); | 446 INTERFACE_ID_PPB_GRAPHICS_3D, instance, attribs, &result)); |
448 if (result.is_null()) | 447 if (result.is_null()) |
449 return 0; | 448 return 0; |
450 | 449 |
451 linked_ptr<Graphics3D> graphics_3d(new Graphics3D(result)); | 450 linked_ptr<Graphics3D> graphics_3d(new Graphics3D(result)); |
452 if (!graphics_3d->Init()) | 451 if (!graphics_3d->Init()) |
453 return 0; | 452 return 0; |
454 | 453 |
455 return PluginResourceTracker::GetInstance()->AddResource(graphics_3d); | 454 return PluginResourceTracker::GetInstance()->AddResource(graphics_3d); |
456 } | 455 } |
457 | 456 |
(...skipping 22 matching lines...) Expand all Loading... |
480 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, | 479 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, |
481 OnMsgSwapBuffersACK) | 480 OnMsgSwapBuffersACK) |
482 IPC_MESSAGE_UNHANDLED(handled = false) | 481 IPC_MESSAGE_UNHANDLED(handled = false) |
483 | 482 |
484 IPC_END_MESSAGE_MAP() | 483 IPC_END_MESSAGE_MAP() |
485 // FIXME(brettw) handle bad messages! | 484 // FIXME(brettw) handle bad messages! |
486 return handled; | 485 return handled; |
487 } | 486 } |
488 | 487 |
489 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, | 488 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, |
490 PP_Config3D_Dev config, | |
491 const std::vector<int32_t>& attribs, | 489 const std::vector<int32_t>& attribs, |
492 HostResource* result) { | 490 HostResource* result) { |
493 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) | 491 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) |
494 return; // Bad message. | 492 return; // Bad message. |
495 | 493 |
496 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); | 494 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); |
497 if (enter.succeeded()) { | 495 if (enter.succeeded()) { |
498 result->SetHostResource( | 496 result->SetHostResource( |
499 instance, | 497 instance, |
500 enter.functions()->CreateGraphics3DRaw(instance, config, 0, | 498 enter.functions()->CreateGraphics3DRaw(instance, 0, &attribs.front())); |
501 &attribs.front())); | |
502 } | 499 } |
503 } | 500 } |
504 | 501 |
505 void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer( | 502 void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer( |
506 const HostResource& context, | 503 const HostResource& context, |
507 int32 size, | 504 int32 size, |
508 base::SharedMemoryHandle* ring_buffer) { | 505 base::SharedMemoryHandle* ring_buffer) { |
509 *ring_buffer = base::SharedMemory::NULLHandle(); | 506 *ring_buffer = base::SharedMemory::NULLHandle(); |
510 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); | 507 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
511 if (enter.failed()) | 508 if (enter.failed()) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 609 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
613 int32_t result, | 610 int32_t result, |
614 const HostResource& context) { | 611 const HostResource& context) { |
615 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 612 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
616 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); | 613 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); |
617 } | 614 } |
618 | 615 |
619 } // namespace proxy | 616 } // namespace proxy |
620 } // namespace pp | 617 } // namespace pp |
621 | 618 |
OLD | NEW |