Index: ppapi/cpp/graphics_2d.h |
diff --git a/ppapi/cpp/graphics_2d.h b/ppapi/cpp/graphics_2d.h |
index 427ea486d88e14d7c127e1d14b353612ab65f0b5..c6a23905d6f3e0e41dd82570bf1a1457d1215a5e 100644 |
--- a/ppapi/cpp/graphics_2d.h |
+++ b/ppapi/cpp/graphics_2d.h |
@@ -41,7 +41,7 @@ class Graphics2D : public Resource { |
/// associated. |
/// |
/// @param[in] size The size of the 2D graphics context in the browser, |
- /// measured in device pixels. |
+ /// measured in pixels. See <code>SetScale()</code> for more information. |
/// |
/// @param[in] is_always_opaque Set the <code>is_always_opaque</code> flag |
/// to true if you know that you will be painting only opaque data to this |
@@ -74,7 +74,7 @@ class Graphics2D : public Resource { |
/// Getter function for returning size of the 2D graphics context. |
/// |
- /// @return The size of the 2D graphics context measured in device pixels. |
+ /// @return The size of the 2D graphics context measured in pixels. |
const Size& size() const { return size_; } |
/// PaintImageData() enqueues a paint command of the given image into |
@@ -260,6 +260,30 @@ class Graphics2D : public Resource { |
// for it. |
int32_t Flush(const CompletionCallback& cc); |
+ /// 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. The default scale for a graphics context |
+ /// is 1.0. |
+ float GetScale(); |
+ |
private: |
Size size_; |
}; |