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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 gpu::CommandBuffer::State state; | 309 gpu::CommandBuffer::State state; |
310 state.num_entries = s.num_entries; | 310 state.num_entries = s.num_entries; |
311 state.get_offset = s.get_offset; | 311 state.get_offset = s.get_offset; |
312 state.put_offset = s.put_offset; | 312 state.put_offset = s.put_offset; |
313 state.token = s.token; | 313 state.token = s.token; |
314 state.error = static_cast<gpu::error::Error>(s.error); | 314 state.error = static_cast<gpu::error::Error>(s.error); |
315 state.generation = s.generation; | 315 state.generation = s.generation; |
316 return state; | 316 return state; |
317 } | 317 } |
318 | 318 |
| 319 InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher, |
| 320 const void* target_interface) { |
| 321 return new PPB_Graphics3D_Proxy(dispatcher, target_interface); |
| 322 } |
319 } // namespace | 323 } // namespace |
320 | 324 |
321 Graphics3D::Graphics3D(const HostResource& resource) | 325 Graphics3D::Graphics3D(const HostResource& resource) |
322 : Resource(resource) { | 326 : Resource(resource) { |
323 } | 327 } |
324 | 328 |
325 Graphics3D::~Graphics3D() { | 329 Graphics3D::~Graphics3D() { |
326 DestroyGLES2Impl(); | 330 DestroyGLES2Impl(); |
327 } | 331 } |
328 | 332 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 int32 Graphics3D::DoSwapBuffers() { | 388 int32 Graphics3D::DoSwapBuffers() { |
385 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( | 389 IPC::Message* msg = new PpapiHostMsg_PPBGraphics3D_SwapBuffers( |
386 INTERFACE_ID_PPB_GRAPHICS_3D, host_resource()); | 390 INTERFACE_ID_PPB_GRAPHICS_3D, host_resource()); |
387 msg->set_unblock(true); | 391 msg->set_unblock(true); |
388 PluginDispatcher::GetForResource(this)->Send(msg); | 392 PluginDispatcher::GetForResource(this)->Send(msg); |
389 | 393 |
390 gles2_impl()->SwapBuffers(); | 394 gles2_impl()->SwapBuffers(); |
391 return PP_OK_COMPLETIONPENDING; | 395 return PP_OK_COMPLETIONPENDING; |
392 } | 396 } |
393 | 397 |
394 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher) | 398 PPB_Graphics3D_Proxy::PPB_Graphics3D_Proxy(Dispatcher* dispatcher, |
395 : InterfaceProxy(dispatcher), | 399 const void* target_interface) |
| 400 : InterfaceProxy(dispatcher, target_interface), |
396 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 401 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
397 } | 402 } |
398 | 403 |
399 PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() { | 404 PPB_Graphics3D_Proxy::~PPB_Graphics3D_Proxy() { |
400 } | 405 } |
401 | 406 |
402 // static | 407 // static |
| 408 const InterfaceProxy::Info* PPB_Graphics3D_Proxy::GetInfo() { |
| 409 static const Info info = { |
| 410 thunk::GetPPB_Graphics3D_Thunk(), |
| 411 PPB_GRAPHICS_3D_INTERFACE, |
| 412 INTERFACE_ID_PPB_GRAPHICS_3D, |
| 413 false, |
| 414 &CreateGraphics3DProxy, |
| 415 }; |
| 416 return &info; |
| 417 } |
| 418 |
| 419 // static |
403 PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( | 420 PP_Resource PPB_Graphics3D_Proxy::CreateProxyResource( |
404 PP_Instance instance, | 421 PP_Instance instance, |
405 PP_Resource share_context, | 422 PP_Resource share_context, |
406 const int32_t* attrib_list) { | 423 const int32_t* attrib_list) { |
407 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 424 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
408 if (!dispatcher) | 425 if (!dispatcher) |
409 return PP_ERROR_BADARGUMENT; | 426 return PP_ERROR_BADARGUMENT; |
410 | 427 |
411 // TODO(alokp): Support shared context. | 428 // TODO(alokp): Support shared context. |
412 DCHECK_EQ(0, share_context); | 429 DCHECK_EQ(0, share_context); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 // FIXME(brettw) handle bad messages! | 483 // FIXME(brettw) handle bad messages! |
467 return handled; | 484 return handled; |
468 } | 485 } |
469 | 486 |
470 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, | 487 void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance, |
471 const std::vector<int32_t>& attribs, | 488 const std::vector<int32_t>& attribs, |
472 HostResource* result) { | 489 HostResource* result) { |
473 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) | 490 if (attribs.empty() || attribs.back() != PP_GRAPHICS3DATTRIB_NONE) |
474 return; // Bad message. | 491 return; // Bad message. |
475 | 492 |
476 thunk::EnterResourceCreation enter(instance); | 493 EnterFunctionNoLock<ResourceCreationAPI> enter(instance, true); |
477 if (enter.succeeded()) { | 494 if (enter.succeeded()) { |
478 result->SetHostResource( | 495 result->SetHostResource( |
479 instance, | 496 instance, |
480 enter.functions()->CreateGraphics3DRaw(instance, 0, &attribs.front())); | 497 enter.functions()->CreateGraphics3DRaw(instance, 0, &attribs.front())); |
481 } | 498 } |
482 } | 499 } |
483 | 500 |
484 void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer( | 501 void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer( |
485 const HostResource& context, | 502 const HostResource& context, |
486 int32 size, | 503 int32 size, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( | 600 void PPB_Graphics3D_Proxy::SendSwapBuffersACKToPlugin( |
584 int32_t result, | 601 int32_t result, |
585 const HostResource& context) { | 602 const HostResource& context) { |
586 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( | 603 dispatcher()->Send(new PpapiMsg_PPBGraphics3D_SwapBuffersACK( |
587 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); | 604 INTERFACE_ID_PPB_GRAPHICS_3D, context, result)); |
588 } | 605 } |
589 | 606 |
590 } // namespace proxy | 607 } // namespace proxy |
591 } // namespace ppapi | 608 } // namespace ppapi |
592 | 609 |
OLD | NEW |