| 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> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| 11 #include "ui/gfx/gfx_export.h" | 11 #include "ui/gfx/gfx_export.h" |
| 12 #include "ui/gfx/image/image_skia.h" | 12 #include "ui/gfx/image/image_skia.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 | 15 |
| 16 class Canvas; | 16 class Canvas; |
| 17 enum class VectorIconId; | 17 enum class VectorIconId; |
| 18 | 18 |
| 19 // 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| |
| 20 // 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 |
| 21 // pixels. |color| is used as the fill. | 21 // pixels. |color| is used as the fill. |
| 22 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, | 22 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, |
| 23 VectorIconId id, | 23 VectorIconId id, |
| 24 size_t dip_size, | 24 size_t dip_size, |
| 25 SkColor color); | 25 SkColor color); |
| 26 | 26 |
| 27 // Creates an ImageSkia which will render the icon on demand. | 27 // 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). |
| 29 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, |
| 30 SkColor color); |
| 31 |
| 32 // As above, but creates the image at the given size. |
| 28 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, | 33 GFX_EXPORT ImageSkia CreateVectorIcon(VectorIconId id, |
| 29 size_t dip_size, | 34 size_t dip_size, |
| 30 SkColor color); | 35 SkColor color); |
| 31 | 36 |
| 32 // As above, but also paints a badge defined by |badge_id| on top of the icon. | 37 // As above, but also paints a badge defined by |badge_id| on top of the icon. |
| 33 // The badge uses the same canvas size and default color as the icon. | 38 // The badge uses the same canvas size and default color as the icon. |
| 34 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(VectorIconId id, | 39 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(VectorIconId id, |
| 35 size_t dip_size, | 40 size_t dip_size, |
| 36 SkColor color, | 41 SkColor color, |
| 37 VectorIconId badge_id); | 42 VectorIconId badge_id); |
| 38 | 43 |
| 39 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION) | 44 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION) |
| 40 // Takes a string of the format expected of .icon files and renders onto | 45 // Takes a string of the format expected of .icon files and renders onto |
| 41 // a canvas. This should only be used as a debugging aid and should never be | 46 // a canvas. This should only be used as a debugging aid and should never be |
| 42 // used in production code. | 47 // used in production code. |
| 43 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, | 48 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, |
| 44 size_t dip_size, | 49 size_t dip_size, |
| 45 SkColor color); | 50 SkColor color); |
| 46 #endif | 51 #endif |
| 47 | 52 |
| 48 } // namespace gfx | 53 } // namespace gfx |
| 49 | 54 |
| 50 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ | 55 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ |
| OLD | NEW |