If CanvasContext configuration is invalid, WebGPU requires to give fallback black bitmap
Categories
(Core :: Graphics: WebGPU, enhancement, P1)
Tracking
()
People
(Reporter: sotaro, Unassigned)
References
(Blocks 1 open bug)
Details
test of Bug 1940072 failed by not handling it.
| Reporter | ||
Comment 1•1 year ago
|
||
chromium implementation GPUCanvasContext::TransferToImageBitmap().
Updated•1 year ago
|
Comment 2•1 year ago
|
||
Fixing this is fairly straightforward. We just need to create a source surface and initialise its pixels to opaque black in CanvasContext::GetSurfaceSnapshot(). But I'm confused by the spec.
The test expects the pixels to have an alpha value of 1.0, but the relevant part of the spec isn't so clear:
Content timeline steps:
1. Let snapshot be a transparent black image of the same size as context.canvas.
2. Let configuration be context.[[configuration]].
3. If configuration is null:
Return snapshot.
...
6. Let alphaMode be configuration.alphaMode.
7. If alphaMode is "opaque":
Clear the alpha channel of snapshot to 1.0.
Tag snapshot as being opaque.
Note: If the [[currentTexture]], if any, has been destroyed (for example in "Expire the current texture"), the alpha channel is unobservable, and implementations may clear the alpha channel in-place.
Otherwise:
Tag snapshot with alphaMode.
Clearly 6 and 7 mention clearing the alpha channel to 1.0. But this canvas is unconfigured, so shouldn't we be returning a transparent black (ie alpha == 0.0) snapshot as per points 1-3?
Clearly chrome disagrees as they unconditionally use an alpha mode of kOpaque, and therefore clear the alpha to 1.0, when the canvas is unconfigured.
There is a comment in the test saying since the canvas is unconfigured we should use the default alpha mode of "opaque". This default is specified here, but I don't see how that overrides step 3 of the above.
Comment 3•1 year ago
|
||
I think that's a recent change https://github.com/gpuweb/gpuweb/pull/4738, it's likely that the CTS and chrome hasn't been updated in this regard.
Description
•