OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_PAINT_VECTOR_ICON_H_ | 5 #ifndef UI_GFX_PAINT_VECTOR_ICON_H_ |
6 #define UI_GFX_PAINT_VECTOR_ICON_H_ | 6 #define UI_GFX_PAINT_VECTOR_ICON_H_ |
7 | 7 |
8 #include <stddef.h> | |
9 | |
10 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
11 #include "ui/gfx/gfx_export.h" | 9 #include "ui/gfx/gfx_export.h" |
12 #include "ui/gfx/image/image_skia.h" | 10 #include "ui/gfx/image/image_skia.h" |
13 | 11 |
14 namespace gfx { | 12 namespace gfx { |
15 | 13 |
16 class Canvas; | 14 class Canvas; |
17 enum class VectorIconId; | 15 enum class VectorIconId; |
18 | 16 |
19 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |dip_size| | 17 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |dip_size| |
20 // is the length of a single edge of the square icon, in device independent | 18 // is the length of a single edge of the square icon, in device independent |
21 // pixels. |color| is used as the fill. | 19 // pixels. |color| is used as the fill. |
22 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, | 20 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, |
23 VectorIconId id, | 21 VectorIconId id, |
24 size_t dip_size, | 22 int dip_size, |
25 SkColor color); | 23 SkColor color); |
26 | 24 |
27 // Creates an ImageSkia which will render the icon on demand. The size will come | 25 // Creates an ImageSkia which will render the icon on demand. The size will come |
28 // from the .icon file (the 1x version, if multiple versions exist). | 26 // from the .icon file (the 1x version, if multiple versions exist). |
29 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, | 27 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, |
30 SkColor color); | 28 SkColor color); |
31 | 29 |
32 // As above, but creates the image at the given size. | 30 // As above, but creates the image at the given size. |
33 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, | 31 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, |
34 size_t dip_size, | 32 int dip_size, |
35 SkColor color); | 33 SkColor color); |
36 | 34 |
37 // As above, but also paints a badge defined by |badge_id| on top of the icon. | 35 // As above, but also paints a badge defined by |badge_id| on top of the icon. |
38 // The badge uses the same canvas size and default color as the icon. | 36 // The badge uses the same canvas size and default color as the icon. |
39 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(VectorIconId id, | 37 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(VectorIconId id, |
40 size_t dip_size, | 38 int dip_size, |
41 SkColor color, | 39 SkColor color, |
42 VectorIconId badge_id); | 40 VectorIconId badge_id); |
43 | 41 |
44 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION) | 42 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION) |
45 // Takes a string of the format expected of .icon files and renders onto | 43 // Takes a string of the format expected of .icon files and renders onto |
46 // a canvas. This should only be used as a debugging aid and should never be | 44 // a canvas. This should only be used as a debugging aid and should never be |
47 // used in production code. | 45 // used in production code. |
48 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, | 46 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, |
49 size_t dip_size, | 47 int dip_size, |
50 SkColor color); | 48 SkColor color); |
51 #endif | 49 #endif |
52 | 50 |
53 } // namespace gfx | 51 } // namespace gfx |
54 | 52 |
55 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ | 53 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ |
OLD | NEW |