mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-04 06:12:04 +08:00
Fix SDL_SetWindowIcon on singlethreaded Emscripten builds (#14850)
This commit is contained in:
@@ -794,11 +794,9 @@ static bool Emscripten_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window,
|
|||||||
|
|
||||||
// Pass PNG data to JavaScript
|
// Pass PNG data to JavaScript
|
||||||
MAIN_THREAD_EM_ASM({
|
MAIN_THREAD_EM_ASM({
|
||||||
var pngData = HEAPU8.subarray($0, $0 + $1);
|
// Use `.slice` to make a copy of the data if we are dealing with a SharedArrayBuffer, or `.subarray` to create a
|
||||||
if (pngData.buffer instanceof SharedArrayBuffer) {
|
// view into the existing buffer if its non-shared.
|
||||||
// explicitly create a copy
|
var pngData = HEAPU8.buffer instanceof ArrayBuffer ? HEAPU8.subarray($0, $0 + $1) : HEAPU8.slice($0, $0 + $1);
|
||||||
pngData = new Uint8Array(pngData);
|
|
||||||
}
|
|
||||||
|
|
||||||
var blob = new Blob([pngData], {type: 'image/png'});
|
var blob = new Blob([pngData], {type: 'image/png'});
|
||||||
var url = URL.createObjectURL(blob);
|
var url = URL.createObjectURL(blob);
|
||||||
|
|||||||
Reference in New Issue
Block a user