summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/renderer/render_widget.cc5
-rw-r--r--content/renderer/render_widget_fullscreen_pepper.cc6
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc9
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc22
4 files changed, 25 insertions, 17 deletions
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 0ffd4e2..ccff877 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -696,9 +696,8 @@ void RenderWidget::PaintRect(const gfx::Rect& rect,
// the plugin. Unlike the DoDeferredUpdate case, an extra copy is still
// required.
base::TimeTicks paint_begin_ticks = base::TimeTicks::Now();
- canvas->save();
- float canvas_scale = device_scale_factor_ / dib_scale_factor;
- canvas->scale(canvas_scale, canvas_scale);
+ SkAutoCanvasRestore auto_restore(canvas, true);
+ canvas->scale(device_scale_factor_, device_scale_factor_);
optimized_instance->Paint(webkit_glue::ToWebCanvas(canvas),
optimized_copy_location, rect);
canvas->restore();
diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc
index a6caf84..887d1de 100644
--- a/content/renderer/render_widget_fullscreen_pepper.cc
+++ b/content/renderer/render_widget_fullscreen_pepper.cc
@@ -15,7 +15,9 @@
#include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
+#include "skia/ext/platform_canvas.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
@@ -121,6 +123,10 @@ class PepperWidget : public WebWidget {
if (!widget_->plugin())
return;
+ SkAutoCanvasRestore auto_restore(canvas, true);
+ float canvas_scale = widget_->deviceScaleFactor();
+ canvas->scale(canvas_scale, canvas_scale);
+
WebRect plugin_rect(0, 0, size_.width, size_.height);
widget_->plugin()->Paint(canvas, plugin_rect, rect);
}
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 600fc44..cd03fa9 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -1011,8 +1011,11 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint(
gfx::Rect relative_paint_bounds(paint_bounds);
relative_paint_bounds.Offset(-plugin_origin.x(), -plugin_origin.y());
- gfx::Rect plugin_backing_store_rect(
+ gfx::Rect pixel_plugin_backing_store_rect(
0, 0, image_data->width(), image_data->height());
+ float scale = GetBoundGraphics2D()->GetScale();
+ gfx::Rect plugin_backing_store_rect =
+ pixel_plugin_backing_store_rect.Scale(scale);
gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect);
gfx::Rect plugin_paint_rect = plugin_backing_store_rect.Intersect(clip_page);
@@ -1032,7 +1035,9 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint(
*location = plugin_backing_store_rect;
clip_page.Offset(plugin_origin);
*clip = clip_page;
- *scale_factor = GetBoundGraphics2D()->GetScale();
+ // The plugin scale factor is inverted, e.g. for a device scale factor of 2x
+ // the plugin scale factor is 0.5.
+ *scale_factor = 1.0 / scale;
return true;
}
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 5c37b95..a838f1f 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -22,6 +22,7 @@
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
+#include "ui/gfx/skia_util.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/gfx_conversion.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
@@ -557,13 +558,11 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
CGContextDrawImage(canvas, bitmap_rect, image);
#else
gfx::Rect invalidate_rect = plugin_rect.Intersect(paint_rect);
- SkRect sk_invalidate_rect = SkRect::MakeXYWH(
- SkIntToScalar(invalidate_rect.origin().x()),
- SkIntToScalar(invalidate_rect.origin().y()),
- SkIntToScalar(invalidate_rect.width()),
- SkIntToScalar(invalidate_rect.height()));
+ SkRect sk_invalidate_rect = gfx::RectToSkRect(invalidate_rect);
SkAutoCanvasRestore auto_restore(canvas, true);
canvas->clipRect(sk_invalidate_rect);
+ gfx::Size pixel_image_size(image_data_->width(), image_data_->height());
+ gfx::Size image_size = pixel_image_size.Scale(scale_);
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
@@ -576,11 +575,8 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
// We don't do this for non-full-frame plugins since we specifically want
// the page background to show through.
SkAutoCanvasRestore auto_restore(canvas, true);
- SkRect image_data_rect = SkRect::MakeXYWH(
- SkIntToScalar(plugin_rect.origin().x()),
- SkIntToScalar(plugin_rect.origin().y()),
- SkIntToScalar(image_data_->width()),
- SkIntToScalar(image_data_->height()));
+ SkRect image_data_rect =
+ gfx::RectToSkRect(gfx::Rect(plugin_rect.origin(), image_size));
canvas->clipRect(image_data_rect, SkRegion::kDifference_Op);
SkPaint paint;
@@ -606,12 +602,14 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
SkPoint origin;
origin.set(SkIntToScalar(plugin_rect.x()), SkIntToScalar(plugin_rect.y()));
+
+ SkPoint pixel_origin = origin;
if (scale_ != 1.0f && scale_ > 0.0f) {
float inverse_scale = 1.0f / scale_;
- origin.scale(inverse_scale);
+ pixel_origin.scale(inverse_scale);
canvas->scale(scale_, scale_);
}
- canvas->drawBitmap(image, origin.x(), origin.y(), &paint);
+ canvas->drawBitmap(image, pixel_origin.x(), pixel_origin.y(), &paint);
#endif
}