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..b118c24243712c8a8b03bc02cad89fbaf3dd18c9 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 ImageWithBadgeSource : public gfx::CanvasImageSource { |
+ public: |
+ ImageWithBadgeSource(const ImageSkia& first, const ImageSkia& second) |
+ : gfx::CanvasImageSource(first.size(), false /* is opaque */), |
+ first_(first), |
+ second_(second) {} |
+ |
+ ~ImageWithBadgeSource() override {} |
+ |
+ // gfx::CanvasImageSource override. |
+ void Draw(Canvas* canvas) override { |
+ canvas->DrawImageInt(first_, 0, 0); |
+ canvas->DrawImageInt(second_, (first_.width() - second_.width()), |
+ (first_.height() - second_.height())); |
+ } |
+ |
+ private: |
+ const ImageSkia first_; |
+ const ImageSkia second_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ImageWithBadgeSource); |
+}; |
} // namespace |
@@ -548,4 +570,13 @@ ImageSkia ImageSkiaOperations::CreateRotatedImage( |
} |
+// static |
+ImageSkia ImageSkiaOperations::CreateImageWithBadge(const ImageSkia& first, |
+ const ImageSkia& second) { |
+ if (first.isNull() || second.isNull()) |
+ return ImageSkia(); |
stevenjb
2016/08/08 22:26:46
It seems reasonable that if 'first' (the icon) is
Andra Paraschiv
2016/08/09 11:34:47
Yes, we could do this way. Also, should we return
Reilly Grant (use Gerrit)
2016/08/09 19:08:45
If the icon is not yet available we should use the
Andra Paraschiv
2016/08/10 14:19:57
Done.
|
+ |
+ return ImageSkia(new ImageWithBadgeSource(first, second), first.size()); |
+} |
+ |
} // namespace gfx |