| 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 | |
| 36 class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API { | 27 class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API { |
| 37 public: | 28 public: |
| 38 Graphics2D(const HostResource& host_resource, | 29 Graphics2D(const HostResource& host_resource, |
| 39 const PP_Size& size, | 30 const PP_Size& size, |
| 40 PP_Bool is_always_opaque); | 31 PP_Bool is_always_opaque); |
| 41 virtual ~Graphics2D(); | 32 virtual ~Graphics2D(); |
| 42 | 33 |
| 43 // Resource. | 34 // Resource. |
| 44 virtual PPB_Graphics2D_API* AsPPB_Graphics2D_API(); | 35 virtual PPB_Graphics2D_API* AsPPB_Graphics2D_API(); |
| 45 | 36 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 132 |
| 142 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Flush( | 133 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Flush( |
| 143 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource())); | 134 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource())); |
| 144 return PP_OK_COMPLETIONPENDING; | 135 return PP_OK_COMPLETIONPENDING; |
| 145 } | 136 } |
| 146 | 137 |
| 147 void Graphics2D::FlushACK(int32_t result_code) { | 138 void Graphics2D::FlushACK(int32_t result_code) { |
| 148 PP_RunAndClearCompletionCallback(¤t_flush_callback_, result_code); | 139 PP_RunAndClearCompletionCallback(¤t_flush_callback_, result_code); |
| 149 } | 140 } |
| 150 | 141 |
| 151 PPB_Graphics2D_Proxy::PPB_Graphics2D_Proxy(Dispatcher* dispatcher, | 142 PPB_Graphics2D_Proxy::PPB_Graphics2D_Proxy(Dispatcher* dispatcher) |
| 152 const void* target_interface) | 143 : InterfaceProxy(dispatcher), |
| 153 : InterfaceProxy(dispatcher, target_interface), | |
| 154 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 144 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 155 } | 145 } |
| 156 | 146 |
| 157 PPB_Graphics2D_Proxy::~PPB_Graphics2D_Proxy() { | 147 PPB_Graphics2D_Proxy::~PPB_Graphics2D_Proxy() { |
| 158 } | 148 } |
| 159 | 149 |
| 160 // static | 150 // 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 | |
| 173 PP_Resource PPB_Graphics2D_Proxy::CreateProxyResource( | 151 PP_Resource PPB_Graphics2D_Proxy::CreateProxyResource( |
| 174 PP_Instance instance, | 152 PP_Instance instance, |
| 175 const PP_Size& size, | 153 const PP_Size& size, |
| 176 PP_Bool is_always_opaque) { | 154 PP_Bool is_always_opaque) { |
| 177 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 155 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 178 if (!dispatcher) | 156 if (!dispatcher) |
| 179 return 0; | 157 return 0; |
| 180 | 158 |
| 181 HostResource result; | 159 HostResource result; |
| 182 dispatcher->Send(new PpapiHostMsg_ResourceCreation_Graphics2D( | 160 dispatcher->Send(new PpapiHostMsg_ResourceCreation_Graphics2D( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 235 |
| 258 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( | 236 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( |
| 259 int32_t result, | 237 int32_t result, |
| 260 const HostResource& graphics_2d) { | 238 const HostResource& graphics_2d) { |
| 261 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK( | 239 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK( |
| 262 INTERFACE_ID_PPB_GRAPHICS_2D, graphics_2d, result)); | 240 INTERFACE_ID_PPB_GRAPHICS_2D, graphics_2d, result)); |
| 263 } | 241 } |
| 264 | 242 |
| 265 } // namespace proxy | 243 } // namespace proxy |
| 266 } // namespace ppapi | 244 } // namespace ppapi |
| OLD | NEW |