Alexandre Julliard : winex11.drv:
Store the palette mapping in an X context instead of the GDI object.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Nov 17 11:49:03 CST 2006
Module: wine
Branch: master
Commit: 5e7afb8c3bda9cff32d698220d9511b1e90892de
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5e7afb8c3bda9cff32d698220d9511b1e90892de
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Nov 17 14:38:43 2006 +0100
winex11.drv: Store the palette mapping in an X context instead of the GDI object.
---
dlls/winex11.drv/palette.c | 59 +++++++++++++++++++++++++------------
dlls/winex11.drv/winex11.drv.spec | 1 +
2 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/dlls/winex11.drv/palette.c b/dlls/winex11.drv/palette.c
index 026b28c..7ccfed7 100644
--- a/dlls/winex11.drv/palette.c
+++ b/dlls/winex11.drv/palette.c
@@ -20,11 +20,12 @@
#include "config.h"
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include "gdi.h"
#include "windef.h"
+#include "winbase.h"
#include "winreg.h"
#include "x11drv.h"
#include "wine/debug.h"
@@ -48,6 +49,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(palette);
* http://premium.microsoft.com/msdn/library/techart/f30/f34/f40/d4d/sa942.htm
*/
+#define NB_RESERVED_COLORS 20 /* number of fixed colors in system palette */
+
#define PC_SYS_USED 0x80 /* palentry is used (both system and logical) */
#define PC_SYS_RESERVED 0x40 /* system palentry is not to be mapped to */
@@ -81,6 +84,8 @@ static int palette_size;
static int X11DRV_PALETTE_firstFree = 0;
static unsigned char X11DRV_PALETTE_freeList[256];
+static XContext palette_context; /* X context to associate a color mapping to a palette */
+
/**********************************************************************/
/* Map an EGA index (0..15) to a pixel value in the system color space. */
@@ -114,14 +119,11 @@ static int X11DRV_PALETTE_LookupSystemXP
*/
static int *palette_get_mapping( HPALETTE hpal )
{
- int *mapping = NULL;
- PALETTEOBJ *ptr;
+ int *mapping;
- if ((ptr = GDI_GetObjPtr( hpal, PALETTE_MAGIC )))
- {
- mapping = ptr->mapping;
- GDI_ReleaseObj( hpal );
- }
+ wine_tsx11_lock();
+ if (XFindContext( gdi_display, (XID)hpal, palette_context, (char **)&mapping )) mapping = NULL;
+ wine_tsx11_unlock();
return mapping;
}
@@ -129,18 +131,11 @@ static int *palette_get_mapping( HPALETT
/***********************************************************************
* palette_set_mapping
*/
-static int *palette_set_mapping( HPALETTE hpal, int *mapping )
+static void palette_set_mapping( HPALETTE hpal, int *mapping )
{
- int *old_mapping = NULL;
- PALETTEOBJ *ptr;
-
- if ((ptr = GDI_GetObjPtr( hpal, PALETTE_MAGIC )))
- {
- old_mapping = ptr->mapping;
- ptr->mapping = mapping;
- GDI_ReleaseObj( hpal );
- }
- return old_mapping;
+ wine_tsx11_lock();
+ XSaveContext( gdi_display, (XID)hpal, palette_context, (char *)mapping );
+ wine_tsx11_unlock();
}
@@ -153,10 +148,14 @@ int X11DRV_PALETTE_Init(void)
{
int mask, white, black;
int monoPlane;
+ int *mapping;
PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS];
TRACE("initializing palette manager...\n");
+ wine_tsx11_lock();
+ palette_context = XUniqueContext();
+ wine_tsx11_unlock();
white = WhitePixel( gdi_display, DefaultScreen(gdi_display) );
black = BlackPixel( gdi_display, DefaultScreen(gdi_display) );
monoPlane = 1;
@@ -244,6 +243,9 @@ int X11DRV_PALETTE_Init(void)
GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, NB_RESERVED_COLORS, sys_pal_template );
+ if ((mapping = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(int) * NB_RESERVED_COLORS )))
+ palette_set_mapping( GetStockObject(DEFAULT_PALETTE), mapping );
+
if( X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_VIRTUAL )
{
palette_size = 0;
@@ -1195,6 +1197,25 @@ UINT X11DRV_RealizePalette( X11DRV_PDEVI
return iRemapped;
}
+
+/***********************************************************************
+ * UnrealizePalette (X11DRV.@)
+ */
+BOOL X11DRV_UnrealizePalette( HPALETTE hpal )
+{
+ int *mapping = palette_get_mapping( hpal );
+
+ if (mapping)
+ {
+ wine_tsx11_lock();
+ XDeleteContext( gdi_display, (XID)hpal, palette_context );
+ wine_tsx11_unlock();
+ HeapFree( GetProcessHeap(), 0, mapping );
+ }
+ return TRUE;
+}
+
+
/***********************************************************************
* GetSystemPaletteEntries (X11DRV.@)
*/
diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec
index e6dc141..92756a6 100644
--- a/dlls/winex11.drv/winex11.drv.spec
+++ b/dlls/winex11.drv/winex11.drv.spec
@@ -59,6 +59,7 @@
@ cdecl SetTextColor(ptr long) X11DRV_SetTextColor
@ cdecl StretchBlt(ptr long long long long ptr long long long long long) X11DRV_StretchBlt
@ cdecl SwapBuffers(ptr) X11DRV_SwapBuffers
+@ cdecl UnrealizePalette(long) X11DRV_UnrealizePalette
# USER driver
More information about the wine-cvs
mailing list