Don't blit unnecessarily.
During the game, a lot of images were blitted outside the visible area. Also, addBuffer() was called even when the destination surface was not the screen, resulting in unnecessary blits in unBuffer().
This commit is contained in:
parent
70d0b13ea2
commit
c42ee44271
|
@ -265,19 +265,25 @@ class Graphics {
|
|||
|
||||
void blit(SDL_Surface *image, int x, int y, SDL_Surface *dest)
|
||||
{
|
||||
// Exit early if image is not on dest at all
|
||||
if(x + image->w < 0 || x >= dest->w || y + image->h < 0 || y >= dest->h)
|
||||
return;
|
||||
|
||||
// Set up a rectangle to draw to
|
||||
blitRect.x = x;
|
||||
blitRect.y = y;
|
||||
blitRect.w = image->w;
|
||||
blitRect.h = image->h;
|
||||
|
||||
/* Blit onto the screen surface */
|
||||
/* Blit onto the destination surface */
|
||||
if(SDL_BlitSurface(image, NULL, dest, &blitRect) < 0)
|
||||
{
|
||||
printf("BlitSurface error: %s\n", SDL_GetError());
|
||||
showErrorAndExit(2, "");
|
||||
}
|
||||
|
||||
// Only ff it is to the screen, mark the region as damaged
|
||||
if(dest == screen)
|
||||
addBuffer(blitRect.x, blitRect.y, blitRect.w, blitRect.h);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue