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/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" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 dispatcher->Send(new PpapiHostMsg_PPBGraphics2D_Create( | 191 dispatcher->Send(new PpapiHostMsg_PPBGraphics2D_Create( |
192 kApiID, instance, size, is_always_opaque, &result)); | 192 kApiID, instance, size, is_always_opaque, &result)); |
193 if (result.is_null()) | 193 if (result.is_null()) |
194 return 0; | 194 return 0; |
195 return (new Graphics2D(result, size, is_always_opaque))->GetReference(); | 195 return (new Graphics2D(result, size, is_always_opaque))->GetReference(); |
196 } | 196 } |
197 | 197 |
198 bool PPB_Graphics2D_Proxy::OnMessageReceived(const IPC::Message& msg) { | 198 bool PPB_Graphics2D_Proxy::OnMessageReceived(const IPC::Message& msg) { |
199 bool handled = true; | 199 bool handled = true; |
200 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics2D_Proxy, msg) | 200 IPC_BEGIN_MESSAGE_MAP(PPB_Graphics2D_Proxy, msg) |
| 201 #if !defined(OS_NACL) |
201 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Create, | 202 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Create, |
202 OnHostMsgCreate) | 203 OnHostMsgCreate) |
203 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_PaintImageData, | 204 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_PaintImageData, |
204 OnHostMsgPaintImageData) | 205 OnHostMsgPaintImageData) |
205 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Scroll, | 206 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Scroll, |
206 OnHostMsgScroll) | 207 OnHostMsgScroll) |
207 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_ReplaceContents, | 208 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_ReplaceContents, |
208 OnHostMsgReplaceContents) | 209 OnHostMsgReplaceContents) |
209 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Flush, | 210 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Flush, |
210 OnHostMsgFlush) | 211 OnHostMsgFlush) |
211 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Dev_SetScale, | 212 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Dev_SetScale, |
212 OnHostMsgSetScale) | 213 OnHostMsgSetScale) |
213 | 214 #endif // !defined(OS_NACL) |
214 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics2D_FlushACK, | 215 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics2D_FlushACK, |
215 OnPluginMsgFlushACK) | 216 OnPluginMsgFlushACK) |
216 IPC_MESSAGE_UNHANDLED(handled = false) | 217 IPC_MESSAGE_UNHANDLED(handled = false) |
217 IPC_END_MESSAGE_MAP() | 218 IPC_END_MESSAGE_MAP() |
218 // FIXME(brettw) handle bad messages! | 219 // FIXME(brettw) handle bad messages! |
219 return handled; | 220 return handled; |
220 } | 221 } |
221 | 222 |
| 223 #if !defined(OS_NACL) |
222 void PPB_Graphics2D_Proxy::OnHostMsgCreate(PP_Instance instance, | 224 void PPB_Graphics2D_Proxy::OnHostMsgCreate(PP_Instance instance, |
223 const PP_Size& size, | 225 const PP_Size& size, |
224 PP_Bool is_always_opaque, | 226 PP_Bool is_always_opaque, |
225 HostResource* result) { | 227 HostResource* result) { |
226 thunk::EnterResourceCreation enter(instance); | 228 thunk::EnterResourceCreation enter(instance); |
227 if (enter.succeeded()) { | 229 if (enter.succeeded()) { |
228 result->SetHostResource(instance, enter.functions()->CreateGraphics2D( | 230 result->SetHostResource(instance, enter.functions()->CreateGraphics2D( |
229 instance, size, is_always_opaque)); | 231 instance, size, is_always_opaque)); |
230 } | 232 } |
231 } | 233 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 284 } |
283 } | 285 } |
284 | 286 |
285 void PPB_Graphics2D_Proxy::OnHostMsgSetScale(const HostResource& graphics_2d, | 287 void PPB_Graphics2D_Proxy::OnHostMsgSetScale(const HostResource& graphics_2d, |
286 float scale) { | 288 float scale) { |
287 EnterHostFromHostResource<PPB_Graphics2D_API> enter(graphics_2d); | 289 EnterHostFromHostResource<PPB_Graphics2D_API> enter(graphics_2d); |
288 if (enter.failed()) | 290 if (enter.failed()) |
289 return; | 291 return; |
290 enter.object()->SetScale(scale); | 292 enter.object()->SetScale(scale); |
291 } | 293 } |
| 294 #endif // !defined(OS_NACL) |
292 | 295 |
293 void PPB_Graphics2D_Proxy::OnPluginMsgFlushACK( | 296 void PPB_Graphics2D_Proxy::OnPluginMsgFlushACK( |
294 const HostResource& host_resource, | 297 const HostResource& host_resource, |
295 int32_t pp_error) { | 298 int32_t pp_error) { |
296 EnterPluginFromHostResource<PPB_Graphics2D_API> enter(host_resource); | 299 EnterPluginFromHostResource<PPB_Graphics2D_API> enter(host_resource); |
297 if (enter.succeeded()) | 300 if (enter.succeeded()) |
298 static_cast<Graphics2D*>(enter.object())->FlushACK(pp_error); | 301 static_cast<Graphics2D*>(enter.object())->FlushACK(pp_error); |
299 } | 302 } |
300 | 303 |
| 304 #if !defined(OS_NACL) |
301 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( | 305 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( |
302 int32_t result, | 306 int32_t result, |
303 const HostResource& graphics_2d) { | 307 const HostResource& graphics_2d) { |
304 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, | 308 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, |
305 result)); | 309 result)); |
306 } | 310 } |
| 311 #endif // !defined(OS_NACL) |
307 | 312 |
308 } // namespace proxy | 313 } // namespace proxy |
309 } // namespace ppapi | 314 } // namespace ppapi |
OLD | NEW |