blob: 51b567eb055f3e888f0788e0db3be2a03e77a380 [file] [log] [blame]
[email protected]eeb4e4a2011-07-19 16:22:061// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// 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
7#include "gpu/command_buffer/client/gles2_implementation.h"
8#include "ppapi/c/pp_errors.h"
9#include "ppapi/proxy/enter_proxy.h"
10#include "ppapi/proxy/plugin_dispatcher.h"
11#include "ppapi/proxy/ppapi_messages.h"
12#include "ppapi/thunk/enter.h"
13#include "ppapi/thunk/resource_creation_api.h"
14#include "ppapi/thunk/thunk.h"
15
[email protected]be0a84b2011-08-13 04:18:4416using ppapi::HostResource;
[email protected]eeb4e4a2011-07-19 16:22:0617using ppapi::thunk::EnterFunctionNoLock;
18using ppapi::thunk::EnterResourceNoLock;
19using ppapi::thunk::PPB_Graphics3D_API;
20using ppapi::thunk::ResourceCreationAPI;
21
22namespace pp {
23namespace proxy {
24
25namespace {
26const int32 kCommandBufferSize = 1024 * 1024;
27const int32 kTransferBufferSize = 1024 * 1024;
28
29class CommandBuffer : public gpu::CommandBuffer {
30 public:
31 CommandBuffer(const HostResource& resource, PluginDispatcher* dispatcher);
32 virtual ~CommandBuffer();
33
34 // gpu::CommandBuffer implementation:
35 virtual bool Initialize(int32 size);
36 virtual bool Initialize(base::SharedMemory* buffer, int32 size);
37 virtual gpu::Buffer GetRingBuffer();
38 virtual State GetState();
[email protected]d58730d2011-07-26 00:00:4139 virtual State GetLastState();
[email protected]eeb4e4a2011-07-19 16:22:0640 virtual void Flush(int32 put_offset);
41 virtual State FlushSync(int32 put_offset, int32 last_known_get);
42 virtual void SetGetOffset(int32 get_offset);
43 virtual int32 CreateTransferBuffer(size_t size, int32 id_request);
44 virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory,
45 size_t size,
46 int32 id_request);
47 virtual void DestroyTransferBuffer(int32 id);
48 virtual gpu::Buffer GetTransferBuffer(int32 handle);
49 virtual void SetToken(int32 token);
50 virtual void SetParseError(gpu::error::Error error);
51 virtual void SetContextLostReason(gpu::error::ContextLostReason reason);
52
53 private:
54 bool Send(IPC::Message* msg);
55 void UpdateState(const gpu::CommandBuffer::State& state);
56
57 int32 num_entries_;
58 scoped_ptr<base::SharedMemory> ring_buffer_;
59
60 typedef base::hash_map<int32, gpu::Buffer> TransferBufferMap;
61 TransferBufferMap transfer_buffers_;
62
63 State last_state_;
64
65 HostResource resource_;
66 PluginDispatcher* dispatcher_;
67
68 DISALLOW_COPY_AND_ASSIGN(CommandBuffer);
69};
70
71CommandBuffer::CommandBuffer(const HostResource& resource,
72 PluginDispatcher* dispatcher)
73 : num_entries_(0),
74 resource_(resource),
75 dispatcher_(dispatcher) {
76}
77
78CommandBuffer::~CommandBuffer() {
79 // Delete all the locally cached shared memory objects, closing the handle
80 // in this process.
81 for (TransferBufferMap::iterator it = transfer_buffers_.begin();
82 it != transfer_buffers_.end(); ++it) {
83 delete it->second.shared_memory;
84 it->second.shared_memory = NULL;
85 }
86}
87
88bool CommandBuffer::Initialize(int32 size) {
89 DCHECK(!ring_buffer_.get());
90
91 // Initialize the service. Assuming we are sandboxed, the GPU
92 // process is responsible for duplicating the handle. This might not be true
93 // for NaCl.
94 base::SharedMemoryHandle handle;
95 if (Send(new PpapiHostMsg_PPBGraphics3D_InitCommandBuffer(
96 INTERFACE_ID_PPB_GRAPHICS_3D, resource_, size, &handle)) &&
97 base::SharedMemory::IsHandleValid(handle)) {
98 ring_buffer_.reset(new base::SharedMemory(handle, false));
99 if (ring_buffer_->Map(size)) {
100 num_entries_ = size / sizeof(gpu::CommandBufferEntry);
101 return true;
102 }
103
104 ring_buffer_.reset();
105 }
106
107 return false;
108}
109
110bool CommandBuffer::Initialize(base::SharedMemory* buffer, int32 size) {
111 // Not implemented in proxy.
112 NOTREACHED();
113 return false;
114}
115
116gpu::Buffer CommandBuffer::GetRingBuffer() {
117 // Return locally cached ring buffer.
118 gpu::Buffer buffer;
119 buffer.ptr = ring_buffer_->memory();
120 buffer.size = num_entries_ * sizeof(gpu::CommandBufferEntry);
121 buffer.shared_memory = ring_buffer_.get();
122 return buffer;
123}
124
125gpu::CommandBuffer::State CommandBuffer::GetState() {
126 // Send will flag state with lost context if IPC fails.
127 if (last_state_.error == gpu::error::kNoError) {
128 gpu::CommandBuffer::State state;
129 if (Send(new PpapiHostMsg_PPBGraphics3D_GetState(
130 INTERFACE_ID_PPB_GRAPHICS_3D, resource_, &state)))
131 UpdateState(state);
132 }
133
134 return last_state_;
135}
136
[email protected]d58730d2011-07-26 00:00:41137gpu::CommandBuffer::State CommandBuffer::GetLastState() {
138 return last_state_;
139}
140
[email protected]eeb4e4a2011-07-19 16:22:06141void CommandBuffer::Flush(int32 put_offset) {
142 if (last_state_.error != gpu::error::kNoError)
143 return;
144
145 IPC::Message* message = new PpapiHostMsg_PPBGraphics3D_AsyncFlush(
146 INTERFACE_ID_PPB_GRAPHICS_3D, resource_, put_offset);
147
148 // Do not let a synchronous flush hold up this message. If this handler is
149 // deferred until after the synchronous flush completes, it will overwrite the
150 // cached last_state_ with out-of-date data.
151 message->set_unblock(true);
152 Send(message);
153}
154
155gpu::CommandBuffer::State CommandBuffer::FlushSync(int32 put_offset,
156 int32 last_known_get) {
157 if (last_known_get == last_state_.get_offset) {
158 // Send will flag state with lost context if IPC fails.
159 if (last_state_.error == gpu::error::kNoError) {
160 gpu::CommandBuffer::State state;
161 if (Send(new PpapiHostMsg_PPBGraphics3D_Flush(
162 INTERFACE_ID_PPB_GRAPHICS_3D, resource_, put_offset,
163 last_known_get, &state)))
164 UpdateState(state);
165 }
166 } else {
167 Flush(put_offset);
168 }
169
170 return last_state_;
171}
172
173void CommandBuffer::SetGetOffset(int32 get_offset) {
174 // Not implemented in proxy.
175 NOTREACHED();
176}
177
178int32 CommandBuffer::CreateTransferBuffer(size_t size, int32 id_request) {
179 if (last_state_.error == gpu::error::kNoError) {
180 int32 id;
181 if (Send(new PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer(
182 INTERFACE_ID_PPB_GRAPHICS_3D, resource_, size, &id))) {
183 return id;
184 }
185 }
186
187 return -1;
188}
189
190int32 CommandBuffer::RegisterTransferBuffer(
191 base::SharedMemory* shared_memory,
192 size_t size,
193 int32 id_request) {
194 // Not implemented in proxy.
195 NOTREACHED();
196 return -1;
197}
198
199void CommandBuffer::DestroyTransferBuffer(int32 id) {
200 if (last_state_.error != gpu::error::kNoError)
201 return;
202
203 // Remove the transfer buffer from the client side4 cache.
204 TransferBufferMap::iterator it = transfer_buffers_.find(id);
205 DCHECK(it != transfer_buffers_.end());
206
207 // Delete the shared memory object, closing the handle in this process.
208 delete it->second.shared_memory;
209
210 transfer_buffers_.erase(it);
211
212 Send(new PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer(
213 INTERFACE_ID_PPB_GRAPHICS_3D, resource_, id));
214}
215
216gpu::Buffer CommandBuffer::GetTransferBuffer(int32 id) {
217 if (last_state_.error != gpu::error::kNoError)
218 return gpu::Buffer();
219
220 // Check local cache to see if there is already a client side shared memory
221 // object for this id.
222 TransferBufferMap::iterator it = transfer_buffers_.find(id);
223 if (it != transfer_buffers_.end()) {
224 return it->second;
225 }
226
227 // Assuming we are in the renderer process, the service is responsible for
228 // duplicating the handle. This might not be true for NaCl.
229 base::SharedMemoryHandle handle;
230 uint32 size;
231 if (!Send(new PpapiHostMsg_PPBGraphics3D_GetTransferBuffer(
232 INTERFACE_ID_PPB_GRAPHICS_3D, resource_, id, &handle, &size))) {
233 return gpu::Buffer();
234 }
235
236 // Cache the transfer buffer shared memory object client side.
237 scoped_ptr<base::SharedMemory> shared_memory(
238 new base::SharedMemory(handle, false));
239
240 // Map the shared memory on demand.
241 if (!shared_memory->memory()) {
242 if (!shared_memory->Map(size)) {
243 return gpu::Buffer();
244 }
245 }
246
247 gpu::Buffer buffer;
248 buffer.ptr = shared_memory->memory();
249 buffer.size = size;
250 buffer.shared_memory = shared_memory.release();
251 transfer_buffers_[id] = buffer;
252
253 return buffer;
254}
255
256void CommandBuffer::SetToken(int32 token) {
257 NOTREACHED();
258}
259
260void CommandBuffer::SetParseError(gpu::error::Error error) {
261 NOTREACHED();
262}
263
264void CommandBuffer::SetContextLostReason(
265 gpu::error::ContextLostReason reason) {
266 NOTREACHED();
267}
268
269bool CommandBuffer::Send(IPC::Message* msg) {
270 DCHECK(last_state_.error == gpu::error::kNoError);
271
272 if (dispatcher_->Send(msg))
273 return true;
274
275 last_state_.error = gpu::error::kLostContext;
276 return false;
277}
278
279void CommandBuffer::UpdateState(const gpu::CommandBuffer::State& state) {
280 // Handle wraparound. It works as long as we don't have more than 2B state
281 // updates in flight across which reordering occurs.
282 if (state.generation - last_state_.generation < 0x80000000U)
283 last_state_ = state;
284}
285
286base::SharedMemoryHandle TransportSHMHandleFromInt(Dispatcher* dispatcher,
287 int shm_handle) {
288 // TODO(piman): Change trusted interface to return a PP_FileHandle, those
289 // casts are ugly.
290 base::PlatformFile source =
291#if defined(OS_WIN)
292 reinterpret_cast<HANDLE>(static_cast<intptr_t>(shm_handle));
293#elif defined(OS_POSIX)
294 shm_handle;
295#else
296 #error Not implemented.
297#endif
298 // Don't close the handle, it doesn't belong to us.
299 return dispatcher->ShareHandleWithRemote(source, false);
300}
301
302PP_Graphics3DTrustedState GetErrorState() {
303 PP_Graphics3DTrustedState error_state = { 0 };
304 error_state.error = PPB_GRAPHICS3D_TRUSTED_ERROR_GENERICERROR;
305 return error_state;
306}
307
308gpu::CommandBuffer::State GPUStateFromPPState(
309 const PP_Graphics3DTrustedState& s) {
310 gpu::CommandBuffer::State state;
311 state.num_entries = s.num_entries;
312 state.get_offset = s.get_offset;
313 state.put_offset = s.put_offset;
314 state.token = s.token;
315 state.error = static_cast<gpu::error::Error>(s.error);
316 state.generation = s.generation;
317 return state;
318}
319
320InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher,
321 const void* target_interface) {
322 return new PPB_Graphics3D_Proxy(dispatcher, target_interface);
323}
324} // namespace
325
326Graphics3D::Graphics3D(const HostResource& resource)
327 : PluginResource(resource) {
328}
329
330Graphics3D::~Graphics3D() {
331 DestroyGLES2Impl();
332}
333
334bool Graphics3D::Init() {
335 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance());
336 if (!dispatcher)
337 return false;
338
339 command_buffer_.reset(new CommandBuffer(host_resource(), dispatcher));
[email protected]0e50fc4d2011-08-01 15:33:51340 if (!command_buffer_->Initialize(kCommandBufferSize))
341 return false;
[email protected]eeb4e4a2011-07-19 16:22:06342
343 return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize);
344}
345
346PP_Bool Graphics3D::InitCommandBuffer(int32_t size) {
347 return PP_FALSE;
348}
349
350PP_Bool Graphics3D::GetRingBuffer(int* shm_handle, uint32_t* shm_size) {
351 return PP_FALSE;
352}
353
354PP_Graphics3DTrustedState Graphics3D::GetState() {
355 return GetErrorState();
356}
357
358PP_Bool Graphics3D::Flush(int32_t put_offset) {
359 return PP_FALSE;
360}
361
362PP_Graphics3DTrustedState Graphics3D::FlushSync(int32_t put_offset) {
363 return GetErrorState();
364}
365
366int32_t Graphics3D::CreateTransferBuffer(uint32_t size) {
367 return PP_FALSE;
368}
369
370PP_Bool Graphics3D::DestroyTransferBuffer(int32_t id) {
371 return PP_FALSE;
372}
373
374PP_Bool Graphics3D::GetTransferBuffer(int32_t id,
375 int* shm_handle,
376 uint32_t* shm_size) {
377 return PP_FALSE;
378}
379
380PP_Graphics3DTrustedState Graphics3D::FlushSyncFast(int32_t put_offset,
381 int32_t last_known_get) {
382 return GetErrorState();
383}
384
385gpu::CommandBuffer* Graphics3D::GetCommandBuffer() {
386 return command_buffer_.get();
387}
388
389int32 Graphics3D::DoSwapBuffers() {
390 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers(
391 INTERFACE_ID_PPB_GRAPHICS_3D, host_resource());
392 msg->set_unblock(true);
393 GetDispatcher()->Send(msg);
394
395 gles2_impl()->SwapBuffers();
396 return PP_OK_COMPLETIONPENDING;
397}
398
399PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher,
400 const void* target_interface)
[email protected]0e50fc4d2011-08-01 15:33:51401 : InterfaceProxy(dispatcher, target_interface),
402 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
[email protected]eeb4e4a2011-07-19 16:22:06403}
404
405PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() {
406}
407
408// static
409const InterfaceProxy::Info* PPB_Graphics3D_Proxy::GetInfo() {
410 static const Info info = {
411 ::ppapi::thunk::GetPPB_Graphics3D_Thunk(),
412 PPB_GRAPHICS_3D_DEV_INTERFACE,
413 INTERFACE_ID_PPB_GRAPHICS_3D,
414 false,
415 &CreateGraphics3DProxy,
416 };
417 return &info;
418}
419
420// static
421PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource(
422 PP_Instance instance,
[email protected]eeb4e4a2011-07-19 16:22:06423 PP_Resource share_context,
424 const int32_t* attrib_list) {
425 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
426 if (!dispatcher)
427 return PP_ERROR_BADARGUMENT;
428
429 // TODO(alokp): Support shared context.
430 DCHECK_EQ(0, share_context);
431 if (share_context != 0)
432 return 0;
433
434 std::vector<int32_t> attribs;
435 if (attrib_list) {
436 for (const int32_t* attr = attrib_list;
[email protected]0e50fc4d2011-08-01 15:33:51437 attr[0] != PP_GRAPHICS3DATTRIB_NONE;
438 attr += 2) {
439 attribs.push_back(attr[0]);
440 attribs.push_back(attr[1]);
[email protected]eeb4e4a2011-07-19 16:22:06441 }
[email protected]eeb4e4a2011-07-19 16:22:06442 }
[email protected]0e50fc4d2011-08-01 15:33:51443 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
[email protected]eeb4e4a2011-07-19 16:22:06444
445 HostResource result;
446 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create(
[email protected]9d8fe822011-08-16 21:02:52447 INTERFACE_ID_PPB_GRAPHICS_3D, instance, attribs, &result));
[email protected]eeb4e4a2011-07-19 16:22:06448 if (result.is_null())
449 return 0;
450
[email protected]51e1aec2011-08-11 04:48:30451 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result));
[email protected]eeb4e4a2011-07-19 16:22:06452 if (!graphics_3d->Init())
453 return 0;
454
455 return PluginResourceTracker::GetInstance()->AddResource(graphics_3d);
456}
457
458bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
459 bool handled = true;
460 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics3D_Proxy, msg)
461 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Create,
462 OnMsgCreate)
463 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer,
464 OnMsgInitCommandBuffer)
465 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetState,
466 OnMsgGetState)
467 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Flush,
468 OnMsgFlush)
469 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_AsyncFlush,
470 OnMsgAsyncFlush)
471 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_CreateTransferBuffer,
472 OnMsgCreateTransferBuffer)
473 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_DestroyTransferBuffer,
474 OnMsgDestroyTransferBuffer)
475 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetTransferBuffer,
476 OnMsgGetTransferBuffer)
477 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SwapBuffers,
478 OnMsgSwapBuffers)
479
480 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK,
481 OnMsgSwapBuffersACK)
482 IPC_MESSAGE_UNHANDLED(handled = false)
483
484 IPC_END_MESSAGE_MAP()
485 // FIXME(brettw) handle bad messages!
486 return handled;
487}
488
489void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance,
[email protected]eeb4e4a2011-07-19 16:22:06490 const std::vector<int32_t>& attribs,
491 HostResource* result) {
[email protected]0e50fc4d2011-08-01 15:33:51492 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE)
[email protected]eeb4e4a2011-07-19 16:22:06493 return; // Bad message.
494
495 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true);
496 if (enter.succeeded()) {
497 result->SetHostResource(
498 instance,
[email protected]9d8fe822011-08-16 21:02:52499 enter.functions()->CreateGraphics3DRaw(instance, 0, &attribs.front()));
[email protected]eeb4e4a2011-07-19 16:22:06500 }
501}
502
503void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer(
504 const HostResource& context,
505 int32 size,
506 base::SharedMemoryHandle* ring_buffer) {
507 *ring_buffer = base::SharedMemory::NULLHandle();
508 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
509 if (enter.failed())
510 return;
511
512 if (!enter.object()->InitCommandBuffer(size))
513 return;
514
515 int shm_handle;
516 uint32_t shm_size;
517 if (!enter.object()->GetRingBuffer(&shm_handle, &shm_size))
518 return;
519 *ring_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle);
520}
521
522void PPB_Graphics3D_Proxy::OnMsgGetState(const HostResource& context,
523 gpu::CommandBuffer::State* state) {
524 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
525 if (enter.failed())
526 return;
527 PP_Graphics3DTrustedState pp_state = enter.object()->GetState();
528 *state = GPUStateFromPPState(pp_state);
529}
530
531void PPB_Graphics3D_Proxy::OnMsgFlush(const HostResource& context,
532 int32 put_offset,
533 int32 last_known_get,
534 gpu::CommandBuffer::State* state) {
535 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
536 if (enter.failed())
537 return;
538 PP_Graphics3DTrustedState pp_state = enter.object()->FlushSyncFast(
539 put_offset, last_known_get);
540 *state = GPUStateFromPPState(pp_state);
541}
542
543void PPB_Graphics3D_Proxy::OnMsgAsyncFlush(const HostResource& context,
544 int32 put_offset) {
545 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
546 if (enter.succeeded())
547 enter.object()->Flush(put_offset);
548}
549
550void PPB_Graphics3D_Proxy::OnMsgCreateTransferBuffer(
551 const HostResource& context,
552 int32 size,
553 int32* id) {
554 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
555 if (enter.succeeded())
556 *id = enter.object()->CreateTransferBuffer(size);
557 else
558 *id = 0;
559}
560
561void PPB_Graphics3D_Proxy::OnMsgDestroyTransferBuffer(
562 const HostResource& context,
563 int32 id) {
564 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
565 if (enter.succeeded())
566 enter.object()->DestroyTransferBuffer(id);
567}
568
569void PPB_Graphics3D_Proxy::OnMsgGetTransferBuffer(
570 const HostResource& context,
571 int32 id,
572 base::SharedMemoryHandle* transfer_buffer,
573 uint32* size) {
574 *transfer_buffer = base::SharedMemory::NULLHandle();
575 *size = 0;
576
577 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
578 int shm_handle = 0;
579 uint32_t shm_size = 0;
580 if (enter.succeeded() &&
581 enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) {
582 *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle);
583 *size = shm_size;
584 }
585}
586
587void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) {
[email protected]79d23c72011-08-08 19:40:40588 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter(
589 context, callback_factory_,
[email protected]eeb4e4a2011-07-19 16:22:06590 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context);
[email protected]eeb4e4a2011-07-19 16:22:06591 if (enter.succeeded())
[email protected]79d23c72011-08-08 19:40:40592 enter.SetResult(enter.object()->SwapBuffers(enter.callback()));
[email protected]eeb4e4a2011-07-19 16:22:06593}
594
595void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource,
596 int32_t pp_error) {
597 EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource);
598 if (enter.succeeded())
599 static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error);
600}
601
602void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin(
603 int32_t result,
604 const HostResource& context) {
605 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK(
606 INTERFACE_ID_PPB_GRAPHICS_3D, context, result));
607}
608
609} // namespace proxy
610} // namespace pp
611