Get rid of the X11DRV_DC_Funcs hack.

Removed a couple of unused bitmap functions.
This commit is contained in:
Alexandre Julliard 2004-03-04 06:13:21 +00:00
parent b0c9f6a34d
commit 37fda71e41
4 changed files with 13 additions and 87 deletions

View File

@ -37,8 +37,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
GC BITMAP_monoGC = 0, BITMAP_colorGC = 0; GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
Pixmap BITMAP_stock_pixmap; /* pixmap for the default stock bitmap */ Pixmap BITMAP_stock_pixmap; /* pixmap for the default stock bitmap */
extern const struct tagDC_FUNCS *X11DRV_DC_Funcs; /* hack */
/*********************************************************************** /***********************************************************************
* X11DRV_BITMAP_Init * X11DRV_BITMAP_Init
*/ */
@ -440,9 +438,10 @@ BOOL X11DRV_DeleteBitmap( HBITMAP hbitmap )
* Note: This function makes the bitmap an owner of the Pixmap so subsequently * Note: This function makes the bitmap an owner of the Pixmap so subsequently
* calling DeleteObject on this will free the Pixmap as well. * calling DeleteObject on this will free the Pixmap as well.
*/ */
HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap) HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(HDC hdc, Pixmap pixmap)
{ {
HBITMAP hBmp = 0; HDC hdcMem;
HBITMAP hBmp = 0, old;
BITMAPOBJ *pBmp = NULL; BITMAPOBJ *pBmp = NULL;
Window root; Window root;
int x,y; /* Unused */ int x,y; /* Unused */
@ -465,90 +464,25 @@ HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap)
*/ */
hBmp = CreateBitmap( width, height, 1, depth, NULL ); hBmp = CreateBitmap( width, height, 1, depth, NULL );
/* force bitmap to be owned by a screen DC */
hdcMem = CreateCompatibleDC( hdc );
old = SelectObject( hdcMem, hBmp );
pBmp = (BITMAPOBJ *)GDI_GetObjPtr( hBmp, BITMAP_MAGIC ); pBmp = (BITMAPOBJ *)GDI_GetObjPtr( hBmp, BITMAP_MAGIC );
pBmp->funcs = X11DRV_DC_Funcs; if (pBmp->physBitmap) XFreePixmap( gdi_display, (Pixmap)pBmp->physBitmap );
pBmp->physBitmap = (void *)pixmap; pBmp->physBitmap = (void *)pixmap;
GDI_ReleaseObj( hBmp ); GDI_ReleaseObj( hBmp );
SelectObject( hdcMem, old );
DeleteDC( hdcMem );
END: END:
TRACE("\tReturning HBITMAP %p\n", hBmp); TRACE("\tReturning HBITMAP %p\n", hBmp);
return hBmp; return hBmp;
} }
/**************************************************************************
* X11DRV_BITMAP_CreateBitmapFromPixmap
*
* Allocates an HBITMAP and copies the Pixmap data into it.
* If bDeletePixmap is TRUE, the Pixmap passed in is deleted after the conversion.
*/
HBITMAP X11DRV_BITMAP_CreateBitmapFromPixmap(Pixmap pixmap, BOOL bDeletePixmap)
{
HBITMAP hBmp = 0, hBmpCopy = 0;
BITMAPOBJ *pBmp = NULL;
unsigned int width, height;
/* Allocate an HBITMAP which references the Pixmap passed to us */
hBmp = X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(pixmap);
if (!hBmp)
{
TRACE("\tCould not create bitmap header for Pixmap\n");
goto END;
}
/* Get the bitmap dimensions */
width = pBmp->bitmap.bmWidth;
height = pBmp->bitmap.bmHeight;
hBmpCopy = (HBITMAP)CopyImage(hBmp, IMAGE_BITMAP, width, height, LR_CREATEDIBSECTION);
/* We can now get rid of the HBITMAP wrapper we created earlier.
* Note: Simply calling DeleteObject will free the embedded Pixmap as well.
*/
if (!bDeletePixmap)
{
/* Manually clear the bitmap internals to prevent the Pixmap
* from being deleted by DeleteObject.
*/
pBmp->physBitmap = NULL;
pBmp->funcs = NULL;
}
DeleteObject(hBmp);
END:
TRACE("\tReturning HBITMAP %p\n", hBmpCopy);
return hBmpCopy;
}
/**************************************************************************
* X11DRV_BITMAP_CreatePixmapFromBitmap
*
* Creates a Pixmap from a bitmap
*/
Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc )
{
HGLOBAL hPackedDIB = 0;
Pixmap pixmap = 0;
/*
* Create a packed DIB from the bitmap passed to us.
* A packed DIB contains a BITMAPINFO structure followed immediately by
* an optional color palette and the pixel data.
*/
hPackedDIB = X11DRV_DIB_CreateDIBFromBitmap(hdc, hBmp);
/* Create a Pixmap from the packed DIB */
pixmap = X11DRV_DIB_CreatePixmapFromDIB( hPackedDIB, hdc );
/* Free the temporary packed DIB */
GlobalFree(hPackedDIB);
return pixmap;
}
/*********************************************************************** /***********************************************************************
* X11DRV_BITMAP_Pixmap * X11DRV_BITMAP_Pixmap
* *

View File

@ -4853,7 +4853,7 @@ HGLOBAL X11DRV_DIB_CreateDIBFromPixmap(Pixmap pixmap, HDC hdc, BOOL bDeletePixma
HGLOBAL hPackedDIB = 0; HGLOBAL hPackedDIB = 0;
/* Allocates an HBITMAP which references the Pixmap passed to us */ /* Allocates an HBITMAP which references the Pixmap passed to us */
hBmp = X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(pixmap); hBmp = X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(hdc, pixmap);
if (!hBmp) if (!hBmp)
{ {
TRACE("\tCould not create bitmap header for Pixmap\n"); TRACE("\tCould not create bitmap header for Pixmap\n");

View File

@ -33,8 +33,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(x11drv); WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
const struct tagDC_FUNCS *X11DRV_DC_Funcs = NULL; /* hack */
Display *gdi_display; /* display to use for all GDI functions */ Display *gdi_display; /* display to use for all GDI functions */
/* a few dynamic device caps */ /* a few dynamic device caps */
@ -92,14 +90,11 @@ BOOL X11DRV_CreateDC( DC *dc, X11DRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR dev
{ {
X11DRV_PDEVICE *physDev; X11DRV_PDEVICE *physDev;
if (!X11DRV_DC_Funcs) X11DRV_DC_Funcs = dc->funcs; /* hack */
physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev) ); physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev) );
if (!physDev) return FALSE; if (!physDev) return FALSE;
*pdev = physDev; *pdev = physDev;
physDev->hdc = dc->hSelf; physDev->hdc = dc->hSelf;
physDev->dc = dc; /* FIXME */
if (GetObjectType( dc->hSelf ) == OBJ_MEMDC) if (GetObjectType( dc->hSelf ) == OBJ_MEMDC)
{ {

View File

@ -86,7 +86,6 @@ typedef struct tagXRENDERINFO *XRENDERINFO;
typedef struct typedef struct
{ {
HDC hdc; HDC hdc;
struct tagDC *dc; /* direct pointer to DC, should go away */
GC gc; /* X Window GC */ GC gc; /* X Window GC */
Drawable drawable; Drawable drawable;
POINT org; /* DC origin relative to drawable */ POINT org; /* DC origin relative to drawable */
@ -200,12 +199,10 @@ struct tagBITMAPOBJ;
extern int X11DRV_DIB_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse ); extern int X11DRV_DIB_BitmapInfoSize( const BITMAPINFO * info, WORD coloruse );
extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp ); extern XImage *X11DRV_BITMAP_GetXImage( const struct tagBITMAPOBJ *bmp );
extern XImage *X11DRV_DIB_CreateXImage( int width, int height, int depth ); extern XImage *X11DRV_DIB_CreateXImage( int width, int height, int depth );
extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(Pixmap pixmap); extern HBITMAP X11DRV_BITMAP_CreateBitmapHeaderFromPixmap(HDC hdc, Pixmap pixmap);
extern HGLOBAL X11DRV_DIB_CreateDIBFromBitmap(HDC hdc, HBITMAP hBmp); extern HGLOBAL X11DRV_DIB_CreateDIBFromBitmap(HDC hdc, HBITMAP hBmp);
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 Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc ); extern Pixmap X11DRV_DIB_CreatePixmapFromDIB( HGLOBAL hPackedDIB, HDC hdc );
extern Pixmap X11DRV_BITMAP_CreatePixmapFromBitmap( HBITMAP hBmp, HDC hdc );
extern RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp ); extern RGNDATA *X11DRV_GetRegionData( HRGN hrgn, HDC hdc_lptodp );