WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
212945
Extended Color: Streamline SimpleColor premulitply/unpremultiply code
https://bugs.webkit.org/show_bug.cgi?id=212945
Summary
Extended Color: Streamline SimpleColor premulitply/unpremultiply code
Sam Weinig
Reported
2020-06-08 18:15:21 PDT
Extended Color: Streamline SimpleColor premulitply/unpremultiply code
Attachments
Patch
(11.16 KB, patch)
2020-06-08 18:23 PDT
,
Sam Weinig
no flags
Details
Formatted Diff
Diff
Patch
(11.45 KB, patch)
2020-06-09 12:27 PDT
,
Sam Weinig
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2020-06-08 18:23:01 PDT
Created
attachment 401404
[details]
Patch
Sam Weinig
Comment 2
2020-06-08 18:23:40 PDT
Now that the signatures only take SimpleColors, I am not sure if I should just make these members of SimpleColor. For now, this feels a lot more clear.
Darin Adler
Comment 3
2020-06-09 11:21:13 PDT
For simple value types with no hidden state like SimpleColor, I personally want member functions kept to the absolute minimum. Free functions are far more flexible. But also, I wish this was a different programming language, where syntax and encapsulation weren’t so closely tied together.
Sam Weinig
Comment 4
2020-06-09 12:27:46 PDT
Created
attachment 401461
[details]
Patch
Darin Adler
Comment 5
2020-06-09 12:51:24 PDT
Comment on
attachment 401461
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=401461&action=review
> Source/WebCore/ChangeLog:9 > + - Removing overloads that didn't took the seperated components, keeping
"didn't took the separated" is not good grammar, and spells "separated" wrong
> Source/WebCore/ChangeLog:14 > + - Simplifying the names from makePremultipliedSimpleColor/makeUnpremultipliedSimpleColor > + to premultiplyFlooring/premultiplyCeiling/unpremultiply.
The use of "ceil" here as a verb with "ceiling" as its gerund is not awesome. No call for premultiplying with rounding? I’m not sure how I feel about these functions with verb names. I think we would call these "premultiplied" rather than "premultiply", but not sure that fully works with the rest of the naming.
> Source/WebCore/ChangeLog:15 > + - Where component order is impotant, use valueAsARGB() explicitly to
"impotant"
> Source/WebCore/platform/graphics/Color.cpp:269 > + // Since premultiplyCeiling() bails on zero alpha, special-case that.
Seems like something we might eventually want to address.
> Source/WebCore/platform/graphics/Color.cpp:270 > + auto premultFrom = from.alpha() ? premultiplyCeiling(from.toSRGBASimpleColorLossy()) : Color::transparent;
I would have renamed all these "premult" to "premultiplied".
> Source/WebCore/platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp:83 > + auto pixelColor = unpremultiply(SimpleColor { *pixel });
I’m not sure I am on board with the strategy where we use valueAsARGB() to emphasize the meaning of the returned integer, but construct SimpleColor from a 32-bit integer with no disambiguation for the meaning there. Maybe there’s a future step coming to solve that?
Sam Weinig
Comment 6
2020-06-09 13:54:19 PDT
(In reply to Darin Adler from
comment #5
)
> Comment on
attachment 401461
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=401461&action=review
> > > Source/WebCore/ChangeLog:9 > > + - Removing overloads that didn't took the seperated components, keeping > > "didn't took the separated" is not good grammar, and spells "separated" wrong > > > Source/WebCore/ChangeLog:14 > > + - Simplifying the names from makePremultipliedSimpleColor/makeUnpremultipliedSimpleColor > > + to premultiplyFlooring/premultiplyCeiling/unpremultiply. > > The use of "ceil" here as a verb with "ceiling" as its gerund is not awesome. > > No call for premultiplying with rounding?
Agreed, though I stole the name from your patch on 180620 :)
> > I’m not sure how I feel about these functions with verb names. I think we > would call these "premultiplied" rather than "premultiply", but not sure > that fully works with the rest of the naming. > > > Source/WebCore/ChangeLog:15 > > + - Where component order is impotant, use valueAsARGB() explicitly to > > "impotant"
Will fix.
> > > Source/WebCore/platform/graphics/Color.cpp:269 > > + // Since premultiplyCeiling() bails on zero alpha, special-case that. > > Seems like something we might eventually want to address.
Yeah, since we check for 0 already there, we could totally just return transparent there. Will look into that in a follow up.
> > > Source/WebCore/platform/graphics/Color.cpp:270 > > + auto premultFrom = from.alpha() ? premultiplyCeiling(from.toSRGBASimpleColorLossy()) : Color::transparent; > > I would have renamed all these "premult" to "premultiplied".
Will fix.
> > > Source/WebCore/platform/graphics/cairo/ImageBufferCairoImageSurfaceBackend.cpp:83 > > + auto pixelColor = unpremultiply(SimpleColor { *pixel }); > > I’m not sure I am on board with the strategy where we use valueAsARGB() to > emphasize the meaning of the returned integer, but construct SimpleColor > from a 32-bit integer with no disambiguation for the meaning there. Maybe > there’s a future step coming to solve that?
Yeah, my thought was to introduce a makeSimpleColorFromARGB (or some name like that) at some point and remove the constructor. From Simon's comments in other bugs, the fact that we use ARGB as the format is a bit surprising to some, so might as well make it explicit. Thanks for the review.
Sam Weinig
Comment 7
2020-06-09 14:05:11 PDT
Committed
r262810
: <
https://trac.webkit.org/changeset/262810
>
Radar WebKit Bug Importer
Comment 8
2020-06-09 14:06:21 PDT
<
rdar://problem/64179100
>
Darin Adler
Comment 9
2020-06-09 14:46:55 PDT
Maybe at some point we’ll change our minds and use a different class for the premultiplied data. Presumably you can’t use it in a Color and have it work correctly. It’s another aspect of how to interpret the channel values, analogous to color space. And SimpleColor is 4 bytes that are implicitly in the sRGB space and should probably also be implicitly not premultiplied for the same reason. As opposed to a more general "4 channels with no judgment about how they are used".
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug