Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Unified Diff: ash/common/system/chromeos/power/power_status.cc

Issue 2774093002: Change PowerStatus::GetBatteryImage to not use ExtractImageRep and scale (Closed)
Patch Set: powericon: removedeadunittestcode Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/common/system/chromeos/power/power_status.cc
diff --git a/ash/common/system/chromeos/power/power_status.cc b/ash/common/system/chromeos/power/power_status.cc
index 7e019fee24f86fbce235042b70e71ada8f8474a5..866d4118d75044fe2b39879d1b0d6076529a97cc 100644
--- a/ash/common/system/chromeos/power/power_status.cc
+++ b/ash/common/system/chromeos/power/power_status.cc
@@ -21,7 +21,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
-#include "ui/gfx/image/image_skia_operations.h"
+#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/paint_vector_icon.h"
namespace ash {
@@ -290,8 +290,7 @@ std::string PowerStatus::GetCurrentPowerSourceID() const {
return proto_.external_power_source_id();
}
-PowerStatus::BatteryImageInfo PowerStatus::GetBatteryImageInfo(
- IconSet icon_set) const {
+PowerStatus::BatteryImageInfo PowerStatus::GetBatteryImageInfo() const {
BatteryImageInfo info;
CalculateBatteryImageInfo(&info);
return info;
@@ -328,18 +327,21 @@ void PowerStatus::CalculateBatteryImageInfo(BatteryImageInfo* info) const {
}
}
-gfx::ImageSkia PowerStatus::GetBatteryImage(
- const BatteryImageInfo& info) const {
+// static
+gfx::Size PowerStatus::GetBatteryImageSizeInDip() {
+ return gfx::Size(kBatteryCanvasSize, kBatteryCanvasSize);
+}
+
+gfx::ImageSkiaRep PowerStatus::GetBatteryImage(const BatteryImageInfo& info,
+ float scale) const {
const bool use_alert_color =
(info.charge_level == kMinVisualChargeLevel && !IsLinePowerConnected());
const SkColor badge_color =
use_alert_color ? kBatteryAlertColor : kBatteryBadgeColor;
const SkColor charge_color =
use_alert_color ? kBatteryAlertColor : kBatteryChargeColor;
- gfx::Canvas canvas(
- gfx::Size(kBatteryCanvasSize, kBatteryCanvasSize),
- display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(),
- false);
+
+ gfx::Canvas canvas(GetBatteryImageSizeInDip(), scale, false /* opaque */);
// Paint the battery's base (background) color.
PaintVectorIcon(&canvas, kSystemTrayBatteryIcon, kBatteryCanvasSize,
@@ -361,7 +363,7 @@ gfx::ImageSkia PowerStatus::GetBatteryImage(
if (info.icon_badge)
PaintVectorIcon(&canvas, *info.icon_badge, kBatteryCanvasSize, badge_color);
- return gfx::ImageSkia(canvas.ExtractImageRep());
+ return gfx::ImageSkiaRep(canvas.GetBitmap(), scale);
}
base::string16 PowerStatus::GetAccessibleNameString(
« no previous file with comments | « ash/common/system/chromeos/power/power_status.h ('k') | ash/common/system/chromeos/power/power_status_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698