| Index: ui/gfx/image/image_skia_operations.cc
|
| diff --git a/ui/gfx/image/image_skia_operations.cc b/ui/gfx/image/image_skia_operations.cc
|
| index 8a3aa12c333d43dac8f128c4f61307e644504210..397b3094c18551f3b9e3ede61108ead2e3a1b5b0 100644
|
| --- a/ui/gfx/image/image_skia_operations.cc
|
| +++ b/ui/gfx/image/image_skia_operations.cc
|
| @@ -58,6 +58,44 @@ void MatchScale(ImageSkiaRep* first, ImageSkiaRep* second) {
|
| }
|
| }
|
|
|
| +class ResizingImageSource : public ImageSkiaSource {
|
| + public:
|
| + ResizingImageSource(const ImageSkia& source,
|
| + const Size& target_size_in_dip)
|
| + : source_(source),
|
| + target_size_in_dip_(target_size_in_dip) {
|
| + DCHECK(source.width() <= 64);
|
| + DCHECK(source.height() <= 64);
|
| + DCHECK(target_size_in_dip.width() <= 64);
|
| + DCHECK(target_size_in_dip.height() <= 64);
|
| + }
|
| + virtual ~ResizingImageSource() {}
|
| +
|
| + // gfx::ImageSkiaSource overrides:
|
| + virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE {
|
| + const ImageSkiaRep& image_rep = source_.GetRepresentation(scale_factor);
|
| + if (image_rep.GetWidth() == target_size_in_dip_.width() &&
|
| + image_rep.GetHeight() == target_size_in_dip_.height()) {
|
| + return image_rep;
|
| + }
|
| +
|
| + const float scale = image_rep.GetScale();;
|
| + const Size target_pixel_size(target_size_in_dip_.Scale(scale));
|
| + const SkBitmap resized = skia::ImageOperations::Resize(
|
| + image_rep.sk_bitmap(),
|
| + skia::ImageOperations::RESIZE_BEST,
|
| + target_pixel_size.width(),
|
| + target_pixel_size.height());
|
| + return ImageSkiaRep(resized, image_rep.scale_factor());
|
| + }
|
| +
|
| +private:
|
| + const ImageSkia source_;
|
| + const Size target_size_in_dip_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ResizingImageSource);
|
| +};
|
| +
|
| class BlendingImageSource : public gfx::ImageSkiaSource {
|
| public:
|
| BlendingImageSource(const ImageSkia& first,
|
| @@ -134,7 +172,7 @@ class TiledImageSource : public gfx::ImageSkiaSource {
|
| }
|
|
|
| private:
|
| - const ImageSkia& source_;
|
| + const ImageSkia source_;
|
| const int src_x_;
|
| const int src_y_;
|
| const int dst_w_;
|
| @@ -143,6 +181,29 @@ class TiledImageSource : public gfx::ImageSkiaSource {
|
| DISALLOW_COPY_AND_ASSIGN(TiledImageSource);
|
| };
|
|
|
| +class HSLImageSource: public gfx::ImageSkiaSource {
|
| + public:
|
| + HSLImageSource(const ImageSkia& image,
|
| + const color_utils::HSL& hsl_shift)
|
| + : image_(image),
|
| + hsl_shift_(hsl_shift) {
|
| + }
|
| +
|
| + // gfx::ImageSkiaSource overrides:
|
| + virtual ImageSkiaRep GetImageForScale(ui::ScaleFactor scale_factor) OVERRIDE {
|
| + ImageSkiaRep image_rep = image_.GetRepresentation(scale_factor);
|
| + return gfx::ImageSkiaRep(
|
| + SkBitmapOperations::CreateHSLShiftedBitmap(image_rep.sk_bitmap(),
|
| + hsl_shift_), image_rep.scale_factor());
|
| + }
|
| +
|
| + private:
|
| + const gfx::ImageSkia image_;
|
| + const color_utils::HSL hsl_shift_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(HSLImageSource);
|
| +};
|
| +
|
| // ResizeSource resizes relevant image reps in |source| to |target_dip_size|
|
| // for requested scale factors.
|
| class ResizeSource : public ImageSkiaSource {
|
| @@ -235,6 +296,13 @@ ImageSkia ImageSkiaOperations::CreateTiledImage(const ImageSkia& source,
|
| }
|
|
|
| // static
|
| +ImageSkia ImageSkiaOperations::CreateHSLShiftedImage(
|
| + const ImageSkia& image,
|
| + const color_utils::HSL& hsl_shift) {
|
| + return ImageSkia(new HSLImageSource(image, hsl_shift), image.size());
|
| +}
|
| +
|
| +// static
|
| ImageSkia ImageSkiaOperations::CreateResizedImage(const ImageSkia& source,
|
| const Size& target_dip_size) {
|
| return ImageSkia(new ResizeSource(source, target_dip_size), target_dip_size);
|
|
|