| 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" |
| 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/plugin_resource_tracker.h" | 17 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 18 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
| 19 #include "ppapi/proxy/ppb_image_data_proxy.h" |
| 19 #include "ppapi/shared_impl/tracked_callback.h" | 20 #include "ppapi/shared_impl/tracked_callback.h" |
| 20 #include "ppapi/thunk/enter.h" | 21 #include "ppapi/thunk/enter.h" |
| 21 #include "ppapi/thunk/ppb_graphics_2d_api.h" | 22 #include "ppapi/thunk/ppb_graphics_2d_api.h" |
| 22 #include "ppapi/thunk/thunk.h" | 23 #include "ppapi/thunk/thunk.h" |
| 23 | 24 |
| 24 using ppapi::thunk::PPB_Graphics2D_API; | 25 using ppapi::thunk::PPB_Graphics2D_API; |
| 25 | 26 |
| 26 namespace ppapi { | 27 namespace ppapi { |
| 27 namespace proxy { | 28 namespace proxy { |
| 28 | 29 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 void Graphics2D::Scroll(const PP_Rect* clip_rect, | 114 void Graphics2D::Scroll(const PP_Rect* clip_rect, |
| 114 const PP_Point* amount) { | 115 const PP_Point* amount) { |
| 115 PP_Rect dummy; | 116 PP_Rect dummy; |
| 116 memset(&dummy, 0, sizeof(PP_Rect)); | 117 memset(&dummy, 0, sizeof(PP_Rect)); |
| 117 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Scroll( | 118 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Scroll( |
| 118 kApiID, host_resource(), !!clip_rect, clip_rect ? *clip_rect : dummy, | 119 kApiID, host_resource(), !!clip_rect, clip_rect ? *clip_rect : dummy, |
| 119 *amount)); | 120 *amount)); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void Graphics2D::ReplaceContents(PP_Resource image_data) { | 123 void Graphics2D::ReplaceContents(PP_Resource image_data) { |
| 123 Resource* image_object = | 124 thunk::EnterResourceNoLock<thunk::PPB_ImageData_API> enter_image( |
| 124 PpapiGlobals::Get()->GetResourceTracker()->GetResource(image_data); | 125 image_data, true); |
| 125 if (!image_object || pp_instance() != image_object->pp_instance()) { | 126 if (enter_image.failed()) |
| 127 return; |
| 128 |
| 129 ImageData* image_object = static_cast<ImageData*>(enter_image.object()); |
| 130 if (pp_instance() != image_object->pp_instance()) { |
| 126 Log(PP_LOGLEVEL_ERROR, | 131 Log(PP_LOGLEVEL_ERROR, |
| 127 "PPB_Graphics2D.PaintImageData: Bad image resource."); | 132 "PPB_Graphics2D.ReplaceContents: Image resource for another instance."); |
| 128 return; | 133 return; |
| 129 } | 134 } |
| 135 image_object->set_used_in_replace_contents(); |
| 130 | 136 |
| 131 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_ReplaceContents( | 137 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_ReplaceContents( |
| 132 kApiID, host_resource(), image_object->host_resource())); | 138 kApiID, host_resource(), image_object->host_resource())); |
| 133 } | 139 } |
| 134 | 140 |
| 135 bool Graphics2D::SetScale(float scale) { | 141 bool Graphics2D::SetScale(float scale) { |
| 136 if (scale <= 0.0f) | 142 if (scale <= 0.0f) |
| 137 return false; | 143 return false; |
| 138 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Dev_SetScale( | 144 GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Dev_SetScale( |
| 139 kApiID, host_resource(), scale)); | 145 kApiID, host_resource(), scale)); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 300 |
| 295 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( | 301 void PPB_Graphics2D_Proxy::SendFlushACKToPlugin( |
| 296 int32_t result, | 302 int32_t result, |
| 297 const HostResource& graphics_2d) { | 303 const HostResource& graphics_2d) { |
| 298 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, | 304 dispatcher()->Send(new PpapiMsg_PPBGraphics2D_FlushACK(kApiID, graphics_2d, |
| 299 result)); | 305 result)); |
| 300 } | 306 } |
| 301 | 307 |
| 302 } // namespace proxy | 308 } // namespace proxy |
| 303 } // namespace ppapi | 309 } // namespace ppapi |
| OLD | NEW |