diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 22:34:00 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-14 22:34:00 +0000 |
commit | a68c660bd1bcfa93d9759bdac2b384587e911c04 (patch) | |
tree | a86770745fca2a96f61e1ef9499417c073993748 /ui/gfx/canvas.h | |
parent | 75af2a115ef599f4c26cd47a8cc336124ecffe52 (diff) | |
download | chromium_src-a68c660bd1bcfa93d9759bdac2b384587e911c04.zip chromium_src-a68c660bd1bcfa93d9759bdac2b384587e911c04.tar.gz chromium_src-a68c660bd1bcfa93d9759bdac2b384587e911c04.tar.bz2 |
Revert 136332 - This patch makes ImageSkia more like SkBitmap. The goal is to make swapping from SkBitmap to ImageSkia easier.
Notable changes:
- ImageSkia can be cheaply copied
- Added extractSubset, will remove after SkBitmaps have been converted to ImageSkia
- Modified API to look more like SkBitmap
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=136304
Review URL: https://chromiumcodereview.appspot.com/10245003
TBR=pkotwicz@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10389132
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136995 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/canvas.h')
-rw-r--r-- | ui/gfx/canvas.h | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/ui/gfx/canvas.h b/ui/gfx/canvas.h index 69f402b..7653f39 100644 --- a/ui/gfx/canvas.h +++ b/ui/gfx/canvas.h @@ -12,7 +12,6 @@ #include "base/memory/scoped_ptr.h" #include "base/string16.h" #include "skia/ext/platform_canvas.h" -#include "ui/gfx/image/image_skia.h" #include "ui/gfx/native_widget_types.h" class SkBitmap; @@ -241,43 +240,47 @@ class UI_EXPORT Canvas { // Draws the given path using the given |paint| parameters. void DrawPath(const SkPath& path, const SkPaint& paint); - // Draws an image with the origin at the specified location. The upper left + // Draws a bitmap with the origin at the specified location. The upper left // corner of the bitmap is rendered at the specified location. - // Parameters are specified relative to current canvas scale not in pixels. - // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. - void DrawBitmapInt(const gfx::ImageSkia&, int x, int y); + void DrawBitmapInt(const SkBitmap& bitmap, int x, int y); - // Draws an image with the origin at the specified location, using the + // Draws a bitmap with the origin at the specified location, using the // specified paint. The upper left corner of the bitmap is rendered at the // specified location. - // Parameters are specified relative to current canvas scale not in pixels. - // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. - void DrawBitmapInt(const gfx::ImageSkia& image, + void DrawBitmapInt(const SkBitmap& bitmap, int x, int y, const SkPaint& paint); - // Draws a portion of an image in the specified location. The src parameters + // Draws a portion of a bitmap in the specified location. The src parameters // correspond to the region of the bitmap to draw in the region defined // by the dest coordinates. // // If the width or height of the source differs from that of the destination, - // the image will be scaled. When scaling down, a mipmap will be generated. - // Set |filter| to use filtering for images, otherwise the nearest-neighbor - // algorithm is used for resampling. + // the bitmap will be scaled. When scaling down, it is highly recommended + // that you call buildMipMap(false) on your bitmap to ensure that it has + // a mipmap, which will result in much higher-quality output. Set |filter| + // to use filtering for bitmaps, otherwise the nearest-neighbor algorithm + // is used for resampling. // // An optional custom SkPaint can be provided. - // Parameters are specified relative to current canvas scale not in pixels. - // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. - void DrawBitmapInt(const gfx::ImageSkia& image, + void DrawBitmapInt(const SkBitmap& bitmap, int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, int dest_w, int dest_h, bool filter); - void DrawBitmapInt(const gfx::ImageSkia& image, + void DrawBitmapInt(const SkBitmap& bitmap, int src_x, int src_y, int src_w, int src_h, int dest_x, int dest_y, int dest_w, int dest_h, bool filter, const SkPaint& paint); + // TODO(pkotwicz): make this function private once gfx::ImageSkia stops + // calling this method. + void DrawBitmapFloat(const SkBitmap& bitmap, + float src_x, float src_y, float src_w, float src_h, + float dest_x, float dest_y, float dest_w, float dest_h, + bool filter, + const SkPaint& paint); + // Draws text with the specified color, font and location. The text is // aligned to the left, vertically centered, clipped to the region. If the // text is too big, it is truncated and '...' is added to the end. @@ -312,11 +315,9 @@ class UI_EXPORT Canvas { void DrawFocusRect(const gfx::Rect& rect); // Tiles the image in the specified region. - // Parameters are specified relative to current canvas scale not in pixels. - // Thus, |x| is 2 pixels if canvas scale = 2 & |x| = 1. - void TileImageInt(const gfx::ImageSkia& image, + void TileImageInt(const SkBitmap& bitmap, int x, int y, int w, int h); - void TileImageInt(const gfx::ImageSkia& image, + void TileImageInt(const SkBitmap& bitmap, int src_x, int src_y, int dest_x, int dest_y, int w, int h); @@ -353,19 +354,6 @@ class UI_EXPORT Canvas { bool IntersectsClipRectInt(int x, int y, int w, int h); bool IntersectsClipRect(const gfx::Rect& rect); - // Returns the bitmap whose density best matches the current canvas scale. - // Returns a null bitmap if |image| contains no bitmaps. - // |bitmap_scale_factor| is set to the scale factor of the returned bitmap. - // Builds mip map for returned bitmap if necessary. - // - // An optional additional user defined scale can be provided. - const SkBitmap& GetBitmapToPaint(const gfx::ImageSkia& image, - float* bitmap_scale_factor) const; - const SkBitmap& GetBitmapToPaint(const gfx::ImageSkia& image, - float user_defined_scale_factor_x, - float user_defined_scale_factor_y, - float* bitmap_scale_factor) const; - #if defined(OS_WIN) // Draws text with the specified color, font and location. The text is // aligned to the left, vertically centered, clipped to the region. If the |