| 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" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 PP_Bool Graphics2D::Describe(PP_Size* size, PP_Bool* is_always_opaque) { | 81 PP_Bool Graphics2D::Describe(PP_Size* size, PP_Bool* is_always_opaque) { |
| 82 *size = size_; | 82 *size = size_; |
| 83 *is_always_opaque = is_always_opaque_; | 83 *is_always_opaque = is_always_opaque_; |
| 84 return PP_TRUE; | 84 return PP_TRUE; |
| 85 } | 85 } |
| 86 | 86 |
| 87 void Graphics2D::PaintImageData(PP_Resource image_data, | 87 void Graphics2D::PaintImageData(PP_Resource image_data, |
| 88 const PP_Point* top_left, | 88 const PP_Point* top_left, |
| 89 const PP_Rect* src_rect) { | 89 const PP_Rect* src_rect) { |
| 90 Resource* image_object = | 90 Resource* image_object = PluginResourceTracker::GetInstance()-> |
| 91 PpapiGlobals::Get()->GetResourceTracker()->GetResource(image_data); | 91 GetResource(image_data); |
| 92 if (!image_object || pp_instance() != image_object->pp_instance()) | 92 if (!image_object || pp_instance() != image_object->pp_instance()) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 PP_Rect dummy; | 95 PP_Rect dummy; |
| 96 memset(&dummy, 0, sizeof(PP_Rect)); | 96 memset(&dummy, 0, sizeof(PP_Rect)); |
| 97 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_PaintImageData( | 97 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_PaintImageData( |
| 98 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource(), | 98 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource(), |
| 99 image_object->host_resource(), *top_left, !!src_rect, | 99 image_object->host_resource(), *top_left, !!src_rect, |
| 100 src_rect ? *src_rect : dummy)); | 100 src_rect ? *src_rect : dummy)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void Graphics2D::Scroll(const PP_Rect* clip_rect, | 103 void Graphics2D::Scroll(const PP_Rect* clip_rect, |
| 104 const PP_Point* amount) { | 104 const PP_Point* amount) { |
| 105 PP_Rect dummy; | 105 PP_Rect dummy; |
| 106 memset(&dummy, 0, sizeof(PP_Rect)); | 106 memset(&dummy, 0, sizeof(PP_Rect)); |
| 107 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Scroll( | 107 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Scroll( |
| 108 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource(), | 108 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource(), |
| 109 !!clip_rect, clip_rect ? *clip_rect : dummy, *amount)); | 109 !!clip_rect, clip_rect ? *clip_rect : dummy, *amount)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void Graphics2D::ReplaceContents(PP_Resource image_data) { | 112 void Graphics2D::ReplaceContents(PP_Resource image_data) { |
| 113 Resource* image_object = | 113 Resource* image_object = PluginResourceTracker::GetInstance()-> |
| 114 PpapiGlobals::Get()->GetResourceTracker()->GetResource(image_data); | 114 GetResource(image_data); |
| 115 if (!image_object || pp_instance() != image_object->pp_instance()) | 115 if (!image_object || pp_instance() != image_object->pp_instance()) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_ReplaceContents( | 118 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_ReplaceContents( |
| 119 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource(), | 119 INTERFACE_ID_PPB_GRAPHICS_2D, host_resource(), |
| 120 image_object->host_resource())); | 120 image_object->host_resource())); |
| 121 } | 121 } |
| 122 | 122 |
| 123 int32_t Graphics2D::Flush(PP_CompletionCallback callback) { | 123 int32_t Graphics2D::Flush(PP_CompletionCallback callback) { |
| 124 // For now, disallow blocking calls. We'll need to add support for other | 124 // For now, disallow blocking calls. We'll need to add support for other |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( | 236 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( |
| 237 int32_t result, | 237 int32_t result, |
| 238 const HostResource& graphics_2d) { | 238 const HostResource& graphics_2d) { |
| 239 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK( | 239 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK( |
| 240 INTERFACE_ID_PPB_GRAPHICS_2D, graphics_2d, result)); | 240 INTERFACE_ID_PPB_GRAPHICS_2D, graphics_2d, result)); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace proxy | 243 } // namespace proxy |
| 244 } // namespace ppapi | 244 } // namespace ppapi |
| OLD | NEW |