LibWeb/WebGL: Respect UNPACK_FLIP_Y_WEBGL pixel storage parameter

When this is true, we have to vertically flip TexImageSource provided
images before uploading them.

Fixes several graphical glitches on Google Maps.
Fixes globe being upside down on Shopify's homepage.
Likely fixes more websites.
This commit is contained in:
Luke Wilde 2025-10-23 20:24:14 +01:00 committed by Andreas Kling
parent 008699c129
commit 3e7061da40
Notes: github-actions[bot] 2025-10-25 10:57:35 +00:00
4 changed files with 45 additions and 3 deletions

View file

@ -14,6 +14,8 @@
namespace Web::WebGL {
static constexpr int UNPACK_FLIP_Y_WEBGL = 0x9240;
// NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly.
using TexImageSource = Variant<GC::Root<HTML::ImageBitmap>, GC::Root<HTML::ImageData>, GC::Root<HTML::HTMLImageElement>, GC::Root<HTML::HTMLCanvasElement>, GC::Root<HTML::OffscreenCanvas>, GC::Root<HTML::HTMLVideoElement>>;
@ -107,7 +109,14 @@ public:
int width { 0 };
int height { 0 };
};
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 {});
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 {});
protected:
// UNPACK_FLIP_Y_WEBGL of type boolean
// If set, then during any subsequent calls to texImage2D or texSubImage2D, the source data is flipped along
// the vertical axis, so that conceptually the last row is the first one transferred. The initial value is false.
// Any non-zero value is interpreted as true.
bool m_unpack_flip_y { false };
};
}