Canvas2D tone mapping
- Category
- Graphics
- Type
- New or changed feature
- Status
- Proposed (Chrome Proposed)
- Intent stage
- None
WPT details: Tests of setting and querying the property: https://wpt.fyi/results/html/canvas/element/manual/context-attributes/getContextAttributes.html?label=experimental&label=master&aligned https://wpt.fyi/results/html/canvas/offscreen/manual/context-attributes/getContextAttributes.html?label=experimental&label=master&aligned Tests drawing HDR colors to a 2D canvas, sending to an ImageBitmap and/or encoding to an image, then drawing the result to a new canvas. Verifies that the HDR metadata of the canvas is preserved in the full roundtrip. https://wpt.fyi/results/html/canvas/element/manual/wide-gamut-canvas/encode-hdr.html?label=experimental&label=master&aligned
Summary
Adds a toneMapping option to CanvasRenderingContext2DSettings, allowing a 2D canvas context to specify 'standard' or 'extended' tone mapping behavior when displaying HDR content, unifying the tone mapping API across 2D canvas and WebGPU.
Motivation
By default, HTML canvas elements limit their contents to the standard dynamic range (SDR) color volume of the target display. While WebGPU already supports configuring canvas tone mapping via GPUCanvasToneMapping, 2D canvas contexts lack a way to opt into displaying extended dynamic range (HDR) pixel values (such as those in float16 canvases) or explicitly constrain output to SDR. Unifying CanvasToneMapping across 2D canvas, WebGL, and WebGPU gives web developers a consistent mechanism to control how HDR canvas contents are tone mapped to the output device.
Standards & signals
- Specification: https://github.com/whatwg/html/pull/11734
- Firefox: No signal — Discussed in W3C ColorWeb-CG and WHATWG HTML PR #11734.
- Safari: Positive — Discussed in W3C ColorWeb-CG and WHATWG HTML PR #11734.
- Web developers: No signals — Positive interest from HDR web developers and W3C Color on the Web Community Group participants.
- Tracking bug: https://issues.chromium.org/issues/448552449
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=html%2Fcanvas%2Felement%2Fmanual%2Fcontext-attributes%2FgetContextAttributes
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Canvas2D%20tone%20mapping
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Canvas2D%20tone%20mapping
- Baseline status: https://webstatus.dev/?q=Canvas2D%20tone%20mapping
Explainers: https://github.com/w3c/ColorWeb-CG/blob/main/canvas-tone-map.md https://github.com/w3c/ColorWeb-CG/blob/main/hdr-big-picture.md