Skip to content

Commit

Permalink
atari:gem: Add function to align work area, so it can adds extra padd…
Browse files Browse the repository at this point in the history
…ing on window.
  • Loading branch information
pmandin committed Sep 30, 2017
1 parent 5420a70 commit bf09b06
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 25 deletions.
21 changes: 1 addition & 20 deletions src/video/gem/SDL_gemevents.c
Expand Up @@ -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);
Expand Down
51 changes: 47 additions & 4 deletions src/video/gem/SDL_gemvideo.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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};

Expand All @@ -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);
}
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/video/gem/SDL_gemvideo.h
Expand Up @@ -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 */

Expand Down

0 comments on commit bf09b06

Please sign in to comment.