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 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
13 #include "third_party/skia/include/core/SkPaint.h" | 14 #include "third_party/skia/include/core/SkPaint.h" |
14 #include "third_party/skia/include/core/SkTypeface.h" | 15 #include "third_party/skia/include/core/SkTypeface.h" |
15 #include "ui/base/resource/material_design/material_design_controller.h" | 16 #include "ui/base/resource/material_design/material_design_controller.h" |
16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
17 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/color_palette.h" | 19 #include "ui/gfx/color_palette.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 grayscale_(false), | 103 grayscale_(false), |
103 paint_decoration_(false) {} | 104 paint_decoration_(false) {} |
104 | 105 |
105 IconWithBadgeImageSource::~IconWithBadgeImageSource() {} | 106 IconWithBadgeImageSource::~IconWithBadgeImageSource() {} |
106 | 107 |
107 void IconWithBadgeImageSource::SetIcon(const gfx::Image& icon) { | 108 void IconWithBadgeImageSource::SetIcon(const gfx::Image& icon) { |
108 icon_ = icon; | 109 icon_ = icon; |
109 } | 110 } |
110 | 111 |
111 void IconWithBadgeImageSource::SetBadge(scoped_ptr<Badge> badge) { | 112 void IconWithBadgeImageSource::SetBadge(scoped_ptr<Badge> badge) { |
112 badge_ = badge.Pass(); | 113 badge_ = std::move(badge); |
113 } | 114 } |
114 | 115 |
115 void IconWithBadgeImageSource::Draw(gfx::Canvas* canvas) { | 116 void IconWithBadgeImageSource::Draw(gfx::Canvas* canvas) { |
116 if (icon_.IsEmpty()) | 117 if (icon_.IsEmpty()) |
117 return; | 118 return; |
118 | 119 |
119 int x_offset = std::floor((size().width() - icon_.Width()) / 2.0); | 120 int x_offset = std::floor((size().width() - icon_.Width()) / 2.0); |
120 int y_offset = std::floor((size().height() - icon_.Height()) / 2.0); | 121 int y_offset = std::floor((size().height() - icon_.Height()) / 2.0); |
121 gfx::ImageSkia skia = icon_.AsImageSkia(); | 122 gfx::ImageSkia skia = icon_.AsImageSkia(); |
122 if (grayscale_) | 123 if (grayscale_) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 gfx::Point center_point(major_radius + 1, size().height() - (major_radius)-1); | 255 gfx::Point center_point(major_radius + 1, size().height() - (major_radius)-1); |
255 SkPaint paint; | 256 SkPaint paint; |
256 paint.setAntiAlias(true); | 257 paint.setAntiAlias(true); |
257 paint.setStyle(SkPaint::kFill_Style); | 258 paint.setStyle(SkPaint::kFill_Style); |
258 paint.setColor(SK_ColorTRANSPARENT); | 259 paint.setColor(SK_ColorTRANSPARENT); |
259 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 260 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
260 canvas->DrawCircle(center_point, major_radius, paint); | 261 canvas->DrawCircle(center_point, major_radius, paint); |
261 paint.setColor(decoration_color); | 262 paint.setColor(decoration_color); |
262 canvas->DrawCircle(center_point, minor_radius, paint); | 263 canvas->DrawCircle(center_point, minor_radius, paint); |
263 } | 264 } |
OLD | NEW |