Skip to content

Commit

Permalink
atari:gem: Avoid querying window workarea at draw time (can be slow).…
Browse files Browse the repository at this point in the history
… Do it only when window created, moved or resized.
  • Loading branch information
pmandin committed Sep 30, 2017
1 parent e77831e commit 5041d51
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/video/gem/SDL_gemevents.c
Expand Up @@ -188,7 +188,6 @@ void GEM_PumpEvents(_THIS)
static int do_messages(_THIS, short *message, short latest_msg_id)
{
int quit;
short x2,y2,w2,h2;

quit = 0;
switch (message[0]) {
Expand All @@ -202,6 +201,7 @@ static int do_messages(_THIS, short *message, short latest_msg_id)
break;
case WM_MOVED:
wind_set(message[3],WF_CURRXYWH,message[4],message[5],message[6],message[7]);
wind_get (message[3], WF_WORKXYWH, &GEM_work_x, &GEM_work_y, &GEM_work_w, &GEM_work_h);
break;
case WM_TOPPED:
wind_set(message[3],WF_TOP,message[4],0,0,0);
Expand All @@ -219,7 +219,7 @@ static int do_messages(_THIS, short *message, short latest_msg_id)
break;
case WM_ICONIFY:
case WM_ALLICONIFY:
wind_set(message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]);
wind_set (message[3],WF_ICONIFY,message[4],message[5],message[6],message[7]);
/* If we're active, make ourselves inactive */
if ( SDL_GetAppState() & SDL_APPACTIVE ) {
/* Send an internal deactivate event */
Expand All @@ -235,7 +235,7 @@ static int do_messages(_THIS, short *message, short latest_msg_id)
}
break;
case WM_UNICONIFY:
wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
wind_set (message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
/* If we're not active, make ourselves active */
if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) {
/* Send an internal activate event */
Expand All @@ -251,10 +251,10 @@ static int do_messages(_THIS, short *message, short latest_msg_id)
break;
case WM_SIZED:
wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
wind_get (message[3], WF_WORKXYWH, &GEM_work_x, &GEM_work_y, &GEM_work_w, &GEM_work_h);
GEM_win_fulled = SDL_FALSE; /* Cancel maximized flag */
GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */
SDL_PrivateResize(w2, h2);
SDL_PrivateResize(GEM_work_w, GEM_work_h);
break;
case WM_FULLED:
{
Expand All @@ -271,9 +271,9 @@ static int do_messages(_THIS, short *message, short latest_msg_id)
GEM_win_fulled = SDL_TRUE;
}
wind_set (message[3], WF_CURRXYWH, x, y, w, h);
wind_get (message[3], WF_WORKXYWH, &x2, &y2, &w2, &h2);
wind_get (message[3], WF_WORKXYWH, &GEM_work_x, &GEM_work_y, &GEM_work_w, &GEM_work_h);
GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers resized */
SDL_PrivateResize(w2, h2);
SDL_PrivateResize(GEM_work_w, GEM_work_h);
}
break;
case WM_BOTTOMED:
Expand Down
30 changes: 18 additions & 12 deletions src/video/gem/SDL_gemvideo.c
Expand Up @@ -349,6 +349,11 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
return 1;
}

GEM_work_x = GEM_desk_x;
GEM_work_y = GEM_desk_y;
GEM_work_w = GEM_desk_w;
GEM_work_h = GEM_desk_h;

/* Read bit depth */
vq_extnd(VDI_handle, 1, work_out);
VDI_bpp = work_out[4];
Expand Down Expand Up @@ -793,6 +798,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_fullscreen = SDL_FALSE;
}

Expand Down Expand Up @@ -933,16 +939,12 @@ static void GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect *rects)

static void GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect *rects)
{
short pxy[4], wind_pxy[4];
short pxy[4];
int i;

if (wind_get(GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {
return;
}

for ( i=0; i<numrects; ++i ) {
pxy[0] = wind_pxy[0] + rects[i].x;
pxy[1] = wind_pxy[1] + rects[i].y;
pxy[0] = GEM_work_x + rects[i].x;
pxy[1] = GEM_work_y + rects[i].y;
pxy[2] = rects[i].w;
pxy[3] = rects[i].h;

Expand Down Expand Up @@ -1028,10 +1030,13 @@ static int GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface *surface)

static int GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface *surface)
{
short pxy[8];
short pxy[4];

/* Update the whole window */
wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]);
pxy[0] = GEM_work_x;
pxy[1] = GEM_work_y;
pxy[2] = GEM_work_w;
pxy[3] = GEM_work_h;

GEM_wind_redraw(this, GEM_handle, pxy);

Expand Down Expand Up @@ -1188,9 +1193,10 @@ static void refresh_window(_THIS, int winhandle, short *rect)
}
}

if (wind_get(winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2], &wind_pxy[3])==0) {
return;
}
wind_pxy[0] = GEM_work_x;
wind_pxy[1] = GEM_work_y;
wind_pxy[2] = GEM_work_w;
wind_pxy[3] = GEM_work_h;

if (iconified && GEM_icon) {
short icon_rect[4], dst_rect[4];
Expand Down
8 changes: 7 additions & 1 deletion src/video/gem/SDL_gemvideo.h
Expand Up @@ -75,6 +75,8 @@ struct SDL_PrivateVideoData {
short desk_w, desk_h;
short win_handle; /* Our window handle */
int window_type; /* Window type */
short work_x, work_y; /* Window work area x,y,w,h */
short work_w, work_h;
const char *title_name; /* Window title */
const char *icon_name; /* Icon title */
short version; /* AES version */
Expand Down Expand Up @@ -115,13 +117,17 @@ struct SDL_PrivateVideoData {
#define VDI_screensize (this->hidden->screensize)
#define VDI_dst_mfdb (this->hidden->dst_mfdb)

#define GEM_ap_id (this->hidden->ap_id)
#define GEM_ap_id (this->hidden->ap_id)
#define GEM_desk_x (this->hidden->desk_x)
#define GEM_desk_y (this->hidden->desk_y)
#define GEM_desk_w (this->hidden->desk_w)
#define GEM_desk_h (this->hidden->desk_h)
#define GEM_handle (this->hidden->win_handle)
#define GEM_win_type (this->hidden->window_type)
#define GEM_work_x (this->hidden->work_x)
#define GEM_work_y (this->hidden->work_y)
#define GEM_work_w (this->hidden->work_w)
#define GEM_work_h (this->hidden->work_h)
#define GEM_title_name (this->hidden->title_name)
#define GEM_icon_name (this->hidden->icon_name)
#define GEM_refresh_name (this->hidden->refresh_name)
Expand Down

0 comments on commit 5041d51

Please sign in to comment.