From 0805b0d56750637619529e91c301fb5e94d47564 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 26 Jan 2017 09:30:19 +0000 Subject: [PATCH] gdi32: Add the ability to disable a DC. Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/gdi32/dc.c | 10 ++++++++++ dlls/gdi32/gdi_private.h | 1 + include/wine/gdi_driver.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 27e89aedcaa..892d3e9744b 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -203,6 +203,11 @@ DC *get_dc_ptr( HDC hdc ) { DC *dc = get_dc_obj( hdc ); if (!dc) return NULL; + if (dc->disabled) + { + GDI_ReleaseObj( hdc ); + return NULL; + } if (!InterlockedCompareExchange( &dc->refcount, 1, 0 )) { @@ -1269,6 +1274,11 @@ WORD WINAPI SetHookFlags( HDC hdc, WORD flags ) else if (flags & DCHF_VALIDATEVISRGN || !flags) ret = InterlockedExchange( &dc->dirty, 0 ); + if (flags & DCHF_DISABLEDC) + ret = InterlockedExchange( &dc->disabled, 1 ); + else if (flags & DCHF_ENABLEDC) + ret = InterlockedExchange( &dc->disabled, 0 ); + GDI_ReleaseObj( hdc ); if (flags & DCHF_RESETDC) ret = reset_dc_state( hdc ); diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index e4633d1c338..ab3c9bb1416 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -65,6 +65,7 @@ typedef struct tagDC DWORD thread; /* thread owning the DC */ LONG refcount; /* thread refcount */ LONG dirty; /* dirty flag */ + LONG disabled; /* get_dc_ptr() will return NULL. Controlled by DCHF_(DISABLE|ENABLE)DC */ INT saveLevel; struct tagDC *saved_dc; DWORD_PTR dwHookData; diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 6f67653b51d..32d17f7dcec 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -266,6 +266,8 @@ static inline ULONG window_surface_release( struct window_surface *surface ) #define DCHF_INVALIDATEVISRGN 0x0001 #define DCHF_VALIDATEVISRGN 0x0002 #define DCHF_RESETDC 0x0004 /* Wine extension */ +#define DCHF_DISABLEDC 0x0008 /* Wine extension */ +#define DCHF_ENABLEDC 0x0010 /* Wine extension */ typedef BOOL (CALLBACK *DCHOOKPROC)(HDC,WORD,DWORD_PTR,LPARAM);