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