| 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 // We specifically want to compare against the area covered by the backing | 1160 // We specifically want to compare against the area covered by the backing |
| 1161 // store when seeing if we cover the given paint bounds, since the backing | 1161 // store when seeing if we cover the given paint bounds, since the backing |
| 1162 // store could be smaller than the declared plugin area. | 1162 // store could be smaller than the declared plugin area. |
| 1163 PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->image_data(); | 1163 PPB_ImageData_Impl* image_data = GetBoundGraphics2D()->image_data(); |
| 1164 // ImageDatas created by NaCl don't have a PlatformImage, so can't be | 1164 // ImageDatas created by NaCl don't have a PlatformImage, so can't be |
| 1165 // optimized this way. | 1165 // optimized this way. |
| 1166 if (!image_data->PlatformImage()) | 1166 if (!image_data->PlatformImage()) |
| 1167 return false; | 1167 return false; |
| 1168 | 1168 |
| 1169 gfx::Point plugin_origin = PP_ToGfxPoint(view_data_.rect.point); | 1169 gfx::Point plugin_origin = PP_ToGfxPoint(view_data_.rect.point); |
| 1170 gfx::Vector2d plugin_offset = plugin_origin.OffsetFromOrigin(); |
| 1170 // Convert |paint_bounds| to be relative to the left-top corner of the plugin. | 1171 // Convert |paint_bounds| to be relative to the left-top corner of the plugin. |
| 1171 gfx::Rect relative_paint_bounds(paint_bounds); | 1172 gfx::Rect relative_paint_bounds(paint_bounds); |
| 1172 relative_paint_bounds.Offset(-plugin_origin.x(), -plugin_origin.y()); | 1173 relative_paint_bounds.Offset(-plugin_offset); |
| 1173 | 1174 |
| 1174 gfx::Rect pixel_plugin_backing_store_rect( | 1175 gfx::Rect pixel_plugin_backing_store_rect( |
| 1175 0, 0, image_data->width(), image_data->height()); | 1176 0, 0, image_data->width(), image_data->height()); |
| 1176 float scale = GetBoundGraphics2D()->GetScale(); | 1177 float scale = GetBoundGraphics2D()->GetScale(); |
| 1177 gfx::Rect plugin_backing_store_rect = gfx::ToEnclosedRect( | 1178 gfx::Rect plugin_backing_store_rect = gfx::ToEnclosedRect( |
| 1178 gfx::ScaleRect(pixel_plugin_backing_store_rect, scale)); | 1179 gfx::ScaleRect(pixel_plugin_backing_store_rect, scale)); |
| 1179 | 1180 |
| 1180 gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect); | 1181 gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect); |
| 1181 gfx::Rect plugin_paint_rect = | 1182 gfx::Rect plugin_paint_rect = |
| 1182 gfx::IntersectRects(plugin_backing_store_rect, clip_page); | 1183 gfx::IntersectRects(plugin_backing_store_rect, clip_page); |
| 1183 if (!plugin_paint_rect.Contains(relative_paint_bounds)) | 1184 if (!plugin_paint_rect.Contains(relative_paint_bounds)) |
| 1184 return false; | 1185 return false; |
| 1185 | 1186 |
| 1186 // Don't do optimized painting if the area to paint intersects with the | 1187 // Don't do optimized painting if the area to paint intersects with the |
| 1187 // cut-out rects, otherwise we will paint over them. | 1188 // cut-out rects, otherwise we will paint over them. |
| 1188 for (std::vector<gfx::Rect>::const_iterator iter = cut_outs_rects_.begin(); | 1189 for (std::vector<gfx::Rect>::const_iterator iter = cut_outs_rects_.begin(); |
| 1189 iter != cut_outs_rects_.end(); ++iter) { | 1190 iter != cut_outs_rects_.end(); ++iter) { |
| 1190 if (relative_paint_bounds.Intersects(*iter)) | 1191 if (relative_paint_bounds.Intersects(*iter)) |
| 1191 return false; | 1192 return false; |
| 1192 } | 1193 } |
| 1193 | 1194 |
| 1194 *dib = image_data->PlatformImage()->GetTransportDIB(); | 1195 *dib = image_data->PlatformImage()->GetTransportDIB(); |
| 1195 plugin_backing_store_rect.Offset(plugin_origin); | 1196 plugin_backing_store_rect.Offset(plugin_offset); |
| 1196 *location = plugin_backing_store_rect; | 1197 *location = plugin_backing_store_rect; |
| 1197 clip_page.Offset(plugin_origin); | 1198 clip_page.Offset(plugin_offset); |
| 1198 *clip = clip_page; | 1199 *clip = clip_page; |
| 1199 // The plugin scale factor is inverted, e.g. for a device scale factor of 2x | 1200 // The plugin scale factor is inverted, e.g. for a device scale factor of 2x |
| 1200 // the plugin scale factor is 0.5. | 1201 // the plugin scale factor is 0.5. |
| 1201 *scale_factor = 1.0 / scale; | 1202 *scale_factor = 1.0 / scale; |
| 1202 return true; | 1203 return true; |
| 1203 } | 1204 } |
| 1204 | 1205 |
| 1205 string16 PluginInstance::GetSelectedText(bool html) { | 1206 string16 PluginInstance::GetSelectedText(bool html) { |
| 1206 // Keep a reference on the stack. See NOTE above. | 1207 // Keep a reference on the stack. See NOTE above. |
| 1207 scoped_refptr<PluginInstance> ref(this); | 1208 scoped_refptr<PluginInstance> ref(this); |
| (...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3226 screen_size_for_fullscreen_ = gfx::Size(); | 3227 screen_size_for_fullscreen_ = gfx::Size(); |
| 3227 WebElement element = container_->element(); | 3228 WebElement element = container_->element(); |
| 3228 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 3229 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 3229 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 3230 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 3230 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 3231 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 3231 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 3232 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 3232 } | 3233 } |
| 3233 | 3234 |
| 3234 } // namespace ppapi | 3235 } // namespace ppapi |
| 3235 } // namespace webkit | 3236 } // namespace webkit |
| OLD | NEW |