OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/extensions/icon_with_badge_image_source.h" | 5 #include "chrome/browser/ui/extensions/icon_with_badge_image_source.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // typeface will be NULL. If we don't do manual fallback then we'll crash. | 75 // typeface will be NULL. If we don't do manual fallback then we'll crash. |
76 if (typeface) { | 76 if (typeface) { |
77 text_paint->setFakeBoldText(true); | 77 text_paint->setFakeBoldText(true); |
78 } else { | 78 } else { |
79 // Fall back to the system font. We don't bold it because we aren't sure | 79 // Fall back to the system font. We don't bold it because we aren't sure |
80 // how it will look. | 80 // how it will look. |
81 // For the most part this code path will only be hit on Linux systems | 81 // For the most part this code path will only be hit on Linux systems |
82 // that don't have Arial. | 82 // that don't have Arial. |
83 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 83 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
84 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 84 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
85 typeface = sk_sp<SkTypeface>(SkTypeface::MakeFromName( | 85 typeface = SkTypeface::MakeFromName(base_font.GetFontName().c_str(), |
86 base_font.GetFontName().c_str(), SkFontStyle())); | 86 SkFontStyle()); |
87 DCHECK(typeface); | 87 DCHECK(typeface); |
88 } | 88 } |
89 | 89 |
90 text_paint->setTypeface(typeface.get()); | 90 text_paint->setTypeface(std::move(typeface)); |
91 // |text_paint| adds its own ref. Release the ref from CreateFontName. | |
92 } | 91 } |
93 return text_paint; | 92 return text_paint; |
94 } | 93 } |
95 | 94 |
96 gfx::ImageSkiaRep ScaleImageSkiaRep(const gfx::ImageSkiaRep& rep, | 95 gfx::ImageSkiaRep ScaleImageSkiaRep(const gfx::ImageSkiaRep& rep, |
97 int target_width_dp, | 96 int target_width_dp, |
98 float target_scale) { | 97 float target_scale) { |
99 int width_px = target_width_dp * target_scale; | 98 int width_px = target_width_dp * target_scale; |
100 return gfx::ImageSkiaRep( | 99 return gfx::ImageSkiaRep( |
101 skia::ImageOperations::Resize(rep.sk_bitmap(), | 100 skia::ImageOperations::Resize(rep.sk_bitmap(), |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 306 } |
308 | 307 |
309 void IconWithBadgeImageSource::PaintBlockedActionDecoration( | 308 void IconWithBadgeImageSource::PaintBlockedActionDecoration( |
310 gfx::Canvas* canvas) { | 309 gfx::Canvas* canvas) { |
311 canvas->Save(); | 310 canvas->Save(); |
312 gfx::ImageSkia img = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 311 gfx::ImageSkia img = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
313 IDR_BLOCKED_EXTENSION_SCRIPT); | 312 IDR_BLOCKED_EXTENSION_SCRIPT); |
314 canvas->DrawImageInt(img, size().width() - img.width(), 0); | 313 canvas->DrawImageInt(img, size().width() - img.width(), 0); |
315 canvas->Restore(); | 314 canvas->Restore(); |
316 } | 315 } |
OLD | NEW |