[PATCH] 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.

Roderick Colenbrander thunderbird2k at gmx.net
Mon Feb 18 14:10:18 CST 2008


---
 dlls/wined3d/surface_gdi.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index 30c922a..c0f54bc 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,
-- 
1.5.3.4


--========GMX202761203367803441806--



More information about the wine-patches mailing list