Authors: Lionel Ulmer <ulmer@directprovider.net>, Babrian Viktor <v@ulysses.sch.bme.hu>
- added support for ColorKeying during blits - miscellaneous fixes
This commit is contained in:
parent
6479f0fab2
commit
1c24d79b18
|
@ -53,7 +53,7 @@ static void activate(LPDIRECT3DMATERIAL2 this) {
|
||||||
TRACE(ddraw, "Size : %ld\n", this->mat.dwSize);
|
TRACE(ddraw, "Size : %ld\n", this->mat.dwSize);
|
||||||
TRACE(ddraw, "Power : %f\n", this->mat.e.power);
|
TRACE(ddraw, "Power : %f\n", this->mat.e.power);
|
||||||
|
|
||||||
TRACE(ddraw, "Texture handle : %ld\n", (DWORD)this->mat.hTexture);
|
TRACE(ddraw, "Texture handle : %08lx\n", (DWORD)this->mat.hTexture);
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -693,6 +693,7 @@ static HRESULT WINAPI IDirectDrawSurface3_Blt(
|
||||||
|
|
||||||
dwFlags &= ~(DDBLT_WAIT|DDBLT_ASYNC);/* FIXME: can't handle right now */
|
dwFlags &= ~(DDBLT_WAIT|DDBLT_ASYNC);/* FIXME: can't handle right now */
|
||||||
|
|
||||||
|
/* First, all the 'source-less' blits */
|
||||||
if (dwFlags & DDBLT_COLORFILL) {
|
if (dwFlags & DDBLT_COLORFILL) {
|
||||||
int bpp = ddesc.ddpfPixelFormat.x.dwRGBBitCount / 8;
|
int bpp = ddesc.ddpfPixelFormat.x.dwRGBBitCount / 8;
|
||||||
LPBYTE xline,xpixel;
|
LPBYTE xline,xpixel;
|
||||||
|
@ -738,6 +739,9 @@ static HRESULT WINAPI IDirectDrawSurface3_Blt(
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now the 'with source' blits */
|
||||||
|
|
||||||
|
/* Standard 'full-surface' blit without special effects */
|
||||||
if ( (xsrc.top ==0) && (xsrc.bottom ==ddesc.dwHeight) &&
|
if ( (xsrc.top ==0) && (xsrc.bottom ==ddesc.dwHeight) &&
|
||||||
(xsrc.left==0) && (xsrc.right ==ddesc.dwWidth) &&
|
(xsrc.left==0) && (xsrc.right ==ddesc.dwWidth) &&
|
||||||
(xdst.top ==0) && (xdst.bottom ==ddesc.dwHeight) &&
|
(xdst.top ==0) && (xdst.bottom ==ddesc.dwHeight) &&
|
||||||
|
@ -768,6 +772,25 @@ static HRESULT WINAPI IDirectDrawSurface3_Blt(
|
||||||
/* This is a basic stretch implementation. It is painfully slow and quite ugly. */
|
/* This is a basic stretch implementation. It is painfully slow and quite ugly. */
|
||||||
if (bpp == 1) {
|
if (bpp == 1) {
|
||||||
/* In this case, we cannot do any anti-aliasing */
|
/* In this case, we cannot do any anti-aliasing */
|
||||||
|
if(dwFlags & DDBLT_KEYSRC) {
|
||||||
|
for (y = xdst.top; y < xdst.bottom; y++) {
|
||||||
|
for (x = xdst.left; x < xdst.right; x++) {
|
||||||
|
double sx, sy;
|
||||||
|
unsigned char tmp;
|
||||||
|
unsigned char *dbuf = (unsigned char *) ddesc.y.lpSurface;
|
||||||
|
unsigned char *sbuf = (unsigned char *) sdesc.y.lpSurface;
|
||||||
|
|
||||||
|
sx = (((double) (x - xdst.left) / dstwidth) * srcwidth) + xsrc.left;
|
||||||
|
sy = (((double) (y - xdst.top) / dstheight) * srcheight) + xsrc.top;
|
||||||
|
|
||||||
|
tmp = sbuf[(((int) sy) * sdesc.lPitch) + ((int) sx)];
|
||||||
|
|
||||||
|
if ((tmp < src->s.surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
||||||
|
(tmp > src->s.surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue))
|
||||||
|
dbuf[(y * ddesc.lPitch) + x] = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (y = xdst.top; y < xdst.bottom; y++) {
|
for (y = xdst.top; y < xdst.bottom; y++) {
|
||||||
for (x = xdst.left; x < xdst.right; x++) {
|
for (x = xdst.left; x < xdst.right; x++) {
|
||||||
double sx, sy;
|
double sx, sy;
|
||||||
|
@ -780,18 +803,65 @@ static HRESULT WINAPI IDirectDrawSurface3_Blt(
|
||||||
dbuf[(y * ddesc.lPitch) + x] = sbuf[(((int) sy) * sdesc.lPitch) + ((int) sx)];
|
dbuf[(y * ddesc.lPitch) + x] = sbuf[(((int) sy) * sdesc.lPitch) + ((int) sx)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FIXME(ddraw, "Not done yet for depth != 8\n");
|
FIXME(ddraw, "Not done yet for depth != 8\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Same size => fast blit */
|
/* Same size => fast blit */
|
||||||
|
if (dwFlags & DDBLT_KEYSRC) {
|
||||||
|
switch (bpp) {
|
||||||
|
case 1: {
|
||||||
|
unsigned char tmp,*psrc,*pdst;
|
||||||
|
int h,i;
|
||||||
|
|
||||||
for (h = 0; h < srcheight; h++) {
|
for (h = 0; h < srcheight; h++) {
|
||||||
|
psrc=sdesc.y.lpSurface +
|
||||||
|
((h + xsrc.top) * sdesc.lPitch) + xsrc.left;
|
||||||
|
pdst=ddesc.y.lpSurface +
|
||||||
|
((h + xdst.top) * ddesc.lPitch) + xdst.left;
|
||||||
|
for(i=0;i<srcwidth;i++) {
|
||||||
|
tmp=*(psrc + i);
|
||||||
|
if ((tmp < src->s.surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
||||||
|
(tmp > src->s.surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue))
|
||||||
|
*(pdst + i)=tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dwFlags&=~(DDBLT_KEYSRC);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case 2: {
|
||||||
|
unsigned short tmp,*psrc,*pdst;
|
||||||
|
int h,i;
|
||||||
|
|
||||||
|
for (h = 0; h < srcheight; h++) {
|
||||||
|
psrc=sdesc.y.lpSurface +
|
||||||
|
((h + xsrc.top) * sdesc.lPitch) + xsrc.left;
|
||||||
|
pdst=ddesc.y.lpSurface +
|
||||||
|
((h + xdst.top) * ddesc.lPitch) + xdst.left;
|
||||||
|
for(i=0;i<srcwidth;i++) {
|
||||||
|
tmp=*(psrc + i);
|
||||||
|
if ((tmp < src->s.surface_desc.ddckCKSrcBlt.dwColorSpaceLowValue) ||
|
||||||
|
(tmp > src->s.surface_desc.ddckCKSrcBlt.dwColorSpaceHighValue))
|
||||||
|
*(pdst + i)=tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dwFlags&=~(DDBLT_KEYSRC);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
FIXME(ddraw, "Bitblt, KEYSRC: Not done yet for depth > 16\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Non-stretching Blt without color keying */
|
||||||
|
for (h = 0; h < srcheight; h++) {
|
||||||
memcpy(ddesc.y.lpSurface + ((h + xdst.top) * ddesc.lPitch) + xdst.left * bpp,
|
memcpy(ddesc.y.lpSurface + ((h + xdst.top) * ddesc.lPitch) + xdst.left * bpp,
|
||||||
sdesc.y.lpSurface + ((h + xsrc.top) * sdesc.lPitch) + xsrc.left * bpp,
|
sdesc.y.lpSurface + ((h + xsrc.top) * sdesc.lPitch) + xsrc.left * bpp,
|
||||||
width);
|
width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (dwFlags && FIXME_ON(ddraw)) {
|
if (dwFlags && FIXME_ON(ddraw)) {
|
||||||
FIXME(ddraw,"\tUnsupported flags: ");_dump_DDBLT(dwFlags);
|
FIXME(ddraw,"\tUnsupported flags: ");_dump_DDBLT(dwFlags);
|
||||||
|
@ -1088,7 +1158,7 @@ static HRESULT WINAPI IDirectDrawSurface3_QueryInterface(LPDIRECTDRAWSURFACE3 th
|
||||||
*obj = this;
|
*obj = this;
|
||||||
this->lpvtbl->fnAddRef(this);
|
this->lpvtbl->fnAddRef(this);
|
||||||
|
|
||||||
TRACE(ddraw, " Creating IDirect3DSurfaceX interface (%p)\n", *obj);
|
TRACE(ddraw, " Creating IDirectDrawSurface interface (%p)\n", *obj);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1767,7 +1837,7 @@ static HRESULT WINAPI IDirect3D_QueryInterface(
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
if (!memcmp(&IID_IDirect3D2,refiid,sizeof(IID_IDirect3D))) {
|
if (!memcmp(&IID_IDirect3D2,refiid,sizeof(IID_IDirect3D2))) {
|
||||||
LPDIRECT3D2 d3d;
|
LPDIRECT3D2 d3d;
|
||||||
|
|
||||||
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
|
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
|
||||||
|
@ -2616,7 +2686,7 @@ static void fill_caps(LPDDCAPS caps) {
|
||||||
DDCAPS_CANBLTSYSMEM | DDCAPS_COLORKEY | DDCAPS_PALETTE | DDCAPS_ZBLTS;
|
DDCAPS_CANBLTSYSMEM | DDCAPS_COLORKEY | DDCAPS_PALETTE | DDCAPS_ZBLTS;
|
||||||
caps->dwCaps2 = DDCAPS2_CERTIFIED | DDCAPS2_NO2DDURING3DSCENE | DDCAPS2_NOPAGELOCKREQUIRED |
|
caps->dwCaps2 = DDCAPS2_CERTIFIED | DDCAPS2_NO2DDURING3DSCENE | DDCAPS2_NOPAGELOCKREQUIRED |
|
||||||
DDCAPS2_WIDESURFACES;
|
DDCAPS2_WIDESURFACES;
|
||||||
caps->dwCKeyCaps = 0xFFFFFFFF;
|
caps->dwCKeyCaps = 0xFFFFFFFF; /* Should put real caps here one day... */
|
||||||
caps->dwFXCaps = 0;
|
caps->dwFXCaps = 0;
|
||||||
caps->dwFXAlphaCaps = 0;
|
caps->dwFXAlphaCaps = 0;
|
||||||
caps->dwPalCaps = DDPCAPS_8BIT | DDPCAPS_ALLOW256;
|
caps->dwPalCaps = DDPCAPS_8BIT | DDPCAPS_ALLOW256;
|
||||||
|
@ -2892,7 +2962,7 @@ static HRESULT WINAPI DGA_IDirectDraw2_QueryInterface(
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
if (!memcmp(&IID_IDirect3D2,refiid,sizeof(IID_IDirect3D))) {
|
if (!memcmp(&IID_IDirect3D2,refiid,sizeof(IID_IDirect3D2))) {
|
||||||
LPDIRECT3D2 d3d;
|
LPDIRECT3D2 d3d;
|
||||||
|
|
||||||
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
|
d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
|
||||||
|
|
Loading…
Reference in New Issue