Use an X context to associate the phys bitmap data to a bitmap handle
instead of directly accessing the bitmap structure.
This commit is contained in:
parent
5673b00adc
commit
042614751c
|
@ -23,12 +23,10 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "gdi.h"
|
#include "windef.h"
|
||||||
|
#include "wingdi.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "x11drv.h"
|
#include "x11drv.h"
|
||||||
#include "wingdi.h"
|
|
||||||
#include "windef.h"
|
|
||||||
#include "wine/winuser16.h"
|
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
||||||
|
|
||||||
|
@ -36,6 +34,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
||||||
GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
|
GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
|
||||||
X_PHYSBITMAP BITMAP_stock_phys_bitmap = { 0 }; /* phys bitmap for the default stock bitmap */
|
X_PHYSBITMAP BITMAP_stock_phys_bitmap = { 0 }; /* phys bitmap for the default stock bitmap */
|
||||||
|
|
||||||
|
static XContext bitmap_context; /* X context to associate a phys bitmap to a handle */
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* X11DRV_BITMAP_Init
|
* X11DRV_BITMAP_Init
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,7 @@ void X11DRV_BITMAP_Init(void)
|
||||||
/* Create the necessary GCs */
|
/* Create the necessary GCs */
|
||||||
|
|
||||||
wine_tsx11_lock();
|
wine_tsx11_lock();
|
||||||
|
bitmap_context = XUniqueContext();
|
||||||
BITMAP_stock_phys_bitmap.pixmap_depth = 1;
|
BITMAP_stock_phys_bitmap.pixmap_depth = 1;
|
||||||
BITMAP_stock_phys_bitmap.pixmap = XCreatePixmap( gdi_display, root_window, 1, 1, 1 );
|
BITMAP_stock_phys_bitmap.pixmap = XCreatePixmap( gdi_display, root_window, 1, 1, 1 );
|
||||||
BITMAP_monoGC = XCreateGC( gdi_display, BITMAP_stock_phys_bitmap.pixmap, 0, NULL );
|
BITMAP_monoGC = XCreateGC( gdi_display, BITMAP_stock_phys_bitmap.pixmap, 0, NULL );
|
||||||
|
@ -108,56 +109,45 @@ HBITMAP X11DRV_SelectBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap )
|
||||||
BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap )
|
BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap )
|
||||||
{
|
{
|
||||||
X_PHYSBITMAP *physBitmap;
|
X_PHYSBITMAP *physBitmap;
|
||||||
BOOL ret = FALSE;
|
BITMAP bitmap;
|
||||||
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
|
|
||||||
|
|
||||||
if(!bmp) {
|
if (!GetObjectW( hbitmap, sizeof(bitmap), &bitmap )) return FALSE;
|
||||||
WARN("Bad bitmap handle %p\n", hbitmap);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check parameters */
|
/* Check parameters */
|
||||||
if (bmp->bitmap.bmPlanes != 1) goto done;
|
if (bitmap.bmPlanes != 1) return FALSE;
|
||||||
|
|
||||||
if ((bmp->bitmap.bmBitsPixel != 1) && (bmp->bitmap.bmBitsPixel != screen_depth))
|
if ((bitmap.bmBitsPixel != 1) && (bitmap.bmBitsPixel != screen_depth))
|
||||||
{
|
{
|
||||||
ERR("Trying to make bitmap with planes=%d, bpp=%d\n",
|
ERR("Trying to make bitmap with planes=%d, bpp=%d\n",
|
||||||
bmp->bitmap.bmPlanes, bmp->bitmap.bmBitsPixel);
|
bitmap.bmPlanes, bitmap.bmBitsPixel);
|
||||||
goto done;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (hbitmap == BITMAP_stock_phys_bitmap.hbitmap)
|
if (hbitmap == BITMAP_stock_phys_bitmap.hbitmap)
|
||||||
{
|
{
|
||||||
ERR( "called for stock bitmap, please report\n" );
|
ERR( "called for stock bitmap, please report\n" );
|
||||||
goto done;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("(%p) %dx%d %d bpp\n", hbitmap, bmp->bitmap.bmWidth,
|
TRACE("(%p) %dx%d %d bpp\n", hbitmap, bitmap.bmWidth, bitmap.bmHeight, bitmap.bmBitsPixel);
|
||||||
bmp->bitmap.bmHeight, bmp->bitmap.bmBitsPixel);
|
|
||||||
|
|
||||||
if (!(physBitmap = X11DRV_init_phys_bitmap( hbitmap ))) goto done;
|
if (!(physBitmap = X11DRV_init_phys_bitmap( hbitmap ))) return FALSE;
|
||||||
|
|
||||||
/* Create the pixmap */
|
/* Create the pixmap */
|
||||||
wine_tsx11_lock();
|
wine_tsx11_lock();
|
||||||
|
physBitmap->pixmap_depth = bitmap.bmBitsPixel;
|
||||||
physBitmap->pixmap = XCreatePixmap(gdi_display, root_window,
|
physBitmap->pixmap = XCreatePixmap(gdi_display, root_window,
|
||||||
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
|
bitmap.bmWidth, bitmap.bmHeight, bitmap.bmBitsPixel);
|
||||||
bmp->bitmap.bmBitsPixel);
|
|
||||||
wine_tsx11_unlock();
|
wine_tsx11_unlock();
|
||||||
if (!physBitmap->pixmap)
|
if (!physBitmap->pixmap)
|
||||||
{
|
{
|
||||||
WARN("Can't create Pixmap\n");
|
WARN("Can't create Pixmap\n");
|
||||||
HeapFree( GetProcessHeap(), 0, physBitmap );
|
HeapFree( GetProcessHeap(), 0, physBitmap );
|
||||||
goto done;
|
return FALSE;
|
||||||
}
|
}
|
||||||
bmp->physBitmap = physBitmap;
|
|
||||||
ret = TRUE;
|
|
||||||
|
|
||||||
if (bmp->bitmap.bmBits) /* Set bitmap bits */
|
if (bitmap.bmBits) /* Set bitmap bits */
|
||||||
X11DRV_SetBitmapBits( hbitmap, bmp->bitmap.bmBits,
|
X11DRV_SetBitmapBits( hbitmap, bitmap.bmBits, bitmap.bmHeight * bitmap.bmWidthBytes );
|
||||||
bmp->bitmap.bmHeight * bmp->bitmap.bmWidthBytes );
|
return TRUE;
|
||||||
|
|
||||||
done:
|
|
||||||
GDI_ReleaseObj( hbitmap );
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -417,25 +407,20 @@ LONG X11DRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count )
|
||||||
*/
|
*/
|
||||||
BOOL X11DRV_DeleteBitmap( HBITMAP hbitmap )
|
BOOL X11DRV_DeleteBitmap( HBITMAP hbitmap )
|
||||||
{
|
{
|
||||||
BITMAPOBJ *bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
|
X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
|
||||||
if (bmp)
|
|
||||||
|
if (physBitmap)
|
||||||
{
|
{
|
||||||
X_PHYSBITMAP *physBitmap = bmp->physBitmap;
|
DIBSECTION dib;
|
||||||
|
|
||||||
if (physBitmap)
|
if (GetObjectW( hbitmap, sizeof(dib), &dib ) == sizeof(dib))
|
||||||
{
|
X11DRV_DIB_DeleteDIBSection( physBitmap, &dib );
|
||||||
DIBSECTION dib;
|
|
||||||
|
|
||||||
if (GetObjectW( hbitmap, sizeof(dib), &dib ) == sizeof(dib))
|
wine_tsx11_lock();
|
||||||
X11DRV_DIB_DeleteDIBSection( physBitmap, &dib );
|
if (physBitmap->pixmap) XFreePixmap( gdi_display, physBitmap->pixmap );
|
||||||
|
XDeleteContext( gdi_display, (XID)hbitmap, bitmap_context );
|
||||||
wine_tsx11_lock();
|
wine_tsx11_unlock();
|
||||||
if (physBitmap->pixmap) XFreePixmap( gdi_display, physBitmap->pixmap );
|
HeapFree( GetProcessHeap(), 0, physBitmap );
|
||||||
wine_tsx11_unlock();
|
|
||||||
HeapFree( GetProcessHeap(), 0, physBitmap );
|
|
||||||
bmp->physBitmap = NULL;
|
|
||||||
}
|
|
||||||
GDI_ReleaseObj( hbitmap );
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -448,13 +433,11 @@ BOOL X11DRV_DeleteBitmap( HBITMAP hbitmap )
|
||||||
*/
|
*/
|
||||||
X_PHYSBITMAP *X11DRV_get_phys_bitmap( HBITMAP hbitmap )
|
X_PHYSBITMAP *X11DRV_get_phys_bitmap( HBITMAP hbitmap )
|
||||||
{
|
{
|
||||||
X_PHYSBITMAP *ret = NULL;
|
X_PHYSBITMAP *ret;
|
||||||
BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
|
|
||||||
if (bmp)
|
wine_tsx11_lock();
|
||||||
{
|
if (XFindContext( gdi_display, (XID)hbitmap, bitmap_context, (char **)&ret )) ret = NULL;
|
||||||
ret = bmp->physBitmap;
|
wine_tsx11_unlock();
|
||||||
GDI_ReleaseObj( hbitmap );
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,25 +445,18 @@ X_PHYSBITMAP *X11DRV_get_phys_bitmap( HBITMAP hbitmap )
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* X11DRV_init_phys_bitmap
|
* X11DRV_init_phys_bitmap
|
||||||
*
|
*
|
||||||
* Initialize the X physical bitmap info if necessary.
|
* Initialize the X physical bitmap info.
|
||||||
*/
|
*/
|
||||||
X_PHYSBITMAP *X11DRV_init_phys_bitmap( HBITMAP hbitmap )
|
X_PHYSBITMAP *X11DRV_init_phys_bitmap( HBITMAP hbitmap )
|
||||||
{
|
{
|
||||||
X_PHYSBITMAP *ret = NULL;
|
X_PHYSBITMAP *ret;
|
||||||
BITMAPOBJ *bmp = GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
|
|
||||||
if (bmp)
|
if ((ret = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret) )) != NULL)
|
||||||
{
|
{
|
||||||
if (!(ret = bmp->physBitmap))
|
ret->hbitmap = hbitmap;
|
||||||
{
|
wine_tsx11_lock();
|
||||||
if ((ret = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret) )) != NULL)
|
XSaveContext( gdi_display, (XID)hbitmap, bitmap_context, (char *)ret );
|
||||||
{
|
wine_tsx11_unlock();
|
||||||
ret->hbitmap = hbitmap;
|
|
||||||
ret->pixmap = 0;
|
|
||||||
ret->pixmap_depth = bmp->bitmap.bmBitsPixel;
|
|
||||||
bmp->physBitmap = ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GDI_ReleaseObj( hbitmap );
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue