| 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 "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "ui/gfx/gfx_export.h" | 9 #include "ui/gfx/gfx_export.h" |
| 10 #include "ui/gfx/image/image_skia.h" | 10 #include "ui/gfx/image/image_skia.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 | 13 |
| 14 class Canvas; | 14 class Canvas; |
| 15 struct VectorIcon; | 15 struct VectorIcon; |
| 16 enum class VectorIconId; | |
| 17 | 16 |
| 18 GFX_EXPORT extern const VectorIcon kNoneIcon; | 17 GFX_EXPORT extern const VectorIcon kNoneIcon; |
| 19 | 18 |
| 20 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |dip_size| | 19 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |dip_size| |
| 21 // is the length of a single edge of the square icon, in device independent | 20 // is the length of a single edge of the square icon, in device independent |
| 22 // pixels. |color| is used as the fill. | 21 // pixels. |color| is used as the fill. |
| 23 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, | 22 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, |
| 24 VectorIconId id, | |
| 25 int dip_size, | |
| 26 SkColor color); | |
| 27 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, | |
| 28 const VectorIcon& icon, | 23 const VectorIcon& icon, |
| 29 int dip_size, | 24 int dip_size, |
| 30 SkColor color); | 25 SkColor color); |
| 31 | 26 |
| 32 // Creates an ImageSkia which will render the icon on demand. The size will come | 27 // Creates an ImageSkia which will render the icon on demand. The size will come |
| 33 // from the .icon file (the 1x version, if multiple versions exist). | 28 // from the .icon file (the 1x version, if multiple versions exist). |
| 34 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, | |
| 35 SkColor color); | |
| 36 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color); | 29 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color); |
| 37 | 30 |
| 38 // As above, but creates the image at the given size. | 31 // As above, but creates the image at the given size. |
| 39 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, | |
| 40 int dip_size, | |
| 41 SkColor color); | |
| 42 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, | 32 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, |
| 43 int dip_size, | 33 int dip_size, |
| 44 SkColor color); | 34 SkColor color); |
| 45 | 35 |
| 46 // As above, but also paints a badge defined by |badge_id| on top of the icon. | 36 // As above, but also paints a badge defined by |badge_id| on top of the icon. |
| 47 // The badge uses the same canvas size and default color as the icon. | 37 // The badge uses the same canvas size and default color as the icon. |
| 48 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(VectorIconId id, | |
| 49 int dip_size, | |
| 50 SkColor color, | |
| 51 VectorIconId badge_id); | |
| 52 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon, | 38 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon, |
| 53 int dip_size, | 39 int dip_size, |
| 54 SkColor color, | 40 SkColor color, |
| 55 const VectorIcon& badge_icon); | 41 const VectorIcon& badge_icon); |
| 56 | 42 |
| 57 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION) | 43 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION) |
| 58 // Takes a string of the format expected of .icon files and renders onto | 44 // Takes a string of the format expected of .icon files and renders onto |
| 59 // a canvas. This should only be used as a debugging aid and should never be | 45 // a canvas. This should only be used as a debugging aid and should never be |
| 60 // used in production code. | 46 // used in production code. |
| 61 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, | 47 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, |
| 62 int dip_size, | 48 int dip_size, |
| 63 SkColor color); | 49 SkColor color); |
| 64 #endif | 50 #endif |
| 65 | 51 |
| 66 } // namespace gfx | 52 } // namespace gfx |
| 67 | 53 |
| 68 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ | 54 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ |
| OLD | NEW |