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>(shm_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 // Don't close the handle, it doesn't belong to us. |
| 147 return dispatcher->ShareHandleWithRemote(source, false); |
145 } | 148 } |
146 | 149 |
147 gpu::CommandBuffer::State GPUStateFromPPState( | 150 gpu::CommandBuffer::State GPUStateFromPPState( |
148 const PP_Context3DTrustedState& s) { | 151 const PP_Context3DTrustedState& s) { |
149 gpu::CommandBuffer::State state; | 152 gpu::CommandBuffer::State state; |
150 state.num_entries = s.num_entries; | 153 state.num_entries = s.num_entries; |
151 state.get_offset = s.get_offset; | 154 state.get_offset = s.get_offset; |
152 state.put_offset = s.put_offset; | 155 state.put_offset = s.put_offset; |
153 state.token = s.token; | 156 state.token = s.token; |
154 state.error = static_cast<gpu::error::Error>(s.error); | 157 state.error = static_cast<gpu::error::Error>(s.error); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 return; | 533 return; |
531 | 534 |
532 int shm_handle; | 535 int shm_handle; |
533 uint32_t shm_size; | 536 uint32_t shm_size; |
534 if (!context_3d_trusted->GetRingBuffer(context.host_resource(), | 537 if (!context_3d_trusted->GetRingBuffer(context.host_resource(), |
535 &shm_handle, | 538 &shm_handle, |
536 &shm_size)) { | 539 &shm_size)) { |
537 return; | 540 return; |
538 } | 541 } |
539 | 542 |
540 *ring_buffer = SHMHandleFromInt(shm_handle); | 543 *ring_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); |
541 } | 544 } |
542 | 545 |
543 void PPB_Context3D_Proxy::OnMsgGetState(const HostResource& context, | 546 void PPB_Context3D_Proxy::OnMsgGetState(const HostResource& context, |
544 gpu::CommandBuffer::State* state) { | 547 gpu::CommandBuffer::State* state) { |
545 PP_Context3DTrustedState pp_state = | 548 PP_Context3DTrustedState pp_state = |
546 ppb_context_3d_trusted()->GetState(context.host_resource()); | 549 ppb_context_3d_trusted()->GetState(context.host_resource()); |
547 *state = GPUStateFromPPState(pp_state); | 550 *state = GPUStateFromPPState(pp_state); |
548 } | 551 } |
549 | 552 |
550 void PPB_Context3D_Proxy::OnMsgFlush(const HostResource& context, | 553 void PPB_Context3D_Proxy::OnMsgFlush(const HostResource& context, |
(...skipping 30 matching lines...) Expand all Loading... |
581 uint32* size) { | 584 uint32* size) { |
582 *transfer_buffer = base::SharedMemory::NULLHandle(); | 585 *transfer_buffer = base::SharedMemory::NULLHandle(); |
583 int shm_handle; | 586 int shm_handle; |
584 uint32_t shm_size; | 587 uint32_t shm_size; |
585 if (!ppb_context_3d_trusted()->GetTransferBuffer(context.host_resource(), | 588 if (!ppb_context_3d_trusted()->GetTransferBuffer(context.host_resource(), |
586 id, | 589 id, |
587 &shm_handle, | 590 &shm_handle, |
588 &shm_size)) { | 591 &shm_size)) { |
589 return; | 592 return; |
590 } | 593 } |
591 *transfer_buffer = SHMHandleFromInt(shm_handle); | 594 *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); |
592 *size = shm_size; | 595 *size = shm_size; |
593 } | 596 } |
594 | 597 |
595 } // namespace proxy | 598 } // namespace proxy |
596 } // namespace pp | 599 } // namespace pp |
OLD | NEW |