Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: ui/gfx/paint_vector_icon.h

Issue 2870643003: Add support for animations in vector icons. (Closed)
Patch Set: what happened Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/paint_vector_icon.cc » ('j') | ui/gfx/paint_vector_icon.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
9 #include "ui/gfx/gfx_export.h" 10 #include "ui/gfx/gfx_export.h"
10 #include "ui/gfx/image/image_skia.h" 11 #include "ui/gfx/image/image_skia.h"
11 12
12 namespace gfx { 13 namespace gfx {
13 14
14 class Canvas; 15 class Canvas;
15 struct VectorIcon; 16 struct VectorIcon;
16 17
17 GFX_EXPORT extern const VectorIcon kNoneIcon; 18 GFX_EXPORT extern const VectorIcon kNoneIcon;
18 19
19 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |color| is 20 // Draws a vector icon identified by |id| onto |canvas| at (0, 0). |color| is
20 // used as the fill. The size will come from the .icon file (the 1x version, if 21 // used as the fill. The size will come from the .icon file (the 1x version, if
21 // multiple versions exist). 22 // multiple versions exist). |elapsed_time|, when non-null, is used to determine
23 // the state of any transitions the icon may define. Null is equivalent to zero
24 // elapsed time.
22 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, 25 GFX_EXPORT void PaintVectorIcon(Canvas* canvas,
23 const VectorIcon& icon, 26 const VectorIcon& icon,
24 SkColor color); 27 SkColor color,
28 const base::TimeDelta* elapsed_time = nullptr);
sadrul 2017/05/11 04:22:55 Make these const-refs (TimeDelta() being the defau
Evan Stade 2017/05/11 16:16:26 Done.
25 29
26 // As above, with a specificed size. |dip_size| is the length of a single edge 30 // As above, with a specificed size. |dip_size| is the length of a single edge
27 // of the square icon, in device independent pixels. 31 // of the square icon, in device independent pixels.
28 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, 32 GFX_EXPORT void PaintVectorIcon(Canvas* canvas,
29 const VectorIcon& icon, 33 const VectorIcon& icon,
30 int dip_size, 34 int dip_size,
31 SkColor color); 35 SkColor color,
36 const base::TimeDelta* elapsed_time = nullptr);
32 37
33 // Creates an ImageSkia which will render the icon on demand. The size will come 38 // Creates an ImageSkia which will render the icon on demand. The size will come
34 // from the .icon file (the 1x version, if multiple versions exist). 39 // from the .icon file (the 1x version, if multiple versions exist).
35 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color); 40 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color);
36 41
37 // As above, but creates the image at the given size. 42 // As above, but creates the image at the given size.
38 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, 43 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon,
39 int dip_size, 44 int dip_size,
40 SkColor color); 45 SkColor color);
41 46
42 // As above, but also paints a badge defined by |badge_id| on top of the icon. 47 // As above, but also paints a badge defined by |badge_id| on top of the icon.
43 // The badge uses the same canvas size and default color as the icon. 48 // The badge uses the same canvas size and default color as the icon.
44 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon, 49 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon,
45 int dip_size, 50 int dip_size,
46 SkColor color, 51 SkColor color,
47 const VectorIcon& badge_icon); 52 const VectorIcon& badge_icon);
48 53
49 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION) 54 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION)
50 // Takes a string of the format expected of .icon files and renders onto 55 // Takes a string of the format expected of .icon files and renders onto
51 // a canvas. This should only be used as a debugging aid and should never be 56 // a canvas. This should only be used as a debugging aid and should never be
52 // used in production code. 57 // used in production code.
53 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, 58 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source,
54 int dip_size, 59 int dip_size,
55 SkColor color); 60 SkColor color);
56 #endif 61 #endif
57 62
58 // Calculates the size that will be default for |icon|, in dip. 63 // Calculates the size that will be default for |icon|, in dip.
59 GFX_EXPORT int GetDefaultSizeOfVectorIcon(const gfx::VectorIcon& icon); 64 GFX_EXPORT int GetDefaultSizeOfVectorIcon(const gfx::VectorIcon& icon);
60 65
66 // Calculates and returns the elapsed time at which all animations/transitions
67 // will be finished.
68 base::TimeDelta GetDurationOfAnimation(const VectorIcon& icon);
69
61 } // namespace gfx 70 } // namespace gfx
62 71
63 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ 72 #endif // UI_GFX_PAINT_VECTOR_ICON_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/paint_vector_icon.cc » ('j') | ui/gfx/paint_vector_icon.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698