| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 VectorIconId id, | 389 VectorIconId id, |
| 390 size_t dip_size, | 390 size_t dip_size, |
| 391 SkColor color) { | 391 SkColor color) { |
| 392 DCHECK(VectorIconId::VECTOR_ICON_NONE != id); | 392 DCHECK(VectorIconId::VECTOR_ICON_NONE != id); |
| 393 const PathElement* path = canvas->image_scale() == 1.f | 393 const PathElement* path = canvas->image_scale() == 1.f |
| 394 ? GetPathForVectorIconAt1xScale(id) | 394 ? GetPathForVectorIconAt1xScale(id) |
| 395 : GetPathForVectorIcon(id); | 395 : GetPathForVectorIcon(id); |
| 396 PaintPath(canvas, path, dip_size, color); | 396 PaintPath(canvas, path, dip_size, color); |
| 397 } | 397 } |
| 398 | 398 |
| 399 ImageSkia CreateVectorIcon(VectorIconId id, SkColor color) { |
| 400 const PathElement* one_x_path = GetPathForVectorIconAt1xScale(id); |
| 401 size_t size = one_x_path[0].type == CANVAS_DIMENSIONS ? one_x_path[1].arg |
| 402 : kReferenceSizeDip; |
| 403 return CreateVectorIcon(id, size, color); |
| 404 } |
| 405 |
| 399 ImageSkia CreateVectorIcon(VectorIconId id, size_t dip_size, SkColor color) { | 406 ImageSkia CreateVectorIcon(VectorIconId id, size_t dip_size, SkColor color) { |
| 400 return CreateVectorIconWithBadge(id, dip_size, color, | 407 return CreateVectorIconWithBadge(id, dip_size, color, |
| 401 VectorIconId::VECTOR_ICON_NONE); | 408 VectorIconId::VECTOR_ICON_NONE); |
| 402 } | 409 } |
| 403 | 410 |
| 404 ImageSkia CreateVectorIconWithBadge(VectorIconId id, | 411 ImageSkia CreateVectorIconWithBadge(VectorIconId id, |
| 405 size_t dip_size, | 412 size_t dip_size, |
| 406 SkColor color, | 413 SkColor color, |
| 407 VectorIconId badge_id) { | 414 VectorIconId badge_id) { |
| 408 return (id == VectorIconId::VECTOR_ICON_NONE) | 415 return (id == VectorIconId::VECTOR_ICON_NONE) |
| 409 ? gfx::ImageSkia() | 416 ? gfx::ImageSkia() |
| 410 : g_icon_cache.Get().GetOrCreateIcon(id, dip_size, color, | 417 : g_icon_cache.Get().GetOrCreateIcon(id, dip_size, color, |
| 411 badge_id); | 418 badge_id); |
| 412 } | 419 } |
| 413 | 420 |
| 414 ImageSkia CreateVectorIconFromSource(const std::string& source, | 421 ImageSkia CreateVectorIconFromSource(const std::string& source, |
| 415 size_t dip_size, | 422 size_t dip_size, |
| 416 SkColor color) { | 423 SkColor color) { |
| 417 return ImageSkia( | 424 return ImageSkia( |
| 418 new VectorIconSource(source, dip_size, color), | 425 new VectorIconSource(source, dip_size, color), |
| 419 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); | 426 gfx::Size(static_cast<int>(dip_size), static_cast<int>(dip_size))); |
| 420 } | 427 } |
| 421 | 428 |
| 422 } // namespace gfx | 429 } // namespace gfx |
| OLD | NEW |