Better separation of the palette functions.
Removed the palette driver.
This commit is contained in:
parent
0d588a4a82
commit
376e65092a
|
@ -21,7 +21,6 @@ C_SRCS = \
|
|||
$(TOPOBJDIR)/objects/bitmap.c \
|
||||
$(TOPOBJDIR)/objects/brush.c \
|
||||
$(TOPOBJDIR)/objects/clipping.c \
|
||||
$(TOPOBJDIR)/objects/color.c \
|
||||
$(TOPOBJDIR)/objects/dc.c \
|
||||
$(TOPOBJDIR)/objects/dcvalues.c \
|
||||
$(TOPOBJDIR)/objects/dib.c \
|
||||
|
|
|
@ -101,8 +101,10 @@ static struct graphics_driver *create_driver( HMODULE module )
|
|||
GET_FUNC(GetDIBits);
|
||||
GET_FUNC(GetDeviceCaps);
|
||||
GET_FUNC(GetDeviceGammaRamp);
|
||||
GET_FUNC(GetNearestColor);
|
||||
GET_FUNC(GetPixel);
|
||||
GET_FUNC(GetPixelFormat);
|
||||
GET_FUNC(GetSystemPaletteEntries);
|
||||
GET_FUNC(GetTextExtentPoint);
|
||||
GET_FUNC(GetTextMetrics);
|
||||
GET_FUNC(IntersectClipRect);
|
||||
|
@ -123,6 +125,7 @@ static struct graphics_driver *create_driver( HMODULE module )
|
|||
GET_FUNC(Polygon);
|
||||
GET_FUNC(Polyline);
|
||||
GET_FUNC(PolylineTo);
|
||||
GET_FUNC(RealizeDefaultPalette);
|
||||
GET_FUNC(RealizePalette);
|
||||
GET_FUNC(Rectangle);
|
||||
GET_FUNC(ResetDC);
|
||||
|
|
|
@ -69,8 +69,10 @@ static const DC_FUNCTIONS EMFDRV_Funcs =
|
|||
NULL, /* pGetDIBits */
|
||||
NULL, /* pGetDeviceCaps */
|
||||
NULL, /* pGetDeviceGammaRamp */
|
||||
NULL, /* pGetNearestColor */
|
||||
NULL, /* pGetPixel */
|
||||
NULL, /* pGetPixelFormat */
|
||||
NULL, /* pGetSystemPaletteEntries */
|
||||
NULL, /* pGetTextExtentPoint */
|
||||
NULL, /* pGetTextMetrics */
|
||||
EMFDRV_IntersectClipRect, /* pIntersectClipRect */
|
||||
|
@ -91,6 +93,7 @@ static const DC_FUNCTIONS EMFDRV_Funcs =
|
|||
EMFDRV_Polygon, /* pPolygon */
|
||||
EMFDRV_Polyline, /* pPolyline */
|
||||
NULL, /* pPolylineTo */
|
||||
NULL, /* pRealizeDefaultPalette */
|
||||
NULL, /* pRealizePalette */
|
||||
EMFDRV_Rectangle, /* pRectangle */
|
||||
NULL, /* pResetDC */
|
||||
|
|
|
@ -70,8 +70,10 @@ static const DC_FUNCTIONS MFDRV_Funcs =
|
|||
NULL, /* pGetDIBits */
|
||||
NULL, /* pGetDeviceCaps */
|
||||
NULL, /* pGetDeviceGammaRamp */
|
||||
NULL, /* pGetNearestColor */
|
||||
NULL, /* pGetPixel */
|
||||
NULL, /* pGetPixelFormat */
|
||||
NULL, /* pGetSystemPaletteEntries */
|
||||
NULL, /* pGetTextExtentPoint */
|
||||
NULL, /* pGetTextMetrics */
|
||||
MFDRV_IntersectClipRect, /* pIntersectClipRect */
|
||||
|
@ -92,6 +94,7 @@ static const DC_FUNCTIONS MFDRV_Funcs =
|
|||
MFDRV_Polygon, /* pPolygon */
|
||||
MFDRV_Polyline, /* pPolyline */
|
||||
NULL, /* pPolylineTo */
|
||||
NULL, /* pRealizeDefaultPalette */
|
||||
NULL, /* pRealizePalette */
|
||||
MFDRV_Rectangle, /* pRectangle */
|
||||
NULL, /* pResetDC */
|
||||
|
|
|
@ -97,8 +97,10 @@ static const DC_FUNCTIONS WIN16DRV_Funcs =
|
|||
NULL, /* pGetDIBits */
|
||||
WIN16DRV_GetDeviceCaps, /* pGetDeviceCaps */
|
||||
NULL, /* pGetDeviceGammaRamp */
|
||||
NULL, /* pGetNearestColor */
|
||||
NULL, /* pGetPixel */
|
||||
NULL, /* pGetPixelFormat */
|
||||
NULL, /* pGetSystemPaletteEntries */
|
||||
WIN16DRV_GetTextExtentPoint, /* pGetTextExtentPoint */
|
||||
WIN16DRV_GetTextMetrics, /* pGetTextMetrics */
|
||||
NULL, /* pIntersectClipRect */
|
||||
|
@ -119,6 +121,7 @@ static const DC_FUNCTIONS WIN16DRV_Funcs =
|
|||
WIN16DRV_Polygon, /* pPolygon */
|
||||
WIN16DRV_Polyline, /* pPolyline */
|
||||
NULL, /* pPolylineTo */
|
||||
NULL, /* pRealizeDefaultPalette */
|
||||
NULL, /* pRealizePalette */
|
||||
WIN16DRV_Rectangle, /* pRectangle */
|
||||
NULL, /* pResetDC */
|
||||
|
@ -444,5 +447,3 @@ static INT WIN16DRV_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in
|
|||
FIXME("temporarily broken, please fix\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,28 +22,26 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "wine/debug.h"
|
||||
#include "palette.h"
|
||||
#include "winbase.h"
|
||||
#include "ttydrv.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(ttydrv);
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
extern PALETTEENTRY *COLOR_sysPal;
|
||||
static PALETTEENTRY *COLOR_sysPal;
|
||||
|
||||
static int palette_size = 256; /* FIXME */
|
||||
|
||||
extern const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS];
|
||||
|
||||
/***********************************************************************
|
||||
* TTYDRV_PALETTE_Initialize
|
||||
*/
|
||||
BOOL TTYDRV_PALETTE_Initialize(void)
|
||||
{
|
||||
int i;
|
||||
PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS];
|
||||
|
||||
TRACE("(void)\n");
|
||||
|
||||
|
@ -53,14 +51,16 @@ BOOL TTYDRV_PALETTE_Initialize(void)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, NB_RESERVED_COLORS, sys_pal_template );
|
||||
|
||||
for(i=0; i < palette_size; i++ ) {
|
||||
const PALETTEENTRY *src;
|
||||
PALETTEENTRY *dst = &COLOR_sysPal[i];
|
||||
|
||||
if(i < NB_RESERVED_COLORS/2) {
|
||||
src = &COLOR_sysPalTemplate[i];
|
||||
src = &sys_pal_template[i];
|
||||
} else if(i >= palette_size - NB_RESERVED_COLORS/2) {
|
||||
src = &COLOR_sysPalTemplate[NB_RESERVED_COLORS + i - palette_size];
|
||||
src = &sys_pal_template[NB_RESERVED_COLORS + i - palette_size];
|
||||
} else {
|
||||
PALETTEENTRY pe = { 0, 0, 0, 0 };
|
||||
src = &pe;
|
||||
|
@ -81,3 +81,27 @@ BOOL TTYDRV_PALETTE_Initialize(void)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* GetSystemPaletteEntries (TTYDRV.@)
|
||||
*/
|
||||
UINT TTYDRV_GetSystemPaletteEntries( TTYDRV_PDEVICE *dev, UINT start, UINT count,
|
||||
LPPALETTEENTRY entries )
|
||||
{
|
||||
UINT i;
|
||||
|
||||
if (!entries) return palette_size;
|
||||
if (start >= palette_size) return 0;
|
||||
if (start + count >= palette_size) count = palette_size - start;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
entries[i].peRed = COLOR_sysPal[start + i].peRed;
|
||||
entries[i].peGreen = COLOR_sysPal[start + i].peGreen;
|
||||
entries[i].peBlue = COLOR_sysPal[start + i].peBlue;
|
||||
entries[i].peFlags = 0;
|
||||
TRACE("\tidx(%02x) -> RGB(%08lx)\n", start + i, *(COLORREF*)(entries + i) );
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ init TTYDRV_Init
|
|||
@ cdecl GetCharWidth(ptr long long ptr) TTYDRV_DC_GetCharWidth
|
||||
@ cdecl GetDeviceCaps(ptr long) TTYDRV_GetDeviceCaps
|
||||
@ cdecl GetPixel(ptr long long) TTYDRV_DC_GetPixel
|
||||
@ cdecl GetSystemPaletteEntries(ptr long long ptr) TTYDRV_GetSystemPaletteEntries
|
||||
@ cdecl GetTextExtentPoint(ptr ptr long ptr) TTYDRV_DC_GetTextExtentPoint
|
||||
@ cdecl GetTextMetrics(ptr ptr) TTYDRV_DC_GetTextMetrics
|
||||
@ cdecl LineTo(ptr long long) TTYDRV_DC_LineTo
|
||||
|
|
|
@ -25,8 +25,10 @@ init X11DRV_Init
|
|||
@ cdecl GetDIBits(ptr long long long ptr ptr long) X11DRV_GetDIBits
|
||||
@ cdecl GetDeviceCaps(ptr long) X11DRV_GetDeviceCaps
|
||||
@ cdecl GetDeviceGammaRamp(ptr ptr) X11DRV_GetDeviceGammaRamp
|
||||
@ cdecl GetNearestColor(ptr long) X11DRV_GetNearestColor
|
||||
@ cdecl GetPixel(ptr long long) X11DRV_GetPixel
|
||||
@ cdecl GetPixelFormat(ptr) X11DRV_GetPixelFormat
|
||||
@ cdecl GetSystemPaletteEntries(ptr long long ptr) X11DRV_GetSystemPaletteEntries
|
||||
@ cdecl GetTextExtentPoint(ptr ptr long ptr) X11DRV_GetTextExtentPoint
|
||||
@ cdecl GetTextMetrics(ptr ptr) X11DRV_GetTextMetrics
|
||||
@ cdecl LineTo(ptr long long) X11DRV_LineTo
|
||||
|
@ -37,6 +39,8 @@ init X11DRV_Init
|
|||
@ cdecl PolyPolyline(ptr ptr ptr long) X11DRV_PolyPolyline
|
||||
@ cdecl Polygon(ptr ptr long) X11DRV_Polygon
|
||||
@ cdecl Polyline(ptr ptr long) X11DRV_Polyline
|
||||
@ cdecl RealizeDefaultPalette(ptr) X11DRV_RealizeDefaultPalette
|
||||
@ cdecl RealizePalette(ptr long long) X11DRV_RealizePalette
|
||||
@ cdecl Rectangle(ptr long long long long) X11DRV_Rectangle
|
||||
@ cdecl RoundRect(ptr long long long long long long) X11DRV_RoundRect
|
||||
@ cdecl SelectBitmap(ptr long) X11DRV_SelectBitmap
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "bitmap.h"
|
||||
#include "color.h"
|
||||
#include "x11drv.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
|
|
|
@ -25,25 +25,16 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "bitmap.h"
|
||||
#include "palette.h"
|
||||
#include "wine/debug.h"
|
||||
#include "winnt.h"
|
||||
#include "x11drv.h"
|
||||
#include "x11font.h"
|
||||
#include "ddrawi.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
||||
|
||||
const DC_FUNCTIONS *X11DRV_DC_Funcs = NULL; /* hack */
|
||||
|
||||
PALETTE_DRIVER X11DRV_PALETTE_Driver =
|
||||
{
|
||||
X11DRV_PALETTE_SetMapping,
|
||||
X11DRV_PALETTE_UpdateMapping,
|
||||
X11DRV_PALETTE_IsDark
|
||||
};
|
||||
|
||||
|
||||
Display *gdi_display; /* display to use for all GDI functions */
|
||||
|
||||
/* a few dynamic device caps */
|
||||
|
@ -65,7 +56,6 @@ BOOL X11DRV_GDI_Initialize( Display *display )
|
|||
Screen *screen = DefaultScreenOfDisplay(display);
|
||||
|
||||
gdi_display = display;
|
||||
PALETTE_Driver = &X11DRV_PALETTE_Driver;
|
||||
|
||||
palette_size = X11DRV_PALETTE_Init();
|
||||
|
||||
|
|
|
@ -25,13 +25,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "wine/debug.h"
|
||||
#include "gdi.h"
|
||||
#include "palette.h"
|
||||
#include "windef.h"
|
||||
#include "winreg.h"
|
||||
#include "x11drv.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(palette);
|
||||
|
||||
|
@ -52,8 +51,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(palette);
|
|||
* http://premium.microsoft.com/msdn/library/techart/f30/f34/f40/d4d/sa942.htm
|
||||
*/
|
||||
|
||||
extern PALETTEENTRY *COLOR_sysPal;
|
||||
extern const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS];
|
||||
static PALETTEENTRY *COLOR_sysPal; /* current system palette */
|
||||
|
||||
static int COLOR_gapStart = 256;
|
||||
static int COLOR_gapEnd = -1;
|
||||
|
@ -103,12 +101,12 @@ int *X11DRV_PALETTE_XPixelToPalette = NULL;
|
|||
|
||||
/**********************************************************************/
|
||||
|
||||
static BOOL X11DRV_PALETTE_BuildPrivateMap(void);
|
||||
static BOOL X11DRV_PALETTE_BuildSharedMap(void);
|
||||
static BOOL X11DRV_PALETTE_BuildPrivateMap( const PALETTEENTRY *sys_pal_template );
|
||||
static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template );
|
||||
static void X11DRV_PALETTE_ComputeShifts(unsigned long maskbits, ColorShifts *physical, ColorShifts *to_logical);
|
||||
static void X11DRV_PALETTE_FillDefaultColors(void);
|
||||
static void X11DRV_PALETTE_FillDefaultColors( const PALETTEENTRY *sys_pal_template );
|
||||
static void X11DRV_PALETTE_FormatSystemPalette(void);
|
||||
static BOOL X11DRV_PALETTE_CheckSysColor(COLORREF c);
|
||||
static BOOL X11DRV_PALETTE_CheckSysColor( const PALETTEENTRY *sys_pal_template, COLORREF c);
|
||||
static int X11DRV_PALETTE_LookupSystemXPixel(COLORREF col);
|
||||
|
||||
|
||||
|
@ -121,6 +119,7 @@ int X11DRV_PALETTE_Init(void)
|
|||
{
|
||||
int mask, white, black;
|
||||
int monoPlane;
|
||||
PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS];
|
||||
|
||||
TRACE("initializing palette manager...\n");
|
||||
|
||||
|
@ -220,17 +219,19 @@ int X11DRV_PALETTE_Init(void)
|
|||
|
||||
memset(X11DRV_PALETTE_freeList, 0, 256*sizeof(unsigned char));
|
||||
|
||||
GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, NB_RESERVED_COLORS, sys_pal_template );
|
||||
|
||||
if (X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_PRIVATE)
|
||||
X11DRV_PALETTE_BuildPrivateMap();
|
||||
X11DRV_PALETTE_BuildPrivateMap( sys_pal_template );
|
||||
else
|
||||
X11DRV_PALETTE_BuildSharedMap();
|
||||
X11DRV_PALETTE_BuildSharedMap( sys_pal_template );
|
||||
|
||||
/* Build free list */
|
||||
|
||||
if( X11DRV_PALETTE_firstFree != -1 )
|
||||
X11DRV_PALETTE_FormatSystemPalette();
|
||||
|
||||
X11DRV_PALETTE_FillDefaultColors();
|
||||
X11DRV_PALETTE_FillDefaultColors( sys_pal_template );
|
||||
|
||||
if( X11DRV_PALETTE_PaletteFlags & X11DRV_PALETTE_VIRTUAL )
|
||||
palette_size = 0;
|
||||
|
@ -304,7 +305,7 @@ static void X11DRV_PALETTE_ComputeShifts(unsigned long maskbits, ColorShifts *ph
|
|||
*
|
||||
* Allocate colorcells and initialize mapping tables.
|
||||
*/
|
||||
static BOOL X11DRV_PALETTE_BuildPrivateMap(void)
|
||||
static BOOL X11DRV_PALETTE_BuildPrivateMap( const PALETTEENTRY *sys_pal_template )
|
||||
{
|
||||
/* Private colormap - identity mapping */
|
||||
|
||||
|
@ -324,18 +325,20 @@ static BOOL X11DRV_PALETTE_BuildPrivateMap(void)
|
|||
{
|
||||
if( i < NB_RESERVED_COLORS/2 )
|
||||
{
|
||||
color.red = COLOR_sysPalTemplate[i].peRed * 65535 / 255;
|
||||
color.green = COLOR_sysPalTemplate[i].peGreen * 65535 / 255;
|
||||
color.blue = COLOR_sysPalTemplate[i].peBlue * 65535 / 255;
|
||||
COLOR_sysPal[i] = COLOR_sysPalTemplate[i];
|
||||
color.red = sys_pal_template[i].peRed * 65535 / 255;
|
||||
color.green = sys_pal_template[i].peGreen * 65535 / 255;
|
||||
color.blue = sys_pal_template[i].peBlue * 65535 / 255;
|
||||
COLOR_sysPal[i] = sys_pal_template[i];
|
||||
COLOR_sysPal[i].peFlags |= PC_SYS_USED;
|
||||
}
|
||||
else if( i >= palette_size - NB_RESERVED_COLORS/2 )
|
||||
{
|
||||
int j = NB_RESERVED_COLORS + i - palette_size;
|
||||
color.red = COLOR_sysPalTemplate[j].peRed * 65535 / 255;
|
||||
color.green = COLOR_sysPalTemplate[j].peGreen * 65535 / 255;
|
||||
color.blue = COLOR_sysPalTemplate[j].peBlue * 65535 / 255;
|
||||
COLOR_sysPal[i] = COLOR_sysPalTemplate[j];
|
||||
color.red = sys_pal_template[j].peRed * 65535 / 255;
|
||||
color.green = sys_pal_template[j].peGreen * 65535 / 255;
|
||||
color.blue = sys_pal_template[j].peBlue * 65535 / 255;
|
||||
COLOR_sysPal[i] = sys_pal_template[j];
|
||||
COLOR_sysPal[i].peFlags |= PC_SYS_USED;
|
||||
}
|
||||
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
|
@ -364,7 +367,7 @@ static BOOL X11DRV_PALETTE_BuildPrivateMap(void)
|
|||
*
|
||||
* Allocate colorcells and initialize mapping tables.
|
||||
*/
|
||||
static BOOL X11DRV_PALETTE_BuildSharedMap(void)
|
||||
static BOOL X11DRV_PALETTE_BuildSharedMap( const PALETTEENTRY *sys_pal_template )
|
||||
{
|
||||
XColor color;
|
||||
unsigned long sysPixel[NB_RESERVED_COLORS];
|
||||
|
@ -418,9 +421,9 @@ static BOOL X11DRV_PALETTE_BuildSharedMap(void)
|
|||
|
||||
for( i = 0; i < NB_RESERVED_COLORS; i++ )
|
||||
{
|
||||
color.red = COLOR_sysPalTemplate[i].peRed * 65535 / 255;
|
||||
color.green = COLOR_sysPalTemplate[i].peGreen * 65535 / 255;
|
||||
color.blue = COLOR_sysPalTemplate[i].peBlue * 65535 / 255;
|
||||
color.red = sys_pal_template[i].peRed * 65535 / 255;
|
||||
color.green = sys_pal_template[i].peGreen * 65535 / 255;
|
||||
color.blue = sys_pal_template[i].peBlue * 65535 / 255;
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
if (!TSXAllocColor( gdi_display, X11DRV_PALETTE_PaletteXColormap, &color ))
|
||||
|
@ -445,9 +448,9 @@ static BOOL X11DRV_PALETTE_BuildSharedMap(void)
|
|||
/* reinit color (XAllocColor() may change it)
|
||||
* and map to the best shared colorcell */
|
||||
|
||||
color.red = COLOR_sysPalTemplate[i].peRed * 65535 / 255;
|
||||
color.green = COLOR_sysPalTemplate[i].peGreen * 65535 / 255;
|
||||
color.blue = COLOR_sysPalTemplate[i].peBlue * 65535 / 255;
|
||||
color.red = sys_pal_template[i].peRed * 65535 / 255;
|
||||
color.green = sys_pal_template[i].peGreen * 65535 / 255;
|
||||
color.blue = sys_pal_template[i].peBlue * 65535 / 255;
|
||||
|
||||
best.pixel = best.red = best.green = best.blue = 0;
|
||||
for( c.pixel = 0, diff = 0x7fffffff; c.pixel < max; c.pixel += step )
|
||||
|
@ -468,7 +471,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap(void)
|
|||
sysPixel[i] = color.pixel;
|
||||
|
||||
TRACE("syscolor(%lx) -> pixel %i\n",
|
||||
*(COLORREF*)(COLOR_sysPalTemplate+i), (int)color.pixel);
|
||||
*(COLORREF*)(sys_pal_template+i), (int)color.pixel);
|
||||
|
||||
/* Set EGA mapping if color in the first or last eight */
|
||||
|
||||
|
@ -598,12 +601,14 @@ static BOOL X11DRV_PALETTE_BuildSharedMap(void)
|
|||
if( i < NB_RESERVED_COLORS/2 )
|
||||
{
|
||||
X11DRV_PALETTE_PaletteToXPixel[i] = sysPixel[i];
|
||||
COLOR_sysPal[i] = COLOR_sysPalTemplate[i];
|
||||
COLOR_sysPal[i] = sys_pal_template[i];
|
||||
COLOR_sysPal[i].peFlags |= PC_SYS_USED;
|
||||
}
|
||||
else if( i >= 256 - NB_RESERVED_COLORS/2 )
|
||||
{
|
||||
X11DRV_PALETTE_PaletteToXPixel[i] = sysPixel[(i + NB_RESERVED_COLORS) - 256];
|
||||
COLOR_sysPal[i] = COLOR_sysPalTemplate[(i + NB_RESERVED_COLORS) - 256];
|
||||
COLOR_sysPal[i] = sys_pal_template[(i + NB_RESERVED_COLORS) - 256];
|
||||
COLOR_sysPal[i].peFlags |= PC_SYS_USED;
|
||||
}
|
||||
else if( pixDynMapping )
|
||||
X11DRV_PALETTE_PaletteToXPixel[i] = pixDynMapping[j++];
|
||||
|
@ -624,7 +629,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap(void)
|
|||
/***********************************************************************
|
||||
* Colormap Initialization
|
||||
*/
|
||||
static void X11DRV_PALETTE_FillDefaultColors(void)
|
||||
static void X11DRV_PALETTE_FillDefaultColors( const PALETTEENTRY *sys_pal_template )
|
||||
{
|
||||
/* initialize unused entries to what Windows uses as a color
|
||||
* cube - based on Greg Kreider's code.
|
||||
|
@ -701,7 +706,7 @@ static void X11DRV_PALETTE_FillDefaultColors(void)
|
|||
TSXQueryColor(gdi_display, X11DRV_PALETTE_PaletteXColormap, &xc);
|
||||
r = xc.red>>8; g = xc.green>>8; b = xc.blue>>8;
|
||||
|
||||
if( xc.pixel < 256 && X11DRV_PALETTE_CheckSysColor(RGB(r, g, b)) &&
|
||||
if( xc.pixel < 256 && X11DRV_PALETTE_CheckSysColor( sys_pal_template, RGB(r, g, b)) &&
|
||||
TSXAllocColor(gdi_display, X11DRV_PALETTE_PaletteXColormap, &xc) )
|
||||
{
|
||||
X11DRV_PALETTE_XPixelToPalette[xc.pixel] = idx;
|
||||
|
@ -788,6 +793,33 @@ COLORREF X11DRV_PALETTE_ToLogical(int pixel)
|
|||
return RGB(color.red >> 8, color.green >> 8, color.blue >> 8);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* X11DRV_SysPaletteLookupPixel
|
||||
*/
|
||||
static int X11DRV_SysPaletteLookupPixel( COLORREF col, BOOL skipReserved )
|
||||
{
|
||||
int i, best = 0, diff = 0x7fffffff;
|
||||
int r,g,b;
|
||||
|
||||
for( i = 0; i < palette_size && diff ; i++ )
|
||||
{
|
||||
if( !(COLOR_sysPal[i].peFlags & PC_SYS_USED) ||
|
||||
(skipReserved && COLOR_sysPal[i].peFlags & PC_SYS_RESERVED) )
|
||||
continue;
|
||||
|
||||
r = COLOR_sysPal[i].peRed - GetRValue(col);
|
||||
g = COLOR_sysPal[i].peGreen - GetGValue(col);
|
||||
b = COLOR_sysPal[i].peBlue - GetBValue(col);
|
||||
|
||||
r = r*r + g*g + b*b;
|
||||
|
||||
if( r < diff ) { best = i; diff = r; }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* X11DRV_PALETTE_ToPhysical
|
||||
*
|
||||
|
@ -898,8 +930,8 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
|
|||
((color >> 8) & 0xff) + (color & 0xff) > 255*3/2) ? 1 : 0;
|
||||
}
|
||||
|
||||
index = COLOR_PaletteLookupPixel( COLOR_sysPal, 256,
|
||||
X11DRV_PALETTE_PaletteToXPixel, color, FALSE);
|
||||
index = X11DRV_SysPaletteLookupPixel( color, FALSE);
|
||||
if (X11DRV_PALETTE_PaletteToXPixel) index = X11DRV_PALETTE_PaletteToXPixel[index];
|
||||
|
||||
/* TRACE(palette,"RGB(%lx) -> pixel %i\n", color, index);
|
||||
*/
|
||||
|
@ -915,9 +947,8 @@ int X11DRV_PALETTE_ToPhysical( X11DRV_PDEVICE *physDev, COLORREF color )
|
|||
*/
|
||||
break;
|
||||
case 2: /* PALETTERGB */
|
||||
index = COLOR_PaletteLookupPixel( palPtr->logpalette.palPalEntry,
|
||||
palPtr->logpalette.palNumEntries,
|
||||
palPtr->mapping, color, FALSE);
|
||||
index = GetNearestPaletteIndex( hPal, color );
|
||||
if (palPtr->mapping) index = palPtr->mapping[index];
|
||||
/* TRACE(palette,"PALETTERGB(%lx) -> pixel %i\n", color, index);
|
||||
*/
|
||||
break;
|
||||
|
@ -982,26 +1013,47 @@ static void X11DRV_PALETTE_FormatSystemPalette(void)
|
|||
/***********************************************************************
|
||||
* X11DRV_PALETTE_CheckSysColor
|
||||
*/
|
||||
static BOOL X11DRV_PALETTE_CheckSysColor(COLORREF c)
|
||||
static BOOL X11DRV_PALETTE_CheckSysColor( const PALETTEENTRY *sys_pal_template, COLORREF c)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < NB_RESERVED_COLORS; i++ )
|
||||
if( c == (*(COLORREF*)(COLOR_sysPalTemplate + i) & 0x00ffffff) )
|
||||
if( c == (*(COLORREF*)(sys_pal_template + i) & 0x00ffffff) )
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* X11DRV_LookupSysPaletteExact
|
||||
*/
|
||||
static int X11DRV_LookupSysPaletteExact( COLORREF col )
|
||||
{
|
||||
int i;
|
||||
BYTE r = GetRValue(col), g = GetGValue(col), b = GetBValue(col);
|
||||
for( i = 0; i < palette_size; i++ )
|
||||
{
|
||||
if( COLOR_sysPal[i].peFlags & PC_SYS_USED ) /* skips gap */
|
||||
if( COLOR_sysPal[i].peRed == r &&
|
||||
COLOR_sysPal[i].peGreen == g &&
|
||||
COLOR_sysPal[i].peBlue == b )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* X11DRV_PALETTE_SetMapping
|
||||
*
|
||||
* Set the color-mapping table for selected palette.
|
||||
* Return number of entries which mapping has changed.
|
||||
*/
|
||||
int X11DRV_PALETTE_SetMapping( PALETTEOBJ* palPtr, UINT uStart, UINT uNum, BOOL mapOnly )
|
||||
static UINT X11DRV_PALETTE_SetMapping( PALETTEOBJ* palPtr, UINT uStart, UINT uNum, BOOL mapOnly )
|
||||
{
|
||||
char flag;
|
||||
int prevMapping = (palPtr->mapping) ? 1 : 0;
|
||||
int index, iRemapped = 0;
|
||||
int index;
|
||||
UINT iRemapped = 0;
|
||||
int* mapping;
|
||||
|
||||
/* reset dynamic system palette entries */
|
||||
|
@ -1019,6 +1071,11 @@ int X11DRV_PALETTE_SetMapping( PALETTEOBJ* palPtr, UINT uStart, UINT uNum, BOOL
|
|||
}
|
||||
palPtr->mapping = mapping;
|
||||
|
||||
if (uStart >= palPtr->logpalette.palNumEntries) return 0;
|
||||
|
||||
if (uStart + uNum > palPtr->logpalette.palNumEntries)
|
||||
uNum = palPtr->logpalette.palNumEntries - uStart;
|
||||
|
||||
for( uNum += uStart; uStart < uNum; uStart++ )
|
||||
{
|
||||
index = -1;
|
||||
|
@ -1040,8 +1097,7 @@ int X11DRV_PALETTE_SetMapping( PALETTEOBJ* palPtr, UINT uStart, UINT uNum, BOOL
|
|||
|
||||
/* fall through */
|
||||
default: /* try to collapse identical colors */
|
||||
index = COLOR_PaletteLookupExactIndex(COLOR_sysPal, 256,
|
||||
*(COLORREF*)(palPtr->logpalette.palPalEntry + uStart));
|
||||
index = X11DRV_LookupSysPaletteExact(*(COLORREF*)(palPtr->logpalette.palPalEntry + uStart));
|
||||
/* fall through */
|
||||
case PC_NOCOLLAPSE:
|
||||
if( index < 0 )
|
||||
|
@ -1075,8 +1131,7 @@ int X11DRV_PALETTE_SetMapping( PALETTEOBJ* palPtr, UINT uStart, UINT uNum, BOOL
|
|||
|
||||
/* we have to map to existing entry in the system palette */
|
||||
|
||||
index = COLOR_PaletteLookupPixel(COLOR_sysPal, 256, NULL,
|
||||
*(COLORREF*)(palPtr->logpalette.palPalEntry + uStart), TRUE);
|
||||
index = X11DRV_SysPaletteLookupPixel( *(COLORREF*)(palPtr->logpalette.palPalEntry + uStart), TRUE);
|
||||
}
|
||||
palPtr->logpalette.palPalEntry[uStart].peFlags |= PC_SYS_USED;
|
||||
|
||||
|
@ -1095,36 +1150,112 @@ int X11DRV_PALETTE_SetMapping( PALETTEOBJ* palPtr, UINT uStart, UINT uNum, BOOL
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
* X11DRV_PALETTE_UpdateMapping
|
||||
*
|
||||
* Update the color-mapping table for selected palette.
|
||||
* Return number of entries which mapping has changed.
|
||||
* GetSystemPaletteEntries (X11DRV.@)
|
||||
*/
|
||||
int X11DRV_PALETTE_UpdateMapping(PALETTEOBJ *palPtr)
|
||||
UINT X11DRV_GetSystemPaletteEntries( X11DRV_PDEVICE *physDev, UINT start, UINT count,
|
||||
LPPALETTEENTRY entries )
|
||||
{
|
||||
int i, index, realized = 0;
|
||||
UINT i;
|
||||
|
||||
if (!palette_size)
|
||||
return 0;
|
||||
if (!entries) return palette_size;
|
||||
if (start >= palette_size) return 0;
|
||||
if (start + count >= palette_size) count = palette_size - start;
|
||||
|
||||
for( i = 0; i < 20; i++ )
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
index = X11DRV_PALETTE_LookupSystemXPixel(*(COLORREF*)(palPtr->logpalette.palPalEntry + i));
|
||||
|
||||
/* mapping is allocated in COLOR_InitPalette() */
|
||||
|
||||
if( index != palPtr->mapping[i] ) { palPtr->mapping[i]=index; realized++; }
|
||||
entries[i].peRed = COLOR_sysPal[start + i].peRed;
|
||||
entries[i].peGreen = COLOR_sysPal[start + i].peGreen;
|
||||
entries[i].peBlue = COLOR_sysPal[start + i].peBlue;
|
||||
entries[i].peFlags = 0;
|
||||
TRACE("\tidx(%02x) -> RGB(%08lx)\n", start + i, *(COLORREF*)(entries + i) );
|
||||
}
|
||||
|
||||
return realized;
|
||||
return count;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* X11DRV_PALETTE_IsDark
|
||||
|
||||
/***********************************************************************
|
||||
* GetNearestColor (X11DRV.@)
|
||||
*/
|
||||
BOOL X11DRV_PALETTE_IsDark(int pixel)
|
||||
COLORREF X11DRV_GetNearestColor( X11DRV_PDEVICE *physDev, COLORREF color )
|
||||
{
|
||||
COLORREF col = X11DRV_PALETTE_ToLogical(pixel);
|
||||
return (GetRValue(col) + GetGValue(col) + GetBValue(col)) <= 0x180;
|
||||
unsigned char spec_type = color >> 24;
|
||||
COLORREF nearest;
|
||||
|
||||
if (!palette_size) return color;
|
||||
|
||||
if (spec_type == 1 || spec_type == 2)
|
||||
{
|
||||
/* we need logical palette for PALETTERGB and PALETTEINDEX colorrefs */
|
||||
|
||||
UINT index;
|
||||
PALETTEENTRY entry;
|
||||
HPALETTE hpal = GetCurrentObject( physDev->hdc, OBJ_PAL );
|
||||
|
||||
if (!hpal) hpal = GetStockObject( DEFAULT_PALETTE );
|
||||
|
||||
if (spec_type == 2) /* PALETTERGB */
|
||||
index = GetNearestPaletteIndex( hpal, color );
|
||||
else /* PALETTEINDEX */
|
||||
index = LOWORD(color);
|
||||
|
||||
if (!GetPaletteEntries( hpal, index, 1, &entry ))
|
||||
{
|
||||
WARN("RGB(%lx) : idx %d is out of bounds, assuming NULL\n", color, index );
|
||||
if (!GetPaletteEntries( hpal, 0, 1, &entry )) return CLR_INVALID;
|
||||
}
|
||||
color = RGB( entry.peRed, entry.peGreen, entry.peBlue );
|
||||
}
|
||||
color &= 0x00ffffff;
|
||||
nearest = (0x00ffffff & *(COLORREF*)(COLOR_sysPal + X11DRV_SysPaletteLookupPixel(color, FALSE)));
|
||||
|
||||
TRACE("(%06lx): returning %06lx\n", color, nearest );
|
||||
return nearest;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* RealizePalette (X11DRV.@)
|
||||
*/
|
||||
UINT X11DRV_RealizePalette( X11DRV_PDEVICE *physDev, HPALETTE hpal, BOOL primary )
|
||||
{
|
||||
UINT ret;
|
||||
PALETTEOBJ *palPtr;
|
||||
|
||||
if (!(palPtr = GDI_GetObjPtr( hpal, PALETTE_MAGIC ))) return 0;
|
||||
ret = X11DRV_PALETTE_SetMapping( palPtr, 0, palPtr->logpalette.palNumEntries, !primary );
|
||||
GDI_ReleaseObj( hpal );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* RealizeDefaultPalette (X11DRV.@)
|
||||
*/
|
||||
UINT X11DRV_RealizeDefaultPalette( X11DRV_PDEVICE *physDev )
|
||||
{
|
||||
DC *dc = physDev->dc;
|
||||
UINT ret = 0;
|
||||
|
||||
if (palette_size && !(dc->flags & DC_MEMORY))
|
||||
{
|
||||
PALETTEOBJ* palPtr = GDI_GetObjPtr( GetStockObject(DEFAULT_PALETTE), PALETTE_MAGIC );
|
||||
if (palPtr)
|
||||
{
|
||||
/* lookup is needed to account for SetSystemPaletteUse() stuff */
|
||||
int i, index;
|
||||
|
||||
for( i = 0; i < 20; i++ )
|
||||
{
|
||||
index = X11DRV_PALETTE_LookupSystemXPixel(*(COLORREF*)(palPtr->logpalette.palPalEntry + i));
|
||||
/* mapping is allocated in COLOR_InitPalette() */
|
||||
if( index != palPtr->mapping[i] )
|
||||
{
|
||||
palPtr->mapping[i]=index;
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
GDI_ReleaseObj( GetStockObject(DEFAULT_PALETTE) );
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright 1993 Alexandre Julliard
|
||||
* Copyright 1996 Alex Korobka
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __WINE_COLOR_H
|
||||
#define __WINE_COLOR_H
|
||||
|
||||
#include "windef.h"
|
||||
#include "wingdi.h"
|
||||
#include "palette.h"
|
||||
|
||||
#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 */
|
||||
#define PC_SYS_MAPPED 0x10 /* logical palentry is a direct alias for system palentry */
|
||||
|
||||
extern COLORREF COLOR_GetSystemPaletteEntry(UINT);
|
||||
extern const PALETTEENTRY *COLOR_GetSystemPaletteTemplate(void);
|
||||
|
||||
extern COLORREF COLOR_LookupNearestColor(PALETTEENTRY *, int, COLORREF);
|
||||
extern int COLOR_PaletteLookupExactIndex(PALETTEENTRY *palPalEntry, int size, COLORREF col);
|
||||
extern int COLOR_PaletteLookupPixel(PALETTEENTRY *, int, int * , COLORREF, BOOL);
|
||||
|
||||
#endif /* __WINE_COLOR_H */
|
|
@ -190,8 +190,10 @@ typedef struct tagDC_FUNCS
|
|||
INT (*pGetDIBits)(PHYSDEV,HBITMAP,UINT,UINT,LPVOID,BITMAPINFO*,UINT);
|
||||
INT (*pGetDeviceCaps)(PHYSDEV,INT);
|
||||
BOOL (*pGetDeviceGammaRamp)(PHYSDEV,LPVOID);
|
||||
COLORREF (*pGetNearestColor)(PHYSDEV,COLORREF);
|
||||
COLORREF (*pGetPixel)(PHYSDEV,INT,INT);
|
||||
INT (*pGetPixelFormat)(PHYSDEV);
|
||||
UINT (*pGetSystemPaletteEntries)(PHYSDEV,UINT,UINT,LPPALETTEENTRY);
|
||||
BOOL (*pGetTextExtentPoint)(PHYSDEV,LPCWSTR,INT,LPSIZE);
|
||||
BOOL (*pGetTextMetrics)(PHYSDEV,TEXTMETRICW*);
|
||||
INT (*pIntersectClipRect)(PHYSDEV,INT,INT,INT,INT);
|
||||
|
@ -212,7 +214,8 @@ typedef struct tagDC_FUNCS
|
|||
BOOL (*pPolygon)(PHYSDEV,const POINT*,INT);
|
||||
BOOL (*pPolyline)(PHYSDEV,const POINT*,INT);
|
||||
BOOL (*pPolylineTo)(PHYSDEV,const POINT*,INT);
|
||||
UINT (*pRealizePalette)(PHYSDEV);
|
||||
UINT (*pRealizeDefaultPalette)(PHYSDEV);
|
||||
UINT (*pRealizePalette)(PHYSDEV,HPALETTE,BOOL);
|
||||
BOOL (*pRectangle)(PHYSDEV,INT,INT,INT,INT);
|
||||
HDC (*pResetDC)(PHYSDEV,const DEVMODEA*);
|
||||
BOOL (*pRestoreDC)(PHYSDEV,INT);
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
|
||||
#include "gdi.h"
|
||||
|
||||
#define NB_RESERVED_COLORS 20 /* number of fixed colors in system palette */
|
||||
#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 */
|
||||
#define PC_SYS_MAPPED 0x10 /* logical palentry is a direct alias for system palentry */
|
||||
|
||||
/* GDI logical palette object */
|
||||
typedef struct tagPALETTEOBJ
|
||||
|
@ -33,15 +37,6 @@ typedef struct tagPALETTEOBJ
|
|||
LOGPALETTE logpalette; /* _MUST_ be the last field */
|
||||
} PALETTEOBJ;
|
||||
|
||||
typedef struct tagPALETTE_DRIVER
|
||||
{
|
||||
int (*pSetMapping)(struct tagPALETTEOBJ *, UINT, UINT, BOOL);
|
||||
int (*pUpdateMapping)(struct tagPALETTEOBJ *);
|
||||
BOOL (*pIsDark)(int pixel);
|
||||
} PALETTE_DRIVER;
|
||||
|
||||
extern PALETTE_DRIVER *PALETTE_Driver;
|
||||
|
||||
extern HPALETTE16 PALETTE_Init(void);
|
||||
|
||||
#endif /* __WINE_PALETTE_H */
|
||||
|
|
|
@ -548,7 +548,7 @@ WORD WINAPI SetHookFlags16(HDC16,WORD);
|
|||
INT16 WINAPI SetMapMode16(HDC16,INT16);
|
||||
DWORD WINAPI SetMapperFlags16(HDC16,DWORD);
|
||||
HMETAFILE16 WINAPI SetMetaFileBits16(HGLOBAL16);
|
||||
UINT16 WINAPI SetPaletteEntries16(HPALETTE16,UINT16,UINT16,LPPALETTEENTRY);
|
||||
UINT16 WINAPI SetPaletteEntries16(HPALETTE16,UINT16,UINT16,const PALETTEENTRY*);
|
||||
COLORREF WINAPI SetPixel16(HDC16,INT16,INT16,COLORREF);
|
||||
INT16 WINAPI SetPolyFillMode16(HDC16,INT16);
|
||||
VOID WINAPI SetRectRgn16(HRGN16,INT16,INT16,INT16,INT16);
|
||||
|
|
|
@ -3368,7 +3368,7 @@ DWORD WINAPI SetMapperFlags(HDC,DWORD);
|
|||
HMETAFILE WINAPI SetMetaFileBitsEx(UINT,const BYTE*);
|
||||
INT WINAPI SetMetaRgn(HDC);
|
||||
BOOL WINAPI SetMiterLimit(HDC, FLOAT, PFLOAT);
|
||||
UINT WINAPI SetPaletteEntries(HPALETTE,UINT,UINT,LPPALETTEENTRY);
|
||||
UINT WINAPI SetPaletteEntries(HPALETTE,UINT,UINT,const PALETTEENTRY*);
|
||||
COLORREF WINAPI SetPixel(HDC,INT,INT,COLORREF);
|
||||
BOOL WINAPI SetPixelV(HDC,INT,INT,COLORREF);
|
||||
BOOL WINAPI SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR*);
|
||||
|
|
|
@ -302,12 +302,6 @@ extern BOOL X11DRV_IsSolidColor(COLORREF color);
|
|||
extern COLORREF X11DRV_PALETTE_ToLogical(int pixel);
|
||||
extern int X11DRV_PALETTE_ToPhysical(X11DRV_PDEVICE *physDev, COLORREF color);
|
||||
|
||||
extern struct tagPALETTE_DRIVER X11DRV_PALETTE_Driver;
|
||||
|
||||
extern int X11DRV_PALETTE_SetMapping(struct tagPALETTEOBJ *palPtr, UINT uStart, UINT uNum, BOOL mapOnly);
|
||||
extern int X11DRV_PALETTE_UpdateMapping(struct tagPALETTEOBJ *palPtr);
|
||||
extern BOOL X11DRV_PALETTE_IsDark(int pixel);
|
||||
|
||||
/* GDI escapes */
|
||||
|
||||
#define X11DRV_ESCAPE 6789
|
||||
|
|
162
objects/color.c
162
objects/color.c
|
@ -1,162 +0,0 @@
|
|||
/*
|
||||
* Color functions
|
||||
*
|
||||
* Copyright 1993 Alexandre Julliard
|
||||
* Copyright 1996 Alex Korobka
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "color.h"
|
||||
#include "wine/debug.h"
|
||||
#include "palette.h"
|
||||
#include "windef.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(palette);
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* System color space.
|
||||
*
|
||||
* First 10 and last 10 colors in COLOR_sysPalette are
|
||||
* "guarded". RealizePalette changes only the rest of colorcells. For
|
||||
* currently inactive window it changes only DC palette mappings.
|
||||
*/
|
||||
|
||||
PALETTEENTRY *COLOR_sysPal = NULL; /* current system palette */
|
||||
|
||||
const PALETTEENTRY COLOR_sysPalTemplate[NB_RESERVED_COLORS] =
|
||||
{
|
||||
/* first 10 entries in the system palette */
|
||||
/* red green blue flags */
|
||||
{ 0x00, 0x00, 0x00, PC_SYS_USED },
|
||||
{ 0x80, 0x00, 0x00, PC_SYS_USED },
|
||||
{ 0x00, 0x80, 0x00, PC_SYS_USED },
|
||||
{ 0x80, 0x80, 0x00, PC_SYS_USED },
|
||||
{ 0x00, 0x00, 0x80, PC_SYS_USED },
|
||||
{ 0x80, 0x00, 0x80, PC_SYS_USED },
|
||||
{ 0x00, 0x80, 0x80, PC_SYS_USED },
|
||||
{ 0xc0, 0xc0, 0xc0, PC_SYS_USED },
|
||||
{ 0xc0, 0xdc, 0xc0, PC_SYS_USED },
|
||||
{ 0xa6, 0xca, 0xf0, PC_SYS_USED },
|
||||
|
||||
/* ... c_min/2 dynamic colorcells */
|
||||
|
||||
/* ... gap (for sparse palettes) */
|
||||
|
||||
/* ... c_min/2 dynamic colorcells */
|
||||
|
||||
{ 0xff, 0xfb, 0xf0, PC_SYS_USED },
|
||||
{ 0xa0, 0xa0, 0xa4, PC_SYS_USED },
|
||||
{ 0x80, 0x80, 0x80, PC_SYS_USED },
|
||||
{ 0xff, 0x00, 0x00, PC_SYS_USED },
|
||||
{ 0x00, 0xff, 0x00, PC_SYS_USED },
|
||||
{ 0xff, 0xff, 0x00, PC_SYS_USED },
|
||||
{ 0x00, 0x00, 0xff, PC_SYS_USED },
|
||||
{ 0xff, 0x00, 0xff, PC_SYS_USED },
|
||||
{ 0x00, 0xff, 0xff, PC_SYS_USED },
|
||||
{ 0xff, 0xff, 0xff, PC_SYS_USED } /* last 10 */
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
* COLOR_GetSystemPaletteTemplate
|
||||
*/
|
||||
const PALETTEENTRY* COLOR_GetSystemPaletteTemplate(void)
|
||||
{
|
||||
return COLOR_sysPalTemplate;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* COLOR_GetSystemPaletteEntry
|
||||
*/
|
||||
|
||||
COLORREF COLOR_GetSystemPaletteEntry(UINT i)
|
||||
{
|
||||
return *(COLORREF*)(COLOR_sysPal + i) & 0x00ffffff;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* COLOR_PaletteLookupPixel
|
||||
*/
|
||||
int COLOR_PaletteLookupPixel( PALETTEENTRY* palPalEntry, int size,
|
||||
int* mapping, COLORREF col, BOOL skipReserved )
|
||||
{
|
||||
int i, best = 0, diff = 0x7fffffff;
|
||||
int r,g,b;
|
||||
|
||||
for( i = 0; i < size && diff ; i++ )
|
||||
{
|
||||
if( !(palPalEntry[i].peFlags & PC_SYS_USED) ||
|
||||
(skipReserved && palPalEntry[i].peFlags & PC_SYS_RESERVED) )
|
||||
continue;
|
||||
|
||||
r = palPalEntry[i].peRed - GetRValue(col);
|
||||
g = palPalEntry[i].peGreen - GetGValue(col);
|
||||
b = palPalEntry[i].peBlue - GetBValue(col);
|
||||
|
||||
r = r*r + g*g + b*b;
|
||||
|
||||
if( r < diff ) { best = i; diff = r; }
|
||||
}
|
||||
return (mapping) ? mapping[best] : best;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* COLOR_PaletteLookupExactIndex
|
||||
*/
|
||||
int COLOR_PaletteLookupExactIndex( PALETTEENTRY* palPalEntry, int size,
|
||||
COLORREF col )
|
||||
{
|
||||
int i;
|
||||
BYTE r = GetRValue(col), g = GetGValue(col), b = GetBValue(col);
|
||||
for( i = 0; i < size; i++ )
|
||||
{
|
||||
if( palPalEntry[i].peFlags & PC_SYS_USED ) /* skips gap */
|
||||
if( palPalEntry[i].peRed == r &&
|
||||
palPalEntry[i].peGreen == g &&
|
||||
palPalEntry[i].peBlue == b )
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* COLOR_LookupNearestColor
|
||||
*/
|
||||
COLORREF COLOR_LookupNearestColor( PALETTEENTRY* palPalEntry, int size, COLORREF color )
|
||||
{
|
||||
unsigned char spec_type = color >> 24;
|
||||
int i;
|
||||
|
||||
/* we need logical palette for PALETTERGB and PALETTEINDEX colorrefs */
|
||||
|
||||
if( spec_type == 2 ) /* PALETTERGB */
|
||||
color = *(COLORREF*)
|
||||
(palPalEntry + COLOR_PaletteLookupPixel(palPalEntry,size,NULL,color,FALSE));
|
||||
|
||||
else if( spec_type == 1 ) /* PALETTEINDEX */
|
||||
{
|
||||
if( (i = color & 0x0000ffff) >= size )
|
||||
{
|
||||
WARN("RGB(%lx) : idx %d is out of bounds, assuming NULL\n", color, i);
|
||||
color = *(COLORREF*)palPalEntry;
|
||||
}
|
||||
else color = *(COLORREF*)(palPalEntry + i);
|
||||
}
|
||||
|
||||
color &= 0x00ffffff;
|
||||
return (0x00ffffff & *(COLORREF*)
|
||||
(COLOR_sysPal + COLOR_PaletteLookupPixel(COLOR_sysPal, 256, NULL, color, FALSE)));
|
||||
}
|
|
@ -31,7 +31,6 @@
|
|||
#include "wingdi.h"
|
||||
#include "wine/winuser16.h"
|
||||
#include "gdi.h"
|
||||
#include "color.h"
|
||||
#include "palette.h"
|
||||
#include "wine/debug.h"
|
||||
#include "winerror.h"
|
||||
|
@ -52,8 +51,6 @@ static const struct gdi_obj_funcs palette_funcs =
|
|||
PALETTE_DeleteObject /* pDeleteObject */
|
||||
};
|
||||
|
||||
PALETTE_DRIVER *PALETTE_Driver = NULL;
|
||||
|
||||
/* Pointers to USER implementation of SelectPalette/RealizePalette */
|
||||
/* they will be patched by USER on startup */
|
||||
FARPROC pfnSelectPalette = NULL;
|
||||
|
@ -63,7 +60,40 @@ static UINT SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */
|
|||
|
||||
static HPALETTE hPrimaryPalette = 0; /* used for WM_PALETTECHANGED */
|
||||
static HPALETTE hLastRealizedPalette = 0; /* UnrealizeObject() needs it */
|
||||
static const DC_FUNCTIONS *pLastRealizedDC;
|
||||
|
||||
static const PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS] =
|
||||
{
|
||||
/* first 10 entries in the system palette */
|
||||
/* red green blue flags */
|
||||
{ 0x00, 0x00, 0x00, 0 },
|
||||
{ 0x80, 0x00, 0x00, 0 },
|
||||
{ 0x00, 0x80, 0x00, 0 },
|
||||
{ 0x80, 0x80, 0x00, 0 },
|
||||
{ 0x00, 0x00, 0x80, 0 },
|
||||
{ 0x80, 0x00, 0x80, 0 },
|
||||
{ 0x00, 0x80, 0x80, 0 },
|
||||
{ 0xc0, 0xc0, 0xc0, 0 },
|
||||
{ 0xc0, 0xdc, 0xc0, 0 },
|
||||
{ 0xa6, 0xca, 0xf0, 0 },
|
||||
|
||||
/* ... c_min/2 dynamic colorcells */
|
||||
|
||||
/* ... gap (for sparse palettes) */
|
||||
|
||||
/* ... c_min/2 dynamic colorcells */
|
||||
|
||||
{ 0xff, 0xfb, 0xf0, 0 },
|
||||
{ 0xa0, 0xa0, 0xa4, 0 },
|
||||
{ 0x80, 0x80, 0x80, 0 },
|
||||
{ 0xff, 0x00, 0x00, 0 },
|
||||
{ 0x00, 0xff, 0x00, 0 },
|
||||
{ 0xff, 0xff, 0x00, 0 },
|
||||
{ 0x00, 0x00, 0xff, 0 },
|
||||
{ 0xff, 0x00, 0xff, 0 },
|
||||
{ 0x00, 0xff, 0xff, 0 },
|
||||
{ 0xff, 0xff, 0xff, 0 } /* last 10 */
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
* PALETTE_Init
|
||||
|
@ -72,11 +102,9 @@ static HPALETTE hLastRealizedPalette = 0; /* UnrealizeObject() needs it */
|
|||
*/
|
||||
HPALETTE16 PALETTE_Init(void)
|
||||
{
|
||||
int i;
|
||||
HPALETTE16 hpalette;
|
||||
LOGPALETTE * palPtr;
|
||||
PALETTEOBJ* palObj;
|
||||
const PALETTEENTRY* __sysPalTemplate = COLOR_GetSystemPaletteTemplate();
|
||||
|
||||
/* create default palette (20 system colors) */
|
||||
|
||||
|
@ -86,20 +114,14 @@ HPALETTE16 PALETTE_Init(void)
|
|||
|
||||
palPtr->palVersion = 0x300;
|
||||
palPtr->palNumEntries = NB_RESERVED_COLORS;
|
||||
for( i = 0; i < NB_RESERVED_COLORS; i ++ )
|
||||
{
|
||||
palPtr->palPalEntry[i].peRed = __sysPalTemplate[i].peRed;
|
||||
palPtr->palPalEntry[i].peGreen = __sysPalTemplate[i].peGreen;
|
||||
palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue;
|
||||
palPtr->palPalEntry[i].peFlags = 0;
|
||||
}
|
||||
memcpy( palPtr->palPalEntry, sys_pal_template, sizeof(sys_pal_template) );
|
||||
hpalette = CreatePalette16( palPtr );
|
||||
HeapFree( GetProcessHeap(), 0, palPtr );
|
||||
|
||||
palObj = (PALETTEOBJ*) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
|
||||
if (palObj)
|
||||
{
|
||||
if (!(palObj->mapping = HeapAlloc( GetProcessHeap(), 0, sizeof(int) * 20 )))
|
||||
if (!(palObj->mapping = HeapAlloc( GetProcessHeap(), 0, sizeof(int) * NB_RESERVED_COLORS )))
|
||||
ERR("Can not create palette mapping -- out of memory!\n");
|
||||
GDI_ReleaseObj( hpalette );
|
||||
}
|
||||
|
@ -109,7 +131,7 @@ HPALETTE16 PALETTE_Init(void)
|
|||
/***********************************************************************
|
||||
* PALETTE_ValidateFlags
|
||||
*/
|
||||
void PALETTE_ValidateFlags(PALETTEENTRY* lpPalE, int size)
|
||||
static void PALETTE_ValidateFlags(PALETTEENTRY* lpPalE, int size)
|
||||
{
|
||||
int i = 0;
|
||||
for( ; i<size ; i++ )
|
||||
|
@ -331,7 +353,7 @@ UINT WINAPI GetPaletteEntries(
|
|||
* SetPaletteEntries (GDI.364)
|
||||
*/
|
||||
UINT16 WINAPI SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start,
|
||||
UINT16 count, LPPALETTEENTRY entries )
|
||||
UINT16 count, const PALETTEENTRY *entries )
|
||||
{
|
||||
return SetPaletteEntries( hpalette, start, count, entries );
|
||||
}
|
||||
|
@ -348,13 +370,14 @@ UINT WINAPI SetPaletteEntries(
|
|||
HPALETTE hpalette, /* [in] Handle of logical palette */
|
||||
UINT start, /* [in] Index of first entry to set */
|
||||
UINT count, /* [in] Number of entries to set */
|
||||
LPPALETTEENTRY entries) /* [in] Address of array of structures */
|
||||
const PALETTEENTRY *entries) /* [in] Address of array of structures */
|
||||
{
|
||||
PALETTEOBJ * palPtr;
|
||||
UINT numEntries;
|
||||
|
||||
TRACE("hpal=%04x,start=%i,count=%i\n",hpalette,start,count );
|
||||
|
||||
if (hpalette == GetStockObject(DEFAULT_PALETTE)) return 0;
|
||||
palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
|
||||
if (!palPtr) return 0;
|
||||
|
||||
|
@ -369,8 +392,7 @@ UINT WINAPI SetPaletteEntries(
|
|||
count * sizeof(PALETTEENTRY) );
|
||||
PALETTE_ValidateFlags(palPtr->logpalette.palPalEntry,
|
||||
palPtr->logpalette.palNumEntries);
|
||||
HeapFree( GetProcessHeap(), 0, palPtr->mapping );
|
||||
palPtr->mapping = NULL;
|
||||
UnrealizeObject( hpalette );
|
||||
GDI_ReleaseObj( hpalette );
|
||||
return count;
|
||||
}
|
||||
|
@ -472,22 +494,12 @@ BOOL WINAPI AnimatePalette(
|
|||
|
||||
if( hPal != GetStockObject(DEFAULT_PALETTE) )
|
||||
{
|
||||
PALETTEOBJ* palPtr = (PALETTEOBJ *)GDI_GetObjPtr(hPal, PALETTE_MAGIC);
|
||||
if (!palPtr) return FALSE;
|
||||
if (!SetPaletteEntries( hPal, StartIndex, NumEntries, PaletteColors )) return FALSE;
|
||||
|
||||
if( (StartIndex + NumEntries) <= palPtr->logpalette.palNumEntries )
|
||||
{
|
||||
UINT u;
|
||||
for( u = 0; u < NumEntries; u++ )
|
||||
palPtr->logpalette.palPalEntry[u + StartIndex] = PaletteColors[u];
|
||||
if (PALETTE_Driver) PALETTE_Driver->pSetMapping(palPtr, StartIndex, NumEntries,
|
||||
hPal != hPrimaryPalette );
|
||||
GDI_ReleaseObj( hPal );
|
||||
return TRUE;
|
||||
}
|
||||
GDI_ReleaseObj( hPal );
|
||||
if (pLastRealizedDC && pLastRealizedDC->pRealizePalette)
|
||||
pLastRealizedDC->pRealizePalette( NULL, hPal, hPal == hPrimaryPalette );
|
||||
}
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -563,23 +575,18 @@ UINT WINAPI GetSystemPaletteEntries(
|
|||
UINT count, /* [in] Number of entries to be retrieved */
|
||||
LPPALETTEENTRY entries) /* [out] Array receiving system-palette entries */
|
||||
{
|
||||
UINT i;
|
||||
INT sizePalette = GetDeviceCaps( hdc, SIZEPALETTE );
|
||||
UINT ret = 0;
|
||||
DC *dc;
|
||||
|
||||
TRACE("hdc=%04x,start=%i,count=%i\n", hdc,start,count);
|
||||
|
||||
if (!entries) return sizePalette;
|
||||
if (start >= sizePalette) return 0;
|
||||
if (start+count >= sizePalette) count = sizePalette - start;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
if ((dc = DC_GetDCPtr( hdc )))
|
||||
{
|
||||
*(COLORREF*)(entries + i) = COLOR_GetSystemPaletteEntry( start + i );
|
||||
|
||||
TRACE("\tidx(%02x) -> RGB(%08lx)\n",
|
||||
start + i, *(COLORREF*)(entries + i) );
|
||||
if (dc->funcs->pGetSystemPaletteEntries)
|
||||
ret = dc->funcs->pGetSystemPaletteEntries( dc->physDev, start, count, entries );
|
||||
GDI_ReleaseObj( hdc );
|
||||
}
|
||||
return count;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -611,11 +618,23 @@ UINT WINAPI GetNearestPaletteIndex(
|
|||
|
||||
if( palObj )
|
||||
{
|
||||
index = COLOR_PaletteLookupPixel(palObj->logpalette.palPalEntry,
|
||||
palObj->logpalette.palNumEntries,
|
||||
NULL, color, FALSE );
|
||||
int i, diff = 0x7fffffff;
|
||||
int r,g,b;
|
||||
PALETTEENTRY* entry = palObj->logpalette.palPalEntry;
|
||||
|
||||
GDI_ReleaseObj( hpalette );
|
||||
for( i = 0; i < palObj->logpalette.palNumEntries && diff ; i++, entry++)
|
||||
{
|
||||
if (!(entry->peFlags & PC_SYS_USED)) continue;
|
||||
|
||||
r = entry->peRed - GetRValue(color);
|
||||
g = entry->peGreen - GetGValue(color);
|
||||
b = entry->peBlue - GetBValue(color);
|
||||
|
||||
r = r*r + g*g + b*b;
|
||||
|
||||
if( r < diff ) { index = i; diff = r; }
|
||||
}
|
||||
GDI_ReleaseObj( hpalette );
|
||||
}
|
||||
TRACE("(%04x,%06lx): returning %d\n", hpalette, color, index );
|
||||
return index;
|
||||
|
@ -642,27 +661,52 @@ COLORREF WINAPI GetNearestColor(
|
|||
HDC hdc, /* [in] Handle of device context */
|
||||
COLORREF color) /* [in] Color to be matched */
|
||||
{
|
||||
COLORREF nearest = CLR_INVALID;
|
||||
unsigned char spec_type;
|
||||
COLORREF nearest;
|
||||
DC *dc;
|
||||
PALETTEOBJ *palObj;
|
||||
|
||||
if(!(GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)) {
|
||||
if (!(dc = DC_GetDCPtr( hdc ))) return CLR_INVALID;
|
||||
|
||||
if (dc->funcs->pGetNearestColor)
|
||||
{
|
||||
nearest = dc->funcs->pGetNearestColor( dc->physDev, color );
|
||||
GDI_ReleaseObj( hdc );
|
||||
return nearest;
|
||||
}
|
||||
|
||||
if (!(GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE))
|
||||
{
|
||||
GDI_ReleaseObj( hdc );
|
||||
return color;
|
||||
}
|
||||
if ( (dc = DC_GetDCPtr( hdc )) )
|
||||
{
|
||||
HPALETTE hpal = (dc->hPalette)? dc->hPalette : GetStockObject( DEFAULT_PALETTE );
|
||||
palObj = GDI_GetObjPtr( hpal, PALETTE_MAGIC );
|
||||
if (!palObj) {
|
||||
GDI_ReleaseObj( hdc );
|
||||
return nearest;
|
||||
}
|
||||
|
||||
nearest = COLOR_LookupNearestColor( palObj->logpalette.palPalEntry,
|
||||
palObj->logpalette.palNumEntries, color );
|
||||
GDI_ReleaseObj( hpal );
|
||||
GDI_ReleaseObj( hdc );
|
||||
spec_type = color >> 24;
|
||||
if (spec_type == 1 || spec_type == 2)
|
||||
{
|
||||
/* we need logical palette for PALETTERGB and PALETTEINDEX colorrefs */
|
||||
|
||||
UINT index;
|
||||
PALETTEENTRY entry;
|
||||
HPALETTE hpal = dc->hPalette ? dc->hPalette : GetStockObject( DEFAULT_PALETTE );
|
||||
|
||||
if (spec_type == 2) /* PALETTERGB */
|
||||
index = GetNearestPaletteIndex( hpal, color );
|
||||
else /* PALETTEINDEX */
|
||||
index = LOWORD(color);
|
||||
|
||||
if (!GetPaletteEntries( hpal, index, 1, &entry ))
|
||||
{
|
||||
WARN("RGB(%lx) : idx %d is out of bounds, assuming NULL\n", color, index );
|
||||
if (!GetPaletteEntries( hpal, 0, 1, &entry ))
|
||||
{
|
||||
GDI_ReleaseObj( hdc );
|
||||
return CLR_INVALID;
|
||||
}
|
||||
}
|
||||
color = RGB( entry.peRed, entry.peGreen, entry.peBlue );
|
||||
}
|
||||
nearest = color & 0x00ffffff;
|
||||
GDI_ReleaseObj( hdc );
|
||||
|
||||
TRACE("(%06lx): returning %06lx\n", color, nearest );
|
||||
return nearest;
|
||||
|
@ -694,7 +738,11 @@ static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle, void *obj )
|
|||
HeapFree( GetProcessHeap(), 0, palette->mapping );
|
||||
palette->mapping = NULL;
|
||||
}
|
||||
if (hLastRealizedPalette == handle) hLastRealizedPalette = 0;
|
||||
if (hLastRealizedPalette == handle)
|
||||
{
|
||||
hLastRealizedPalette = 0;
|
||||
pLastRealizedDC = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -707,7 +755,11 @@ static BOOL PALETTE_DeleteObject( HGDIOBJ handle, void *obj )
|
|||
PALETTEOBJ *palette = obj;
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, palette->mapping );
|
||||
if (hLastRealizedPalette == handle) hLastRealizedPalette = 0;
|
||||
if (hLastRealizedPalette == handle)
|
||||
{
|
||||
hLastRealizedPalette = 0;
|
||||
pLastRealizedDC = NULL;
|
||||
}
|
||||
return GDI_FreeObject( handle, obj );
|
||||
}
|
||||
|
||||
|
@ -741,39 +793,28 @@ HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpal, WORD wBkg)
|
|||
*/
|
||||
UINT16 WINAPI GDIRealizePalette16( HDC16 hdc )
|
||||
{
|
||||
PALETTEOBJ* palPtr;
|
||||
int realized = 0;
|
||||
UINT realized = 0;
|
||||
DC* dc = DC_GetDCPtr( hdc );
|
||||
|
||||
if (!dc) return 0;
|
||||
|
||||
TRACE("%04x...\n", hdc );
|
||||
|
||||
if( dc->hPalette == GetStockObject( DEFAULT_PALETTE ))
|
||||
{
|
||||
GDI_ReleaseObj( hdc );
|
||||
return RealizeDefaultPalette16( hdc );
|
||||
}
|
||||
|
||||
if(dc->hPalette != hLastRealizedPalette )
|
||||
{
|
||||
if( dc->hPalette == GetStockObject( DEFAULT_PALETTE )) {
|
||||
realized = RealizeDefaultPalette16( hdc );
|
||||
GDI_ReleaseObj( hdc );
|
||||
return (UINT16)realized;
|
||||
}
|
||||
|
||||
|
||||
palPtr = (PALETTEOBJ *) GDI_GetObjPtr( dc->hPalette, PALETTE_MAGIC );
|
||||
|
||||
if (!palPtr) {
|
||||
GDI_ReleaseObj( hdc );
|
||||
FIXME("invalid selected palette %04x\n",dc->hPalette);
|
||||
return 0;
|
||||
}
|
||||
if (PALETTE_Driver)
|
||||
realized = PALETTE_Driver->pSetMapping(palPtr,0,palPtr->logpalette.palNumEntries,
|
||||
(dc->hPalette != hPrimaryPalette) ||
|
||||
(dc->hPalette == GetStockObject( DEFAULT_PALETTE )));
|
||||
hLastRealizedPalette = dc->hPalette;
|
||||
GDI_ReleaseObj( dc->hPalette );
|
||||
if (dc->funcs->pRealizePalette)
|
||||
realized = dc->funcs->pRealizePalette( dc->physDev, dc->hPalette,
|
||||
(dc->hPalette == hPrimaryPalette) );
|
||||
hLastRealizedPalette = dc->hPalette;
|
||||
pLastRealizedDC = dc->funcs;
|
||||
}
|
||||
else TRACE(" skipping (hLastRealizedPalette = %04x)\n",
|
||||
hLastRealizedPalette);
|
||||
else TRACE(" skipping (hLastRealizedPalette = %04x)\n", hLastRealizedPalette);
|
||||
GDI_ReleaseObj( hdc );
|
||||
|
||||
TRACE(" realized %i colors.\n", realized );
|
||||
|
@ -788,22 +829,12 @@ UINT16 WINAPI RealizeDefaultPalette16( HDC16 hdc )
|
|||
{
|
||||
UINT16 ret = 0;
|
||||
DC *dc;
|
||||
PALETTEOBJ* palPtr;
|
||||
|
||||
TRACE("%04x\n", hdc );
|
||||
|
||||
if (!(dc = DC_GetDCPtr( hdc ))) return 0;
|
||||
|
||||
if (!(dc->flags & DC_MEMORY))
|
||||
{
|
||||
palPtr = (PALETTEOBJ*)GDI_GetObjPtr( GetStockObject(DEFAULT_PALETTE), PALETTE_MAGIC );
|
||||
if (palPtr)
|
||||
{
|
||||
/* lookup is needed to account for SetSystemPaletteUse() stuff */
|
||||
if (PALETTE_Driver) ret = PALETTE_Driver->pUpdateMapping(palPtr);
|
||||
GDI_ReleaseObj( GetStockObject(DEFAULT_PALETTE) );
|
||||
}
|
||||
}
|
||||
if (dc->funcs->pRealizeDefaultPalette) ret = dc->funcs->pRealizeDefaultPalette( dc->physDev );
|
||||
GDI_ReleaseObj( hdc );
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue