| Summary: | Match other browsers by interpolating colors in floating point space rather than uint8_t space | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Sam Weinig <sam> | ||||
| Component: | New Bugs | Assignee: | Sam Weinig <sam> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | graouts, ifernandez, simon.fraser, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | WebKit Nightly Build | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
Sam Weinig
2021-03-14 13:08:04 PDT
Created attachment 423133 [details]
Patch
This does seem to fix WPT results, though I am curious if there is a way to do this and stay in uint8_t space using more clever rounding.
For each color channel, we are doing:
premultiplication:
float:
color.red = color.red * color.alpha
uint8_t:
color.red = static_cast<uint8_t>(fastDivideBy255(color.red * color.alpha + 254))
blending:
float:
from + (to - from) * progress
uint8_t:
static_cast<int>(lround(static_cast<double>(from) + static_cast<double>(to - from) * progress))
unpremultiplication:
float:
color.red = color.red / color.alpha
uint8_t:
color.red = static_cast<uint8_t>((fastMultiplyBy255(color.red) + color.alpha - 1) / color.alpha)
Committed r274408: <https://commits.webkit.org/r274408> All reviewed patches have been landed. Closing bug and clearing flags on attachment 423133 [details]. |