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) |
214 #endif // !defined(OS_NACL) | |
213 | 215 |
214 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics2D_FlushACK, | 216 IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics2D_FlushACK, |
215 OnPluginMsgFlushACK) | 217 OnPluginMsgFlushACK) |
216 IPC_MESSAGE_UNHANDLED(handled = false) | 218 IPC_MESSAGE_UNHANDLED(handled = false) |
217 IPC_END_MESSAGE_MAP() | 219 IPC_END_MESSAGE_MAP() |
218 // FIXME(brettw) handle bad messages! | 220 // FIXME(brettw) handle bad messages! |
219 return handled; | 221 return handled; |
220 } | 222 } |
221 | 223 |
224 #if !defined(OS_NACL) | |
222 void PPB_Graphics2D_Proxy::OnHostMsgCreate(PP_Instance instance, | 225 void PPB_Graphics2D_Proxy::OnHostMsgCreate(PP_Instance instance, |
223 const PP_Size& size, | 226 const PP_Size& size, |
224 PP_Bool is_always_opaque, | 227 PP_Bool is_always_opaque, |
225 HostResource* result) { | 228 HostResource* result) { |
226 thunk::EnterResourceCreation enter(instance); | 229 thunk::EnterResourceCreation enter(instance); |
227 if (enter.succeeded()) { | 230 if (enter.succeeded()) { |
228 result->SetHostResource(instance, enter.functions()->CreateGraphics2D( | 231 result->SetHostResource(instance, enter.functions()->CreateGraphics2D( |
229 instance, size, is_always_opaque)); | 232 instance, size, is_always_opaque)); |
230 } | 233 } |
231 } | 234 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 } | 286 } |
284 | 287 |
285 void PPB_Graphics2D_Proxy::OnHostMsgSetScale(const HostResource& graphics_2d, | 288 void PPB_Graphics2D_Proxy::OnHostMsgSetScale(const HostResource& graphics_2d, |
286 float scale) { | 289 float scale) { |
287 EnterHostFromHostResource<PPB_Graphics2D_API> enter(graphics_2d); | 290 EnterHostFromHostResource<PPB_Graphics2D_API> enter(graphics_2d); |
288 if (enter.failed()) | 291 if (enter.failed()) |
289 return; | 292 return; |
290 enter.object()->SetScale(scale); | 293 enter.object()->SetScale(scale); |
291 } | 294 } |
292 | 295 |
296 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( | |
brettw
2012/10/11 18:05:50
Can you revert the change to Graphics2D? Victor is
bbudge
2012/10/11 18:46:02
Done.
| |
297 int32_t result, | |
298 const HostResource& graphics_2d) { | |
299 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, | |
300 result)); | |
301 } | |
302 #endif // !defined(OS_NACL) | |
303 | |
293 void PPB_Graphics2D_Proxy::OnPluginMsgFlushACK( | 304 void PPB_Graphics2D_Proxy::OnPluginMsgFlushACK( |
294 const HostResource& host_resource, | 305 const HostResource& host_resource, |
295 int32_t pp_error) { | 306 int32_t pp_error) { |
296 EnterPluginFromHostResource<PPB_Graphics2D_API> enter(host_resource); | 307 EnterPluginFromHostResource<PPB_Graphics2D_API> enter(host_resource); |
297 if (enter.succeeded()) | 308 if (enter.succeeded()) |
298 static_cast<Graphics2D*>(enter.object())->FlushACK(pp_error); | 309 static_cast<Graphics2D*>(enter.object())->FlushACK(pp_error); |
299 } | 310 } |
300 | 311 |
301 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( | |
302 int32_t result, | |
303 const HostResource& graphics_2d) { | |
304 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, | |
305 result)); | |
306 } | |
307 | |
308 } // namespace proxy | 312 } // namespace proxy |
309 } // namespace ppapi | 313 } // namespace ppapi |
OLD | NEW |