Jacek Caban : gdi32: Don't use gdi_private.h and ntgdi_private.h at the same time.

Alexandre Julliard julliard at winehq.org
Tue Sep 7 16:25:19 CDT 2021


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep  7 14:11:38 2021 +0200

gdi32: Don't use gdi_private.h and ntgdi_private.h at the same time.

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/gdi32/dc.c            |  2 +-
 dlls/gdi32/dib.c           |  2 +-
 dlls/gdi32/emfdc.c         |  2 +-
 dlls/gdi32/enhmetafile.c   |  4 +++-
 dlls/gdi32/gdi_private.h   | 16 ++++++++++++++++
 dlls/gdi32/metadc.c        |  1 -
 dlls/gdi32/metafile.c      | 23 ++++++++++++++++++++++-
 dlls/gdi32/ntgdi_private.h |  3 ++-
 8 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index d8eaa1093f3..4ed09e91eb1 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -30,7 +30,7 @@
 #include "winternl.h"
 #include "winerror.h"
 #include "ntgdi_private.h"
-#include "gdi_private.h"
+
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(dc);
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index b504e8c1a01..f539df6d41e 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -93,7 +93,7 @@ static const struct gdi_obj_funcs dib_funcs =
  *
  * Return the size of the bitmap info structure including color table.
  */
-int bitmap_info_size( const BITMAPINFO * info, WORD coloruse )
+static int bitmap_info_size( const BITMAPINFO *info, WORD coloruse )
 {
     unsigned int colors, size, masks = 0;
 
diff --git a/dlls/gdi32/emfdc.c b/dlls/gdi32/emfdc.c
index 2e237ff26ae..df4515aee8e 100644
--- a/dlls/gdi32/emfdc.c
+++ b/dlls/gdi32/emfdc.c
@@ -21,9 +21,9 @@
  */
 
 #include <assert.h>
+#include <stdlib.h>
 
 #include "gdi_private.h"
-#include "ntgdi_private.h"
 #include "winnls.h"
 
 #include "wine/debug.h"
diff --git a/dlls/gdi32/enhmetafile.c b/dlls/gdi32/enhmetafile.c
index a3147c9b0c4..4b1ccaa9206 100644
--- a/dlls/gdi32/enhmetafile.c
+++ b/dlls/gdi32/enhmetafile.c
@@ -35,13 +35,15 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+#include <math.h>
+
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
 #include "winnls.h"
 #include "winerror.h"
-#include "ntgdi_private.h"
 #include "gdi_private.h"
+
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index af152e10644..2dddf361d5b 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -23,6 +23,7 @@
 #define __WINE_GDI_PRIVATE_H
 
 #include <stdarg.h>
+#include <limits.h>
 
 #include "windef.h"
 #include "winbase.h"
@@ -273,4 +274,19 @@ extern HENHMETAFILE EMF_Create_HENHMETAFILE( ENHMETAHEADER *emh, DWORD filesize,
 extern BOOL get_brush_bitmap_info( HBRUSH handle, BITMAPINFO *info, void *bits,
                                    UINT *usage ) DECLSPEC_HIDDEN;
 
+static inline int get_dib_stride( int width, int bpp )
+{
+    return ((width * bpp + 31) >> 3) & ~3;
+}
+
+/* only for use on sanitized BITMAPINFO structures */
+static inline int get_dib_info_size( const BITMAPINFO *info, UINT coloruse )
+{
+    if (info->bmiHeader.biCompression == BI_BITFIELDS)
+        return sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD);
+    if (coloruse == DIB_PAL_COLORS)
+        return sizeof(BITMAPINFOHEADER) + info->bmiHeader.biClrUsed * sizeof(WORD);
+    return FIELD_OFFSET( BITMAPINFO, bmiColors[info->bmiHeader.biClrUsed] );
+}
+
 #endif /* __WINE_GDI_PRIVATE_H */
diff --git a/dlls/gdi32/metadc.c b/dlls/gdi32/metadc.c
index f988118f29a..6b93dab63ce 100644
--- a/dlls/gdi32/metadc.c
+++ b/dlls/gdi32/metadc.c
@@ -22,7 +22,6 @@
 
 #include <stdarg.h>
 
-#include "ntgdi_private.h"
 #include "gdi_private.h"
 #include "winnls.h"
 #include "wine/wingdi16.h"
diff --git a/dlls/gdi32/metafile.c b/dlls/gdi32/metafile.c
index 07f467914cc..3a49ec6be3d 100644
--- a/dlls/gdi32/metafile.c
+++ b/dlls/gdi32/metafile.c
@@ -56,7 +56,7 @@
 #include "winnls.h"
 #include "winternl.h"
 #include "gdi_private.h"
-#include "ntgdi_private.h"
+
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(metafile);
@@ -110,6 +110,27 @@ HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh)
     return handle;
 }
 
+static int bitmap_info_size( const BITMAPINFO *info, WORD coloruse )
+{
+    unsigned int colors, size, masks = 0;
+
+    if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
+    {
+        const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info;
+        colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0;
+        return sizeof(BITMAPCOREHEADER) + colors *
+             ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD));
+    }
+    else  /* assume BITMAPINFOHEADER */
+    {
+        if (info->bmiHeader.biClrUsed) colors = min( info->bmiHeader.biClrUsed, 256 );
+        else colors = info->bmiHeader.biBitCount > 8 ? 0 : 1 << info->bmiHeader.biBitCount;
+        if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3;
+        size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) );
+        return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD));
+    }
+}
+
 /******************************************************************
  *         convert_points
  *
diff --git a/dlls/gdi32/ntgdi_private.h b/dlls/gdi32/ntgdi_private.h
index 1e379649591..7f21608b244 100644
--- a/dlls/gdi32/ntgdi_private.h
+++ b/dlls/gdi32/ntgdi_private.h
@@ -180,7 +180,6 @@ extern void DC_InitDC( DC * dc ) DECLSPEC_HIDDEN;
 extern void DC_UpdateXforms( DC * dc ) DECLSPEC_HIDDEN;
 
 /* dib.c */
-extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
 extern BOOL fill_color_table_from_pal_colors( BITMAPINFO *info, HDC hdc ) DECLSPEC_HIDDEN;
 extern const RGBQUAD *get_default_color_table( int bpp ) DECLSPEC_HIDDEN;
 extern void fill_default_color_table( BITMAPINFO *info ) DECLSPEC_HIDDEN;
@@ -645,6 +644,8 @@ static inline void copy_bitmapinfo( BITMAPINFO *dst, const BITMAPINFO *src )
 
 extern void CDECL free_heap_bits( struct gdi_image_bits *bits ) DECLSPEC_HIDDEN;
 
+void set_gdi_client_ptr( HGDIOBJ handle, void *ptr ) DECLSPEC_HIDDEN;
+
 extern HMODULE gdi32_module DECLSPEC_HIDDEN;
 
 #endif /* __WINE_NTGDI_PRIVATE_H */




More information about the wine-cvs mailing list