RESOLVED FIXED 213742
Move Color blending related functions to their own files
https://bugs.webkit.org/show_bug.cgi?id=213742
Summary Move Color blending related functions to their own files
Sam Weinig
Reported 2020-06-29 10:16:07 PDT
Move Color blending related functions to their own files
Attachments
Patch (39.24 KB, patch)
2020-06-29 10:20 PDT, Sam Weinig
no flags
Patch (37.10 KB, patch)
2020-06-29 18:25 PDT, Sam Weinig
ews-feeder: commit-queue-
Patch (26.25 KB, patch)
2020-06-30 13:01 PDT, Sam Weinig
no flags
Sam Weinig
Comment 1 2020-06-29 10:20:54 PDT Comment hidden (obsolete)
Dean Jackson
Comment 2 2020-06-29 15:15:47 PDT
Comment on attachment 403078 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=403078&action=review > Source/WebCore/ChangeLog:25 > + Move declarations / implemenatations from Color.h/cpp to ColorBlending.h/cpp. Typo
Sam Weinig
Comment 3 2020-06-29 18:25:08 PDT Comment hidden (obsolete)
EWS
Comment 4 2020-06-29 18:33:35 PDT Comment hidden (obsolete)
Sam Weinig
Comment 5 2020-06-30 09:11:20 PDT Comment hidden (obsolete)
Radar WebKit Bug Importer
Comment 6 2020-06-30 09:12:17 PDT
Jason Lawrence
Comment 7 2020-06-30 09:54:48 PDT Comment hidden (obsolete)
Sam Weinig
Comment 8 2020-06-30 10:24:56 PDT Comment hidden (obsolete)
Darin Adler
Comment 9 2020-06-30 10:54:28 PDT
Comment on attachment 403152 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=403152&action=review > Source/WebCore/platform/graphics/ColorBlending.h:39 > +// This is an implementation of Porter-Duff's "source-over" equation > +Color blendSourceOver(const Color&, const Color&); > + > +// Bespoke "whitening" algorithm used by RenderTheme::transformSelectionBackgroundColor. > +Color blendWithWhite(const Color&); > + > +Color blend(const Color& from, const Color& to, double progress); > +Color blendWithoutPremultiply(const Color& from, const Color& to, double progress); All of these functions also transform extended colors into simple colors. Would be nice if this was clearer.
Sam Weinig
Comment 10 2020-06-30 11:28:55 PDT
(In reply to Darin Adler from comment #9) > Comment on attachment 403152 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=403152&action=review > > > Source/WebCore/platform/graphics/ColorBlending.h:39 > > +// This is an implementation of Porter-Duff's "source-over" equation > > +Color blendSourceOver(const Color&, const Color&); > > + > > +// Bespoke "whitening" algorithm used by RenderTheme::transformSelectionBackgroundColor. > > +Color blendWithWhite(const Color&); > > + > > +Color blend(const Color& from, const Color& to, double progress); > > +Color blendWithoutPremultiply(const Color& from, const Color& to, double progress); > > All of these functions also transform extended colors into simple colors. > Would be nice if this was clearer. Hm, indeed. Color blendSourceOverSRGBASimpleColorLossy(const Color&, const Color&); That seems a bit wordy and very unclear, so let's not do that :). I wonder what if we made them take a typed color, and make the caller do the conversion (I tend to like this approach, as it makes it easy to find all the lossy conversions easily). SRGBA<uint8_t> blendSourceOver(const SRGBA<uint8_t>&, const const SRGBA<uint8_t>&); SRGBA<uint8_t> blendWithWhite(const SRGBA<uint8_t>&); SRGBA<uint8_t> blend(const SRGBA<uint8_t>&, const SRGBA<uint8_t>&, double progress); SRGBA<uint8_t> blendWithoutPremultiply(const SRGBA<uint8_t>&, const SRGBA<uint8_t>&, double progress); This has a few initial problems I can think of. 1) blendWithWhite for some reason preserves the Semantic bit. This is easily solvable, since blendWithWhite has only one caller, by just making it the callers responsibility to preserve it. (Honestly, I have not looked into why we still have that bit or why its ok for it to only work for SimpleColors. I know it's used only by editing and filter code, but not entirely sure why). 2) blend and blendWithoutPremultiply preserve the isValid bit in certain circumstances (when progress == 1).
Sam Weinig
Comment 11 2020-06-30 11:32:12 PDT
(In reply to Sam Weinig from comment #10) > (In reply to Darin Adler from comment #9) > > Comment on attachment 403152 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=403152&action=review > > > > > Source/WebCore/platform/graphics/ColorBlending.h:39 > > > +// This is an implementation of Porter-Duff's "source-over" equation > > > +Color blendSourceOver(const Color&, const Color&); > > > + > > > +// Bespoke "whitening" algorithm used by RenderTheme::transformSelectionBackgroundColor. > > > +Color blendWithWhite(const Color&); > > > + > > > +Color blend(const Color& from, const Color& to, double progress); > > > +Color blendWithoutPremultiply(const Color& from, const Color& to, double progress); > > > > All of these functions also transform extended colors into simple colors. > > Would be nice if this was clearer. > > Hm, indeed. > > Color blendSourceOverSRGBASimpleColorLossy(const Color&, const Color&); > > That seems a bit wordy and very unclear, so let's not do that :). A shorter name idea, just use Lossy suffix and add a comment: // NOTE: These function will do a lossy conversion to 8-bit sRGBA before blending. Color blendSourceOverLossy(const Color&, const Color&);
Sam Weinig
Comment 12 2020-06-30 13:01:46 PDT
EWS
Comment 13 2020-06-30 15:50:38 PDT
Committed r263776: <https://trac.webkit.org/changeset/263776> All reviewed patches have been landed. Closing bug and clearing flags on attachment 403230 [details].
Note You need to log in before you can comment on or make changes to this bug.