diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-24 16:51:16 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-24 16:51:16 +0000 |
commit | de13f35d1ffedf90f791fa5bb127697094771c2c (patch) | |
tree | fac7173e5bcc6d5f8988043d657f012d45c68e81 /ui/gfx/canvas.h | |
parent | e3301c30d83b7b9c895fba14d1f78491906c86b7 (diff) | |
download | chromium_src-de13f35d1ffedf90f791fa5bb127697094771c2c.zip chromium_src-de13f35d1ffedf90f791fa5bb127697094771c2c.tar.gz chromium_src-de13f35d1ffedf90f791fa5bb127697094771c2c.tar.bz2 |
Cleanup gfx::Canvas now that 10562027 has landed
Bug=None
Test=Compiles on Mac and CrOS
R=oshima,sky
TBR=sadrul,sail
Review URL: https://chromiumcodereview.appspot.com/10701063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/canvas.h')
-rw-r--r-- | ui/gfx/canvas.h | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h index 8256412..700d7d2 100644 --- a/ui/gfx/canvas.h +++ b/ui/gfx/canvas.h @@ -99,12 +99,6 @@ class UI_EXPORT Canvas { // 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. @@ -116,14 +110,14 @@ class UI_EXPORT Canvas { // 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 @@ -172,13 +166,8 @@ class UI_EXPORT Canvas { 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 ExtractImageSkiaRep() const; + gfx::ImageSkiaRep ExtractImageRep() const; // Draws a dashed rectangle of the specified color. void DrawDashedRect(const gfx::Rect& rect, SkColor color); @@ -388,16 +377,12 @@ class UI_EXPORT Canvas { 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. @@ -410,18 +395,14 @@ class UI_EXPORT Canvas { 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); }; |