Moved the driver-independent part of CreateDIBSection into GDI.

This commit is contained in:
Alexandre Julliard 2005-04-13 14:45:27 +00:00
parent da56a9c16e
commit 9591466a60
5 changed files with 198 additions and 237 deletions

View File

@ -150,14 +150,16 @@ int DIB_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse )
* 4 for V4HEADER, 5 for V5HEADER, -1 for error. * 4 for V4HEADER, 5 for V5HEADER, -1 for error.
*/ */
static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width, static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
LONG *height, WORD *bpp, DWORD *compr ) LONG *height, WORD *planes, WORD *bpp, DWORD *compr, DWORD *size )
{ {
if (header->biSize == sizeof(BITMAPINFOHEADER)) if (header->biSize == sizeof(BITMAPINFOHEADER))
{ {
*width = header->biWidth; *width = header->biWidth;
*height = header->biHeight; *height = header->biHeight;
*planes = header->biPlanes;
*bpp = header->biBitCount; *bpp = header->biBitCount;
*compr = header->biCompression; *compr = header->biCompression;
*size = header->biSizeImage;
return 1; return 1;
} }
if (header->biSize == sizeof(BITMAPCOREHEADER)) if (header->biSize == sizeof(BITMAPCOREHEADER))
@ -165,8 +167,10 @@ static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)header; BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)header;
*width = core->bcWidth; *width = core->bcWidth;
*height = core->bcHeight; *height = core->bcHeight;
*planes = core->bcPlanes;
*bpp = core->bcBitCount; *bpp = core->bcBitCount;
*compr = 0; *compr = 0;
*size = 0;
return 0; return 0;
} }
if (header->biSize == sizeof(BITMAPV4HEADER)) if (header->biSize == sizeof(BITMAPV4HEADER))
@ -174,8 +178,10 @@ static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
BITMAPV4HEADER *v4hdr = (BITMAPV4HEADER *)header; BITMAPV4HEADER *v4hdr = (BITMAPV4HEADER *)header;
*width = v4hdr->bV4Width; *width = v4hdr->bV4Width;
*height = v4hdr->bV4Height; *height = v4hdr->bV4Height;
*planes = v4hdr->bV4Planes;
*bpp = v4hdr->bV4BitCount; *bpp = v4hdr->bV4BitCount;
*compr = v4hdr->bV4V4Compression; *compr = v4hdr->bV4V4Compression;
*size = v4hdr->bV4SizeImage;
return 4; return 4;
} }
if (header->biSize == sizeof(BITMAPV5HEADER)) if (header->biSize == sizeof(BITMAPV5HEADER))
@ -183,8 +189,10 @@ static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
BITMAPV5HEADER *v5hdr = (BITMAPV5HEADER *)header; BITMAPV5HEADER *v5hdr = (BITMAPV5HEADER *)header;
*width = v5hdr->bV5Width; *width = v5hdr->bV5Width;
*height = v5hdr->bV5Height; *height = v5hdr->bV5Height;
*planes = v5hdr->bV5Planes;
*bpp = v5hdr->bV5BitCount; *bpp = v5hdr->bV5BitCount;
*compr = v5hdr->bV5Compression; *compr = v5hdr->bV5Compression;
*size = v5hdr->bV5SizeImage;
return 5; return 5;
} }
ERR("(%ld): unknown/wrong size for header\n", header->biSize ); ERR("(%ld): unknown/wrong size for header\n", header->biSize );
@ -222,10 +230,10 @@ INT WINAPI StretchDIBits(HDC hdc, INT xDst, INT yDst, INT widthDst,
HDC hdcMem; HDC hdcMem;
LONG height; LONG height;
LONG width; LONG width;
WORD bpp; WORD planes, bpp;
DWORD compr; DWORD compr, size;
if (DIB_GetBitmapInfo( (BITMAPINFOHEADER*) info, &width, &height, &bpp, &compr ) == -1) if (DIB_GetBitmapInfo( &info->bmiHeader, &width, &height, &planes, &bpp, &compr, &size ) == -1)
{ {
ERR("Invalid bitmap\n"); ERR("Invalid bitmap\n");
return 0; return 0;
@ -525,15 +533,15 @@ INT WINAPI GetDIBits(
BOOL core_header; BOOL core_header;
LONG width; LONG width;
LONG height; LONG height;
WORD bpp; WORD planes, bpp;
DWORD compr; DWORD compr, size;
void* colorPtr; void* colorPtr;
RGBTRIPLE* rgbTriples; RGBTRIPLE* rgbTriples;
RGBQUAD* rgbQuads; RGBQUAD* rgbQuads;
if (!info) return 0; if (!info) return 0;
bitmap_type = DIB_GetBitmapInfo( (BITMAPINFOHEADER*) info, &width, &height, &bpp, &compr); bitmap_type = DIB_GetBitmapInfo( &info->bmiHeader, &width, &height, &planes, &bpp, &compr, &size);
if (bitmap_type == -1) if (bitmap_type == -1)
{ {
ERR("Invalid bitmap format\n"); ERR("Invalid bitmap format\n");
@ -984,11 +992,11 @@ HBITMAP WINAPI CreateDIBitmap( HDC hdc, const BITMAPINFOHEADER *header,
HBITMAP handle; HBITMAP handle;
LONG width; LONG width;
LONG height; LONG height;
WORD bpp; WORD planes, bpp;
DWORD compr; DWORD compr, size;
DC *dc; DC *dc;
if (DIB_GetBitmapInfo( header, &width, &height, &bpp, &compr ) == -1) return 0; if (DIB_GetBitmapInfo( header, &width, &height, &planes, &bpp, &compr, &size ) == -1) return 0;
if (width < 0) if (width < 0)
{ {
@ -1042,28 +1050,18 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, const BITMAPINFO *bmi, UINT16 us
{ {
const BITMAPINFOHEADER *bi = &bmi->bmiHeader; const BITMAPINFOHEADER *bi = &bmi->bmiHeader;
LONG width, height; LONG width, height;
WORD bpp; WORD planes, bpp;
DWORD compr; DWORD compr, size;
BOOL core_header;
INT width_bytes; INT width_bytes;
INT size;
WORD count, sel; WORD count, sel;
int i; int i;
core_header = (DIB_GetBitmapInfo(bi, &width, &height, &bpp, &compr) == 0); DIB_GetBitmapInfo(bi, &width, &height, &planes, &bpp, &compr, &size);
height = height >= 0 ? height : -height; height = height >= 0 ? height : -height;
width_bytes = DIB_GetDIBWidthBytes(width, bpp); width_bytes = DIB_GetDIBWidthBytes(width, bpp);
if (core_header) if (!size || (compr != BI_RLE4 && compr != BI_RLE8)) size = width_bytes * height;
{
size = width_bytes * height;
}
else
{
size = (bi->biSizeImage && compr != BI_RGB) ?
bi->biSizeImage : width_bytes * height;
}
/* calculate number of sel's needed for size with 64K steps */ /* calculate number of sel's needed for size with 64K steps */
count = (size + 0xffff) / 0x10000; count = (size + 0xffff) / 0x10000;
@ -1087,12 +1085,118 @@ HBITMAP16 WINAPI CreateDIBSection16 (HDC16 hdc, const BITMAPINFO *bmi, UINT16 us
* DIB_CreateDIBSection * DIB_CreateDIBSection
*/ */
HBITMAP DIB_CreateDIBSection(HDC hdc, const BITMAPINFO *bmi, UINT usage, HBITMAP DIB_CreateDIBSection(HDC hdc, const BITMAPINFO *bmi, UINT usage,
VOID **bits, HANDLE section, VOID **bits, HANDLE section,
DWORD offset, DWORD ovr_pitch) DWORD offset, DWORD ovr_pitch)
{ {
HBITMAP hbitmap = 0; HBITMAP ret = 0;
DC *dc; DC *dc;
BOOL bDesktopDC = FALSE; BOOL bDesktopDC = FALSE;
DIBSECTION *dib;
BITMAPOBJ *bmp;
int bitmap_type;
LONG width, height;
WORD planes, bpp;
DWORD compression, sizeImage;
const DWORD *colorPtr;
void *mapBits = NULL;
if (((bitmap_type = DIB_GetBitmapInfo( &bmi->bmiHeader, &width, &height,
&planes, &bpp, &compression, &sizeImage )) == -1))
return 0;
if (!(dib = HeapAlloc( GetProcessHeap(), 0, sizeof(*dib) ))) return 0;
TRACE("format (%ld,%ld), planes %d, bpp %d, size %ld, %s\n",
width, height, planes, bpp, sizeImage, usage == DIB_PAL_COLORS? "PAL" : "RGB");
dib->dsBm.bmType = 0;
dib->dsBm.bmWidth = width;
dib->dsBm.bmHeight = height >= 0 ? height : -height;
dib->dsBm.bmWidthBytes = ovr_pitch ? ovr_pitch : DIB_GetDIBWidthBytes(width, bpp);
dib->dsBm.bmPlanes = planes;
dib->dsBm.bmBitsPixel = bpp;
dib->dsBm.bmBits = NULL;
if (!bitmap_type) /* core header */
{
/* convert the BITMAPCOREHEADER to a BITMAPINFOHEADER */
dib->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
dib->dsBmih.biWidth = width;
dib->dsBmih.biHeight = height;
dib->dsBmih.biPlanes = planes;
dib->dsBmih.biBitCount = bpp;
dib->dsBmih.biCompression = compression;
dib->dsBmih.biXPelsPerMeter = 0;
dib->dsBmih.biYPelsPerMeter = 0;
dib->dsBmih.biClrUsed = 0;
dib->dsBmih.biClrImportant = 0;
}
else
{
/* truncate extended bitmap headers (BITMAPV4HEADER etc.) */
dib->dsBmih = bmi->bmiHeader;
dib->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
}
/* only use sizeImage if it's valid and we're dealing with a compressed bitmap */
if (sizeImage && (compression == BI_RLE4 || compression == BI_RLE8))
dib->dsBmih.biSizeImage = sizeImage;
else
dib->dsBmih.biSizeImage = dib->dsBm.bmWidthBytes * dib->dsBm.bmHeight;
/* set dsBitfields values */
colorPtr = (const DWORD *)((const char *)bmi + (WORD) bmi->bmiHeader.biSize);
if (usage == DIB_PAL_COLORS || bpp <= 8)
{
dib->dsBitfields[0] = dib->dsBitfields[1] = dib->dsBitfields[2] = 0;
}
else switch( bpp )
{
case 15:
case 16:
dib->dsBitfields[0] = (compression == BI_BITFIELDS) ? colorPtr[0] : 0x7c00;
dib->dsBitfields[1] = (compression == BI_BITFIELDS) ? colorPtr[1] : 0x03e0;
dib->dsBitfields[2] = (compression == BI_BITFIELDS) ? colorPtr[2] : 0x001f;
break;
case 24:
case 32:
dib->dsBitfields[0] = (compression == BI_BITFIELDS) ? colorPtr[0] : 0xff0000;
dib->dsBitfields[1] = (compression == BI_BITFIELDS) ? colorPtr[1] : 0x00ff00;
dib->dsBitfields[2] = (compression == BI_BITFIELDS) ? colorPtr[2] : 0x0000ff;
break;
}
/* get storage location for DIB bits */
if (section)
{
SYSTEM_INFO SystemInfo;
DWORD mapOffset;
INT mapSize;
GetSystemInfo( &SystemInfo );
mapOffset = offset - (offset % SystemInfo.dwAllocationGranularity);
mapSize = dib->dsBmih.biSizeImage + (offset - mapOffset);
mapBits = MapViewOfFile( section, FILE_MAP_ALL_ACCESS, 0, mapOffset, mapSize );
if (mapBits) dib->dsBm.bmBits = (char *)mapBits + (offset - mapOffset);
}
else if (ovr_pitch && offset)
dib->dsBm.bmBits = (LPVOID) offset;
else
{
offset = 0;
dib->dsBm.bmBits = VirtualAlloc( NULL, dib->dsBmih.biSizeImage,
MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE );
}
dib->dshSection = section;
dib->dsOffset = offset;
if (!dib->dsBm.bmBits)
{
HeapFree( GetProcessHeap(), 0, dib );
return 0;
}
/* If the reference hdc is null, take the desktop dc */ /* If the reference hdc is null, take the desktop dc */
if (hdc == 0) if (hdc == 0)
@ -1101,17 +1205,39 @@ HBITMAP DIB_CreateDIBSection(HDC hdc, const BITMAPINFO *bmi, UINT usage,
bDesktopDC = TRUE; bDesktopDC = TRUE;
} }
if ((dc = DC_GetDCPtr( hdc ))) if (!(dc = DC_GetDCPtr( hdc ))) goto error;
/* create Device Dependent Bitmap and add DIB pointer */
ret = CreateBitmap( dib->dsBm.bmWidth, dib->dsBm.bmHeight, 1,
(bpp == 1) ? 1 : GetDeviceCaps(hdc, BITSPIXEL), NULL );
if (ret && ((bmp = GDI_GetObjPtr(ret, BITMAP_MAGIC))))
{ {
if(dc->funcs->pCreateDIBSection) bmp->dib = dib;
hbitmap = dc->funcs->pCreateDIBSection(dc->physDev, bmi, usage, bits, section, offset, ovr_pitch); bmp->funcs = dc->funcs;
GDI_ReleaseObj(hdc); GDI_ReleaseObj( ret );
if (dc->funcs->pCreateDIBSection)
{
if (!dc->funcs->pCreateDIBSection(dc->physDev, ret, bmi, usage))
{
DeleteObject( ret );
ret = 0;
}
}
} }
if (bDesktopDC) GDI_ReleaseObj(hdc);
DeleteDC(hdc); if (bDesktopDC) DeleteDC( hdc );
if (ret && bits) *bits = dib->dsBm.bmBits;
return ret;
return hbitmap; error:
if (bDesktopDC) DeleteDC( hdc );
if (section) UnmapViewOfFile( mapBits );
else if (!offset) VirtualFree( dib->dsBm.bmBits, 0, MEM_RELEASE );
HeapFree( GetProcessHeap(), 0, dib );
return 0;
} }
/*********************************************************************** /***********************************************************************

View File

@ -66,7 +66,7 @@ typedef struct tagDC_FUNCS
BOOL (*pCloseFigure)(PHYSDEV); BOOL (*pCloseFigure)(PHYSDEV);
BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP); BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP);
BOOL (*pCreateDC)(HDC,PHYSDEV *,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*); BOOL (*pCreateDC)(HDC,PHYSDEV *,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*);
HBITMAP (*pCreateDIBSection)(PHYSDEV,const BITMAPINFO *,UINT,VOID **,HANDLE,DWORD,DWORD); HBITMAP (*pCreateDIBSection)(PHYSDEV,HBITMAP,const BITMAPINFO *,UINT);
BOOL (*pDeleteBitmap)(HBITMAP); BOOL (*pDeleteBitmap)(HBITMAP);
BOOL (*pDeleteDC)(PHYSDEV); BOOL (*pDeleteDC)(PHYSDEV);
BOOL (*pDeleteObject)(PHYSDEV,HGDIOBJ); BOOL (*pDeleteObject)(PHYSDEV,HGDIOBJ);

View File

@ -36,7 +36,7 @@
#include <string.h> #include <string.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "gdi.h" #include "wingdi.h"
#include "x11drv.h" #include "x11drv.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -4531,217 +4531,54 @@ static XImage *X11DRV_XShmCreateImage( int width, int height, int bpp,
/*********************************************************************** /***********************************************************************
* X11DRV_DIB_CreateDIBSection * X11DRV_CreateDIBSection (X11DRV.@)
*/ */
HBITMAP X11DRV_DIB_CreateDIBSection( HBITMAP X11DRV_CreateDIBSection( X11DRV_PDEVICE *physDev, HBITMAP hbitmap,
X11DRV_PDEVICE *physDev, const BITMAPINFO *bmi, UINT usage, const BITMAPINFO *bmi, UINT usage )
VOID **bits, HANDLE section,
DWORD offset, DWORD ovr_pitch)
{ {
HBITMAP res = 0; extern BOOL VIRTUAL_SetFaultHandler(LPCVOID addr, BOOL (*proc)(LPVOID, LPCVOID), LPVOID arg);
X_PHYSBITMAP *physBitmap = NULL; X_PHYSBITMAP *physBitmap;
DIBSECTION *dib = NULL; DIBSECTION dib;
int *colorMap = NULL;
int nColorMap;
RGBQUAD *colorTable = NULL;
/* Fill BITMAP structure with DIB data */ if (!(physBitmap = X11DRV_init_phys_bitmap( hbitmap ))) return 0;
INT effHeight, totalSize; physBitmap->status = DIB_Status_None;
BITMAP bm;
LPVOID mapBits = NULL;
int bitmap_type; GetObjectW( hbitmap, sizeof(dib), &dib );
BOOL core_header;
LONG width, height;
WORD planes, bpp, compression;
DWORD sizeImage;
void* colorPtr;
if (((bitmap_type = DIB_GetBitmapInfoEx((BITMAPINFOHEADER*) bmi, /* create color map */
&width, &height, &planes, &bpp, &compression, &sizeImage)) == -1)) if (dib.dsBm.bmBitsPixel <= 8)
{
ERR("Invalid bitmap\n");
return 0;
}
core_header = (bitmap_type == 0);
TRACE("format (%ld,%ld), planes %d, bpp %d, size %ld, %s\n",
width, height, planes, bpp,
sizeImage, usage == DIB_PAL_COLORS? "PAL" : "RGB");
effHeight = height >= 0 ? height : -height;
bm.bmType = 0;
bm.bmWidth = width;
bm.bmHeight = effHeight;
bm.bmWidthBytes = ovr_pitch ? ovr_pitch : X11DRV_DIB_GetDIBWidthBytes(bm.bmWidth, bpp);
bm.bmPlanes = planes;
bm.bmBitsPixel = bpp;
bm.bmBits = NULL;
/* Get storage location for DIB bits. Only use sizeImage if it's valid and
we're dealing with a compressed bitmap. Otherwise, use width * height. */
if (sizeImage && (compression == BI_RLE4 || compression == BI_RLE8))
totalSize = sizeImage;
else
totalSize = bm.bmWidthBytes * effHeight;
if (section)
{
SYSTEM_INFO SystemInfo;
DWORD mapOffset;
INT mapSize;
GetSystemInfo( &SystemInfo );
mapOffset = offset - (offset % SystemInfo.dwAllocationGranularity);
mapSize = totalSize + (offset - mapOffset);
mapBits = MapViewOfFile( section,
FILE_MAP_ALL_ACCESS,
0L,
mapOffset,
mapSize );
bm.bmBits = (char *)mapBits + (offset - mapOffset);
}
else if (ovr_pitch && offset)
bm.bmBits = (LPVOID) offset;
else {
offset = 0;
bm.bmBits = VirtualAlloc(NULL, totalSize,
MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
}
/* Create Color Map */
if (bm.bmBits && bm.bmBitsPixel <= 8) {
colorMap = X11DRV_DIB_BuildColorMap( usage == DIB_PAL_COLORS? physDev : NULL,
usage, bm.bmBitsPixel, bmi, &nColorMap );
colorTable = X11DRV_DIB_BuildColorTable( physDev, usage, bm.bmBitsPixel, bmi );
}
/* Allocate Memory for DIB and fill structure */
if (bm.bmBits)
dib = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dib));
if (dib)
{ {
dib->dsBm = bm; physBitmap->colorMap = X11DRV_DIB_BuildColorMap( usage == DIB_PAL_COLORS ? physDev : NULL,
usage, dib.dsBm.bmBitsPixel, bmi,
if (core_header) &physBitmap->nColorMap );
{ physBitmap->colorTable = X11DRV_DIB_BuildColorTable( physDev, usage, dib.dsBm.bmBitsPixel, bmi );
/* Convert the BITMAPCOREHEADER to a BITMAPINFOHEADER.
The structure is already filled with zeros */
dib->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
dib->dsBmih.biWidth = width;
dib->dsBmih.biHeight = height;
dib->dsBmih.biPlanes = planes;
dib->dsBmih.biBitCount = bpp;
dib->dsBmih.biCompression = compression;
}
else
{
/* Truncate extended bitmap headers (BITMAPV4HEADER etc.) */
dib->dsBmih = *((BITMAPINFOHEADER*) bmi);
dib->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
}
dib->dsBmih.biSizeImage = totalSize;
colorPtr = (LPBYTE) bmi + (WORD) bmi->bmiHeader.biSize;
/* Set dsBitfields values */
if ( usage == DIB_PAL_COLORS || bpp <= 8)
{
dib->dsBitfields[0] = dib->dsBitfields[1] = dib->dsBitfields[2] = 0;
}
else switch( bpp )
{
case 15:
case 16:
dib->dsBitfields[0] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr ) : 0x7c00;
dib->dsBitfields[1] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 1) : 0x03e0;
dib->dsBitfields[2] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 2) : 0x001f;
break;
case 24:
case 32:
dib->dsBitfields[0] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr ) : 0xff0000;
dib->dsBitfields[1] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 1) : 0x00ff00;
dib->dsBitfields[2] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 2) : 0x0000ff;
break;
}
dib->dshSection = section;
dib->dsOffset = offset;
} }
/* Create Device Dependent Bitmap and add DIB pointer */ /* create pixmap and X image */
if (dib) wine_tsx11_lock();
{ physBitmap->pixmap_depth = (dib.dsBm.bmBitsPixel == 1) ? 1 : screen_depth;
int depth = (bpp == 1) ? 1 : GetDeviceCaps(physDev->hdc, BITSPIXEL); physBitmap->pixmap = XCreatePixmap( gdi_display, root_window, dib.dsBm.bmWidth,
res = CreateBitmap(width, effHeight, 1, depth, NULL); dib.dsBm.bmHeight, physBitmap->pixmap_depth );
if (res)
{
BITMAPOBJ *bmp = GDI_GetObjPtr(res, BITMAP_MAGIC);
if (bmp) bmp->dib = dib;
GDI_ReleaseObj( res );
physBitmap = X11DRV_init_phys_bitmap( res );
physBitmap->status = DIB_Status_None;
physBitmap->nColorMap = nColorMap;
physBitmap->colorMap = colorMap;
physBitmap->colorTable = colorTable;
}
}
/* Create XImage */
if (dib && physBitmap)
{
wine_tsx11_lock();
#ifdef HAVE_LIBXXSHM #ifdef HAVE_LIBXXSHM
if (XShmQueryExtension(gdi_display) && physBitmap->shminfo.shmid = -1;
(physBitmap->image = X11DRV_XShmCreateImage( bm.bmWidth, effHeight, if (!XShmQueryExtension(gdi_display) ||
physBitmap->pixmap_depth, &physBitmap->shminfo )) ) !(physBitmap->image = X11DRV_XShmCreateImage( dib.dsBm.bmWidth, dib.dsBm.bmHeight,
{ physBitmap->pixmap_depth, &physBitmap->shminfo )) )
; /* Created Image */
} else {
physBitmap->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, physBitmap->pixmap_depth );
physBitmap->shminfo.shmid = -1;
}
#else
physBitmap->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, physBitmap->pixmap_depth );
#endif #endif
wine_tsx11_unlock(); physBitmap->image = X11DRV_DIB_CreateXImage( dib.dsBm.bmWidth, dib.dsBm.bmHeight,
} physBitmap->pixmap_depth );
wine_tsx11_unlock();
if (!physBitmap->pixmap || !physBitmap->image) return 0;
/* Clean up in case of errors */ /* install fault handler */
if (!res || !physBitmap || !dib || !bm.bmBits || (bm.bmBitsPixel <= 8 && !colorMap)) InitializeCriticalSection( &physBitmap->lock );
if (VIRTUAL_SetFaultHandler(dib.dsBm.bmBits, X11DRV_DIB_FaultHandler, physBitmap))
{ {
TRACE("got an error res=%p, bmp=%p, dib=%p, bm.bmBits=%p\n", X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
res, physBitmap, dib, bm.bmBits); physBitmap->status = DIB_Status_AppMod;
if (bm.bmBits)
{
if (section)
UnmapViewOfFile(mapBits), bm.bmBits = NULL;
else if (!offset)
VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL;
}
if (dib && physBitmap->image) { XDestroyImage(physBitmap->image); physBitmap->image = NULL; }
HeapFree(GetProcessHeap(), 0, colorMap); colorMap = NULL;
HeapFree(GetProcessHeap(), 0, colorTable); colorTable = NULL;
HeapFree(GetProcessHeap(), 0, dib); dib = NULL;
if (res) { DeleteObject(res); res = 0; }
}
else if (bm.bmBits)
{
extern BOOL VIRTUAL_SetFaultHandler(LPCVOID addr, BOOL (*proc)(LPVOID, LPCVOID), LPVOID arg);
/* Install fault handler, if possible */
InitializeCriticalSection(&physBitmap->lock);
if (VIRTUAL_SetFaultHandler(bm.bmBits, X11DRV_DIB_FaultHandler, physBitmap))
{
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
physBitmap->status = DIB_Status_AppMod;
}
} }
/* Return BITMAP handle and storage location */ return hbitmap;
if (bm.bmBits && bits) *bits = bm.bmBits;
return res;
} }
/*********************************************************************** /***********************************************************************

View File

@ -409,8 +409,6 @@ extern INT X11DRV_CoerceDIBSection(X11DRV_PDEVICE *physDev,INT,BOOL);
extern INT X11DRV_LockDIBSection(X11DRV_PDEVICE *physDev,INT,BOOL); extern INT X11DRV_LockDIBSection(X11DRV_PDEVICE *physDev,INT,BOOL);
extern void X11DRV_UnlockDIBSection(X11DRV_PDEVICE *physDev,BOOL); extern void X11DRV_UnlockDIBSection(X11DRV_PDEVICE *physDev,BOOL);
extern HBITMAP X11DRV_DIB_CreateDIBSection(X11DRV_PDEVICE *physDev, const BITMAPINFO *bmi, UINT usage,
VOID **bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
extern void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap, DIBSECTION *dib); extern void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap, DIBSECTION *dib);
void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDevDst, void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physDevDst,
DWORD xSrc, DWORD ySrc, DWORD xDest, DWORD yDest, DWORD xSrc, DWORD ySrc, DWORD xDest, DWORD yDest,

View File

@ -7,7 +7,7 @@
@ cdecl Chord(ptr long long long long long long long long) X11DRV_Chord @ cdecl Chord(ptr long long long long long long long long) X11DRV_Chord
@ cdecl CreateBitmap(ptr long) X11DRV_CreateBitmap @ cdecl CreateBitmap(ptr long) X11DRV_CreateBitmap
@ cdecl CreateDC(long ptr wstr wstr wstr ptr) X11DRV_CreateDC @ cdecl CreateDC(long ptr wstr wstr wstr ptr) X11DRV_CreateDC
@ cdecl CreateDIBSection(ptr ptr long ptr long long long) X11DRV_DIB_CreateDIBSection @ cdecl CreateDIBSection(ptr long ptr long) X11DRV_CreateDIBSection
@ cdecl DeleteBitmap(long) X11DRV_DeleteBitmap @ cdecl DeleteBitmap(long) X11DRV_DeleteBitmap
@ cdecl DeleteDC(ptr) X11DRV_DeleteDC @ cdecl DeleteDC(ptr) X11DRV_DeleteDC
@ cdecl DescribePixelFormat(ptr long long ptr) X11DRV_DescribePixelFormat @ cdecl DescribePixelFormat(ptr long long ptr) X11DRV_DescribePixelFormat