Alexander Dorofeyev : wined3d: Don't use device palettes in RealizePalette.

Alexandre Julliard julliard at winehq.org
Tue Mar 25 06:58:22 CDT 2008


Module: wine
Branch: master
Commit: 9b913b3b79ae59a842b91a859fdea0e6b467b905
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9b913b3b79ae59a842b91a859fdea0e6b467b905

Author: Alexander Dorofeyev <alexd4 at inbox.lv>
Date:   Tue Mar 25 02:03:59 2008 +0200

wined3d: Don't use device palettes in RealizePalette.

---

 dlls/wined3d/surface.c     |   21 +++++++--------------
 dlls/wined3d/surface_gdi.c |   24 ++++++++----------------
 2 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 2f9dc66..8ed1513 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3574,6 +3574,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
     unsigned int n;
     TRACE("(%p)\n", This);
 
+    if (!pal) return WINED3D_OK;
+
     if(This->resource.format == WINED3DFMT_P8 ||
        This->resource.format == WINED3DFMT_A8P8)
     {
@@ -3588,26 +3590,17 @@ HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
     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].rgbRed   = pal->palents[n].peRed;
+            col[n].rgbGreen = pal->palents[n].peGreen;
+            col[n].rgbBlue  = pal->palents[n].peBlue;
             col[n].rgbReserved = 0;
         }
         SetDIBColorTable(This->hDC, 0, 256, col);
     }
 
-    /* Propagate the changes to the drawable when we have a palette. This function is also called
-     * when the palette is removed.
+    /* Propagate the changes to the drawable when we have a palette.
      * TODO: in case of hardware p8 palettes we should only upload the palette. */
-    if(pal && (This->resource.usage & WINED3DUSAGE_RENDERTARGET))
+    if(This->resource.usage & WINED3DUSAGE_RENDERTARGET)
         IWineD3DSurface_LoadLocation(iface, SFLAG_INDRAWABLE, NULL);
 
     return WINED3D_OK;
diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index fcbecd3..1da1a6a 100644
--- a/dlls/wined3d/surface_gdi.c
+++ b/dlls/wined3d/surface_gdi.c
@@ -635,30 +635,22 @@ HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
     unsigned int n;
     TRACE("(%p)\n", This);
 
+    if (!pal) return WINED3D_OK;
+
     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].rgbRed   = pal->palents[n].peRed;
+            col[n].rgbGreen = pal->palents[n].peGreen;
+            col[n].rgbBlue  = pal->palents[n].peBlue;
             col[n].rgbReserved = 0;
         }
         SetDIBColorTable(This->hDC, 0, 256, col);
     }
 
-    /* Update the image because of the palette change. Note that this function is also
-     * called on a palette removal. In such a case we don't have to update the screen.
-     * Some games like e.g Red Alert call SetEntries a lot to implement fading.
-     */
-    if(pal && This->resource.usage & WINED3DUSAGE_RENDERTARGET)
+    /* 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;




More information about the wine-cvs mailing list