diff options
author | jhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-28 19:33:33 +0000 |
---|---|---|
committer | jhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-28 19:33:33 +0000 |
commit | 0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a (patch) | |
tree | 4f52f8e8297c613550899b6685dcba9718f103c8 /webkit/plugins/ppapi/ppb_graphics_2d_impl.cc | |
parent | 65828ab68c586b3074e8705644f7d93b54bac418 (diff) | |
download | chromium_src-0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a.zip chromium_src-0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a.tar.gz chromium_src-0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a.tar.bz2 |
Implement HiDPI support in Pepper dev interface
This patch requires WebKit patch https://bugs.webkit.org/show_bug.cgi?id=87874 (WebKit r121364)
Expose device_scale_factor and css_scale_factor to Pepper plugins via a dev
interface on View resource.
Allow Pepper plugins to create a 2D graphics context with a scale factor so the
plugins can render at device resolution rather than DIPs if they want.
BUG=114673
TEST=browser_tests --gtest_filter="PPAPITest.*"
TEST=browser_tests --gtest_filter="OutOfProcessPPAPITest.*"
TEST=Build, run existing PPAPI plugin at 2x scale
TEST=Build, run test HiDPI aware plugin to render at device rez, at 1x, 2x scale
Review URL: https://chromiumcodereview.appspot.com/10544168
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144773 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/ppapi/ppb_graphics_2d_impl.cc')
-rw-r--r-- | webkit/plugins/ppapi/ppb_graphics_2d_impl.cc | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc index 69ac176..79821bb 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc @@ -159,6 +159,7 @@ PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PP_Instance instance) bound_instance_(NULL), offscreen_flush_pending_(false), is_always_opaque_(false), + scale_(1.0f), weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { } @@ -191,6 +192,7 @@ bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) { return false; } is_always_opaque_ = is_always_opaque; + scale_ = 1.0f; return true; } @@ -378,6 +380,19 @@ int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback) { return PP_OK_COMPLETIONPENDING; } +bool PPB_Graphics2D_Impl::SetScale(float scale) { + if (scale > 0.0f) { + scale_ = scale; + return true; + } + + return false; +} + +float PPB_Graphics2D_Impl::GetScale() { + return scale_; +} + bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image, const PP_Point* top_left) { // Get and validate the image object to paint into. @@ -562,10 +577,15 @@ void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas, // more optimized painting. paint.setXfermodeMode(SkXfermode::kSrc_Mode); } - canvas->drawBitmap(image, - SkIntToScalar(plugin_rect.x()), - SkIntToScalar(plugin_rect.y()), - &paint); + + SkPoint origin; + origin.set(SkIntToScalar(plugin_rect.x()), SkIntToScalar(plugin_rect.y())); + if (scale_ != 1.0f && scale_ > 0.0f) { + float inverse_scale = 1.0f / scale_; + origin.scale(inverse_scale); + canvas->scale(scale_, scale_); + } + canvas->drawBitmap(image, origin.x(), origin.y(), &paint); canvas->restore(); #endif } |