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

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

Issue 1228923002: Revert vector icon CLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@merge_aide_oobe_completion
Patch Set: Created 5 years, 5 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 | « ui/gfx/paint_vector_icon.h ('k') | ui/gfx/vector_icons.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/gfx/paint_vector_icon.h"
6
7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/vector_icons.h"
9 #include "ui/gfx/vector_icons_public.h"
10
11 namespace gfx {
12
13 void PaintVectorIcon(Canvas* canvas,
14 VectorIconId id,
15 size_t dip_size,
16 SkColor color) {
17 DCHECK(VectorIconId::VECTOR_ICON_NONE != id);
18 const PathElement* path_elements = GetPathForVectorIcon(id);
19 SkPath path;
20 path.setFillType(SkPath::kEvenOdd_FillType);
21 if (dip_size != kReferenceSizeDip) {
22 SkScalar scale = SkIntToScalar(dip_size) / SkIntToScalar(kReferenceSizeDip);
23 canvas->sk_canvas()->scale(scale, scale);
24 }
25
26 for (size_t i = 0; path_elements[i].type != END;) {
27 switch (path_elements[i++].type) {
28 case MOVE_TO: {
29 SkScalar x = path_elements[i++].arg;
30 SkScalar y = path_elements[i++].arg;
31 path.moveTo(x, y);
32 break;
33 }
34
35 case R_MOVE_TO: {
36 SkScalar x = path_elements[i++].arg;
37 SkScalar y = path_elements[i++].arg;
38 path.rMoveTo(x, y);
39 break;
40 }
41
42 case LINE_TO: {
43 SkScalar x = path_elements[i++].arg;
44 SkScalar y = path_elements[i++].arg;
45 path.lineTo(x, y);
46 break;
47 }
48
49 case R_LINE_TO: {
50 SkScalar x = path_elements[i++].arg;
51 SkScalar y = path_elements[i++].arg;
52 path.rLineTo(x, y);
53 break;
54 }
55
56 case H_LINE_TO: {
57 SkPoint last_point;
58 path.getLastPt(&last_point);
59 SkScalar x = path_elements[i++].arg;
60 path.lineTo(x, last_point.fY);
61 break;
62 }
63
64 case R_H_LINE_TO: {
65 SkScalar x = path_elements[i++].arg;
66 path.rLineTo(x, 0);
67 break;
68 }
69
70 case V_LINE_TO: {
71 SkPoint last_point;
72 path.getLastPt(&last_point);
73 SkScalar y = path_elements[i++].arg;
74 path.lineTo(last_point.fX, y);
75 break;
76 }
77
78 case R_V_LINE_TO: {
79 SkScalar y = path_elements[i++].arg;
80 path.rLineTo(0, y);
81 break;
82 }
83
84 case R_CUBIC_TO: {
85 SkScalar x1 = path_elements[i++].arg;
86 SkScalar y1 = path_elements[i++].arg;
87 SkScalar x2 = path_elements[i++].arg;
88 SkScalar y2 = path_elements[i++].arg;
89 SkScalar x3 = path_elements[i++].arg;
90 SkScalar y3 = path_elements[i++].arg;
91 path.rCubicTo(x1, y1, x2, y2, x3, y3);
92 break;
93 }
94
95 case CLOSE: {
96 path.close();
97 break;
98 }
99
100 case CIRCLE: {
101 SkScalar x = path_elements[i++].arg;
102 SkScalar y = path_elements[i++].arg;
103 SkScalar r = path_elements[i++].arg;
104 path.addCircle(x, y, r);
105 break;
106 }
107
108 case END:
109 NOTREACHED();
110 break;
111 }
112 }
113
114 SkPaint paint;
115 paint.setStyle(SkPaint::kFill_Style);
116 paint.setAntiAlias(true);
117 paint.setColor(color);
118 canvas->DrawPath(path, paint);
119 }
120
121 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/paint_vector_icon.h ('k') | ui/gfx/vector_icons.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698