[email protected] | 4c41d3f | 2012-02-15 01:44:47 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "ppapi/proxy/ppp_graphics_3d_proxy.h" | ||||
6 | |||||
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame] | 7 | #include "build/build_config.h" |
[email protected] | fae0e94 | 2011-09-07 17:10:46 | [diff] [blame] | 8 | #include "ppapi/c/ppp_graphics_3d.h" |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 9 | #include "ppapi/proxy/host_dispatcher.h" |
10 | #include "ppapi/proxy/plugin_dispatcher.h" | ||||
11 | #include "ppapi/proxy/ppapi_messages.h" | ||||
[email protected] | 4c41d3f | 2012-02-15 01:44:47 | [diff] [blame] | 12 | #include "ppapi/shared_impl/proxy_lock.h" |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 13 | |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 14 | namespace ppapi { |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 15 | namespace proxy { |
16 | |||||
17 | namespace { | ||||
18 | |||||
[email protected] | 24d70dea3 | 2012-11-19 22:18:20 | [diff] [blame] | 19 | #if !defined(OS_NACL) |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 20 | void ContextLost(PP_Instance instance) { |
21 | HostDispatcher::GetForInstance(instance)->Send( | ||||
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 22 | new PpapiMsg_PPPGraphics3D_ContextLost(API_ID_PPP_GRAPHICS_3D, instance)); |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 23 | } |
24 | |||||
[email protected] | fae0e94 | 2011-09-07 17:10:46 | [diff] [blame] | 25 | static const PPP_Graphics3D graphics_3d_interface = { |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 26 | &ContextLost |
27 | }; | ||||
[email protected] | 24d70dea3 | 2012-11-19 22:18:20 | [diff] [blame] | 28 | #else |
29 | // The NaCl plugin doesn't need the host side interface - stub it out. | ||||
30 | static const PPP_Graphics3D graphics_3d_interface = {}; | ||||
31 | #endif // !defined(OS_NACL) | ||||
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 32 | |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 33 | } // namespace |
34 | |||||
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 35 | PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher) |
36 | : InterfaceProxy(dispatcher), | ||||
37 | ppp_graphics_3d_impl_(NULL) { | ||||
38 | if (dispatcher->IsPlugin()) { | ||||
39 | ppp_graphics_3d_impl_ = static_cast<const PPP_Graphics3D*>( | ||||
40 | dispatcher->local_get_interface()(PPP_GRAPHICS_3D_INTERFACE)); | ||||
41 | } | ||||
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 42 | } |
43 | |||||
44 | PPP_Graphics3D_Proxy::~PPP_Graphics3D_Proxy() { | ||||
45 | } | ||||
46 | |||||
47 | // static | ||||
[email protected] | 6642ebf | 2013-12-17 20:49:30 | [diff] [blame] | 48 | const PPP_Graphics3D* PPP_Graphics3D_Proxy::GetProxyInterface() { |
49 | return &graphics_3d_interface; | ||||
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 50 | } |
51 | |||||
52 | bool PPP_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { | ||||
[email protected] | d5f5dc1 | 2013-01-22 23:05:03 | [diff] [blame] | 53 | if (!dispatcher()->IsPlugin()) |
54 | return false; | ||||
55 | |||||
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 56 | bool handled = true; |
57 | IPC_BEGIN_MESSAGE_MAP(PPP_Graphics3D_Proxy, msg) | ||||
58 | IPC_MESSAGE_HANDLER(PpapiMsg_PPPGraphics3D_ContextLost, | ||||
59 | OnMsgContextLost) | ||||
60 | IPC_MESSAGE_UNHANDLED(handled = false) | ||||
61 | IPC_END_MESSAGE_MAP() | ||||
62 | return handled; | ||||
63 | } | ||||
64 | |||||
65 | void PPP_Graphics3D_Proxy::OnMsgContextLost(PP_Instance instance) { | ||||
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 66 | if (ppp_graphics_3d_impl_) |
[email protected] | 4c41d3f | 2012-02-15 01:44:47 | [diff] [blame] | 67 | CallWhileUnlocked(ppp_graphics_3d_impl_->Graphics3DContextLost, instance); |
[email protected] | 8c3bd1d | 2011-04-12 20:01:42 | [diff] [blame] | 68 | } |
69 | |||||
70 | } // namespace proxy | ||||
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 71 | } // namespace ppapi |