Commit 78f9fae7 authored by Alexandre Julliard's avatar Alexandre Julliard

Create GDI stock objects as normal objects instead of using magic

handle values.
parent e811f9c3
......@@ -18,9 +18,15 @@ DEFAULT_DEBUG_CHANNEL(psdrv);
*/
inline static BOOL is_stock_font( HFONT font )
{
return (font >= FIRST_STOCK_FONT && font <= LAST_STOCK_FONT);
int i;
for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++)
{
if (i != DEFAULT_PALETTE && font == GetStockObject(i)) return TRUE;
}
return FALSE;
}
/*******************************************************************************
* ScaleFont
*
......
......@@ -101,25 +101,24 @@ static HBRUSH EMFDRV_BRUSH_SelectObject(DC *dc, HBRUSH hBrush )
EMRSELECTOBJECT emr;
DWORD index;
HBRUSH hOldBrush;
int i;
/* If the object is a stock brush object, do not need to create it.
* See definitions in wingdi.h for range of stock brushes.
* We do however have to handle setting the higher order bit to
* designate that this is a stock object.
*/
if (hBrush >= FIRST_STOCK_HANDLE &&
hBrush <= FIRST_STOCK_HANDLE+HOLLOW_BRUSH )
{
DWORD brush_index = hBrush - FIRST_STOCK_HANDLE;
index = brush_index | 0x80000000;
}
else
for (i = WHITE_BRUSH; i <= NULL_BRUSH; i++)
{
index = EMFDRV_CreateBrushIndirect(dc, hBrush );
if (hBrush == GetStockObject(i))
{
index = i | 0x80000000;
goto found;
}
}
if(!index) return FALSE;
if (!(index = EMFDRV_CreateBrushIndirect(dc, hBrush ))) return 0;
found:
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
......@@ -180,6 +179,7 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
EMRSELECTOBJECT emr;
DWORD index;
HFONT hOldFont;
int i;
/* If the object is a stock font object, do not need to create it.
* See definitions in wingdi.h for range of stock fonts.
......@@ -187,20 +187,16 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
* designate that this is a stock object.
*/
if (hFont >= STOCK_OEM_FIXED_FONT &&
hFont <= STOCK_DEFAULT_GUI_FONT &&
hFont != STOCK_DEFAULT_PALETTE)
for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++)
{
DWORD font_index = hFont - FIRST_STOCK_HANDLE;
index = font_index | 0x80000000;
if (i != DEFAULT_PALETTE && hFont == GetStockObject(i))
{
index = i | 0x80000000;
goto found;
}
}
else
{
index = EMFDRV_CreateFontIndirect(dc, hFont );
}
if(!index) return FALSE;
if (!(index = EMFDRV_CreateFontIndirect(dc, hFont ))) return 0;
found:
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
......@@ -241,6 +237,7 @@ static HPEN EMFDRV_PEN_SelectObject(DC *dc, HPEN hPen )
EMRSELECTOBJECT emr;
DWORD index;
HPEN hOldPen;
int i;
/* If the object is a stock pen object, do not need to create it.
* See definitions in wingdi.h for range of stock pens.
......@@ -248,19 +245,16 @@ static HPEN EMFDRV_PEN_SelectObject(DC *dc, HPEN hPen )
* designate that this is a stock object.
*/
if (hPen >= STOCK_WHITE_PEN &&
hPen <= STOCK_NULL_PEN )
for (i = WHITE_PEN; i <= NULL_PEN; i++)
{
DWORD pen_index = hPen - FIRST_STOCK_HANDLE;
index = pen_index | 0x80000000;
if (hPen == GetStockObject(i))
{
index = i | 0x80000000;
goto found;
}
}
else
{
index = EMFDRV_CreatePenIndirect(dc, hPen );
}
if(!index) return FALSE;
if (!(index = EMFDRV_CreatePenIndirect(dc, hPen ))) return 0;
found:
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
......
......@@ -350,7 +350,12 @@ static Atom RAW_DESCENT;
*/
inline static BOOL is_stock_font( HFONT font )
{
return (font >= FIRST_STOCK_FONT && font <= LAST_STOCK_FONT);
int i;
for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++)
{
if (i != DEFAULT_PALETTE && font == GetStockObject(i)) return TRUE;
}
return FALSE;
}
......
......@@ -246,41 +246,10 @@ typedef struct tagDC_FUNCS
#define DC_DIRTY 0x0004 /* hVisRgn has to be updated */
#define DC_THUNKHOOK 0x0008 /* DC hook is in the 16-bit code */
/* Last 32 bytes are reserved for stock object handles */
#define GDI_HEAP_SIZE 0xffe0
/* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */
#define FIRST_STOCK_HANDLE GDI_HEAP_SIZE
/* Stock objects handles */
#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
#define STOCK_WHITE_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+WHITE_BRUSH))
#define STOCK_LTGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH))
#define STOCK_GRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+GRAY_BRUSH))
#define STOCK_DKGRAY_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH))
#define STOCK_BLACK_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+BLACK_BRUSH))
#define STOCK_NULL_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+NULL_BRUSH))
#define STOCK_HOLLOW_BRUSH ((HBRUSH16)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH))
#define STOCK_WHITE_PEN ((HPEN16)(FIRST_STOCK_HANDLE+WHITE_PEN))
#define STOCK_BLACK_PEN ((HPEN16)(FIRST_STOCK_HANDLE+BLACK_PEN))
#define STOCK_NULL_PEN ((HPEN16)(FIRST_STOCK_HANDLE+NULL_PEN))
#define STOCK_OEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT))
#define STOCK_ANSI_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT))
#define STOCK_ANSI_VAR_FONT ((HFONT16)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT))
#define STOCK_SYSTEM_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FONT))
#define STOCK_DEVICE_DEFAULT_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT))
#define STOCK_DEFAULT_PALETTE ((HPALETTE16)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE))
#define STOCK_SYSTEM_FIXED_FONT ((HFONT16)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT))
#define STOCK_DEFAULT_GUI_FONT ((HFONT16)(FIRST_STOCK_HANDLE+DEFAULT_GUI_FONT))
#define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT
#define LAST_STOCK_FONT STOCK_DEFAULT_GUI_FONT
#define LAST_STOCK_HANDLE ((DWORD)STOCK_DEFAULT_GUI_FONT)
extern HBITMAP hPseudoStockBitmap;
#define GDI_HEAP_SIZE 0xffe0
/* extra stock object: default 1x1 bitmap for memory DCs */
#define DEFAULT_BITMAP (STOCK_LAST+1)
/* Device <-> logical coords conversion */
......
......@@ -681,7 +681,7 @@ HDC WINAPI CreateCompatibleDC( HDC hdc )
dc->flags = DC_MEMORY;
dc->bitsPerPixel = 1;
dc->hBitmap = hPseudoStockBitmap;
dc->hBitmap = GetStockObject( DEFAULT_BITMAP );
/* Copy the driver-specific physical device info into
* the new DC. The driver may use this read-only info
......
......@@ -98,9 +98,6 @@ static COLORREF SysColors[NUM_SYS_COLORS];
static HBRUSH SysColorBrushes[NUM_SYS_COLORS];
static HPEN SysColorPens[NUM_SYS_COLORS];
#define MAKE_SOLID(color) \
(PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color))))
/*************************************************************************
* SYSCOLOR_MakeObjectSystem
......
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