Commit e2944175 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Base surface move, part 2.

parent d99143c2
......@@ -189,3 +189,250 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface) {
This->Flags &= ~SFLAG_LOST;
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DPaletteImpl *PalImpl = (IWineD3DPaletteImpl *) Pal;
TRACE("(%p)->(%p)\n", This, Pal);
if(This->palette != NULL)
if(This->resource.usage & WINED3DUSAGE_RENDERTARGET)
This->palette->Flags &= ~WINEDDPCAPS_PRIMARYSURFACE;
if(PalImpl != NULL) {
if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
/* Set the device's main palette if the palette
* wasn't a primary palette before
*/
if(!(PalImpl->Flags & WINEDDPCAPS_PRIMARYSURFACE)) {
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
unsigned int i;
for(i=0; i < 256; i++) {
device->palettes[device->currentPalette][i] = PalImpl->palents[i];
}
}
(PalImpl)->Flags |= WINEDDPCAPS_PRIMARYSURFACE;
}
}
This->palette = PalImpl;
return IWineD3DSurface_RealizePalette(iface);
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, WINEDDCOLORKEY *CKey) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
if ((Flags & WINEDDCKEY_COLORSPACE) != 0) {
FIXME(" colorkey value not supported (%08x) !\n", Flags);
return WINED3DERR_INVALIDCALL;
}
/* Dirtify the surface, but only if a key was changed */
if(CKey) {
switch (Flags & ~WINEDDCKEY_COLORSPACE) {
case WINEDDCKEY_DESTBLT:
This->DestBltCKey = *CKey;
This->CKeyFlags |= WINEDDSD_CKDESTBLT;
break;
case WINEDDCKEY_DESTOVERLAY:
This->DestOverlayCKey = *CKey;
This->CKeyFlags |= WINEDDSD_CKDESTOVERLAY;
break;
case WINEDDCKEY_SRCOVERLAY:
This->SrcOverlayCKey = *CKey;
This->CKeyFlags |= WINEDDSD_CKSRCOVERLAY;
break;
case WINEDDCKEY_SRCBLT:
This->SrcBltCKey = *CKey;
This->CKeyFlags |= WINEDDSD_CKSRCBLT;
break;
}
}
else {
switch (Flags & ~WINEDDCKEY_COLORSPACE) {
case WINEDDCKEY_DESTBLT:
This->CKeyFlags &= ~WINEDDSD_CKDESTBLT;
break;
case WINEDDCKEY_DESTOVERLAY:
This->CKeyFlags &= ~WINEDDSD_CKDESTOVERLAY;
break;
case WINEDDCKEY_SRCOVERLAY:
This->CKeyFlags &= ~WINEDDSD_CKSRCOVERLAY;
break;
case WINEDDCKEY_SRCBLT:
This->CKeyFlags &= ~WINEDDSD_CKSRCBLT;
break;
}
}
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
TRACE("(%p)->(%p)\n", This, Pal);
*Pal = (IWineD3DPalette *) This->palette;
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
RGBQUAD col[256];
IWineD3DPaletteImpl *pal = This->palette;
unsigned int n;
TRACE("(%p)\n", This);
if(This->resource.format == WINED3DFMT_P8 ||
This->resource.format == WINED3DFMT_A8P8)
{
if(!This->Flags & SFLAG_INSYSMEM) {
FIXME("Palette changed with surface that does not have an up to date system memory copy\n");
}
TRACE("Dirtifying surface\n");
This->Flags &= ~(SFLAG_INTEXTURE | SFLAG_INDRAWABLE);
}
if(This->Flags & SFLAG_DIBSECTION) {
TRACE("(%p): Updating the hdc's palette\n", This);
for (n=0; n<256; n++) {
if(pal) {
col[n].rgbRed = pal->palents[n].peRed;
col[n].rgbGreen = pal->palents[n].peGreen;
col[n].rgbBlue = pal->palents[n].peBlue;
} else {
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
/* Use the default device palette */
col[n].rgbRed = device->palettes[device->currentPalette][n].peRed;
col[n].rgbGreen = device->palettes[device->currentPalette][n].peGreen;
col[n].rgbBlue = device->palettes[device->currentPalette][n].peBlue;
}
col[n].rgbReserved = 0;
}
SetDIBColorTable(This->hDC, 0, 256, col);
}
return WINED3D_OK;
}
DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
DWORD ret;
TRACE("(%p)\n", This);
/* DXTn formats don't have exact pitches as they are to the new row of blocks,
where each block is 4x4 pixels, 8 bytes (dxt1) and 16 bytes (dxt2/3/4/5)
ie pitch = (width/4) * bytes per block */
if (This->resource.format == WINED3DFMT_DXT1) /* DXT1 is 8 bytes per block */
ret = ((This->currentDesc.Width + 3) >> 2) << 3;
else if (This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5) /* DXT2/3/4/5 is 16 bytes per block */
ret = ((This->currentDesc.Width + 3) >> 2) << 4;
else {
unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
ret = This->bytesPerPixel * This->currentDesc.Width; /* Bytes / row */
ret = (ret + alignment - 1) & ~(alignment - 1);
}
TRACE("(%p) Returning %d\n", This, ret);
return ret;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
FIXME("(%p)->(%d,%d) Stub!\n", This, X, Y);
if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
{
TRACE("(%p): Not an overlay surface\n", This);
return WINEDDERR_NOTAOVERLAYSURFACE;
}
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
FIXME("(%p)->(%p,%p) Stub!\n", This, X, Y);
if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
{
TRACE("(%p): Not an overlay surface\n", This);
return WINEDDERR_NOTAOVERLAYSURFACE;
}
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *RefImpl = (IWineD3DSurfaceImpl *) Ref;
FIXME("(%p)->(%08x,%p) Stub!\n", This, Flags, RefImpl);
if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
{
TRACE("(%p): Not an overlay surface\n", This);
return WINEDDERR_NOTAOVERLAYSURFACE;
}
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *Dst = (IWineD3DSurfaceImpl *) DstSurface;
FIXME("(%p)->(%p, %p, %p, %08x, %p)\n", This, SrcRect, Dst, DstRect, Flags, FX);
if(!(This->resource.usage & WINED3DUSAGE_OVERLAY))
{
TRACE("(%p): Not an overlay surface\n", This);
return WINEDDERR_NOTAOVERLAYSURFACE;
}
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
TRACE("(%p)->(%p)\n", This, clipper);
This->clipper = clipper;
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
TRACE("(%p)->(%p)\n", This, clipper);
*clipper = This->clipper;
if(*clipper) {
IWineD3DClipper_AddRef(*clipper);
}
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("This %p, container %p\n", This, container);
/* We can't keep a reference to the container, since the container already keeps a reference to us. */
TRACE("Setting container to %p from %p\n", container, This->container);
This->container = container;
return WINED3D_OK;
}
......@@ -1550,6 +1550,9 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
return WINED3D_OK;
}
/* FIXME: This vtable should not use any IWineD3DSurface* implementation functions,
* only IWineD3DBaseSurface and IWineGDISurface ones.
*/
const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
{
/* IUnknown */
......@@ -1580,23 +1583,23 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
IWineD3DBaseSurfaceImpl_IsLost,
IWineD3DBaseSurfaceImpl_Restore,
IWineGDISurfaceImpl_BltFast,
IWineD3DSurfaceImpl_GetPalette,
IWineD3DSurfaceImpl_SetPalette,
IWineD3DSurfaceImpl_RealizePalette,
IWineD3DSurfaceImpl_SetColorKey,
IWineD3DSurfaceImpl_GetPitch,
IWineD3DBaseSurfaceImpl_GetPalette,
IWineD3DBaseSurfaceImpl_SetPalette,
IWineD3DBaseSurfaceImpl_RealizePalette,
IWineD3DBaseSurfaceImpl_SetColorKey,
IWineD3DBaseSurfaceImpl_GetPitch,
IWineD3DSurfaceImpl_SetMem,
IWineD3DSurfaceImpl_SetOverlayPosition,
IWineD3DSurfaceImpl_GetOverlayPosition,
IWineD3DSurfaceImpl_UpdateOverlayZOrder,
IWineD3DSurfaceImpl_UpdateOverlay,
IWineD3DSurfaceImpl_SetClipper,
IWineD3DSurfaceImpl_GetClipper,
IWineD3DBaseSurfaceImpl_SetOverlayPosition,
IWineD3DBaseSurfaceImpl_GetOverlayPosition,
IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder,
IWineD3DBaseSurfaceImpl_UpdateOverlay,
IWineD3DBaseSurfaceImpl_SetClipper,
IWineD3DBaseSurfaceImpl_GetClipper,
/* Internal use: */
IWineD3DSurfaceImpl_AddDirtyRect,
IWineGDISurfaceImpl_LoadTexture,
IWineGDISurfaceImpl_SaveSnapshot,
IWineD3DSurfaceImpl_SetContainer,
IWineD3DBaseSurfaceImpl_SetContainer,
IWineD3DSurfaceImpl_SetGlTextureDesc,
IWineD3DSurfaceImpl_GetGlDesc,
IWineD3DSurfaceImpl_GetData,
......
......@@ -1159,12 +1159,12 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWO
HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DSurfaceImpl_SetPixelFormat(IWineD3DSurface *iface, WINED3DFORMAT Format, BYTE *Surface, DWORD Size);
HRESULT WINAPI IWineD3DSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal);
HRESULT WINAPI IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
HRESULT WINAPI IWineD3DSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, WINEDDCOLORKEY *CKey);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, WINEDDCOLORKEY *CKey);
HRESULT WINAPI IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface *iface);
extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect);
HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container);
void WINAPI IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface *iface, UINT textureName, int target);
void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription);
const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface);
......@@ -1174,15 +1174,15 @@ HRESULT WINAPI IWineGDISurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, D
HRESULT WINAPI IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC);
HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC);
DWORD WINAPI IWineD3DSurfaceImpl_GetPitch(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface);
DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_RealizePalette(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem);
HRESULT WINAPI IWineD3DSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y);
HRESULT WINAPI IWineD3DSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y);
HRESULT WINAPI IWineD3DSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref);
HRESULT WINAPI IWineD3DSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX);
HRESULT WINAPI IWineD3DSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper);
HRESULT WINAPI IWineD3DSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper);
/* Surface flags: */
#define SFLAG_OVERSIZE 0x00000001 /* Surface is bigger than gl size, blts only */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment