emscripten: drop CanvasPixelArray support from framebuffer

main
Charlie Birks 2022-09-30 16:28:57 +01:00 committed by GitHub
parent a97d2e6958
commit 0c6d5b3ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 59 deletions

View File

@ -92,22 +92,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
var src = pixels >> 2; var src = pixels >> 2;
var dst = 0; var dst = 0;
var num; var num;
if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) {
// IE10/IE11: ImageData objects are backed by the deprecated CanvasPixelArray,
// not UInt8ClampedArray. These don't have buffers, so we need to revert
// to copying a byte at a time. We do the undefined check because modern
// browsers do not define CanvasPixelArray anymore.
num = data.length;
while (dst < num) {
var val = HEAP32[src]; // This is optimized. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
data[dst ] = val & 0xff;
data[dst+1] = (val >> 8) & 0xff;
data[dst+2] = (val >> 16) & 0xff;
data[dst+3] = 0xff;
src++;
dst += 4;
}
} else {
if (SDL2.data32Data !== data) { if (SDL2.data32Data !== data) {
SDL2.data32 = new Int32Array(data.buffer); SDL2.data32 = new Int32Array(data.buffer);
SDL2.data8 = new Uint8Array(data.buffer); SDL2.data8 = new Uint8Array(data.buffer);
@ -153,7 +138,6 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
i = i + 4 | 0; i = i + 4 | 0;
} }
} }
}
SDL2.ctx.putImageData(SDL2.image, 0, 0); SDL2.ctx.putImageData(SDL2.image, 0, 0);
}, surface->w, surface->h, surface->pixels); }, surface->w, surface->h, surface->pixels);