From bf09b062b54e9c786407e6b553fd1765a78edcf4 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 30 Sep 2017 23:29:53 +0200 Subject: [PATCH] atari:gem: Add function to align work area, so it can adds extra padding on window. --- src/video/gem/SDL_gemevents.c | 21 +-------------- src/video/gem/SDL_gemvideo.c | 51 ++++++++++++++++++++++++++++++++--- src/video/gem/SDL_gemvideo.h | 2 +- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/video/gem/SDL_gemevents.c b/src/video/gem/SDL_gemevents.c index 61cf1b292..b521ac055 100644 --- a/src/video/gem/SDL_gemevents.c +++ b/src/video/gem/SDL_gemevents.c @@ -288,26 +288,7 @@ static int do_messages(_THIS, short *message, short latest_msg_id) } if (update_work_area) { - wind_get (message[3], WF_WORKXYWH, &GEM_work_x, &GEM_work_y, &GEM_work_w, &GEM_work_h); - - /* Align work area on 16 pixels boundary (faster for bitplanes modes) */ - if (align_work_area) { - int aligned_x; - short pxy[4]; - - aligned_x = GEM_work_x; - if (aligned_x & 15) { - aligned_x = (aligned_x|15)+1; - - pxy[0] = GEM_work_x; - pxy[1] = GEM_work_y; - pxy[2] = aligned_x - 1; - pxy[3] = pxy[1] + GEM_work_h - 1; - GEM_clear_rect(this, pxy); - } - GEM_work_w -= (aligned_x - GEM_work_x); - GEM_work_x = aligned_x; - } + GEM_align_work_area(this, message[3], 1); if (sdl_resize) { SDL_PrivateResize(GEM_work_w, GEM_work_h); diff --git a/src/video/gem/SDL_gemvideo.c b/src/video/gem/SDL_gemvideo.c index de9d0fc7f..0de0462fa 100644 --- a/src/video/gem/SDL_gemvideo.c +++ b/src/video/gem/SDL_gemvideo.c @@ -93,6 +93,7 @@ static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect *rects); /* Internal functions */ static void GEM_FreeBuffers(_THIS); static void GEM_ClearScreen(_THIS); +static void GEM_ClearRect(_THIS, short *rect); static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]); static void GEM_LockScreen(_THIS); static void GEM_UnlockScreen(_THIS); @@ -499,7 +500,7 @@ static void GEM_FreeBuffers(_THIS) } } -void GEM_clear_rect(_THIS, short *rect) +void GEM_ClearRect(_THIS, short *rect) { short oldrgb[3], rgb[3]={0,0,0}; @@ -523,7 +524,7 @@ static void GEM_ClearScreen(_THIS) pxy[0] = pxy[1] = 0; pxy[2] = VDI_w - 1; pxy[3] = VDI_h - 1; - GEM_clear_rect(this, pxy); + GEM_ClearRect(this, pxy); v_show_c(VDI_handle, 1); } @@ -760,6 +761,8 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, /* Align work area on 16 pixels boundary (faster for bitplanes modes) */ wind_calc(WC_WORK, GEM_win_type, x2,y2,w2,h2, &x2,&y2,&w2,&h2); x2 &= -16; + x2 -= 8; + w2 += 16; wind_calc(WC_BORDER, GEM_win_type, x2,y2,w2,h2, &x2,&y2,&w2,&h2); /* Destroy existing window */ @@ -797,7 +800,7 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, } } - wind_get (GEM_handle, WF_WORKXYWH, &GEM_work_x,&GEM_work_y,&GEM_work_w,&GEM_work_h); + GEM_align_work_area(this, GEM_handle, 0); GEM_fullscreen = SDL_FALSE; } @@ -837,6 +840,46 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, return(current); } +void GEM_align_work_area(_THIS, short windowid, int clear_pads) +{ + int new_x, new_w; + + wind_get(windowid, WF_WORKXYWH, &GEM_work_x,&GEM_work_y,&GEM_work_w,&GEM_work_h); + + /* Align work area on 16 pixels boundary (faster for bitplanes modes) */ + new_x = GEM_work_x; + if (new_x & 15) { + new_x = (new_x|15)+1; + } + new_w = GEM_work_w; + new_w -= (new_x - GEM_work_x); + new_w &= -16; + + if (clear_pads) { + short pxy[4]; + + pxy[1] = GEM_work_y; + pxy[3] = pxy[1] + GEM_work_h - 1; + + /* Left padding */ + pxy[0] = GEM_work_x; + pxy[2] = new_x - 1; + if (pxy[0]<=pxy[2]) { + GEM_ClearRect(this, pxy); + } + + /* Right padding */ + pxy[0] = new_x + new_w; + pxy[2] = GEM_work_x + GEM_work_w - 1; + if (pxy[0]<=pxy[2]) { + GEM_ClearRect(this, pxy); + } + } + + GEM_work_w = new_w; + GEM_work_x = new_x; +} + static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface) { return -1; @@ -1203,7 +1246,7 @@ static void refresh_window(_THIS, int winhandle, short *rect) surface = GEM_icon; - GEM_clear_rect(this, rect); + GEM_ClearRect(this, rect); /* Calculate centered icon(x,y,w,h) relative to window */ iconx = (wind_pxy[2]-surface->w)>>1; diff --git a/src/video/gem/SDL_gemvideo.h b/src/video/gem/SDL_gemvideo.h index 6fc27b35c..1fd7c5607 100644 --- a/src/video/gem/SDL_gemvideo.h +++ b/src/video/gem/SDL_gemvideo.h @@ -37,7 +37,7 @@ struct WMcursor { /* Functions prototypes */ void GEM_wind_redraw(_THIS, int winhandle, short *inside); -void GEM_clear_rect(_THIS, short *rect); +void GEM_align_work_area(_THIS, short windowid, int clear_pads); /* Private display data */