| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size)), | 302 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size)), |
| 303 false), | 303 false), |
| 304 id_(VectorIconId::VECTOR_ICON_NONE), | 304 id_(VectorIconId::VECTOR_ICON_NONE), |
| 305 path_(PathFromSource(definition)), | 305 path_(PathFromSource(definition)), |
| 306 color_(color), | 306 color_(color), |
| 307 badge_id_(VectorIconId::VECTOR_ICON_NONE) {} | 307 badge_id_(VectorIconId::VECTOR_ICON_NONE) {} |
| 308 | 308 |
| 309 ~VectorIconSource() override {} | 309 ~VectorIconSource() override {} |
| 310 | 310 |
| 311 // CanvasImageSource: | 311 // CanvasImageSource: |
| 312 bool HasRepresentationAtAllScales() const override { |
| 313 return id_ != VectorIconId::VECTOR_ICON_NONE; |
| 314 } |
| 315 |
| 312 void Draw(gfx::Canvas* canvas) override { | 316 void Draw(gfx::Canvas* canvas) override { |
| 313 if (path_.empty()) { | 317 if (path_.empty()) { |
| 314 PaintVectorIcon(canvas, id_, size_.width(), color_); | 318 PaintVectorIcon(canvas, id_, size_.width(), color_); |
| 315 if (badge_id_ != VectorIconId::VECTOR_ICON_NONE) | 319 if (badge_id_ != VectorIconId::VECTOR_ICON_NONE) |
| 316 PaintVectorIcon(canvas, badge_id_, size_.width(), color_); | 320 PaintVectorIcon(canvas, badge_id_, size_.width(), color_); |
| 317 } else { | 321 } else { |
| 318 PaintPath(canvas, path_.data(), size_.width(), color_); | 322 PaintPath(canvas, path_.data(), size_.width(), color_); |
| 319 } | 323 } |
| 320 } | 324 } |
| 321 | 325 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 410 |
| 407 ImageSkia CreateVectorIconFromSource(const std::string& source, | 411 ImageSkia CreateVectorIconFromSource(const std::string& source, |
| 408 size_t dip_size, | 412 size_t dip_size, |
| 409 SkColor color) { | 413 SkColor color) { |
| 410 return ImageSkia( | 414 return ImageSkia( |
| 411 new VectorIconSource(source, dip_size, color), | 415 new VectorIconSource(source, dip_size, color), |
| 412 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); | 416 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); |
| 413 } | 417 } |
| 414 | 418 |
| 415 } // namespace gfx | 419 } // namespace gfx |
| OLD | NEW |