From 4229c59e8b63c82137ad48b4fed1cb28a44e0f72 Mon Sep 17 00:00:00 2001 From: kanjitalk755 Date: Sat, 18 Jan 2020 11:13:08 +0900 Subject: [PATCH] force redraw --- BasiliskII/src/SDL/video_rootless.cpp | 11 ++++++++--- BasiliskII/src/SDL/video_sdl2.cpp | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/BasiliskII/src/SDL/video_rootless.cpp b/BasiliskII/src/SDL/video_rootless.cpp index 6c667ba7..a648b359 100644 --- a/BasiliskII/src/SDL/video_rootless.cpp +++ b/BasiliskII/src/SDL/video_rootless.cpp @@ -73,6 +73,7 @@ static uint32 rootless_proc_ptr = 0; static uint32 low_mem_map = 0; static bool dragging_region = false; static uint32 drag_region_ptr = 0; +static size_t mask_n = 0; static void MyPatchTrap(int trap, uint32 ptr) { M68kRegisters r; @@ -368,16 +369,16 @@ void WalkLayerHierarchy(uint32 layerPtr, int level, std::vector &mask_ if (nextWindow) WalkLayerHierarchy(nextWindow, level, mask_rects); } -void update_display_mask(SDL_Window *window, int w, int h) { +bool update_display_mask(SDL_Window *window, int w, int h) { if (rootless_proc_ptr == 0) { - return; + return false; } // Check for process manager uint32 expandMem = ReadMacInt32(0x02B6); uint16 emProcessMgrExists = ReadMacInt16(expandMem + 0x0128); if (!emProcessMgrExists) { - return; + return false; } // Read lowmem mapping @@ -474,6 +475,10 @@ void update_display_mask(SDL_Window *window, int w, int h) { extern void update_window_mask_rects(SDL_Window * window, int h, const std::vector &rects); update_window_mask_rects(window, display_mask.h, mask_rects); + + bool f = mask_rects.size() > mask_n; + mask_n = mask_rects.size(); + return f; } void apply_display_mask(SDL_Surface * host_surface, SDL_Rect update_rect) { diff --git a/BasiliskII/src/SDL/video_sdl2.cpp b/BasiliskII/src/SDL/video_sdl2.cpp index 8dec5feb..f332a138 100644 --- a/BasiliskII/src/SDL/video_sdl2.cpp +++ b/BasiliskII/src/SDL/video_sdl2.cpp @@ -66,9 +66,11 @@ #include "vm_alloc.h" #ifdef VIDEO_ROOTLESS -extern void update_display_mask(SDL_Window * window, int w, int h); +extern bool update_display_mask(SDL_Window * window, int w, int h); extern void apply_display_mask(SDL_Surface * host_surface, SDL_Rect update_rect); extern bool cursor_point_opaque(void); +static bool force_redraw = false; +static spinlock_t force_redraw_lock = SPIN_LOCK_UNLOCKED; #endif #define DEBUG 0 @@ -1733,7 +1735,9 @@ void VideoInterrupt(void) do_toggle_fullscreen(); #ifdef VIDEO_ROOTLESS - update_display_mask(sdl_window, host_surface->w, host_surface->h); + spin_lock(&force_redraw_lock); + force_redraw |= update_display_mask(sdl_window, host_surface->w, host_surface->h); + spin_unlock(&force_redraw_lock); #endif present_sdl_video(); @@ -2391,6 +2395,13 @@ static void update_display_static(driver_base *drv) // XXX use NQD bounding boxes to help detect dirty areas? static void update_display_static_bbox(driver_base *drv) { +#ifdef VIDEO_ROOTLESS + spin_lock(&force_redraw_lock); + bool redraw = force_redraw; + force_redraw = false; + spin_unlock(&force_redraw_lock); +#endif + const VIDEO_MODE &mode = drv->mode; // Allocate bounding boxes for SDL_UpdateRects() @@ -2422,7 +2433,11 @@ static void update_display_static_bbox(driver_base *drv) for (uint32 j = y; j < (y + h); j++) { const uint32 yb = j * bytes_per_row; const uint32 dst_yb = j * dst_bytes_per_row; +#ifdef VIDEO_ROOTLESS + if (redraw || memcmp(&the_buffer[yb + xb], &the_buffer_copy[yb + xb], xs) != 0) { +#else if (memcmp(&the_buffer[yb + xb], &the_buffer_copy[yb + xb], xs) != 0) { +#endif memcpy(&the_buffer_copy[yb + xb], &the_buffer[yb + xb], xs); Screen_blit((uint8 *)drv->s->pixels + dst_yb + xb, the_buffer + yb + xb, xs); dirty = true;