Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Unified Diff: ui/gfx/image/image_skia_operations.cc

Issue 1585013002: MacViews: Use Cocoa folder icons in tree views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698