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

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

Issue 2075863002: Fix check for ARC_TO vs R_ARC_TO for vector assets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | no next file » | no next file with comments »
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 #include "ui/gfx/paint_vector_icon.h" 5 #include "ui/gfx/paint_vector_icon.h"
6 6
7 #include <map> 7 #include <map>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 paths.back().setFillType(SkPath::kEvenOdd_FillType); 95 paths.back().setFillType(SkPath::kEvenOdd_FillType);
96 96
97 paints.push_back(SkPaint()); 97 paints.push_back(SkPaint());
98 paints.back().setColor(color); 98 paints.back().setColor(color);
99 paints.back().setAntiAlias(true); 99 paints.back().setAntiAlias(true);
100 paints.back().setStrokeCap(SkPaint::kRound_Cap); 100 paints.back().setStrokeCap(SkPaint::kRound_Cap);
101 } 101 }
102 102
103 SkPath& path = paths.back(); 103 SkPath& path = paths.back();
104 SkPaint& paint = paints.back(); 104 SkPaint& paint = paints.back();
105 switch (path_elements[i].type) { 105 CommandType command_type = path_elements[i].type;
106 switch (command_type) {
106 // Handled above. 107 // Handled above.
107 case NEW_PATH: 108 case NEW_PATH:
108 continue; 109 continue;
109 110
110 case PATH_COLOR_ARGB: { 111 case PATH_COLOR_ARGB: {
111 int a = SkScalarFloorToInt(path_elements[++i].arg); 112 int a = SkScalarFloorToInt(path_elements[++i].arg);
112 int r = SkScalarFloorToInt(path_elements[++i].arg); 113 int r = SkScalarFloorToInt(path_elements[++i].arg);
113 int g = SkScalarFloorToInt(path_elements[++i].arg); 114 int g = SkScalarFloorToInt(path_elements[++i].arg);
114 int b = SkScalarFloorToInt(path_elements[++i].arg); 115 int b = SkScalarFloorToInt(path_elements[++i].arg);
115 paint.setColor(SkColorSetARGB(a, r, g, b)); 116 paint.setColor(SkColorSetARGB(a, r, g, b));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 case R_ARC_TO: { 152 case R_ARC_TO: {
152 SkScalar rx = path_elements[++i].arg; 153 SkScalar rx = path_elements[++i].arg;
153 SkScalar ry = path_elements[++i].arg; 154 SkScalar ry = path_elements[++i].arg;
154 SkScalar angle = path_elements[++i].arg; 155 SkScalar angle = path_elements[++i].arg;
155 SkScalar large_arc_flag = path_elements[++i].arg; 156 SkScalar large_arc_flag = path_elements[++i].arg;
156 SkScalar arc_sweep_flag = path_elements[++i].arg; 157 SkScalar arc_sweep_flag = path_elements[++i].arg;
157 SkScalar x = path_elements[++i].arg; 158 SkScalar x = path_elements[++i].arg;
158 SkScalar y = path_elements[++i].arg; 159 SkScalar y = path_elements[++i].arg;
159 160
160 auto path_fn = 161 auto path_fn =
161 path_elements[i].type == ARC_TO 162 command_type == ARC_TO
162 ? static_cast<void (SkPath::*)( 163 ? static_cast<void (SkPath::*)(
163 SkScalar, SkScalar, SkScalar, SkPath::ArcSize, 164 SkScalar, SkScalar, SkScalar, SkPath::ArcSize,
164 SkPath::Direction, SkScalar, SkScalar)>(&SkPath::arcTo) 165 SkPath::Direction, SkScalar, SkScalar)>(&SkPath::arcTo)
165 : &SkPath::rArcTo; 166 : &SkPath::rArcTo;
166 (path.*path_fn)( 167 (path.*path_fn)(
167 rx, ry, angle, 168 rx, ry, angle,
168 large_arc_flag ? SkPath::kLarge_ArcSize : SkPath::kSmall_ArcSize, 169 large_arc_flag ? SkPath::kLarge_ArcSize : SkPath::kSmall_ArcSize,
169 arc_sweep_flag ? SkPath::kCW_Direction : SkPath::kCCW_Direction, 170 arc_sweep_flag ? SkPath::kCW_Direction : SkPath::kCCW_Direction,
170 x, y); 171 x, y);
171 break; 172 break;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 447
447 ImageSkia CreateVectorIconFromSource(const std::string& source, 448 ImageSkia CreateVectorIconFromSource(const std::string& source,
448 size_t dip_size, 449 size_t dip_size,
449 SkColor color) { 450 SkColor color) {
450 return ImageSkia( 451 return ImageSkia(
451 new VectorIconSource(source, dip_size, color), 452 new VectorIconSource(source, dip_size, color),
452 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); 453 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size)));
453 } 454 }
454 455
455 } // namespace gfx 456 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698