Index: ui/gfx/canvas.h |
=================================================================== |
--- ui/gfx/canvas.h (revision 147935) |
+++ ui/gfx/canvas.h (working copy) |
@@ -99,6 +99,12 @@ |
// Creates an empty canvas with scale factor of 1x. |
Canvas(); |
+ // Creates canvas with provided DIP |size| and a scale factor of 1x. |
+ // If this canvas is not opaque, it's explicitly cleared to transparent before |
+ // being returned. |
+ // TODO(pkotwicz): Remove this constructor. |
+ Canvas(const gfx::Size& size, bool is_opaque); |
+ |
// Creates canvas with provided DIP |size| and |scale_factor|. |
// If this canvas is not opaque, it's explicitly cleared to transparent before |
// being returned. |
@@ -110,14 +116,14 @@ |
// provided |image_rep|, and draws the |image_rep| into it. |
Canvas(const gfx::ImageSkiaRep& image_rep, bool is_opaque); |
+ // Sets scale factor to |scale_factor|. |
+ // Only scales canvas if |scale_canvas| is true. |
+ Canvas(SkCanvas* canvas, |
+ ui::ScaleFactor scale_factor, |
+ bool scale_canvas); |
+ |
virtual ~Canvas(); |
- // Creates a gfx::Canvas backed by an |sk_canvas| with |scale_factor|. |
- // |sk_canvas| is assumed to be already scaled based on |scale_factor| |
- // so no additional scaling is applied. |
- static Canvas* CreateCanvasWithoutScaling(SkCanvas* sk_canvas, |
- ui::ScaleFactor scale_factor); |
- |
// Recreates the backing platform canvas with DIP |size| and |scale_factor|. |
// If the canvas is not opaque, it is explicitly cleared. |
// This method is public so that canvas_skia_paint can recreate the platform |
@@ -166,8 +172,13 @@ |
int x, int y, int w, int h, |
int flags); |
+ // Extracts a bitmap from the contents of this canvas. |
+ // TODO(pkotwicz): Remove ExtractBitmap once all callers use |
+ // ExtractImageSkiaRep instead. |
+ SkBitmap ExtractBitmap() const; |
+ |
// Extracts an ImageSkiaRep from the contents of this canvas. |
- gfx::ImageSkiaRep ExtractImageRep() const; |
+ gfx::ImageSkiaRep ExtractImageSkiaRep() const; |
// Draws a dashed rectangle of the specified color. |
void DrawDashedRect(const gfx::Rect& rect, SkColor color); |
@@ -377,12 +388,16 @@ |
ui::ScaleFactor scale_factor() const { return scale_factor_; } |
private: |
- Canvas(SkCanvas* canvas, ui::ScaleFactor scale_factor); |
- |
// Test whether the provided rectangle intersects the current clip rect. |
bool IntersectsClipRectInt(int x, int y, int w, int h); |
bool IntersectsClipRect(const gfx::Rect& rect); |
+ // Sets the canvas' scale factor to |scale_factor|. This affects |
+ // the scale factor at which drawing bitmaps occurs and the scale factor of |
+ // the image rep returned by Canvas::ExtractImageSkiaRep(). |
+ // If |scale_canvas| is true, scales the canvas by |scale_factor|. |
+ void ApplyScaleFactor(ui::ScaleFactor scale_factor, bool scale_canvas); |
+ |
// Returns the image rep which best matches the canvas |scale_factor_|. |
// Returns a null image rep if |image| contains no image reps. |
// Builds mip map for returned image rep if necessary. |
@@ -395,14 +410,18 @@ |
float user_defined_scale_factor_x, |
float user_defined_scale_factor_y) const; |
+ scoped_ptr<skia::PlatformCanvas> owned_canvas_; |
+ SkCanvas* canvas_; |
+ |
+ // True if the scale factor scales the canvas and the inverse |
+ // canvas scale should be applied when the destructor is called. |
+ bool scale_factor_scales_canvas_; |
+ |
// The device scale factor at which drawing on this canvas occurs. |
// An additional scale can be applied via Canvas::Scale(). However, |
// Canvas::Scale() does not affect |scale_factor_|. |
ui::ScaleFactor scale_factor_; |
- scoped_ptr<skia::PlatformCanvas> owned_canvas_; |
- SkCanvas* canvas_; |
- |
DISALLOW_COPY_AND_ASSIGN(Canvas); |
}; |