Improving DIB support for SHM

Gavriel State gav at transgaming.com
Wed Nov 21 11:51:28 CST 2001


Doh!  I guess we've been too lax about integrating some of our non D3D 
work back into WineHQ.  We did this in WineX some time ago, but with 
a couple of differences:
 1) We don't restrict using XShmGetImage to the whole-screen case
and
 2) We save and restore the XImage mask fields around the call to 
    XShmGetImage, which seems to like to write over those fields
    to no useful purpose.

IE:
        /* We must save and restore the bmpImage's masks in order
         * to preserve them across the call to XShmGetImage, which
         * decides to eliminate them since it doesn't happen to know
         * what the format of the image is supposed to be, even though
         * we do. */
        saveRed = bmpImage->red_mask;
        saveBlue= bmpImage->blue_mask;
        saveGreen = bmpImage->green_mask;

        XShmGetImage( gdi_display, descr->drawable, bmpImage,
                      descr->xSrc, descr->ySrc, AllPlanes);

        bmpImage->red_mask = saveRed;
        bmpImage->blue_mask = saveBlue;
        bmpImage->green_mask = saveGreen;

We'll probably get around to doing some merging back into WineHQ after
our next release.

 -Gav


Jukka Heinonen wrote:
> 
> 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/>

-- 
Gavriel State, CEO
TransGaming Technologies Inc.
http://www.transgaming.com
gav at transgaming.com




More information about the wine-devel mailing list