atari:gem: Add function to align work area, so it can adds extra padding on window. SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Sat, 30 Sep 2017 23:29:53 +0200
branchSDL-1.2
changeset 11560c267eabdc97f
parent 11559 a330adcd0490
child 11561 e990d334b75a
atari:gem: Add function to align work area, so it can adds extra padding on window.
src/video/gem/SDL_gemevents.c
src/video/gem/SDL_gemvideo.c
src/video/gem/SDL_gemvideo.h
     1.1 --- a/src/video/gem/SDL_gemevents.c	Sat Sep 30 22:06:30 2017 +0200
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Sat Sep 30 23:29:53 2017 +0200
     1.3 @@ -288,26 +288,7 @@
     1.4  	}
     1.5  
     1.6  	if (update_work_area) {
     1.7 -		wind_get (message[3], WF_WORKXYWH, &GEM_work_x, &GEM_work_y, &GEM_work_w, &GEM_work_h);
     1.8 -
     1.9 -		/* Align work area on 16 pixels boundary (faster for bitplanes modes) */
    1.10 -		if (align_work_area) {
    1.11 -			int aligned_x;
    1.12 -			short pxy[4];
    1.13 -
    1.14 -			aligned_x = GEM_work_x;
    1.15 -			if (aligned_x & 15) {
    1.16 -				aligned_x = (aligned_x|15)+1;
    1.17 -
    1.18 -				pxy[0] = GEM_work_x;
    1.19 -				pxy[1] = GEM_work_y;
    1.20 -				pxy[2] = aligned_x - 1;
    1.21 -				pxy[3] = pxy[1] + GEM_work_h - 1;
    1.22 -				GEM_clear_rect(this, pxy);
    1.23 -			}
    1.24 -			GEM_work_w -= (aligned_x - GEM_work_x);
    1.25 -			GEM_work_x = aligned_x;
    1.26 -		}
    1.27 +		GEM_align_work_area(this, message[3], 1);
    1.28  
    1.29  		if (sdl_resize) {
    1.30  			SDL_PrivateResize(GEM_work_w, GEM_work_h);
     2.1 --- a/src/video/gem/SDL_gemvideo.c	Sat Sep 30 22:06:30 2017 +0200
     2.2 +++ b/src/video/gem/SDL_gemvideo.c	Sat Sep 30 23:29:53 2017 +0200
     2.3 @@ -93,6 +93,7 @@
     2.4  /* Internal functions */
     2.5  static void GEM_FreeBuffers(_THIS);
     2.6  static void GEM_ClearScreen(_THIS);
     2.7 +static void GEM_ClearRect(_THIS, short *rect);
     2.8  static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]);
     2.9  static void GEM_LockScreen(_THIS);
    2.10  static void GEM_UnlockScreen(_THIS);
    2.11 @@ -499,7 +500,7 @@
    2.12  	}
    2.13  }
    2.14  
    2.15 -void GEM_clear_rect(_THIS, short *rect)
    2.16 +void GEM_ClearRect(_THIS, short *rect)
    2.17  {
    2.18  	short oldrgb[3], rgb[3]={0,0,0};
    2.19  
    2.20 @@ -523,7 +524,7 @@
    2.21  	pxy[0] = pxy[1] = 0;
    2.22  	pxy[2] = VDI_w - 1;
    2.23  	pxy[3] = VDI_h - 1;
    2.24 -	GEM_clear_rect(this, pxy);
    2.25 +	GEM_ClearRect(this, pxy);
    2.26  
    2.27  	v_show_c(VDI_handle, 1);
    2.28  }
    2.29 @@ -760,6 +761,8 @@
    2.30  			/* Align work area on 16 pixels boundary (faster for bitplanes modes) */
    2.31  			wind_calc(WC_WORK, GEM_win_type, x2,y2,w2,h2, &x2,&y2,&w2,&h2);
    2.32  			x2 &= -16;
    2.33 +			x2 -= 8;
    2.34 +			w2 += 16;
    2.35  			wind_calc(WC_BORDER, GEM_win_type, x2,y2,w2,h2, &x2,&y2,&w2,&h2);
    2.36  
    2.37  			/* Destroy existing window */
    2.38 @@ -797,7 +800,7 @@
    2.39  			}
    2.40  		}
    2.41  
    2.42 -		wind_get (GEM_handle, WF_WORKXYWH, &GEM_work_x,&GEM_work_y,&GEM_work_w,&GEM_work_h);
    2.43 +		GEM_align_work_area(this, GEM_handle, 0);
    2.44  		GEM_fullscreen = SDL_FALSE;
    2.45  	}
    2.46  
    2.47 @@ -837,6 +840,46 @@
    2.48  	return(current);
    2.49  }
    2.50  
    2.51 +void GEM_align_work_area(_THIS, short windowid, int clear_pads)
    2.52 +{
    2.53 +	int new_x, new_w;
    2.54 +
    2.55 +	wind_get(windowid, WF_WORKXYWH, &GEM_work_x,&GEM_work_y,&GEM_work_w,&GEM_work_h);
    2.56 +
    2.57 +	/* Align work area on 16 pixels boundary (faster for bitplanes modes) */
    2.58 +	new_x = GEM_work_x;
    2.59 +	if (new_x & 15) {
    2.60 +		new_x = (new_x|15)+1;
    2.61 +	}
    2.62 +	new_w = GEM_work_w;
    2.63 +	new_w -= (new_x - GEM_work_x);
    2.64 +	new_w &= -16;
    2.65 +
    2.66 +	if (clear_pads) {
    2.67 +		short pxy[4];
    2.68 +
    2.69 +		pxy[1] = GEM_work_y;
    2.70 +		pxy[3] = pxy[1] + GEM_work_h - 1;
    2.71 +
    2.72 +		/* Left padding */
    2.73 +		pxy[0] = GEM_work_x;
    2.74 +		pxy[2] = new_x - 1;
    2.75 +		if (pxy[0]<=pxy[2]) {
    2.76 +			GEM_ClearRect(this, pxy);
    2.77 +		}
    2.78 +
    2.79 +		/* Right padding */
    2.80 +		pxy[0] = new_x + new_w;
    2.81 +		pxy[2] = GEM_work_x + GEM_work_w - 1;
    2.82 +		if (pxy[0]<=pxy[2]) {
    2.83 +			GEM_ClearRect(this, pxy);
    2.84 +		}
    2.85 +	}
    2.86 +
    2.87 +	GEM_work_w = new_w;
    2.88 +	GEM_work_x = new_x;
    2.89 +}
    2.90 +
    2.91  static int GEM_AllocHWSurface(_THIS, SDL_Surface *surface)
    2.92  {
    2.93  	return -1;
    2.94 @@ -1203,7 +1246,7 @@
    2.95  
    2.96  		surface = GEM_icon;
    2.97  
    2.98 -		GEM_clear_rect(this, rect);
    2.99 +		GEM_ClearRect(this, rect);
   2.100  
   2.101  		/* Calculate centered icon(x,y,w,h) relative to window */
   2.102  		iconx = (wind_pxy[2]-surface->w)>>1;
     3.1 --- a/src/video/gem/SDL_gemvideo.h	Sat Sep 30 22:06:30 2017 +0200
     3.2 +++ b/src/video/gem/SDL_gemvideo.h	Sat Sep 30 23:29:53 2017 +0200
     3.3 @@ -37,7 +37,7 @@
     3.4  
     3.5  /* Functions prototypes */
     3.6  void GEM_wind_redraw(_THIS, int winhandle, short *inside);
     3.7 -void GEM_clear_rect(_THIS, short *rect);
     3.8 +void GEM_align_work_area(_THIS, short windowid, int clear_pads);
     3.9  
    3.10  /* Private display data */
    3.11