mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
try to use a single memcpy if possible - adds stretching support (not used in C&C games though)
This commit is contained in:
parent
897fdb5bbb
commit
ff7267d044
2
ddraw.rc
2
ddraw.rc
@ -2,7 +2,7 @@
|
|||||||
#define vxstr(a,b,c,d) str(a##.##b##.##c##.##d)
|
#define vxstr(a,b,c,d) str(a##.##b##.##c##.##d)
|
||||||
#define str(s) #s
|
#define str(s) #s
|
||||||
|
|
||||||
#define VERSION 1,1,7,3
|
#define VERSION 1,1,7,4
|
||||||
|
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION VERSION
|
FILEVERSION VERSION
|
||||||
|
@ -104,29 +104,51 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
|||||||
|
|
||||||
if(Source)
|
if(Source)
|
||||||
{
|
{
|
||||||
int dx=0,dy=0;
|
//BitBlt(This->hDC, lpDestRect->left, lpDestRect->top, lpDestRect->right, lpDestRect->bottom,
|
||||||
if (lpDestRect)
|
// Source->hDC, lpSrcRect->left, lpSrcRect->top, SRCCOPY);
|
||||||
{
|
|
||||||
dx=lpDestRect->left;
|
int dst_w = lpDestRect->right - lpDestRect->left;
|
||||||
dy=lpDestRect->top;
|
int dst_h = lpDestRect->bottom - lpDestRect->top;
|
||||||
}
|
int src_w = lpSrcRect->right - lpSrcRect->left;
|
||||||
int x0=0,y0=0,x1=Source->width,y1=Source->height;
|
int src_h = lpSrcRect->bottom - lpSrcRect->top;
|
||||||
if (lpSrcRect)
|
|
||||||
{
|
if (dst_w != src_w || dst_h != src_h)
|
||||||
x0 = max(x0, lpSrcRect->left);
|
{
|
||||||
x1 = min(x1, lpSrcRect->right);
|
StretchBlt(This->hDC, lpDestRect->left, lpDestRect->top, lpDestRect->right, lpDestRect->bottom,
|
||||||
y0 = max(y0, lpSrcRect->top);
|
Source->hDC, lpSrcRect->left, lpSrcRect->top, lpSrcRect->right, lpSrcRect->bottom, SRCCOPY);
|
||||||
y1 = min(y1, lpSrcRect->bottom);
|
}
|
||||||
}
|
else if (dst_w == This->width && dst_h == This->height &&
|
||||||
unsigned char* to = (unsigned char *)This->surface + dy*This->width + dx;
|
src_w == Source->width && src_h == Source->height)
|
||||||
unsigned char* from = (unsigned char *)Source->surface + y0*Source->width + x0;
|
{
|
||||||
int s = x1-x0;
|
memcpy(This->surface, Source->surface, This->width * This->height * This->lXPitch);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int dx=0,dy=0;
|
||||||
|
if (lpDestRect)
|
||||||
|
{
|
||||||
|
dx=lpDestRect->left;
|
||||||
|
dy=lpDestRect->top;
|
||||||
|
}
|
||||||
|
int x0=0,y0=0,x1=Source->width,y1=Source->height;
|
||||||
|
if (lpSrcRect)
|
||||||
|
{
|
||||||
|
x0 = max(x0, lpSrcRect->left);
|
||||||
|
x1 = min(x1, lpSrcRect->right);
|
||||||
|
y0 = max(y0, lpSrcRect->top);
|
||||||
|
y1 = min(y1, lpSrcRect->bottom);
|
||||||
|
}
|
||||||
|
unsigned char* to = (unsigned char *)This->surface + dy*This->width + dx;
|
||||||
|
unsigned char* from = (unsigned char *)Source->surface + y0*Source->width + x0;
|
||||||
|
int s = x1-x0;
|
||||||
|
|
||||||
|
int y;
|
||||||
|
for(y=y0; y<y1; ++y, to+=This->width, from+=Source->width)
|
||||||
|
{
|
||||||
|
memcpy(to, from, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int y;
|
|
||||||
for(y=y0; y<y1; ++y, to+=This->width, from+=Source->width)
|
|
||||||
{
|
|
||||||
memcpy(to, from, s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(This->caps & DDSCAPS_PRIMARYSURFACE && !(This->flags & DDSD_BACKBUFFERCOUNT) && ddraw->render.run)
|
if(This->caps & DDSCAPS_PRIMARYSURFACE && !(This->flags & DDSD_BACKBUFFERCOUNT) && ddraw->render.run)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user