From ccb851343ebefdfde3dfca3b4a21545cf67cecc7 Mon Sep 17 00:00:00 2001 From: "Joakim L. Gilje" Date: Sun, 28 Nov 2021 21:00:41 +0100 Subject: [PATCH] replaced blitter function with a copy from win_sdl --- src/qt/qt_sdl.c | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/qt/qt_sdl.c b/src/qt/qt_sdl.c index 30c2aff9d..072531bd6 100644 --- a/src/qt/qt_sdl.c +++ b/src/qt/qt_sdl.c @@ -85,7 +85,6 @@ static int cur_w, cur_h; static int cur_ww = 0, cur_wh = 0; static volatile int sdl_enabled = 0; static SDL_mutex* sdl_mutex = NULL; -static int blit_w = 0, blit_h = 0, blit_tex_updated = 0; static const uint16_t sdl_to_xt[0x200] = { @@ -302,8 +301,9 @@ sdl_stretch(int *w, int *h, int *x, int *y) static void sdl_blit(int x, int y, int w, int h) { + SDL_Rect r_src; void *pixeldata; - int pitch; + int ret, pitch; if (!sdl_enabled || (x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) { video_blit_complete(); @@ -318,13 +318,24 @@ sdl_blit(int x, int y, int w, int h) if (screenshots) video_screenshot((uint32_t *) pixeldata, 0, 0, (2048 + 64)); - blit_w = w; - blit_h = h; - blit_tex_updated = 1; - SDL_UnlockTexture(sdl_tex); - SDL_UnlockMutex(sdl_mutex); + video_blit_complete(); + + SDL_RenderClear(sdl_render); + + r_src.x = 0; + r_src.y = 0; + r_src.w = w; + r_src.h = h; + + ret = SDL_RenderCopy(sdl_render, sdl_tex, &r_src, 0); + if (ret) + sdl_log("SDL: unable to copy texture to renderer (%s)\n", sdl_GetError()); + + SDL_RenderPresent(sdl_render); + + SDL_UnlockMutex(sdl_mutex); } @@ -698,28 +709,6 @@ enum sdl_main_status sdl_main() { } } - if (blit_tex_updated > 0) { - SDL_LockMutex(sdl_mutex); - int status = SDL_RenderClear(sdl_render); - if (status) { - sdl_log("SDL: unable to SDL_RenderClear (%s)\n", SDL_GetError()); - } - - r_src.x = 0; - r_src.y = 0; - r_src.w = blit_w; - r_src.h = blit_h; - - status = SDL_RenderCopy(sdl_render, sdl_tex, &r_src, 0); - if (status) { - sdl_log("SDL: unable to copy texture to renderer (%s)\n", SDL_GetError()); - } - - SDL_RenderPresent(sdl_render); - blit_tex_updated = 0; - SDL_UnlockMutex(sdl_mutex); - } - if (mouse_capture && keyboard_ismsexit()) { plat_mouse_capture(0); }