LibWeb: Add OffscreenCanvas to IDL types

Add OffscreenCanvas to TexImageSource and CanvasImageSource.
Implement all the necessary features to make it work in all cases where
these types are used.
This commit is contained in:
Totto16 2025-03-06 23:41:31 +01:00 committed by Andrew Kaster
commit f1a096d6e4
Notes: github-actions[bot] 2025-06-30 15:47:37 +00:00
8 changed files with 35 additions and 9 deletions

View file

@ -730,7 +730,7 @@ struct ConvertedTexture {
int height { 0 };
};
static Optional<ConvertedTexture> read_and_pixel_convert_texture_image_source(Variant<GC::Root<ImageBitmap>, GC::Root<ImageData>, GC::Root<HTMLImageElement>, GC::Root<HTMLCanvasElement>, GC::Root<HTMLVideoElement>> const& source, WebIDL::UnsignedLong format, WebIDL::UnsignedLong type, Optional<int> destination_width = OptionalNone {}, Optional<int> destination_height = OptionalNone {})
static Optional<ConvertedTexture> read_and_pixel_convert_texture_image_source(TexImageSource const& source, WebIDL::UnsignedLong format, WebIDL::UnsignedLong type, Optional<int> destination_width = OptionalNone {}, Optional<int> destination_height = OptionalNone {})
{
// FIXME: If this function is called with an ImageData whose data attribute has been neutered,
// an INVALID_VALUE error is generated.
@ -753,6 +753,9 @@ static Optional<ConvertedTexture> read_and_pixel_convert_texture_image_source(Va
surface->read_into_bitmap(*bitmap);
return Gfx::ImmutableBitmap::create(*bitmap);
},
[](GC::Root<OffscreenCanvas> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
return Gfx::ImmutableBitmap::create(*source->bitmap());
},
[](GC::Root<HTMLVideoElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
return Gfx::ImmutableBitmap::create(*source->bitmap());
},