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/ppp_graphics_3d_proxy.h" | 5 #include "ppapi/proxy/ppp_graphics_3d_proxy.h" |
6 | 6 |
7 #include "ppapi/c/ppp_graphics_3d.h" | 7 #include "ppapi/c/ppp_graphics_3d.h" |
8 #include "ppapi/proxy/host_dispatcher.h" | 8 #include "ppapi/proxy/host_dispatcher.h" |
9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 } | 22 } |
23 | 23 |
24 static const PPP_Graphics3D graphics_3d_interface = { | 24 static const PPP_Graphics3D graphics_3d_interface = { |
25 &ContextLost | 25 &ContextLost |
26 }; | 26 }; |
27 #else | 27 #else |
28 // The NaCl plugin doesn't need the host side interface - stub it out. | 28 // The NaCl plugin doesn't need the host side interface - stub it out. |
29 static const PPP_Graphics3D graphics_3d_interface = {}; | 29 static const PPP_Graphics3D graphics_3d_interface = {}; |
30 #endif // !defined(OS_NACL) | 30 #endif // !defined(OS_NACL) |
31 | 31 |
32 InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher) { | |
33 return new PPP_Graphics3D_Proxy(dispatcher); | |
34 } | |
35 | |
36 } // namespace | 32 } // namespace |
37 | 33 |
38 PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher) | 34 PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher) |
39 : InterfaceProxy(dispatcher), | 35 : InterfaceProxy(dispatcher), |
40 ppp_graphics_3d_impl_(NULL) { | 36 ppp_graphics_3d_impl_(NULL) { |
41 if (dispatcher->IsPlugin()) { | 37 if (dispatcher->IsPlugin()) { |
42 ppp_graphics_3d_impl_ = static_cast<const PPP_Graphics3D*>( | 38 ppp_graphics_3d_impl_ = static_cast<const PPP_Graphics3D*>( |
43 dispatcher->local_get_interface()(PPP_GRAPHICS_3D_INTERFACE)); | 39 dispatcher->local_get_interface()(PPP_GRAPHICS_3D_INTERFACE)); |
44 } | 40 } |
45 } | 41 } |
46 | 42 |
47 PPP_Graphics3D_Proxy::~PPP_Graphics3D_Proxy() { | 43 PPP_Graphics3D_Proxy::~PPP_Graphics3D_Proxy() { |
48 } | 44 } |
49 | 45 |
50 // static | 46 // static |
51 const InterfaceProxy::Info* PPP_Graphics3D_Proxy::GetInfo() { | 47 const PPP_Graphics3D* PPP_Graphics3D_Proxy::GetProxyInterface() { |
52 static const Info info = { | 48 return &graphics_3d_interface; |
53 &graphics_3d_interface, | |
54 PPP_GRAPHICS_3D_INTERFACE, | |
55 API_ID_PPP_GRAPHICS_3D, | |
56 false, | |
57 &CreateGraphics3DProxy, | |
58 }; | |
59 return &info; | |
60 } | 49 } |
61 | 50 |
62 bool PPP_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { | 51 bool PPP_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
63 if (!dispatcher()->IsPlugin()) | 52 if (!dispatcher()->IsPlugin()) |
64 return false; | 53 return false; |
65 | 54 |
66 bool handled = true; | 55 bool handled = true; |
67 IPC_BEGIN_MESSAGE_MAP(PPP_Graphics3D_Proxy, msg) | 56 IPC_BEGIN_MESSAGE_MAP(PPP_Graphics3D_Proxy, msg) |
68 IPC_MESSAGE_HANDLER(PpapiMsg_PPPGraphics3D_ContextLost, | 57 IPC_MESSAGE_HANDLER(PpapiMsg_PPPGraphics3D_ContextLost, |
69 OnMsgContextLost) | 58 OnMsgContextLost) |
70 IPC_MESSAGE_UNHANDLED(handled = false) | 59 IPC_MESSAGE_UNHANDLED(handled = false) |
71 IPC_END_MESSAGE_MAP() | 60 IPC_END_MESSAGE_MAP() |
72 return handled; | 61 return handled; |
73 } | 62 } |
74 | 63 |
75 void PPP_Graphics3D_Proxy::OnMsgContextLost(PP_Instance instance) { | 64 void PPP_Graphics3D_Proxy::OnMsgContextLost(PP_Instance instance) { |
76 if (ppp_graphics_3d_impl_) | 65 if (ppp_graphics_3d_impl_) |
77 CallWhileUnlocked(ppp_graphics_3d_impl_->Graphics3DContextLost, instance); | 66 CallWhileUnlocked(ppp_graphics_3d_impl_->Graphics3DContextLost, instance); |
78 } | 67 } |
79 | 68 |
80 } // namespace proxy | 69 } // namespace proxy |
81 } // namespace ppapi | 70 } // namespace ppapi |
OLD | NEW |