Chromium Code Reviews| 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 "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/gfx/gfx_export.h" | 10 #include "ui/gfx/gfx_export.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 11 #include "ui/gfx/image/image_skia.h" |
| 12 | 12 |
| 13 namespace gfx { | 13 namespace gfx { |
| 14 | 14 |
| 15 class Canvas; | 15 class Canvas; |
| 16 struct VectorIcon; | 16 struct VectorIcon; |
| 17 | 17 |
| 18 // Describes an instance of an icon: an icon definition and a set of drawing | |
| 19 // parameters. | |
| 20 struct GFX_EXPORT IconDescription { | |
| 21 IconDescription(const IconDescription& other); | |
| 22 | |
| 23 IconDescription(const VectorIcon& icon, | |
| 24 int dip_size, | |
| 25 SkColor color, | |
| 26 const base::TimeDelta& elapsed_time, | |
| 27 const VectorIcon& badge_icon); | |
| 28 | |
| 29 ~IconDescription(); | |
| 30 | |
| 31 bool operator<(const IconDescription& other) const; | |
|
sadrul
2017/05/23 18:01:14
I don't think < operator makes sense for IconDescr
Evan Stade
2017/05/23 23:38:42
Why not? This is just used as an ordering operatio
sadrul
2017/05/24 17:35:14
I don't know what the result of comparing two non-
Evan Stade
2017/05/24 17:47:53
Does it matter what the meaning of the comparison
sadrul
2017/05/26 19:50:27
Let's create a separate function for that, then, a
Evan Stade
2017/05/26 20:48:52
I moved this to a separate struct, although I'd st
| |
| 32 | |
| 33 const VectorIcon& icon; | |
| 34 int dip_size; | |
| 35 SkColor color; | |
| 36 const base::TimeDelta elapsed_time; | |
| 37 const VectorIcon& badge_icon; | |
| 38 }; | |
| 39 | |
| 18 GFX_EXPORT extern const VectorIcon kNoneIcon; | 40 GFX_EXPORT extern const VectorIcon kNoneIcon; |
| 19 | 41 |
| 20 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |color| is | 42 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |color| is |
| 21 // used as the fill. The size will come from the .icon file (the 1x version, if | 43 // used as the fill. The size will come from the .icon file (the 1x version, if |
| 22 // multiple versions exist). |elapsed_time| is used to determine the state of | 44 // multiple versions exist). |elapsed_time| is used to determine the state of |
| 23 // any transitions the icon may define. | 45 // any transitions the icon may define. |
| 24 GFX_EXPORT void PaintVectorIcon( | 46 GFX_EXPORT void PaintVectorIcon( |
| 25 Canvas* canvas, | 47 Canvas* canvas, |
| 26 const VectorIcon& icon, | 48 const VectorIcon& icon, |
| 27 SkColor color, | 49 SkColor color, |
| 28 const base::TimeDelta& elapsed_time = base::TimeDelta()); | 50 const base::TimeDelta& elapsed_time = base::TimeDelta()); |
| 29 | 51 |
| 30 // As above, with a specificed size. |dip_size| is the length of a single edge | 52 // As above, with a specificed size. |dip_size| is the length of a single edge |
| 31 // of the square icon, in device independent pixels. | 53 // of the square icon, in device independent pixels. |
| 32 GFX_EXPORT void PaintVectorIcon( | 54 GFX_EXPORT void PaintVectorIcon( |
| 33 Canvas* canvas, | 55 Canvas* canvas, |
| 34 const VectorIcon& icon, | 56 const VectorIcon& icon, |
| 35 int dip_size, | 57 int dip_size, |
| 36 SkColor color, | 58 SkColor color, |
| 37 const base::TimeDelta& elapsed_time = base::TimeDelta()); | 59 const base::TimeDelta& elapsed_time = base::TimeDelta()); |
| 38 | 60 |
| 61 // Creates an ImageSkia which will render the icon on demand. | |
| 62 // TODO(estade): update clients to use this version and remove the other | |
| 63 // CreateVectorIcon()s. | |
| 64 GFX_EXPORT ImageSkia CreateVectorIcon(const IconDescription& params); | |
| 65 | |
| 39 // Creates an ImageSkia which will render the icon on demand. The size will come | 66 // Creates an ImageSkia which will render the icon on demand. The size will come |
| 40 // from the .icon file (the 1x version, if multiple versions exist). | 67 // from the .icon file (the 1x version, if multiple versions exist). |
| 41 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color); | 68 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color); |
| 42 | 69 |
| 43 // As above, but creates the image at the given size. | 70 // As above, but creates the image at the given size. |
| 44 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, | 71 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, |
| 45 int dip_size, | 72 int dip_size, |
| 46 SkColor color); | 73 SkColor color); |
| 47 | 74 |
| 48 // As above, but also paints a badge defined by |badge_id| on top of the icon. | 75 // As above, but also paints a badge defined by |badge_id| on top of the icon. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 64 // Calculates the size that will be default for |icon|, in dip. | 91 // Calculates the size that will be default for |icon|, in dip. |
| 65 GFX_EXPORT int GetDefaultSizeOfVectorIcon(const gfx::VectorIcon& icon); | 92 GFX_EXPORT int GetDefaultSizeOfVectorIcon(const gfx::VectorIcon& icon); |
| 66 | 93 |
| 67 // Calculates and returns the elapsed time at which all animations/transitions | 94 // Calculates and returns the elapsed time at which all animations/transitions |
| 68 // will be finished. | 95 // will be finished. |
| 69 base::TimeDelta GetDurationOfAnimation(const VectorIcon& icon); | 96 base::TimeDelta GetDurationOfAnimation(const VectorIcon& icon); |
| 70 | 97 |
| 71 } // namespace gfx | 98 } // namespace gfx |
| 72 | 99 |
| 73 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ | 100 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ |
| OLD | NEW |