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

Issue 1777403002: Allow const& for SkImages and SkPictures in draw methods. (Closed)

Created:
4 years, 9 months ago by reed1
Modified:
4 years, 8 months ago
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Allow const& for SkImages and SkPictures in draw methods. This is just a convenience for callers, since we are (strongly) encouraging them to use sk_sp<> for managing image objects (and pictures btw). No change under the hood, as we are keeping our agnostic approach to these for the protected virtuals (since often we don't want to ref the parameter). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1777403002 Committed: https://skia.googlesource.com/skia/+/f8053da25981c6b3152b637c1c91f43cff194c25

Patch Set 1 #

Total comments: 3

Patch Set 2 : use const& instead of value #

Total comments: 2

Patch Set 3 : rebase #

Patch Set 4 : const& for pictures as well #

Total comments: 1

Patch Set 5 : change to const sk_sp<Foo>&, to match the signature of all of our factories and setters #

Unified diffs Side-by-side diffs Delta from patch set Stats (+40 lines, -1 line) Patch
M include/core/SkCanvas.h View 1 2 3 4 6 chunks +40 lines, -1 line 0 comments Download

Messages

Total messages: 56 (19 generated)
reed1
4 years, 9 months ago (2016-03-10 22:01:02 UTC) #3
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1777403002/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1777403002/1
4 years, 9 months ago (2016-03-10 22:01:24 UTC) #5
bsalomon
lgtm
4 years, 9 months ago (2016-03-10 22:02:46 UTC) #6
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: Build-Win-MSVC-x86_64-Debug-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Win-MSVC-x86_64-Debug-Trybot/builds/7089)
4 years, 9 months ago (2016-03-10 22:06:18 UTC) #8
bungeman-skia
https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h File include/core/SkCanvas.h (right): https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h#newcode775 include/core/SkCanvas.h:775: void drawImage(sk_sp<const SkImage> image, SkScalar left, SkScalar top, Taking ...
4 years, 9 months ago (2016-03-10 22:14:02 UTC) #9
bungeman-skia
On 2016/03/10 22:14:02, bungeman1 wrote: > https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h > File include/core/SkCanvas.h (right): > > https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h#newcode775 > ...
4 years, 9 months ago (2016-03-10 22:15:46 UTC) #10
bsalomon
https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h File include/core/SkCanvas.h (right): https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h#newcode775 include/core/SkCanvas.h:775: void drawImage(sk_sp<const SkImage> image, SkScalar left, SkScalar top, On ...
4 years, 9 months ago (2016-03-10 22:22:16 UTC) #11
reed1
Doh! I actually meant to use const sp& for all of those. Will amend. So ...
4 years, 9 months ago (2016-03-10 23:06:01 UTC) #12
bungeman-skia
https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h File include/core/SkCanvas.h (right): https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h#newcode775 include/core/SkCanvas.h:775: void drawImage(sk_sp<const SkImage> image, SkScalar left, SkScalar top, On ...
4 years, 9 months ago (2016-03-10 23:06:14 UTC) #13
bungeman-skia
On 2016/03/10 23:06:14, bungeman1 wrote: > https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h > File include/core/SkCanvas.h (right): > > https://codereview.chromium.org/1777403002/diff/1/include/core/SkCanvas.h#newcode775 > ...
4 years, 9 months ago (2016-03-10 23:15:52 UTC) #14
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1777403002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1777403002/20001
4 years, 9 months ago (2016-03-10 23:51:56 UTC) #16
reed1
now passing by const&
4 years, 9 months ago (2016-03-10 23:51:59 UTC) #17
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 9 months ago (2016-03-11 00:03:59 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1777403002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1777403002/20001
4 years, 9 months ago (2016-03-11 00:21:38 UTC) #22
f(malita)
On 2016/03/10 23:15:52, bungeman1 wrote: > the rvalue with bind to the const sk_sp<const>&, so ...
4 years, 9 months ago (2016-03-11 14:33:40 UTC) #24
reed1
Do we think move scenarios are common for images? Clearly (looking at our code and ...
4 years, 9 months ago (2016-03-11 14:40:32 UTC) #25
f(malita)
On 2016/03/11 14:40:32, reed1 wrote: > Do we think move scenarios are common for images? ...
4 years, 9 months ago (2016-03-11 14:51:28 UTC) #26
mtklein
Here's what we can do if we restrict ourselves to one function, passing by const ...
4 years, 9 months ago (2016-03-11 15:28:00 UTC) #27
bungeman-skia
https://codereview.chromium.org/1777403002/diff/20001/include/core/SkCanvas.h File include/core/SkCanvas.h (right): https://codereview.chromium.org/1777403002/diff/20001/include/core/SkCanvas.h#newcode775 include/core/SkCanvas.h:775: void drawImage(sk_sp<const SkImage>& image, SkScalar left, SkScalar top, First ...
4 years, 9 months ago (2016-03-11 15:31:11 UTC) #28
mtklein
On 2016/03/11 15:28:00, mtklein wrote: > Here's what we can do if we restrict ourselves ...
4 years, 9 months ago (2016-03-11 15:33:47 UTC) #29
bungeman-skia
https://codereview.chromium.org/1777403002/diff/20001/include/core/SkCanvas.h File include/core/SkCanvas.h (right): https://codereview.chromium.org/1777403002/diff/20001/include/core/SkCanvas.h#newcode775 include/core/SkCanvas.h:775: void drawImage(sk_sp<const SkImage>& image, SkScalar left, SkScalar top, On ...
4 years, 9 months ago (2016-03-11 16:03:39 UTC) #30
reed1
Glad this is sparking discussion. I am not in a hurry to land this (or ...
4 years, 9 months ago (2016-03-11 18:07:25 UTC) #31
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1777403002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1777403002/40001
4 years, 9 months ago (2016-03-17 14:17:09 UTC) #33
reed1
ptal
4 years, 9 months ago (2016-03-17 14:19:02 UTC) #35
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1777403002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1777403002/60001
4 years, 9 months ago (2016-03-17 14:21:08 UTC) #37
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 9 months ago (2016-03-17 14:32:35 UTC) #40
bungeman-skia
https://codereview.chromium.org/1777403002/diff/60001/include/core/SkCanvas.h File include/core/SkCanvas.h (right): https://codereview.chromium.org/1777403002/diff/60001/include/core/SkCanvas.h#newcode775 include/core/SkCanvas.h:775: void drawImage(sk_sp<const SkImage>& image, SkScalar left, SkScalar top, These ...
4 years, 9 months ago (2016-03-17 14:46:22 UTC) #41
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1777403002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1777403002/80001
4 years, 9 months ago (2016-03-17 14:55:18 UTC) #43
reed1
agreed. Changed to const sk_sp<Foo>&, to match our factories and setters.
4 years, 9 months ago (2016-03-17 14:55:34 UTC) #44
f(malita)
On 2016/03/17 14:46:22, bungeman1 wrote: > Unfortunately, due to the limitations of the type system ...
4 years, 9 months ago (2016-03-17 14:58:10 UTC) #45
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 9 months ago (2016-03-17 15:03:44 UTC) #47
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1777403002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1777403002/80001
4 years, 9 months ago (2016-03-17 15:14:04 UTC) #50
commit-bot: I haz the power
Committed patchset #5 (id:80001) as https://skia.googlesource.com/skia/+/f8053da25981c6b3152b637c1c91f43cff194c25
4 years, 9 months ago (2016-03-17 15:15:05 UTC) #52
dogben
On 2016/03/17 14:58:10, f(malita) wrote: > On 2016/03/17 14:46:22, bungeman1 wrote: > > Unfortunately, due ...
4 years, 8 months ago (2016-04-06 22:16:24 UTC) #53
f(malita)
On 2016/04/06 22:16:24, Ben Wagner wrote: > On 2016/03/17 14:58:10, f(malita) wrote: > > On ...
4 years, 8 months ago (2016-04-07 13:11:57 UTC) #54
reed1
On 2016/04/06 22:16:24, Ben Wagner wrote: > On 2016/03/17 14:58:10, f(malita) wrote: > > On ...
4 years, 8 months ago (2016-04-07 13:40:12 UTC) #55
bungeman-skia
4 years, 8 months ago (2016-04-07 14:17:46 UTC) #56
Message was sent while issue was closed.
On 2016/04/07 13:40:12, reed1 wrote:
> On 2016/04/06 22:16:24, Ben Wagner wrote:
> > On 2016/03/17 14:58:10, f(malita) wrote:
> > > On 2016/03/17 14:46:22, bungeman1 wrote:
> > > > Unfortunately, due to the limitations of the type system and whatnot, we
> may
> > > be
> > > > better off with a 'borrowed_sk_sp' type to represent this sort of
> borrowing.
> > > 
> > > PassRefPtr? :)
> > > 
> > > 
> > > On 2016/03/17 14:55:34, reed1 wrote:
> > > > agreed. Changed to const sk_sp<Foo>&, to match our factories and
setters.
> > > 
> > > const sk_sp<Foo>& lgtm
> > 
> > So, we decided against simple "const SkImage&" because sometimes we will
take
> a
> > ref when drawing?
> 
> We have always had simple "SkImage*", and we still do. The sp variants are
just
> convenience helpers so callers don't have to say obj.get() each time.

And if you take "const SkImage&" you can say '*obj' instead of obj.get(), which
is much terser. Of course, this also states that you don't take nullptr, which
isn't always the case.

Powered by Google App Engine
This is Rietveld 408576698