Performance optimisation for blitting loops and depth3d
This commit is contained in:
parent
0cf117a5f0
commit
b66ca770da
@ -279,11 +279,11 @@ void blit(pixel * vid)
|
||||
unsigned int red, green, blue;
|
||||
pixel px, lastpx, nextpx;
|
||||
SDL_PixelFormat *fmt = sdl_scrn->format;
|
||||
if(depth3d)
|
||||
{
|
||||
for (j=0; j<h; j++)
|
||||
{
|
||||
for (i=0; i<w; i++)
|
||||
{
|
||||
if (depth3d)
|
||||
{
|
||||
lastpx = i >= depth3d && i < w+depth3d ? src[i-depth3d] : 0;
|
||||
nextpx = i >= -depth3d && i < w-depth3d ? src[i+depth3d] : 0;
|
||||
@ -296,14 +296,6 @@ void blit(pixel * vid)
|
||||
red = ((int)(PIXR(lastpx)*.69f+redshift*.3f)>>fmt->Rloss)<<fmt->Rshift;
|
||||
green = ((int)(PIXG(nextpx)*.3f)>>fmt->Gloss)<<fmt->Gshift;
|
||||
blue = ((int)(PIXB(nextpx)*.69f+blueshift*.3f)>>fmt->Bloss)<<fmt->Bshift;
|
||||
}
|
||||
else
|
||||
{
|
||||
px = src[i];
|
||||
red = (PIXR(px)>>fmt->Rloss)<<fmt->Rshift;
|
||||
green = (PIXG(px)>>fmt->Gloss)<<fmt->Gshift;
|
||||
blue = (PIXB(px)>>fmt->Bloss)<<fmt->Bshift;
|
||||
}
|
||||
dst[i] = red|green|blue;
|
||||
}
|
||||
dst+=sdl_scrn->pitch/PIXELSIZE;
|
||||
@ -312,12 +304,29 @@ void blit(pixel * vid)
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
for (j=0; j<h; j++)
|
||||
{
|
||||
for (i=0; i<w; i++)
|
||||
{
|
||||
px = src[i];
|
||||
red = (PIXR(px)>>fmt->Rloss)<<fmt->Rshift;
|
||||
green = (PIXG(px)>>fmt->Gloss)<<fmt->Gshift;
|
||||
blue = (PIXB(px)>>fmt->Bloss)<<fmt->Bshift;
|
||||
dst[i] = red|green|blue;
|
||||
}
|
||||
dst+=sdl_scrn->pitch/PIXELSIZE;
|
||||
src+=pitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
if(depth3d)
|
||||
{
|
||||
pixel lastpx, nextpx;
|
||||
for (j=0; j<h; j++)
|
||||
{
|
||||
for (i=0; i<w; i++)
|
||||
{
|
||||
lastpx = i >= depth3d && i < w+depth3d ? src[i-depth3d] : 0;
|
||||
@ -330,13 +339,20 @@ void blit(pixel * vid)
|
||||
blueshift = 255;
|
||||
dst[i] = PIXRGB((int)(PIXR(lastpx)*.69f+redshift*.3f), (int)(PIXG(nextpx)*.3f), (int)(PIXB(nextpx)*.69f+blueshift*.3f));
|
||||
}
|
||||
dst+=sdl_scrn->pitch/PIXELSIZE;
|
||||
src+=pitch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j=0; j<h; j++)
|
||||
{
|
||||
memcpy(dst, src, w*PIXELSIZE);
|
||||
dst+=sdl_scrn->pitch/PIXELSIZE;
|
||||
src+=pitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SDL_MUSTLOCK(sdl_scrn))
|
||||
SDL_UnlockSurface(sdl_scrn);
|
||||
SDL_UpdateRect(sdl_scrn,0,0,0,0);
|
||||
|
Loading…
Reference in New Issue
Block a user