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

Issue 2349923002: Add getters for gfx::ColorSpace components (Closed)

Created:
4 years, 3 months ago by servolk
Modified:
3 years, 8 months ago
Reviewers:
danakj, hubbe, ccameron
CC:
chromium-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add getters for gfx::ColorSpace components

Patch Set 1 #

Patch Set 2 : Added tests for getters #

Unified diffs Side-by-side diffs Delta from patch set Stats (+10 lines, -0 lines) Patch
M ui/gfx/color_space.h View 1 chunk +5 lines, -0 lines 0 comments Download
M ui/gfx/color_transform_unittest.cc View 1 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 23 (8 generated)
servolk
4 years, 3 months ago (2016-09-16 23:53:55 UTC) #4
hubbe
We've intentionally avoided this so far. I'm personally ok with adding them, but I'd like ...
4 years, 3 months ago (2016-09-16 23:57:54 UTC) #6
hubbe
On 2016/09/16 23:57:54, hubbe wrote: > We've intentionally avoided this so far. > I'm personally ...
4 years, 3 months ago (2016-09-16 23:58:56 UTC) #7
servolk
On 2016/09/16 23:57:54, hubbe wrote: > We've intentionally avoided this so far. > I'm personally ...
4 years, 3 months ago (2016-09-17 00:02:09 UTC) #8
servolk
On 2016/09/16 23:58:56, hubbe wrote: > On 2016/09/16 23:57:54, hubbe wrote: > > We've intentionally ...
4 years, 3 months ago (2016-09-17 00:09:24 UTC) #10
hubbe
lgtm
4 years, 3 months ago (2016-09-19 17:34:06 UTC) #14
ccameron
On 2016/09/17 00:02:09, servolk wrote: > On 2016/09/16 23:57:54, hubbe wrote: > > We've intentionally ...
4 years, 3 months ago (2016-09-19 17:58:02 UTC) #15
servolk
On 2016/09/19 17:58:02, ccameron wrote: > On 2016/09/17 00:02:09, servolk wrote: > > On 2016/09/16 ...
4 years, 3 months ago (2016-09-19 18:16:58 UTC) #16
ccameron
On 2016/09/19 18:16:58, servolk wrote: > On 2016/09/19 17:58:02, ccameron wrote: > > On 2016/09/17 ...
4 years, 3 months ago (2016-09-19 18:27:32 UTC) #17
hubbe
On 2016/09/19 17:58:02, ccameron wrote: > On 2016/09/17 00:02:09, servolk wrote: > > On 2016/09/16 ...
4 years, 3 months ago (2016-09-19 19:30:58 UTC) #18
servolk
On 2016/09/19 18:27:32, ccameron wrote: > On 2016/09/19 18:16:58, servolk wrote: > > On 2016/09/19 ...
4 years, 3 months ago (2016-09-19 21:40:20 UTC) #19
hubbe
On 2016/09/19 21:40:20, servolk wrote: > On 2016/09/19 18:27:32, ccameron wrote: > > On 2016/09/19 ...
4 years, 3 months ago (2016-09-19 22:22:43 UTC) #20
servolk
On 2016/09/19 22:22:43, hubbe wrote: > On 2016/09/19 21:40:20, servolk wrote: > > On 2016/09/19 ...
4 years, 3 months ago (2016-09-20 21:50:23 UTC) #21
hubbe
On 2016/09/20 21:50:23, servolk wrote: > On 2016/09/19 22:22:43, hubbe wrote: > > On 2016/09/19 ...
4 years, 3 months ago (2016-09-20 22:21:36 UTC) #22
servolk
4 years, 3 months ago (2016-09-20 23:01:31 UTC) #23
On 2016/09/20 22:21:36, hubbe wrote:
> On 2016/09/20 21:50:23, servolk wrote:
> > On 2016/09/19 22:22:43, hubbe wrote:
> > > On 2016/09/19 21:40:20, servolk wrote:
> > > > On 2016/09/19 18:27:32, ccameron wrote:
> > > > > On 2016/09/19 18:16:58, servolk wrote:
> > > > > > On 2016/09/19 17:58:02, ccameron wrote:
> > > > > > > On 2016/09/17 00:02:09, servolk wrote:
> > > > > > > > On 2016/09/16 23:57:54, hubbe wrote:
> > > > > > > > > We've intentionally avoided this so far.
> > > > > > > > > I'm personally ok with adding them, but I'd like to know why
you
> > > need
> > > > > > them.
> > > > > > > > 
> > > > > > > > On Chromecast we are using VideoDecoderConfig to carry this
> > > information
> > > > > > > through
> > > > > > > > Chromium media pipeline, but in the end we need to get this out
of
> > the
> > > > > > > > VideoDecoderConfig to give it to our platform hardware decoders
> > (which
> > > > are
> > > > > > > using
> > > > > > > > vendor-specific data structures for this, and not Chromium's
> > > > > > > > VideoDecoderConfig).
> > > > > > > 
> > > > > > > Sorry, I'm not okay with this.
> > > > > > > 
> > > > > > > I'd prefer:
> > > > > > > 1. If the HW decoder only supports a few formats, then just
compare
> > > > > > > gfx::ColorSpace objects (like, say "input_color_space ==
> > > > > > > gfx::ColorSpace::GetSRGB()" to test if it's SRGB).
> > > > > > > 
> > > > > > > If that's not possible:
> > > > > > > 2. Just add a friend class to do the conversion.
> > > > > > 
> > > > > > Chris, could you please explan why you don't like having getters? I
> > think
> > > > > that's
> > > > > > consistent with other structs that we have elsewhere in ui/gfx and
> > media/
> > > > > code,
> > > > > > so if anything I'd prefer to have getters also here for consistency.
> > > > > > 
> > > > > > I'm not sure that what you suggested are really viable solutions.
> > > > > > #1 is not scalable, there are many possible combinations of color
> space
> > > > > > parameters. It's probably not a good idea to introduce a separate
> > > ColorSpace
> > > > > > constructor for each possible combination. Besides, there is
actually
> a
> > > TODO
> > > > > > saying we should remove at least some of those
> > > > > >
> (https://cs.chromium.org/chromium/src/ui/gfx/color_space.h?rcl=0&l=127).
> > > > > > 
> > > > > > #2 adding friends for every place where we need to access individual
> > > > > components
> > > > > > also doesn't seem like a good scalable solution to me. To quote
Google
> > C++
> > > > > style
> > > > > > guide (https://google.github.io/styleguide/cppguide.html#Friends):
> > > > > > > Friends should usually be defined in the same file so that the
> reader
> > > does
> > > > > not
> > > > > > have to look in another file
> > > > > > > to find uses of the private members of a class.
> > > > > > > In some cases this is better than making a member public when you
> want
> > > to
> > > > > give
> > > > > > only one other class access to it.
> > > > > > > However, most classes should interact with other classes solely
> > through
> > > > > their
> > > > > > public members.
> > > > > > So there's a few problems here:
> > > > > > 1. We already have 3 friend declarations there, and now we are about
> to
> > > add
> > > > > one
> > > > > > more.
> > > > > > 2. We won't be able to have Chromecast-specific conversion code
added
> in
> > > the
> > > > > > same file as gfx::ColorSpace declaration.
> > > > > > 
> > > > > > All in all having getters in gfx::ColorSpace seems like a much
cleaner
> > > > > solution
> > > > > > to me. Are there any downsides to having getters?
> > > > > 
> > > > > gfx::ColorSpace structure is planned to change substantially in the
near
> > > > future
> > > > > (see crbug.com/634102)
> > > > > 
> > > > > I'd prefer to have a friend so that we don't give the idea that these
> > things
> > > > are
> > > > > okay to access and can be relied on in the future.
> > > > > 
> > > > > The downside to adding getters is that it legitimizes accessing these
> > > members
> > > > > (and could lead to access proliferating).
> > > > 
> > > > Ok, thanks for pointing this out Christopher. I now understand better
the
> > > > motivation for not having getters so far. But I have a few further
> questions
> > > > now. Perhaps you and/or hubbe@ could help with answering those:
> > > > 1. gfx::ColorSpace has things like transfer function, range, primaries
> which
> > > map
> > > > nicely to what's available in video streams (e.g. here is the color
> metadata
> > > > available in WebM container for video -
> > > > http://www.webmproject.org/docs/container/#colour, as you can see it
> > > essentially
> > > > directly to the current gfx::ColorSpace, which I was planning to use in
> this
> > > CL
> > > > https://codereview.chromium.org/2333663003/). SkColorSpace looks like a
> > > generic
> > > > 4x4 matrix. Now I understand that it might possible to represent all
those
> > > color
> > > > transforms in the form of generic matrix, but that might lead to loss of
> > > > efficiency. E.g. on Chromecast we might be able to do some typical
> > conversions
> > > > using fixed-function hardware (e.g. BT709 -> BT2020 conversion). If we
> just
> > > deal
> > > > with generic matrices how are we going to be able to optimize cases like
> > that?
> > > > hubbe@, you are more familiar with gfx::ColorSpace and media code - any
> > ideas
> > > > how we would deal in media code with gfx::ColorSpace being a wrapper
over
> > > > generic SkColorSpace 4x4 matrix?
> > > > 
> > > 
> > > Unfortunately, a 4x4 matrix cannot properly convey how video color spaces
> > > are usually done, as the non-linear transforms are usually sandwiched
> between
> > > two linear transforms. (matrices)
> > 
> > Ok, so are we going to add video color spaces separate from the 4x4 matrix
in
> > SkColorSpace then? If that's the case then perhaps we could still provide
> > getters for video color spaces?
> > 
> 
> Don't know. The people working on SkColorSpace keep telling me they want to
> replace
> gfx::ColorSpace with SkColorSpace, but so far they have been reluctant to make
> SkColorSpace capable of implementing all the things that is needed from it, at
> least
> from a video use case perspective.  Last I heard the plan was to try to break
it
> up so that the YUV aspects are handled by gfx::ColorSpace/gfx::ColorTransform
> and
> SkColorSpace would only deal with RGB color spaces, but I'm not a big fan of
> that
> plan myself.

Ok, so it sounds like there's no consensus here yet. Do we have an ETA for when
we are planning to merge gfx::ColorSpace / SkColorSpace? Is it likely to happen
after ~M55 branch point?

> > > One approach to check if an input color space is bt2020, without using
> getters
> > > would be to use gfx::ColorTransform(). Just map a few example colors from
> > bt2020
> > > to
> > > the unknown color space. (or vice versa) If the transform is nearly 1:1,
> then
> > > using
> > > the bt2020->bt709 pipeline is clearly the right thing to do.
> > >
> > > It's also possible to extract the primaries and approximate transfer
> functions
> > > using this
> > > method, which might be what is needed for semi-generic hardware.
> > > 
> > > I'm not sure if this is the *best* way to do things, but there are some
> > > advantages
> > > to this level of abstraction.
> > > 
> > > 
> > > > 2. Another problem with using a friend in this case is that the code
that
> > does
> > > > the conversion into Chromecast internal structures would ideally live
> under
> > > > chromecast/ directory (and in chromecast namespace). But Chromecast code
> is
> > > > generally considered a higher-level than the relatively low-level ui/gfx
> > > > primitives. To me it feels like a potential dependency/layering
violation
> if
> > > we
> > > > declared some Chromecast class to be a friend of gfx::ColorSpace.
> > Christopher,
> > > > do you think that would be acceptable from the dependencies point of
view?
> > > 
> > > What data does the chromecast want exactly?
> > 
> > For now I think we'll want to know at least the range (full/limited), the
> > transfer function and the primaries being used by the video stream (and
> > specified in the WebM Colour element). But ideally we'll probably want to
have
> > access to all information available in the Colour element, even if for now
> some
> > of it going to be ignored.
> 
> That's everything except for the YUV->RGB matrix. :)
> Do you care what the format of this information is?
> If you got the primaries as a list of floats, would it matter?

I'll reply to this separately shortly.

Powered by Google App Engine
This is Rietveld 408576698