mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-01 01:17:40 +00:00
emscripten: use MAIN_THREAD_EM_ASM for the fb/cursor proxying
This is how everything else was handled and fixes undefined symbol errors in non-threads builds.
This commit is contained in:
parent
b9c2ad8395
commit
0fcfaf9e94
2 changed files with 26 additions and 64 deletions
|
@ -63,10 +63,20 @@ Emscripten_CreateDefaultCursor()
|
|||
return Emscripten_CreateCursorFromString("default", SDL_FALSE);
|
||||
}
|
||||
|
||||
static const char*
|
||||
Emscripten_GetCursorUrl(int w, int h, int hot_x, int hot_y, void* pixels)
|
||||
|
||||
static SDL_Cursor*
|
||||
Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
|
||||
{
|
||||
return (const char *)EM_ASM_INT({
|
||||
const char *cursor_url = NULL;
|
||||
SDL_Surface *conv_surf;
|
||||
|
||||
conv_surf = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888, 0);
|
||||
|
||||
if (!conv_surf) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor_url = (const char *)MAIN_THREAD_EM_ASM_INT({
|
||||
var w = $0;
|
||||
var h = $1;
|
||||
var hot_x = $2;
|
||||
|
@ -114,40 +124,7 @@ Emscripten_GetCursorUrl(int w, int h, int hot_x, int hot_y, void* pixels)
|
|||
stringToUTF8(url, urlBuf, url.length + 1);
|
||||
|
||||
return urlBuf;
|
||||
}, w, h, hot_x, hot_y, pixels);
|
||||
}
|
||||
|
||||
static SDL_Cursor*
|
||||
Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
|
||||
{
|
||||
const char *cursor_url = NULL;
|
||||
SDL_Surface *conv_surf;
|
||||
|
||||
conv_surf = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888, 0);
|
||||
|
||||
if (!conv_surf) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (emscripten_is_main_runtime_thread()) {
|
||||
cursor_url = Emscripten_GetCursorUrl(
|
||||
surface->w,
|
||||
surface->h,
|
||||
hot_x,
|
||||
hot_y,
|
||||
conv_surf->pixels
|
||||
);
|
||||
} else {
|
||||
cursor_url = (const char *)emscripten_sync_run_in_main_runtime_thread(
|
||||
EM_FUNC_SIG_IIIIIII,
|
||||
Emscripten_GetCursorUrl,
|
||||
surface->w,
|
||||
surface->h,
|
||||
hot_x,
|
||||
hot_y,
|
||||
conv_surf->pixels
|
||||
);
|
||||
}
|
||||
}, surface->w, surface->h, hot_x, hot_y, conv_surf->pixels);
|
||||
|
||||
SDL_FreeSurface(conv_surf);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue