summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 19:33:33 +0000
committerjhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 19:33:33 +0000
commit0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a (patch)
tree4f52f8e8297c613550899b6685dcba9718f103c8
parent65828ab68c586b3074e8705644f7d93b54bac418 (diff)
downloadchromium_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
-rw-r--r--chrome/test/ui/ppapi_uitest.cc12
-rw-r--r--ppapi/api/dev/ppb_graphics_2d_dev.idl46
-rw-r--r--ppapi/api/dev/ppb_view_dev.idl43
-rw-r--r--ppapi/c/dev/ppb_graphics_2d_dev.h66
-rw-r--r--ppapi/c/dev/ppb_view_dev.h65
-rw-r--r--ppapi/cpp/dev/graphics_2d_dev.cc33
-rw-r--r--ppapi/cpp/dev/graphics_2d_dev.h52
-rw-r--r--ppapi/cpp/dev/view_dev.cc32
-rw-r--r--ppapi/cpp/dev/view_dev.h44
-rw-r--r--ppapi/ppapi_sources.gypi4
-rw-r--r--ppapi/proxy/interface_list.cc2
-rw-r--r--ppapi/proxy/ppapi_messages.h5
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.cc29
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.h2
-rw-r--r--ppapi/shared_impl/ppb_view_shared.cc4
-rw-r--r--ppapi/shared_impl/ppb_view_shared.h2
-rw-r--r--ppapi/tests/all_c_includes.h2
-rw-r--r--ppapi/tests/all_cpp_includes.h2
-rw-r--r--ppapi/tests/test_graphics_2d.cc43
-rw-r--r--ppapi/tests/test_graphics_2d.h1
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev.h4
-rw-r--r--ppapi/thunk/ppb_graphics_2d_api.h2
-rw-r--r--ppapi/thunk/ppb_graphics_2d_thunk.cc24
-rw-r--r--ppapi/thunk/ppb_view_thunk.cc24
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc2
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc28
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.h6
28 files changed, 574 insertions, 8 deletions
diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc
index 031fdf9..46310ca 100644
--- a/chrome/test/ui/ppapi_uitest.cc
+++ b/chrome/test/ui/ppapi_uitest.cc
@@ -554,7 +554,17 @@ TEST_PPAPI_OUT_OF_PROCESS(Instance_LeakedObjectDestructors);
TEST_PPAPI_IN_PROCESS(Graphics2D)
TEST_PPAPI_OUT_OF_PROCESS(Graphics2D)
-TEST_PPAPI_NACL_VIA_HTTP(Graphics2D)
+// Graphics2D_Dev isn't supported in NaCl, only test the other interfaces
+// TODO(jhorwich) Enable when Graphics2D_Dev interfaces are proxied in NaCl.
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_InvalidResource)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_InvalidSize)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_Humongous)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_InitToZero)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_Describe)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_Paint)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_Scroll)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_Replace)
+TEST_PPAPI_NACL_VIA_HTTP(Graphics2D_Flush)
TEST_PPAPI_IN_PROCESS(Graphics3D)
TEST_PPAPI_OUT_OF_PROCESS(Graphics3D)
diff --git a/ppapi/api/dev/ppb_graphics_2d_dev.idl b/ppapi/api/dev/ppb_graphics_2d_dev.idl
new file mode 100644
index 0000000..6d0c99a
--- /dev/null
+++ b/ppapi/api/dev/ppb_graphics_2d_dev.idl
@@ -0,0 +1,46 @@
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* This file contains the <code>PPB_Graphics2D_Dev</code> interface. */
+label Chrome {
+ M22 = 0.1
+};
+
+/* PPB_Graphics2D_Dev interface */
+interface PPB_Graphics2D_Dev {
+ /**
+ * SetScale() sets the scale factor that will be applied when painting the
+ * graphics context onto the output device. Typically, if rendering at device
+ * resolution is desired, the context would be created with the width and
+ * height scaled up by the view's GetDeviceScale and SetScale called with a
+ * scale of 1.0 / GetDeviceScale(). For example, if the view resource passed
+ * to DidChangeView has a rectangle of (w=200, h=100) and a device scale of
+ * 2.0, one would call Create with a size of (w=400, h=200) and then call
+ * SetScale with 0.5. One would then treat each pixel in the context as a
+ * single device pixel.
+ *
+ * @param[in] resource A <code>Graphics2D</code> context resource.
+ * @param[in] scale The scale to apply when painting.
+ *
+ * @return Returns <code>PP_TRUE</code> on success or <code>PP_FALSE</code> if
+ * the resource is invalid or the scale factor is 0 or less.
+ */
+ PP_Bool SetScale(
+ [in] PP_Resource resource,
+ [in] float_t scale);
+
+ /***
+ * GetScale() gets the scale factor that will be applied when painting the
+ * graphics context onto the output device.
+ *
+ * @param[in] resource A <code>Graphics2D</code> context resource.
+ *
+ * @return Returns the scale factor for the graphics context. If the resource
+ * is not a valid <code>Graphics2D</code> context, this will return 0.0.
+ */
+ float_t GetScale(
+ [in] PP_Resource resource);
+};
+
diff --git a/ppapi/api/dev/ppb_view_dev.idl b/ppapi/api/dev/ppb_view_dev.idl
new file mode 100644
index 0000000..b72014e
--- /dev/null
+++ b/ppapi/api/dev/ppb_view_dev.idl
@@ -0,0 +1,43 @@
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* This file contains the <code>PPB_View_Dev</code> interface. */
+label Chrome {
+ M22 = 0.1
+};
+
+/* PPB_View_Dev interface */
+interface PPB_View_Dev {
+ /**
+ * GetDeviceScale returns the scale factor between device pixels and DIPs
+ * (also known as logical pixels or UI pixels on some platforms). This allows
+ * the developer to render their contents at device resolution, even as
+ * coordinates / sizes are given in DIPs through the API.
+ *
+ * Note that the coordinate system for Pepper APIs is DIPs. Also note that
+ * one DIP might not equal one CSS pixel - when page scale/zoom is in effect.
+ *
+ * @param[in] resource A <code>PP_Resource</code> corresponding to a
+ * <code>PPB_View</code> resource.
+ *
+ * @return A <code>float</code> value representing the number of device pixels
+ * per DIP. If the resource is invalid, the value will be 0.0.
+ */
+ float_t GetDeviceScale([in] PP_Resource resource);
+
+ /**
+ * GetCSSScale returns the scale factor between DIPs and CSS pixels. This
+ * allows proper scaling between DIPs - as sent via the Pepper API - and CSS
+ * pixel coordinates used for Web content.
+ *
+ * @param[in] resource A <code>PP_Resource</code> corresponding to a
+ * <code>PPB_View</code> resource.
+ *
+ * @return css_scale A <code>float</code> value representing the number of
+ * DIPs per CSS pixel. If the resource is invalid, the value will be 0.0.
+ */
+ float_t GetCSSScale([in] PP_Resource resource);
+};
+
diff --git a/ppapi/c/dev/ppb_graphics_2d_dev.h b/ppapi/c/dev/ppb_graphics_2d_dev.h
new file mode 100644
index 0000000..a4661215
--- /dev/null
+++ b/ppapi/c/dev/ppb_graphics_2d_dev.h
@@ -0,0 +1,66 @@
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* From dev/ppb_graphics_2d_dev.idl modified Tue Jun 19 14:11:08 2012. */
+
+#ifndef PPAPI_C_DEV_PPB_GRAPHICS_2D_DEV_H_
+#define PPAPI_C_DEV_PPB_GRAPHICS_2D_DEV_H_
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_stdint.h"
+
+#define PPB_GRAPHICS2D_DEV_INTERFACE_0_1 "PPB_Graphics2D(Dev);0.1"
+#define PPB_GRAPHICS2D_DEV_INTERFACE PPB_GRAPHICS2D_DEV_INTERFACE_0_1
+
+/**
+ * @file
+ * This file contains the <code>PPB_Graphics2D_Dev</code> interface. */
+
+
+/**
+ * @addtogroup Interfaces
+ * @{
+ */
+/* PPB_Graphics2D_Dev interface */
+struct PPB_Graphics2D_Dev_0_1 {
+ /**
+ * SetScale() sets the scale factor that will be applied when painting the
+ * graphics context onto the output device. Typically, if rendering at device
+ * resolution is desired, the context would be created with the width and
+ * height scaled up by the view's GetDeviceScale and SetScale called with a
+ * scale of 1.0 / GetDeviceScale(). For example, if the view resource passed
+ * to DidChangeView has a rectangle of (w=200, h=100) and a device scale of
+ * 2.0, one would call Create with a size of (w=400, h=200) and then call
+ * SetScale with 0.5. One would then treat each pixel in the context as a
+ * single device pixel.
+ *
+ * @param[in] resource A <code>Graphics2D</code> context resource.
+ * @param[in] scale The scale to apply when painting.
+ *
+ * @return Returns <code>PP_TRUE</code> on success or <code>PP_FALSE</code> if
+ * the resource is invalid or the scale factor is 0 or less.
+ */
+ PP_Bool (*SetScale)(PP_Resource resource, float scale);
+ /***
+ * GetScale() gets the scale factor that will be applied when painting the
+ * graphics context onto the output device.
+ *
+ * @param[in] resource A <code>Graphics2D</code> context resource.
+ *
+ * @return Returns the scale factor for the graphics context. If the resource
+ * is not a valid <code>Graphics2D</code> context, this will return 0.0.
+ */
+ float (*GetScale)(PP_Resource resource);
+};
+
+typedef struct PPB_Graphics2D_Dev_0_1 PPB_Graphics2D_Dev;
+/**
+ * @}
+ */
+
+#endif /* PPAPI_C_DEV_PPB_GRAPHICS_2D_DEV_H_ */
+
diff --git a/ppapi/c/dev/ppb_view_dev.h b/ppapi/c/dev/ppb_view_dev.h
new file mode 100644
index 0000000..1995193
--- /dev/null
+++ b/ppapi/c/dev/ppb_view_dev.h
@@ -0,0 +1,65 @@
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* From dev/ppb_view_dev.idl modified Mon Jun 18 14:55:58 2012. */
+
+#ifndef PPAPI_C_DEV_PPB_VIEW_DEV_H_
+#define PPAPI_C_DEV_PPB_VIEW_DEV_H_
+
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/c/pp_stdint.h"
+
+#define PPB_VIEW_DEV_INTERFACE_0_1 "PPB_View(Dev);0.1"
+#define PPB_VIEW_DEV_INTERFACE PPB_VIEW_DEV_INTERFACE_0_1
+
+/**
+ * @file
+ * This file contains the <code>PPB_View_Dev</code> interface. */
+
+
+/**
+ * @addtogroup Interfaces
+ * @{
+ */
+/* PPB_View_Dev interface */
+struct PPB_View_Dev_0_1 {
+ /**
+ * GetDeviceScale returns the scale factor between device pixels and DIPs
+ * (also known as logical pixels or UI pixels on some platforms). This allows
+ * the developer to render their contents at device resolution, even as
+ * coordinates / sizes are given in DIPs through the API.
+ *
+ * Note that the coordinate system for Pepper APIs is DIPs. Also note that
+ * one DIP might not equal one CSS pixel - when page scale/zoom is in effect.
+ *
+ * @param[in] resource A <code>PP_Resource</code> corresponding to a
+ * <code>PPB_View</code> resource.
+ *
+ * @return A <code>float</code> value representing the number of device pixels
+ * per DIP. If the resource is invalid, the value will be 0.0.
+ */
+ float (*GetDeviceScale)(PP_Resource resource);
+ /**
+ * GetCSSScale returns the scale factor between DIPs and CSS pixels. This
+ * allows proper scaling between DIPs - as sent via the Pepper API - and CSS
+ * pixel coordinates used for Web content.
+ *
+ * @param[in] resource A <code>PP_Resource</code> corresponding to a
+ * <code>PPB_View</code> resource.
+ *
+ * @return css_scale A <code>float</code> value representing the number of
+ * DIPs per CSS pixel. If the resource is invalid, the value will be 0.0.
+ */
+ float (*GetCSSScale)(PP_Resource resource);
+};
+
+typedef struct PPB_View_Dev_0_1 PPB_View_Dev;
+/**
+ * @}
+ */
+
+#endif /* PPAPI_C_DEV_PPB_VIEW_DEV_H_ */
+
diff --git a/ppapi/cpp/dev/graphics_2d_dev.cc b/ppapi/cpp/dev/graphics_2d_dev.cc
new file mode 100644
index 0000000..1a04b6a
--- /dev/null
+++ b/ppapi/cpp/dev/graphics_2d_dev.cc
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/dev/graphics_2d_dev.h"
+
+#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Graphics2D_Dev>() {
+ return PPB_GRAPHICS2D_DEV_INTERFACE;
+}
+
+} // namespace
+
+bool Graphics2DDev::SetScale(float scale) {
+ if (!has_interface<PPB_Graphics2D_Dev>())
+ return false;
+ return PP_ToBool(get_interface<PPB_Graphics2D_Dev>()->SetScale(pp_resource(),
+ scale));
+}
+
+float Graphics2DDev::GetScale() {
+ if (!has_interface<PPB_Graphics2D_Dev>())
+ return 1.0f;
+ return get_interface<PPB_Graphics2D_Dev>()->GetScale(pp_resource());
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/dev/graphics_2d_dev.h b/ppapi/cpp/dev/graphics_2d_dev.h
new file mode 100644
index 0000000..2ebc06e
--- /dev/null
+++ b/ppapi/cpp/dev/graphics_2d_dev.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DEV_GRAPHICS_2D_DEV_H_
+#define PPAPI_CPP_DEV_GRAPHICS_2D_DEV_H_
+
+#include "ppapi/cpp/graphics_2d.h"
+
+namespace pp {
+
+// Graphics2DDev is a version of Graphics2D that exposes under-development APIs
+// for HiDPI
+class Graphics2DDev : public Graphics2D {
+ public:
+ /// Default constructor for creating an is_null()
+ /// <code>Graphics2DDev</code> object.
+ Graphics2DDev() : Graphics2D() {}
+
+ // Constructor for creating a <code>Graphics2DDev</code> object from an
+ // existing <code>Graphics2D</code> object.
+ Graphics2DDev(const Graphics2D& other) : Graphics2D(other) {}
+
+ virtual ~Graphics2DDev() {}
+
+ /// SetScale() sets the scale factor that will be applied when painting the
+ /// graphics context onto the output device. Typically, if rendering at device
+ /// resolution is desired, the context would be created with the width and
+ /// height scaled up by the view's GetDeviceScale and SetScale called with a
+ /// scale of 1.0 / GetDeviceScale(). For example, if the view resource passed
+ /// to DidChangeView has a rectangle of (w=200, h=100) and a device scale of
+ /// 2.0, one would call Create with a size of (w=400, h=200) and then call
+ /// SetScale with 0.5. One would then treat each pixel in the context as a
+ /// single device pixel.
+ ///
+ /// @param[in] scale The scale to apply when painting.
+ ///
+ /// @return Returns <code>true</code> on success or <code>false</code>
+ /// if the resource is invalid or the scale factor is 0 or less.
+ bool SetScale(float scale);
+
+ /// GetScale() gets the scale factor that will be applied when painting the
+ /// graphics context onto the output device.
+ ///
+ /// @return Returns the scale factor for the graphics context. If the resource
+ /// is invalid, 0.0 will be returned.
+ float GetScale();
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_GRAPHICS_2D_DEV_H_
diff --git a/ppapi/cpp/dev/view_dev.cc b/ppapi/cpp/dev/view_dev.cc
new file mode 100644
index 0000000..473e9b4
--- /dev/null
+++ b/ppapi/cpp/dev/view_dev.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/dev/view_dev.h"
+
+#include "ppapi/c/dev/ppb_view_dev.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_View_Dev>() {
+ return PPB_VIEW_DEV_INTERFACE;
+}
+
+} // namespace
+
+float ViewDev::GetDeviceScale() const {
+ if (!has_interface<PPB_View_Dev>())
+ return 1.0f;
+ return get_interface<PPB_View_Dev>()->GetDeviceScale(pp_resource());
+}
+
+float ViewDev::GetCSSScale() const {
+ if (!has_interface<PPB_View_Dev>())
+ return 1.0f;
+ return get_interface<PPB_View_Dev>()->GetCSSScale(pp_resource());
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/dev/view_dev.h b/ppapi/cpp/dev/view_dev.h
new file mode 100644
index 0000000..2c99e48
--- /dev/null
+++ b/ppapi/cpp/dev/view_dev.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DEV_VIEW_DEV_H_
+#define PPAPI_CPP_DEV_VIEW_DEV_H_
+
+#include "ppapi/cpp/view.h"
+
+namespace pp {
+
+// ViewDev is a version of View that exposes under-development APIs related to
+// HiDPI
+class ViewDev : public View {
+ public:
+ ViewDev() : View() {}
+ ViewDev(const View& other) : View(other) {}
+
+ virtual ~ViewDev() {}
+
+ /// GetDeviceScale returns the scale factor between device pixels and DIPs
+ /// (also known as logical pixels or UI pixels on some platforms). This allows
+ /// the developer to render their contents at device resolution, even as
+ /// coordinates / sizes are given in DIPs through the API.
+ ///
+ /// Note that the coordinate system for Pepper APIs is DIPs. Also note that
+ /// one DIP might not equal one CSS pixel - when page scale/zoom is in effect.
+ ///
+ /// @return A <code>float</code> value representing the number of device
+ /// pixels per DIP.
+ float GetDeviceScale() const;
+
+ /// GetCSSScale returns the scale factor between DIPs and CSS pixels. This
+ /// allows proper scaling between DIPs - as sent via the Pepper API - and CSS
+ /// pixel coordinates used for Web content.
+ ///
+ /// @return A <code>float</code> value representing the number of DIPs per CSS
+ /// pixel.
+ float GetCSSScale() const;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_VIEW_DEV_H_
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index 8cdbcba..875506e 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -213,6 +213,8 @@
'cpp/dev/font_dev.h',
'cpp/dev/fullscreen_dev.cc',
'cpp/dev/fullscreen_dev.h',
+ 'cpp/dev/graphics_2d_dev.cc',
+ 'cpp/dev/graphics_2d_dev.h',
'cpp/dev/ime_input_event_dev.cc',
'cpp/dev/ime_input_event_dev.h',
'cpp/dev/memory_dev.cc',
@@ -239,6 +241,8 @@
'cpp/dev/video_decoder_client_dev.h',
'cpp/dev/video_decoder_dev.cc',
'cpp/dev/video_decoder_dev.h',
+ 'cpp/dev/view_dev.cc',
+ 'cpp/dev/view_dev.h',
'cpp/dev/widget_client_dev.cc',
'cpp/dev/widget_client_dev.h',
'cpp/dev/widget_dev.cc',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index f801276..ffed09f 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -15,6 +15,7 @@
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h"
+#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
#include "ppapi/c/dev/ppb_keyboard_input_event_dev.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
@@ -27,6 +28,7 @@
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/dev/ppb_video_capture_dev.h"
+#include "ppapi/c/dev/ppb_view_dev.h"
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_audio.h"
#include "ppapi/c/ppb_core.h"
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 69005e5..755d353 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -144,6 +144,8 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::ViewData)
IPC_STRUCT_TRAITS_MEMBER(is_fullscreen)
IPC_STRUCT_TRAITS_MEMBER(is_page_visible)
IPC_STRUCT_TRAITS_MEMBER(clip_rect)
+ IPC_STRUCT_TRAITS_MEMBER(device_scale)
+ IPC_STRUCT_TRAITS_MEMBER(css_scale)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(PP_TouchPoint)
@@ -858,6 +860,9 @@ IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBGraphics2D_ReplaceContents,
ppapi::HostResource /* image_data */)
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBGraphics2D_Flush,
ppapi::HostResource /* graphics_2d */)
+IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBGraphics2D_Dev_SetScale,
+ ppapi::HostResource /* graphics_2d */,
+ float /* scale */)
#if !defined(OS_NACL)
// PPB_Graphics3D.
diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.cc b/ppapi/proxy/ppb_graphics_2d_proxy.cc
index 2fc34cc..909abc1 100644
--- a/ppapi/proxy/ppb_graphics_2d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_2d_proxy.cc
@@ -43,6 +43,8 @@ class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API {
void Scroll(const PP_Rect* clip_rect,
const PP_Point* amount);
void ReplaceContents(PP_Resource image_data);
+ bool SetScale(float scale);
+ float GetScale();
int32_t Flush(scoped_refptr<TrackedCallback> callback);
// Notification that the host has sent an ACK for a pending Flush.
@@ -57,6 +59,7 @@ class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API {
PP_Size size_;
PP_Bool is_always_opaque_;
+ float scale_;
// In the plugin, this is the current callback set for Flushes. When the
// pointer is non-NULL, we're waiting for a flush ACK.
@@ -70,7 +73,8 @@ Graphics2D::Graphics2D(const HostResource& host_resource,
PP_Bool is_always_opaque)
: Resource(OBJECT_IS_PROXY, host_resource),
size_(size),
- is_always_opaque_(is_always_opaque) {
+ is_always_opaque_(is_always_opaque),
+ scale_(1.0f) {
}
Graphics2D::~Graphics2D() {
@@ -126,6 +130,19 @@ void Graphics2D::ReplaceContents(PP_Resource image_data) {
kApiID, host_resource(), image_object->host_resource()));
}
+bool Graphics2D::SetScale(float scale) {
+ if (scale <= 0.0f)
+ return false;
+ GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Dev_SetScale(
+ kApiID, host_resource(), scale));
+ scale_ = scale;
+ return true;
+}
+
+float Graphics2D::GetScale() {
+ return scale_;
+}
+
int32_t Graphics2D::Flush(scoped_refptr<TrackedCallback> callback) {
if (TrackedCallback::IsPending(current_flush_callback_))
return PP_ERROR_INPROGRESS; // Can't have >1 flush pending.
@@ -178,6 +195,8 @@ bool PPB_Graphics2D_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgReplaceContents)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Flush,
OnHostMsgFlush)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Dev_SetScale,
+ OnHostMsgSetScale)
IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics2D_FlushACK,
OnPluginMsgFlushACK)
@@ -239,6 +258,14 @@ void PPB_Graphics2D_Proxy::OnHostMsgFlush(const HostResource& graphics_2d) {
enter.SetResult(enter.object()->Flush(enter.callback()));
}
+void PPB_Graphics2D_Proxy::OnHostMsgSetScale(const HostResource& graphics_2d,
+ float scale) {
+ EnterHostFromHostResource<PPB_Graphics2D_API> enter(graphics_2d);
+ if (enter.failed())
+ return;
+ enter.object()->SetScale(scale);
+}
+
void PPB_Graphics2D_Proxy::OnPluginMsgFlushACK(
const HostResource& host_resource,
int32_t pp_error) {
diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.h b/ppapi/proxy/ppb_graphics_2d_proxy.h
index f7afb64..45043ce 100644
--- a/ppapi/proxy/ppb_graphics_2d_proxy.h
+++ b/ppapi/proxy/ppb_graphics_2d_proxy.h
@@ -55,6 +55,8 @@ class PPB_Graphics2D_Proxy : public InterfaceProxy {
void OnHostMsgReplaceContents(const HostResource& graphics_2d,
const HostResource& image_data);
void OnHostMsgFlush(const HostResource& graphics_2d);
+ void OnHostMsgSetScale(const HostResource& graphics_2d,
+ float scale);
// Host->plugin message handlers.
void OnPluginMsgFlushACK(const HostResource& graphics_2d,
diff --git a/ppapi/shared_impl/ppb_view_shared.cc b/ppapi/shared_impl/ppb_view_shared.cc
index 1e024a6..54659a3 100644
--- a/ppapi/shared_impl/ppb_view_shared.cc
+++ b/ppapi/shared_impl/ppb_view_shared.cc
@@ -24,7 +24,9 @@ bool ViewData::Equals(const ViewData& other) const {
clip_rect.point.x == other.clip_rect.point.x &&
clip_rect.point.y == other.clip_rect.point.y &&
clip_rect.size.width == other.clip_rect.size.width &&
- clip_rect.size.height == other.clip_rect.size.height;
+ clip_rect.size.height == other.clip_rect.size.height &&
+ device_scale == other.device_scale &&
+ css_scale == other.css_scale;
}
PPB_View_Shared::PPB_View_Shared(ResourceObjectType type,
diff --git a/ppapi/shared_impl/ppb_view_shared.h b/ppapi/shared_impl/ppb_view_shared.h
index 59b8e72..e3d41ac 100644
--- a/ppapi/shared_impl/ppb_view_shared.h
+++ b/ppapi/shared_impl/ppb_view_shared.h
@@ -25,6 +25,8 @@ struct PPAPI_SHARED_EXPORT ViewData {
bool is_fullscreen;
bool is_page_visible;
PP_Rect clip_rect;
+ float device_scale;
+ float css_scale;
};
class PPAPI_SHARED_EXPORT PPB_View_Shared
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index 8dd43df..8dfa6cd 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -22,6 +22,7 @@
#include "ppapi/c/dev/ppb_find_dev.h"
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
+#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
#include "ppapi/c/dev/ppb_layer_compositor_dev.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
@@ -44,6 +45,7 @@
#include "ppapi/c/dev/ppp_selection_dev.h"
#include "ppapi/c/dev/ppp_text_input_dev.h"
#include "ppapi/c/dev/ppp_video_decoder_dev.h"
+#include "ppapi/c/dev/ppb_view_dev.h"
#include "ppapi/c/dev/ppp_widget_dev.h"
#include "ppapi/c/dev/ppp_zoom_dev.h"
#include "ppapi/c/pp_bool.h"
diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h
index 7a18802..6abe681 100644
--- a/ppapi/tests/all_cpp_includes.h
+++ b/ppapi/tests/all_cpp_includes.h
@@ -20,6 +20,7 @@
#include "ppapi/cpp/dev/find_dev.h"
#include "ppapi/cpp/dev/font_dev.h"
#include "ppapi/cpp/dev/fullscreen_dev.h"
+#include "ppapi/cpp/dev/graphics_2d_dev.h"
#include "ppapi/cpp/dev/ime_input_event_dev.h"
#include "ppapi/cpp/dev/memory_dev.h"
#include "ppapi/cpp/dev/printing_dev.h"
@@ -30,6 +31,7 @@
#include "ppapi/cpp/dev/text_input_dev.h"
#include "ppapi/cpp/dev/url_util_dev.h"
#include "ppapi/cpp/dev/video_decoder_dev.h"
+#include "ppapi/cpp/dev/view_dev.h"
#include "ppapi/cpp/dev/widget_client_dev.h"
#include "ppapi/cpp/dev/widget_dev.h"
#include "ppapi/cpp/dev/zoom_dev.h"
diff --git a/ppapi/tests/test_graphics_2d.cc b/ppapi/tests/test_graphics_2d.cc
index 86de406..f8f23f5 100644
--- a/ppapi/tests/test_graphics_2d.cc
+++ b/ppapi/tests/test_graphics_2d.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,6 +11,7 @@
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_graphics_2d.h"
#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/dev/graphics_2d_dev.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/instance.h"
@@ -51,6 +52,7 @@ void TestGraphics2D::RunTests(const std::string& filter) {
RUN_TEST_FORCEASYNC_AND_NOT(Scroll, filter);
RUN_TEST_FORCEASYNC_AND_NOT(Replace, filter);
RUN_TEST_FORCEASYNC_AND_NOT(Flush, filter);
+ RUN_TEST(Dev, filter);
}
void TestGraphics2D::QuitMessageLoop() {
@@ -628,3 +630,42 @@ std::string TestGraphics2D::TestFlush() {
PASS();
}
+
+std::string TestGraphics2D::TestDev() {
+ // Tests GetScale/SetScale via the Graphics2DDev C++ wrapper
+ const int w=20, h=16;
+ const float scale=1.0f/2.0f;
+ pp::Graphics2D dc(instance_, pp::Size(w, h), false);
+ if (dc.is_null())
+ return "Failure creating a boring device";
+ pp::Graphics2DDev dc_dev(dc);
+ if (dc_dev.GetScale() != 1.0f)
+ return "GetScale returned unexpected value before SetScale";
+ if (!dc_dev.SetScale(scale))
+ return "SetScale failed";
+ if (dc_dev.GetScale() != scale)
+ return "GetScale mismatch with prior SetScale";
+ // Try setting a few invalid scale factors. Ensure that we catch these errors
+ // and don't change the actual scale
+ if (dc_dev.SetScale(-1.0f))
+ return "SetScale(-1f) did not fail";
+ if (dc_dev.SetScale(0.0f))
+ return "SetScale(0.0f) did not fail";
+ if (dc_dev.GetScale() != scale)
+ return "SetScale with invalid parameter overwrote the scale";
+
+ // Verify that the context has the specified number of pixels, despite the
+ // non-identity scale
+ PP_Size size;
+ size.width = -1;
+ size.height = -1;
+ PP_Bool is_always_opaque = PP_FALSE;
+ if (!graphics_2d_interface_->Describe(dc_dev.pp_resource(), &size,
+ &is_always_opaque))
+ return "Describe failed";
+ if (size.width != w || size.height != h ||
+ is_always_opaque != PP_FromBool(false))
+ return "Mismatch of data.";
+
+ PASS();
+}
diff --git a/ppapi/tests/test_graphics_2d.h b/ppapi/tests/test_graphics_2d.h
index 86eb9a8..b5165e2 100644
--- a/ppapi/tests/test_graphics_2d.h
+++ b/ppapi/tests/test_graphics_2d.h
@@ -78,6 +78,7 @@ class TestGraphics2D : public TestCase {
std::string TestScroll();
std::string TestReplace();
std::string TestFlush();
+ std::string TestDev();
// Used by the tests that access the C API directly.
const PPB_Graphics2D* graphics_2d_interface_;
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h
index b606823..a204d22 100644
--- a/ppapi/thunk/interfaces_ppb_public_dev.h
+++ b/ppapi/thunk/interfaces_ppb_public_dev.h
@@ -42,6 +42,8 @@ PROXIED_IFACE(PPB_FileChooser, PPB_FILECHOOSER_DEV_INTERFACE_0_5,
PPB_FileChooser_Dev_0_5)
PROXIED_IFACE(PPB_FileChooser, PPB_FILECHOOSER_DEV_INTERFACE_0_6,
PPB_FileChooser_Dev_0_6)
+PROXIED_IFACE(NoAPIName, PPB_GRAPHICS2D_DEV_INTERFACE_0_1,
+ PPB_Graphics2D_Dev_0_1)
PROXIED_IFACE(PPB_Instance, PPB_CHAR_SET_DEV_INTERFACE_0_4, PPB_CharSet_Dev_0_4)
PROXIED_IFACE(PPB_Instance, PPB_CONSOLE_DEV_INTERFACE_0_1, PPB_Console_Dev_0_1)
PROXIED_IFACE(PPB_Instance, PPB_URLUTIL_DEV_INTERFACE_0_6, PPB_URLUtil_Dev_0_6)
@@ -69,6 +71,8 @@ PROXIED_IFACE(PPB_VideoDecoder, PPB_VIDEODECODER_DEV_INTERFACE_0_16,
PPB_VideoDecoder_Dev_0_16)
UNPROXIED_IFACE(PPB_VideoLayer, PPB_VIDEOLAYER_DEV_INTERFACE_0_1,
PPB_VideoLayer_Dev_0_1)
+PROXIED_IFACE(NoAPIName, PPB_VIEW_DEV_INTERFACE_0_1,
+ PPB_View_Dev_0_1)
UNPROXIED_IFACE(PPB_WebSocket, PPB_WEBSOCKET_INTERFACE_1_0,
PPB_WebSocket_1_0)
UNPROXIED_IFACE(PPB_Widget, PPB_WIDGET_DEV_INTERFACE_0_3, PPB_Widget_Dev_0_3)
diff --git a/ppapi/thunk/ppb_graphics_2d_api.h b/ppapi/thunk/ppb_graphics_2d_api.h
index 320297b..80c8c78 100644
--- a/ppapi/thunk/ppb_graphics_2d_api.h
+++ b/ppapi/thunk/ppb_graphics_2d_api.h
@@ -28,6 +28,8 @@ class PPB_Graphics2D_API {
const PP_Point* amount) = 0;
virtual void ReplaceContents(PP_Resource image_data) = 0;
virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) = 0;
+ virtual bool SetScale(float scale) = 0;
+ virtual float GetScale() = 0;
};
} // namespace thunk
diff --git a/ppapi/thunk/ppb_graphics_2d_thunk.cc b/ppapi/thunk/ppb_graphics_2d_thunk.cc
index 1d76bba..4deabc1 100644
--- a/ppapi/thunk/ppb_graphics_2d_thunk.cc
+++ b/ppapi/thunk/ppb_graphics_2d_thunk.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_graphics_2d.h"
@@ -78,6 +79,20 @@ int32_t Flush(PP_Resource graphics_2d, PP_CompletionCallback callback) {
return enter.SetResult(enter.object()->Flush(enter.callback()));
}
+PP_Bool SetScale(PP_Resource graphics_2d, float scale) {
+ EnterGraphics2D enter(graphics_2d, true);
+ if (enter.failed())
+ return PP_FALSE;
+ return PP_FromBool(enter.object()->SetScale(scale));
+}
+
+float GetScale(PP_Resource graphics_2d) {
+ EnterGraphics2D enter(graphics_2d, true);
+ if (enter.failed())
+ return 0.0f;
+ return enter.object()->GetScale();
+}
+
const PPB_Graphics2D g_ppb_graphics_2d_thunk = {
&Create,
&IsGraphics2D,
@@ -88,11 +103,20 @@ const PPB_Graphics2D g_ppb_graphics_2d_thunk = {
&Flush
};
+const PPB_Graphics2D_Dev g_ppb_graphics_2d_dev_thunk = {
+ &SetScale,
+ &GetScale
+};
+
} // namespace
const PPB_Graphics2D_1_0* GetPPB_Graphics2D_1_0_Thunk() {
return &g_ppb_graphics_2d_thunk;
}
+const PPB_Graphics2D_Dev_0_1* GetPPB_Graphics2D_Dev_0_1_Thunk() {
+ return &g_ppb_graphics_2d_dev_thunk;
+}
+
} // namespace thunk
} // namespace ppapi
diff --git a/ppapi/thunk/ppb_view_thunk.cc b/ppapi/thunk/ppb_view_thunk.cc
index 874513b..ea6f624 100644
--- a/ppapi/thunk/ppb_view_thunk.cc
+++ b/ppapi/thunk/ppb_view_thunk.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ppapi/c/dev/ppb_view_dev.h"
#include "ppapi/c/ppb_view.h"
#include "ppapi/shared_impl/ppb_view_shared.h"
#include "ppapi/thunk/enter.h"
@@ -77,6 +78,20 @@ PP_Bool GetClipRect(PP_Resource resource, PP_Rect* clip) {
return PP_TRUE;
}
+float GetDeviceScale(PP_Resource resource) {
+ EnterView enter(resource, true);
+ if (enter.failed())
+ return 0.0f;
+ return enter.object()->GetData().device_scale;
+}
+
+float GetCSSScale(PP_Resource resource) {
+ EnterView enter(resource, true);
+ if (enter.failed())
+ return 0.0f;
+ return enter.object()->GetData().css_scale;
+}
+
const PPB_View g_ppb_view_thunk = {
&IsView,
&GetRect,
@@ -86,11 +101,20 @@ const PPB_View g_ppb_view_thunk = {
&GetClipRect
};
+const PPB_View_Dev g_ppb_view_dev_thunk = {
+ &GetDeviceScale,
+ &GetCSSScale
+};
+
} // namespace
const PPB_View* GetPPB_View_1_0_Thunk() {
return &g_ppb_view_thunk;
}
+const PPB_View_Dev* GetPPB_View_Dev_0_1_Thunk() {
+ return &g_ppb_view_dev_thunk;
+}
+
} // namespace thunk
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 7098f70..5ce0bf2 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -26,6 +26,7 @@
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h"
+#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
#include "ppapi/c/dev/ppb_layer_compositor_dev.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
#include "ppapi/c/dev/ppb_opengles2ext_dev.h"
@@ -39,6 +40,7 @@
#include "ppapi/c/dev/ppb_video_capture_dev.h"
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
#include "ppapi/c/dev/ppb_video_layer_dev.h"
+#include "ppapi/c/dev/ppb_view_dev.h"
#include "ppapi/c/dev/ppb_widget_dev.h"
#include "ppapi/c/dev/ppb_zoom_dev.h"
#include "ppapi/c/pp_module.h"
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 6ebf2a2..9e52b1f 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -750,6 +750,9 @@ void PluginInstance::ViewChanged(const gfx::Rect& position,
view_data_.rect = PP_FromGfxRect(position);
view_data_.clip_rect = PP_FromGfxRect(clip);
+ view_data_.device_scale = container_->deviceScaleFactor();
+ view_data_.css_scale = container_->pageZoomFactor() *
+ container_->pageScaleFactor();
if (desired_fullscreen_state_ || view_data_.is_fullscreen) {
WebElement element = container_->element();
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
}
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
index 69e0f96..cec39c6 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
@@ -51,6 +51,8 @@ class PPB_Graphics2D_Impl : public ::ppapi::Resource,
virtual void ReplaceContents(PP_Resource image_data) OVERRIDE;
virtual int32_t Flush(
scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual bool SetScale(float scale) OVERRIDE;
+ virtual float GetScale() OVERRIDE;
bool ReadImageData(PP_Resource image, const PP_Point* top_left);
@@ -185,6 +187,10 @@ class PPB_Graphics2D_Impl : public ::ppapi::Resource,
// This allows us to do more optimized painting in some cases.
bool is_always_opaque_;
+ // Set to the scale between what the plugin considers to be one pixel and one
+ // DIP
+ float scale_;
+
base::WeakPtrFactory<PPB_Graphics2D_Impl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl);