| 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   const VectorIcon& icon; | 
 |  32   int dip_size; | 
 |  33   SkColor color; | 
 |  34   const base::TimeDelta elapsed_time; | 
 |  35   const VectorIcon& badge_icon; | 
 |  36 }; | 
 |  37  | 
|  18 GFX_EXPORT extern const VectorIcon kNoneIcon; |  38 GFX_EXPORT extern const VectorIcon kNoneIcon; | 
|  19  |  39  | 
|  20 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |color| is |  40 // 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 |  41 // 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 |  42 // multiple versions exist). |elapsed_time| is used to determine the state of | 
|  23 // any transitions the icon may define. |  43 // any transitions the icon may define. | 
|  24 GFX_EXPORT void PaintVectorIcon( |  44 GFX_EXPORT void PaintVectorIcon( | 
|  25     Canvas* canvas, |  45     Canvas* canvas, | 
|  26     const VectorIcon& icon, |  46     const VectorIcon& icon, | 
|  27     SkColor color, |  47     SkColor color, | 
|  28     const base::TimeDelta& elapsed_time = base::TimeDelta()); |  48     const base::TimeDelta& elapsed_time = base::TimeDelta()); | 
|  29  |  49  | 
|  30 // As above, with a specificed size. |dip_size| is the length of a single edge |  50 // As above, with a specificed size. |dip_size| is the length of a single edge | 
|  31 // of the square icon, in device independent pixels. |  51 // of the square icon, in device independent pixels. | 
|  32 GFX_EXPORT void PaintVectorIcon( |  52 GFX_EXPORT void PaintVectorIcon( | 
|  33     Canvas* canvas, |  53     Canvas* canvas, | 
|  34     const VectorIcon& icon, |  54     const VectorIcon& icon, | 
|  35     int dip_size, |  55     int dip_size, | 
|  36     SkColor color, |  56     SkColor color, | 
|  37     const base::TimeDelta& elapsed_time = base::TimeDelta()); |  57     const base::TimeDelta& elapsed_time = base::TimeDelta()); | 
|  38  |  58  | 
 |  59 // Creates an ImageSkia which will render the icon on demand. | 
 |  60 // TODO(estade): update clients to use this version and remove the other | 
 |  61 // CreateVectorIcon()s. | 
 |  62 GFX_EXPORT ImageSkia CreateVectorIcon(const IconDescription& params); | 
 |  63  | 
|  39 // Creates an ImageSkia which will render the icon on demand. The size will come |  64 // 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). |  65 // from the .icon file (the 1x version, if multiple versions exist). | 
|  41 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color); |  66 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color); | 
|  42  |  67  | 
|  43 // As above, but creates the image at the given size. |  68 // As above, but creates the image at the given size. | 
|  44 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, |  69 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, | 
|  45                                       int dip_size, |  70                                       int dip_size, | 
|  46                                       SkColor color); |  71                                       SkColor color); | 
|  47  |  72  | 
|  48 // As above, but also paints a badge defined by |badge_id| on top of the icon. |  73 // As above, but also paints a badge defined by |badge_id| on top of the icon. | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  59 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, |  84 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, | 
|  60                                                 int dip_size, |  85                                                 int dip_size, | 
|  61                                                 SkColor color); |  86                                                 SkColor color); | 
|  62 #endif |  87 #endif | 
|  63  |  88  | 
|  64 // Calculates the size that will be default for |icon|, in dip. |  89 // Calculates the size that will be default for |icon|, in dip. | 
|  65 GFX_EXPORT int GetDefaultSizeOfVectorIcon(const gfx::VectorIcon& icon); |  90 GFX_EXPORT int GetDefaultSizeOfVectorIcon(const gfx::VectorIcon& icon); | 
|  66  |  91  | 
|  67 // Calculates and returns the elapsed time at which all animations/transitions |  92 // Calculates and returns the elapsed time at which all animations/transitions | 
|  68 // will be finished. |  93 // will be finished. | 
|  69 base::TimeDelta GetDurationOfAnimation(const VectorIcon& icon); |  94 GFX_EXPORT base::TimeDelta GetDurationOfAnimation(const VectorIcon& icon); | 
|  70  |  95  | 
|  71 }  // namespace gfx |  96 }  // namespace gfx | 
|  72  |  97  | 
|  73 #endif  // UI_GFX_PAINT_VECTOR_ICON_H_ |  98 #endif  // UI_GFX_PAINT_VECTOR_ICON_H_ | 
| OLD | NEW |