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 /ppapi/c | |
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 'ppapi/c')
-rw-r--r-- | ppapi/c/dev/ppb_graphics_2d_dev.h | 66 | ||||
-rw-r--r-- | ppapi/c/dev/ppb_view_dev.h | 65 |
2 files changed, 131 insertions, 0 deletions
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_ */ + |