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/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" |
11 | 11 |
12 namespace ppapi { | 12 namespace ppapi { |
13 namespace proxy { | 13 namespace proxy { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 void ContextLost(PP_Instance instance) { | 17 void ContextLost(PP_Instance instance) { |
18 HostDispatcher::GetForInstance(instance)->Send( | 18 HostDispatcher::GetForInstance(instance)->Send( |
19 new PpapiMsg_PPPGraphics3D_ContextLost(INTERFACE_ID_PPP_GRAPHICS_3D, | 19 new PpapiMsg_PPPGraphics3D_ContextLost(API_ID_PPP_GRAPHICS_3D, instance)); |
20 instance)); | |
21 } | 20 } |
22 | 21 |
23 static const PPP_Graphics3D graphics_3d_interface = { | 22 static const PPP_Graphics3D graphics_3d_interface = { |
24 &ContextLost | 23 &ContextLost |
25 }; | 24 }; |
26 | 25 |
27 InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher) { | 26 InterfaceProxy* CreateGraphics3DProxy(Dispatcher* dispatcher) { |
28 return new PPP_Graphics3D_Proxy(dispatcher); | 27 return new PPP_Graphics3D_Proxy(dispatcher); |
29 } | 28 } |
30 | 29 |
31 } // namespace | 30 } // namespace |
32 | 31 |
33 PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher) | 32 PPP_Graphics3D_Proxy::PPP_Graphics3D_Proxy(Dispatcher* dispatcher) |
34 : InterfaceProxy(dispatcher), | 33 : InterfaceProxy(dispatcher), |
35 ppp_graphics_3d_impl_(NULL) { | 34 ppp_graphics_3d_impl_(NULL) { |
36 if (dispatcher->IsPlugin()) { | 35 if (dispatcher->IsPlugin()) { |
37 ppp_graphics_3d_impl_ = static_cast<const PPP_Graphics3D*>( | 36 ppp_graphics_3d_impl_ = static_cast<const PPP_Graphics3D*>( |
38 dispatcher->local_get_interface()(PPP_GRAPHICS_3D_INTERFACE)); | 37 dispatcher->local_get_interface()(PPP_GRAPHICS_3D_INTERFACE)); |
39 } | 38 } |
40 } | 39 } |
41 | 40 |
42 PPP_Graphics3D_Proxy::~PPP_Graphics3D_Proxy() { | 41 PPP_Graphics3D_Proxy::~PPP_Graphics3D_Proxy() { |
43 } | 42 } |
44 | 43 |
45 // static | 44 // static |
46 const InterfaceProxy::Info* PPP_Graphics3D_Proxy::GetInfo() { | 45 const InterfaceProxy::Info* PPP_Graphics3D_Proxy::GetInfo() { |
47 static const Info info = { | 46 static const Info info = { |
48 &graphics_3d_interface, | 47 &graphics_3d_interface, |
49 PPP_GRAPHICS_3D_INTERFACE, | 48 PPP_GRAPHICS_3D_INTERFACE, |
50 INTERFACE_ID_PPP_GRAPHICS_3D, | 49 API_ID_PPP_GRAPHICS_3D, |
51 false, | 50 false, |
52 &CreateGraphics3DProxy, | 51 &CreateGraphics3DProxy, |
53 }; | 52 }; |
54 return &info; | 53 return &info; |
55 } | 54 } |
56 | 55 |
57 bool PPP_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { | 56 bool PPP_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
58 bool handled = true; | 57 bool handled = true; |
59 IPC_BEGIN_MESSAGE_MAP(PPP_Graphics3D_Proxy, msg) | 58 IPC_BEGIN_MESSAGE_MAP(PPP_Graphics3D_Proxy, msg) |
60 IPC_MESSAGE_HANDLER(PpapiMsg_PPPGraphics3D_ContextLost, | 59 IPC_MESSAGE_HANDLER(PpapiMsg_PPPGraphics3D_ContextLost, |
61 OnMsgContextLost) | 60 OnMsgContextLost) |
62 IPC_MESSAGE_UNHANDLED(handled = false) | 61 IPC_MESSAGE_UNHANDLED(handled = false) |
63 IPC_END_MESSAGE_MAP() | 62 IPC_END_MESSAGE_MAP() |
64 return handled; | 63 return handled; |
65 } | 64 } |
66 | 65 |
67 void PPP_Graphics3D_Proxy::OnMsgContextLost(PP_Instance instance) { | 66 void PPP_Graphics3D_Proxy::OnMsgContextLost(PP_Instance instance) { |
68 if (ppp_graphics_3d_impl_) | 67 if (ppp_graphics_3d_impl_) |
69 ppp_graphics_3d_impl_->Graphics3DContextLost(instance); | 68 ppp_graphics_3d_impl_->Graphics3DContextLost(instance); |
70 } | 69 } |
71 | 70 |
72 } // namespace proxy | 71 } // namespace proxy |
73 } // namespace ppapi | 72 } // namespace ppapi |
OLD | NEW |