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

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

Issue 1345813002: Added a unique command buffer ID for command buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad merge Created 5 years, 3 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
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.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 "base/numerics/safe_conversions.h" 7 #include "base/numerics/safe_conversions.h"
8 #include "gpu/command_buffer/client/gles2_implementation.h" 8 #include "gpu/command_buffer/client/gles2_implementation.h"
9 #include "gpu/command_buffer/common/command_buffer.h" 9 #include "gpu/command_buffer/common/command_buffer.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 Graphics3D::Graphics3D(const HostResource& resource) 49 Graphics3D::Graphics3D(const HostResource& resource)
50 : PPB_Graphics3D_Shared(resource) { 50 : PPB_Graphics3D_Shared(resource) {
51 } 51 }
52 52
53 Graphics3D::~Graphics3D() { 53 Graphics3D::~Graphics3D() {
54 DestroyGLES2Impl(); 54 DestroyGLES2Impl();
55 } 55 }
56 56
57 bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2, 57 bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2,
58 const gpu::Capabilities& capabilities, 58 const gpu::Capabilities& capabilities,
59 const SerializedHandle& shared_state) { 59 const SerializedHandle& shared_state,
60 uint64_t command_buffer_id) {
60 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); 61 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this);
61 if (!dispatcher) 62 if (!dispatcher)
62 return false; 63 return false;
63 64
64 command_buffer_.reset(new PpapiCommandBufferProxy( 65 command_buffer_.reset(new PpapiCommandBufferProxy(
65 host_resource(), dispatcher, capabilities, shared_state)); 66 host_resource(), dispatcher, capabilities, shared_state,
67 command_buffer_id));
66 68
67 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize, 69 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize,
68 share_gles2); 70 share_gles2);
69 } 71 }
70 72
71 PP_Bool Graphics3D::SetGetBuffer(int32_t /* transfer_buffer_id */) { 73 PP_Bool Graphics3D::SetGetBuffer(int32_t /* transfer_buffer_id */) {
72 return PP_FALSE; 74 return PP_FALSE;
73 } 75 }
74 76
75 PP_Bool Graphics3D::Flush(int32_t put_offset) { 77 PP_Bool Graphics3D::Flush(int32_t put_offset) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 attr += 2) { 168 attr += 2) {
167 attribs.push_back(attr[0]); 169 attribs.push_back(attr[0]);
168 attribs.push_back(attr[1]); 170 attribs.push_back(attr[1]);
169 } 171 }
170 } 172 }
171 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); 173 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
172 174
173 HostResource result; 175 HostResource result;
174 gpu::Capabilities capabilities; 176 gpu::Capabilities capabilities;
175 ppapi::proxy::SerializedHandle shared_state; 177 ppapi::proxy::SerializedHandle shared_state;
178 uint64_t command_buffer_id = 0;
176 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(API_ID_PPB_GRAPHICS_3D, 179 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(API_ID_PPB_GRAPHICS_3D,
177 instance, share_host, attribs, &result, &capabilities, &shared_state)); 180 instance, share_host, attribs, &result, &capabilities, &shared_state,
181 &command_buffer_id));
178 182
179 if (result.is_null()) 183 if (result.is_null())
180 return 0; 184 return 0;
181 185
182 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); 186 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result));
183 if (!graphics_3d->Init(share_gles2, capabilities, shared_state)) 187 if (!graphics_3d->Init(share_gles2, capabilities, shared_state,
188 command_buffer_id)) {
184 return 0; 189 return 0;
190 }
185 return graphics_3d->GetReference(); 191 return graphics_3d->GetReference();
186 } 192 }
187 193
188 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { 194 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
189 bool handled = true; 195 bool handled = true;
190 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg) 196 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg)
191 #if !defined(OS_NACL) 197 #if !defined(OS_NACL)
192 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create, 198 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create,
193 OnMsgCreate) 199 OnMsgCreate)
194 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SetGetBuffer, 200 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SetGetBuffer,
(...skipping 20 matching lines...) Expand all
215 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, 221 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK,
216 OnMsgSwapBuffersACK) 222 OnMsgSwapBuffersACK)
217 IPC_MESSAGE_UNHANDLED(handled = false) 223 IPC_MESSAGE_UNHANDLED(handled = false)
218 224
219 IPC_END_MESSAGE_MAP() 225 IPC_END_MESSAGE_MAP()
220 // FIXME(brettw) handle bad messages! 226 // FIXME(brettw) handle bad messages!
221 return handled; 227 return handled;
222 } 228 }
223 229
224 #if !defined(OS_NACL) 230 #if !defined(OS_NACL)
225 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, 231 void PPB_Graphics3D_Proxy::OnMsgCreate(
226 HostResource share_context, 232 PP_Instance instance,
227 const std::vector<int32_t>& attribs, 233 HostResource share_context,
228 HostResource* result, 234 const std::vector<int32_t>& attribs,
229 gpu::Capabilities* capabilities, 235 HostResource* result,
230 SerializedHandle* shared_state) { 236 gpu::Capabilities* capabilities,
237 SerializedHandle* shared_state,
238 uint64* command_buffer_id) {
231 shared_state->set_null_shmem(); 239 shared_state->set_null_shmem();
232 if (attribs.empty() || 240 if (attribs.empty() ||
233 attribs.back() != PP_GRAPHICS3DATTRIB_NONE || 241 attribs.back() != PP_GRAPHICS3DATTRIB_NONE ||
234 !(attribs.size() & 1)) 242 !(attribs.size() & 1))
235 return; // Bad message. 243 return; // Bad message.
236 244
237 thunk::EnterResourceCreation enter(instance); 245 thunk::EnterResourceCreation enter(instance);
238 246
239 if (!enter.succeeded()) 247 if (!enter.succeeded())
240 return; 248 return;
241 249
242 base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle(); 250 base::SharedMemoryHandle handle = base::SharedMemory::NULLHandle();
243 result->SetHostResource( 251 result->SetHostResource(
244 instance, 252 instance,
245 enter.functions()->CreateGraphics3DRaw(instance, 253 enter.functions()->CreateGraphics3DRaw(instance,
246 share_context.host_resource(), 254 share_context.host_resource(),
247 &attribs.front(), 255 &attribs.front(),
248 capabilities, 256 capabilities,
249 &handle)); 257 &handle,
258 command_buffer_id));
250 if (!result->is_null()) { 259 if (!result->is_null()) {
251 shared_state->set_shmem(TransportSHMHandle(dispatcher(), handle), 260 shared_state->set_shmem(TransportSHMHandle(dispatcher(), handle),
252 sizeof(gpu::CommandBuffer::State)); 261 sizeof(gpu::CommandBuffer::State));
253 } 262 }
254 } 263 }
255 264
256 void PPB_Graphics3D_Proxy::OnMsgSetGetBuffer( 265 void PPB_Graphics3D_Proxy::OnMsgSetGetBuffer(
257 const HostResource& context, 266 const HostResource& context,
258 int32 transfer_buffer_id) { 267 int32 transfer_buffer_id) {
259 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 268 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( 382 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin(
374 int32_t result, 383 int32_t result,
375 const HostResource& context) { 384 const HostResource& context) {
376 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( 385 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK(
377 API_ID_PPB_GRAPHICS_3D, context, result)); 386 API_ID_PPB_GRAPHICS_3D, context, result));
378 } 387 }
379 #endif // !defined(OS_NACL) 388 #endif // !defined(OS_NACL)
380 389
381 } // namespace proxy 390 } // namespace proxy
382 } // namespace ppapi 391 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698