Chromium Code Reviews| Index: ui/gfx/paint_vector_icon.cc |
| diff --git a/ui/gfx/paint_vector_icon.cc b/ui/gfx/paint_vector_icon.cc |
| index 5db76e25af63cf5749df5c0ee6eda37b6c17f025..d060c502b0387af103e00bcfaecdace42c7bbc22 100644 |
| --- a/ui/gfx/paint_vector_icon.cc |
| +++ b/ui/gfx/paint_vector_icon.cc |
| @@ -80,13 +80,13 @@ std::vector<PathElement> PathFromSource(const std::string& source) { |
| void PaintPath(Canvas* canvas, |
| const PathElement* path_elements, |
| - size_t dip_size, |
| + int dip_size, |
| SkColor color) { |
| canvas->Save(); |
| SkPath path; |
| path.setFillType(SkPath::kEvenOdd_FillType); |
| - size_t canvas_size = kReferenceSizeDip; |
| + int canvas_size = kReferenceSizeDip; |
| std::vector<SkPath> paths; |
| std::vector<SkPaint> paints; |
| SkRect clip_rect = SkRect::MakeEmpty(); |
| @@ -295,7 +295,7 @@ void PaintPath(Canvas* canvas, |
| if (flips_in_rtl && base::i18n::IsRTL()) { |
| canvas->Scale(-1, 1); |
| - canvas->Translate(gfx::Vector2d(-static_cast<int>(canvas_size), 0)); |
|
Evan Stade
2016/08/18 23:25:37
I don't think this cast is an indication that a ne
Peter Kasting
2016/08/18 23:35:13
Well, a negative canvas size doesn't make sense in
Evan Stade
2016/08/19 04:21:49
I didn't know the style guide said that and I stil
|
| + canvas->Translate(gfx::Vector2d(-canvas_size, 0)); |
| } |
| if (dip_size != canvas_size) { |
| @@ -315,22 +315,18 @@ void PaintPath(Canvas* canvas, |
| class VectorIconSource : public CanvasImageSource { |
| public: |
| VectorIconSource(VectorIconId id, |
| - size_t dip_size, |
| + int dip_size, |
| SkColor color, |
| VectorIconId badge_id) |
| - : CanvasImageSource( |
| - gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size)), |
| - false), |
| + : CanvasImageSource(gfx::Size(dip_size, dip_size), false), |
| id_(id), |
| color_(color), |
| badge_id_(badge_id) {} |
| VectorIconSource(const std::string& definition, |
| - size_t dip_size, |
| + int dip_size, |
| SkColor color) |
| - : CanvasImageSource( |
| - gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size)), |
| - false), |
| + : CanvasImageSource(gfx::Size(dip_size, dip_size), false), |
| id_(VectorIconId::VECTOR_ICON_NONE), |
| path_(PathFromSource(definition)), |
| color_(color), |
| @@ -371,7 +367,7 @@ class VectorIconCache { |
| ~VectorIconCache() {} |
| ImageSkia GetOrCreateIcon(VectorIconId id, |
| - size_t dip_size, |
| + int dip_size, |
| SkColor color, |
| VectorIconId badge_id) { |
| IconDescription description(id, dip_size, color, badge_id); |
| @@ -379,9 +375,8 @@ class VectorIconCache { |
| if (iter != images_.end()) |
| return iter->second; |
| - ImageSkia icon( |
| - new VectorIconSource(id, dip_size, color, badge_id), |
| - gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); |
| + ImageSkia icon(new VectorIconSource(id, dip_size, color, badge_id), |
| + gfx::Size(dip_size, dip_size)); |
| images_.insert(std::make_pair(description, icon)); |
| return icon; |
| } |
| @@ -389,7 +384,7 @@ class VectorIconCache { |
| private: |
| struct IconDescription { |
| IconDescription(VectorIconId id, |
| - size_t dip_size, |
| + int dip_size, |
| SkColor color, |
| VectorIconId badge_id) |
| : id(id), dip_size(dip_size), color(color), badge_id(badge_id) {} |
| @@ -417,7 +412,7 @@ static base::LazyInstance<VectorIconCache> g_icon_cache = |
| void PaintVectorIcon(Canvas* canvas, |
| VectorIconId id, |
| - size_t dip_size, |
| + int dip_size, |
| SkColor color) { |
| DCHECK(VectorIconId::VECTOR_ICON_NONE != id); |
| const PathElement* path = canvas->image_scale() == 1.f |
| @@ -428,18 +423,19 @@ void PaintVectorIcon(Canvas* canvas, |
| ImageSkia CreateVectorIcon(VectorIconId id, SkColor color) { |
| const PathElement* one_x_path = GetPathForVectorIconAt1xScale(id); |
| - size_t size = one_x_path[0].type == CANVAS_DIMENSIONS ? one_x_path[1].arg |
| - : kReferenceSizeDip; |
| + int size = (one_x_path[0].type == CANVAS_DIMENSIONS) |
| + ? SkScalarTruncToInt(one_x_path[1].arg) |
| + : kReferenceSizeDip; |
| return CreateVectorIcon(id, size, color); |
| } |
| -ImageSkia CreateVectorIcon(VectorIconId id, size_t dip_size, SkColor color) { |
| +ImageSkia CreateVectorIcon(VectorIconId id, int dip_size, SkColor color) { |
| return CreateVectorIconWithBadge(id, dip_size, color, |
| VectorIconId::VECTOR_ICON_NONE); |
| } |
| ImageSkia CreateVectorIconWithBadge(VectorIconId id, |
| - size_t dip_size, |
| + int dip_size, |
| SkColor color, |
| VectorIconId badge_id) { |
| return (id == VectorIconId::VECTOR_ICON_NONE) |
| @@ -449,11 +445,11 @@ ImageSkia CreateVectorIconWithBadge(VectorIconId id, |
| } |
| ImageSkia CreateVectorIconFromSource(const std::string& source, |
| - size_t dip_size, |
| + int dip_size, |
| SkColor color) { |
| return ImageSkia( |
| new VectorIconSource(source, dip_size, color), |
| - gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); |
| + gfx::Size(dip_size, dip_size)); |
| } |
| } // namespace gfx |