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..0dc4c80327abbfb1d698b8ace05eaa9233080f5b 100644 |
--- a/ui/gfx/image/image_skia_operations.cc |
+++ b/ui/gfx/image/image_skia_operations.cc |
@@ -423,6 +423,28 @@ class RotatedSource : public ImageSkiaSource { |
DISALLOW_COPY_AND_ASSIGN(RotatedSource); |
}; |
+class IconWithBadgeSource : public gfx::CanvasImageSource { |
+ public: |
+ IconWithBadgeSource(const ImageSkia& icon, const ImageSkia& badge) |
+ : gfx::CanvasImageSource(icon.size(), false /* is opaque */), |
+ icon_(icon), |
+ badge_(badge) {} |
+ |
+ ~IconWithBadgeSource() override {} |
+ |
+ // gfx::CanvasImageSource override. |
+ void Draw(Canvas* canvas) override { |
+ canvas->DrawImageInt(icon_, 0, 0); |
+ canvas->DrawImageInt(badge_, (icon_.width() - badge_.width()), |
+ (icon_.height() - badge_.height())); |
+ } |
+ |
+ private: |
+ const ImageSkia icon_; |
+ const ImageSkia badge_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(IconWithBadgeSource); |
+}; |
} // namespace |
@@ -548,4 +570,16 @@ ImageSkia ImageSkiaOperations::CreateRotatedImage( |
} |
+// static |
+ImageSkia ImageSkiaOperations::CreateIconWithBadge(const ImageSkia& icon, |
+ const ImageSkia& badge) { |
+ if (icon.isNull()) |
+ return ImageSkia(); |
+ |
+ if (badge.isNull()) |
+ return icon; |
+ |
+ return ImageSkia(new IconWithBadgeSource(icon, badge), icon.size()); |
+} |
+ |
} // namespace gfx |