| 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_context_3d_proxy.h" | 5 #include "ppapi/proxy/ppb_context_3d_proxy.h" |
| 6 | 6 |
| 7 #include "base/hash_tables.h" | 7 #include "base/hash_tables.h" |
| 8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 state.token = s.token; | 61 state.token = s.token; |
| 62 state.error = static_cast<gpu::error::Error>(s.error); | 62 state.error = static_cast<gpu::error::Error>(s.error); |
| 63 state.generation = s.generation; | 63 state.generation = s.generation; |
| 64 return state; | 64 return state; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Size of the transfer buffer. | 67 // Size of the transfer buffer. |
| 68 const int32 kCommandBufferSize = 1024 * 1024; | 68 const int32 kCommandBufferSize = 1024 * 1024; |
| 69 const int32 kTransferBufferSize = 1024 * 1024; | 69 const int32 kTransferBufferSize = 1024 * 1024; |
| 70 | 70 |
| 71 InterfaceProxy* CreateContext3DProxy(Dispatcher* dispatcher, | |
| 72 const void* target_interface) { | |
| 73 return new PPB_Context3D_Proxy(dispatcher, target_interface); | |
| 74 } | |
| 75 | |
| 76 } // namespace | 71 } // namespace |
| 77 | 72 |
| 78 class PepperCommandBuffer : public gpu::CommandBuffer { | 73 class PepperCommandBuffer : public gpu::CommandBuffer { |
| 79 public: | 74 public: |
| 80 PepperCommandBuffer(const HostResource& resource, | 75 PepperCommandBuffer(const HostResource& resource, |
| 81 PluginDispatcher* dispatcher); | 76 PluginDispatcher* dispatcher); |
| 82 virtual ~PepperCommandBuffer(); | 77 virtual ~PepperCommandBuffer(); |
| 83 | 78 |
| 84 // CommandBuffer implementation: | 79 // CommandBuffer implementation: |
| 85 virtual bool Initialize(int32 size); | 80 virtual bool Initialize(int32 size); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 void Context3D::UnmapTexSubImage2DCHROMIUM(const void* mem) { | 509 void Context3D::UnmapTexSubImage2DCHROMIUM(const void* mem) { |
| 515 gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem); | 510 gles2_impl_->UnmapTexSubImage2DCHROMIUM(mem); |
| 516 } | 511 } |
| 517 | 512 |
| 518 gpu::gles2::GLES2Implementation* Context3D::GetGLES2Impl() { | 513 gpu::gles2::GLES2Implementation* Context3D::GetGLES2Impl() { |
| 519 return gles2_impl(); | 514 return gles2_impl(); |
| 520 } | 515 } |
| 521 | 516 |
| 522 // PPB_Context3D_Proxy --------------------------------------------------------- | 517 // PPB_Context3D_Proxy --------------------------------------------------------- |
| 523 | 518 |
| 524 PPB_Context3D_Proxy::PPB_Context3D_Proxy(Dispatcher* dispatcher, | 519 PPB_Context3D_Proxy::PPB_Context3D_Proxy(Dispatcher* dispatcher) |
| 525 const void* target_interface) | 520 : InterfaceProxy(dispatcher) { |
| 526 : InterfaceProxy(dispatcher, target_interface) { | |
| 527 } | 521 } |
| 528 | 522 |
| 529 PPB_Context3D_Proxy::~PPB_Context3D_Proxy() { | 523 PPB_Context3D_Proxy::~PPB_Context3D_Proxy() { |
| 530 } | 524 } |
| 531 | 525 |
| 532 // static | 526 // static |
| 533 const InterfaceProxy::Info* PPB_Context3D_Proxy::GetInfo() { | |
| 534 static const Info info = { | |
| 535 thunk::GetPPB_Context3D_Thunk(), | |
| 536 PPB_CONTEXT_3D_DEV_INTERFACE, | |
| 537 INTERFACE_ID_PPB_CONTEXT_3D, | |
| 538 false, | |
| 539 &CreateContext3DProxy, | |
| 540 }; | |
| 541 return &info; | |
| 542 } | |
| 543 | |
| 544 // static | |
| 545 const InterfaceProxy::Info* PPB_Context3D_Proxy::GetTextureMappingInfo() { | |
| 546 static const Info info = { | |
| 547 thunk::GetPPB_GLESChromiumTextureMapping_Thunk(), | |
| 548 PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE, | |
| 549 INTERFACE_ID_NONE, // CONTEXT_3D is the canonical one. | |
| 550 false, | |
| 551 &CreateContext3DProxy, | |
| 552 }; | |
| 553 return &info; | |
| 554 } | |
| 555 | |
| 556 // static | |
| 557 PP_Resource PPB_Context3D_Proxy::Create(PP_Instance instance, | 527 PP_Resource PPB_Context3D_Proxy::Create(PP_Instance instance, |
| 558 PP_Config3D_Dev config, | 528 PP_Config3D_Dev config, |
| 559 PP_Resource share_context, | 529 PP_Resource share_context, |
| 560 const int32_t* attrib_list) { | 530 const int32_t* attrib_list) { |
| 561 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 531 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 562 if (!dispatcher) | 532 if (!dispatcher) |
| 563 return PP_ERROR_BADARGUMENT; | 533 return PP_ERROR_BADARGUMENT; |
| 564 | 534 |
| 565 // TODO(alokp): Support shared context. | 535 // TODO(alokp): Support shared context. |
| 566 DCHECK_EQ(0, share_context); | 536 DCHECK_EQ(0, share_context); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 // FIXME(brettw) handle bad messages! | 584 // FIXME(brettw) handle bad messages! |
| 615 return handled; | 585 return handled; |
| 616 } | 586 } |
| 617 | 587 |
| 618 void PPB_Context3D_Proxy::OnMsgCreate(PP_Instance instance, | 588 void PPB_Context3D_Proxy::OnMsgCreate(PP_Instance instance, |
| 619 PP_Config3D_Dev config, | 589 PP_Config3D_Dev config, |
| 620 const std::vector<int32_t>& attribs, | 590 const std::vector<int32_t>& attribs, |
| 621 HostResource* result) { | 591 HostResource* result) { |
| 622 if (attribs.empty() || attribs.back() != 0) | 592 if (attribs.empty() || attribs.back() != 0) |
| 623 return; // Bad message. | 593 return; // Bad message. |
| 624 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); | 594 thunk::EnterResourceCreation enter(instance); |
| 625 if (enter.succeeded()) { | 595 if (enter.succeeded()) { |
| 626 result->SetHostResource( | 596 result->SetHostResource( |
| 627 instance, | 597 instance, |
| 628 enter.functions()->CreateContext3DRaw(instance, config, 0, | 598 enter.functions()->CreateContext3DRaw(instance, config, 0, |
| 629 &attribs.front())); | 599 &attribs.front())); |
| 630 } | 600 } |
| 631 } | 601 } |
| 632 | 602 |
| 633 void PPB_Context3D_Proxy::OnMsgBindSurfaces(const HostResource& context, | 603 void PPB_Context3D_Proxy::OnMsgBindSurfaces(const HostResource& context, |
| 634 const HostResource& draw, | 604 const HostResource& draw, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 uint32_t shm_size = 0; | 692 uint32_t shm_size = 0; |
| 723 if (enter.succeeded() && | 693 if (enter.succeeded() && |
| 724 enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) { | 694 enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) { |
| 725 *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); | 695 *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); |
| 726 *size = shm_size; | 696 *size = shm_size; |
| 727 } | 697 } |
| 728 } | 698 } |
| 729 | 699 |
| 730 } // namespace proxy | 700 } // namespace proxy |
| 731 } // namespace ppapi | 701 } // namespace ppapi |
| OLD | NEW |