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

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

Issue 1586883002: Converted Ppapi post swap buffer sync point to use sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some .get() booleans Created 4 years, 11 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/shared_impl/ppb_graphics_3d_shared.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 "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"
11 #include "gpu/command_buffer/common/sync_token.h"
11 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/proxy/enter_proxy.h" 13 #include "ppapi/proxy/enter_proxy.h"
13 #include "ppapi/proxy/plugin_dispatcher.h" 14 #include "ppapi/proxy/plugin_dispatcher.h"
14 #include "ppapi/proxy/ppapi_command_buffer_proxy.h" 15 #include "ppapi/proxy/ppapi_command_buffer_proxy.h"
15 #include "ppapi/proxy/ppapi_messages.h" 16 #include "ppapi/proxy/ppapi_messages.h"
16 #include "ppapi/shared_impl/ppapi_globals.h" 17 #include "ppapi/shared_impl/ppapi_globals.h"
17 #include "ppapi/thunk/enter.h" 18 #include "ppapi/thunk/enter.h"
18 #include "ppapi/thunk/resource_creation_api.h" 19 #include "ppapi/thunk/resource_creation_api.h"
19 #include "ppapi/thunk/thunk.h" 20 #include "ppapi/thunk/thunk.h"
20 21
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 120 }
120 121
121 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() { 122 gpu::CommandBuffer* Graphics3D::GetCommandBuffer() {
122 return command_buffer_.get(); 123 return command_buffer_.get();
123 } 124 }
124 125
125 gpu::GpuControl* Graphics3D::GetGpuControl() { 126 gpu::GpuControl* Graphics3D::GetGpuControl() {
126 return command_buffer_.get(); 127 return command_buffer_.get();
127 } 128 }
128 129
129 int32_t Graphics3D::DoSwapBuffers() { 130 int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token) {
130 gles2_impl()->SwapBuffers(); 131 // A valid sync token would indicate a swap buffer already happened somehow.
132 DCHECK(!sync_token.HasData());
133
134 gpu::gles2::GLES2Implementation* gl = gles2_impl();
135 gl->SwapBuffers();
136 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
137 gl->ShallowFlushCHROMIUM();
138
139 gpu::SyncToken new_sync_token;
140 gl->GenSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData());
141
131 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( 142 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers(
132 API_ID_PPB_GRAPHICS_3D, host_resource()); 143 API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token);
133 msg->set_unblock(true); 144 msg->set_unblock(true);
134 PluginDispatcher::GetForResource(this)->Send(msg); 145 PluginDispatcher::GetForResource(this)->Send(msg);
135 146
136 return PP_OK_COMPLETIONPENDING; 147 return PP_OK_COMPLETIONPENDING;
137 } 148 }
138 149
139 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher) 150 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher)
140 : InterfaceProxy(dispatcher), 151 : InterfaceProxy(dispatcher),
141 callback_factory_(this) { 152 callback_factory_(this) {
142 } 153 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 347 }
337 348
338 void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer( 349 void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer(
339 const HostResource& context, 350 const HostResource& context,
340 int32_t id) { 351 int32_t id) {
341 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 352 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
342 if (enter.succeeded()) 353 if (enter.succeeded())
343 enter.object()->DestroyTransferBuffer(id); 354 enter.object()->DestroyTransferBuffer(id);
344 } 355 }
345 356
346 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { 357 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context,
358 const gpu::SyncToken& sync_token) {
347 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( 359 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter(
348 context, callback_factory_, 360 context, callback_factory_,
349 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); 361 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context);
350 if (enter.succeeded()) 362 if (enter.succeeded())
351 enter.SetResult(enter.object()->SwapBuffers(enter.callback())); 363 enter.SetResult(enter.object()->SwapBuffers(enter.callback(), sync_token));
352 } 364 }
353 365
354 void PPB_Graphics3D_Proxy::OnMsgInsertSyncPoint(const HostResource& context, 366 void PPB_Graphics3D_Proxy::OnMsgInsertSyncPoint(const HostResource& context,
355 uint32_t* sync_point) { 367 uint32_t* sync_point) {
356 *sync_point = 0; 368 *sync_point = 0;
357 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); 369 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
358 if (enter.succeeded()) 370 if (enter.succeeded())
359 *sync_point = enter.object()->InsertSyncPoint(); 371 *sync_point = enter.object()->InsertSyncPoint();
360 } 372 }
361 373
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( 405 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin(
394 int32_t result, 406 int32_t result,
395 const HostResource& context) { 407 const HostResource& context) {
396 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( 408 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK(
397 API_ID_PPB_GRAPHICS_3D, context, result)); 409 API_ID_PPB_GRAPHICS_3D, context, result));
398 } 410 }
399 #endif // !defined(OS_NACL) 411 #endif // !defined(OS_NACL)
400 412
401 } // namespace proxy 413 } // namespace proxy
402 } // namespace ppapi 414 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_graphics_3d_proxy.h ('k') | ppapi/shared_impl/ppb_graphics_3d_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698