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

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 v2 + Badge Icon 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..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
« ui/gfx/image/image_skia_operations.h ('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