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

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: name 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 d7dd534da72a0ba07308b13292851b9a6b83c7c0..f91f9bb7a3a3b18d48cb9f29ff73a257333edaf0 100644
--- a/ash/common/system/chromeos/power/power_status.cc
+++ b/ash/common/system/chromeos/power/power_status.cc
@@ -24,7 +24,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 {
@@ -123,10 +123,6 @@ static PowerStatus* g_power_status = NULL;
// Minimum battery percentage rendered in UI.
const int kMinBatteryPercent = 1;
-// Width and height of battery images.
-const int kBatteryImageHeight = 25;
-const int kBatteryImageWidth = 25;
-
// Number of different power states.
const int kNumPowerImages = 15;
@@ -392,21 +388,21 @@ void PowerStatus::CalculateBatteryImageInfoNonMd(
}
}
-gfx::ImageSkia PowerStatus::GetBatteryImage(
- const BatteryImageInfo& info) const {
- if (!MaterialDesignController::UseMaterialDesignSystemIcons())
- return GetBatteryImageNonMd(info);
+// static
+gfx::Size PowerStatus::GetBatteryImageSizeInDip() {
+ return gfx::Size(kBatteryCanvasSizeMd, kBatteryCanvasSizeMd);
Peter Kasting 2017/03/25 00:22:30 Nit: Now that there is no non-MD path, remove "Md"
+}
+gfx::ImageSkiaRep PowerStatus::GetBatteryImage(const BatteryImageInfo& info,
+ float scale) const {
const bool use_alert_color =
(info.charge_level == kMinVisualChargeLevelMd && !IsLinePowerConnected());
const SkColor badge_color =
use_alert_color ? kBatteryAlertColor : kBatteryBadgeColor;
const SkColor charge_color =
use_alert_color ? kBatteryAlertColor : kBatteryChargeColor;
- gfx::Canvas canvas(
- gfx::Size(kBatteryCanvasSizeMd, kBatteryCanvasSizeMd),
- 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, kBatteryCanvasSizeMd,
@@ -430,17 +426,7 @@ gfx::ImageSkia PowerStatus::GetBatteryImage(
kBatteryCanvasSizeMd, badge_color);
}
- return gfx::ImageSkia(canvas.ExtractImageRep());
-}
-
-gfx::ImageSkia PowerStatus::GetBatteryImageNonMd(
- const BatteryImageInfo& info) const {
- gfx::Image all;
- all = ui::ResourceBundle::GetSharedInstance().GetImageNamed(info.resource_id);
- gfx::Rect region(info.offset * kBatteryImageWidth,
- info.index * kBatteryImageHeight, kBatteryImageWidth,
Peter Kasting 2017/03/25 00:22:30 With this removal, |resource_id|, |offset|, and |i
Evan Stade 2017/03/27 15:11:23 that's all done here: https://codereview.chromium.
- kBatteryImageHeight);
- return gfx::ImageSkiaOperations::ExtractSubset(*all.ToImageSkia(), region);
+ return gfx::ImageSkiaRep(canvas.GetBitmap(), scale);
}
base::string16 PowerStatus::GetAccessibleNameString(

Powered by Google App Engine
This is Rietveld 408576698