LibWeb/WebGL: Avoid copying canvas surface when uploading it

This commit is contained in:
Luke Wilde 2025-10-24 15:59:17 +01:00 committed by Andreas Kling
parent d65f0e4490
commit d733bf54cc
Notes: github-actions[bot] 2025-10-25 10:57:23 +00:00

View file

@ -128,10 +128,8 @@ Optional<WebGLRenderingContextBase::ConvertedTexture> WebGLRenderingContextBase:
[](GC::Root<HTML::HTMLCanvasElement> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
auto surface = source->surface();
if (!surface)
return {};
auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA8888, Gfx::AlphaType::Premultiplied, surface->size()));
surface->read_into_bitmap(*bitmap);
return Gfx::ImmutableBitmap::create(*bitmap);
return Gfx::ImmutableBitmap::create(*source->get_bitmap_from_surface());
return Gfx::ImmutableBitmap::create_snapshot_from_painting_surface(*surface);
},
[](GC::Root<HTML::OffscreenCanvas> const& source) -> RefPtr<Gfx::ImmutableBitmap> {
return Gfx::ImmutableBitmap::create(*source->bitmap());