From 61c82f8069a34426646f304c2c9dc616c912b06e Mon Sep 17 00:00:00 2001 From: Roderick Colenbrander Date: Mon, 18 Feb 2008 21:10:18 +0100 Subject: [PATCH] wined3d: Add a GDI version of RealizePalette. The base version won't suffice anymore as it is not able to upload palette changes to the drawable in an efficient way for both GDI and GL. Further the LoadLocation code in RealizePalette isn't needed for the GDI version as in all cases it works on system memory. --- dlls/wined3d/surface_gdi.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c index 30c922a7bc3..c0f54bc4dd2 100644 --- a/dlls/wined3d/surface_gdi.c +++ b/dlls/wined3d/surface_gdi.c @@ -631,6 +631,41 @@ HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) { return WINED3D_OK; } +HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) { + IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; + RGBQUAD col[256]; + IWineD3DPaletteImpl *pal = This->palette; + unsigned int n; + TRACE("(%p)\n", This); + + 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); + } + + /* Update the image because of the palette change. Some games like e.g Red Alert + * call SetEntries a lot to implement fading. + */ + if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) + x11_copy_to_screen(This, NULL); + + return WINED3D_OK; +} + /***************************************************************************** * IWineD3DSurface::PrivateSetup, GDI version * @@ -808,7 +843,7 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl = IWineD3DBaseSurfaceImpl_BltFast, IWineD3DBaseSurfaceImpl_GetPalette, IWineD3DBaseSurfaceImpl_SetPalette, - IWineD3DBaseSurfaceImpl_RealizePalette, + IWineGDISurfaceImpl_RealizePalette, IWineD3DBaseSurfaceImpl_SetColorKey, IWineD3DBaseSurfaceImpl_GetPitch, IWineGDISurfaceImpl_SetMem,