Store DIB section information directly in the phys bitmap structure
and get rid of the X11DRV_DIBSECTION structure. Get rid of the unused AuxMod DIB state.
This commit is contained in:
parent
9b626b7bed
commit
66add27b21
|
@ -424,7 +424,11 @@ BOOL X11DRV_DeleteBitmap( HBITMAP hbitmap )
|
||||||
|
|
||||||
if (physBitmap)
|
if (physBitmap)
|
||||||
{
|
{
|
||||||
if (physBitmap->dib) X11DRV_DIB_DeleteDIBSection( physBitmap );
|
DIBSECTION dib;
|
||||||
|
|
||||||
|
if (GetObjectW( hbitmap, sizeof(dib), &dib ) == sizeof(dib))
|
||||||
|
X11DRV_DIB_DeleteDIBSection( physBitmap, &dib );
|
||||||
|
|
||||||
wine_tsx11_lock();
|
wine_tsx11_lock();
|
||||||
if (physBitmap->pixmap) XFreePixmap( gdi_display, physBitmap->pixmap );
|
if (physBitmap->pixmap) XFreePixmap( gdi_display, physBitmap->pixmap );
|
||||||
wine_tsx11_unlock();
|
wine_tsx11_unlock();
|
||||||
|
@ -468,12 +472,11 @@ X_PHYSBITMAP *X11DRV_init_phys_bitmap( HBITMAP hbitmap )
|
||||||
{
|
{
|
||||||
if (!(ret = bmp->physBitmap))
|
if (!(ret = bmp->physBitmap))
|
||||||
{
|
{
|
||||||
if ((ret = HeapAlloc( GetProcessHeap(), 0, sizeof(*ret) )) != NULL)
|
if ((ret = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret) )) != NULL)
|
||||||
{
|
{
|
||||||
ret->hbitmap = hbitmap;
|
ret->hbitmap = hbitmap;
|
||||||
ret->pixmap = 0;
|
ret->pixmap = 0;
|
||||||
ret->pixmap_depth = bmp->bitmap.bmBitsPixel;
|
ret->pixmap_depth = bmp->bitmap.bmBitsPixel;
|
||||||
ret->dib = NULL;
|
|
||||||
bmp->physBitmap = ret;
|
bmp->physBitmap = ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,41 +43,6 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(bitmap);
|
WINE_DEFAULT_DEBUG_CHANNEL(bitmap);
|
||||||
WINE_DECLARE_DEBUG_CHANNEL(x11drv);
|
WINE_DECLARE_DEBUG_CHANNEL(x11drv);
|
||||||
|
|
||||||
/* Additional info for DIB section objects */
|
|
||||||
typedef struct _X11DRV_DIBSECTION
|
|
||||||
{
|
|
||||||
/* Windows DIB section */
|
|
||||||
DIBSECTION dibSection;
|
|
||||||
|
|
||||||
/* Mapping status */
|
|
||||||
int status, p_status;
|
|
||||||
|
|
||||||
/* Color map info */
|
|
||||||
int nColorMap;
|
|
||||||
int *colorMap;
|
|
||||||
|
|
||||||
/* Original dib color table converted to
|
|
||||||
rgb values if usage was DIB_PAL_COLORS */
|
|
||||||
RGBQUAD *colorTable;
|
|
||||||
|
|
||||||
/* Cached XImage */
|
|
||||||
XImage *image;
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBXXSHM
|
|
||||||
/* Shared memory segment info */
|
|
||||||
XShmSegmentInfo shminfo;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Aux buffer access function */
|
|
||||||
void (*copy_aux)(void*ctx, int req);
|
|
||||||
void *aux_ctx;
|
|
||||||
|
|
||||||
/* GDI access lock */
|
|
||||||
CRITICAL_SECTION lock;
|
|
||||||
|
|
||||||
} X11DRV_DIBSECTION;
|
|
||||||
|
|
||||||
|
|
||||||
static int ximageDepthTable[32];
|
static int ximageDepthTable[32];
|
||||||
|
|
||||||
/* This structure holds the arguments for DIB_SetImageBits() */
|
/* This structure holds the arguments for DIB_SetImageBits() */
|
||||||
|
@ -3961,10 +3926,10 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
|
||||||
LPVOID bits, BITMAPINFO *info, UINT coloruse )
|
LPVOID bits, BITMAPINFO *info, UINT coloruse )
|
||||||
{
|
{
|
||||||
X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
|
X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
|
||||||
X11DRV_DIBSECTION *dib;
|
DIBSECTION dib;
|
||||||
X11DRV_DIB_IMAGEBITS_DESCR descr;
|
X11DRV_DIB_IMAGEBITS_DESCR descr;
|
||||||
PALETTEENTRY palette[256];
|
PALETTEENTRY palette[256];
|
||||||
BITMAP bitmap;
|
size_t obj_size;
|
||||||
int height;
|
int height;
|
||||||
LONG tempHeight;
|
LONG tempHeight;
|
||||||
int bitmap_type;
|
int bitmap_type;
|
||||||
|
@ -3974,10 +3939,8 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
|
||||||
GetPaletteEntries( GetCurrentObject( physDev->hdc, OBJ_PAL ), 0, 256, palette );
|
GetPaletteEntries( GetCurrentObject( physDev->hdc, OBJ_PAL ), 0, 256, palette );
|
||||||
|
|
||||||
if (!physBitmap) return 0;
|
if (!physBitmap) return 0;
|
||||||
if (!GetObjectW( hbitmap, sizeof(bitmap), &bitmap )) return 0;
|
if (!(obj_size = GetObjectW( hbitmap, sizeof(dib), &dib ))) return 0;
|
||||||
|
|
||||||
dib = physBitmap->dib;
|
|
||||||
|
|
||||||
bitmap_type = DIB_GetBitmapInfo( (BITMAPINFOHEADER*) info, &descr.infoWidth, &tempHeight, &descr.infoBpp, &descr.compression);
|
bitmap_type = DIB_GetBitmapInfo( (BITMAPINFOHEADER*) info, &descr.infoWidth, &tempHeight, &descr.infoBpp, &descr.compression);
|
||||||
descr.lines = tempHeight;
|
descr.lines = tempHeight;
|
||||||
if (bitmap_type == -1)
|
if (bitmap_type == -1)
|
||||||
|
@ -3989,10 +3952,9 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
|
||||||
colorPtr = (LPBYTE) info + (WORD) info->bmiHeader.biSize;
|
colorPtr = (LPBYTE) info + (WORD) info->bmiHeader.biSize;
|
||||||
|
|
||||||
TRACE("%u scanlines of (%i,%i) -> (%i,%i) starting from %u\n",
|
TRACE("%u scanlines of (%i,%i) -> (%i,%i) starting from %u\n",
|
||||||
lines, bitmap.bmWidth, bitmap.bmHeight,
|
lines, dib.dsBm.bmWidth, dib.dsBm.bmHeight, (int)descr.infoWidth, descr.lines, startscan);
|
||||||
(int)descr.infoWidth, descr.lines, startscan);
|
|
||||||
|
|
||||||
if( lines > bitmap.bmHeight ) lines = bitmap.bmHeight;
|
if( lines > dib.dsBm.bmHeight ) lines = dib.dsBm.bmHeight;
|
||||||
|
|
||||||
height = descr.lines;
|
height = descr.lines;
|
||||||
if (height < 0) height = -height;
|
if (height < 0) height = -height;
|
||||||
|
@ -4005,7 +3967,7 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
|
||||||
*/
|
*/
|
||||||
if( descr.lines < 0 && lines > 0) lines = -lines;
|
if( descr.lines < 0 && lines > 0) lines = -lines;
|
||||||
|
|
||||||
if( startscan >= bitmap.bmHeight ) return 0;
|
if( startscan >= dib.dsBm.bmHeight ) return 0;
|
||||||
|
|
||||||
descr.colorMap = NULL;
|
descr.colorMap = NULL;
|
||||||
|
|
||||||
|
@ -4054,8 +4016,8 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
|
||||||
descr.depth = physBitmap->pixmap_depth;
|
descr.depth = physBitmap->pixmap_depth;
|
||||||
descr.drawable = physBitmap->pixmap;
|
descr.drawable = physBitmap->pixmap;
|
||||||
descr.gc = BITMAP_GC(physBitmap);
|
descr.gc = BITMAP_GC(physBitmap);
|
||||||
descr.width = bitmap.bmWidth;
|
descr.width = dib.dsBm.bmWidth;
|
||||||
descr.height = bitmap.bmHeight;
|
descr.height = dib.dsBm.bmHeight;
|
||||||
descr.xDest = 0;
|
descr.xDest = 0;
|
||||||
descr.yDest = 0;
|
descr.yDest = 0;
|
||||||
descr.xSrc = 0;
|
descr.xSrc = 0;
|
||||||
|
@ -4070,11 +4032,11 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
|
||||||
descr.ySrc = startscan;
|
descr.ySrc = startscan;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LIBXXSHM
|
#ifdef HAVE_LIBXXSHM
|
||||||
descr.useShm = dib ? (dib->shminfo.shmid != -1) : FALSE;
|
descr.useShm = (obj_size == sizeof(DIBSECTION)) && (physBitmap->shminfo.shmid != -1);
|
||||||
#else
|
#else
|
||||||
descr.useShm = FALSE;
|
descr.useShm = FALSE;
|
||||||
#endif
|
#endif
|
||||||
descr.dibpitch = dib ? (dib->dibSection.dsBm.bmWidthBytes)
|
descr.dibpitch = (obj_size == sizeof(DIBSECTION)) ? dib.dsBm.bmWidthBytes
|
||||||
: (((descr.infoWidth * descr.infoBpp + 31) &~31) / 8);
|
: (((descr.infoWidth * descr.infoBpp + 31) &~31) / 8);
|
||||||
|
|
||||||
X11DRV_DIB_Lock( physBitmap, DIB_Status_GdiMod, FALSE );
|
X11DRV_DIB_Lock( physBitmap, DIB_Status_GdiMod, FALSE );
|
||||||
|
@ -4110,21 +4072,10 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
|
||||||
static void X11DRV_DIB_DoProtectDIBSection( X_PHYSBITMAP *physBitmap, DWORD new_prot )
|
static void X11DRV_DIB_DoProtectDIBSection( X_PHYSBITMAP *physBitmap, DWORD new_prot )
|
||||||
{
|
{
|
||||||
DWORD old_prot;
|
DWORD old_prot;
|
||||||
INT totalSize;
|
DIBSECTION dib;
|
||||||
DIBSECTION *dib = &physBitmap->dib->dibSection;
|
|
||||||
INT effHeight = dib->dsBm.bmHeight >= 0? dib->dsBm.bmHeight
|
|
||||||
: -dib->dsBm.bmHeight;
|
|
||||||
|
|
||||||
/* use the biSizeImage data as the memory size only if we're dealing with a
|
GetObjectW( physBitmap->hbitmap, sizeof(dib), &dib );
|
||||||
compressed image where the value is set. Otherwise, calculate based on
|
VirtualProtect(dib.dsBm.bmBits, dib.dsBmih.biSizeImage, new_prot, &old_prot);
|
||||||
width * height */
|
|
||||||
if (dib->dsBmih.biSizeImage &&
|
|
||||||
(dib->dsBmih.biCompression == BI_RLE4 || dib->dsBmih.biCompression == BI_RLE8))
|
|
||||||
totalSize = dib->dsBmih.biSizeImage;
|
|
||||||
else
|
|
||||||
totalSize = dib->dsBm.bmWidthBytes * effHeight;
|
|
||||||
|
|
||||||
VirtualProtect(dib->dsBm.bmBits, totalSize, new_prot, &old_prot);
|
|
||||||
TRACE("Changed protection from %ld to %ld\n", old_prot, new_prot);
|
TRACE("Changed protection from %ld to %ld\n", old_prot, new_prot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4138,21 +4089,23 @@ static void X11DRV_DIB_DoCopyDIBSection(X_PHYSBITMAP *physBitmap, BOOL toDIB,
|
||||||
DWORD xDest, DWORD yDest,
|
DWORD xDest, DWORD yDest,
|
||||||
DWORD width, DWORD height)
|
DWORD width, DWORD height)
|
||||||
{
|
{
|
||||||
X11DRV_DIBSECTION *dib = physBitmap->dib;
|
DIBSECTION dibSection;
|
||||||
X11DRV_DIB_IMAGEBITS_DESCR descr;
|
X11DRV_DIB_IMAGEBITS_DESCR descr;
|
||||||
int identity[2] = {0,1};
|
int identity[2] = {0,1};
|
||||||
|
|
||||||
if (DIB_GetBitmapInfo( &dib->dibSection.dsBmih, &descr.infoWidth, (DWORD*) &descr.lines,
|
if (!GetObjectW( physBitmap->hbitmap, sizeof(dibSection), &dibSection )) return;
|
||||||
&descr.infoBpp, &descr.compression ) == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
descr.physDev = NULL;
|
descr.physDev = NULL;
|
||||||
descr.palentry = NULL;
|
descr.palentry = NULL;
|
||||||
descr.image = dib->image;
|
descr.infoWidth = dibSection.dsBmih.biWidth;
|
||||||
|
descr.infoBpp = dibSection.dsBmih.biBitCount;
|
||||||
|
descr.lines = dibSection.dsBmih.biHeight;
|
||||||
|
descr.image = physBitmap->image;
|
||||||
descr.colorMap = colorMap;
|
descr.colorMap = colorMap;
|
||||||
descr.nColorMap = nColorMap;
|
descr.nColorMap = nColorMap;
|
||||||
descr.bits = dib->dibSection.dsBm.bmBits;
|
descr.bits = dibSection.dsBm.bmBits;
|
||||||
descr.depth = physBitmap->pixmap_depth;
|
descr.depth = physBitmap->pixmap_depth;
|
||||||
|
descr.compression = dibSection.dsBmih.biCompression;
|
||||||
|
|
||||||
if(descr.infoBpp == 1)
|
if(descr.infoBpp == 1)
|
||||||
descr.colorMap = (void*)identity;
|
descr.colorMap = (void*)identity;
|
||||||
|
@ -4166,16 +4119,16 @@ static void X11DRV_DIB_DoCopyDIBSection(X_PHYSBITMAP *physBitmap, BOOL toDIB,
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
case 16:
|
case 16:
|
||||||
descr.rMask = (descr.compression == BI_BITFIELDS) ? dib->dibSection.dsBitfields[0] : 0x7c00;
|
descr.rMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[0] : 0x7c00;
|
||||||
descr.gMask = (descr.compression == BI_BITFIELDS) ? dib->dibSection.dsBitfields[1] : 0x03e0;
|
descr.gMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[1] : 0x03e0;
|
||||||
descr.bMask = (descr.compression == BI_BITFIELDS) ? dib->dibSection.dsBitfields[2] : 0x001f;
|
descr.bMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[2] : 0x001f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
case 32:
|
case 32:
|
||||||
descr.rMask = (descr.compression == BI_BITFIELDS) ? dib->dibSection.dsBitfields[0] : 0xff0000;
|
descr.rMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[0] : 0xff0000;
|
||||||
descr.gMask = (descr.compression == BI_BITFIELDS) ? dib->dibSection.dsBitfields[1] : 0x00ff00;
|
descr.gMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[1] : 0x00ff00;
|
||||||
descr.bMask = (descr.compression == BI_BITFIELDS) ? dib->dibSection.dsBitfields[2] : 0x0000ff;
|
descr.bMask = (descr.compression == BI_BITFIELDS) ? dibSection.dsBitfields[2] : 0x0000ff;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4191,11 +4144,11 @@ static void X11DRV_DIB_DoCopyDIBSection(X_PHYSBITMAP *physBitmap, BOOL toDIB,
|
||||||
descr.sizeImage = 0;
|
descr.sizeImage = 0;
|
||||||
|
|
||||||
#ifdef HAVE_LIBXXSHM
|
#ifdef HAVE_LIBXXSHM
|
||||||
descr.useShm = (dib->shminfo.shmid != -1);
|
descr.useShm = (physBitmap->shminfo.shmid != -1);
|
||||||
#else
|
#else
|
||||||
descr.useShm = FALSE;
|
descr.useShm = FALSE;
|
||||||
#endif
|
#endif
|
||||||
descr.dibpitch = dib->dibSection.dsBm.bmWidthBytes;
|
descr.dibpitch = dibSection.dsBm.bmWidthBytes;
|
||||||
|
|
||||||
if (toDIB)
|
if (toDIB)
|
||||||
{
|
{
|
||||||
|
@ -4247,8 +4200,8 @@ void X11DRV_DIB_CopyDIBSection(X11DRV_PDEVICE *physDevSrc, X11DRV_PDEVICE *physD
|
||||||
* use the DIB colormap instead - this is necessary in some
|
* use the DIB colormap instead - this is necessary in some
|
||||||
* cases since we need to do depth conversion in some places
|
* cases since we need to do depth conversion in some places
|
||||||
* where real Windows can just copy data straight over */
|
* where real Windows can just copy data straight over */
|
||||||
colorMap = physBitmap->dib->colorMap;
|
colorMap = physBitmap->colorMap;
|
||||||
nColorMap = physBitmap->dib->nColorMap;
|
nColorMap = physBitmap->nColorMap;
|
||||||
} else {
|
} else {
|
||||||
colorMap = X11DRV_DIB_BuildColorMap( physDevSrc, (WORD)-1,
|
colorMap = X11DRV_DIB_BuildColorMap( physDevSrc, (WORD)-1,
|
||||||
dib.dsBm.bmBitsPixel,
|
dib.dsBm.bmBitsPixel,
|
||||||
|
@ -4277,7 +4230,7 @@ static void X11DRV_DIB_DoUpdateDIBSection(X_PHYSBITMAP *physBitmap, BOOL toDIB)
|
||||||
|
|
||||||
GetObjectW( physBitmap->hbitmap, sizeof(bitmap), &bitmap );
|
GetObjectW( physBitmap->hbitmap, sizeof(bitmap), &bitmap );
|
||||||
X11DRV_DIB_DoCopyDIBSection(physBitmap, toDIB,
|
X11DRV_DIB_DoCopyDIBSection(physBitmap, toDIB,
|
||||||
physBitmap->dib->colorMap, physBitmap->dib->nColorMap,
|
physBitmap->colorMap, physBitmap->nColorMap,
|
||||||
physBitmap->pixmap, 0, 0, 0, 0,
|
physBitmap->pixmap, 0, 0, 0, 0,
|
||||||
bitmap.bmWidth, bitmap.bmHeight);
|
bitmap.bmWidth, bitmap.bmHeight);
|
||||||
}
|
}
|
||||||
|
@ -4308,46 +4261,34 @@ static BOOL X11DRV_DIB_FaultHandler( LPVOID res, LPCVOID addr )
|
||||||
*/
|
*/
|
||||||
static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
{
|
{
|
||||||
X11DRV_DIBSECTION *dib = physBitmap->dib;
|
INT ret = DIB_Status_None;
|
||||||
INT ret = DIB_Status_None;
|
|
||||||
|
|
||||||
if (dib) {
|
if (!physBitmap->image) return ret; /* not a DIB section */
|
||||||
EnterCriticalSection(&(dib->lock));
|
EnterCriticalSection(&physBitmap->lock);
|
||||||
ret = dib->status;
|
ret = physBitmap->status;
|
||||||
switch (req) {
|
switch (req) {
|
||||||
case DIB_Status_GdiMod:
|
case DIB_Status_GdiMod:
|
||||||
/* GDI access - request to draw on pixmap */
|
/* GDI access - request to draw on pixmap */
|
||||||
switch (dib->status)
|
switch (physBitmap->status)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case DIB_Status_None:
|
case DIB_Status_None:
|
||||||
dib->p_status = DIB_Status_GdiMod;
|
physBitmap->p_status = DIB_Status_GdiMod;
|
||||||
X11DRV_DIB_DoUpdateDIBSection( physBitmap, FALSE );
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, FALSE );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_GdiMod:
|
case DIB_Status_GdiMod:
|
||||||
TRACE("GdiMod requested in status GdiMod\n" );
|
TRACE("GdiMod requested in status GdiMod\n" );
|
||||||
dib->p_status = DIB_Status_GdiMod;
|
physBitmap->p_status = DIB_Status_GdiMod;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_InSync:
|
case DIB_Status_InSync:
|
||||||
TRACE("GdiMod requested in status InSync\n" );
|
TRACE("GdiMod requested in status InSync\n" );
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
|
||||||
dib->status = DIB_Status_GdiMod;
|
physBitmap->status = DIB_Status_GdiMod;
|
||||||
dib->p_status = DIB_Status_InSync;
|
physBitmap->p_status = DIB_Status_InSync;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_AuxMod:
|
|
||||||
TRACE("GdiMod requested in status AuxMod\n" );
|
|
||||||
if (lossy) dib->status = DIB_Status_GdiMod;
|
|
||||||
else (*dib->copy_aux)(dib->aux_ctx, DIB_Status_GdiMod);
|
|
||||||
dib->p_status = DIB_Status_AuxMod;
|
|
||||||
if (dib->status != DIB_Status_AppMod) {
|
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* fall through if copy_aux() had to change to AppMod state */
|
|
||||||
|
|
||||||
case DIB_Status_AppMod:
|
case DIB_Status_AppMod:
|
||||||
TRACE("GdiMod requested in status AppMod\n" );
|
TRACE("GdiMod requested in status AppMod\n" );
|
||||||
if (!lossy) {
|
if (!lossy) {
|
||||||
|
@ -4356,8 +4297,8 @@ static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
X11DRV_DIB_DoUpdateDIBSection( physBitmap, FALSE );
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, FALSE );
|
||||||
}
|
}
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
|
||||||
dib->p_status = DIB_Status_AppMod;
|
physBitmap->p_status = DIB_Status_AppMod;
|
||||||
dib->status = DIB_Status_GdiMod;
|
physBitmap->status = DIB_Status_GdiMod;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -4365,26 +4306,13 @@ static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
case DIB_Status_InSync:
|
case DIB_Status_InSync:
|
||||||
/* App access - request access to read DIB surface */
|
/* App access - request access to read DIB surface */
|
||||||
/* (typically called from signal handler) */
|
/* (typically called from signal handler) */
|
||||||
switch (dib->status)
|
switch (physBitmap->status)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case DIB_Status_None:
|
case DIB_Status_None:
|
||||||
/* shouldn't happen from signal handler */
|
/* shouldn't happen from signal handler */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_AuxMod:
|
|
||||||
TRACE("InSync requested in status AuxMod\n" );
|
|
||||||
if (lossy) dib->status = DIB_Status_InSync;
|
|
||||||
else {
|
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
|
||||||
(*dib->copy_aux)(dib->aux_ctx, DIB_Status_InSync);
|
|
||||||
}
|
|
||||||
if (dib->status != DIB_Status_GdiMod) {
|
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* fall through if copy_aux() had to change to GdiMod state */
|
|
||||||
|
|
||||||
case DIB_Status_GdiMod:
|
case DIB_Status_GdiMod:
|
||||||
TRACE("InSync requested in status GdiMod\n" );
|
TRACE("InSync requested in status GdiMod\n" );
|
||||||
if (!lossy) {
|
if (!lossy) {
|
||||||
|
@ -4392,7 +4320,7 @@ static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
||||||
}
|
}
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
|
||||||
dib->status = DIB_Status_InSync;
|
physBitmap->status = DIB_Status_InSync;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_InSync:
|
case DIB_Status_InSync:
|
||||||
|
@ -4411,33 +4339,24 @@ static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
case DIB_Status_AppMod:
|
case DIB_Status_AppMod:
|
||||||
/* App access - request access to write DIB surface */
|
/* App access - request access to write DIB surface */
|
||||||
/* (typically called from signal handler) */
|
/* (typically called from signal handler) */
|
||||||
switch (dib->status)
|
switch (physBitmap->status)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case DIB_Status_None:
|
case DIB_Status_None:
|
||||||
/* shouldn't happen from signal handler */
|
/* shouldn't happen from signal handler */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_AuxMod:
|
|
||||||
TRACE("AppMod requested in status AuxMod\n" );
|
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
|
||||||
if (lossy) dib->status = DIB_Status_AppMod;
|
|
||||||
else (*dib->copy_aux)(dib->aux_ctx, DIB_Status_AppMod);
|
|
||||||
if (dib->status != DIB_Status_GdiMod)
|
|
||||||
break;
|
|
||||||
/* fall through if copy_aux() had to change to GdiMod state */
|
|
||||||
|
|
||||||
case DIB_Status_GdiMod:
|
case DIB_Status_GdiMod:
|
||||||
TRACE("AppMod requested in status GdiMod\n" );
|
TRACE("AppMod requested in status GdiMod\n" );
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
||||||
if (!lossy) X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
if (!lossy) X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
||||||
dib->status = DIB_Status_AppMod;
|
physBitmap->status = DIB_Status_AppMod;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_InSync:
|
case DIB_Status_InSync:
|
||||||
TRACE("AppMod requested in status InSync\n" );
|
TRACE("AppMod requested in status InSync\n" );
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
||||||
dib->status = DIB_Status_AppMod;
|
physBitmap->status = DIB_Status_AppMod;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_AppMod:
|
case DIB_Status_AppMod:
|
||||||
|
@ -4447,21 +4366,11 @@ static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_AuxMod:
|
|
||||||
if (dib->status == DIB_Status_None) {
|
|
||||||
dib->p_status = req;
|
|
||||||
} else {
|
|
||||||
if (dib->status != DIB_Status_AuxMod)
|
|
||||||
dib->p_status = dib->status;
|
|
||||||
dib->status = DIB_Status_AuxMod;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/* it is up to the caller to do the copy/conversion, probably
|
/* it is up to the caller to do the copy/conversion, probably
|
||||||
* using the return value to decide where to copy from */
|
* using the return value to decide where to copy from */
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&(dib->lock));
|
LeaveCriticalSection(&physBitmap->lock);
|
||||||
}
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -4469,17 +4378,15 @@ static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
*/
|
*/
|
||||||
static INT X11DRV_DIB_Lock(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
static INT X11DRV_DIB_Lock(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
{
|
{
|
||||||
X11DRV_DIBSECTION *dib = physBitmap->dib;
|
INT ret = DIB_Status_None;
|
||||||
INT ret = DIB_Status_None;
|
|
||||||
|
|
||||||
if (dib) {
|
if (!physBitmap->image) return ret; /* not a DIB section */
|
||||||
TRACE("Locking %p from thread %04lx\n", physBitmap->hbitmap, GetCurrentThreadId());
|
TRACE("Locking %p from thread %04lx\n", physBitmap->hbitmap, GetCurrentThreadId());
|
||||||
EnterCriticalSection(&(dib->lock));
|
EnterCriticalSection(&physBitmap->lock);
|
||||||
ret = dib->status;
|
ret = physBitmap->status;
|
||||||
if (req != DIB_Status_None)
|
if (req != DIB_Status_None)
|
||||||
X11DRV_DIB_Coerce(physBitmap, req, lossy);
|
X11DRV_DIB_Coerce(physBitmap, req, lossy);
|
||||||
}
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -4487,29 +4394,16 @@ static INT X11DRV_DIB_Lock(X_PHYSBITMAP *physBitmap, INT req, BOOL lossy)
|
||||||
*/
|
*/
|
||||||
static void X11DRV_DIB_Unlock(X_PHYSBITMAP *physBitmap, BOOL commit)
|
static void X11DRV_DIB_Unlock(X_PHYSBITMAP *physBitmap, BOOL commit)
|
||||||
{
|
{
|
||||||
X11DRV_DIBSECTION *dib = physBitmap->dib;
|
if (!physBitmap->image) return; /* not a DIB section */
|
||||||
|
switch (physBitmap->status)
|
||||||
if (dib) {
|
|
||||||
switch (dib->status)
|
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case DIB_Status_None:
|
case DIB_Status_None:
|
||||||
/* in case anyone is wondering, this is the "signal handler doesn't
|
/* in case anyone is wondering, this is the "signal handler doesn't
|
||||||
* work" case, where we always have to be ready for app access */
|
* work" case, where we always have to be ready for app access */
|
||||||
if (commit) {
|
if (commit) {
|
||||||
switch (dib->p_status)
|
switch (physBitmap->p_status)
|
||||||
{
|
{
|
||||||
case DIB_Status_AuxMod:
|
|
||||||
TRACE("Unlocking and syncing from AuxMod\n" );
|
|
||||||
(*dib->copy_aux)(dib->aux_ctx, DIB_Status_AppMod);
|
|
||||||
if (dib->status != DIB_Status_None) {
|
|
||||||
dib->p_status = dib->status;
|
|
||||||
dib->status = DIB_Status_None;
|
|
||||||
}
|
|
||||||
if (dib->p_status != DIB_Status_GdiMod)
|
|
||||||
break;
|
|
||||||
/* fall through if copy_aux() had to change to GdiMod state */
|
|
||||||
|
|
||||||
case DIB_Status_GdiMod:
|
case DIB_Status_GdiMod:
|
||||||
TRACE("Unlocking and syncing from GdiMod\n" );
|
TRACE("Unlocking and syncing from GdiMod\n" );
|
||||||
X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
X11DRV_DIB_DoUpdateDIBSection( physBitmap, TRUE );
|
||||||
|
@ -4521,7 +4415,7 @@ static void X11DRV_DIB_Unlock(X_PHYSBITMAP *physBitmap, BOOL commit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else TRACE("Unlocking with no changes\n");
|
else TRACE("Unlocking with no changes\n");
|
||||||
dib->p_status = DIB_Status_None;
|
physBitmap->p_status = DIB_Status_None;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_GdiMod:
|
case DIB_Status_GdiMod:
|
||||||
|
@ -4529,10 +4423,10 @@ static void X11DRV_DIB_Unlock(X_PHYSBITMAP *physBitmap, BOOL commit)
|
||||||
/* DIB was protected in Coerce */
|
/* DIB was protected in Coerce */
|
||||||
if (!commit) {
|
if (!commit) {
|
||||||
/* no commit, revert to InSync if applicable */
|
/* no commit, revert to InSync if applicable */
|
||||||
if ((dib->p_status == DIB_Status_InSync) ||
|
if ((physBitmap->p_status == DIB_Status_InSync) ||
|
||||||
(dib->p_status == DIB_Status_AppMod)) {
|
(physBitmap->p_status == DIB_Status_AppMod)) {
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
|
||||||
dib->status = DIB_Status_InSync;
|
physBitmap->status = DIB_Status_InSync;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -4548,26 +4442,9 @@ static void X11DRV_DIB_Unlock(X_PHYSBITMAP *physBitmap, BOOL commit)
|
||||||
/* this case is ordinary only called from the signal handler,
|
/* this case is ordinary only called from the signal handler,
|
||||||
* so we don't bother to check for !commit */
|
* so we don't bother to check for !commit */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DIB_Status_AuxMod:
|
|
||||||
TRACE("Unlocking in status AuxMod\n" );
|
|
||||||
if (commit) {
|
|
||||||
/* DIB may need protection now */
|
|
||||||
if ((dib->p_status == DIB_Status_InSync) ||
|
|
||||||
(dib->p_status == DIB_Status_AppMod))
|
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
|
|
||||||
} else {
|
|
||||||
/* no commit, revert to previous state */
|
|
||||||
if (dib->p_status != DIB_Status_None)
|
|
||||||
dib->status = dib->p_status;
|
|
||||||
/* no protections changed */
|
|
||||||
}
|
|
||||||
dib->p_status = DIB_Status_None;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&(dib->lock));
|
LeaveCriticalSection(&physBitmap->lock);
|
||||||
TRACE("Unlocked %p\n", physBitmap->hbitmap);
|
TRACE("Unlocked %p\n", physBitmap->hbitmap);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -4663,7 +4540,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
|
||||||
{
|
{
|
||||||
HBITMAP res = 0;
|
HBITMAP res = 0;
|
||||||
X_PHYSBITMAP *physBitmap = NULL;
|
X_PHYSBITMAP *physBitmap = NULL;
|
||||||
X11DRV_DIBSECTION *dib = NULL;
|
DIBSECTION *dib = NULL;
|
||||||
int *colorMap = NULL;
|
int *colorMap = NULL;
|
||||||
int nColorMap;
|
int nColorMap;
|
||||||
RGBQUAD *colorTable = NULL;
|
RGBQUAD *colorTable = NULL;
|
||||||
|
@ -4740,60 +4617,56 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
|
||||||
}
|
}
|
||||||
/* Allocate Memory for DIB and fill structure */
|
/* Allocate Memory for DIB and fill structure */
|
||||||
if (bm.bmBits)
|
if (bm.bmBits)
|
||||||
dib = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(X11DRV_DIBSECTION));
|
dib = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dib));
|
||||||
if (dib)
|
if (dib)
|
||||||
{
|
{
|
||||||
dib->dibSection.dsBm = bm;
|
dib->dsBm = bm;
|
||||||
|
|
||||||
if (core_header)
|
if (core_header)
|
||||||
{
|
{
|
||||||
/* Convert the BITMAPCOREHEADER to a BITMAPINFOHEADER.
|
/* Convert the BITMAPCOREHEADER to a BITMAPINFOHEADER.
|
||||||
The structure is already filled with zeros */
|
The structure is already filled with zeros */
|
||||||
dib->dibSection.dsBmih.biSize = sizeof(BITMAPINFOHEADER);
|
dib->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
dib->dibSection.dsBmih.biWidth = width;
|
dib->dsBmih.biWidth = width;
|
||||||
dib->dibSection.dsBmih.biHeight = height;
|
dib->dsBmih.biHeight = height;
|
||||||
dib->dibSection.dsBmih.biPlanes = planes;
|
dib->dsBmih.biPlanes = planes;
|
||||||
dib->dibSection.dsBmih.biBitCount = bpp;
|
dib->dsBmih.biBitCount = bpp;
|
||||||
dib->dibSection.dsBmih.biCompression = compression;
|
dib->dsBmih.biCompression = compression;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Truncate extended bitmap headers (BITMAPV4HEADER etc.) */
|
/* Truncate extended bitmap headers (BITMAPV4HEADER etc.) */
|
||||||
dib->dibSection.dsBmih = *((BITMAPINFOHEADER*) bmi);
|
dib->dsBmih = *((BITMAPINFOHEADER*) bmi);
|
||||||
dib->dibSection.dsBmih.biSize = sizeof(BITMAPINFOHEADER);
|
dib->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
dib->dibSection.dsBmih.biSizeImage = totalSize;
|
dib->dsBmih.biSizeImage = totalSize;
|
||||||
colorPtr = (LPBYTE) bmi + (WORD) bmi->bmiHeader.biSize;
|
colorPtr = (LPBYTE) bmi + (WORD) bmi->bmiHeader.biSize;
|
||||||
|
|
||||||
/* Set dsBitfields values */
|
/* Set dsBitfields values */
|
||||||
if ( usage == DIB_PAL_COLORS || bpp <= 8)
|
if ( usage == DIB_PAL_COLORS || bpp <= 8)
|
||||||
{
|
{
|
||||||
dib->dibSection.dsBitfields[0] = dib->dibSection.dsBitfields[1] = dib->dibSection.dsBitfields[2] = 0;
|
dib->dsBitfields[0] = dib->dsBitfields[1] = dib->dsBitfields[2] = 0;
|
||||||
}
|
}
|
||||||
else switch( bpp )
|
else switch( bpp )
|
||||||
{
|
{
|
||||||
case 15:
|
case 15:
|
||||||
case 16:
|
case 16:
|
||||||
dib->dibSection.dsBitfields[0] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr ) : 0x7c00;
|
dib->dsBitfields[0] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr ) : 0x7c00;
|
||||||
dib->dibSection.dsBitfields[1] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 1) : 0x03e0;
|
dib->dsBitfields[1] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 1) : 0x03e0;
|
||||||
dib->dibSection.dsBitfields[2] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 2) : 0x001f;
|
dib->dsBitfields[2] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 2) : 0x001f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
case 32:
|
case 32:
|
||||||
dib->dibSection.dsBitfields[0] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr ) : 0xff0000;
|
dib->dsBitfields[0] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr ) : 0xff0000;
|
||||||
dib->dibSection.dsBitfields[1] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 1) : 0x00ff00;
|
dib->dsBitfields[1] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 1) : 0x00ff00;
|
||||||
dib->dibSection.dsBitfields[2] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 2) : 0x0000ff;
|
dib->dsBitfields[2] = (compression == BI_BITFIELDS) ? *((const DWORD *)colorPtr + 2) : 0x0000ff;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dib->dibSection.dshSection = section;
|
dib->dshSection = section;
|
||||||
dib->dibSection.dsOffset = offset;
|
dib->dsOffset = offset;
|
||||||
|
|
||||||
dib->status = DIB_Status_None;
|
|
||||||
dib->nColorMap = nColorMap;
|
|
||||||
dib->colorMap = colorMap;
|
|
||||||
dib->colorTable = colorTable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create Device Dependent Bitmap and add DIB pointer */
|
/* Create Device Dependent Bitmap and add DIB pointer */
|
||||||
|
@ -4805,10 +4678,13 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
BITMAPOBJ *bmp = GDI_GetObjPtr(res, BITMAP_MAGIC);
|
BITMAPOBJ *bmp = GDI_GetObjPtr(res, BITMAP_MAGIC);
|
||||||
if (bmp) bmp->dib = &dib->dibSection;
|
if (bmp) bmp->dib = dib;
|
||||||
GDI_ReleaseObj( res );
|
GDI_ReleaseObj( res );
|
||||||
physBitmap = X11DRV_init_phys_bitmap( res );
|
physBitmap = X11DRV_init_phys_bitmap( res );
|
||||||
physBitmap->dib = dib;
|
physBitmap->status = DIB_Status_None;
|
||||||
|
physBitmap->nColorMap = nColorMap;
|
||||||
|
physBitmap->colorMap = colorMap;
|
||||||
|
physBitmap->colorTable = colorTable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4818,16 +4694,16 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
|
||||||
wine_tsx11_lock();
|
wine_tsx11_lock();
|
||||||
#ifdef HAVE_LIBXXSHM
|
#ifdef HAVE_LIBXXSHM
|
||||||
if (XShmQueryExtension(gdi_display) &&
|
if (XShmQueryExtension(gdi_display) &&
|
||||||
(dib->image = X11DRV_XShmCreateImage( bm.bmWidth, effHeight,
|
(physBitmap->image = X11DRV_XShmCreateImage( bm.bmWidth, effHeight,
|
||||||
physBitmap->pixmap_depth, &dib->shminfo )) )
|
physBitmap->pixmap_depth, &physBitmap->shminfo )) )
|
||||||
{
|
{
|
||||||
; /* Created Image */
|
; /* Created Image */
|
||||||
} else {
|
} else {
|
||||||
dib->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, physBitmap->pixmap_depth );
|
physBitmap->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, physBitmap->pixmap_depth );
|
||||||
dib->shminfo.shmid = -1;
|
physBitmap->shminfo.shmid = -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
dib->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, physBitmap->pixmap_depth );
|
physBitmap->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, physBitmap->pixmap_depth );
|
||||||
#endif
|
#endif
|
||||||
wine_tsx11_unlock();
|
wine_tsx11_unlock();
|
||||||
}
|
}
|
||||||
|
@ -4845,7 +4721,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
|
||||||
VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL;
|
VirtualFree(bm.bmBits, 0L, MEM_RELEASE), bm.bmBits = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dib && dib->image) { XDestroyImage(dib->image); dib->image = NULL; }
|
if (dib && physBitmap->image) { XDestroyImage(physBitmap->image); physBitmap->image = NULL; }
|
||||||
HeapFree(GetProcessHeap(), 0, colorMap); colorMap = NULL;
|
HeapFree(GetProcessHeap(), 0, colorMap); colorMap = NULL;
|
||||||
HeapFree(GetProcessHeap(), 0, colorTable); colorTable = NULL;
|
HeapFree(GetProcessHeap(), 0, colorTable); colorTable = NULL;
|
||||||
HeapFree(GetProcessHeap(), 0, dib); dib = NULL;
|
HeapFree(GetProcessHeap(), 0, dib); dib = NULL;
|
||||||
|
@ -4855,11 +4731,11 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
|
||||||
{
|
{
|
||||||
extern BOOL VIRTUAL_SetFaultHandler(LPCVOID addr, BOOL (*proc)(LPVOID, LPCVOID), LPVOID arg);
|
extern BOOL VIRTUAL_SetFaultHandler(LPCVOID addr, BOOL (*proc)(LPVOID, LPCVOID), LPVOID arg);
|
||||||
/* Install fault handler, if possible */
|
/* Install fault handler, if possible */
|
||||||
InitializeCriticalSection(&(dib->lock));
|
InitializeCriticalSection(&physBitmap->lock);
|
||||||
if (VIRTUAL_SetFaultHandler(bm.bmBits, X11DRV_DIB_FaultHandler, physBitmap))
|
if (VIRTUAL_SetFaultHandler(bm.bmBits, X11DRV_DIB_FaultHandler, physBitmap))
|
||||||
{
|
{
|
||||||
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
|
||||||
if (dib) dib->status = DIB_Status_AppMod;
|
physBitmap->status = DIB_Status_AppMod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4871,34 +4747,31 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* X11DRV_DIB_DeleteDIBSection
|
* X11DRV_DIB_DeleteDIBSection
|
||||||
*/
|
*/
|
||||||
void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap)
|
void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap, DIBSECTION *dib)
|
||||||
{
|
{
|
||||||
X11DRV_DIBSECTION *dib = physBitmap->dib;
|
if (dib->dshSection)
|
||||||
|
|
||||||
if (dib->dibSection.dshSection)
|
|
||||||
X11DRV_DIB_Coerce(physBitmap, DIB_Status_InSync, FALSE);
|
X11DRV_DIB_Coerce(physBitmap, DIB_Status_InSync, FALSE);
|
||||||
|
|
||||||
if (dib->image)
|
if (physBitmap->image)
|
||||||
{
|
{
|
||||||
wine_tsx11_lock();
|
wine_tsx11_lock();
|
||||||
#ifdef HAVE_LIBXXSHM
|
#ifdef HAVE_LIBXXSHM
|
||||||
if (dib->shminfo.shmid != -1)
|
if (physBitmap->shminfo.shmid != -1)
|
||||||
{
|
{
|
||||||
XShmDetach (gdi_display, &(dib->shminfo));
|
XShmDetach( gdi_display, &(physBitmap->shminfo) );
|
||||||
XDestroyImage (dib->image);
|
XDestroyImage( physBitmap->image );
|
||||||
shmdt (dib->shminfo.shmaddr);
|
shmdt( physBitmap->shminfo.shmaddr );
|
||||||
dib->shminfo.shmid = -1;
|
physBitmap->shminfo.shmid = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
XDestroyImage( dib->image );
|
XDestroyImage( physBitmap->image );
|
||||||
wine_tsx11_unlock();
|
wine_tsx11_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, dib->colorMap);
|
HeapFree(GetProcessHeap(), 0, physBitmap->colorMap);
|
||||||
HeapFree(GetProcessHeap(), 0, dib->colorTable);
|
HeapFree(GetProcessHeap(), 0, physBitmap->colorTable);
|
||||||
|
DeleteCriticalSection(&physBitmap->lock);
|
||||||
DeleteCriticalSection(&(dib->lock));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -4906,25 +4779,25 @@ void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap)
|
||||||
*/
|
*/
|
||||||
UINT X11DRV_SetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, const RGBQUAD *colors )
|
UINT X11DRV_SetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, const RGBQUAD *colors )
|
||||||
{
|
{
|
||||||
X11DRV_DIBSECTION *dib;
|
DIBSECTION dib;
|
||||||
UINT ret = 0;
|
UINT ret = 0;
|
||||||
X_PHYSBITMAP *physBitmap = physDev->bitmap;
|
X_PHYSBITMAP *physBitmap = physDev->bitmap;
|
||||||
|
|
||||||
if (!physBitmap) return 0;
|
if (!physBitmap) return 0;
|
||||||
dib = physBitmap->dib;
|
GetObjectW( physBitmap->hbitmap, sizeof(dib), &dib );
|
||||||
|
|
||||||
if (dib && dib->colorMap && start < dib->nColorMap) {
|
if (physBitmap->colorMap && start < physBitmap->nColorMap) {
|
||||||
UINT end = count + start;
|
UINT end = count + start;
|
||||||
if (end > dib->nColorMap) end = dib->nColorMap;
|
if (end > physBitmap->nColorMap) end = physBitmap->nColorMap;
|
||||||
/*
|
/*
|
||||||
* Changing color table might change the mapping between
|
* Changing color table might change the mapping between
|
||||||
* DIB colors and X11 colors and thus alter the visible state
|
* DIB colors and X11 colors and thus alter the visible state
|
||||||
* of the bitmap object.
|
* of the bitmap object.
|
||||||
*/
|
*/
|
||||||
X11DRV_DIB_Lock( physBitmap, DIB_Status_AppMod, FALSE );
|
X11DRV_DIB_Lock( physBitmap, DIB_Status_AppMod, FALSE );
|
||||||
memcpy(dib->colorTable + start, colors, (end - start) * sizeof(RGBQUAD));
|
memcpy(physBitmap->colorTable + start, colors, (end - start) * sizeof(RGBQUAD));
|
||||||
X11DRV_DIB_GenColorMap( physDev, dib->colorMap, DIB_RGB_COLORS,
|
X11DRV_DIB_GenColorMap( physDev, physBitmap->colorMap, DIB_RGB_COLORS,
|
||||||
dib->dibSection.dsBm.bmBitsPixel,
|
dib.dsBm.bmBitsPixel,
|
||||||
TRUE, colors, start, end );
|
TRUE, colors, start, end );
|
||||||
X11DRV_DIB_Unlock( physBitmap, TRUE );
|
X11DRV_DIB_Unlock( physBitmap, TRUE );
|
||||||
ret = end - start;
|
ret = end - start;
|
||||||
|
@ -4937,16 +4810,12 @@ UINT X11DRV_SetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, c
|
||||||
*/
|
*/
|
||||||
UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, RGBQUAD *colors )
|
UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, RGBQUAD *colors )
|
||||||
{
|
{
|
||||||
X11DRV_DIBSECTION *dib;
|
|
||||||
UINT ret = 0;
|
UINT ret = 0;
|
||||||
X_PHYSBITMAP *physBitmap = physDev->bitmap;
|
X_PHYSBITMAP *physBitmap = physDev->bitmap;
|
||||||
|
|
||||||
if (!physBitmap) return 0;
|
if (physBitmap && physBitmap->colorTable && start < physBitmap->nColorMap) {
|
||||||
dib = physBitmap->dib;
|
if (start + count > physBitmap->nColorMap) count = physBitmap->nColorMap - start;
|
||||||
|
memcpy(colors, physBitmap->colorTable + start, count * sizeof(RGBQUAD));
|
||||||
if (dib && dib->colorTable && start < dib->nColorMap) {
|
|
||||||
if (start + count > dib->nColorMap) count = dib->nColorMap - start;
|
|
||||||
memcpy(colors, dib->colorTable + start, count * sizeof(RGBQUAD));
|
|
||||||
ret = count;
|
ret = count;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -84,7 +84,16 @@ typedef struct
|
||||||
HBITMAP hbitmap;
|
HBITMAP hbitmap;
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
int pixmap_depth;
|
int pixmap_depth;
|
||||||
struct _X11DRV_DIBSECTION *dib;
|
/* the following fields are only used for DIB section bitmaps */
|
||||||
|
int status, p_status; /* mapping status */
|
||||||
|
XImage *image; /* cached XImage */
|
||||||
|
int *colorMap; /* color map info */
|
||||||
|
int nColorMap;
|
||||||
|
RGBQUAD *colorTable; /* original dib color table converted to rgb values if usage was DIB_PAL_COLORS */
|
||||||
|
CRITICAL_SECTION lock; /* GDI access lock */
|
||||||
|
#ifdef HAVE_LIBXXSHM
|
||||||
|
XShmSegmentInfo shminfo; /* shared memory segment info */
|
||||||
|
#endif
|
||||||
} X_PHYSBITMAP;
|
} X_PHYSBITMAP;
|
||||||
|
|
||||||
/* X physical font */
|
/* X physical font */
|
||||||
|
@ -261,7 +270,7 @@ extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event );
|
||||||
/* exported dib functions for now */
|
/* exported dib functions for now */
|
||||||
|
|
||||||
/* DIB Section sync state */
|
/* DIB Section sync state */
|
||||||
enum { DIB_Status_None, DIB_Status_InSync, DIB_Status_GdiMod, DIB_Status_AppMod, DIB_Status_AuxMod };
|
enum { DIB_Status_None, DIB_Status_InSync, DIB_Status_GdiMod, DIB_Status_AppMod };
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void (*Convert_5x5_asis)(int width, int height,
|
void (*Convert_5x5_asis)(int width, int height,
|
||||||
|
@ -402,7 +411,7 @@ extern void X11DRV_UnlockDIBSection(X11DRV_PDEVICE *physDev,BOOL);
|
||||||
|
|
||||||
extern HBITMAP X11DRV_DIB_CreateDIBSection(X11DRV_PDEVICE *physDev, const BITMAPINFO *bmi, UINT usage,
|
extern HBITMAP X11DRV_DIB_CreateDIBSection(X11DRV_PDEVICE *physDev, const BITMAPINFO *bmi, UINT usage,
|
||||||
VOID **bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
|
VOID **bits, HANDLE section, DWORD offset, DWORD ovr_pitch);
|
||||||
extern void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap);
|
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,
|
||||||
DWORD width, DWORD height);
|
DWORD width, DWORD height);
|
||||||
|
|
Loading…
Reference in New Issue