*/
HBITMAP X11DRV_SelectBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap )
{
- BITMAPOBJ *bmp;
-
- if (!(bmp = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) return 0;
+ int depth;
if(physDev->xrender)
X11DRV_XRender_UpdateDrawable( physDev );
if (hbitmap == BITMAP_stock_bitmap)
+ {
physDev->drawable = BITMAP_stock_pixmap;
+ depth = 1;
+ }
else
- physDev->drawable = X11DRV_get_pixmap( hbitmap );
+ {
+ X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
+ if (!physBitmap) return 0;
+ physDev->drawable = physBitmap->pixmap;
+ depth = physBitmap->pixmap_depth;
+ }
/* Change GC depth if needed */
- if (physDev->depth != bmp->bitmap.bmBitsPixel)
+ if (physDev->depth != depth)
{
- physDev->depth = bmp->bitmap.bmBitsPixel;
+ physDev->depth = depth;
wine_tsx11_lock();
XFreeGC( gdi_display, physDev->gc );
physDev->gc = XCreateGC( gdi_display, physDev->drawable, 0, NULL );
XFlush( gdi_display );
wine_tsx11_unlock();
}
- GDI_ReleaseObj( hbitmap );
return hbitmap;
}
TRACE("(%p) %dx%d %d bpp\n", hbitmap, bmp->bitmap.bmWidth,
bmp->bitmap.bmHeight, bmp->bitmap.bmBitsPixel);
- if (!(physBitmap = HeapAlloc( GetProcessHeap(), 0, sizeof(*physBitmap) ))) goto done;
+ if (!(physBitmap = X11DRV_init_phys_bitmap( hbitmap ))) goto done;
/* Create the pixmap */
wine_tsx11_lock();
*/
LONG X11DRV_GetBitmapBits( HBITMAP hbitmap, void *buffer, LONG count )
{
- BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
+ BITMAP bitmap;
+ X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
LONG old_height, height;
- Pixmap pixmap = X11DRV_get_pixmap( hbitmap );
XImage *image;
LPBYTE tbuf, startline;
int h, w;
- if (!bmp) return 0;
- TRACE("(bmp=%p, buffer=%p, count=0x%lx)\n", bmp, buffer, count);
+ if (!physBitmap || !GetObjectW( hbitmap, sizeof(bitmap), &bitmap )) return 0;
+
+ TRACE("(bmp=%p, buffer=%p, count=0x%lx)\n", hbitmap, buffer, count);
wine_tsx11_lock();
/* Hack: change the bitmap height temporarily to avoid */
/* getting unnecessary bitmap rows. */
- old_height = bmp->bitmap.bmHeight;
- height = bmp->bitmap.bmHeight = count / bmp->bitmap.bmWidthBytes;
+ old_height = bitmap.bmHeight;
+ height = bitmap.bmHeight = count / bitmap.bmWidthBytes;
- image = XGetImage( gdi_display, pixmap, 0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
- AllPlanes, ZPixmap );
- bmp->bitmap.bmHeight = old_height;
+ image = XGetImage( gdi_display, physBitmap->pixmap, 0, 0,
+ bitmap.bmWidth, bitmap.bmHeight, AllPlanes, ZPixmap );
+ bitmap.bmHeight = old_height;
/* copy XImage to 16 bit padded image buffer with real bitsperpixel */
startline = buffer;
- switch (bmp->bitmap.bmBitsPixel)
+ switch (physBitmap->pixmap_depth)
{
case 1:
for (h=0;h<height;h++)
{
tbuf = startline;
*tbuf = 0;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
if ((w%8) == 0)
*tbuf = 0;
*tbuf |= XGetPixel(image,w,h)<<(7-(w&7));
if ((w&7) == 7) ++tbuf;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 4:
for (h=0;h<height;h++)
{
tbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
if (!(w & 1)) *tbuf = XGetPixel( image, w, h) << 4;
else *tbuf++ |= XGetPixel( image, w, h) & 0x0f;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 8:
for (h=0;h<height;h++)
{
tbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
*tbuf++ = XGetPixel(image,w,h);
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 15:
for (h=0;h<height;h++)
{
tbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
long pixel = XGetPixel(image,w,h);
*tbuf++ = pixel & 0xff;
*tbuf++ = (pixel>>8) & 0xff;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 24:
for (h=0;h<height;h++)
{
tbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
long pixel = XGetPixel(image,w,h);
*tbuf++ = (pixel>> 8) & 0xff;
*tbuf++ = (pixel>>16) & 0xff;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
for (h=0;h<height;h++)
{
tbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
long pixel = XGetPixel(image,w,h);
*tbuf++ = (pixel>>16) & 0xff;
*tbuf++ = (pixel>>24) & 0xff;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
default:
- FIXME("Unhandled bits:%d\n", bmp->bitmap.bmBitsPixel);
+ FIXME("Unhandled bits:%d\n", physBitmap->pixmap_depth);
}
XDestroyImage( image );
wine_tsx11_unlock();
- GDI_ReleaseObj( hbitmap );
return count;
}
*/
LONG X11DRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count )
{
- BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
- Pixmap pixmap = X11DRV_get_pixmap( hbitmap );
+ BITMAP bitmap;
+ X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
LONG height;
XImage *image;
const BYTE *sbuf, *startline;
int w, h;
- if (!bmp) return 0;
- TRACE("(bmp=%p, bits=%p, count=0x%lx)\n", bmp, bits, count);
+ if (!physBitmap || !GetObjectW( hbitmap, sizeof(bitmap), &bitmap )) return 0;
+
+ TRACE("(bmp=%p, bits=%p, count=0x%lx)\n", hbitmap, bits, count);
- height = count / bmp->bitmap.bmWidthBytes;
+ height = count / bitmap.bmWidthBytes;
wine_tsx11_lock();
- image = XCreateImage( gdi_display, visual, bmp->bitmap.bmBitsPixel, ZPixmap, 0, NULL,
- bmp->bitmap.bmWidth, height, 32, 0 );
- if (!(image->data = (LPBYTE)malloc(image->bytes_per_line * height)))
+ image = XCreateImage( gdi_display, visual, physBitmap->pixmap_depth, ZPixmap, 0, NULL,
+ bitmap.bmWidth, height, 32, 0 );
+ if (!(image->data = malloc(image->bytes_per_line * height)))
{
WARN("No memory to create image data.\n");
XDestroyImage( image );
wine_tsx11_unlock();
- GDI_ReleaseObj( hbitmap );
return 0;
}
startline = bits;
- switch (bmp->bitmap.bmBitsPixel)
+ switch (physBitmap->pixmap_depth)
{
case 1:
for (h=0;h<height;h++)
{
sbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
XPutPixel(image,w,h,(sbuf[0]>>(7-(w&7))) & 1);
if ((w&7) == 7)
sbuf++;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 4:
for (h=0;h<height;h++)
{
sbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
if (!(w & 1)) XPutPixel( image, w, h, *sbuf >> 4 );
else XPutPixel( image, w, h, *sbuf++ & 0xf );
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 8:
for (h=0;h<height;h++)
{
sbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
XPutPixel(image,w,h,*sbuf++);
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 15:
for (h=0;h<height;h++)
{
sbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
XPutPixel(image,w,h,sbuf[1]*256+sbuf[0]);
sbuf+=2;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 24:
for (h=0;h<height;h++)
{
sbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
XPutPixel(image,w,h,(sbuf[2]<<16)+(sbuf[1]<<8)+sbuf[0]);
sbuf += 3;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
case 32:
for (h=0;h<height;h++)
{
sbuf = startline;
- for (w=0;w<bmp->bitmap.bmWidth;w++)
+ for (w=0;w<bitmap.bmWidth;w++)
{
XPutPixel(image,w,h,(sbuf[3]<<24)+(sbuf[2]<<16)+(sbuf[1]<<8)+sbuf[0]);
sbuf += 4;
}
- startline += bmp->bitmap.bmWidthBytes;
+ startline += bitmap.bmWidthBytes;
}
break;
default:
- FIXME("Unhandled bits:%d\n", bmp->bitmap.bmBitsPixel);
+ FIXME("Unhandled bits:%d\n", physBitmap->pixmap_depth);
}
- XPutImage( gdi_display, pixmap, BITMAP_GC(bmp),
- image, 0, 0, 0, 0, bmp->bitmap.bmWidth, height );
+ XPutImage( gdi_display, physBitmap->pixmap, BITMAP_GC(physBitmap),
+ image, 0, 0, 0, 0, bitmap.bmWidth, height );
XDestroyImage( image ); /* frees image->data too */
wine_tsx11_unlock();
- GDI_ReleaseObj( hbitmap );
return count;
}
if (physBitmap)
{
- if (bmp->dib) X11DRV_DIB_DeleteDIBSection( physBitmap, bmp );
+ if (physBitmap->dib) X11DRV_DIB_DeleteDIBSection( physBitmap, bmp );
wine_tsx11_lock();
if (physBitmap->pixmap) XFreePixmap( gdi_display, physBitmap->pixmap );
wine_tsx11_unlock();
/***********************************************************************
- * X11DRV_set_pixmap
+ * X11DRV_init_phys_bitmap
*
- * Set the pixmap associated to a bitmap, and return the previous one.
+ * Initialize the X physical bitmap info if necessary.
*/
-Pixmap X11DRV_set_pixmap( HBITMAP hbitmap, Pixmap pixmap )
+X_PHYSBITMAP *X11DRV_init_phys_bitmap( HBITMAP hbitmap )
{
- Pixmap ret = 0;
- X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
-
- if (physBitmap)
+ X_PHYSBITMAP *ret = NULL;
+ BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
+ if (bmp)
{
- ret = physBitmap->pixmap;
- physBitmap->pixmap = pixmap;
+ if (!(ret = bmp->physBitmap))
+ {
+ if ((ret = HeapAlloc( GetProcessHeap(), 0, sizeof(*ret) )) != NULL)
+ {
+ ret->pixmap = 0;
+ ret->pixmap_depth = bmp->bitmap.bmBitsPixel;
+ ret->dib = NULL;
+ bmp->physBitmap = ret;
+ }
+ }
+ GDI_ReleaseObj( hbitmap );
}
return ret;
}
descr.image = NULL;
descr.palentry = NULL;
descr.lines = tmpheight >= 0 ? lines : -lines;
- descr.depth = bmp->bitmap.bmBitsPixel;
+ descr.depth = physBitmap->pixmap_depth;
descr.drawable = physBitmap->pixmap;
- descr.gc = BITMAP_GC(bmp);
+ descr.gc = BITMAP_GC(physBitmap);
descr.xSrc = 0;
descr.ySrc = 0;
descr.xDest = 0;
if (!physBitmap) return 0;
if (!(bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) return 0;
- dib = (X11DRV_DIBSECTION *) bmp->dib;
+ dib = physBitmap->dib;
bitmap_type = DIB_GetBitmapInfo( (BITMAPINFOHEADER*) info, &descr.infoWidth, &tempHeight, &descr.infoBpp, &descr.compression);
descr.lines = tempHeight;
descr.bits = bits;
descr.image = NULL;
descr.lines = lines;
- descr.depth = bmp->bitmap.bmBitsPixel;
+ descr.depth = physBitmap->pixmap_depth;
descr.drawable = physBitmap->pixmap;
- descr.gc = BITMAP_GC(bmp);
+ descr.gc = BITMAP_GC(physBitmap);
descr.width = bmp->bitmap.bmWidth;
descr.height = bmp->bitmap.bmHeight;
descr.xDest = 0;
/***********************************************************************
* DIB_DoProtectDIBSection
*/
-static void X11DRV_DIB_DoProtectDIBSection( BITMAPOBJ *bmp, DWORD new_prot )
+static void X11DRV_DIB_DoProtectDIBSection( X_PHYSBITMAP *physBitmap, DWORD new_prot )
{
DWORD old_prot;
INT totalSize;
- DIBSECTION *dib = bmp->dib;
+ DIBSECTION *dib = &physBitmap->dib->dibSection;
INT effHeight = dib->dsBm.bmHeight >= 0? dib->dsBm.bmHeight
: -dib->dsBm.bmHeight;
}
/***********************************************************************
- * X11DRV_DIB_DoUpdateDIBSection
+ * X11DRV_DIB_DoCopyDIBSection
*/
-static void X11DRV_DIB_DoCopyDIBSection(BITMAPOBJ *bmp, BOOL toDIB,
+static void X11DRV_DIB_DoCopyDIBSection(X_PHYSBITMAP *physBitmap, BOOL toDIB,
void *colorMap, int nColorMap,
Drawable dest,
DWORD xSrc, DWORD ySrc,
DWORD xDest, DWORD yDest,
DWORD width, DWORD height)
{
- X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
+ X11DRV_DIBSECTION *dib = physBitmap->dib;
X11DRV_DIB_IMAGEBITS_DESCR descr;
int identity[2] = {0,1};
descr.colorMap = colorMap;
descr.nColorMap = nColorMap;
descr.bits = dib->dibSection.dsBm.bmBits;
- descr.depth = bmp->bitmap.bmBitsPixel;
+ descr.depth = physBitmap->pixmap_depth;
if(descr.infoBpp == 1)
descr.colorMap = (void*)identity;
/* Hack for now */
descr.drawable = dest;
- descr.gc = BITMAP_GC(bmp);
+ descr.gc = BITMAP_GC(physBitmap);
descr.xSrc = xSrc;
descr.ySrc = ySrc;
descr.xDest = xDest;
DWORD xSrc, DWORD ySrc, DWORD xDest, DWORD yDest,
DWORD width, DWORD height)
{
- BITMAPOBJ *bmp;
+ DIBSECTION dib;
HBITMAP hBitmap;
+ X_PHYSBITMAP *physBitmap;
int nColorMap = 0, *colorMap = NULL, aColorMap = FALSE;
TRACE("(%p,%p,%ld,%ld,%ld,%ld,%ld,%ld)\n", physDevSrc->hdc, physDevDst->hdc,
}
hBitmap = GetCurrentObject( physDevSrc->hdc, OBJ_BITMAP );
- bmp = (BITMAPOBJ *)GDI_GetObjPtr( hBitmap, BITMAP_MAGIC );
- if (!(bmp && bmp->dib)) {
+ physBitmap = X11DRV_get_phys_bitmap( hBitmap );
+ if (!physBitmap || GetObjectW( hBitmap, sizeof(dib), &dib ) != sizeof(dib))
+ {
ERR("called for non-DIBSection!?\n");
- GDI_ReleaseObj( hBitmap );
return;
}
/* while BitBlt should already have made sure we only get
* positive values, we should check for oversize values */
- if ((xSrc < bmp->bitmap.bmWidth) &&
- (ySrc < bmp->bitmap.bmHeight)) {
- if (xSrc + width > bmp->bitmap.bmWidth)
- width = bmp->bitmap.bmWidth - xSrc;
- if (ySrc + height > bmp->bitmap.bmHeight)
- height = bmp->bitmap.bmHeight - ySrc;
+ if ((xSrc < dib.dsBm.bmWidth) &&
+ (ySrc < dib.dsBm.bmHeight)) {
+ if (xSrc + width > dib.dsBm.bmWidth)
+ width = dib.dsBm.bmWidth - xSrc;
+ if (ySrc + height > dib.dsBm.bmHeight)
+ height = dib.dsBm.bmHeight - ySrc;
/* if the source bitmap is 8bpp or less, we're supposed to use the
* DC's palette for color conversion (not the DIB color table) */
- if (bmp->dib->dsBm.bmBitsPixel <= 8) {
- X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
+ if (dib.dsBm.bmBitsPixel <= 8) {
HPALETTE hPalette = GetCurrentObject( physDevSrc->hdc, OBJ_PAL );
if (!hPalette || (hPalette == GetStockObject(DEFAULT_PALETTE))) {
/* HACK: no palette has been set in the source DC,
* use the DIB colormap instead - this is necessary in some
* cases since we need to do depth conversion in some places
* where real Windows can just copy data straight over */
- colorMap = dib->colorMap;
- nColorMap = dib->nColorMap;
+ colorMap = physBitmap->dib->colorMap;
+ nColorMap = physBitmap->dib->nColorMap;
} else {
colorMap = X11DRV_DIB_BuildColorMap( physDevSrc, (WORD)-1,
- bmp->dib->dsBm.bmBitsPixel,
- (BITMAPINFO*)&(bmp->dib->dsBmih),
+ dib.dsBm.bmBitsPixel,
+ (BITMAPINFO*)&dib.dsBmih,
&nColorMap );
if (colorMap) aColorMap = TRUE;
}
}
/* perform the copy */
- X11DRV_DIB_DoCopyDIBSection(bmp, FALSE, colorMap, nColorMap,
+ X11DRV_DIB_DoCopyDIBSection(physBitmap, FALSE, colorMap, nColorMap,
physDevDst->drawable, xSrc, ySrc,
physDevDst->org.x + xDest, physDevDst->org.y + yDest,
width, height);
if (aColorMap)
HeapFree(GetProcessHeap(), 0, colorMap);
}
- GDI_ReleaseObj( hBitmap );
}
/***********************************************************************
*/
static void X11DRV_DIB_DoUpdateDIBSection(X_PHYSBITMAP *physBitmap, BITMAPOBJ *bmp, BOOL toDIB)
{
- X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
- X11DRV_DIB_DoCopyDIBSection(bmp, toDIB, dib->colorMap, dib->nColorMap,
+ X11DRV_DIB_DoCopyDIBSection(physBitmap, toDIB,
+ physBitmap->dib->colorMap, physBitmap->dib->nColorMap,
physBitmap->pixmap, 0, 0, 0, 0,
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight);
}
*/
static INT X11DRV_DIB_Coerce(X_PHYSBITMAP *physBitmap, BITMAPOBJ *bmp, INT req, BOOL lossy)
{
- X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
+ X11DRV_DIBSECTION *dib = physBitmap->dib;
INT ret = DIB_Status_None;
if (dib) {
case DIB_Status_InSync:
TRACE("GdiMod requested in status InSync\n" );
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_NOACCESS );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
dib->status = DIB_Status_GdiMod;
dib->p_status = DIB_Status_InSync;
break;
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( bmp, PAGE_NOACCESS );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
break;
}
/* fall through if copy_aux() had to change to AppMod state */
TRACE("GdiMod requested in status AppMod\n" );
if (!lossy) {
/* make it readonly to avoid app changing data while we copy */
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
X11DRV_DIB_DoUpdateDIBSection( physBitmap, bmp, FALSE );
}
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_NOACCESS );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
dib->p_status = DIB_Status_AppMod;
dib->status = DIB_Status_GdiMod;
break;
TRACE("InSync requested in status AuxMod\n" );
if (lossy) dib->status = DIB_Status_InSync;
else {
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
(*dib->copy_aux)(dib->aux_ctx, DIB_Status_InSync);
}
if (dib->status != DIB_Status_GdiMod) {
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
break;
}
/* fall through if copy_aux() had to change to GdiMod state */
case DIB_Status_GdiMod:
TRACE("InSync requested in status GdiMod\n" );
if (!lossy) {
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
X11DRV_DIB_DoUpdateDIBSection( physBitmap, bmp, TRUE );
}
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
dib->status = DIB_Status_InSync;
break;
case DIB_Status_AuxMod:
TRACE("AppMod requested in status AuxMod\n" );
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
+ 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)
case DIB_Status_GdiMod:
TRACE("AppMod requested in status GdiMod\n" );
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
if (!lossy) X11DRV_DIB_DoUpdateDIBSection( physBitmap, bmp, TRUE );
dib->status = DIB_Status_AppMod;
break;
case DIB_Status_InSync:
TRACE("AppMod requested in status InSync\n" );
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
dib->status = DIB_Status_AppMod;
break;
*/
static INT X11DRV_DIB_Lock(X_PHYSBITMAP *physBitmap, BITMAPOBJ *bmp, INT req, BOOL lossy)
{
- X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
+ X11DRV_DIBSECTION *dib = physBitmap->dib;
INT ret = DIB_Status_None;
if (dib) {
*/
static void X11DRV_DIB_Unlock(X_PHYSBITMAP *physBitmap, BITMAPOBJ *bmp, BOOL commit)
{
- X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
+ X11DRV_DIBSECTION *dib = physBitmap->dib;
if (dib) {
switch (dib->status)
/* no commit, revert to InSync if applicable */
if ((dib->p_status == DIB_Status_InSync) ||
(dib->p_status == DIB_Status_AppMod)) {
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READONLY );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READONLY );
dib->status = DIB_Status_InSync;
}
}
/* DIB may need protection now */
if ((dib->p_status == DIB_Status_InSync) ||
(dib->p_status == DIB_Status_AppMod))
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_NOACCESS );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_NOACCESS );
} else {
/* no commit, revert to previous state */
if (dib->p_status != DIB_Status_None)
DWORD offset, DWORD ovr_pitch)
{
HBITMAP res = 0;
- BITMAPOBJ *bmp = NULL;
+ X_PHYSBITMAP *physBitmap = NULL;
X11DRV_DIBSECTION *dib = NULL;
int *colorMap = NULL;
int nColorMap;
res = CreateBitmap(width, effHeight, 1, depth, NULL);
if (res)
- {
- bmp = (BITMAPOBJ *) GDI_GetObjPtr(res, BITMAP_MAGIC);
- if (bmp) bmp->dib = (DIBSECTION *) dib;
- }
+ {
+ BITMAPOBJ *bmp = GDI_GetObjPtr(res, BITMAP_MAGIC);
+ if (bmp) bmp->dib = &dib->dibSection;
+ GDI_ReleaseObj( res );
+ physBitmap = X11DRV_init_phys_bitmap( res );
+ physBitmap->dib = dib;
+ }
}
/* Create XImage */
- if (dib && bmp)
+ if (dib && physBitmap)
{
wine_tsx11_lock();
#ifdef HAVE_LIBXXSHM
if (XShmQueryExtension(gdi_display) &&
(dib->image = X11DRV_XShmCreateImage( bm.bmWidth, effHeight,
- bmp->bitmap.bmBitsPixel, &dib->shminfo )) )
+ physBitmap->pixmap_depth, &dib->shminfo )) )
{
; /* Created Image */
} else {
- dib->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, bmp->bitmap.bmBitsPixel );
+ dib->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, physBitmap->pixmap_depth );
dib->shminfo.shmid = -1;
}
#else
- dib->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, bmp->bitmap.bmBitsPixel );
+ dib->image = X11DRV_DIB_CreateXImage( bm.bmWidth, effHeight, physBitmap->pixmap_depth );
#endif
wine_tsx11_unlock();
}
/* Clean up in case of errors */
- if (!res || !bmp || !dib || !bm.bmBits || (bm.bmBitsPixel <= 8 && !colorMap))
+ if (!res || !physBitmap || !dib || !bm.bmBits || (bm.bmBitsPixel <= 8 && !colorMap))
{
TRACE("got an error res=%p, bmp=%p, dib=%p, bm.bmBits=%p\n",
- res, bmp, dib, bm.bmBits);
+ res, physBitmap, dib, bm.bmBits);
if (bm.bmBits)
{
if (section)
HeapFree(GetProcessHeap(), 0, colorMap); colorMap = NULL;
HeapFree(GetProcessHeap(), 0, colorTable); colorTable = NULL;
HeapFree(GetProcessHeap(), 0, dib); dib = NULL;
- if (bmp) { GDI_ReleaseObj(res); bmp = NULL; }
if (res) { DeleteObject(res); res = 0; }
}
else if (bm.bmBits)
InitializeCriticalSection(&(dib->lock));
if (VIRTUAL_SetFaultHandler(bm.bmBits, X11DRV_DIB_FaultHandler, (LPVOID)res))
{
- X11DRV_DIB_DoProtectDIBSection( bmp, PAGE_READWRITE );
+ X11DRV_DIB_DoProtectDIBSection( physBitmap, PAGE_READWRITE );
if (dib) dib->status = DIB_Status_AppMod;
}
}
/* Return BITMAP handle and storage location */
- if (bmp) GDI_ReleaseObj(res);
if (bm.bmBits && bits) *bits = bm.bmBits;
return res;
}
*/
void X11DRV_DIB_DeleteDIBSection(X_PHYSBITMAP *physBitmap, BITMAPOBJ *bmp)
{
- X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
+ X11DRV_DIBSECTION *dib = physBitmap->dib;
if (dib->dibSection.dshSection)
X11DRV_DIB_Coerce(physBitmap, bmp, DIB_Status_InSync, FALSE);
if (!physBitmap) return 0;
if (!(bmp = (BITMAPOBJ*)GDI_GetObjPtr( hBitmap, BITMAP_MAGIC ))) return 0;
- dib = (X11DRV_DIBSECTION *) bmp->dib;
+ dib = physBitmap->dib;
if (dib && dib->colorMap && start < dib->nColorMap) {
UINT end = count + start;
*/
UINT X11DRV_GetDIBColorTable( X11DRV_PDEVICE *physDev, UINT start, UINT count, RGBQUAD *colors )
{
- BITMAPOBJ * bmp;
X11DRV_DIBSECTION *dib;
UINT ret = 0;
HBITMAP hBitmap = GetCurrentObject( physDev->hdc, OBJ_BITMAP );
+ X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hBitmap );
- if (!(bmp = (BITMAPOBJ*)GDI_GetObjPtr( hBitmap, BITMAP_MAGIC ))) return 0;
- dib = (X11DRV_DIBSECTION *) bmp->dib;
+ if (!physBitmap) return 0;
+ dib = physBitmap->dib;
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;
}
- GDI_ReleaseObj( hBitmap );
return ret;
}
HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc)
{
HDC hdcMem;
- Pixmap old_pixmap;
+ X_PHYSBITMAP *physBitmap;
HBITMAP hBmp = 0, old;
HGLOBAL hPackedDIB = 0;
Window root;
hdcMem = CreateCompatibleDC( hdc );
old = SelectObject( hdcMem, hBmp );
- old_pixmap = X11DRV_set_pixmap( hBmp, pixmap );
+ physBitmap = X11DRV_get_phys_bitmap( hBmp );
+
wine_tsx11_lock();
- if (old_pixmap) XFreePixmap( gdi_display, old_pixmap );
+ if (physBitmap->pixmap) XFreePixmap( gdi_display, physBitmap->pixmap );
+ physBitmap->pixmap = pixmap;
wine_tsx11_unlock();
SelectObject( hdcMem, old );
Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc )
{
Pixmap pixmap;
+ X_PHYSBITMAP *physBitmap;
HBITMAP hBmp;
LPBITMAPINFO pbmi;
GlobalUnlock(hPackedDIB);
/* clear the physBitmap so that we can steal its pixmap */
- pixmap = X11DRV_set_pixmap( hBmp, 0 );
+ physBitmap = X11DRV_get_phys_bitmap( hBmp );
+ pixmap = physBitmap->pixmap;
+ physBitmap->pixmap = 0;
/* Delete the DDB we created earlier now that we have stolen its pixmap */
DeleteObject(hBmp);