Improving DIB support for SHM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following patch halves the time it takes to move units
from one square to another in Civilization 2. If SHM is supported,
the patch uses XShmGetImage instead of XGetSubImage when filling
the whole XImage (which is probably way too careful since SHM is
much faster than the alternative...). Hopefully this
version is paranoid enough to work with older XFree86 servers
where XShmGetImage might change the underlying XImage format
into XYPixmap.

Changelog:
  Try to use XShmGetImage instead of XGetSubImage if SHM is supported.
  Do a sanity check before using XShmPutImage.

Index: wine/graphics/x11drv/dib.c
===================================================================
RCS file: /home/wine/wine/graphics/x11drv/dib.c,v
retrieving revision 1.82
diff -u -r1.82 dib.c
--- wine/graphics/x11drv/dib.c  2001/11/05 23:52:18     1.82
+++ wine/graphics/x11drv/dib.c  2001/11/21 12:39:42
@@ -4473,7 +4473,7 @@
      descr->xSrc, descr->ySrc, descr->xDest, descr->yDest,
      descr->width, descr->height);
 #ifdef HAVE_LIBXXSHM
-    if (descr->useShm)
+    if (descr->useShm && descr->image)
     {
         XShmPutImage( gdi_display, descr->drawable, descr->gc, bmpImage,
                       descr->xSrc, descr->ySrc, descr->xDest, descr->yDest,
@@ -4519,9 +4519,26 @@
     TRACE("XGetSubImage(%ld,%d,%d,%d,%d,%ld,%d,%p,%d,%d)\n",
      descr->drawable, descr->xSrc, descr->ySrc, descr->width,
      lines, AllPlanes, ZPixmap, bmpImage, descr->xDest, descr->yDest);
-    XGetSubImage( gdi_display, descr->drawable, descr->xSrc, descr->ySrc,
-                  descr->width, lines, AllPlanes, ZPixmap,
-                  bmpImage, descr->xDest, descr->yDest );
+
+#ifdef HAVE_LIBXXSHM
+    if (descr->useShm && descr->image &&
+        descr->xDest == 0 && descr->yDest == 0 && 
+        descr->width == bmpImage->width && 
+        lines == bmpImage->height &&
+        XShmPixmapFormat( gdi_display ) == ZPixmap)
+    {
+        XShmGetImage( gdi_display, descr->drawable, bmpImage, 
+                      descr->xSrc, descr->ySrc, AllPlanes );
+        if (bmpImage->format != ZPixmap)
+            ERR( "XShmGetImage changed image format!\n" );
+    }
+    else
+#endif
+    {
+        XGetSubImage( gdi_display, descr->drawable, descr->xSrc, descr->ySrc,
+                      descr->width, lines, AllPlanes, ZPixmap,
+                      bmpImage, descr->xDest, descr->yDest );
+    }
 
     TRACE("Dib: depth=%2d r=%lx g=%lx b=%lx\n",
           descr->infoBpp,descr->rMask,descr->gMask,descr->bMask);


-- 
Jukka Heinonen <http://www.iki.fi/jhei/>



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux