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..068d7f6304ccee0f421f6803929edbd51e7a289c 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 (!icon.isNull() && badge.isNull()) |
|
stevenjb
2016/08/10 16:58:48
This can just be if (badge.isNull())
Andra Paraschiv
2016/08/11 07:20:55
Done.
|
| + return icon; |
| + |
| + return ImageSkia(new IconWithBadgeSource(icon, badge), icon.size()); |
| +} |
| + |
| } // namespace gfx |