OLD | NEW |
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 168 } |
169 virtual void SetParseError(gpu::error::Error error) OVERRIDE { | 169 virtual void SetParseError(gpu::error::Error error) OVERRIDE { |
170 MaybeLock lock(need_to_lock_); | 170 MaybeLock lock(need_to_lock_); |
171 gpu_command_buffer_->SetParseError(error); | 171 gpu_command_buffer_->SetParseError(error); |
172 } | 172 } |
173 virtual void SetContextLostReason( | 173 virtual void SetContextLostReason( |
174 gpu::error::ContextLostReason reason) OVERRIDE { | 174 gpu::error::ContextLostReason reason) OVERRIDE { |
175 MaybeLock lock(need_to_lock_); | 175 MaybeLock lock(need_to_lock_); |
176 gpu_command_buffer_->SetContextLostReason(reason); | 176 gpu_command_buffer_->SetContextLostReason(reason); |
177 } | 177 } |
| 178 virtual uint32 InsertSyncPoint() OVERRIDE { |
| 179 MaybeLock lock(need_to_lock_); |
| 180 return gpu_command_buffer_->InsertSyncPoint(); |
| 181 } |
178 | 182 |
179 // Weak pointer - see class Graphics3D for the scopted_ptr. | 183 // Weak pointer - see class Graphics3D for the scopted_ptr. |
180 gpu::CommandBuffer* gpu_command_buffer_; | 184 gpu::CommandBuffer* gpu_command_buffer_; |
181 | 185 |
182 bool need_to_lock_; | 186 bool need_to_lock_; |
183 }; | 187 }; |
184 | 188 |
185 Graphics3D::Graphics3D(const HostResource& resource) | 189 Graphics3D::Graphics3D(const HostResource& resource) |
186 : PPB_Graphics3D_Shared(resource), | 190 : PPB_Graphics3D_Shared(resource), |
187 num_already_locked_calls_(0) { | 191 num_already_locked_calls_(0) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 int* shm_handle, | 245 int* shm_handle, |
242 uint32_t* shm_size) { | 246 uint32_t* shm_size) { |
243 return PP_FALSE; | 247 return PP_FALSE; |
244 } | 248 } |
245 | 249 |
246 PP_Graphics3DTrustedState Graphics3D::FlushSyncFast(int32_t put_offset, | 250 PP_Graphics3DTrustedState Graphics3D::FlushSyncFast(int32_t put_offset, |
247 int32_t last_known_get) { | 251 int32_t last_known_get) { |
248 return GetErrorState(); | 252 return GetErrorState(); |
249 } | 253 } |
250 | 254 |
| 255 uint32_t Graphics3D::InsertSyncPoint() { |
| 256 NOTREACHED(); |
| 257 return 0; |
| 258 } |
| 259 |
251 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { | 260 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { |
252 return locking_command_buffer_.get(); | 261 return locking_command_buffer_.get(); |
253 } | 262 } |
254 | 263 |
255 int32 Graphics3D::DoSwapBuffers() { | 264 int32 Graphics3D::DoSwapBuffers() { |
256 // gles2_impl()->SwapBuffers() results in CommandBuffer calls, and we already | 265 // gles2_impl()->SwapBuffers() results in CommandBuffer calls, and we already |
257 // have the proxy lock. | 266 // have the proxy lock. |
258 ScopedNoLocking already_locked(this); | 267 ScopedNoLocking already_locked(this); |
259 | 268 |
260 gles2_impl()->SwapBuffers(); | 269 gles2_impl()->SwapBuffers(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush, | 362 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush, |
354 OnMsgAsyncFlush) | 363 OnMsgAsyncFlush) |
355 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer, | 364 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer, |
356 OnMsgCreateTransferBuffer) | 365 OnMsgCreateTransferBuffer) |
357 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer, | 366 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer, |
358 OnMsgDestroyTransferBuffer) | 367 OnMsgDestroyTransferBuffer) |
359 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetTransferBuffer, | 368 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetTransferBuffer, |
360 OnMsgGetTransferBuffer) | 369 OnMsgGetTransferBuffer) |
361 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers, | 370 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers, |
362 OnMsgSwapBuffers) | 371 OnMsgSwapBuffers) |
| 372 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InsertSyncPoint, |
| 373 OnMsgInsertSyncPoint) |
363 #endif // !defined(OS_NACL) | 374 #endif // !defined(OS_NACL) |
364 | 375 |
365 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, | 376 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, |
366 OnMsgSwapBuffersACK) | 377 OnMsgSwapBuffersACK) |
367 IPC_MESSAGE_UNHANDLED(handled = false) | 378 IPC_MESSAGE_UNHANDLED(handled = false) |
368 | 379 |
369 IPC_END_MESSAGE_MAP() | 380 IPC_END_MESSAGE_MAP() |
370 // FIXME(brettw) handle bad messages! | 381 // FIXME(brettw) handle bad messages! |
371 return handled; | 382 return handled; |
372 } | 383 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 } | 493 } |
483 } | 494 } |
484 | 495 |
485 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { | 496 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { |
486 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( | 497 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( |
487 context, callback_factory_, | 498 context, callback_factory_, |
488 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); | 499 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); |
489 if (enter.succeeded()) | 500 if (enter.succeeded()) |
490 enter.SetResult(enter.object()->SwapBuffers(enter.callback())); | 501 enter.SetResult(enter.object()->SwapBuffers(enter.callback())); |
491 } | 502 } |
| 503 |
| 504 void PPB_Graphics3D_Proxy::OnMsgInsertSyncPoint(const HostResource& context, |
| 505 uint32* sync_point) { |
| 506 *sync_point = 0; |
| 507 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 508 if (enter.succeeded()) |
| 509 *sync_point = enter.object()->InsertSyncPoint(); |
| 510 } |
492 #endif // !defined(OS_NACL) | 511 #endif // !defined(OS_NACL) |
493 | 512 |
494 void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, | 513 void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, |
495 int32_t pp_error) { | 514 int32_t pp_error) { |
496 EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource); | 515 EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource); |
497 if (enter.succeeded()) | 516 if (enter.succeeded()) |
498 static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error); | 517 static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error); |
499 } | 518 } |
500 | 519 |
501 #if !defined(OS_NACL) | 520 #if !defined(OS_NACL) |
502 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 521 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
503 int32_t result, | 522 int32_t result, |
504 const HostResource& context) { | 523 const HostResource& context) { |
505 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 524 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
506 API_ID_PPB_GRAPHICS_3D, context, result)); | 525 API_ID_PPB_GRAPHICS_3D, context, result)); |
507 } | 526 } |
508 #endif // !defined(OS_NACL) | 527 #endif // !defined(OS_NACL) |
509 | 528 |
510 } // namespace proxy | 529 } // namespace proxy |
511 } // namespace ppapi | 530 } // namespace ppapi |
512 | 531 |
OLD | NEW |