Be conservative about border redraws

This commit is contained in:
Kevin Lange 2013-06-12 23:42:14 -07:00
parent 40fe8c42a1
commit 1c58a72ef3
3 changed files with 12 additions and 4 deletions

View File

@ -57,6 +57,7 @@ void TOARU_PumpEvents(_THIS) {
if (window) { if (window) {
window->focused = evt->left; window->focused = evt->left;
} }
this->hidden->redraw_borders = 1;
SDL_PrivateAppActive(0, evt->left); SDL_PrivateAppActive(0, evt->left);
break; break;
} }

View File

@ -170,6 +170,7 @@ SDL_Surface *TOARU_SetVideoMode(_THIS, SDL_Surface *current,
if (this->hidden->bordered) { if (this->hidden->bordered) {
this->hidden->buffer = realloc(this->hidden->buffer, sizeof(uint32_t) * width * height); this->hidden->buffer = realloc(this->hidden->buffer, sizeof(uint32_t) * width * height);
this->hidden->redraw_borders = 1;
} }
} else { } else {
@ -188,6 +189,7 @@ SDL_Surface *TOARU_SetVideoMode(_THIS, SDL_Surface *current,
this->hidden->x_w = decor_width(); this->hidden->x_w = decor_width();
this->hidden->o_h = decor_top_height; this->hidden->o_h = decor_top_height;
this->hidden->o_w = decor_left_width; this->hidden->o_w = decor_left_width;
this->hidden->redraw_borders = 1;
} }
fprintf(stderr, "Initializing window %dx%d (%d bpp)\n", width, height, bpp); fprintf(stderr, "Initializing window %dx%d (%d bpp)\n", width, height, bpp);
@ -249,10 +251,13 @@ static void TOARU_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
int x = 0; int x = 0;
if (this->hidden->bordered) { if (this->hidden->bordered) {
gfx_context_t * ctx = (gfx_context_t *)this->hidden->ctx; gfx_context_t * ctx = (gfx_context_t *)this->hidden->ctx;
if (this->hidden->title) { if (this->hidden->redraw_borders) {
render_decorations(this->hidden->window, this->hidden->ctx, this->hidden->title); if (this->hidden->title) {
} else { render_decorations(this->hidden->window, this->hidden->ctx, this->hidden->title);
render_decorations(this->hidden->window, this->hidden->ctx, "[SDL App]"); } else {
render_decorations(this->hidden->window, this->hidden->ctx, "[SDL App]");
}
this->hidden->redraw_borders = 0;
} }
flip(this->hidden->ctx); flip(this->hidden->ctx);
for (y = 0; y < this->hidden->h; ++y) { for (y = 0; y < this->hidden->h; ++y) {
@ -291,5 +296,6 @@ static void TOARU_SetCaption(_THIS, const char *title, const char *icon) {
free(this->hidden->title); free(this->hidden->title);
} }
this->hidden->title = strdup(title); this->hidden->title = strdup(title);
this->hidden->redraw_borders = 1;
} }

View File

@ -41,6 +41,7 @@ struct SDL_PrivateVideoData {
char * title; char * title;
int x_w, x_h; int x_w, x_h;
int o_w, o_h; int o_w, o_h;
int redraw_borders;
}; };
#endif /* _SDL_nullvideo_h */ #endif /* _SDL_nullvideo_h */