wined3d: Don't use device palettes in GetDC.

This commit is contained in:
Alexander Dorofeyev 2008-03-25 02:03:55 +02:00 committed by Alexandre Julliard
parent 85fd313046
commit 13ce219235
2 changed files with 34 additions and 30 deletions

View File

@ -1359,6 +1359,14 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
if (This->Flags & SFLAG_LOCKED)
return WINED3DERR_INVALIDCALL;
/* According to Direct3D9 docs, only these formats are supported */
if (((IWineD3DImpl *)This->resource.wineD3DDevice->wineD3D)->dxVersion > 7) {
if (This->resource.format != WINED3DFMT_R5G6B5 &&
This->resource.format != WINED3DFMT_X1R5G5B5 &&
This->resource.format != WINED3DFMT_R8G8B8 &&
This->resource.format != WINED3DFMT_X8R8G8B8) return WINED3DERR_INVALIDCALL;
}
memset(&lock, 0, sizeof(lock)); /* To be sure */
/* Create a DIB section if there isn't a hdc yet */
@ -1392,29 +1400,28 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
if(This->resource.format == WINED3DFMT_P8 ||
This->resource.format == WINED3DFMT_A8P8) {
/* GetDC on palettized formats is unsupported in D3D9, and the method is missing in
D3D8, so this should only be used for DX <=7 surfaces (with non-device palettes) */
unsigned int n;
PALETTEENTRY *pal = NULL;
if(This->palette) {
PALETTEENTRY ent[256];
GetPaletteEntries(This->palette->hpal, 0, 256, ent);
for (n=0; n<256; n++) {
col[n].rgbRed = ent[n].peRed;
col[n].rgbGreen = ent[n].peGreen;
col[n].rgbBlue = ent[n].peBlue;
col[n].rgbReserved = 0;
}
pal = This->palette->palents;
} else {
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
IWineD3DSurfaceImpl *dds_primary = (IWineD3DSurfaceImpl *)This->resource.wineD3DDevice->ddraw_primary;
if (dds_primary && dds_primary->palette)
pal = dds_primary->palette->palents;
}
if (pal) {
for (n=0; n<256; n++) {
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].rgbRed = pal[n].peRed;
col[n].rgbGreen = pal[n].peGreen;
col[n].rgbBlue = pal[n].peBlue;
col[n].rgbReserved = 0;
}
SetDIBColorTable(This->hDC, 0, 256, col);
}
SetDIBColorTable(This->hDC, 0, 256, col);
}
*pHDC = This->hDC;

View File

@ -579,28 +579,25 @@ HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
if(This->resource.format == WINED3DFMT_P8 ||
This->resource.format == WINED3DFMT_A8P8) {
unsigned int n;
PALETTEENTRY *pal = NULL;
if(This->palette) {
PALETTEENTRY ent[256];
GetPaletteEntries(This->palette->hpal, 0, 256, ent);
for (n=0; n<256; n++) {
col[n].rgbRed = ent[n].peRed;
col[n].rgbGreen = ent[n].peGreen;
col[n].rgbBlue = ent[n].peBlue;
col[n].rgbReserved = 0;
}
pal = This->palette->palents;
} else {
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
IWineD3DSurfaceImpl *dds_primary = (IWineD3DSurfaceImpl *)This->resource.wineD3DDevice->ddraw_primary;
if (dds_primary && dds_primary->palette)
pal = dds_primary->palette->palents;
}
if (pal) {
for (n=0; n<256; n++) {
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].rgbRed = pal[n].peRed;
col[n].rgbGreen = pal[n].peGreen;
col[n].rgbBlue = pal[n].peBlue;
col[n].rgbReserved = 0;
}
SetDIBColorTable(This->hDC, 0, 256, col);
}
SetDIBColorTable(This->hDC, 0, 256, col);
}
*pHDC = This->hDC;