Commit 165b21dd authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winex11.drv: Fix SetDIBits optimization to work with top-down dib sections.

parent 38901f08
...@@ -3922,7 +3922,7 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan, ...@@ -3922,7 +3922,7 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
{ {
X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap ); X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
X11DRV_DIB_IMAGEBITS_DESCR descr; X11DRV_DIB_IMAGEBITS_DESCR descr;
BITMAP bitmap; DIBSECTION ds;
LONG width, height, tmpheight; LONG width, height, tmpheight;
INT result; INT result;
...@@ -3939,7 +3939,7 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan, ...@@ -3939,7 +3939,7 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
if (!lines || (startscan >= height)) if (!lines || (startscan >= height))
return 0; return 0;
if (!GetObjectW( hbitmap, sizeof(bitmap), &bitmap )) return 0; if (!GetObjectW( hbitmap, sizeof(ds), &ds )) return 0;
if (startscan + lines > height) lines = height - startscan; if (startscan + lines > height) lines = height - startscan;
...@@ -3986,7 +3986,7 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan, ...@@ -3986,7 +3986,7 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
descr.ySrc = 0; descr.ySrc = 0;
descr.xDest = 0; descr.xDest = 0;
descr.yDest = height - startscan - lines; descr.yDest = height - startscan - lines;
descr.width = bitmap.bmWidth; descr.width = ds.dsBm.bmWidth;
descr.height = lines; descr.height = lines;
descr.useShm = FALSE; descr.useShm = FALSE;
descr.dibpitch = ((descr.infoWidth * descr.infoBpp + 31) &~31) / 8; descr.dibpitch = ((descr.infoWidth * descr.infoBpp + 31) &~31) / 8;
...@@ -3998,27 +3998,27 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan, ...@@ -3998,27 +3998,27 @@ INT X11DRV_SetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
* cheap - saves a round trip to the X server */ * cheap - saves a round trip to the X server */
if (descr.compression == BI_RGB && if (descr.compression == BI_RGB &&
coloruse == DIB_RGB_COLORS && coloruse == DIB_RGB_COLORS &&
descr.infoBpp == bitmap.bmBitsPixel && descr.infoBpp == ds.dsBm.bmBitsPixel &&
physBitmap->base && physBitmap->size < 65536) physBitmap->base && physBitmap->size < 65536)
{ {
unsigned int srcwidthb = bitmap.bmWidthBytes; unsigned int srcwidthb = ds.dsBm.bmWidthBytes;
int dstwidthb = X11DRV_DIB_GetDIBWidthBytes( width, descr.infoBpp ); int dstwidthb = X11DRV_DIB_GetDIBWidthBytes( width, descr.infoBpp );
LPBYTE dbits = physBitmap->base, sbits = (LPBYTE)bits + (startscan * srcwidthb); LPBYTE dbits = physBitmap->base, sbits = (LPBYTE)bits + (startscan * srcwidthb);
int widthb; int widthb;
UINT y; UINT y;
TRACE("syncing compatible set bits to app bits\n"); TRACE("syncing compatible set bits to app bits\n");
if ((tmpheight < 0) ^ (bitmap.bmHeight < 0)) if ((tmpheight < 0) ^ (ds.dsBmih.biHeight < 0))
{ {
dbits += dstwidthb * (lines-1); dbits += dstwidthb * (lines-1);
dstwidthb = -dstwidthb; dstwidthb = -dstwidthb;
} }
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE ); X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
widthb = min(srcwidthb, abs(dstwidthb)); widthb = min(srcwidthb, abs(dstwidthb));
for (y = 0; y < lines; y++, dbits += dstwidthb, sbits += srcwidthb) for (y = 0; y < lines; y++, dbits += dstwidthb, sbits += srcwidthb)
memcpy(dbits, sbits, widthb); memcpy(dbits, sbits, widthb);
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY ); X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
physBitmap->status = DIB_Status_InSync; physBitmap->status = DIB_Status_InSync;
} }
X11DRV_DIB_Unlock( physBitmap, TRUE ); X11DRV_DIB_Unlock( physBitmap, TRUE );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment