Skia Lanczos3 downscaling: fix rounding bug
| Tracking | Status | |
|---|---|---|
| firefox152 | --- | fixed |
| Assignee | |
Description•2 months ago
|
Steps to reproduce:
The Skia Lanczos3 downscaler in gfx/2d/SkConvolver.cpp and its SIMD variants use arithmetic right shift when converting fixed-point accumulators to pixel values. This truncates the fractional part rather than rounding towards the nearest integer value.
This happens once during the horizontal pass, and once during the vertical pass. Each pass loses an average of 0.5 per channel, for a combined bias of roughly -1.0 average across both passes, darkening the output image.
The fix is to add the equivalent of +0.5 in fixed point to the number before truncation.
I benchmarked this with SSE2 and AVX2 backends, and I saw no difference. This should also apply to the NEON backend -- it's a single-cycle operation on all of these architectures.
| Assignee | |
Comment 1•2 months ago
|
Updated•2 months ago
|
Comment 2•2 months ago
|
The Bugbug bot thinks this bug should belong to the 'Core::Graphics' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•2 months ago
|
| Assignee | |
Comment 3•2 months ago
|
A demo of this issue is here:
https://tourmaline-peony-ff2b1c.netlify.app/
It's a checkerboard image of (100, 100, 100) and (102, 102, 102) pixels.
Proper resizing should scale it to an image of (101, 101, 101) pixels, but current firefox generates a (100, 100, 100) image due to truncation instead of rounding.
Backed out for causing xpcshell failures
Comment 8•1 month ago
|
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/59398 for changes under testing/web-platform/tests
Comment 10•1 month ago
|
|
| bugherder | |
Comment 11•1 month ago
|
Upstream PR merged by moz-wptsync-bot
Updated•26 days ago
|
