Upload the 16-bit sidecar unflipped so it matches the JPEG proxy.

Chrome ignores UNPACK_FLIP_Y_WEBGL for ImageBitmap uploads, so the JPEG proxy
lands in the texture top-down while the parser pre-flipped the sidecar rows.
The picture jumped upside down a few seconds after load, when the sidecar
replaced the proxy. The parser now keeps the PNG's row order.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-28 06:59:55 +00:00
parent 2dc569256c
commit c10ff97670
4 changed files with 18 additions and 10 deletions
+6 -4
View File
@@ -149,7 +149,7 @@ describe('parsePreview16', () => {
expect(Array.from(parsed!.rgba.slice(4, 8))).toEqual([0x3c00, 0, 0x3800, 0x3c00]);
});
it('flips the rows so upload needs no UNPACK_FLIP_Y', async () => {
it('keeps the PNG row order so the sidecar matches the JPEG texture', async () => {
const parsed = await parsePreview16(
encodePng16(
[
@@ -161,9 +161,11 @@ describe('parsePreview16', () => {
),
);
expect(parsed).not.toBeNull();
// Row 0 of the returned buffer is the last image row.
expect(parsed!.rgba[0]).toBe(0);
expect(parsed!.rgba[4]).toBe(0x3c00);
// Chrome ignores UNPACK_FLIP_Y_WEBGL for ImageBitmap uploads, so the JPEG
// proxy is top-down in the texture. Flipping here put the 16-bit sidecar
// upside down once it replaced the proxy a few seconds after load.
expect(parsed!.rgba[0]).toBe(0x3c00);
expect(parsed!.rgba[4]).toBe(0);
});
it('reads the camera matrix out of the sidecar text chunk', async () => {