atari:gem: Avoid querying window workarea at draw time (can be slow). Do it only when window created, moved or resized. SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Sat, 30 Sep 2017 18:07:02 +0200
branchSDL-1.2
changeset 11555a3426706e128
parent 11554 9694b296d6e6
child 11556 87e99e7708ce
atari:gem: Avoid querying window workarea at draw time (can be slow). Do it only when window created, moved or resized.
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 15:43:28 2017 +0200
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Sat Sep 30 18:07:02 2017 +0200
     1.3 @@ -188,7 +188,6 @@
     1.4  static int do_messages(_THIS, short *message, short latest_msg_id)
     1.5  {
     1.6  	int quit;
     1.7 -	short x2,y2,w2,h2;
     1.8  
     1.9  	quit = 0;
    1.10  	switch (message[0]) {
    1.11 @@ -202,6 +201,7 @@
    1.12  			break;
    1.13  		case WM_MOVED:
    1.14  			wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]);
    1.15 +			wind_get (message[3], WF_WORKXYWH, &GEM_work_x, &GEM_work_y, &GEM_work_w, &GEM_work_h);
    1.16  			break;
    1.17  		case WM_TOPPED:
    1.18  			wind_set(message[3],WF_TOP,message[4],0,0,0);
    1.19 @@ -219,7 +219,7 @@
    1.20  			break;
    1.21  		case WM_ICONIFY:
    1.22  		case WM_ALLICONIFY:
    1.23 -			wind_set(message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]);
    1.24 +			wind_set (message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]);
    1.25  			/* If we're active, make ourselves inactive */
    1.26  			if ( SDL_GetAppState() & SDL_APPACTIVE ) {
    1.27  				/* Send an internal deactivate event */
    1.28 @@ -235,7 +235,7 @@
    1.29  			}
    1.30  			break;
    1.31  		case WM_UNICONIFY:
    1.32 -			wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
    1.33 +			wind_set (message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
    1.34  			/* If we're not active, make ourselves active */
    1.35  			if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) {
    1.36  				/* Send an internal activate event */
    1.37 @@ -251,10 +251,10 @@
    1.38  			break;
    1.39  		case WM_SIZED:
    1.40  			wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
    1.41 -			wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
    1.42 +			wind_get (message[3], WF_WORKXYWH, &GEM_work_x, &GEM_work_y, &GEM_work_w, &GEM_work_h);
    1.43  			GEM_win_fulled = SDL_FALSE;		/* Cancel maximized flag */
    1.44  			GEM_lock_redraw = SDL_TRUE;		/* Prevent redraw till buffers resized */
    1.45 -			SDL_PrivateResize(w2, h2);
    1.46 +			SDL_PrivateResize(GEM_work_w, GEM_work_h);
    1.47  			break;
    1.48  		case WM_FULLED:
    1.49  			{
    1.50 @@ -271,9 +271,9 @@
    1.51  					GEM_win_fulled = SDL_TRUE;
    1.52  				}
    1.53  				wind_set (message[3], WF_CURRXYWH, x, y, w, h);
    1.54 -				wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
    1.55 +				wind_get (message[3], WF_WORKXYWH, &GEM_work_x, &GEM_work_y, &GEM_work_w, &GEM_work_h);
    1.56  				GEM_lock_redraw = SDL_TRUE;		/* Prevent redraw till buffers resized */
    1.57 -				SDL_PrivateResize(w2, h2);
    1.58 +				SDL_PrivateResize(GEM_work_w, GEM_work_h);
    1.59  			}
    1.60  			break;
    1.61  		case WM_BOTTOMED:
     2.1 --- a/src/video/gem/SDL_gemvideo.c	Sat Sep 30 15:43:28 2017 +0200
     2.2 +++ b/src/video/gem/SDL_gemvideo.c	Sat Sep 30 18:07:02 2017 +0200
     2.3 @@ -349,6 +349,11 @@
     2.4  		return 1;
     2.5  	}
     2.6  
     2.7 +	GEM_work_x = GEM_desk_x;
     2.8 +	GEM_work_y = GEM_desk_y;
     2.9 +	GEM_work_w = GEM_desk_w;
    2.10 +	GEM_work_h = GEM_desk_h;
    2.11 +
    2.12  	/* Read bit depth */
    2.13  	vq_extnd(VDI_handle, 1, work_out);
    2.14  	VDI_bpp = work_out[4];
    2.15 @@ -793,6 +798,7 @@
    2.16  			}
    2.17  		}
    2.18  
    2.19 +		wind_get (GEM_handle, WF_WORKXYWH, &GEM_work_x,&GEM_work_y,&GEM_work_w,&GEM_work_h);
    2.20  		GEM_fullscreen = SDL_FALSE;
    2.21  	}
    2.22  
    2.23 @@ -933,16 +939,12 @@
    2.24  
    2.25  static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects)
    2.26  {
    2.27 -	short pxy[4], wind_pxy[4];
    2.28 +	short pxy[4];
    2.29  	int i;
    2.30  
    2.31 -	if (wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {
    2.32 -		return;
    2.33 -	}
    2.34 -
    2.35  	for ( i=0; i<numrects; ++i ) {
    2.36 -		pxy[0] = wind_pxy[0] + rects[i].x;
    2.37 -		pxy[1] = wind_pxy[1] + rects[i].y;
    2.38 +		pxy[0] = GEM_work_x + rects[i].x;
    2.39 +		pxy[1] = GEM_work_y + rects[i].y;
    2.40  		pxy[2] = rects[i].w;
    2.41  		pxy[3] = rects[i].h;
    2.42  
    2.43 @@ -1028,10 +1030,13 @@
    2.44  
    2.45  static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface)
    2.46  {
    2.47 -	short	pxy[8];
    2.48 +	short pxy[4];
    2.49  
    2.50  	/* Update the whole window */
    2.51 -	wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]);
    2.52 +	pxy[0] = GEM_work_x;
    2.53 +	pxy[1] = GEM_work_y;
    2.54 +	pxy[2] = GEM_work_w;
    2.55 +	pxy[3] = GEM_work_h;
    2.56  
    2.57  	GEM_wind_redraw(this, GEM_handle, pxy);
    2.58  
    2.59 @@ -1188,9 +1193,10 @@
    2.60  		}
    2.61  	}
    2.62  
    2.63 -	if (wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {
    2.64 -		return;
    2.65 -	}
    2.66 +	wind_pxy[0] = GEM_work_x;
    2.67 +	wind_pxy[1] = GEM_work_y;
    2.68 +	wind_pxy[2] = GEM_work_w;
    2.69 +	wind_pxy[3] = GEM_work_h;
    2.70  
    2.71  	if (iconified && GEM_icon) {
    2.72  		short icon_rect[4], dst_rect[4];
     3.1 --- a/src/video/gem/SDL_gemvideo.h	Sat Sep 30 15:43:28 2017 +0200
     3.2 +++ b/src/video/gem/SDL_gemvideo.h	Sat Sep 30 18:07:02 2017 +0200
     3.3 @@ -75,6 +75,8 @@
     3.4  	short desk_w, desk_h;
     3.5  	short win_handle;			/* Our window handle */
     3.6  	int window_type;			/* Window type */
     3.7 +	short work_x, work_y;		/* Window work area x,y,w,h */
     3.8 +	short work_w, work_h;
     3.9  	const char *title_name;		/* Window title */
    3.10  	const char *icon_name;		/* Icon title */
    3.11  	short version;				/* AES version */
    3.12 @@ -115,13 +117,17 @@
    3.13  #define VDI_screensize		(this->hidden->screensize)
    3.14  #define VDI_dst_mfdb		(this->hidden->dst_mfdb)
    3.15  
    3.16 -#define GEM_ap_id		(this->hidden->ap_id)
    3.17 +#define GEM_ap_id			(this->hidden->ap_id)
    3.18  #define GEM_desk_x			(this->hidden->desk_x)
    3.19  #define GEM_desk_y			(this->hidden->desk_y)
    3.20  #define GEM_desk_w			(this->hidden->desk_w)
    3.21  #define GEM_desk_h			(this->hidden->desk_h)
    3.22  #define GEM_handle			(this->hidden->win_handle)
    3.23  #define GEM_win_type		(this->hidden->window_type)
    3.24 +#define GEM_work_x			(this->hidden->work_x)
    3.25 +#define GEM_work_y			(this->hidden->work_y)
    3.26 +#define GEM_work_w			(this->hidden->work_w)
    3.27 +#define GEM_work_h			(this->hidden->work_h)
    3.28  #define GEM_title_name		(this->hidden->title_name)
    3.29  #define GEM_icon_name		(this->hidden->icon_name)
    3.30  #define GEM_refresh_name	(this->hidden->refresh_name)