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

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

Issue 2870643003: Add support for animations in vector icons. (Closed)
Patch Set: 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
tdanderson 2017/05/08 21:22:54 nit: update docs for |elapsed_time|.
Evan Stade 2017/05/08 22:27:41 Done.
21 // multiple versions exist). 22 // multiple versions exist).
22 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, 23 GFX_EXPORT void PaintVectorIcon(Canvas* canvas,
23 const VectorIcon& icon, 24 const VectorIcon& icon,
24 SkColor color); 25 SkColor color,
26 const base::TimeDelta* elapsed_time = nullptr);
25 27
26 // As above, with a specificed size. |dip_size| is the length of a single edge 28 // As above, with a specificed size. |dip_size| is the length of a single edge
27 // of the square icon, in device independent pixels. 29 // of the square icon, in device independent pixels.
28 GFX_EXPORT void PaintVectorIcon(Canvas* canvas, 30 GFX_EXPORT void PaintVectorIcon(Canvas* canvas,
29 const VectorIcon& icon, 31 const VectorIcon& icon,
30 int dip_size, 32 int dip_size,
31 SkColor color); 33 SkColor color,
34 const base::TimeDelta* elapsed_time = nullptr);
32 35
33 // Creates an ImageSkia which will render the icon on demand. The size will come 36 // 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). 37 // from the .icon file (the 1x version, if multiple versions exist).
35 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color); 38 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color);
36 39
37 // As above, but creates the image at the given size. 40 // As above, but creates the image at the given size.
38 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon, 41 GFX_EXPORT ImageSkia CreateVectorIcon(const VectorIcon& icon,
39 int dip_size, 42 int dip_size,
40 SkColor color); 43 SkColor color);
41 44
42 // As above, but also paints a badge defined by |badge_id| on top of the icon. 45 // 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. 46 // The badge uses the same canvas size and default color as the icon.
44 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon, 47 GFX_EXPORT ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon,
45 int dip_size, 48 int dip_size,
46 SkColor color, 49 SkColor color,
47 const VectorIcon& badge_icon); 50 const VectorIcon& badge_icon);
48 51
49 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION) 52 #if defined(GFX_VECTOR_ICONS_UNSAFE) || defined(GFX_IMPLEMENTATION)
50 // Takes a string of the format expected of .icon files and renders onto 53 // 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 54 // a canvas. This should only be used as a debugging aid and should never be
52 // used in production code. 55 // used in production code.
53 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source, 56 GFX_EXPORT ImageSkia CreateVectorIconFromSource(const std::string& source,
54 int dip_size, 57 int dip_size,
55 SkColor color); 58 SkColor color);
56 #endif 59 #endif
57 60
58 // Calculates the size that will be default for |icon|, in dip. 61 // Calculates the size that will be default for |icon|, in dip.
59 GFX_EXPORT int GetDefaultSizeOfVectorIcon(const gfx::VectorIcon& icon); 62 GFX_EXPORT int GetDefaultSizeOfVectorIcon(const gfx::VectorIcon& icon);
60 63
64 // Calculates and returns the elapsed time at which all animations/transitions
65 // will be finished.
66 base::TimeDelta GetDurationOfAnimation(const VectorIcon& icon);
67
61 } // namespace gfx 68 } // namespace gfx
62 69
63 #endif // UI_GFX_PAINT_VECTOR_ICON_H_ 70 #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