| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { | 112 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { |
| 113 return command_buffer_.get(); | 113 return command_buffer_.get(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 gpu::GpuControl* Graphics3D::GetGpuControl() { | 116 gpu::GpuControl* Graphics3D::GetGpuControl() { |
| 117 return command_buffer_.get(); | 117 return command_buffer_.get(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token) { | 120 int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token, |
| 121 int32_t width, |
| 122 int32_t height) { |
| 121 // A valid sync token would indicate a swap buffer already happened somehow. | 123 // A valid sync token would indicate a swap buffer already happened somehow. |
| 122 DCHECK(!sync_token.HasData()); | 124 DCHECK(!sync_token.HasData()); |
| 123 | 125 |
| 124 gpu::gles2::GLES2Implementation* gl = gles2_impl(); | 126 gpu::gles2::GLES2Implementation* gl = gles2_impl(); |
| 125 gl->SwapBuffers(); | 127 gl->SwapBuffers(); |
| 126 | 128 |
| 127 PluginDispatcher::GetForResource(this)->Send( | 129 PluginDispatcher::GetForResource(this)->Send( |
| 128 new PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer(API_ID_PPB_GRAPHICS_3D, | 130 new PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer(API_ID_PPB_GRAPHICS_3D, |
| 129 host_resource())); | 131 host_resource())); |
| 130 | 132 |
| 131 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 133 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 132 gl->ShallowFlushCHROMIUM(); | 134 gl->ShallowFlushCHROMIUM(); |
| 133 | 135 |
| 134 gpu::SyncToken new_sync_token; | 136 gpu::SyncToken new_sync_token; |
| 135 gl->GenSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData()); | 137 gl->GenSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData()); |
| 136 | 138 |
| 137 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( | 139 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( |
| 138 API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token); | 140 API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token, width, |
| 141 height); |
| 139 msg->set_unblock(true); | 142 msg->set_unblock(true); |
| 140 PluginDispatcher::GetForResource(this)->Send(msg); | 143 PluginDispatcher::GetForResource(this)->Send(msg); |
| 141 | 144 |
| 142 return PP_OK_COMPLETIONPENDING; | 145 return PP_OK_COMPLETIONPENDING; |
| 143 } | 146 } |
| 144 | 147 |
| 145 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher) | 148 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher) |
| 146 : InterfaceProxy(dispatcher), | 149 : InterfaceProxy(dispatcher), |
| 147 callback_factory_(this) { | 150 callback_factory_(this) { |
| 148 } | 151 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 343 |
| 341 void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer( | 344 void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer( |
| 342 const HostResource& context, | 345 const HostResource& context, |
| 343 int32_t id) { | 346 int32_t id) { |
| 344 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); | 347 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 345 if (enter.succeeded()) | 348 if (enter.succeeded()) |
| 346 enter.object()->DestroyTransferBuffer(id); | 349 enter.object()->DestroyTransferBuffer(id); |
| 347 } | 350 } |
| 348 | 351 |
| 349 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context, | 352 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context, |
| 350 const gpu::SyncToken& sync_token) { | 353 const gpu::SyncToken& sync_token, |
| 354 int32_t width, |
| 355 int32_t height) { |
| 351 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( | 356 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( |
| 352 context, callback_factory_, | 357 context, callback_factory_, |
| 353 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); | 358 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); |
| 354 if (enter.succeeded()) | 359 if (enter.succeeded()) |
| 355 enter.SetResult( | 360 enter.SetResult(enter.object()->SwapBuffersWithSyncToken( |
| 356 enter.object()->SwapBuffersWithSyncToken(enter.callback(), sync_token)); | 361 enter.callback(), sync_token, width, height)); |
| 357 } | 362 } |
| 358 | 363 |
| 359 void PPB_Graphics3D_Proxy::OnMsgTakeFrontBuffer(const HostResource& context) { | 364 void PPB_Graphics3D_Proxy::OnMsgTakeFrontBuffer(const HostResource& context) { |
| 360 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); | 365 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| 361 if (enter.succeeded()) | 366 if (enter.succeeded()) |
| 362 enter.object()->TakeFrontBuffer(); | 367 enter.object()->TakeFrontBuffer(); |
| 363 } | 368 } |
| 364 | 369 |
| 365 void PPB_Graphics3D_Proxy::OnMsgEnsureWorkVisible(const HostResource& context) { | 370 void PPB_Graphics3D_Proxy::OnMsgEnsureWorkVisible(const HostResource& context) { |
| 366 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); | 371 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 380 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 385 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
| 381 int32_t result, | 386 int32_t result, |
| 382 const HostResource& context) { | 387 const HostResource& context) { |
| 383 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 388 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
| 384 API_ID_PPB_GRAPHICS_3D, context, result)); | 389 API_ID_PPB_GRAPHICS_3D, context, result)); |
| 385 } | 390 } |
| 386 #endif // !defined(OS_NACL) | 391 #endif // !defined(OS_NACL) |
| 387 | 392 |
| 388 } // namespace proxy | 393 } // namespace proxy |
| 389 } // namespace ppapi | 394 } // namespace ppapi |
| OLD | NEW |