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_2d_proxy.h" | 5 #include "ppapi/proxy/ppb_graphics_2d_proxy.h" |
6 | 6 |
7 #include <string.h> // For memset. | 7 #include <string.h> // For memset. |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "ppapi/c/pp_completion_callback.h" | 11 #include "ppapi/c/pp_completion_callback.h" |
12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
14 #include "ppapi/c/ppb_graphics_2d.h" | 14 #include "ppapi/c/ppb_graphics_2d.h" |
15 #include "ppapi/proxy/enter_proxy.h" | 15 #include "ppapi/proxy/enter_proxy.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
18 #include "ppapi/thunk/enter.h" | 18 #include "ppapi/thunk/enter.h" |
19 #include "ppapi/thunk/ppb_graphics_2d_api.h" | 19 #include "ppapi/thunk/ppb_graphics_2d_api.h" |
20 #include "ppapi/thunk/thunk.h" | 20 #include "ppapi/thunk/thunk.h" |
21 | 21 |
22 using ppapi::thunk::PPB_Graphics2D_API; | 22 using ppapi::thunk::PPB_Graphics2D_API; |
23 | 23 |
24 namespace ppapi { | 24 namespace ppapi { |
25 namespace proxy { | 25 namespace proxy { |
26 | 26 |
| 27 namespace { |
| 28 |
| 29 InterfaceProxy* CreateGraphics2DProxy(Dispatcher* dispatcher, |
| 30 const void* target_interface) { |
| 31 return new PPB_Graphics2D_Proxy(dispatcher, target_interface); |
| 32 } |
| 33 |
| 34 } // namespace |
| 35 |
27 class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API { | 36 class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API { |
28 public: | 37 public: |
29 Graphics2D(const HostResource& host_resource, | 38 Graphics2D(const HostResource& host_resource, |
30 const PP_Size& size, | 39 const PP_Size& size, |
31 PP_Bool is_always_opaque); | 40 PP_Bool is_always_opaque); |
32 virtual ~Graphics2D(); | 41 virtual ~Graphics2D(); |
33 | 42 |
34 // Resource. | 43 // Resource. |
35 virtual PPB_Graphics2D_API* AsPPB_Graphics2D_API(); | 44 virtual PPB_Graphics2D_API* AsPPB_Graphics2D_API(); |
36 | 45 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 141 |
133 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Flush( | 142 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Flush( |
134 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource())); | 143 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource())); |
135 return PP_OK_COMPLETIONPENDING; | 144 return PP_OK_COMPLETIONPENDING; |
136 } | 145 } |
137 | 146 |
138 void Graphics2D::FlushACK(int32_t result_code) { | 147 void Graphics2D::FlushACK(int32_t result_code) { |
139 PP_RunAndClearCompletionCallback(¤t_flush_callback_, result_code); | 148 PP_RunAndClearCompletionCallback(¤t_flush_callback_, result_code); |
140 } | 149 } |
141 | 150 |
142 PPB_Graphics2D_Proxy::PPB_Graphics2D_Proxy(Dispatcher* dispatcher) | 151 PPB_Graphics2D_Proxy::PPB_Graphics2D_Proxy(Dispatcher* dispatcher, |
143 : InterfaceProxy(dispatcher), | 152 const void* target_interface) |
| 153 : InterfaceProxy(dispatcher, target_interface), |
144 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 154 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
145 } | 155 } |
146 | 156 |
147 PPB_Graphics2D_Proxy::~PPB_Graphics2D_Proxy() { | 157 PPB_Graphics2D_Proxy::~PPB_Graphics2D_Proxy() { |
148 } | 158 } |
149 | 159 |
150 // static | 160 // static |
| 161 const InterfaceProxy::Info* PPB_Graphics2D_Proxy::GetInfo() { |
| 162 static const Info info = { |
| 163 thunk::GetPPB_Graphics2D_Thunk(), |
| 164 PPB_GRAPHICS_2D_INTERFACE, |
| 165 INTERFACE_ID_PPB_GRAPHICS_2D, |
| 166 false, |
| 167 &CreateGraphics2DProxy, |
| 168 }; |
| 169 return &info; |
| 170 } |
| 171 |
| 172 // static |
151 PP_Resource PPB_Graphics2D_Proxy::CreateProxyResource( | 173 PP_Resource PPB_Graphics2D_Proxy::CreateProxyResource( |
152 PP_Instance instance, | 174 PP_Instance instance, |
153 const PP_Size& size, | 175 const PP_Size& size, |
154 PP_Bool is_always_opaque) { | 176 PP_Bool is_always_opaque) { |
155 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 177 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
156 if (!dispatcher) | 178 if (!dispatcher) |
157 return 0; | 179 return 0; |
158 | 180 |
159 HostResource result; | 181 HostResource result; |
160 dispatcher->Send(new PpapiHostMsg_ResourceCreation_Graphics2D( | 182 dispatcher->Send(new PpapiHostMsg_ResourceCreation_Graphics2D( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 257 |
236 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( | 258 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( |
237 int32_t result, | 259 int32_t result, |
238 const HostResource& graphics_2d) { | 260 const HostResource& graphics_2d) { |
239 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK( | 261 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK( |
240 INTERFACE_ID_PPB_GRAPHICS_2D, graphics_2d, result)); | 262 INTERFACE_ID_PPB_GRAPHICS_2D, graphics_2d, result)); |
241 } | 263 } |
242 | 264 |
243 } // namespace proxy | 265 } // namespace proxy |
244 } // namespace ppapi | 266 } // namespace ppapi |
OLD | NEW |