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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/message_center/views/small_image_mask.h"
6
7 #include "ui/gfx/image/image_skia_operations.h"
8
9 // Take small_iamge as the alpha channel, mask it with the foreground,
10 // then add the masked foreground on top of the background
11 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.
12 int width = small_image.width();
13 int height = small_image.height();
14
15 // Background color grey
16 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.
17 // Foreground color white
18 const gfx::ImageSkia foreground = CreateImage(width, height, 255, 255, 255);
19 const gfx::ImageSkia masked_small_image =
20 gfx::ImageSkiaOperations::CreateMaskedImage(foreground, small_image);
21 return gfx::ImageSkiaOperations::CreateSuperimposedImage(background,
22 masked_small_image);
23 }
24
25 const gfx::ImageSkia CreateImage(int width,
26 int height,
27 int red,
28 int green,
29 int blue) {
30 return gfx::ImageSkia::CreateFrom1xBitmap(
31 CreateBitmap(width, height, red, green, blue));
32 }
33
34 const SkBitmap CreateBitmap(int width,
35 int height,
36 int red,
37 int green,
38 int blue) {
39 SkBitmap bitmap;
40 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
41 bitmap.allocPixels();
42 bitmap.eraseRGB(red, green, blue);
43 return bitmap;
44 }
OLDNEW
« 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