Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b29f6e40dca930fbde3ab958180dc9f0e10655b9
      
https://github.com/WebKit/WebKit/commit/b29f6e40dca930fbde3ab958180dc9f0e10655b9
  Author: Gerald Squelart <[email protected]>
  Date:   2026-08-03 (Mon, 03 Aug 2026)

  Changed paths:
    M 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled.html
    M 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled.html
    M 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-pixelFormat-disabled.html
    M 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-pixelFormat-enabled-expected.txt
    M 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-pixelFormat-enabled.html
    A 
LayoutTests/fast/canvas/hdr/CanvasRenderingContext2DSettings-pixelFormat-enabled-expected.txt
    A 
LayoutTests/fast/canvas/hdr/CanvasRenderingContext2DSettings-pixelFormat-enabled.html
    M LayoutTests/fast/canvas/hdr/float16-canvas-imagedata.js
    A LayoutTests/fast/canvas/hdr/imagedata-storageformat-enabled-expected.txt
    A LayoutTests/fast/canvas/hdr/imagedata-storageformat-enabled.html
    M LayoutTests/fast/canvas/imagedata-storageformat-enabled-expected.txt
    M LayoutTests/fast/canvas/imagedata-storageformat-enabled.html
    M Source/WebCore/html/ImageData.cpp
    M Source/WebCore/html/ImageDataArray.cpp
    M Source/WebCore/html/ImageDataPixelFormat.h
    M Source/WebCore/html/ImageDataPixelFormat.idl
    M Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp
    M Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.h
    M Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.idl
    M Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp
    M Source/WebKit/WebProcess/Model/WebModelPlayer.mm

  Log Message:
  -----------
  Float16 canvas and ImageData require RGBA16F
https://bugs.webkit.org/show_bug.cgi?id=320848
rdar://183878218

Reviewed by Mike Wyrzykowski.

On platforms where PixelFormat::RGBA16F is not available (because
ENABLE_PIXEL_FORMAT_RGBA16F is 0), allowing float16 canvas and ImageData
is not helpful:
- A 2D canvas context with colorType "float16" would not be able to
  interpret its data. It could probably be faked by immediately
  converting float16 data into unorm8 behind the scene, but that would
  lose the extra precision and out-of-gamut values.
- While it would be possible to store a Float16Array in an ImageData
  with pixelFormat "rgba-float16", actually using it in a unorm8 canvas
  (or fake float16) would also lose precision and higher values.

So it's best to just disallow these values, so as not to give wrong
expectations.

This limitation can be detected, e.g.:
`canvas.getContext("2d", {colorType:"float16"})` would throw a TypeError;
so websites can know when not to try and use HDR canvas.

The relevant full float16 tests have been copied to fast/canvas/hdr for
platforms that do support RGBA16F. And the original tests in fast/canvas
(for all platforms) have been reduced to not test float16 cases anymore,
except to verify that trying float16 either works or throws the
expected TypeError.

* 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled.html:
* 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled.html:
* 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-pixelFormat-disabled.html:
* 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-pixelFormat-enabled-expected.txt:
* 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-pixelFormat-enabled.html:
* 
LayoutTests/fast/canvas/hdr/CanvasRenderingContext2DSettings-pixelFormat-enabled-expected.txt:
 Copied from 
LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-pixelFormat-enabled-expected.txt.
* 
LayoutTests/fast/canvas/hdr/CanvasRenderingContext2DSettings-pixelFormat-enabled.html:
 Added.
* LayoutTests/fast/canvas/hdr/float16-canvas-imagedata.js:
(areEqualImageData):
* LayoutTests/fast/canvas/hdr/imagedata-storageformat-enabled-expected.txt: 
Copied from 
LayoutTests/fast/canvas/imagedata-storageformat-enabled-expected.txt.
* LayoutTests/fast/canvas/hdr/imagedata-storageformat-enabled.html: Copied from 
LayoutTests/fast/canvas/imagedata-storageformat-enabled.html.
* LayoutTests/fast/canvas/imagedata-storageformat-enabled-expected.txt:
* LayoutTests/fast/canvas/imagedata-storageformat-enabled.html:
* Source/WebCore/html/ImageData.cpp:
(WebCore::ImageData::pixelBuffer const):
* Source/WebCore/html/ImageDataArray.cpp:
(WebCore::ImageDataArray::tryCreate):
(WebCore::ImageDataArray::extractBufferViewWithPixelFormat):
* Source/WebCore/html/ImageDataPixelFormat.h:
(WebCore::toPixelFormat):
(WebCore::toImageDataPixelFormat):
* Source/WebCore/html/ImageDataPixelFormat.idl:
* Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::pixelFormat const):
* Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.h:
* Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.idl:
* Source/WebKit/GPUProcess/graphics/WebGPU/RemoteGPU.cpp:
(WebKit::RemoteGPU::createRenderBuffers):
* Source/WebKit/WebProcess/Model/WebModelPlayer.mm:
(WebKit::WebModelPlayer::load):
(WebKit::WebModelPlayer::render):

Canonical link: https://commits.webkit.org/318494@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to