mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-07-31 05:30:23 +02:00
Performance optimisation for blitting loops and depth3d
This commit is contained in:
@@ -279,11 +279,11 @@ void blit(pixel * vid)
|
|||||||
unsigned int red, green, blue;
|
unsigned int red, green, blue;
|
||||||
pixel px, lastpx, nextpx;
|
pixel px, lastpx, nextpx;
|
||||||
SDL_PixelFormat *fmt = sdl_scrn->format;
|
SDL_PixelFormat *fmt = sdl_scrn->format;
|
||||||
for (j=0; j<h; j++)
|
if(depth3d)
|
||||||
{
|
{
|
||||||
for (i=0; i<w; i++)
|
for (j=0; j<h; j++)
|
||||||
{
|
{
|
||||||
if (depth3d)
|
for (i=0; i<w; i++)
|
||||||
{
|
{
|
||||||
lastpx = i >= depth3d && i < w+depth3d ? src[i-depth3d] : 0;
|
lastpx = i >= depth3d && i < w+depth3d ? src[i-depth3d] : 0;
|
||||||
nextpx = i >= -depth3d && i < w-depth3d ? src[i+depth3d] : 0;
|
nextpx = i >= -depth3d && i < w-depth3d ? src[i+depth3d] : 0;
|
||||||
@@ -296,28 +296,37 @@ void blit(pixel * vid)
|
|||||||
red = ((int)(PIXR(lastpx)*.69f+redshift*.3f)>>fmt->Rloss)<<fmt->Rshift;
|
red = ((int)(PIXR(lastpx)*.69f+redshift*.3f)>>fmt->Rloss)<<fmt->Rshift;
|
||||||
green = ((int)(PIXG(nextpx)*.3f)>>fmt->Gloss)<<fmt->Gshift;
|
green = ((int)(PIXG(nextpx)*.3f)>>fmt->Gloss)<<fmt->Gshift;
|
||||||
blue = ((int)(PIXB(nextpx)*.69f+blueshift*.3f)>>fmt->Bloss)<<fmt->Bshift;
|
blue = ((int)(PIXB(nextpx)*.69f+blueshift*.3f)>>fmt->Bloss)<<fmt->Bshift;
|
||||||
|
dst[i] = red|green|blue;
|
||||||
}
|
}
|
||||||
else
|
dst+=sdl_scrn->pitch/PIXELSIZE;
|
||||||
|
src+=pitch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (j=0; j<h; j++)
|
||||||
|
{
|
||||||
|
for (i=0; i<w; i++)
|
||||||
{
|
{
|
||||||
px = src[i];
|
px = src[i];
|
||||||
red = (PIXR(px)>>fmt->Rloss)<<fmt->Rshift;
|
red = (PIXR(px)>>fmt->Rloss)<<fmt->Rshift;
|
||||||
green = (PIXG(px)>>fmt->Gloss)<<fmt->Gshift;
|
green = (PIXG(px)>>fmt->Gloss)<<fmt->Gshift;
|
||||||
blue = (PIXB(px)>>fmt->Bloss)<<fmt->Bshift;
|
blue = (PIXB(px)>>fmt->Bloss)<<fmt->Bshift;
|
||||||
|
dst[i] = red|green|blue;
|
||||||
}
|
}
|
||||||
dst[i] = red|green|blue;
|
dst+=sdl_scrn->pitch/PIXELSIZE;
|
||||||
|
src+=pitch;
|
||||||
}
|
}
|
||||||
dst+=sdl_scrn->pitch/PIXELSIZE;
|
|
||||||
src+=pitch;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (j=0; j<h; j++)
|
if(depth3d)
|
||||||
{
|
{
|
||||||
if (depth3d)
|
pixel lastpx, nextpx;
|
||||||
|
for (j=0; j<h; j++)
|
||||||
{
|
{
|
||||||
pixel lastpx, nextpx;
|
|
||||||
for (i=0; i<w; i++)
|
for (i=0; i<w; i++)
|
||||||
{
|
{
|
||||||
lastpx = i >= depth3d && i < w+depth3d ? src[i-depth3d] : 0;
|
lastpx = i >= depth3d && i < w+depth3d ? src[i-depth3d] : 0;
|
||||||
@@ -330,11 +339,18 @@ void blit(pixel * vid)
|
|||||||
blueshift = 255;
|
blueshift = 255;
|
||||||
dst[i] = PIXRGB((int)(PIXR(lastpx)*.69f+redshift*.3f), (int)(PIXG(nextpx)*.3f), (int)(PIXB(nextpx)*.69f+blueshift*.3f));
|
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
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (j=0; j<h; j++)
|
||||||
|
{
|
||||||
memcpy(dst, src, w*PIXELSIZE);
|
memcpy(dst, src, w*PIXELSIZE);
|
||||||
dst+=sdl_scrn->pitch/PIXELSIZE;
|
dst+=sdl_scrn->pitch/PIXELSIZE;
|
||||||
src+=pitch;
|
src+=pitch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SDL_MUSTLOCK(sdl_scrn))
|
if (SDL_MUSTLOCK(sdl_scrn))
|
||||||
|
Reference in New Issue
Block a user