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

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

Issue 2209053004: Enhance chrome.app.window API with icon property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review v5 Created 4 years, 4 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
« no previous file with comments | « ui/gfx/image/image_skia_operations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/gfx/image/image_skia_operations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698