Extended Color: Unify rounding / clamping conversions between 0-1 float components and 0-255 byte components
Created attachment 401269 [details] WIP
Created attachment 401271 [details] WIP
Created attachment 401272 [details] Patch
Created attachment 401274 [details] Patch
Created attachment 401275 [details] Patch
Created attachment 401276 [details] Patch
Created attachment 401277 [details] Patch
Created attachment 401279 [details] Patch
Created attachment 401280 [details] Patch
Created attachment 401281 [details] Patch
Comment on attachment 401281 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=401281&action=review > Source/WebCore/platform/graphics/ColorUtilities.h:54 > +inline uint8_t convertPrescaledToComponentByte(float f) Not really a fan of "prescaled". Does it mean "in the range 0-1"? Can't think of a better word though.
Probably obvious to both of you but: We do need terminology for 0-1 and 0-255 for floating point components. Sadly it seems we need code that deals with both. And when overloading a function so it can take either integers or floating point, it seems really bad to have a floating point overload that takes 0-1 and an integer ones that takes 0-255, so we’ll want to avoid that.
Committed r262733: <https://trac.webkit.org/changeset/262733> All reviewed patches have been landed. Closing bug and clearing flags on attachment 401281 [details].
<rdar://problem/64130839>
(In reply to Darin Adler from comment #12) > Probably obvious to both of you but: We do need terminology for 0-1 and > 0-255 for floating point components. Sadly it seems we need code that deals > with both. And when overloading a function so it can take either integers or > floating point, it seems really bad to have a floating point overload that > takes 0-1 and an integer ones that takes 0-255, so we’ll want to avoid that. Yes!
We need the one taking 0-255 float values in exactly one place right now, in the CSS parser. Everywhere else is 0-1 float or 0-255 int.
(In reply to Simon Fraser (smfr) from comment #15) > (In reply to Darin Adler from comment #12) > > Probably obvious to both of you but: We do need terminology for 0-1 and > > 0-255 for floating point components. Sadly it seems we need code that deals > > with both. And when overloading a function so it can take either integers or > > floating point, it seems really bad to have a floating point overload that > > takes 0-1 and an integer ones that takes 0-255, so we’ll want to avoid that. > > Yes! The naming I was thinking about was: makeSimpleColorFromSRGBABytes makeSimpleColorFromSRGBAFloats (in the patch for https://bugs.webkit.org/show_bug.cgi?id=180620, Darin used makeSimpleColorFromRGBABytes for 0-255 ints and makeSimpleColorFromSRGBA for 0-1 floats). Not wed to this.