Jacek Caban : win32u: Move 55aa brush implementation from user32.

Alexandre Julliard julliard at winehq.org
Tue Dec 7 15:58:45 CST 2021


Module: wine
Branch: master
Commit: a48127034ddc230b7375703f7827f049478e83e7
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a48127034ddc230b7375703f7827f049478e83e7

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Dec  7 15:29:06 2021 +0100

win32u: Move 55aa brush implementation from user32.

And don't expose __wine_make_gdi_object_system.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/sysparams.c      | 17 +----------------
 dlls/win32u/gdiobj.c         | 11 +----------
 dlls/win32u/ntgdi_private.h  |  1 +
 dlls/win32u/sysparams.c      | 33 +++++++++++++++++++++++++++------
 dlls/win32u/win32u.spec      |  1 -
 dlls/win32u/win32u_private.h |  1 -
 dlls/win32u/wrappers.c       |  6 ------
 include/ntuser.h             |  3 +++
 include/wine/gdi_driver.h    |  1 -
 9 files changed, 33 insertions(+), 41 deletions(-)

diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index bcc9c5cbf07..a21b5035048 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -523,22 +523,7 @@ HPEN SYSCOLOR_GetPen( INT index )
  */
 HBRUSH SYSCOLOR_Get55AABrush(void)
 {
-    static const WORD pattern[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
-    static HBRUSH brush_55aa;
-
-    if (!brush_55aa)
-    {
-        HBITMAP bitmap = CreateBitmap( 8, 8, 1, 1, pattern );
-        HBRUSH brush = CreatePatternBrush( bitmap );
-        DeleteObject( bitmap );
-        __wine_make_gdi_object_system( brush, TRUE );
-        if (InterlockedCompareExchangePointer( (void **)&brush_55aa, brush, 0 ))
-        {
-            __wine_make_gdi_object_system( brush, FALSE );
-            DeleteObject( brush );
-        }
-    }
-    return brush_55aa;
+    return UlongToHandle( NtUserCallOneParam( COLOR_55AA_BRUSH, NtUserGetSysColorBrush ));
 }
 
 /***********************************************************************
diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c
index a771f10d20b..002c7539498 100644
--- a/dlls/win32u/gdiobj.c
+++ b/dlls/win32u/gdiobj.c
@@ -452,15 +452,7 @@ static const struct DefaultFontInfo default_fonts[] =
     },
 };
 
-
-/*************************************************************************
- * __wine_make_gdi_object_system    (win32u.@)
- *
- * USER has to tell GDI that its system brushes and pens are non-deletable.
- * For a description of the GDI object magics and their flags,
- * see "Undocumented Windows" (wrong about the OBJECT_NOSYSTEM flag, though).
- */
-void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set)
+void make_gdi_object_system( HGDIOBJ handle, BOOL set)
 {
     GDI_HANDLE_ENTRY *entry;
 
@@ -1191,7 +1183,6 @@ static struct unix_funcs unix_funcs =
     __wine_get_icm_profile,
     __wine_get_vulkan_driver,
     __wine_get_wgl_driver,
-    __wine_make_gdi_object_system,
     __wine_set_display_driver,
     __wine_set_visible_region,
 };
diff --git a/dlls/win32u/ntgdi_private.h b/dlls/win32u/ntgdi_private.h
index b42ff024b59..bfeb4557da7 100644
--- a/dlls/win32u/ntgdi_private.h
+++ b/dlls/win32u/ntgdi_private.h
@@ -374,6 +374,7 @@ extern HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
 extern BOOL GDI_dec_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
 extern HGDIOBJ get_stock_object( INT obj ) DECLSPEC_HIDDEN;
 extern DWORD get_gdi_object_type( HGDIOBJ obj ) DECLSPEC_HIDDEN;
+extern void make_gdi_object_system( HGDIOBJ handle, BOOL set ) DECLSPEC_HIDDEN;
 
 /* mapping.c */
 extern BOOL dp_to_lp( DC *dc, POINT *points, INT count ) DECLSPEC_HIDDEN;
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index 9d600d10fe8..94c7a58fc0e 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -2357,12 +2357,12 @@ static BOOL set_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void
     entry->hdr.loaded = TRUE;
     if ((brush = InterlockedExchangePointer( (void **)&entry->rgb.brush, 0 )))
     {
-        __wine_make_gdi_object_system( brush, FALSE );
+        make_gdi_object_system( brush, FALSE );
         NtGdiDeleteObjectApp( brush );
     }
     if ((pen = InterlockedExchangePointer( (void **)&entry->rgb.pen, 0 )))
     {
-        __wine_make_gdi_object_system( pen, FALSE );
+        make_gdi_object_system( pen, FALSE );
         NtGdiDeleteObjectApp( pen );
     }
     return TRUE;
@@ -4279,17 +4279,38 @@ static COLORREF get_sys_color( int index )
     return ret;
 }
 
+static HBRUSH get_55aa_brush(void)
+{
+    static const WORD pattern[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
+    static HBRUSH brush_55aa;
+
+    if (!brush_55aa)
+    {
+        HBITMAP bitmap = NtGdiCreateBitmap( 8, 8, 1, 1, pattern );
+        HBRUSH brush = NtGdiCreatePatternBrushInternal( bitmap, FALSE, FALSE );
+        NtGdiDeleteObjectApp( bitmap );
+        make_gdi_object_system( brush, TRUE );
+        if (InterlockedCompareExchangePointer( (void **)&brush_55aa, brush, 0 ))
+        {
+            make_gdi_object_system( brush, FALSE );
+            NtGdiDeleteObjectApp( brush );
+        }
+    }
+    return brush_55aa;
+}
+
 static HBRUSH get_sys_color_brush( unsigned int index )
 {
+    if (index == COLOR_55AA_BRUSH) return get_55aa_brush();
     if (index >= ARRAY_SIZE( system_colors )) return 0;
 
     if (!system_colors[index].brush)
     {
         HBRUSH brush = NtGdiCreateSolidBrush( get_sys_color( index ), NULL );
-        __wine_make_gdi_object_system( brush, TRUE );
+        make_gdi_object_system( brush, TRUE );
         if (InterlockedCompareExchangePointer( (void **)&system_colors[index].brush, brush, 0 ))
         {
-            __wine_make_gdi_object_system( brush, FALSE );
+            make_gdi_object_system( brush, FALSE );
             NtGdiDeleteObjectApp( brush );
         }
     }
@@ -4303,10 +4324,10 @@ static HPEN get_sys_color_pen( unsigned int index )
     if (!system_colors[index].pen)
     {
         HPEN pen = NtGdiCreatePen( PS_SOLID, 1, get_sys_color( index ), NULL );
-        __wine_make_gdi_object_system( pen, TRUE );
+        make_gdi_object_system( pen, TRUE );
         if (InterlockedCompareExchangePointer( (void **)&system_colors[index].pen, pen, 0 ))
         {
-            __wine_make_gdi_object_system( pen, FALSE );
+            make_gdi_object_system( pen, FALSE );
             NtGdiDeleteObjectApp( pen );
         }
     }
diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec
index cb06e06d2a9..786d764a095 100644
--- a/dlls/win32u/win32u.spec
+++ b/dlls/win32u/win32u.spec
@@ -1324,7 +1324,6 @@
 @ stdcall GetDCHook(long ptr)
 @ stdcall SetDCHook(long ptr long)
 @ stdcall SetHookFlags(long long)
-@ cdecl __wine_make_gdi_object_system(long long)
 @ cdecl __wine_set_visible_region(long long ptr ptr ptr)
 
 # Graphics drivers
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index 46893760356..098baef51a5 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -235,7 +235,6 @@ struct unix_funcs
     BOOL (CDECL *get_icm_profile)( HDC hdc, BOOL allow_default, DWORD *size, WCHAR *filename );
     const struct vulkan_funcs * (CDECL *get_vulkan_driver)( HDC hdc, UINT version );
     struct opengl_funcs * (CDECL *get_wgl_driver)( HDC hdc, UINT version );
-    void (CDECL *make_gdi_object_system)( HGDIOBJ handle, BOOL set );
     void (CDECL *set_display_driver)( struct user_driver_funcs *funcs, UINT version );
     void (CDECL *set_visible_region)( HDC hdc, HRGN hrgn, const RECT *vis_rect, const RECT *device_rect,
                                       struct window_surface *surface );
diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c
index 3402c09f023..bf84846a002 100644
--- a/dlls/win32u/wrappers.c
+++ b/dlls/win32u/wrappers.c
@@ -877,12 +877,6 @@ BOOL CDECL __wine_get_icm_profile( HDC hdc, BOOL allow_default, DWORD *size, WCH
     return unix_funcs->get_icm_profile( hdc, allow_default, size, filename );
 }
 
-void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set )
-{
-    if (!unix_funcs) return;
-    return unix_funcs->make_gdi_object_system( handle, set );
-}
-
 void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect, const RECT *device_rect,
                                       struct window_surface *surface )
 {
diff --git a/include/ntuser.h b/include/ntuser.h
index 4cb090c4a31..9583b78acf2 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -66,6 +66,9 @@ enum
     NtUserMirrorRgn,
 };
 
+/* color index used to retrieve system 55aa brush */
+#define COLOR_55AA_BRUSH  0x100
+
 /* this is the structure stored in TEB->Win32ClientInfo */
 /* no attempt is made to keep the layout compatible with the Windows one */
 struct user_thread_info
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h
index f76170f5a16..f0263857883 100644
--- a/include/wine/gdi_driver.h
+++ b/include/wine/gdi_driver.h
@@ -342,7 +342,6 @@ WINGDIAPI DWORD_PTR WINAPI GetDCHook(HDC,DCHOOKPROC*);
 WINGDIAPI BOOL      WINAPI SetDCHook(HDC,DCHOOKPROC,DWORD_PTR);
 WINGDIAPI WORD      WINAPI SetHookFlags(HDC,WORD);
 
-extern void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set );
 extern void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect,
                                              const RECT *device_rect, struct window_surface *surface );
 extern void CDECL __wine_set_display_driver( struct user_driver_funcs *funcs, UINT version );




More information about the wine-cvs mailing list