| 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_surface_3d_proxy.h" | 5 #include "ppapi/proxy/ppb_surface_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/c/pp_resource.h" | 9 #include "ppapi/c/pp_resource.h" |
| 10 #include "ppapi/c/dev/ppb_surface_3d_dev.h" | 10 #include "ppapi/c/dev/ppb_surface_3d_dev.h" |
| 11 #include "ppapi/proxy/enter_proxy.h" | 11 #include "ppapi/proxy/enter_proxy.h" |
| 12 #include "ppapi/proxy/plugin_dispatcher.h" | 12 #include "ppapi/proxy/plugin_dispatcher.h" |
| 13 #include "ppapi/proxy/ppapi_messages.h" | 13 #include "ppapi/proxy/ppapi_messages.h" |
| 14 #include "ppapi/proxy/ppb_context_3d_proxy.h" | 14 #include "ppapi/proxy/ppb_context_3d_proxy.h" |
| 15 #include "ppapi/thunk/enter.h" | 15 #include "ppapi/thunk/enter.h" |
| 16 #include "ppapi/thunk/resource_creation_api.h" | 16 #include "ppapi/thunk/resource_creation_api.h" |
| 17 #include "ppapi/thunk/thunk.h" | 17 #include "ppapi/thunk/thunk.h" |
| 18 | 18 |
| 19 using ppapi::thunk::EnterFunctionNoLock; | 19 using ppapi::thunk::EnterFunctionNoLock; |
| 20 using ppapi::thunk::PPB_Surface3D_API; | 20 using ppapi::thunk::PPB_Surface3D_API; |
| 21 using ppapi::thunk::ResourceCreationAPI; | 21 using ppapi::thunk::ResourceCreationAPI; |
| 22 | 22 |
| 23 namespace ppapi { | 23 namespace ppapi { |
| 24 namespace proxy { | 24 namespace proxy { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 InterfaceProxy* CreateSurface3DProxy(Dispatcher* dispatcher) { | 28 InterfaceProxy* CreateSurface3DProxy(Dispatcher* dispatcher, |
| 29 return new PPB_Surface3D_Proxy(dispatcher); | 29 const void* target_interface) { |
| 30 return new PPB_Surface3D_Proxy(dispatcher, target_interface); |
| 30 } | 31 } |
| 31 | 32 |
| 32 } // namespace | 33 } // namespace |
| 33 | 34 |
| 34 // Surface3D ------------------------------------------------------------------- | 35 // Surface3D ------------------------------------------------------------------- |
| 35 | 36 |
| 36 Surface3D::Surface3D(const HostResource& host_resource) | 37 Surface3D::Surface3D(const HostResource& host_resource) |
| 37 : Resource(host_resource), | 38 : Resource(host_resource), |
| 38 context_(NULL), | 39 context_(NULL), |
| 39 current_flush_callback_(PP_BlockUntilComplete()) { | 40 current_flush_callback_(PP_BlockUntilComplete()) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 context_->gles2_impl()->SwapBuffers(); | 81 context_->gles2_impl()->SwapBuffers(); |
| 81 return PP_OK_COMPLETIONPENDING; | 82 return PP_OK_COMPLETIONPENDING; |
| 82 } | 83 } |
| 83 | 84 |
| 84 void Surface3D::SwapBuffersACK(int32_t pp_error) { | 85 void Surface3D::SwapBuffersACK(int32_t pp_error) { |
| 85 PP_RunAndClearCompletionCallback(¤t_flush_callback_, pp_error); | 86 PP_RunAndClearCompletionCallback(¤t_flush_callback_, pp_error); |
| 86 } | 87 } |
| 87 | 88 |
| 88 // PPB_Surface3D_Proxy --------------------------------------------------------- | 89 // PPB_Surface3D_Proxy --------------------------------------------------------- |
| 89 | 90 |
| 90 PPB_Surface3D_Proxy::PPB_Surface3D_Proxy(Dispatcher* dispatcher) | 91 PPB_Surface3D_Proxy::PPB_Surface3D_Proxy(Dispatcher* dispatcher, |
| 91 : InterfaceProxy(dispatcher), | 92 const void* target_interface) |
| 93 : InterfaceProxy(dispatcher, target_interface), |
| 92 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 94 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 93 } | 95 } |
| 94 | 96 |
| 95 PPB_Surface3D_Proxy::~PPB_Surface3D_Proxy() { | 97 PPB_Surface3D_Proxy::~PPB_Surface3D_Proxy() { |
| 96 } | 98 } |
| 97 | 99 |
| 98 // static | 100 // static |
| 99 const InterfaceProxy::Info* PPB_Surface3D_Proxy::GetInfo() { | 101 const InterfaceProxy::Info* PPB_Surface3D_Proxy::GetInfo() { |
| 100 static const Info info = { | 102 static const Info info = { |
| 101 thunk::GetPPB_Surface3D_Dev_Thunk(), | 103 thunk::GetPPB_Surface3D_Thunk(), |
| 102 PPB_SURFACE_3D_DEV_INTERFACE, | 104 PPB_SURFACE_3D_DEV_INTERFACE, |
| 103 INTERFACE_ID_PPB_SURFACE_3D, | 105 INTERFACE_ID_PPB_SURFACE_3D, |
| 104 false, | 106 false, |
| 105 &CreateSurface3DProxy, | 107 &CreateSurface3DProxy, |
| 106 }; | 108 }; |
| 107 return &info; | 109 return &info; |
| 108 } | 110 } |
| 109 | 111 |
| 110 // static | 112 // static |
| 111 PP_Resource PPB_Surface3D_Proxy::CreateProxyResource( | 113 PP_Resource PPB_Surface3D_Proxy::CreateProxyResource( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 155 |
| 154 void PPB_Surface3D_Proxy::OnMsgCreate(PP_Instance instance, | 156 void PPB_Surface3D_Proxy::OnMsgCreate(PP_Instance instance, |
| 155 PP_Config3D_Dev config, | 157 PP_Config3D_Dev config, |
| 156 const std::vector<int32_t>& attribs, | 158 const std::vector<int32_t>& attribs, |
| 157 HostResource* result) { | 159 HostResource* result) { |
| 158 if (attribs.empty() || | 160 if (attribs.empty() || |
| 159 attribs.size() % 2 != 1 || | 161 attribs.size() % 2 != 1 || |
| 160 attribs.back() != PP_GRAPHICS3DATTRIB_NONE) | 162 attribs.back() != PP_GRAPHICS3DATTRIB_NONE) |
| 161 return; // Bad message. | 163 return; // Bad message. |
| 162 | 164 |
| 163 thunk::EnterResourceCreation enter(instance); | 165 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); |
| 164 if (enter.succeeded()) { | 166 if (enter.succeeded()) { |
| 165 result->SetHostResource( | 167 result->SetHostResource( |
| 166 instance, | 168 instance, |
| 167 enter.functions()->CreateSurface3D(instance, config, &attribs.front())); | 169 enter.functions()->CreateSurface3D(instance, config, &attribs.front())); |
| 168 } | 170 } |
| 169 } | 171 } |
| 170 | 172 |
| 171 void PPB_Surface3D_Proxy::OnMsgSwapBuffers(const HostResource& surface_3d) { | 173 void PPB_Surface3D_Proxy::OnMsgSwapBuffers(const HostResource& surface_3d) { |
| 172 EnterHostFromHostResourceForceCallback<PPB_Surface3D_API> enter( | 174 EnterHostFromHostResourceForceCallback<PPB_Surface3D_API> enter( |
| 173 surface_3d, callback_factory_, | 175 surface_3d, callback_factory_, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 185 | 187 |
| 186 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( | 188 void PPB_Surface3D_Proxy::SendSwapBuffersACKToPlugin( |
| 187 int32_t result, | 189 int32_t result, |
| 188 const HostResource& surface_3d) { | 190 const HostResource& surface_3d) { |
| 189 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK( | 191 dispatcher()->Send(new PpapiMsg_PPBSurface3D_SwapBuffersACK( |
| 190 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result)); | 192 INTERFACE_ID_PPB_SURFACE_3D, surface_3d, result)); |
| 191 } | 193 } |
| 192 | 194 |
| 193 } // namespace proxy | 195 } // namespace proxy |
| 194 } // namespace ppapi | 196 } // namespace ppapi |
| OLD | NEW |