[Webkit-unassigned] [Bug 213981] Part 2 of SimpleColor and SRGBA<uint8_t> are essentially the same - let's converge them

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jul 5 20:50:52 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=213981

--- Comment #2 from Sam Weinig <sam at webkit.org> ---
Goals for this stage:
- Remove uses of SimpleColor class that are not implementation details of Color. 
    - Mostly replacing them with direct use of SRGBA<uint8_t> either explicitly or by using auto. 
- Remove implicit conversions from ARGB8888 uint32_ts to SimpleColor
    - Replaced by explicit use of asSRGBA(Packed::ARGB { value }) to get a SRGBA<uint8_t> where the value is not a constant
    - Replaced by either SRGBA<uint8_t>(uint8_t, uint8_t, uint8_t, uint8_t) or the very incorrectly named makeSimpleColor() (as it now returns a SRGBA<uint8_t>).


- Current change has makeSimpleColor(SRGBA<float>) being replaced by convertToComponentBytesLossy(SRGBA<float>). I think the latter needs a better name and to look more cast-like. I want to keep the "Lossy", as I think many of these sites are unnecessarily getting rid of the precision. Perhaps convertToLossy<SRGBA<uint8_t>>(SRGBA<float>)? Maybe convertTo<SRGBA<uint8_t>>(SRGBA<float>) is nicer?

- As noted above, the current change still has makeSimpleColor(int, int, int, int), but it now returns SRGBA<uint8_t>. Many callers, specifically the ones passing constants, could probably switch to just using SRGBA<uint8_t> { int, int, int, int }, which has the benefit of being very clear what color space and component type is being created. Non-constant users should likely switch to clampToComponentBytes<SRGBA<uint8_t>>(int, int, int, int).

- To keep support for the Color::yellow.colorWithAlpha(...) and switching on Color::white.value() idioms, I added a new type, tentatively called ConstexprColor which wraps a SRGBA<uint8_t> and exposes the needed functionality. This needs more iteration. I think the ideal solution would be to make Color itself constexpr-able, and have Color::yellow return a Color. Not sure how feasible that is.

Regardless of all this, probably want to break this up a bit. I think maybe a good first step here will be just removing the SimpleColor constructor that takes an unsigned, and updating all callers to pass each component or convert to SRGBA<uint8_t> first.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200706/8722f451/attachment-0001.htm>


More information about the webkit-unassigned mailing list