| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 | 125 |
| 126 const PPB_Context3D_Dev context_3d_interface = { | 126 const PPB_Context3D_Dev context_3d_interface = { |
| 127 &Create, | 127 &Create, |
| 128 &IsContext3D, | 128 &IsContext3D, |
| 129 &GetAttrib, | 129 &GetAttrib, |
| 130 &BindSurfaces, | 130 &BindSurfaces, |
| 131 &GetBoundSurfaces, | 131 &GetBoundSurfaces, |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 base::SharedMemoryHandle SHMHandleFromInt(int shm_handle) { | 134 base::SharedMemoryHandle TransportSHMHandleFromInt(Dispatcher* dispatcher, |
| 135 #if defined(OS_POSIX) | 135 int shm_handle) { |
| 136 // The handle isn't ours to close, but we want to keep a reference to the | 136 // TODO(piman): Change trusted interface to return a PP_FileHandle, those |
| 137 // handle until it is actually sent, so duplicate it, and mark auto-close. | 137 // casts are ugly. |
| 138 return base::FileDescriptor(dup(shm_handle), true); | 138 base::PlatformFile source = |
| 139 #elif defined(OS_WIN) | 139 #if defined(OS_WIN) |
| 140 // TODO(piman): DuplicateHandle to the plugin process. | 140 reinterpret_cast<HANDLE>(static_cast<intptr_t>(handle)); |
| 141 return reinterpret_cast<HANDLE>(shm_handle); | 141 #elif defined(OS_POSIX) |
| 142 shm_handle; |
| 142 #else | 143 #else |
| 143 #error "Platform not supported." | 144 #error Not implemented. |
| 144 #endif | 145 #endif |
| 146 return dispatcher->ShareHandleWithRemote(source, false); |
| 145 } | 147 } |
| 146 | 148 |
| 147 gpu::CommandBuffer::State GPUStateFromPPState( | 149 gpu::CommandBuffer::State GPUStateFromPPState( |
| 148 const PP_Context3DTrustedState& s) { | 150 const PP_Context3DTrustedState& s) { |
| 149 gpu::CommandBuffer::State state; | 151 gpu::CommandBuffer::State state; |
| 150 state.num_entries = s.num_entries; | 152 state.num_entries = s.num_entries; |
| 151 state.get_offset = s.get_offset; | 153 state.get_offset = s.get_offset; |
| 152 state.put_offset = s.put_offset; | 154 state.put_offset = s.put_offset; |
| 153 state.token = s.token; | 155 state.token = s.token; |
| 154 state.error = static_cast<gpu::error::Error>(s.error); | 156 state.error = static_cast<gpu::error::Error>(s.error); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 return; | 532 return; |
| 531 | 533 |
| 532 int shm_handle; | 534 int shm_handle; |
| 533 uint32_t shm_size; | 535 uint32_t shm_size; |
| 534 if (!context_3d_trusted->GetRingBuffer(context.host_resource(), | 536 if (!context_3d_trusted->GetRingBuffer(context.host_resource(), |
| 535 &shm_handle, | 537 &shm_handle, |
| 536 &shm_size)) { | 538 &shm_size)) { |
| 537 return; | 539 return; |
| 538 } | 540 } |
| 539 | 541 |
| 540 *ring_buffer = SHMHandleFromInt(shm_handle); | 542 *ring_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); |
| 541 } | 543 } |
| 542 | 544 |
| 543 void PPB_Context3D_Proxy::OnMsgGetState(const HostResource& context, | 545 void PPB_Context3D_Proxy::OnMsgGetState(const HostResource& context, |
| 544 gpu::CommandBuffer::State* state) { | 546 gpu::CommandBuffer::State* state) { |
| 545 PP_Context3DTrustedState pp_state = | 547 PP_Context3DTrustedState pp_state = |
| 546 ppb_context_3d_trusted()->GetState(context.host_resource()); | 548 ppb_context_3d_trusted()->GetState(context.host_resource()); |
| 547 *state = GPUStateFromPPState(pp_state); | 549 *state = GPUStateFromPPState(pp_state); |
| 548 } | 550 } |
| 549 | 551 |
| 550 void PPB_Context3D_Proxy::OnMsgFlush(const HostResource& context, | 552 void PPB_Context3D_Proxy::OnMsgFlush(const HostResource& context, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 581 uint32* size) { | 583 uint32* size) { |
| 582 *transfer_buffer = base::SharedMemory::NULLHandle(); | 584 *transfer_buffer = base::SharedMemory::NULLHandle(); |
| 583 int shm_handle; | 585 int shm_handle; |
| 584 uint32_t shm_size; | 586 uint32_t shm_size; |
| 585 if (!ppb_context_3d_trusted()->GetTransferBuffer(context.host_resource(), | 587 if (!ppb_context_3d_trusted()->GetTransferBuffer(context.host_resource(), |
| 586 id, | 588 id, |
| 587 &shm_handle, | 589 &shm_handle, |
| 588 &shm_size)) { | 590 &shm_size)) { |
| 589 return; | 591 return; |
| 590 } | 592 } |
| 591 *transfer_buffer = SHMHandleFromInt(shm_handle); | 593 *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); |
| 592 *size = shm_size; | 594 *size = shm_size; |
| 593 } | 595 } |
| 594 | 596 |
| 595 } // namespace proxy | 597 } // namespace proxy |
| 596 } // namespace pp | 598 } // namespace pp |
| OLD | NEW |