1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef PPAPI_CPP_DEV_GRAPHICS_2D_DEV_H_ 6 #define PPAPI_CPP_DEV_GRAPHICS_2D_DEV_H_ 7 8 #include "ppapi/cpp/graphics_2d.h" 9 10 #include "ppapi/c/dev/ppb_graphics_2d_dev.h" 11 12 namespace pp { 13 14 class Point; 15 16 // Graphics2DDev is a version of Graphics2D that exposes under-development APIs 17 // for HiDPI 18 class Graphics2D_Dev : public Graphics2D { 19 public: 20 /// Default constructor for creating an is_null() 21 /// <code>Graphics2D_Dev</code> object. 22 Graphics2D_Dev() : Graphics2D() {} 23 24 // Constructor for creating a <code>Graphics2DDev</code> object from an 25 // existing <code>Graphics2D</code> object. 26 Graphics2D_Dev(const Graphics2D& other) : Graphics2D(other) {} 27 28 virtual ~Graphics2D_Dev() {} 29 30 /// Returns true if SetScale and GetScale are supported. False if not. 31 static bool SupportsScale(); 32 33 /// SetScale() sets the scale factor that will be applied when painting the 34 /// graphics context onto the output device. Typically, if rendering at device 35 /// resolution is desired, the context would be created with the width and 36 /// height scaled up by the view's GetDeviceScale and SetScale called with a 37 /// scale of 1.0 / GetDeviceScale(). For example, if the view resource passed 38 /// to DidChangeView has a rectangle of (w=200, h=100) and a device scale of 39 /// 2.0, one would call Create with a size of (w=400, h=200) and then call 40 /// SetScale with 0.5. One would then treat each pixel in the context as a 41 /// single device pixel. 42 /// 43 /// @param[in] scale The scale to apply when painting. 44 /// 45 /// @return Returns <code>true</code> on success or <code>false</code> 46 /// if the resource is invalid or the scale factor is 0 or less. 47 bool SetScale(float scale); 48 49 /// GetScale() gets the scale factor that will be applied when painting the 50 /// graphics context onto the output device. 51 /// 52 /// @return Returns the scale factor for the graphics context. If the resource 53 /// is invalid, 0.0 will be returned. 54 float GetScale(); 55 56 /// Set the offset into the plugin element at which the graphics context is 57 /// painted. This allows a portion of the plugin element to be painted to. 58 /// The new offset will only be applied after Flush() has been called. 59 /// 60 /// @param[in] resource A <code>Graphics2D</code> context resource. 61 /// @param[in] offset The offset at which the context should be painted. 62 void SetOffset(const pp::Point& offset); 63 64 /// Sets the resize mode for the graphics context. When a plugin element is 65 /// resized in the DOM, it takes time for the plugin to update the graphics 66 /// context in the renderer. These options affect how the existing context is 67 /// displayed until the backing store is updated by the plugin. 68 /// 69 ///@param[in] resource A <code>Graphics2D</code> context resource. 70 ///@param[in] resize_mode The resize mode to change this context to. 71 void SetResizeMode(PP_Graphics2D_Dev_ResizeMode resize_mode); 72 }; 73 74 } // namespace pp 75 76 #endif // PPAPI_CPP_DEV_GRAPHICS_2D_DEV_H_ 77