1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-26 02:19:24 +01:00

improve DDBLT_COLORFILL performance - fill only the first row and then copy first row into the remaining rows

This commit is contained in:
FunkyFr3sh 2018-11-17 03:48:41 +01:00
parent 20205db5d5
commit d00b95f8b0

View File

@ -147,31 +147,25 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
if (This->surface && (dwFlags & DDBLT_COLORFILL)) if (This->surface && (dwFlags & DDBLT_COLORFILL))
{ {
unsigned char *dst = (unsigned char *)This->surface + (dst_x * This->lXPitch) + (This->lPitch * dst_y);
unsigned char *firstRow = dst;
int x, i;
if (This->bpp == 8) if (This->bpp == 8)
{ {
int y, x;
for (y = 0; y < dst_h; y++)
{
int ydst = This->width * (y + dst_y);
for (x = 0; x < dst_w; x++) for (x = 0; x < dst_w; x++)
{ ((unsigned char *)dst)[x] = lpDDBltFx->dwFillColor;
((unsigned char *)This->surface)[x + dst_x + ydst] = lpDDBltFx->dwFillColor;
}
}
} }
else if (This->bpp == 16) else if (This->bpp == 16)
{ {
int y, x;
for (y = 0; y < dst_h; y++)
{
int ydst = This->width * (y + dst_y);
for (x = 0; x < dst_w; x++) for (x = 0; x < dst_w; x++)
((unsigned short *)dst)[x] = lpDDBltFx->dwFillColor;
}
for (i = 1; i < dst_h; i++)
{ {
((unsigned short *)This->surface)[x + dst_x + ydst] = lpDDBltFx->dwFillColor; dst += This->lPitch;
} memcpy(dst, firstRow, dst_w * This->lXPitch);
}
} }
} }