decodeTexture method
Decoded by the browser, copied in with copyExternalImageToTexture,
and given a chain drawn level by level on the GPU — A4.16. See
webgpu_image_decode.dart.
maxDimension is held to the device's own maxTextureDimension2D as
well, so no cap still means an image the device can allocate. An image
the browser will not decode is refused with a
DeviceResourceException.
Implementation
@override
Future<TextureHandle> decodeTexture(
Uint8List encoded, {
bool mipmaps = false,
int? maxDimension,
}) async {
final limit = limits.maxTextureDimension2D;
final cap = maxDimension == null || maxDimension > limit
? limit
: maxDimension;
return await webgpuCreateTextureFromEncodedImage(
_gpuDevice,
_textures,
_mips,
encoded,
mipmaps: mipmaps,
guard: _guard,
maxDimension: cap,
) ??
(throw refuseResource(
'decodeTexture',
'the browser would not decode these ${encoded.length} bytes as an '
'image',
));
}