Chromium Code Reviews| 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 f523abf54ecec41f722fe4d94d95089be90570ee..89c4a6fe69cfd4972f53d77946b543264cbf8d1d 100644 |
| --- a/ui/gfx/image/image_skia_operations.cc |
| +++ b/ui/gfx/image/image_skia_operations.cc |
| @@ -423,6 +423,25 @@ class RotatedSource : public ImageSkiaSource { |
| DISALLOW_COPY_AND_ASSIGN(RotatedSource); |
| }; |
| +// MirroredSource generates image reps that are mirrors of those in |source|. |
| +class MirroredSource : public ImageSkiaSource { |
|
tapted
2016/01/14 23:43:50
For RTL, another approach is to flip the canvas wh
karandeepb
2016/01/18 00:31:18
Done.
|
| + public: |
| + MirroredSource(const ImageSkia& source) : source_(source) {} |
| + ~MirroredSource() override {} |
| + |
| + // gfx::ImageSkiaSource overrides: |
| + ImageSkiaRep GetImageForScale(float scale) override { |
| + const ImageSkiaRep& image_rep = source_.GetRepresentation(scale); |
| + const SkBitmap mirrored_bitmap = |
| + SkBitmapOperations::CreateMirroredBitmap(image_rep.sk_bitmap()); |
| + return ImageSkiaRep(mirrored_bitmap, image_rep.scale()); |
| + } |
| + |
| + private: |
| + const ImageSkia source_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MirroredSource); |
| +}; |
| } // namespace |
| @@ -548,4 +567,12 @@ ImageSkia ImageSkiaOperations::CreateRotatedImage( |
| } |
| +// static |
| +ImageSkia ImageSkiaOperations::CreateMirroredImage(const ImageSkia& source) { |
| + if (source.isNull()) |
| + return ImageSkia(); |
| + |
| + return ImageSkia(new MirroredSource(source), source.size()); |
| +} |
| + |
| } // namespace gfx |