mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 16:13:38 +00:00
gdi32: Use shifted values for NTGDI_OBJ_* constants.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
21cec48570
commit
5794b2da18
|
@ -47,7 +47,7 @@ static const struct gdi_obj_funcs dc_funcs =
|
|||
|
||||
static inline DC *get_dc_obj( HDC hdc )
|
||||
{
|
||||
WORD type;
|
||||
DWORD type;
|
||||
DC *dc = get_any_obj_ptr( hdc, &type );
|
||||
if (!dc) return NULL;
|
||||
|
||||
|
@ -118,7 +118,7 @@ static void set_initial_dc_state( DC *dc )
|
|||
/***********************************************************************
|
||||
* alloc_dc_ptr
|
||||
*/
|
||||
DC *alloc_dc_ptr( WORD magic )
|
||||
DC *alloc_dc_ptr( DWORD magic )
|
||||
{
|
||||
DC *dc;
|
||||
|
||||
|
|
|
@ -29,16 +29,16 @@
|
|||
#include "ntgdi.h"
|
||||
|
||||
void set_gdi_client_ptr( HGDIOBJ handle, void *ptr ) DECLSPEC_HIDDEN;
|
||||
void *get_gdi_client_ptr( HGDIOBJ handle, WORD type ) DECLSPEC_HIDDEN;
|
||||
void *get_gdi_client_ptr( HGDIOBJ handle, DWORD type ) DECLSPEC_HIDDEN;
|
||||
DC_ATTR *get_dc_attr( HDC hdc ) DECLSPEC_HIDDEN;
|
||||
void GDI_hdc_using_object( HGDIOBJ obj, HDC hdc,
|
||||
void (*delete)( HDC hdc, HGDIOBJ handle )) DECLSPEC_HIDDEN;
|
||||
void GDI_hdc_not_using_object( HGDIOBJ obj, HDC hdc ) DECLSPEC_HIDDEN;
|
||||
|
||||
static inline WORD gdi_handle_type( HGDIOBJ obj )
|
||||
static inline DWORD gdi_handle_type( HGDIOBJ obj )
|
||||
{
|
||||
unsigned int handle = HandleToULong( obj );
|
||||
return (handle & NTGDI_HANDLE_TYPE_MASK) >> NTGDI_HANDLE_TYPE_SHIFT;
|
||||
return handle & NTGDI_HANDLE_TYPE_MASK;
|
||||
}
|
||||
|
||||
static inline BOOL is_meta_dc( HDC hdc )
|
||||
|
|
|
@ -31,9 +31,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdi);
|
|||
|
||||
DC_ATTR *get_dc_attr( HDC hdc )
|
||||
{
|
||||
WORD type = gdi_handle_type( hdc );
|
||||
DWORD type = gdi_handle_type( hdc );
|
||||
DC_ATTR *dc_attr;
|
||||
if ((type & 0x1f) != NTGDI_OBJ_DC || !(dc_attr = get_gdi_client_ptr( hdc, 0 )))
|
||||
if ((type & 0x1f0000) != NTGDI_OBJ_DC || !(dc_attr = get_gdi_client_ptr( hdc, 0 )))
|
||||
{
|
||||
SetLastError( ERROR_INVALID_HANDLE );
|
||||
return NULL;
|
||||
|
|
|
@ -47,7 +47,7 @@ HMODULE gdi32_module = 0;
|
|||
static inline HGDIOBJ entry_to_handle( GDI_HANDLE_ENTRY *entry )
|
||||
{
|
||||
unsigned int idx = entry - gdi_shared.Handles;
|
||||
return LongToHandle( idx | (entry->Unique << 16) );
|
||||
return LongToHandle( idx | (entry->Unique << NTGDI_HANDLE_TYPE_SHIFT) );
|
||||
}
|
||||
|
||||
static inline GDI_HANDLE_ENTRY *handle_entry( HGDIOBJ handle )
|
||||
|
@ -720,8 +720,8 @@ static void dump_gdi_objects( void )
|
|||
else
|
||||
TRACE( "handle %p obj %s type %s selcount %u deleted %u\n",
|
||||
entry_to_handle( entry ), wine_dbgstr_longlong( entry->Object ),
|
||||
gdi_obj_type( entry->ExtType ), entry_obj( entry )->selcount,
|
||||
entry_obj( entry )->deleted );
|
||||
gdi_obj_type( entry->ExtType << NTGDI_HANDLE_TYPE_SHIFT ),
|
||||
entry_obj( entry )->selcount, entry_obj( entry )->deleted );
|
||||
}
|
||||
LeaveCriticalSection( &gdi_section );
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ static void dump_gdi_objects( void )
|
|||
*
|
||||
* Allocate a GDI handle for an object, which must have been allocated on the process heap.
|
||||
*/
|
||||
HGDIOBJ alloc_gdi_handle( struct gdi_obj_header *obj, WORD type, const struct gdi_obj_funcs *funcs )
|
||||
HGDIOBJ alloc_gdi_handle( struct gdi_obj_header *obj, DWORD type, const struct gdi_obj_funcs *funcs )
|
||||
{
|
||||
GDI_HANDLE_ENTRY *entry;
|
||||
HGDIOBJ ret;
|
||||
|
@ -757,8 +757,8 @@ HGDIOBJ alloc_gdi_handle( struct gdi_obj_header *obj, WORD type, const struct gd
|
|||
obj->system = 0;
|
||||
obj->deleted = 0;
|
||||
entry->Object = (UINT_PTR)obj;
|
||||
entry->Type = type & 0x1f;
|
||||
entry->ExtType = type;
|
||||
entry->ExtType = type >> NTGDI_HANDLE_TYPE_SHIFT;
|
||||
entry->Type = entry->ExtType & 0x1f;
|
||||
if (++entry->Generation == 0xff) entry->Generation = 1;
|
||||
ret = entry_to_handle( entry );
|
||||
LeaveCriticalSection( &gdi_section );
|
||||
|
@ -781,8 +781,8 @@ void *free_gdi_handle( HGDIOBJ handle )
|
|||
EnterCriticalSection( &gdi_section );
|
||||
if ((entry = handle_entry( handle )))
|
||||
{
|
||||
TRACE( "freed %s %p %u/%u\n", gdi_obj_type( entry->ExtType ), handle,
|
||||
InterlockedDecrement( &debug_count ) + 1, GDI_MAX_HANDLE_COUNT );
|
||||
TRACE( "freed %s %p %u/%u\n", gdi_obj_type( entry->ExtType << NTGDI_HANDLE_TYPE_SHIFT ),
|
||||
handle, InterlockedDecrement( &debug_count ) + 1, GDI_MAX_HANDLE_COUNT );
|
||||
object = entry_obj( entry );
|
||||
entry->Type = 0;
|
||||
entry->Object = (UINT_PTR)next_free;
|
||||
|
@ -818,7 +818,7 @@ HGDIOBJ get_full_gdi_handle( HGDIOBJ handle )
|
|||
* associated with the handle.
|
||||
* The object must be released with GDI_ReleaseObj.
|
||||
*/
|
||||
void *get_any_obj_ptr( HGDIOBJ handle, WORD *type )
|
||||
void *get_any_obj_ptr( HGDIOBJ handle, DWORD *type )
|
||||
{
|
||||
void *ptr = NULL;
|
||||
GDI_HANDLE_ENTRY *entry;
|
||||
|
@ -828,7 +828,7 @@ void *get_any_obj_ptr( HGDIOBJ handle, WORD *type )
|
|||
if ((entry = handle_entry( handle )))
|
||||
{
|
||||
ptr = entry_obj( entry );
|
||||
*type = entry->ExtType;
|
||||
*type = entry->ExtType << NTGDI_HANDLE_TYPE_SHIFT;
|
||||
}
|
||||
|
||||
if (!ptr) LeaveCriticalSection( &gdi_section );
|
||||
|
@ -842,9 +842,9 @@ void *get_any_obj_ptr( HGDIOBJ handle, WORD *type )
|
|||
* Return NULL if the object has the wrong type.
|
||||
* The object must be released with GDI_ReleaseObj.
|
||||
*/
|
||||
void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
|
||||
void *GDI_GetObjPtr( HGDIOBJ handle, DWORD type )
|
||||
{
|
||||
WORD ret_type;
|
||||
DWORD ret_type;
|
||||
void *ptr = get_any_obj_ptr( handle, &ret_type );
|
||||
if (ptr && ret_type != type)
|
||||
{
|
||||
|
|
|
@ -187,7 +187,7 @@ static inline HRGN get_dc_region( DC *dc )
|
|||
}
|
||||
|
||||
/* dc.c */
|
||||
extern DC *alloc_dc_ptr( WORD magic ) DECLSPEC_HIDDEN;
|
||||
extern DC *alloc_dc_ptr( DWORD magic ) DECLSPEC_HIDDEN;
|
||||
extern void free_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
|
||||
extern DC *get_dc_ptr( HDC hdc ) DECLSPEC_HIDDEN;
|
||||
extern void release_dc_ptr( DC *dc ) DECLSPEC_HIDDEN;
|
||||
|
@ -390,12 +390,12 @@ extern BOOL opentype_get_properties( const void *data, size_t size, const struct
|
|||
extern BOOL translate_charset_info( DWORD *src, CHARSETINFO *cs, DWORD flags ) DECLSPEC_HIDDEN;
|
||||
|
||||
/* gdiobj.c */
|
||||
extern HGDIOBJ alloc_gdi_handle( struct gdi_obj_header *obj, WORD type,
|
||||
extern HGDIOBJ alloc_gdi_handle( struct gdi_obj_header *obj, DWORD type,
|
||||
const struct gdi_obj_funcs *funcs ) DECLSPEC_HIDDEN;
|
||||
extern void *free_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
|
||||
extern HGDIOBJ get_full_gdi_handle( HGDIOBJ handle ) DECLSPEC_HIDDEN;
|
||||
extern void *GDI_GetObjPtr( HGDIOBJ, WORD ) DECLSPEC_HIDDEN;
|
||||
extern void *get_any_obj_ptr( HGDIOBJ, WORD * ) DECLSPEC_HIDDEN;
|
||||
extern void *GDI_GetObjPtr( HGDIOBJ, DWORD ) DECLSPEC_HIDDEN;
|
||||
extern void *get_any_obj_ptr( HGDIOBJ, DWORD * ) DECLSPEC_HIDDEN;
|
||||
extern void GDI_ReleaseObj( HGDIOBJ ) DECLSPEC_HIDDEN;
|
||||
extern void GDI_CheckNotLock(void) DECLSPEC_HIDDEN;
|
||||
extern UINT GDI_get_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -95,10 +95,10 @@ static inline GDI_HANDLE_ENTRY *handle_entry( HGDIOBJ handle )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static WORD get_object_type( HGDIOBJ obj )
|
||||
static DWORD get_object_type( HGDIOBJ obj )
|
||||
{
|
||||
GDI_HANDLE_ENTRY *entry = handle_entry( obj );
|
||||
return entry ? entry->ExtType : 0;
|
||||
return entry ? entry->ExtType << NTGDI_HANDLE_TYPE_SHIFT : 0;
|
||||
}
|
||||
|
||||
void set_gdi_client_ptr( HGDIOBJ obj, void *ptr )
|
||||
|
@ -107,10 +107,10 @@ void set_gdi_client_ptr( HGDIOBJ obj, void *ptr )
|
|||
if (entry) entry->UserPointer = (UINT_PTR)ptr;
|
||||
}
|
||||
|
||||
void *get_gdi_client_ptr( HGDIOBJ obj, WORD type )
|
||||
void *get_gdi_client_ptr( HGDIOBJ obj, DWORD type )
|
||||
{
|
||||
GDI_HANDLE_ENTRY *entry = handle_entry( obj );
|
||||
if (!entry || (type && entry->ExtType != type) || !entry->UserPointer)
|
||||
if (!entry || (type && entry->ExtType << NTGDI_HANDLE_TYPE_SHIFT != type))
|
||||
return NULL;
|
||||
return (void *)(UINT_PTR)entry->UserPointer;
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ HGDIOBJ WINAPI NtGdiSelectPen( HDC hdc, HGDIOBJ handle )
|
|||
{
|
||||
PENOBJ *pen;
|
||||
HGDIOBJ ret = 0;
|
||||
WORD type;
|
||||
DWORD type;
|
||||
DC *dc;
|
||||
|
||||
if (!(dc = get_dc_ptr( hdc ))) return 0;
|
||||
|
@ -262,7 +262,7 @@ static BOOL PEN_DeleteObject( HGDIOBJ handle )
|
|||
*/
|
||||
static INT PEN_GetObject( HGDIOBJ handle, INT count, LPVOID buffer )
|
||||
{
|
||||
WORD type;
|
||||
DWORD type;
|
||||
PENOBJ *pen = get_any_obj_ptr( handle, &type );
|
||||
INT ret = 0;
|
||||
|
||||
|
|
|
@ -389,15 +389,18 @@ static void test_shared_handle_entry( HGDIOBJ obj, unsigned int type, BOOL is_st
|
|||
entry->Unique, handle >> 16);
|
||||
if (type != NTGDI_OBJ_MEMDC)
|
||||
{
|
||||
ok(entry->ExtType == type, "ExtType = %x, expected %x\n", entry->ExtType, type);
|
||||
ok(entry->ExtType << NTGDI_HANDLE_TYPE_SHIFT == type, "ExtType = %x, expected %x\n",
|
||||
entry->ExtType, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
todo_wine
|
||||
ok(entry->ExtType == NTGDI_OBJ_DC, "ExtType = %x, expected NTGDI_OBJ_DC\n", entry->ExtType);
|
||||
ok(entry->ExtType << NTGDI_HANDLE_TYPE_SHIFT == NTGDI_OBJ_DC,
|
||||
"ExtType = %x, expected NTGDI_OBJ_DC\n", entry->ExtType);
|
||||
}
|
||||
ok(entry->StockFlag == is_stock, "StockFlag = %x\n", entry->StockFlag);
|
||||
ok(entry->Type == (type & 0x1f), "Type = %x, expected %x\n", entry->Type, type & 0x1f);
|
||||
ok(entry->Type << NTGDI_HANDLE_TYPE_SHIFT == (type & 0x1f0000),
|
||||
"Type = %x, expected %x\n", entry->Type, type & 0x1f);
|
||||
ok(entry->Object, "Object = NULL\n");
|
||||
ok(entry->Owner.Count == 0, "Count = %u\n", entry->Owner.Count);
|
||||
}
|
||||
|
|
|
@ -54,21 +54,21 @@ typedef struct _GDI_HANDLE_ENTRY
|
|||
|
||||
#define GDI_MAX_HANDLE_COUNT 0x10000
|
||||
|
||||
#define NTGDI_OBJ_DC 0x01
|
||||
#define NTGDI_OBJ_ENHMETADC 0x21
|
||||
#define NTGDI_OBJ_REGION 0x04
|
||||
#define NTGDI_OBJ_METAFILE 0x26
|
||||
#define NTGDI_OBJ_ENHMETAFILE 0x46
|
||||
#define NTGDI_OBJ_METADC 0x66
|
||||
#define NTGDI_OBJ_PAL 0x08
|
||||
#define NTGDI_OBJ_BITMAP 0x09
|
||||
#define NTGDI_OBJ_FONT 0x0a
|
||||
#define NTGDI_OBJ_BRUSH 0x10
|
||||
#define NTGDI_OBJ_PEN 0x30
|
||||
#define NTGDI_OBJ_EXTPEN 0x50
|
||||
#define NTGDI_OBJ_DC 0x010000
|
||||
#define NTGDI_OBJ_ENHMETADC 0x210000
|
||||
#define NTGDI_OBJ_REGION 0x040000
|
||||
#define NTGDI_OBJ_METAFILE 0x260000
|
||||
#define NTGDI_OBJ_ENHMETAFILE 0x460000
|
||||
#define NTGDI_OBJ_METADC 0x660000
|
||||
#define NTGDI_OBJ_PAL 0x080000
|
||||
#define NTGDI_OBJ_BITMAP 0x090000
|
||||
#define NTGDI_OBJ_FONT 0x0a0000
|
||||
#define NTGDI_OBJ_BRUSH 0x100000
|
||||
#define NTGDI_OBJ_PEN 0x300000
|
||||
#define NTGDI_OBJ_EXTPEN 0x500000
|
||||
|
||||
/* Wine extension, native uses NTGDI_OBJ_DC */
|
||||
#define NTGDI_OBJ_MEMDC 0x41
|
||||
#define NTGDI_OBJ_MEMDC 0x410000
|
||||
|
||||
#define NTGDI_HANDLE_TYPE_SHIFT 16
|
||||
#define NTGDI_HANDLE_TYPE_MASK 0x007f0000
|
||||
|
|
Loading…
Reference in a new issue