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

Unified Diff: ui/message_center/views/small_image_mask.cc

Issue 308053004: Add appIconMask to notification API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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/message_center/views/small_image_mask.cc
diff --git a/ui/message_center/views/small_image_mask.cc b/ui/message_center/views/small_image_mask.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4e721dd0ee3ba70e514e9d6e1f6a8649d1e1bcfd
--- /dev/null
+++ b/ui/message_center/views/small_image_mask.cc
@@ -0,0 +1,44 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/message_center/views/small_image_mask.h"
+
+#include "ui/gfx/image/image_skia_operations.h"
+
+// Take small_iamge as the alpha channel, mask it with the foreground,
+// then add the masked foreground on top of the background
+const gfx::ImageSkia GetMaskedSmallImage(const gfx::ImageSkia& small_image) {
dewittj 2014/06/16 18:09:55 I would just move this into notification_view.cc i
liyanhou 2014/06/27 03:18:40 Done.
+ int width = small_image.width();
+ int height = small_image.height();
+
+ // Background color grey
+ const gfx::ImageSkia background = CreateImage(width, height, 163, 163, 163);
dewittj 2014/06/16 18:09:55 I would suggest you use an SkColor in these functi
liyanhou 2014/06/27 03:18:40 Done.
+ // Foreground color white
+ const gfx::ImageSkia foreground = CreateImage(width, height, 255, 255, 255);
+ const gfx::ImageSkia masked_small_image =
+ gfx::ImageSkiaOperations::CreateMaskedImage(foreground, small_image);
+ return gfx::ImageSkiaOperations::CreateSuperimposedImage(background,
+ masked_small_image);
+}
+
+const gfx::ImageSkia CreateImage(int width,
+ int height,
+ int red,
+ int green,
+ int blue) {
+ return gfx::ImageSkia::CreateFrom1xBitmap(
+ CreateBitmap(width, height, red, green, blue));
+}
+
+const SkBitmap CreateBitmap(int width,
+ int height,
+ int red,
+ int green,
+ int blue) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.allocPixels();
+ bitmap.eraseRGB(red, green, blue);
+ return bitmap;
+}
« chrome/common/extensions/api/notifications.idl ('K') | « ui/message_center/views/small_image_mask.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698