Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1309)

Side by Side Diff: ppapi/proxy/ppb_graphics_3d_proxy.cc

Issue 215803002: Remove CommandBuffer::GetTransferBuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/thunk/ppb_graphics_3d_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "gpu/command_buffer/common/command_buffer.h" 8 #include "gpu/command_buffer/common/command_buffer.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/enter_proxy.h" 10 #include "ppapi/proxy/enter_proxy.h"
(...skipping 10 matching lines...) Expand all
21 using ppapi::thunk::ResourceCreationAPI; 21 using ppapi::thunk::ResourceCreationAPI;
22 22
23 namespace ppapi { 23 namespace ppapi {
24 namespace proxy { 24 namespace proxy {
25 25
26 namespace { 26 namespace {
27 27
28 const int32 kCommandBufferSize = 1024 * 1024; 28 const int32 kCommandBufferSize = 1024 * 1024;
29 const int32 kTransferBufferSize = 1024 * 1024; 29 const int32 kTransferBufferSize = 1024 * 1024;
30 30
31 base::SharedMemoryHandle TransportSHMHandleFromInt(Dispatcher* dispatcher, 31 base::SharedMemoryHandle TransportSHMHandle(Dispatcher* dispatcher,
32 int shm_handle) { 32 base::SharedMemory* shm) {
33 // TODO(piman): Change trusted interface to return a PP_FileHandle, those
34 // casts are ugly.
35 base::PlatformFile source = 33 base::PlatformFile source =
36 #if defined(OS_WIN) 34 IPC::PlatformFileForTransitToPlatformFile(shm->handle());
37 reinterpret_cast<HANDLE>(static_cast<intptr_t>(shm_handle));
38 #elif defined(OS_POSIX)
39 shm_handle;
40 #else
41 #error Not implemented.
42 #endif
43 // Don't close the handle, it doesn't belong to us. 35 // Don't close the handle, it doesn't belong to us.
44 return dispatcher->ShareHandleWithRemote(source, false); 36 return dispatcher->ShareHandleWithRemote(source, false);
45 } 37 }
46 38
47 gpu::CommandBuffer::State GetErrorState() { 39 gpu::CommandBuffer::State GetErrorState() {
48 gpu::CommandBuffer::State error_state; 40 gpu::CommandBuffer::State error_state;
49 error_state.error = gpu::error::kGenericError; 41 error_state.error = gpu::error::kGenericError;
50 return error_state; 42 return error_state;
51 } 43 }
52 44
(...skipping 24 matching lines...) Expand all
77 } 69 }
78 70
79 gpu::CommandBuffer::State Graphics3D::GetState() { 71 gpu::CommandBuffer::State Graphics3D::GetState() {
80 return GetErrorState(); 72 return GetErrorState();
81 } 73 }
82 74
83 PP_Bool Graphics3D::Flush(int32_t put_offset) { 75 PP_Bool Graphics3D::Flush(int32_t put_offset) {
84 return PP_FALSE; 76 return PP_FALSE;
85 } 77 }
86 78
87 int32_t Graphics3D::CreateTransferBuffer(uint32_t size) { 79 scoped_refptr<gpu::Buffer> Graphics3D::CreateTransferBuffer(
88 return PP_FALSE; 80 uint32_t size,
81 int32_t* id) {
82 *id = -1;
83 return NULL;
89 } 84 }
90 85
91 PP_Bool Graphics3D::DestroyTransferBuffer(int32_t id) { 86 PP_Bool Graphics3D::DestroyTransferBuffer(int32_t id) {
92 return PP_FALSE; 87 return PP_FALSE;
93 } 88 }
94 89
95 PP_Bool Graphics3D::GetTransferBuffer(int32_t id,
96 int* shm_handle,
97 uint32_t* shm_size) {
98 return PP_FALSE;
99 }
100
101 gpu::CommandBuffer::State Graphics3D::WaitForTokenInRange(int32_t start, 90 gpu::CommandBuffer::State Graphics3D::WaitForTokenInRange(int32_t start,
102 int32_t end) { 91 int32_t end) {
103 return GetErrorState(); 92 return GetErrorState();
104 } 93 }
105 94
106 gpu::CommandBuffer::State Graphics3D::WaitForGetOffsetInRange(int32_t start, 95 gpu::CommandBuffer::State Graphics3D::WaitForGetOffsetInRange(int32_t start,
107 int32_t end) { 96 int32_t end) {
108 return GetErrorState(); 97 return GetErrorState();
109 } 98 }
110 99
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 OnMsgGetState) 185 OnMsgGetState)
197 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange, 186 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange,
198 OnMsgWaitForTokenInRange) 187 OnMsgWaitForTokenInRange)
199 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange, 188 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange,
200 OnMsgWaitForGetOffsetInRange) 189 OnMsgWaitForGetOffsetInRange)
201 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush, OnMsgAsyncFlush) 190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush, OnMsgAsyncFlush)
202 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer, 191 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer,
203 OnMsgCreateTransferBuffer) 192 OnMsgCreateTransferBuffer)
204 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer, 193 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer,
205 OnMsgDestroyTransferBuffer) 194 OnMsgDestroyTransferBuffer)
206 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetTransferBuffer,
207 OnMsgGetTransferBuffer)
208 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers, 195 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers,
209 OnMsgSwapBuffers) 196 OnMsgSwapBuffers)
210 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InsertSyncPoint, 197 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InsertSyncPoint,
211 OnMsgInsertSyncPoint) 198 OnMsgInsertSyncPoint)
212 #endif // !defined(OS_NACL) 199 #endif // !defined(OS_NACL)
213 200
214 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, 201 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK,
215 OnMsgSwapBuffersACK) 202 OnMsgSwapBuffersACK)
216 IPC_MESSAGE_UNHANDLED(handled = false) 203 IPC_MESSAGE_UNHANDLED(handled = false)
217 204
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 void PPB_Graphics3D_Proxy::OnMsgAsyncFlush(const HostResource& context, 281 void PPB_Graphics3D_Proxy::OnMsgAsyncFlush(const HostResource& context,
295 int32 put_offset) { 282 int32 put_offset) {
296 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 283 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
297 if (enter.succeeded()) 284 if (enter.succeeded())
298 enter.object()->Flush(put_offset); 285 enter.object()->Flush(put_offset);
299 } 286 }
300 287
301 void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer( 288 void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer(
302 const HostResource& context, 289 const HostResource& context,
303 uint32 size, 290 uint32 size,
304 int32* id) { 291 int32* id,
292 ppapi::proxy::SerializedHandle* transfer_buffer) {
293 transfer_buffer->set_null_shmem();
305 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 294 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
306 if (enter.succeeded()) 295 if (enter.succeeded()) {
307 *id = enter.object()->CreateTransferBuffer(size); 296 scoped_refptr<gpu::Buffer> buffer =
308 else 297 enter.object()->CreateTransferBuffer(size, id);
298 if (!buffer)
299 return;
300 DCHECK(buffer->shared_memory());
301 transfer_buffer->set_shmem(
302 TransportSHMHandle(dispatcher(), buffer->shared_memory()),
303 buffer->size());
304 } else {
309 *id = -1; 305 *id = -1;
306 }
310 } 307 }
311 308
312 void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer( 309 void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer(
313 const HostResource& context, 310 const HostResource& context,
314 int32 id) { 311 int32 id) {
315 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 312 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
316 if (enter.succeeded()) 313 if (enter.succeeded())
317 enter.object()->DestroyTransferBuffer(id); 314 enter.object()->DestroyTransferBuffer(id);
318 } 315 }
319 316
320 void PPB_Graphics3D_Proxy::OnMsgGetTransferBuffer(
321 const HostResource& context,
322 int32 id,
323 ppapi::proxy::SerializedHandle* transfer_buffer) {
324 transfer_buffer->set_null_shmem();
325
326 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
327 int shm_handle = 0;
328 uint32_t shm_size = 0;
329 if (enter.succeeded() &&
330 enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) {
331 transfer_buffer->set_shmem(
332 TransportSHMHandleFromInt(dispatcher(), shm_handle),
333 shm_size);
334 }
335 }
336
337 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { 317 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) {
338 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( 318 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter(
339 context, callback_factory_, 319 context, callback_factory_,
340 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); 320 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context);
341 if (enter.succeeded()) 321 if (enter.succeeded())
342 enter.SetResult(enter.object()->SwapBuffers(enter.callback())); 322 enter.SetResult(enter.object()->SwapBuffers(enter.callback()));
343 } 323 }
344 324
345 void PPB_Graphics3D_Proxy::OnMsgInsertSyncPoint(const HostResource& context, 325 void PPB_Graphics3D_Proxy::OnMsgInsertSyncPoint(const HostResource& context,
346 uint32* sync_point) { 326 uint32* sync_point) {
(...skipping 16 matching lines...) Expand all
363 int32_t result, 343 int32_t result,
364 const HostResource& context) { 344 const HostResource& context) {
365 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( 345 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK(
366 API_ID_PPB_GRAPHICS_3D, context, result)); 346 API_ID_PPB_GRAPHICS_3D, context, result));
367 } 347 }
368 #endif // !defined(OS_NACL) 348 #endif // !defined(OS_NACL)
369 349
370 } // namespace proxy 350 } // namespace proxy
371 } // namespace ppapi 351 } // namespace ppapi
372 352
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/thunk/ppb_graphics_3d_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698