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

Issue 2774093002: Change PowerStatus::GetBatteryImage to not use ExtractImageRep and scale (Closed)

Created:
3 years, 9 months ago by danakj
Modified:
3 years, 8 months ago
CC:
chromium-reviews, kalyank, sadrul, oshima+watch_chromium.org, enne (OOO)
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Change PowerStatus::GetBatteryImage to not use ExtractImageRep and scale This changes PowerStatus::GetBatteryImage to take a scale parameter, and to use GetBitmap() instead of ExtractImageRep() which copies pixels out of the gfx::Canvas, since it uses a constructor that builds a bitmap. In order to raster the correct scale, this changes TrayPower to make an ImageSkiaSource instead of generating a bitmap off a fixed device scale factor. In the process, the return type had to change from ImageSkia to ImageSkiaRep, so rather than updating the dead non-material design path, I've removed that code. R=estade@chromium.org, pkasting@chromium.org BUG=671433, 614453 Review-Url: https://codereview.chromium.org/2774093002 Cr-Commit-Position: refs/heads/master@{#461484} Committed: https://chromium.googlesource.com/chromium/src/+/df0952b6d946aeddee245b2085acba1a0e7ba654

Patch Set 1 : powericon: name #

Total comments: 16

Patch Set 2 : powericon: . #

Total comments: 4

Patch Set 3 : powericon: nits #

Patch Set 4 : powericon: removedeadunittestcode #

Unified diffs Side-by-side diffs Delta from patch set Stats (+74 lines, -110 lines) Patch
M ash/common/system/chromeos/power/power_status.h View 1 2 chunks +6 lines, -5 lines 0 comments Download
M ash/common/system/chromeos/power/power_status.cc View 1 4 chunks +12 lines, -10 lines 0 comments Download
M ash/common/system/chromeos/power/power_status_unittest.cc View 1 6 chunks +21 lines, -51 lines 0 comments Download
M ash/common/system/chromeos/power/power_status_view.h View 1 2 2 chunks +0 lines, -8 lines 0 comments Download
M ash/common/system/chromeos/power/power_status_view.cc View 1 2 4 chunks +4 lines, -23 lines 0 comments Download
M ash/common/system/chromeos/power/power_status_view_unittest.cc View 1 2 3 1 chunk +0 lines, -2 lines 0 comments Download
M ash/common/system/chromeos/power/tray_power.cc View 1 3 chunks +31 lines, -11 lines 0 comments Download

Messages

Total messages: 35 (22 generated)
danakj
3 years, 9 months ago (2017-03-24 23:57:14 UTC) #4
Peter Kasting
https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/power_status.cc File ash/common/system/chromeos/power/power_status.cc (left): https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/power_status.cc#oldcode441 ash/common/system/chromeos/power/power_status.cc:441: info.index * kBatteryImageHeight, kBatteryImageWidth, With this removal, |resource_id|, |offset|, ...
3 years, 9 months ago (2017-03-25 00:22:31 UTC) #9
Evan Stade
https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/power_status.cc File ash/common/system/chromeos/power/power_status.cc (left): https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/power_status.cc#oldcode441 ash/common/system/chromeos/power/power_status.cc:441: info.index * kBatteryImageHeight, kBatteryImageWidth, On 2017/03/25 00:22:30, Peter Kasting ...
3 years, 9 months ago (2017-03-27 15:11:23 UTC) #12
danakj
PTAL https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/power_status_view.cc File ash/common/system/chromeos/power/power_status_view.cc (left): https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/power_status_view.cc#oldcode62 ash/common/system/chromeos/power/power_status_view.cc:62: PowerStatus::Get()->GetBatteryImageInfo(PowerStatus::ICON_DARK); On 2017/03/25 00:22:30, Peter Kasting wrote: > ...
3 years, 8 months ago (2017-03-31 20:49:05 UTC) #13
Peter Kasting
https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/tray_power.cc File ash/common/system/chromeos/power/tray_power.cc (right): https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/tray_power.cc#newcode96 ash/common/system/chromeos/power/tray_power.cc:96: PowerTrayImageSource(const PowerStatus::BatteryImageInfo& info) On 2017/03/31 20:49:04, danakj wrote: > ...
3 years, 8 months ago (2017-03-31 22:07:20 UTC) #18
Peter Kasting
LGTM BTW, I trust you to resolve the above issues in some appropriate way
3 years, 8 months ago (2017-04-01 05:55:41 UTC) #19
danakj
https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/tray_power.cc File ash/common/system/chromeos/power/tray_power.cc (right): https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/tray_power.cc#newcode96 ash/common/system/chromeos/power/tray_power.cc:96: PowerTrayImageSource(const PowerStatus::BatteryImageInfo& info) On 2017/03/31 22:07:20, Peter Kasting wrote: ...
3 years, 8 months ago (2017-04-03 14:43:14 UTC) #20
danakj
+oshima for OWNERS
3 years, 8 months ago (2017-04-03 14:43:47 UTC) #22
oshima
lgtm
3 years, 8 months ago (2017-04-03 17:45:36 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2774093002/80001
3 years, 8 months ago (2017-04-03 17:53:20 UTC) #30
commit-bot: I haz the power
Committed patchset #4 (id:80001) as https://chromium.googlesource.com/chromium/src/+/df0952b6d946aeddee245b2085acba1a0e7ba654
3 years, 8 months ago (2017-04-03 18:39:37 UTC) #33
Peter Kasting
https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/tray_power.cc File ash/common/system/chromeos/power/tray_power.cc (right): https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chromeos/power/tray_power.cc#newcode96 ash/common/system/chromeos/power/tray_power.cc:96: PowerTrayImageSource(const PowerStatus::BatteryImageInfo& info) On 2017/04/03 14:43:13, danakj wrote: > ...
3 years, 8 months ago (2017-04-03 20:32:51 UTC) #34
danakj
3 years, 8 months ago (2017-04-03 21:30:55 UTC) #35
Message was sent while issue was closed.
On 2017/04/03 20:32:51, Peter Kasting wrote:
>
https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chrom...
> File ash/common/system/chromeos/power/tray_power.cc (right):
> 
>
https://codereview.chromium.org/2774093002/diff/20001/ash/common/system/chrom...
> ash/common/system/chromeos/power/tray_power.cc:96: PowerTrayImageSource(const
> PowerStatus::BatteryImageInfo& info)
> On 2017/04/03 14:43:13, danakj wrote:
> > I think everything I wrote above is accurate but I might have something
wrong
> > too. Does this agree with what you read?
> 
> It sounds like pass-by-value + move-into-place is either 2 moves or 1 move + 1
> copy (depending on caller), while pass-by-const-ref is 1-2 copies plus
possibly
> forcing the arg to the stack (you didn't mention this but I think it's true?).

> If move and copy are the same cost, then pass-by-const-ref is usually better?
> 
> I thought in some cases the compiler could optimize move constructors away
> entirely, though, if it was able to move/copy the argument directly into the
> right place.  That's the case where pass-by-value might be a win.

Oh this sounds like RVO, I guess that can apply when the item is a native
rvalue.

CallingThing(ThisIsRVOYay());

That would require no copy or move from the caller, and just a move inside the
method to assign to the member. So that'd be a case where pass-by-value wins
clearly.

Whereas a const& would need an lvalue, so it would destroy RVO. I think that's
what I was thinking of when I mentioned native rvalues, without realizing I was
talking about RVO.

So pass-by-value is:
- 2 moves if you had an lvalue and casted
- 1 copy + 1 move if you had an lvalue and didn't cast
- 1 move if you had an rvalue and RVO worked
- 2 moves if you had an rvalue and RVO didn't work

And pass-by-constref is:
- 1 copy if you had an lvalue
- 2 copies if you had a rvalue cuz you can't RVO

So by-value optimizes for rvalues but hurts lvalues, and by-constref optimizes
for
lvalues but hurts rvalues... but by-value takes advantage of move being cheaper
when relevant to the type. To me then, the easy rule here is const-ref unless
move is cheaper than copy (or required) for the type. This is consistent with
our
historical practices, and the only time by-value is better (when move == copy)
is
when you had an rvalue and you're getting RVO assistance.

> Anyway, it definitely doesn't matter here, so I'm happy whichever way.  I'm
more
> trying to figure this out so I know what best practices are for future code.

Powered by Google App Engine
This is Rietveld 408576698