OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 : InterfaceProxy(dispatcher), | 139 : InterfaceProxy(dispatcher), |
140 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 140 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
141 } | 141 } |
142 | 142 |
143 PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() { | 143 PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() { |
144 } | 144 } |
145 | 145 |
146 // static | 146 // static |
147 PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( | 147 PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( |
148 PP_Instance instance, | 148 PP_Instance instance, |
149 PP_Resource share_context, | 149 PPB_Graphics3D_API* share_context, |
150 const int32_t* attrib_list) { | 150 const int32_t* attrib_list) { |
151 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 151 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
152 if (!dispatcher) | 152 if (!dispatcher) |
153 return PP_ERROR_BADARGUMENT; | 153 return PP_ERROR_BADARGUMENT; |
154 | 154 |
155 // TODO(alokp): Support shared context. | |
156 DCHECK_EQ(0, share_context); | |
157 if (share_context != 0) | |
158 return 0; | |
159 | |
160 std::vector<int32_t> attribs; | 155 std::vector<int32_t> attribs; |
161 if (attrib_list) { | 156 if (attrib_list) { |
162 for (const int32_t* attr = attrib_list; | 157 for (const int32_t* attr = attrib_list; |
163 attr[0] != PP_GRAPHICS3DATTRIB_NONE; | 158 attr[0] != PP_GRAPHICS3DATTRIB_NONE; |
164 attr += 2) { | 159 attr += 2) { |
165 attribs.push_back(attr[0]); | 160 attribs.push_back(attr[0]); |
166 attribs.push_back(attr[1]); | 161 attribs.push_back(attr[1]); |
167 } | 162 } |
168 } | 163 } |
169 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); | 164 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); |
170 | 165 |
| 166 HostResource share_host; |
| 167 if (share_context) |
| 168 share_host = static_cast<Graphics3D*>(share_context)->host_resource(); |
| 169 |
171 HostResource result; | 170 HostResource result; |
172 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( | 171 dispatcher->Send(new PpapiHostMsg_PPBGraphics3D_Create( |
173 API_ID_PPB_GRAPHICS_3D, instance, attribs, &result)); | 172 API_ID_PPB_GRAPHICS_3D, instance, share_host, attribs, &result)); |
174 if (result.is_null()) | 173 if (result.is_null()) |
175 return 0; | 174 return 0; |
176 | 175 |
177 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); | 176 scoped_refptr<Graphics3D> graphics_3d(new Graphics3D(result)); |
178 if (!graphics_3d->Init()) | 177 if (!graphics_3d->Init()) |
179 return 0; | 178 return 0; |
180 return graphics_3d->GetReference(); | 179 return graphics_3d->GetReference(); |
181 } | 180 } |
182 | 181 |
183 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { | 182 bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
(...skipping 23 matching lines...) Expand all Loading... |
207 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, | 206 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics3D_SwapBuffersACK, |
208 OnMsgSwapBuffersACK) | 207 OnMsgSwapBuffersACK) |
209 IPC_MESSAGE_UNHANDLED(handled = false) | 208 IPC_MESSAGE_UNHANDLED(handled = false) |
210 | 209 |
211 IPC_END_MESSAGE_MAP() | 210 IPC_END_MESSAGE_MAP() |
212 // FIXME(brettw) handle bad messages! | 211 // FIXME(brettw) handle bad messages! |
213 return handled; | 212 return handled; |
214 } | 213 } |
215 | 214 |
216 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, | 215 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, |
| 216 HostResource share_context, |
217 const std::vector<int32_t>& attribs, | 217 const std::vector<int32_t>& attribs, |
218 HostResource* result) { | 218 HostResource* result) { |
219 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) | 219 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) |
220 return; // Bad message. | 220 return; // Bad message. |
221 | 221 |
222 thunk::EnterResourceCreation enter(instance); | 222 thunk::EnterResourceCreation enter(instance); |
| 223 PPB_Graphics3D_API *share_api = NULL; |
| 224 if (share_context.host_resource() != 0) { |
| 225 thunk::EnterResource<thunk::PPB_Graphics3D_API> |
| 226 enter_share(share_context.host_resource(), true); |
| 227 if (!enter_share.succeeded()) |
| 228 return; |
| 229 share_api = enter_share.object(); |
| 230 } |
| 231 |
223 if (enter.succeeded()) { | 232 if (enter.succeeded()) { |
224 result->SetHostResource( | 233 result->SetHostResource( |
225 instance, | 234 instance, |
226 enter.functions()->CreateGraphics3DRaw(instance, 0, &attribs.front())); | 235 enter.functions()->CreateGraphics3DRaw(instance, |
| 236 share_api, |
| 237 &attribs.front())); |
227 } | 238 } |
228 } | 239 } |
229 | 240 |
230 void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer( | 241 void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer( |
231 const HostResource& context) { | 242 const HostResource& context) { |
232 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); | 243 EnterHostFromHostResource<PPB_Graphics3D_API> enter(context); |
233 if (enter.failed()) | 244 if (enter.failed()) |
234 return; | 245 return; |
235 | 246 |
236 if (!enter.object()->InitCommandBuffer()) | 247 if (!enter.object()->InitCommandBuffer()) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 347 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
337 int32_t result, | 348 int32_t result, |
338 const HostResource& context) { | 349 const HostResource& context) { |
339 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 350 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
340 API_ID_PPB_GRAPHICS_3D, context, result)); | 351 API_ID_PPB_GRAPHICS_3D, context, result)); |
341 } | 352 } |
342 | 353 |
343 } // namespace proxy | 354 } // namespace proxy |
344 } // namespace ppapi | 355 } // namespace ppapi |
345 | 356 |
OLD | NEW |