| 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 "components/favicon/core/fallback_icon_service.h" | 5 #include "components/favicon/core/fallback_icon_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return bitmap_data; | 51 return bitmap_data; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void FallbackIconService::DrawFallbackIcon( | 54 void FallbackIconService::DrawFallbackIcon( |
| 55 const GURL& icon_url, | 55 const GURL& icon_url, |
| 56 int size, | 56 int size, |
| 57 const favicon_base::FallbackIconStyle& style, | 57 const favicon_base::FallbackIconStyle& style, |
| 58 gfx::Canvas* canvas) { | 58 gfx::Canvas* canvas) { |
| 59 const int kOffsetX = 0; | 59 const int kOffsetX = 0; |
| 60 const int kOffsetY = 0; | 60 const int kOffsetY = 0; |
| 61 SkPaint paint; | 61 cc::PaintFlags paint; |
| 62 paint.setStyle(SkPaint::kFill_Style); | 62 paint.setStyle(cc::PaintFlags::kFill_Style); |
| 63 paint.setAntiAlias(true); | 63 paint.setAntiAlias(true); |
| 64 | 64 |
| 65 // Draw a filled, colored rounded square. | 65 // Draw a filled, colored rounded square. |
| 66 paint.setColor(style.background_color); | 66 paint.setColor(style.background_color); |
| 67 int corner_radius = static_cast<int>(size * style.roundness * 0.5 + 0.5); | 67 int corner_radius = static_cast<int>(size * style.roundness * 0.5 + 0.5); |
| 68 canvas->DrawRoundRect( | 68 canvas->DrawRoundRect( |
| 69 gfx::Rect(kOffsetX, kOffsetY, size, size), corner_radius, paint); | 69 gfx::Rect(kOffsetX, kOffsetY, size, size), corner_radius, paint); |
| 70 | 70 |
| 71 // Draw text. | 71 // Draw text. |
| 72 base::string16 icon_text = GetFallbackIconText(icon_url); | 72 base::string16 icon_text = GetFallbackIconText(icon_url); |
| 73 if (icon_text.empty()) | 73 if (icon_text.empty()) |
| 74 return; | 74 return; |
| 75 int font_size = static_cast<int>(size * style.font_size_ratio); | 75 int font_size = static_cast<int>(size * style.font_size_ratio); |
| 76 if (font_size <= 0) | 76 if (font_size <= 0) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 canvas->DrawStringRectWithFlags( | 79 canvas->DrawStringRectWithFlags( |
| 80 icon_text, | 80 icon_text, |
| 81 gfx::FontList(fallback_icon_client_->GetFontNameList(), gfx::Font::NORMAL, | 81 gfx::FontList(fallback_icon_client_->GetFontNameList(), gfx::Font::NORMAL, |
| 82 font_size, gfx::Font::Weight::NORMAL), | 82 font_size, gfx::Font::Weight::NORMAL), |
| 83 style.text_color, gfx::Rect(kOffsetX, kOffsetY, size, size), | 83 style.text_color, gfx::Rect(kOffsetX, kOffsetY, size, size), |
| 84 gfx::Canvas::TEXT_ALIGN_CENTER); | 84 gfx::Canvas::TEXT_ALIGN_CENTER); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace favicon | 87 } // namespace favicon |
| OLD | NEW |