Closed Bug 2070229 Opened 2 months ago Closed 2 months ago

[wpt-sync] Sync PR 62475 - Avoid precision loss when encoding linear float16 canvases

Categories

(Core :: Graphics: Canvas2D, task, P4)

task

Tracking

()

RESOLVED FIXED
158 Branch
Tracking Status
firefox158 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 62475 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/62475
Details from upstream follow.

Christopher Cameron <ccameron@google.com> wrote:

Avoid precision loss when encoding linear float16 canvases

When encoding images from a linear float16 canvas (using toBlob,
toDataURL, or convertToBlob), converting directly to 8-bit linear
integers produces quantization artifacts at dark values (e.g. an
sRGB-value gradient with 256 stops will only produce 183 unique output
values).

Add ImageEncoderUtils::GetColorInfoForEncoder to select an
appropriate non-linear encoding color space (sRGB transfer function)
when serializing linear float16 canvases, and ensure premultiplied alpha
is converted to unpremultiplied alpha upfront. Include a gfx::HDRMetadata
parameter which we can use, in the future, to select between sRGB and PQ.

Apply this conversion in CanvasAsyncBlobCreator and ImageDataBuffer's
StaticBitmapImage constructor. Log a warning in ImageDataBuffer(SkPixmap)
if callers higher in the stack have not already performed any necessary
conversion.

Add WPT tests for toBlob, toDataURL, and convertToBlob with both JPEG
and PNG formats across HTMLCanvasElement and OffscreenCanvas.

TAG=agy
CONV=6afb9a4e-b9e1-4c5a-9273-c80de68abad8

Bug: 454152417
Change-Id: Ifb6a25195e0cb39c80cabf00fab2ee39f6db8fcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8342747
Reviewed-by: Florin Malita \<fmalita@chromium.org>
Commit-Queue: ccameron chromium \<ccameron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1692722}

Component: web-platform-tests → Graphics: Canvas2D
Product: Testing → Core

CI Results

Ran 4 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 24 tests and 2 subtests

Status Summary

Firefox

OK : 4[GitHub] 24[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS: 8
FAIL: 12[GitHub] 24[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]

Chrome

OK : 4
FAIL: 12

Safari

OK : 4
FAIL: 12

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 158 Branch
You need to log in before you can comment on or make changes to this bug.