| 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 "ash/common/system/chromeos/network/network_icon.h" | 5 #include "ash/common/system/chromeos/network/network_icon.h" |
| 6 | 6 |
| 7 #include "ash/common/strings/grit/ash_strings.h" | 7 #include "ash/common/strings/grit/ash_strings.h" |
| 8 #include "ash/common/system/chromeos/network/network_icon_animation.h" | 8 #include "ash/common/system/chromeos/network/network_icon_animation.h" |
| 9 #include "ash/common/system/chromeos/network/network_icon_animation_observer.h" | 9 #include "ash/common/system/chromeos/network/network_icon_animation_observer.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 oval_bounds.Inset(gfx::Insets(kIconInset)); | 302 oval_bounds.Inset(gfx::Insets(kIconInset)); |
| 303 // Double the width and height. The new midpoint should be the former | 303 // Double the width and height. The new midpoint should be the former |
| 304 // bottom center. | 304 // bottom center. |
| 305 oval_bounds.Inset(-oval_bounds.width() / 2, 0, -oval_bounds.width() / 2, | 305 oval_bounds.Inset(-oval_bounds.width() / 2, 0, -oval_bounds.width() / 2, |
| 306 -oval_bounds.height()); | 306 -oval_bounds.height()); |
| 307 | 307 |
| 308 const SkScalar kAngleAboveHorizontal = 51.f; | 308 const SkScalar kAngleAboveHorizontal = 51.f; |
| 309 const SkScalar kStartAngle = 180.f + kAngleAboveHorizontal; | 309 const SkScalar kStartAngle = 180.f + kAngleAboveHorizontal; |
| 310 const SkScalar kSweepAngle = 180.f - 2 * kAngleAboveHorizontal; | 310 const SkScalar kSweepAngle = 180.f - 2 * kAngleAboveHorizontal; |
| 311 | 311 |
| 312 SkPaint paint; | 312 cc::PaintFlags flags; |
| 313 paint.setAntiAlias(true); | 313 flags.setAntiAlias(true); |
| 314 paint.setStyle(SkPaint::kFill_Style); | 314 flags.setStyle(cc::PaintFlags::kFill_Style); |
| 315 // Background. Skip drawing for full signal. | 315 // Background. Skip drawing for full signal. |
| 316 if (signal_strength_ != kNumNetworkImages - 1) { | 316 if (signal_strength_ != kNumNetworkImages - 1) { |
| 317 paint.setColor(SkColorSetA(color_, kBgAlpha)); | 317 flags.setColor(SkColorSetA(color_, kBgAlpha)); |
| 318 canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, | 318 canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, |
| 319 kSweepAngle, true, paint); | 319 kSweepAngle, true, flags); |
| 320 } | 320 } |
| 321 // Foreground (signal strength). | 321 // Foreground (signal strength). |
| 322 if (signal_strength_ != 0) { | 322 if (signal_strength_ != 0) { |
| 323 paint.setColor(color_); | 323 flags.setColor(color_); |
| 324 // Percent of the height of the background wedge that we draw the | 324 // Percent of the height of the background wedge that we draw the |
| 325 // foreground wedge, indexed by signal strength. | 325 // foreground wedge, indexed by signal strength. |
| 326 static const float kWedgeHeightPercentages[] = {0.f, 0.375f, 0.5833f, | 326 static const float kWedgeHeightPercentages[] = {0.f, 0.375f, 0.5833f, |
| 327 0.75f, 1.f}; | 327 0.75f, 1.f}; |
| 328 const float wedge_percent = kWedgeHeightPercentages[signal_strength_]; | 328 const float wedge_percent = kWedgeHeightPercentages[signal_strength_]; |
| 329 oval_bounds.Inset( | 329 oval_bounds.Inset( |
| 330 gfx::InsetsF((oval_bounds.height() / 2) * (1.f - wedge_percent))); | 330 gfx::InsetsF((oval_bounds.height() / 2) * (1.f - wedge_percent))); |
| 331 canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, | 331 canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, |
| 332 kSweepAngle, true, paint); | 332 kSweepAngle, true, flags); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 void DrawBars(gfx::Canvas* canvas) { | 336 void DrawBars(gfx::Canvas* canvas) { |
| 337 // Undo the canvas's device scaling and round values to the nearest whole | 337 // Undo the canvas's device scaling and round values to the nearest whole |
| 338 // number so we can draw on exact pixel boundaries. | 338 // number so we can draw on exact pixel boundaries. |
| 339 const float dsf = canvas->UndoDeviceScaleFactor(); | 339 const float dsf = canvas->UndoDeviceScaleFactor(); |
| 340 auto scale = [dsf](SkScalar dimension) { | 340 auto scale = [dsf](SkScalar dimension) { |
| 341 return std::round(dimension * dsf); | 341 return std::round(dimension * dsf); |
| 342 }; | 342 }; |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 network_paths.insert((*iter)->path()); | 948 network_paths.insert((*iter)->path()); |
| 949 } | 949 } |
| 950 PurgeIconMap(ICON_TYPE_TRAY, network_paths); | 950 PurgeIconMap(ICON_TYPE_TRAY, network_paths); |
| 951 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); | 951 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); |
| 952 PurgeIconMap(ICON_TYPE_LIST, network_paths); | 952 PurgeIconMap(ICON_TYPE_LIST, network_paths); |
| 953 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); | 953 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); |
| 954 } | 954 } |
| 955 | 955 |
| 956 } // namespace network_icon | 956 } // namespace network_icon |
| 957 } // namespace ash | 957 } // namespace ash |
| OLD | NEW |