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