mirror of
https://github.com/servo/servo.git
synced 2025-06-28 11:03:39 +01:00
Integer color components representation has performance and memory storage benefits but suffers from precision loss after multiple consequence alpha (un)premultiply operations. Rounding any fractional bits (to the nearest integer) during alpha multiplication should reduce the loss of precision. Expensive division will be replaced by multiplication and bits shift. https://research.swtch.com/divmult https://docs.google.com/document/d/1tNrMWShq55rfltcZxAx1N-6f82Dt7MWLDHm-5GQVEnE Other browsers and graphics libraries have the similar approach: - Chromium (Skia): https://github.com/google/skia/blob/main/include/private/base/SkMath.h#L73 - Firefox: https://github.com/mozilla/gecko-dev/blob/master/gfx/2d/Swizzle.cpp#L276 - Servo (Raqote): https://github.com/jrmuizel/sw-composite/blob/master/src/lib.rs#L878 Testing: Improvements in the following WPT test - html/canvas/element/manual/imagebitmap/createImageBitmap-premultiplyAlpha.html Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com> |
||
---|---|---|
.. | ||
tests | ||
benches.rs | ||
Cargo.toml | ||
lib.rs |