OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // 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 | 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 "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/proxy/enter_proxy.h" | 9 #include "ppapi/proxy/enter_proxy.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 int shm_handle = 0; | 580 int shm_handle = 0; |
581 uint32_t shm_size = 0; | 581 uint32_t shm_size = 0; |
582 if (enter.succeeded() && | 582 if (enter.succeeded() && |
583 enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) { | 583 enter.object()->GetTransferBuffer(id, &shm_handle, &shm_size)) { |
584 *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); | 584 *transfer_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle); |
585 *size = shm_size; | 585 *size = shm_size; |
586 } | 586 } |
587 } | 587 } |
588 | 588 |
589 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { | 589 void PPB_Graphics3D_Proxy::OnMsgSwapBuffers(const HostResource& context) { |
590 CompletionCallback callback = callback_factory_.NewOptionalCallback( | 590 EnterHostFromHostResourceForceCallback<PPB_Graphics3D_API> enter( |
| 591 context, callback_factory_, |
591 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); | 592 &PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin, context); |
592 | |
593 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); | |
594 int32_t result = PP_ERROR_BADRESOURCE; | |
595 if (enter.succeeded()) | 593 if (enter.succeeded()) |
596 result = enter.object()->SwapBuffers(callback.pp_completion_callback()); | 594 enter.SetResult(enter.object()->SwapBuffers(enter.callback())); |
597 if (result != PP_OK_COMPLETIONPENDING) { | |
598 // There was some error, so we won't get a flush callback. We need to now | |
599 // issue the ACK to the plugin hears about the error. This will also clean | |
600 // up the data associated with the callback. | |
601 callback.Run(result); | |
602 } | |
603 } | 595 } |
604 | 596 |
605 void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, | 597 void PPB_Graphics3D_Proxy::OnMsgSwapBuffersACK(const HostResource& resource, |
606 int32_t pp_error) { | 598 int32_t pp_error) { |
607 EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource); | 599 EnterPluginFromHostResource<PPB_Graphics3D_API> enter(resource); |
608 if (enter.succeeded()) | 600 if (enter.succeeded()) |
609 static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error); | 601 static_cast<Graphics3D*>(enter.object())->SwapBuffersACK(pp_error); |
610 } | 602 } |
611 | 603 |
612 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 604 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
613 int32_t result, | 605 int32_t result, |
614 const HostResource& context) { | 606 const HostResource& context) { |
615 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 607 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
616 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); | 608 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); |
617 } | 609 } |
618 | 610 |
619 } // namespace proxy | 611 } // namespace proxy |
620 } // namespace pp | 612 } // namespace pp |
621 | 613 |
OLD | NEW |