Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 RETURN_IF_IS(CIRCLE); | 50 RETURN_IF_IS(CIRCLE); |
| 51 RETURN_IF_IS(ROUND_RECT); | 51 RETURN_IF_IS(ROUND_RECT); |
| 52 RETURN_IF_IS(CLOSE); | 52 RETURN_IF_IS(CLOSE); |
| 53 RETURN_IF_IS(CANVAS_DIMENSIONS); | 53 RETURN_IF_IS(CANVAS_DIMENSIONS); |
| 54 RETURN_IF_IS(CLIP); | 54 RETURN_IF_IS(CLIP); |
| 55 RETURN_IF_IS(DISABLE_AA); | 55 RETURN_IF_IS(DISABLE_AA); |
| 56 RETURN_IF_IS(FLIPS_IN_RTL); | 56 RETURN_IF_IS(FLIPS_IN_RTL); |
| 57 RETURN_IF_IS(END); | 57 RETURN_IF_IS(END); |
| 58 #undef RETURN_IF_IS | 58 #undef RETURN_IF_IS |
| 59 | 59 |
| 60 NOTREACHED(); | 60 NOTREACHED() << "Unrecognized command: " << source; |
| 61 return CLOSE; | 61 return CLOSE; |
| 62 } | 62 } |
| 63 | 63 |
| 64 std::vector<PathElement> PathFromSource(const std::string& source) { | 64 std::vector<PathElement> PathFromSource(const std::string& source) { |
| 65 std::vector<PathElement> path; | 65 std::vector<PathElement> path; |
| 66 std::vector<std::string> pieces = base::SplitString( | 66 std::vector<std::string> pieces = base::SplitString( |
| 67 source, "\n ,f", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 67 source, "\n ,f", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 68 for (const auto& piece : pieces) { | 68 for (const auto& piece : pieces) { |
| 69 double value; | 69 double value; |
| 70 int hex_value; | |
|
msw
2016/07/14 20:57:02
nit: init to 0; ditto above.
| |
| 70 if (base::StringToDouble(piece, &value)) | 71 if (base::StringToDouble(piece, &value)) |
| 71 path.push_back(PathElement(SkDoubleToScalar(value))); | 72 path.push_back(PathElement(SkDoubleToScalar(value))); |
| 73 else if (base::HexStringToInt(piece, &hex_value)) | |
| 74 path.push_back(PathElement(SkIntToScalar(hex_value))); | |
| 72 else | 75 else |
| 73 path.push_back(PathElement(CommandFromString(piece))); | 76 path.push_back(PathElement(CommandFromString(piece))); |
| 74 } | 77 } |
| 75 return path; | 78 return path; |
| 76 } | 79 } |
| 77 | 80 |
| 78 void PaintPath(Canvas* canvas, | 81 void PaintPath(Canvas* canvas, |
| 79 const PathElement* path_elements, | 82 const PathElement* path_elements, |
| 80 size_t dip_size, | 83 size_t dip_size, |
| 81 SkColor color) { | 84 SkColor color) { |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 | 450 |
| 448 ImageSkia CreateVectorIconFromSource(const std::string& source, | 451 ImageSkia CreateVectorIconFromSource(const std::string& source, |
| 449 size_t dip_size, | 452 size_t dip_size, |
| 450 SkColor color) { | 453 SkColor color) { |
| 451 return ImageSkia( | 454 return ImageSkia( |
| 452 new VectorIconSource(source, dip_size, color), | 455 new VectorIconSource(source, dip_size, color), |
| 453 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); | 456 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); |
| 454 } | 457 } |
| 455 | 458 |
| 456 } // namespace gfx | 459 } // namespace gfx |
| OLD | NEW |