dibsection blit patch

Ove Kaaven ovehk at ping.uio.no
Fri Feb 2 19:11:25 CST 2001


This patch should fix most regressions that the DIBsection BitBlt
optimization have caused. It's a hack, I'm not happy with this solution,
but it's necessary since x11drv's DIBsection implementation have to do
depth conversion, where Windows don't (even a blit between two 8bpp DIBs
needs depth conversion under Wine, and hence some colormap/palette, which
isn't required for the same blit under Windows), and it shouldn't break
anything. Now e.g. the Starcraft Installer displays stuff again, and I
assume that WinG (used by Civilization II) colors should work again, too.

Log:
Ove Kaaven <ovek at transgaming.com>
In CopyDIBSection, use source DIB colormap instead if no palette has been
selected into the source DC, to work around some X11-imposed DIBsection
implementation deficiencies.

Index: graphics/x11drv/dib.c
===================================================================
RCS file: /home/cvs/wine/graphics/x11drv/dib.c,v
retrieving revision 1.1.1.11
diff -u -r1.1.1.11 dib.c
--- graphics/x11drv/dib.c	2001/01/29 17:22:06	1.1.1.11
+++ graphics/x11drv/dib.c	2001/02/03 01:37:24
@@ -3245,7 +3245,7 @@
 {
   BITMAPOBJ *bmp;
   X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dcDst->physDev;
-  int nColorMap = 0, *colorMap = NULL;
+  int nColorMap = 0, *colorMap = NULL, aColorMap = FALSE;
 
   TRACE("(%p,%p,%ld,%ld,%ld,%ld,%ld,%ld)\n", dcSrc, dcDst,
     xSrc, ySrc, xDest, yDest, width, height);
@@ -3272,17 +3272,30 @@
       height = bmp->bitmap.bmHeight - ySrc;
     /* if the source bitmap is 8bpp or less, we're supposed to use the
      * DC's palette for color conversion (not the DIB color table) */
-    if (bmp->dib->dsBm.bmBitsPixel <= 8)
-      colorMap = X11DRV_DIB_BuildColorMap( dcSrc, (WORD)-1,
-					   bmp->dib->dsBm.bmBitsPixel,
-					   (BITMAPINFO*)&(bmp->dib->dsBmih),
-					   &nColorMap );
+    if (bmp->dib->dsBm.bmBitsPixel <= 8) {
+      X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
+      if ((!dcSrc->hPalette) ||
+	  (dcSrc->hPalette == GetStockObject(DEFAULT_PALETTE))) {
+	/* HACK: no palette has been set in the source DC,
+	 * use the DIB colormap instead - this is necessary in some
+	 * cases since we need to do depth conversion in some places
+	 * where real Windows can just copy data straight over */
+	colorMap = dib->colorMap;
+	nColorMap = dib->nColorMap;
+      } else {
+	colorMap = X11DRV_DIB_BuildColorMap( dcSrc, (WORD)-1,
+					     bmp->dib->dsBm.bmBitsPixel,
+					     (BITMAPINFO*)&(bmp->dib->dsBmih),
+					     &nColorMap );
+	if (colorMap) aColorMap = TRUE;
+      }
+    }
     /* perform the copy */
     X11DRV_DIB_DoCopyDIBSection(bmp, FALSE, colorMap, nColorMap,
 				physDev->drawable, xSrc, ySrc, xDest, yDest,
 				width, height);
     /* free color mapping */
-    if (colorMap)
+    if (aColorMap)
       HeapFree(GetProcessHeap(), 0, colorMap);
   }
   GDI_ReleaseObj( dcSrc->hBitmap );




More information about the wine-patches mailing list