Commit a08e2cf1 authored by Alexandre Julliard's avatar Alexandre Julliard

Merged DDBitmap and physBitmap into the generic bitmap structure

(suggested by Andrew Lewycky).
parent 199aebaa
...@@ -24,19 +24,13 @@ TTYDRV_PHYSBITMAP *TTYDRV_DC_AllocBitmap(BITMAPOBJ *bitmap) ...@@ -24,19 +24,13 @@ TTYDRV_PHYSBITMAP *TTYDRV_DC_AllocBitmap(BITMAPOBJ *bitmap)
{ {
TTYDRV_PHYSBITMAP *physBitmap; TTYDRV_PHYSBITMAP *physBitmap;
if(!(bitmap->DDBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(DDBITMAP)))) {
ERR("Can't alloc DDBITMAP\n");
return NULL;
}
if(!(physBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(TTYDRV_PHYSBITMAP)))) { if(!(physBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(TTYDRV_PHYSBITMAP)))) {
ERR("Can't alloc TTYDRV_PHYSBITMAP\n"); ERR("Can't alloc TTYDRV_PHYSBITMAP\n");
HeapFree(GetProcessHeap(), 0, bitmap->DDBitmap);
return NULL; return NULL;
} }
bitmap->DDBitmap->physBitmap = physBitmap; bitmap->physBitmap = physBitmap;
bitmap->DDBitmap->funcs = DRIVER_FindDriver("DISPLAY"); bitmap->funcs = DRIVER_FindDriver("DISPLAY");
return physBitmap; return physBitmap;
} }
...@@ -102,9 +96,9 @@ BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap) ...@@ -102,9 +96,9 @@ BOOL TTYDRV_DC_BITMAP_DeleteObject(HBITMAP hbitmap, BITMAPOBJ *bitmap)
{ {
TRACE("(0x%04x, %p)\n", hbitmap, bitmap); TRACE("(0x%04x, %p)\n", hbitmap, bitmap);
HeapFree(GetProcessHeap(), 0, bitmap->DDBitmap->physBitmap); HeapFree(GetProcessHeap(), 0, bitmap->physBitmap);
HeapFree(GetProcessHeap(), 0, bitmap->DDBitmap); bitmap->physBitmap = NULL;
bitmap->DDBitmap = NULL; bitmap->funcs = NULL;
return TRUE; return TRUE;
} }
...@@ -134,10 +128,10 @@ HBITMAP TTYDRV_DC_BITMAP_SelectObject(DC *dc, HBITMAP hbitmap, BITMAPOBJ *bitmap ...@@ -134,10 +128,10 @@ HBITMAP TTYDRV_DC_BITMAP_SelectObject(DC *dc, HBITMAP hbitmap, BITMAPOBJ *bitmap
return 0; return 0;
/* Assure that the bitmap device dependent */ /* Assure that the bitmap device dependent */
if(!bitmap->DDBitmap && !TTYDRV_DC_CreateBitmap(hbitmap)) if(!bitmap->physBitmap && !TTYDRV_DC_CreateBitmap(hbitmap))
return 0; return 0;
if(bitmap->DDBitmap->funcs != dc->funcs) { if(bitmap->funcs != dc->funcs) {
ERR("Trying to select a non-TTY DDB into a TTY DC\n"); ERR("Trying to select a non-TTY DDB into a TTY DC\n");
return 0; return 0;
} }
......
...@@ -73,23 +73,20 @@ HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap, ...@@ -73,23 +73,20 @@ HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
{ {
HRGN hrgn; HRGN hrgn;
HBITMAP prevHandle = dc->w.hBitmap; HBITMAP prevHandle = dc->w.hBitmap;
X11DRV_PHYSBITMAP *pbitmap;
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev; X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
if (!(dc->w.flags & DC_MEMORY)) return 0; if (!(dc->w.flags & DC_MEMORY)) return 0;
if(!bmp->DDBitmap) if(!bmp->physBitmap)
if(!X11DRV_CreateBitmap(hbitmap)) if(!X11DRV_CreateBitmap(hbitmap))
return 0; return 0;
if(bmp->DDBitmap->funcs != dc->funcs) { if(bmp->funcs != dc->funcs) {
WARN("Trying to select non-X11 DDB into an X11 dc\n"); WARN("Trying to select non-X11 DDB into an X11 dc\n");
return 0; return 0;
} }
pbitmap = bmp->DDBitmap->physBitmap;
dc->w.totalExtent.left = 0; dc->w.totalExtent.left = 0;
dc->w.totalExtent.top = 0; dc->w.totalExtent.top = 0;
dc->w.totalExtent.right = bmp->bitmap.bmWidth; dc->w.totalExtent.right = bmp->bitmap.bmWidth;
...@@ -105,7 +102,7 @@ HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap, ...@@ -105,7 +102,7 @@ HBITMAP X11DRV_BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
dc->w.hVisRgn = hrgn; dc->w.hVisRgn = hrgn;
} }
physDev->drawable = pbitmap->pixmap; physDev->drawable = (Pixmap)bmp->physBitmap;
dc->w.hBitmap = hbitmap; dc->w.hBitmap = hbitmap;
/* Change GC depth if needed */ /* Change GC depth if needed */
...@@ -139,41 +136,11 @@ struct XPutImage_descr ...@@ -139,41 +136,11 @@ struct XPutImage_descr
static int XPutImage_wrapper( const struct XPutImage_descr *descr ) static int XPutImage_wrapper( const struct XPutImage_descr *descr )
{ {
return XPutImage( display, return XPutImage( display, (Pixmap)descr->bmp->physBitmap, BITMAP_GC(descr->bmp),
((X11DRV_PHYSBITMAP *)descr->bmp->DDBitmap->physBitmap)->pixmap,
BITMAP_GC(descr->bmp),
descr->image, 0, 0, 0, 0, descr->width, descr->height ); descr->image, 0, 0, 0, 0, descr->width, descr->height );
} }
/***************************************************************************
*
* X11DRV_AllocBitmap
*
* Allocate DDBitmap and physBitmap
*
*/
X11DRV_PHYSBITMAP *X11DRV_AllocBitmap( BITMAPOBJ *bmp )
{
X11DRV_PHYSBITMAP *pbitmap;
if(!(bmp->DDBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(DDBITMAP)))) {
WARN("Can't alloc DDBITMAP\n");
return NULL;
}
if(!(pbitmap = HeapAlloc(GetProcessHeap(), 0,sizeof(X11DRV_PHYSBITMAP)))) {
WARN("Can't alloc X11DRV_PHYSBITMAP\n");
HeapFree(GetProcessHeap(), 0, bmp->DDBitmap);
return NULL;
}
bmp->DDBitmap->physBitmap = pbitmap;
bmp->DDBitmap->funcs = DRIVER_FindDriver( "DISPLAY" );
return pbitmap;
}
/**************************************************************************** /****************************************************************************
* *
* X11DRV_CreateBitmap * X11DRV_CreateBitmap
...@@ -186,7 +153,6 @@ X11DRV_PHYSBITMAP *X11DRV_AllocBitmap( BITMAPOBJ *bmp ) ...@@ -186,7 +153,6 @@ X11DRV_PHYSBITMAP *X11DRV_AllocBitmap( BITMAPOBJ *bmp )
BOOL X11DRV_CreateBitmap( HBITMAP hbitmap ) BOOL X11DRV_CreateBitmap( HBITMAP hbitmap )
{ {
X11DRV_PHYSBITMAP *pbitmap;
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ); BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if(!bmp) { if(!bmp) {
...@@ -208,19 +174,16 @@ BOOL X11DRV_CreateBitmap( HBITMAP hbitmap ) ...@@ -208,19 +174,16 @@ BOOL X11DRV_CreateBitmap( HBITMAP hbitmap )
TRACE("(%08x) %dx%d %d bpp\n", hbitmap, bmp->bitmap.bmWidth, TRACE("(%08x) %dx%d %d bpp\n", hbitmap, bmp->bitmap.bmWidth,
bmp->bitmap.bmHeight, bmp->bitmap.bmBitsPixel); bmp->bitmap.bmHeight, bmp->bitmap.bmBitsPixel);
pbitmap = X11DRV_AllocBitmap( bmp );
if(!pbitmap) return FALSE;
/* Create the pixmap */ /* Create the pixmap */
pbitmap->pixmap = TSXCreatePixmap(display, X11DRV_GetXRootWindow(), bmp->bitmap.bmWidth, if (!(bmp->physBitmap = (void *)TSXCreatePixmap(display, X11DRV_GetXRootWindow(),
bmp->bitmap.bmHeight, bmp->bitmap.bmBitsPixel); bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
if (!pbitmap->pixmap) { bmp->bitmap.bmBitsPixel)))
{
WARN("Can't create Pixmap\n"); WARN("Can't create Pixmap\n");
HeapFree(GetProcessHeap(), 0, bmp->DDBitmap->physBitmap);
HeapFree(GetProcessHeap(), 0, bmp->DDBitmap);
GDI_HEAP_UNLOCK( hbitmap ); GDI_HEAP_UNLOCK( hbitmap );
return FALSE; return FALSE;
} }
bmp->funcs = &X11DRV_DC_Funcs;
if (bmp->bitmap.bmBits) /* Set bitmap bits */ if (bmp->bitmap.bmBits) /* Set bitmap bits */
X11DRV_BitmapBits( hbitmap, bmp->bitmap.bmBits, X11DRV_BitmapBits( hbitmap, bmp->bitmap.bmBits,
...@@ -239,8 +202,7 @@ BOOL X11DRV_CreateBitmap( HBITMAP hbitmap ) ...@@ -239,8 +202,7 @@ BOOL X11DRV_CreateBitmap( HBITMAP hbitmap )
*/ */
XImage *X11DRV_BITMAP_GetXImage( const BITMAPOBJ *bmp ) XImage *X11DRV_BITMAP_GetXImage( const BITMAPOBJ *bmp )
{ {
return XGetImage( display, return XGetImage( display, (Pixmap)bmp->physBitmap,
((X11DRV_PHYSBITMAP *)bmp->DDBitmap->physBitmap)->pixmap,
0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight, 0, 0, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
AllPlanes, ZPixmap ); AllPlanes, ZPixmap );
} }
...@@ -521,14 +483,9 @@ LONG X11DRV_BitmapBits(HBITMAP hbitmap, void *bits, LONG count, WORD flags) ...@@ -521,14 +483,9 @@ LONG X11DRV_BitmapBits(HBITMAP hbitmap, void *bits, LONG count, WORD flags)
*/ */
BOOL X11DRV_BITMAP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ * bmp ) BOOL X11DRV_BITMAP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ * bmp )
{ {
X11DRV_PHYSBITMAP *pbitmap = bmp->DDBitmap->physBitmap; TSXFreePixmap( display, (Pixmap)bmp->physBitmap );
bmp->physBitmap = NULL;
TSXFreePixmap( display, pbitmap->pixmap ); bmp->funcs = NULL;
HeapFree( GetProcessHeap(), 0, bmp->DDBitmap->physBitmap );
HeapFree( GetProcessHeap(), 0, bmp->DDBitmap );
bmp->DDBitmap = NULL;
return TRUE; return TRUE;
} }
...@@ -543,7 +500,6 @@ HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap) ...@@ -543,7 +500,6 @@ HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap)
{ {
HBITMAP hBmp = 0; HBITMAP hBmp = 0;
BITMAPOBJ *pBmp = NULL; BITMAPOBJ *pBmp = NULL;
X11DRV_PHYSBITMAP *pPhysBmp = NULL;
Window root; Window root;
int x,y; /* Unused */ int x,y; /* Unused */
unsigned border_width; /* Unused */ unsigned border_width; /* Unused */
...@@ -563,20 +519,10 @@ HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap) ...@@ -563,20 +519,10 @@ HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap)
*/ */
hBmp = CreateBitmap( width, height, 1, depth, NULL ); hBmp = CreateBitmap( width, height, 1, depth, NULL );
/* Allocate DDBitmap and physBitmap structures in BITMAPOBJ.
* The hBmp is just a filled in BITMAPOBJ header at this point.
*/
pBmp = (BITMAPOBJ *)GDI_GetObjPtr( hBmp, BITMAP_MAGIC ); pBmp = (BITMAPOBJ *)GDI_GetObjPtr( hBmp, BITMAP_MAGIC );
pPhysBmp = X11DRV_AllocBitmap( pBmp );
if( !pPhysBmp )
{
DeleteObject(hBmp);
hBmp = NULL;
goto END;
}
/* Point to our Pixmap in the physical bitmap structure */ pBmp->funcs = &X11DRV_DC_Funcs;
pPhysBmp->pixmap = pixmap; pBmp->physBitmap = (void *)pixmap;
END: END:
TRACE("\tReturning HBITMAP %x\n", hBmp); TRACE("\tReturning HBITMAP %x\n", hBmp);
...@@ -615,13 +561,11 @@ HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap) ...@@ -615,13 +561,11 @@ HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap)
*/ */
if (!bDeletePixmap) if (!bDeletePixmap)
{ {
/* Manually free the DDBitmap internals to prevent the Pixmap /* Manually clear the bitmap internals to prevent the Pixmap
* from being deleted by DeleteObject. * from being deleted by DeleteObject.
*/ */
pBmp = (BITMAPOBJ *)GDI_GetObjPtr( hBmp, BITMAP_MAGIC ); pBmp->physBitmap = NULL;
HeapFree( GetProcessHeap(), 0, pBmp->DDBitmap->physBitmap ); pBmp->funcs = NULL;
HeapFree( GetProcessHeap(), 0, pBmp->DDBitmap );
pBmp->DDBitmap = NULL;
} }
DeleteObject(hBmp); DeleteObject(hBmp);
...@@ -663,10 +607,10 @@ Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc ) ...@@ -663,10 +607,10 @@ Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc )
* *
* This function exists solely for x11 driver of the window system. * This function exists solely for x11 driver of the window system.
*/ */
BOOL X11DRV_BITMAP_Pixmap(HBITMAP hbitmap) Pixmap X11DRV_BITMAP_Pixmap(HBITMAP hbitmap)
{ {
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ); BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
return ((X11DRV_PHYSBITMAP *)(bmp->DDBitmap->physBitmap))->pixmap; return (Pixmap)bmp->physBitmap;
} }
#endif /* !defined(X_DISPLAY_MISSING) */ #endif /* !defined(X_DISPLAY_MISSING) */
...@@ -174,35 +174,32 @@ static void BRUSH_SelectSolidBrush( DC *dc, COLORREF color ) ...@@ -174,35 +174,32 @@ static void BRUSH_SelectSolidBrush( DC *dc, COLORREF color )
*/ */
static BOOL BRUSH_SelectPatternBrush( DC * dc, HBITMAP hbitmap ) static BOOL BRUSH_SelectPatternBrush( DC * dc, HBITMAP hbitmap )
{ {
X11DRV_PHYSBITMAP *pbitmap;
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev; X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ); BITMAPOBJ * bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmp) return FALSE; if (!bmp) return FALSE;
if(!bmp->DDBitmap) if(!bmp->physBitmap)
if(!X11DRV_CreateBitmap(hbitmap)) if(!X11DRV_CreateBitmap(hbitmap))
return 0; return 0;
if(bmp->DDBitmap->funcs != dc->funcs) { if(bmp->funcs != dc->funcs) {
WARN("Trying to select non-X11 DDB into an X11 dc\n"); WARN("Trying to select non-X11 DDB into an X11 dc\n");
return 0; return 0;
} }
pbitmap = bmp->DDBitmap->physBitmap;
if ((dc->w.bitsPerPixel == 1) && (bmp->bitmap.bmBitsPixel != 1)) if ((dc->w.bitsPerPixel == 1) && (bmp->bitmap.bmBitsPixel != 1))
{ {
/* Special case: a color pattern on a monochrome DC */ /* Special case: a color pattern on a monochrome DC */
physDev->brush.pixmap = TSXCreatePixmap( display, X11DRV_GetXRootWindow(), 8, 8, 1); physDev->brush.pixmap = TSXCreatePixmap( display, X11DRV_GetXRootWindow(), 8, 8, 1);
/* FIXME: should probably convert to monochrome instead */ /* FIXME: should probably convert to monochrome instead */
TSXCopyPlane( display, pbitmap->pixmap, physDev->brush.pixmap, TSXCopyPlane( display, (Pixmap)bmp->physBitmap, physDev->brush.pixmap,
BITMAP_monoGC, 0, 0, 8, 8, 0, 0, 1 ); BITMAP_monoGC, 0, 0, 8, 8, 0, 0, 1 );
} }
else else
{ {
physDev->brush.pixmap = TSXCreatePixmap( display, X11DRV_GetXRootWindow(), physDev->brush.pixmap = TSXCreatePixmap( display, X11DRV_GetXRootWindow(),
8, 8, bmp->bitmap.bmBitsPixel ); 8, 8, bmp->bitmap.bmBitsPixel );
TSXCopyArea( display, pbitmap->pixmap, physDev->brush.pixmap, TSXCopyArea( display, (Pixmap)bmp->physBitmap, physDev->brush.pixmap,
BITMAP_GC(bmp), 0, 0, 8, 8, 0, 0 ); BITMAP_GC(bmp), 0, 0, 8, 8, 0, 0 );
} }
......
...@@ -2781,7 +2781,6 @@ INT X11DRV_DIB_SetDIBits( ...@@ -2781,7 +2781,6 @@ INT X11DRV_DIB_SetDIBits(
UINT coloruse, HBITMAP hbitmap) UINT coloruse, HBITMAP hbitmap)
{ {
X11DRV_DIB_IMAGEBITS_DESCR descr; X11DRV_DIB_IMAGEBITS_DESCR descr;
X11DRV_PHYSBITMAP *pbitmap;
int height, tmpheight; int height, tmpheight;
INT result; INT result;
...@@ -2834,17 +2833,15 @@ INT X11DRV_DIB_SetDIBits( ...@@ -2834,17 +2833,15 @@ INT X11DRV_DIB_SetDIBits(
} }
/* HACK for now */ /* HACK for now */
if(!bmp->DDBitmap) if(!bmp->physBitmap)
X11DRV_CreateBitmap(hbitmap); X11DRV_CreateBitmap(hbitmap);
pbitmap = bmp->DDBitmap->physBitmap;
descr.bits = bits; descr.bits = bits;
descr.image = NULL; descr.image = NULL;
descr.palentry = NULL; descr.palentry = NULL;
descr.lines = tmpheight >= 0 ? lines : -lines; descr.lines = tmpheight >= 0 ? lines : -lines;
descr.depth = bmp->bitmap.bmBitsPixel; descr.depth = bmp->bitmap.bmBitsPixel;
descr.drawable = pbitmap->pixmap; descr.drawable = (Pixmap)bmp->physBitmap;
descr.gc = BITMAP_GC(bmp); descr.gc = BITMAP_GC(bmp);
descr.xSrc = 0; descr.xSrc = 0;
descr.ySrc = 0; descr.ySrc = 0;
...@@ -2873,7 +2870,6 @@ INT X11DRV_DIB_GetDIBits( ...@@ -2873,7 +2870,6 @@ INT X11DRV_DIB_GetDIBits(
{ {
X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib; X11DRV_DIBSECTION *dib = (X11DRV_DIBSECTION *) bmp->dib;
X11DRV_DIB_IMAGEBITS_DESCR descr; X11DRV_DIB_IMAGEBITS_DESCR descr;
X11DRV_PHYSBITMAP *pbitmap;
PALETTEOBJ * palette; PALETTEOBJ * palette;
TRACE("%u scanlines of (%i,%i) -> (%i,%i) starting from %u\n", TRACE("%u scanlines of (%i,%i) -> (%i,%i) starting from %u\n",
...@@ -2914,17 +2910,16 @@ INT X11DRV_DIB_GetDIBits( ...@@ -2914,17 +2910,16 @@ INT X11DRV_DIB_GetDIBits(
} }
/* Hack for now */ /* Hack for now */
if(!bmp->DDBitmap) if(!bmp->physBitmap)
X11DRV_CreateBitmap(hbitmap); X11DRV_CreateBitmap(hbitmap);
pbitmap = bmp->DDBitmap->physBitmap;
descr.dc = dc; descr.dc = dc;
descr.palentry = palette->logpalette.palPalEntry; descr.palentry = palette->logpalette.palPalEntry;
descr.bits = bits; descr.bits = bits;
descr.lines = lines; descr.lines = lines;
descr.depth = bmp->bitmap.bmBitsPixel; descr.depth = bmp->bitmap.bmBitsPixel;
descr.drawable = pbitmap->pixmap; descr.drawable = (Pixmap)bmp->physBitmap;
descr.gc = BITMAP_GC(bmp); descr.gc = BITMAP_GC(bmp);
descr.xSrc = 0; descr.xSrc = 0;
descr.ySrc = startscan; descr.ySrc = startscan;
...@@ -3018,7 +3013,7 @@ static void X11DRV_DIB_DoUpdateDIBSection(BITMAPOBJ *bmp, BOOL toDIB) ...@@ -3018,7 +3013,7 @@ static void X11DRV_DIB_DoUpdateDIBSection(BITMAPOBJ *bmp, BOOL toDIB)
} }
/* Hack for now */ /* Hack for now */
descr.drawable = ((X11DRV_PHYSBITMAP *)bmp->DDBitmap->physBitmap)->pixmap; descr.drawable = (Pixmap)bmp->physBitmap;
descr.gc = BITMAP_GC(bmp); descr.gc = BITMAP_GC(bmp);
descr.xSrc = 0; descr.xSrc = 0;
descr.ySrc = 0; descr.ySrc = 0;
...@@ -3375,7 +3370,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection( ...@@ -3375,7 +3370,7 @@ HBITMAP X11DRV_DIB_CreateDIBSection(
{ {
bmp->dib = (DIBSECTION *) dib; bmp->dib = (DIBSECTION *) dib;
/* HACK for now */ /* HACK for now */
if(!bmp->DDBitmap) if(!bmp->physBitmap)
X11DRV_CreateBitmap(res); X11DRV_CreateBitmap(res);
} }
} }
...@@ -3496,12 +3491,9 @@ HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixma ...@@ -3496,12 +3491,9 @@ HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixma
*/ */
if (!bDeletePixmap) if (!bDeletePixmap)
{ {
/* Manually free the DDBitmap internals to prevent the Pixmap /* Clear the physBitmap to prevent the Pixmap from being deleted by DeleteObject */
* from being deleted by DeleteObject. pBmp->physBitmap = NULL;
*/ pBmp->funcs = NULL;
HeapFree( GetProcessHeap(), 0, pBmp->DDBitmap->physBitmap );
HeapFree( GetProcessHeap(), 0, pBmp->DDBitmap );
pBmp->DDBitmap = NULL;
} }
DeleteObject(hBmp); DeleteObject(hBmp);
...@@ -3550,17 +3542,10 @@ Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc ) ...@@ -3550,17 +3542,10 @@ Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc )
pBmp = (BITMAPOBJ *) GDI_GetObjPtr( hBmp, BITMAP_MAGIC ); pBmp = (BITMAPOBJ *) GDI_GetObjPtr( hBmp, BITMAP_MAGIC );
if (pBmp->DDBitmap && pBmp->DDBitmap->physBitmap) pixmap = (Pixmap)pBmp->physBitmap;
{ /* clear the physBitmap so that we can steal its pixmap */
pixmap = ((X11DRV_PHYSBITMAP *)(pBmp->DDBitmap->physBitmap))->pixmap; pBmp->physBitmap = NULL;
if (!pixmap) pBmp->funcs = NULL;
TRACE("NULL Pixmap in DDBitmap->physBitmap!\n");
/* Manually free the BITMAPOBJ internals so that we can steal its pixmap */
HeapFree( GetProcessHeap(), 0, pBmp->DDBitmap->physBitmap );
HeapFree( GetProcessHeap(), 0, pBmp->DDBitmap );
pBmp->DDBitmap = NULL; /* Its not a DDB anymore */
}
/* Delete the DDB we created earlier now that we have stolen its pixmap */ /* Delete the DDB we created earlier now that we have stolen its pixmap */
DeleteObject(hBmp); DeleteObject(hBmp);
......
...@@ -30,7 +30,7 @@ static BOOL X11DRV_DeleteDC( DC *dc ); ...@@ -30,7 +30,7 @@ static BOOL X11DRV_DeleteDC( DC *dc );
static INT X11DRV_Escape( DC *dc, INT nEscape, INT cbInput, static INT X11DRV_Escape( DC *dc, INT nEscape, INT cbInput,
SEGPTR lpInData, SEGPTR lpOutData ); SEGPTR lpInData, SEGPTR lpOutData );
static const DC_FUNCTIONS X11DRV_Funcs = const DC_FUNCTIONS X11DRV_DC_Funcs =
{ {
NULL, /* pAbortDoc */ NULL, /* pAbortDoc */
NULL, /* pAbortPath */ NULL, /* pAbortPath */
...@@ -210,7 +210,7 @@ BOOL X11DRV_GDI_Initialize(void) ...@@ -210,7 +210,7 @@ BOOL X11DRV_GDI_Initialize(void)
if (!X11DRV_FONT_Init( &X11DRV_DevCaps )) return FALSE; if (!X11DRV_FONT_Init( &X11DRV_DevCaps )) return FALSE;
return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_Funcs ); return DRIVER_RegisterDriver( "DISPLAY", &X11DRV_DC_Funcs );
} }
/********************************************************************** /**********************************************************************
...@@ -239,12 +239,10 @@ static BOOL X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device, ...@@ -239,12 +239,10 @@ static BOOL X11DRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
dc->w.devCaps = &X11DRV_DevCaps; dc->w.devCaps = &X11DRV_DevCaps;
if (dc->w.flags & DC_MEMORY) if (dc->w.flags & DC_MEMORY)
{ {
X11DRV_PHYSBITMAP *pbitmap;
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap, BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( dc->w.hBitmap,
BITMAP_MAGIC ); BITMAP_MAGIC );
X11DRV_CreateBitmap( dc->w.hBitmap ); X11DRV_CreateBitmap( dc->w.hBitmap );
pbitmap = bmp->DDBitmap->physBitmap; physDev->drawable = (Pixmap)bmp->physBitmap;
physDev->drawable = pbitmap->pixmap;
physDev->gc = TSXCreateGC(display, physDev->drawable, 0, NULL); physDev->gc = TSXCreateGC(display, physDev->drawable, 0, NULL);
dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel; dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
......
...@@ -345,7 +345,6 @@ static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height, ...@@ -345,7 +345,6 @@ static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
{ {
HBITMAP16 hbitmap; HBITMAP16 hbitmap;
BITMAPOBJ * bmpObjPtr; BITMAPOBJ * bmpObjPtr;
X11DRV_PHYSBITMAP *pbitmap;
if (!pixmap) return 0; if (!pixmap) return 0;
...@@ -364,9 +363,8 @@ static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height, ...@@ -364,9 +363,8 @@ static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
bmpObjPtr->bitmap.bmBits = NULL; bmpObjPtr->bitmap.bmBits = NULL;
bmpObjPtr->dib = NULL; bmpObjPtr->dib = NULL;
pbitmap = X11DRV_AllocBitmap(bmpObjPtr); bmpObjPtr->funcs = &X11DRV_DC_Funcs;
bmpObjPtr->physBitmap = (void *)pixmap;
pbitmap->pixmap = pixmap;
GDI_HEAP_UNLOCK( hbitmap ); GDI_HEAP_UNLOCK( hbitmap );
return hbitmap; return hbitmap;
...@@ -532,11 +530,10 @@ static HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL fCursor ) ...@@ -532,11 +530,10 @@ static HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL fCursor )
if (descr.mask) if (descr.mask)
{ {
X11DRV_PHYSBITMAP *pbitmapAnd = bmpAnd->DDBitmap->physBitmap;
/* Invert the mask */ /* Invert the mask */
TSXSetFunction( display, BITMAP_monoGC, GXinvert ); TSXSetFunction( display, BITMAP_monoGC, GXinvert );
TSXFillRectangle( display, pbitmapAnd->pixmap, BITMAP_monoGC, 0, 0, TSXFillRectangle( display, (Pixmap)bmpAnd->physBitmap, BITMAP_monoGC, 0, 0,
bmpAnd->bitmap.bmWidth, bmpAnd->bitmap.bmHeight ); bmpAnd->bitmap.bmWidth, bmpAnd->bitmap.bmHeight );
TSXSetFunction( display, BITMAP_monoGC, GXcopy ); TSXSetFunction( display, BITMAP_monoGC, GXcopy );
...@@ -544,13 +541,12 @@ static HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL fCursor ) ...@@ -544,13 +541,12 @@ static HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL fCursor )
if (bmpXor->bitmap.bmBitsPixel != 1) if (bmpXor->bitmap.bmBitsPixel != 1)
{ {
X11DRV_PHYSBITMAP *pbitmapXor = bmpXor->DDBitmap->physBitmap;
TSXSetForeground( display, BITMAP_colorGC, TSXSetForeground( display, BITMAP_colorGC,
X11DRV_PALETTE_ToPhysical( NULL, RGB(0,0,0) )); X11DRV_PALETTE_ToPhysical( NULL, RGB(0,0,0) ));
TSXSetBackground( display, BITMAP_colorGC, 0 ); TSXSetBackground( display, BITMAP_colorGC, 0 );
TSXSetFunction( display, BITMAP_colorGC, GXor ); TSXSetFunction( display, BITMAP_colorGC, GXor );
TSXCopyPlane(display, pbitmapAnd->pixmap, pbitmapXor->pixmap, BITMAP_colorGC, TSXCopyPlane(display, (Pixmap)bmpAnd->physBitmap, (Pixmap)bmpXor->physBitmap,
0, 0, bmpXor->bitmap.bmWidth, bmpXor->bitmap.bmHeight, BITMAP_colorGC, 0, 0, bmpXor->bitmap.bmWidth, bmpXor->bitmap.bmHeight,
0, 0, 1 ); 0, 0, 1 );
TSXSetFunction( display, BITMAP_colorGC, GXcopy ); TSXSetFunction( display, BITMAP_colorGC, GXcopy );
} }
......
...@@ -18,20 +18,14 @@ struct tagGDI_BITMAP_DRIVER; ...@@ -18,20 +18,14 @@ struct tagGDI_BITMAP_DRIVER;
#define DDB_COPY 4 #define DDB_COPY 4
#define DDB_SETWITHFILLER 8 #define DDB_SETWITHFILLER 8
typedef struct {
const struct tagDC_FUNCS *funcs; /* DC function table */
void *physBitmap; /* ptr to device specific data */
} DDBITMAP;
/* GDI logical bitmap object */ /* GDI logical bitmap object */
typedef struct tagBITMAPOBJ typedef struct tagBITMAPOBJ
{ {
GDIOBJHDR header; GDIOBJHDR header;
BITMAP bitmap; BITMAP bitmap;
SIZE size; /* For SetBitmapDimension() */ SIZE size; /* For SetBitmapDimension() */
const struct tagDC_FUNCS *funcs; /* DC function table */
DDBITMAP *DDBitmap; void *physBitmap; /* ptr to device specific data */
/* For device-independent bitmaps: */ /* For device-independent bitmaps: */
DIBSECTION *dib; DIBSECTION *dib;
} BITMAPOBJ; } BITMAPOBJ;
......
...@@ -70,10 +70,6 @@ typedef struct ...@@ -70,10 +70,6 @@ typedef struct
} X11DRV_PDEVICE; } X11DRV_PDEVICE;
typedef struct {
Pixmap pixmap;
} X11DRV_PHYSBITMAP;
/* GCs used for B&W and color bitmap operations */ /* GCs used for B&W and color bitmap operations */
extern GC BITMAP_monoGC, BITMAP_colorGC; extern GC BITMAP_monoGC, BITMAP_colorGC;
...@@ -84,6 +80,8 @@ extern DeviceCaps X11DRV_DevCaps; ...@@ -84,6 +80,8 @@ extern DeviceCaps X11DRV_DevCaps;
/* Wine driver X11 functions */ /* Wine driver X11 functions */
extern const DC_FUNCTIONS X11DRV_DC_Funcs;
extern BOOL X11DRV_BitBlt( struct tagDC *dcDst, INT xDst, INT yDst, extern BOOL X11DRV_BitBlt( struct tagDC *dcDst, INT xDst, INT yDst,
INT width, INT height, struct tagDC *dcSrc, INT width, INT height, struct tagDC *dcSrc,
INT xSrc, INT ySrc, DWORD rop ); INT xSrc, INT ySrc, DWORD rop );
...@@ -167,7 +165,6 @@ struct tagBITMAPOBJ; ...@@ -167,7 +165,6 @@ struct tagBITMAPOBJ;
extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp ); extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp );
extern int X11DRV_DIB_GetXImageWidthBytes( int width, int depth ); extern int X11DRV_DIB_GetXImageWidthBytes( int width, int depth );
extern BOOL X11DRV_DIB_Init(void); extern BOOL X11DRV_DIB_Init(void);
extern X11DRV_PHYSBITMAP *X11DRV_AllocBitmap( struct tagBITMAPOBJ *bmp );
extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap); extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap);
extern HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixmap); extern HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixmap);
extern HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap); extern HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap);
......
...@@ -140,7 +140,8 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes, ...@@ -140,7 +140,8 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
bmp->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp ); bmp->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
bmp->bitmap.bmBits = NULL; bmp->bitmap.bmBits = NULL;
bmp->DDBitmap = NULL; bmp->funcs = NULL;
bmp->physBitmap = NULL;
bmp->dib = NULL; bmp->dib = NULL;
if (bits) /* Set bitmap bits */ if (bits) /* Set bitmap bits */
...@@ -273,12 +274,11 @@ LONG WINAPI GetBitmapBits( ...@@ -273,12 +274,11 @@ LONG WINAPI GetBitmapBits(
hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight, hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel, height ); 1 << bmp->bitmap.bmBitsPixel, height );
if(bmp->DDBitmap) { if(bmp->funcs) {
TRACE("Calling device specific BitmapBits\n"); TRACE("Calling device specific BitmapBits\n");
if(bmp->DDBitmap->funcs->pBitmapBits) if(bmp->funcs->pBitmapBits)
ret = bmp->DDBitmap->funcs->pBitmapBits(hbitmap, bits, count, ret = bmp->funcs->pBitmapBits(hbitmap, bits, count, DDB_GET);
DDB_GET);
else { else {
ERR("BitmapBits == NULL??\n"); ERR("BitmapBits == NULL??\n");
ret = 0; ret = 0;
...@@ -342,12 +342,11 @@ LONG WINAPI SetBitmapBits( ...@@ -342,12 +342,11 @@ LONG WINAPI SetBitmapBits(
hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight, hbitmap, count, bits, bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel, height ); 1 << bmp->bitmap.bmBitsPixel, height );
if(bmp->DDBitmap) { if(bmp->funcs) {
TRACE("Calling device specific BitmapBits\n"); TRACE("Calling device specific BitmapBits\n");
if(bmp->DDBitmap->funcs->pBitmapBits) if(bmp->funcs->pBitmapBits)
ret = bmp->DDBitmap->funcs->pBitmapBits(hbitmap, (void *) bits, ret = bmp->funcs->pBitmapBits(hbitmap, (void *) bits, count, DDB_SET);
count, DDB_SET);
else { else {
ERR("BitmapBits == NULL??\n"); ERR("BitmapBits == NULL??\n");
ret = 0; ret = 0;
...@@ -403,10 +402,8 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap) ...@@ -403,10 +402,8 @@ HBITMAP BITMAP_CopyBitmap(HBITMAP hbitmap)
*/ */
BOOL BITMAP_DeleteObject( HBITMAP16 hbitmap, BITMAPOBJ * bmp ) BOOL BITMAP_DeleteObject( HBITMAP16 hbitmap, BITMAPOBJ * bmp )
{ {
if( bmp->DDBitmap ) { if (bmp->funcs && bmp->funcs->pDeleteObject)
if( bmp->DDBitmap->funcs->pDeleteObject ) bmp->funcs->pDeleteObject( hbitmap );
bmp->DDBitmap->funcs->pDeleteObject( hbitmap );
}
if( bmp->bitmap.bmBits ) if( bmp->bitmap.bmBits )
HeapFree( GetProcessHeap(), 0, bmp->bitmap.bmBits ); HeapFree( GetProcessHeap(), 0, bmp->bitmap.bmBits );
......
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