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