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 "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
10 #include "gpu/command_buffer/common/command_buffer.h" | 10 #include "gpu/command_buffer/common/command_buffer.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 gpu::CommandBuffer::State Graphics3D::WaitForGetOffsetInRange(int32_t start, | 99 gpu::CommandBuffer::State Graphics3D::WaitForGetOffsetInRange(int32_t start, |
100 int32_t end) { | 100 int32_t end) { |
101 return GetErrorState(); | 101 return GetErrorState(); |
102 } | 102 } |
103 | 103 |
104 void Graphics3D::EnsureWorkVisible() { | 104 void Graphics3D::EnsureWorkVisible() { |
105 NOTREACHED(); | 105 NOTREACHED(); |
106 } | 106 } |
107 | 107 |
| 108 void Graphics3D::TakeFrontBuffer() { |
| 109 NOTREACHED(); |
| 110 } |
| 111 |
108 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { | 112 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { |
109 return command_buffer_.get(); | 113 return command_buffer_.get(); |
110 } | 114 } |
111 | 115 |
112 gpu::GpuControl* Graphics3D::GetGpuControl() { | 116 gpu::GpuControl* Graphics3D::GetGpuControl() { |
113 return command_buffer_.get(); | 117 return command_buffer_.get(); |
114 } | 118 } |
115 | 119 |
116 int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token) { | 120 int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token) { |
117 // A valid sync token would indicate a swap buffer already happened somehow. | 121 // A valid sync token would indicate a swap buffer already happened somehow. |
118 DCHECK(!sync_token.HasData()); | 122 DCHECK(!sync_token.HasData()); |
119 | 123 |
120 gpu::gles2::GLES2Implementation* gl = gles2_impl(); | 124 gpu::gles2::GLES2Implementation* gl = gles2_impl(); |
121 gl->SwapBuffers(); | 125 gl->SwapBuffers(); |
| 126 |
| 127 PluginDispatcher::GetForResource(this)->Send( |
| 128 new PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer(API_ID_PPB_GRAPHICS_3D, |
| 129 host_resource())); |
| 130 |
122 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 131 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
123 gl->ShallowFlushCHROMIUM(); | 132 gl->ShallowFlushCHROMIUM(); |
124 | 133 |
125 gpu::SyncToken new_sync_token; | 134 gpu::SyncToken new_sync_token; |
126 gl->GenSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData()); | 135 gl->GenSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData()); |
127 | 136 |
128 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( | 137 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( |
129 API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token); | 138 API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token); |
130 msg->set_unblock(true); | 139 msg->set_unblock(true); |
131 PluginDispatcher::GetForResource(this)->Send(msg); | 140 PluginDispatcher::GetForResource(this)->Send(msg); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 OnMsgWaitForTokenInRange) | 214 OnMsgWaitForTokenInRange) |
206 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange, | 215 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange, |
207 OnMsgWaitForGetOffsetInRange) | 216 OnMsgWaitForGetOffsetInRange) |
208 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush, OnMsgAsyncFlush) | 217 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush, OnMsgAsyncFlush) |
209 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer, | 218 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer, |
210 OnMsgCreateTransferBuffer) | 219 OnMsgCreateTransferBuffer) |
211 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer, | 220 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer, |
212 OnMsgDestroyTransferBuffer) | 221 OnMsgDestroyTransferBuffer) |
213 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers, | 222 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers, |
214 OnMsgSwapBuffers) | 223 OnMsgSwapBuffers) |
| 224 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer, |
| 225 OnMsgTakeFrontBuffer) |
215 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_EnsureWorkVisible, | 226 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_EnsureWorkVisible, |
216 OnMsgEnsureWorkVisible) | 227 OnMsgEnsureWorkVisible) |
217 #endif // !defined(OS_NACL) | 228 #endif // !defined(OS_NACL) |
218 | 229 |
219 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, | 230 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, |
220 OnMsgSwapBuffersACK) | 231 OnMsgSwapBuffersACK) |
221 IPC_MESSAGE_UNHANDLED(handled = false) | 232 IPC_MESSAGE_UNHANDLED(handled = false) |
222 | 233 |
223 IPC_END_MESSAGE_MAP() | 234 IPC_END_MESSAGE_MAP() |
224 // FIXME(brettw) handle bad messages! | 235 // FIXME(brettw) handle bad messages! |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context, | 349 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context, |
339 const gpu::SyncToken& sync_token) { | 350 const gpu::SyncToken& sync_token) { |
340 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( | 351 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( |
341 context, callback_factory_, | 352 context, callback_factory_, |
342 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); | 353 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); |
343 if (enter.succeeded()) | 354 if (enter.succeeded()) |
344 enter.SetResult( | 355 enter.SetResult( |
345 enter.object()->SwapBuffersWithSyncToken(enter.callback(), sync_token)); | 356 enter.object()->SwapBuffersWithSyncToken(enter.callback(), sync_token)); |
346 } | 357 } |
347 | 358 |
| 359 void PPB_Graphics3D_Proxy::OnMsgTakeFrontBuffer(const HostResource& context) { |
| 360 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 361 if (enter.succeeded()) |
| 362 enter.object()->TakeFrontBuffer(); |
| 363 } |
| 364 |
348 void PPB_Graphics3D_Proxy::OnMsgEnsureWorkVisible(const HostResource& context) { | 365 void PPB_Graphics3D_Proxy::OnMsgEnsureWorkVisible(const HostResource& context) { |
349 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); | 366 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
350 if (enter.succeeded()) | 367 if (enter.succeeded()) |
351 enter.object()->EnsureWorkVisible(); | 368 enter.object()->EnsureWorkVisible(); |
352 } | 369 } |
353 #endif // !defined(OS_NACL) | 370 #endif // !defined(OS_NACL) |
354 | 371 |
355 void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, | 372 void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, |
356 int32_t pp_error) { | 373 int32_t pp_error) { |
357 EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource); | 374 EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource); |
358 if (enter.succeeded()) | 375 if (enter.succeeded()) |
359 static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error); | 376 static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error); |
360 } | 377 } |
361 | 378 |
362 #if !defined(OS_NACL) | 379 #if !defined(OS_NACL) |
363 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 380 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
364 int32_t result, | 381 int32_t result, |
365 const HostResource& context) { | 382 const HostResource& context) { |
366 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 383 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
367 API_ID_PPB_GRAPHICS_3D, context, result)); | 384 API_ID_PPB_GRAPHICS_3D, context, result)); |
368 } | 385 } |
369 #endif // !defined(OS_NACL) | 386 #endif // !defined(OS_NACL) |
370 | 387 |
371 } // namespace proxy | 388 } // namespace proxy |
372 } // namespace ppapi | 389 } // namespace ppapi |
OLD | NEW |