blob: ea77cd1f918aa1dc449b85ed01c9c9e41dbc2abd [file] [log] [blame]
[email protected]aaa11b32012-03-08 12:30:131// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]eeb4e4a2011-07-19 16:22:062// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ppapi/proxy/ppb_graphics_3d_proxy.h"
6
brettw669d47b12015-02-13 21:17:387#include "base/numerics/safe_conversions.h"
avie029c4132015-12-23 06:45:228#include "build/build_config.h"
[email protected]eeb4e4a2011-07-19 16:22:069#include "gpu/command_buffer/client/gles2_implementation.h"
[email protected]84b44c552012-10-15 20:58:1710#include "gpu/command_buffer/common/command_buffer.h"
dyenddfdbbb2016-01-14 22:21:3811#include "gpu/command_buffer/common/sync_token.h"
[email protected]eeb4e4a2011-07-19 16:22:0612#include "ppapi/c/pp_errors.h"
13#include "ppapi/proxy/enter_proxy.h"
14#include "ppapi/proxy/plugin_dispatcher.h"
[email protected]aaa11b32012-03-08 12:30:1315#include "ppapi/proxy/ppapi_command_buffer_proxy.h"
[email protected]eeb4e4a2011-07-19 16:22:0616#include "ppapi/proxy/ppapi_messages.h"
[email protected]84b44c552012-10-15 20:58:1717#include "ppapi/shared_impl/ppapi_globals.h"
[email protected]eeb4e4a2011-07-19 16:22:0618#include "ppapi/thunk/enter.h"
19#include "ppapi/thunk/resource_creation_api.h"
20#include "ppapi/thunk/thunk.h"
21
[email protected]eeb4e4a2011-07-19 16:22:0622using ppapi::thunk::EnterResourceNoLock;
23using ppapi::thunk::PPB_Graphics3D_API;
24using ppapi::thunk::ResourceCreationAPI;
25
[email protected]4d2efd22011-08-18 21:58:0226namespace ppapi {
[email protected]eeb4e4a2011-07-19 16:22:0627namespace proxy {
28
29namespace {
[email protected]84b44c552012-10-15 20:58:1730
mazda9cfbcfb2014-11-12 17:07:1131#if !defined(OS_NACL)
penghuanga206fb492014-09-09 21:27:3232base::SharedMemoryHandle TransportSHMHandle(
33 Dispatcher* dispatcher,
34 const base::SharedMemoryHandle& handle) {
[email protected]eeb4e4a2011-07-19 16:22:0635 // Don't close the handle, it doesn't belong to us.
erikchen4fc32d52015-06-02 02:16:3836 return dispatcher->ShareSharedMemoryHandleWithRemote(handle);
[email protected]eeb4e4a2011-07-19 16:22:0637}
mazda9cfbcfb2014-11-12 17:07:1138#endif // !defined(OS_NACL)
[email protected]eeb4e4a2011-07-19 16:22:0639
[email protected]914f5262013-06-01 00:17:2240gpu::CommandBuffer::State GetErrorState() {
41 gpu::CommandBuffer::State error_state;
42 error_state.error = gpu::error::kGenericError;
[email protected]eeb4e4a2011-07-19 16:22:0643 return error_state;
44}
45
[email protected]eeb4e4a2011-07-19 16:22:0646} // namespace
47
pimanb36392c22016-07-13 02:11:3648Graphics3D::Graphics3D(const HostResource& resource, const gfx::Size& size)
49 : PPB_Graphics3D_Shared(resource, size) {
[email protected]eeb4e4a2011-07-19 16:22:0650}
51
52Graphics3D::~Graphics3D() {
[email protected]edccb562013-10-02 00:01:2053 DestroyGLES2Impl();
[email protected]eeb4e4a2011-07-19 16:22:0654}
55
penghuanga206fb492014-09-09 21:27:3256bool Graphics3D::Init(gpu::gles2::GLES2Implementation* share_gles2,
piman360175c2014-11-07 02:30:0157 const gpu::Capabilities& capabilities,
dyen12e45962015-09-18 00:13:5158 const SerializedHandle& shared_state,
lukasza2573ce7d2016-02-16 19:17:2259 gpu::CommandBufferId command_buffer_id) {
[email protected]7f8b26b2011-08-18 15:41:0160 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this);
[email protected]eeb4e4a2011-07-19 16:22:0661 if (!dispatcher)
62 return false;
63
piman360175c2014-11-07 02:30:0164 command_buffer_.reset(new PpapiCommandBufferProxy(
dyen12e45962015-09-18 00:13:5165 host_resource(), dispatcher, capabilities, shared_state,
66 command_buffer_id));
[email protected]84b44c552012-10-15 20:58:1767
Eric Karl2fc4409b92017-08-18 18:48:3968 return CreateGLES2Impl(share_gles2);
[email protected]eeb4e4a2011-07-19 16:22:0669}
70
[email protected]503b3a22011-12-12 23:29:4071PP_Bool Graphics3D::SetGetBuffer(int32_t /* transfer_buffer_id */) {
[email protected]eeb4e4a2011-07-19 16:22:0672 return PP_FALSE;
73}
74
[email protected]eeb4e4a2011-07-19 16:22:0675PP_Bool Graphics3D::Flush(int32_t put_offset) {
76 return PP_FALSE;
77}
78
[email protected]046fa1ac2014-04-01 09:06:4379scoped_refptr<gpu::Buffer> Graphics3D::CreateTransferBuffer(
80 uint32_t size,
81 int32_t* id) {
82 *id = -1;
83 return NULL;
[email protected]eeb4e4a2011-07-19 16:22:0684}
85
86PP_Bool Graphics3D::DestroyTransferBuffer(int32_t id) {
87 return PP_FALSE;
88}
89
[email protected]7fe4198b2014-03-18 21:52:3690gpu::CommandBuffer::State Graphics3D::WaitForTokenInRange(int32_t start,
91 int32_t end) {
92 return GetErrorState();
93}
94
Antoine Labourd3469942017-05-16 21:23:4295gpu::CommandBuffer::State Graphics3D::WaitForGetOffsetInRange(
96 uint32_t set_get_buffer_count,
97 int32_t start,
98 int32_t end) {
[email protected]eeb4e4a2011-07-19 16:22:0699 return GetErrorState();
100}
101
dyen4de3d345f2016-01-12 18:30:42102void Graphics3D::EnsureWorkVisible() {
103 NOTREACHED();
104}
105
erikchen438b0442016-05-11 18:33:30106void Graphics3D::TakeFrontBuffer() {
107 NOTREACHED();
108}
109
[email protected]eeb4e4a2011-07-19 16:22:06110gpu::CommandBuffer* Graphics3D::GetCommandBuffer() {
[email protected]4e46a732013-09-30 18:35:59111 return command_buffer_.get();
[email protected]eeb4e4a2011-07-19 16:22:06112}
113
[email protected]744e0792013-09-27 01:18:35114gpu::GpuControl* Graphics3D::GetGpuControl() {
115 return command_buffer_.get();
116}
117
erikchenb13637b2016-07-08 09:38:56118int32_t Graphics3D::DoSwapBuffers(const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:36119 const gfx::Size& size) {
dyenddfdbbb2016-01-14 22:21:38120 // A valid sync token would indicate a swap buffer already happened somehow.
121 DCHECK(!sync_token.HasData());
122
123 gpu::gles2::GLES2Implementation* gl = gles2_impl();
124 gl->SwapBuffers();
erikchen438b0442016-05-11 18:33:30125
126 PluginDispatcher::GetForResource(this)->Send(
127 new PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer(API_ID_PPB_GRAPHICS_3D,
128 host_resource()));
129
dyenddfdbbb2016-01-14 22:21:38130 gpu::SyncToken new_sync_token;
Sunny Sachanandanic94b8de2017-12-16 03:30:30131 gl->GenSyncTokenCHROMIUM(new_sync_token.GetData());
dyenddfdbbb2016-01-14 22:21:38132
[email protected]eeb4e4a2011-07-19 16:22:06133 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers(
pimanb36392c22016-07-13 02:11:36134 API_ID_PPB_GRAPHICS_3D, host_resource(), new_sync_token, size);
[email protected]eeb4e4a2011-07-19 16:22:06135 msg->set_unblock(true);
[email protected]7f8b26b2011-08-18 15:41:01136 PluginDispatcher::GetForResource(this)->Send(msg);
[email protected]eeb4e4a2011-07-19 16:22:06137
[email protected]eeb4e4a2011-07-19 16:22:06138 return PP_OK_COMPLETIONPENDING;
139}
140
[email protected]5c966022011-09-13 18:09:37141PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher)
142 : InterfaceProxy(dispatcher),
[email protected]a2f53dc2013-04-30 01:06:35143 callback_factory_(this) {
[email protected]eeb4e4a2011-07-19 16:22:06144}
145
146PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() {
147}
148
149// static
[email protected]eeb4e4a2011-07-19 16:22:06150PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource(
151 PP_Instance instance,
[email protected]eeb4e4a2011-07-19 16:22:06152 PP_Resource share_context,
153 const int32_t* attrib_list) {
154 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
155 if (!dispatcher)
156 return PP_ERROR_BADARGUMENT;
157
[email protected]9ed07f82012-05-29 21:54:55158 HostResource share_host;
159 gpu::gles2::GLES2Implementation* share_gles2 = NULL;
160 if (share_context != 0) {
161 EnterResourceNoLock<PPB_Graphics3D_API> enter(share_context, true);
162 if (enter.failed())
163 return PP_ERROR_BADARGUMENT;
164
165 PPB_Graphics3D_Shared* share_graphics =
166 static_cast<PPB_Graphics3D_Shared*>(enter.object());
167 share_host = share_graphics->host_resource();
168 share_gles2 = share_graphics->gles2_impl();
169 }
[email protected]eeb4e4a2011-07-19 16:22:06170
Antoine Labourfeab2392017-12-21 20:28:39171 gpu::ContextCreationAttribs attrib_helper;
[email protected]eeb4e4a2011-07-19 16:22:06172 if (attrib_list) {
pimanfe4e4882016-07-09 01:18:21173 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE;
[email protected]0e50fc4d2011-08-01 15:33:51174 attr += 2) {
Antoine Labour492d57a12017-12-21 02:42:11175 int32_t key = attr[0];
176 int32_t value = attr[1];
177 switch (key) {
178 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE:
179 attrib_helper.alpha_size = value;
180 break;
181 case PP_GRAPHICS3DATTRIB_BLUE_SIZE:
182 attrib_helper.blue_size = value;
183 break;
184 case PP_GRAPHICS3DATTRIB_GREEN_SIZE:
185 attrib_helper.green_size = value;
186 break;
187 case PP_GRAPHICS3DATTRIB_RED_SIZE:
188 attrib_helper.red_size = value;
189 break;
190 case PP_GRAPHICS3DATTRIB_DEPTH_SIZE:
191 attrib_helper.depth_size = value;
192 break;
193 case PP_GRAPHICS3DATTRIB_STENCIL_SIZE:
194 attrib_helper.stencil_size = value;
195 break;
196 case PP_GRAPHICS3DATTRIB_SAMPLES:
197 attrib_helper.samples = value;
198 break;
199 case PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS:
200 attrib_helper.sample_buffers = value;
201 break;
202 case PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR:
203 attrib_helper.buffer_preserved =
204 value == PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED;
205 break;
pimanfe4e4882016-07-09 01:18:21206 case PP_GRAPHICS3DATTRIB_WIDTH:
Antoine Labour492d57a12017-12-21 02:42:11207 attrib_helper.offscreen_framebuffer_size.set_width(value);
pimanfe4e4882016-07-09 01:18:21208 break;
209 case PP_GRAPHICS3DATTRIB_HEIGHT:
Antoine Labour492d57a12017-12-21 02:42:11210 attrib_helper.offscreen_framebuffer_size.set_height(value);
pimanfe4e4882016-07-09 01:18:21211 break;
212 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE:
213 attrib_helper.gpu_preference =
Antoine Labour492d57a12017-12-21 02:42:11214 (value == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER)
pimanfe4e4882016-07-09 01:18:21215 ? gl::PreferIntegratedGpu
216 : gl::PreferDiscreteGpu;
217 break;
David Revemanca46de732017-06-09 19:48:19218 case PP_GRAPHICS3DATTRIB_SINGLE_BUFFER:
Antoine Labour492d57a12017-12-21 02:42:11219 attrib_helper.single_buffer = !!value;
David Revemanca46de732017-06-09 19:48:19220 break;
pimanfe4e4882016-07-09 01:18:21221 default:
Antoine Labour492d57a12017-12-21 02:42:11222 DLOG(ERROR) << "Invalid context creation attribute: " << attr[0];
223 return 0;
pimanfe4e4882016-07-09 01:18:21224 }
[email protected]eeb4e4a2011-07-19 16:22:06225 }
[email protected]eeb4e4a2011-07-19 16:22:06226 }
[email protected]eeb4e4a2011-07-19 16:22:06227
228 HostResource result;
piman360175c2014-11-07 02:30:01229 gpu::Capabilities capabilities;
penghuanga206fb492014-09-09 21:27:32230 ppapi::proxy::SerializedHandle shared_state;
lukasza2573ce7d2016-02-16 19:17:22231 gpu::CommandBufferId command_buffer_id;
pimanfe4e4882016-07-09 01:18:21232 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(
233 API_ID_PPB_GRAPHICS_3D, instance, share_host, attrib_helper, &result,
234 &capabilities, &shared_state, &command_buffer_id));
penghuanga206fb492014-09-09 21:27:32235
[email protected]eeb4e4a2011-07-19 16:22:06236 if (result.is_null())
237 return 0;
238
pimanb36392c22016-07-13 02:11:36239 scoped_refptr<Graphics3D> graphics_3d(
240 new Graphics3D(result, attrib_helper.offscreen_framebuffer_size));
dyen12e45962015-09-18 00:13:51241 if (!graphics_3d->Init(share_gles2, capabilities, shared_state,
242 command_buffer_id)) {
[email protected]eeb4e4a2011-07-19 16:22:06243 return 0;
dyen12e45962015-09-18 00:13:51244 }
[email protected]7f8b26b2011-08-18 15:41:01245 return graphics_3d->GetReference();
[email protected]eeb4e4a2011-07-19 16:22:06246}
247
248bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
249 bool handled = true;
250 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg)
[email protected]11494c5c2012-11-13 02:50:57251#if !defined(OS_NACL)
[email protected]eeb4e4a2011-07-19 16:22:06252 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create,
253 OnMsgCreate)
[email protected]503b3a22011-12-12 23:29:40254 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SetGetBuffer,
255 OnMsgSetGetBuffer)
[email protected]7fe4198b2014-03-18 21:52:36256 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForTokenInRange,
257 OnMsgWaitForTokenInRange)
258 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_WaitForGetOffsetInRange,
259 OnMsgWaitForGetOffsetInRange)
260 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush, OnMsgAsyncFlush)
[email protected]eeb4e4a2011-07-19 16:22:06261 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer,
262 OnMsgCreateTransferBuffer)
263 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer,
264 OnMsgDestroyTransferBuffer)
[email protected]eeb4e4a2011-07-19 16:22:06265 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers,
266 OnMsgSwapBuffers)
erikchen438b0442016-05-11 18:33:30267 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_TakeFrontBuffer,
268 OnMsgTakeFrontBuffer)
dyen4de3d345f2016-01-12 18:30:42269 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_EnsureWorkVisible,
270 OnMsgEnsureWorkVisible)
[email protected]11494c5c2012-11-13 02:50:57271#endif // !defined(OS_NACL)
[email protected]eeb4e4a2011-07-19 16:22:06272
273 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK,
274 OnMsgSwapBuffersACK)
275 IPC_MESSAGE_UNHANDLED(handled = false)
276
277 IPC_END_MESSAGE_MAP()
278 // FIXME(brettw) handle bad messages!
279 return handled;
280}
281
[email protected]11494c5c2012-11-13 02:50:57282#if !defined(OS_NACL)
lukasza2573ce7d2016-02-16 19:17:22283void PPB_Graphics3D_Proxy::OnMsgCreate(
284 PP_Instance instance,
285 HostResource share_context,
Antoine Labourfeab2392017-12-21 20:28:39286 const gpu::ContextCreationAttribs& attrib_helper,
lukasza2573ce7d2016-02-16 19:17:22287 HostResource* result,
288 gpu::Capabilities* capabilities,
289 SerializedHandle* shared_state,
290 gpu::CommandBufferId* command_buffer_id) {
penghuanga206fb492014-09-09 21:27:32291 shared_state->set_null_shmem();
[email protected]eeb4e4a2011-07-19 16:22:06292
[email protected]5c966022011-09-13 18:09:37293 thunk::EnterResourceCreation enter(instance);
[email protected]9ed07f82012-05-29 21:54:55294
penghuanga206fb492014-09-09 21:27:32295 if (!enter.succeeded())
296 return;
297
erikchena40775d02017-04-29 07:15:49298 base::SharedMemoryHandle handle;
penghuanga206fb492014-09-09 21:27:32299 result->SetHostResource(
pimanfe4e4882016-07-09 01:18:21300 instance, enter.functions()->CreateGraphics3DRaw(
301 instance, share_context.host_resource(), attrib_helper,
302 capabilities, &handle, command_buffer_id));
penghuanga206fb492014-09-09 21:27:32303 if (!result->is_null()) {
304 shared_state->set_shmem(TransportSHMHandle(dispatcher(), handle),
305 sizeof(gpu::CommandBuffer::State));
[email protected]eeb4e4a2011-07-19 16:22:06306 }
307}
308
avie029c4132015-12-23 06:45:22309void PPB_Graphics3D_Proxy::OnMsgSetGetBuffer(const HostResource& context,
310 int32_t transfer_buffer_id) {
[email protected]503b3a22011-12-12 23:29:40311 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
312 if (enter.succeeded())
313 enter.object()->SetGetBuffer(transfer_buffer_id);
[email protected]eeb4e4a2011-07-19 16:22:06314}
315
[email protected]7fe4198b2014-03-18 21:52:36316void PPB_Graphics3D_Proxy::OnMsgWaitForTokenInRange(
317 const HostResource& context,
avie029c4132015-12-23 06:45:22318 int32_t start,
319 int32_t end,
[email protected]7fe4198b2014-03-18 21:52:36320 gpu::CommandBuffer::State* state,
321 bool* success) {
[email protected]eeb4e4a2011-07-19 16:22:06322 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
[email protected]571b35e82012-05-19 00:04:35323 if (enter.failed()) {
324 *success = false;
[email protected]eeb4e4a2011-07-19 16:22:06325 return;
[email protected]571b35e82012-05-19 00:04:35326 }
[email protected]7fe4198b2014-03-18 21:52:36327 *state = enter.object()->WaitForTokenInRange(start, end);
328 *success = true;
329}
330
331void PPB_Graphics3D_Proxy::OnMsgWaitForGetOffsetInRange(
332 const HostResource& context,
Antoine Labourd3469942017-05-16 21:23:42333 uint32_t set_get_buffer_count,
avie029c4132015-12-23 06:45:22334 int32_t start,
335 int32_t end,
[email protected]7fe4198b2014-03-18 21:52:36336 gpu::CommandBuffer::State* state,
337 bool* success) {
338 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
339 if (enter.failed()) {
340 *success = false;
341 return;
342 }
Antoine Labourd3469942017-05-16 21:23:42343 *state =
344 enter.object()->WaitForGetOffsetInRange(set_get_buffer_count, start, end);
[email protected]571b35e82012-05-19 00:04:35345 *success = true;
[email protected]eeb4e4a2011-07-19 16:22:06346}
347
348void PPB_Graphics3D_Proxy::OnMsgAsyncFlush(const HostResource& context,
avie029c4132015-12-23 06:45:22349 int32_t put_offset) {
[email protected]eeb4e4a2011-07-19 16:22:06350 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
351 if (enter.succeeded())
352 enter.object()->Flush(put_offset);
353}
354
355void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer(
356 const HostResource& context,
avie029c4132015-12-23 06:45:22357 uint32_t size,
358 int32_t* id,
penghuanga206fb492014-09-09 21:27:32359 SerializedHandle* transfer_buffer) {
[email protected]046fa1ac2014-04-01 09:06:43360 transfer_buffer->set_null_shmem();
[email protected]eeb4e4a2011-07-19 16:22:06361 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
[email protected]046fa1ac2014-04-01 09:06:43362 if (enter.succeeded()) {
363 scoped_refptr<gpu::Buffer> buffer =
364 enter.object()->CreateTransferBuffer(size, id);
Daniel Cheng6d3ae972014-08-26 00:27:38365 if (!buffer.get())
[email protected]046fa1ac2014-04-01 09:06:43366 return;
[email protected]8a978df2014-04-02 23:54:09367 gpu::SharedMemoryBufferBacking* backing =
368 static_cast<gpu::SharedMemoryBufferBacking*>(buffer->backing());
369 DCHECK(backing && backing->shared_memory());
[email protected]046fa1ac2014-04-01 09:06:43370 transfer_buffer->set_shmem(
penghuanga206fb492014-09-09 21:27:32371 TransportSHMHandle(dispatcher(), backing->shared_memory()->handle()),
brettw669d47b12015-02-13 21:17:38372 base::checked_cast<uint32_t>(buffer->size()));
[email protected]046fa1ac2014-04-01 09:06:43373 } else {
[email protected]67c80782012-12-21 01:16:52374 *id = -1;
[email protected]046fa1ac2014-04-01 09:06:43375 }
[email protected]eeb4e4a2011-07-19 16:22:06376}
377
378void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer(
379 const HostResource& context,
avie029c4132015-12-23 06:45:22380 int32_t id) {
[email protected]eeb4e4a2011-07-19 16:22:06381 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
382 if (enter.succeeded())
383 enter.object()->DestroyTransferBuffer(id);
384}
385
dyenddfdbbb2016-01-14 22:21:38386void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context,
erikchenb13637b2016-07-08 09:38:56387 const gpu::SyncToken& sync_token,
pimanb36392c22016-07-13 02:11:36388 const gfx::Size& size) {
[email protected]79d23c72011-08-08 19:40:40389 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter(
390 context, callback_factory_,
[email protected]eeb4e4a2011-07-19 16:22:06391 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context);
[email protected]eeb4e4a2011-07-19 16:22:06392 if (enter.succeeded())
erikchenb13637b2016-07-08 09:38:56393 enter.SetResult(enter.object()->SwapBuffersWithSyncToken(
pimanb36392c22016-07-13 02:11:36394 enter.callback(), sync_token, size));
[email protected]eeb4e4a2011-07-19 16:22:06395}
[email protected]b096d032013-03-08 03:08:01396
erikchen438b0442016-05-11 18:33:30397void PPB_Graphics3D_Proxy::OnMsgTakeFrontBuffer(const HostResource& context) {
398 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
399 if (enter.succeeded())
400 enter.object()->TakeFrontBuffer();
401}
402
dyen4de3d345f2016-01-12 18:30:42403void PPB_Graphics3D_Proxy::OnMsgEnsureWorkVisible(const HostResource& context) {
404 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
405 if (enter.succeeded())
406 enter.object()->EnsureWorkVisible();
407}
[email protected]11494c5c2012-11-13 02:50:57408#endif // !defined(OS_NACL)
[email protected]eeb4e4a2011-07-19 16:22:06409
410void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource,
411 int32_t pp_error) {
412 EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource);
413 if (enter.succeeded())
414 static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error);
415}
416
[email protected]11494c5c2012-11-13 02:50:57417#if !defined(OS_NACL)
[email protected]eeb4e4a2011-07-19 16:22:06418void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin(
419 int32_t result,
420 const HostResource& context) {
421 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK(
[email protected]ac4b54d2011-10-20 23:09:28422 API_ID_PPB_GRAPHICS_3D, context, result));
[email protected]eeb4e4a2011-07-19 16:22:06423}
[email protected]11494c5c2012-11-13 02:50:57424#endif // !defined(OS_NACL)
[email protected]eeb4e4a2011-07-19 16:22:06425
426} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:02427} // namespace ppapi