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

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 v4 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
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
« extensions/browser/app_window/app_window.cc ('K') | « 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