Index: ppapi/proxy/ppb_graphics_3d_proxy.cc |
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc |
index 847e294680d2acaa5b4a5d07f0c53f0fc4ed7215..20c55de7b9acb09cda5016fda16ddfcd672acc7b 100644 |
--- a/ppapi/proxy/ppb_graphics_3d_proxy.cc |
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc |
@@ -28,18 +28,10 @@ namespace { |
const int32 kCommandBufferSize = 1024 * 1024; |
const int32 kTransferBufferSize = 1024 * 1024; |
-base::SharedMemoryHandle TransportSHMHandleFromInt(Dispatcher* dispatcher, |
- int shm_handle) { |
- // TODO(piman): Change trusted interface to return a PP_FileHandle, those |
- // casts are ugly. |
+base::SharedMemoryHandle TransportSHMHandle(Dispatcher* dispatcher, |
+ base::SharedMemory* shm) { |
base::PlatformFile source = |
-#if defined(OS_WIN) |
- reinterpret_cast<HANDLE>(static_cast<intptr_t>(shm_handle)); |
-#elif defined(OS_POSIX) |
- shm_handle; |
-#else |
- #error Not implemented. |
-#endif |
+ IPC::PlatformFileForTransitToPlatformFile(shm->handle()); |
// Don't close the handle, it doesn't belong to us. |
return dispatcher->ShareHandleWithRemote(source, false); |
} |
@@ -84,20 +76,17 @@ PP_Bool Graphics3D::Flush(int32_t put_offset) { |
return PP_FALSE; |
} |
-int32_t Graphics3D::CreateTransferBuffer(uint32_t size) { |
- return PP_FALSE; |
+scoped_refptr<gpu::Buffer> Graphics3D::CreateTransferBuffer( |
+ uint32_t size, |
+ int32_t* id) { |
+ *id = -1; |
+ return NULL; |
} |
PP_Bool Graphics3D::DestroyTransferBuffer(int32_t id) { |
return PP_FALSE; |
} |
-PP_Bool Graphics3D::GetTransferBuffer(int32_t id, |
- int* shm_handle, |
- uint32_t* shm_size) { |
- return PP_FALSE; |
-} |
- |
gpu::CommandBuffer::State Graphics3D::WaitForTokenInRange(int32_t start, |
int32_t end) { |
return GetErrorState(); |
@@ -203,8 +192,6 @@ bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
OnMsgCreateTransferBuffer) |
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer, |
OnMsgDestroyTransferBuffer) |
- IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetTransferBuffer, |
- OnMsgGetTransferBuffer) |
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers, |
OnMsgSwapBuffers) |
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InsertSyncPoint, |
@@ -301,12 +288,22 @@ void PPB_Graphics3D_Proxy::OnMsgAsyncFlush(const HostResource& context, |
void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer( |
const HostResource& context, |
uint32 size, |
- int32* id) { |
+ int32* id, |
+ ppapi::proxy::SerializedHandle* transfer_buffer) { |
+ transfer_buffer->set_null_shmem(); |
EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
- if (enter.succeeded()) |
- *id = enter.object()->CreateTransferBuffer(size); |
- else |
+ if (enter.succeeded()) { |
+ scoped_refptr<gpu::Buffer> buffer = |
+ enter.object()->CreateTransferBuffer(size, id); |
+ if (!buffer) |
+ return; |
+ DCHECK(buffer->shared_memory()); |
+ transfer_buffer->set_shmem( |
+ TransportSHMHandle(dispatcher(), buffer->shared_memory()), |
+ buffer->size()); |
+ } else { |
*id = -1; |
+ } |
} |
void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer( |
@@ -317,23 +314,6 @@ void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer( |
enter.object()->DestroyTransferBuffer(id); |
} |
-void PPB_Graphics3D_Proxy::OnMsgGetTransferBuffer( |
- const HostResource& context, |
- int32 id, |
- ppapi::proxy::SerializedHandle* transfer_buffer) { |
- transfer_buffer->set_null_shmem(); |
- |
- EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
- int shm_handle = 0; |
- uint32_t shm_size = 0; |
- if (enter.succeeded() && |
- enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) { |
- transfer_buffer->set_shmem( |
- TransportSHMHandleFromInt(dispatcher(), shm_handle), |
- shm_size); |
- } |
-} |
- |
void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { |
EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( |
context, callback_factory_, |