[cairo-commit] 2 commits - boilerplate/cairo-boilerplate.h src/cairo-compiler-private.h src/cairo-ft-font.c src/cairo-scaled-font.c src/win32 test/cairo-test.c test/pdf-tagged-text.c util/cairo-script util/cairo-trace

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Sep 2 20:36:22 UTC 2021


 boilerplate/cairo-boilerplate.h          |    7 
 src/cairo-compiler-private.h             |    7 
 src/cairo-ft-font.c                      |   15 +-
 src/cairo-scaled-font.c                  |    2 
 src/win32/cairo-win32-display-surface.c  |   36 +++--
 src/win32/cairo-win32-font.c             |  222 -------------------------------
 src/win32/cairo-win32-printing-surface.c |    7 
 test/cairo-test.c                        |    4 
 test/pdf-tagged-text.c                   |    2 
 util/cairo-script/csi-replay.c           |    2 
 util/cairo-trace/trace.c                 |    7 
 11 files changed, 72 insertions(+), 239 deletions(-)

New commits:
commit 918fe02666f681decb79a0dd8dd782b1f42b13f8
Merge: 42d3f4cc2 2822728f2
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Thu Sep 2 20:36:19 2021 +0000

    Merge branch 'ming-warnings' into 'master'
    
    Fix some MinGW warnings
    
    See merge request cairo/cairo!247

commit 2822728f2af36d7599962d8e57d293cd1a5a2f69
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Aug 28 14:08:25 2021 +0930

    Fix some MinGW warnings
    
    The FT change is because my MinGW build is using a more recent version
    of FT.
    
    Remove the disabled _cairo_win32_scaled_font_text_to_glyphs() code to
    fix the defined but not used warning.
    
    _cairo_win32_scaled_font_text_to_glyphs() was diabled in d9408041aa with
    the comment:
    
      "Currently disable the win32-font text_to_glyphs(), until that one
       is updated.  Or better yet, remove it and implement
       ucs4_to_index().  It's the toy font API afterall."
    
    _cairo_win32_scaled_font_ucs4_to_index() was added in d1c619bc7d.

diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 544d38816..736534eaf 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -74,8 +74,13 @@
 #endif
 
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index) \
+#ifdef __MINGW32__
+#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index)            \
+	__attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index)))
+#else
+#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index)            \
 	__attribute__((__format__(__printf__, fmt_index, va_index)))
+#endif
 #else
 #define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index)
 #endif
diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h
index 502478a5c..103b7a859 100644
--- a/src/cairo-compiler-private.h
+++ b/src/cairo-compiler-private.h
@@ -107,8 +107,13 @@
 #endif
 
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \
+#ifdef __MINGW32__
+#define CAIRO_PRINTF_FORMAT(fmt_index, va_index)                        \
+	__attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index)))
+#else
+#define CAIRO_PRINTF_FORMAT(fmt_index, va_index)                        \
 	__attribute__((__format__(__printf__, fmt_index, va_index)))
+#endif
 #else
 #define CAIRO_PRINTF_FORMAT(fmt_index, va_index)
 #endif
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index adfb445df..8090722ef 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -93,6 +93,11 @@
 #define FT_LCD_FILTER_LEGACY	16
 #endif
 
+/*  FreeType version older than 2.11 does not have the FT_RENDER_MODE_SDF enum value in FT_Render_Mode */
+#if FREETYPE_MAJOR > 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 11)
+#define HAVE_FT_RENDER_MODE_SDF 1
+#endif
+
 #define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0)
 #define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0))
 #define DOUBLE_FROM_16_16(t) ((double)(t) / 65536.0)
@@ -1498,6 +1503,9 @@ _render_glyph_outline (FT_Face                    face,
 	case FT_RENDER_MODE_LIGHT:
 	case FT_RENDER_MODE_NORMAL:
 	case FT_RENDER_MODE_MAX:
+#if HAVE_FT_RENDER_MODE_SDF
+	case FT_RENDER_MODE_SDF:
+#endif
 	default:
 	    format = CAIRO_FORMAT_A8;
 	    break;
@@ -1531,6 +1539,9 @@ _render_glyph_outline (FT_Face                    face,
 	case FT_RENDER_MODE_LIGHT:
 	case FT_RENDER_MODE_NORMAL:
 	case FT_RENDER_MODE_MAX:
+#if HAVE_FT_RENDER_MODE_SDF
+	case FT_RENDER_MODE_SDF:
+#endif
 	default:
 	    break;
 	}
@@ -3241,8 +3252,6 @@ _cairo_ft_font_face_get_implementation (void                     *abstract_face,
 					const cairo_matrix_t       *ctm,
 					const cairo_font_options_t *options)
 {
-    cairo_ft_font_face_t      *font_face = abstract_face;
-
     /* The handling of font options is different depending on how the
      * font face was created. When the user creates a font face with
      * cairo_ft_font_face_create_for_ft_face(), then the load flags
@@ -3254,6 +3263,8 @@ _cairo_ft_font_face_get_implementation (void                     *abstract_face,
      */
 
 #if CAIRO_HAS_FC_FONT
+    cairo_ft_font_face_t      *font_face = abstract_face;
+
     /* If we have an unresolved pattern, resolve it and create
      * unscaled font.  Otherwise, use the ones stored in font_face.
      */
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 65c1d2595..8e7f754f7 100755
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -629,7 +629,7 @@ _hash_mix_bits (uint64_t hash)
 static uintptr_t
 _cairo_scaled_font_compute_hash (cairo_scaled_font_t *scaled_font)
 {
-    uintptr_t hash = FNV1_64_INIT;
+    uint64_t hash = FNV1_64_INIT;
 
     /* We do a bytewise hash on the font matrices */
     hash = _hash_matrix_fnv (&scaled_font->font_matrix, hash);
diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
index 93d33b38b..a3f224c58 100644
--- a/src/win32/cairo-win32-display-surface.c
+++ b/src/win32/cairo-win32-display-surface.c
@@ -987,11 +987,18 @@ cairo_win32_surface_create_with_format (HDC hdc, cairo_format_t format)
     cairo_device_t *device;
 
     switch (format) {
-    default:
-	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
-    case CAIRO_FORMAT_ARGB32:
-    case CAIRO_FORMAT_RGB24:
-	break;
+	case CAIRO_FORMAT_INVALID:
+	case CAIRO_FORMAT_A8:
+	case CAIRO_FORMAT_A1:
+	case CAIRO_FORMAT_RGB16_565:
+	case CAIRO_FORMAT_RGB30:
+	case CAIRO_FORMAT_RGB96F:
+	case CAIRO_FORMAT_RGBA128F:
+	default:
+	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
+	case CAIRO_FORMAT_ARGB32:
+	case CAIRO_FORMAT_RGB24:
+	    break;
     }
 
     surface = _cairo_malloc (sizeof (*surface));
@@ -1102,14 +1109,19 @@ cairo_win32_surface_create_with_ddb (HDC hdc,
     HBITMAP saved_dc_bitmap;
 
     switch (format) {
-    default:
 /* XXX handle these eventually */
-    case CAIRO_FORMAT_A8:
-    case CAIRO_FORMAT_A1:
-	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
-    case CAIRO_FORMAT_ARGB32:
-    case CAIRO_FORMAT_RGB24:
-	break;
+	case CAIRO_FORMAT_INVALID:
+	case CAIRO_FORMAT_A8:
+	case CAIRO_FORMAT_A1:
+	case CAIRO_FORMAT_RGB16_565:
+	case CAIRO_FORMAT_RGB30:
+	case CAIRO_FORMAT_RGB96F:
+	case CAIRO_FORMAT_RGBA128F:
+	default:
+	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
+	case CAIRO_FORMAT_ARGB32:
+	case CAIRO_FORMAT_RGB24:
+	    break;
     }
 
     if (!hdc) {
diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
index 792e329d4..1a0942a29 100644
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -650,226 +650,6 @@ _cairo_win32_scaled_font_fini (void *abstract_font)
 	DeleteObject (scaled_font->unscaled_hfont);
 }
 
-static cairo_int_status_t
-_cairo_win32_scaled_font_type1_text_to_glyphs (cairo_win32_scaled_font_t *scaled_font,
-					       double		          x,
-					       double		          y,
-					       const char	         *utf8,
-					       cairo_glyph_t            **glyphs,
-					       int		         *num_glyphs)
-{
-    uint16_t *utf16;
-    int n16;
-    int i;
-    WORD *glyph_indices = NULL;
-    cairo_status_t status;
-    double x_pos, y_pos;
-    HDC hdc = NULL;
-    cairo_matrix_t mat;
-
-    status = _cairo_utf8_to_utf16 (utf8, -1, &utf16, &n16);
-    if (status)
-	return status;
-
-    glyph_indices = _cairo_malloc_ab (n16 + 1, sizeof (WORD));
-    if (!glyph_indices) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	goto FAIL1;
-    }
-
-    hdc = _get_global_font_dc ();
-    assert (hdc != NULL);
-
-    status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc);
-    if (status)
-	goto FAIL2;
-
-    if (GetGlyphIndicesW (hdc, utf16, n16, glyph_indices, 0) == GDI_ERROR) {
-	status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_type1_text_to_glyphs:GetGlyphIndicesW");
-	goto FAIL3;
-    }
-
-    *num_glyphs = n16;
-    *glyphs = _cairo_malloc_ab (n16, sizeof (cairo_glyph_t));
-    if (!*glyphs) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	goto FAIL3;
-    }
-
-    x_pos = x;
-    y_pos = y;
-
-    mat = scaled_font->base.ctm;
-    status = cairo_matrix_invert (&mat);
-    assert (status == CAIRO_STATUS_SUCCESS);
-
-    _cairo_scaled_font_freeze_cache (&scaled_font->base);
-
-    for (i = 0; i < n16; i++) {
-	cairo_scaled_glyph_t *scaled_glyph;
-
-	(*glyphs)[i].index = glyph_indices[i];
-	(*glyphs)[i].x = x_pos;
-	(*glyphs)[i].y = y_pos;
-
-	status = _cairo_scaled_glyph_lookup (&scaled_font->base,
-					     glyph_indices[i],
-					     CAIRO_SCALED_GLYPH_INFO_METRICS,
-					     &scaled_glyph);
-	if (status) {
-	    free (*glyphs);
-	    *glyphs = NULL;
-	    break;
-	}
-
-	x = scaled_glyph->x_advance;
-	y = scaled_glyph->y_advance;
-	cairo_matrix_transform_distance (&mat, &x, &y);
-	x_pos += x;
-	y_pos += y;
-    }
-
-    _cairo_scaled_font_thaw_cache (&scaled_font->base);
-
-FAIL3:
-    cairo_win32_scaled_font_done_font (&scaled_font->base);
-FAIL2:
-    free (glyph_indices);
-FAIL1:
-    free (utf16);
-
-    return status;
-}
-
-static cairo_int_status_t
-_cairo_win32_scaled_font_text_to_glyphs (void		*abstract_font,
-					 double		x,
-					 double		y,
-					 const char	*utf8,
-					 cairo_glyph_t **glyphs,
-					 int		*num_glyphs)
-{
-    cairo_win32_scaled_font_t *scaled_font = abstract_font;
-    uint16_t *utf16;
-    int n16;
-    GCP_RESULTSW gcp_results;
-    unsigned int buffer_size, i;
-    WCHAR *glyph_indices = NULL;
-    int *dx = NULL;
-    cairo_status_t status;
-    double x_pos, y_pos;
-    double x_incr, y_incr;
-    HDC hdc = NULL;
-
-    /* GetCharacterPlacement() returns utf16 instead of glyph indices
-     * for Type 1 fonts. Use GetGlyphIndices for Type 1 fonts. */
-    if (scaled_font->is_type1)
-	 return _cairo_win32_scaled_font_type1_text_to_glyphs (scaled_font,
-							       x,
-							       y,
-							       utf8,
-							       glyphs,
-							       num_glyphs);
-
-    /* Compute a vector in user space along the baseline of length one logical space unit */
-    x_incr = 1;
-    y_incr = 0;
-    cairo_matrix_transform_distance (&scaled_font->base.font_matrix, &x_incr, &y_incr);
-    x_incr /= scaled_font->logical_scale;
-    y_incr /= scaled_font->logical_scale;
-
-    status = _cairo_utf8_to_utf16 (utf8, -1, &utf16, &n16);
-    if (status)
-	return status;
-
-    gcp_results.lStructSize = sizeof (GCP_RESULTS);
-    gcp_results.lpOutString = NULL;
-    gcp_results.lpOrder = NULL;
-    gcp_results.lpCaretPos = NULL;
-    gcp_results.lpClass = NULL;
-
-    buffer_size = MAX (n16 * 1.2, 16);		/* Initially guess number of chars plus a few */
-    if (buffer_size > INT_MAX) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	goto FAIL1;
-    }
-
-    hdc = _get_global_font_dc ();
-    assert (hdc != NULL);
-
-    status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc);
-    if (status)
-	goto FAIL1;
-
-    while (TRUE) {
-	free (glyph_indices);
-	glyph_indices = NULL;
-
-	free (dx);
-	dx = NULL;
-
-	glyph_indices = _cairo_malloc_ab (buffer_size, sizeof (WCHAR));
-	dx = _cairo_malloc_ab (buffer_size, sizeof (int));
-	if (!glyph_indices || !dx) {
-	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    goto FAIL2;
-	}
-
-	gcp_results.nGlyphs = buffer_size;
-	gcp_results.lpDx = dx;
-	gcp_results.lpGlyphs = glyph_indices;
-
-	if (!GetCharacterPlacementW (hdc, utf16, n16,
-				     0,
-				     &gcp_results,
-				     GCP_DIACRITIC | GCP_LIGATE | GCP_GLYPHSHAPE | GCP_REORDER)) {
-	    status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_text_to_glyphs");
-	    goto FAIL2;
-	}
-
-	if (gcp_results.lpDx && gcp_results.lpGlyphs)
-	    break;
-
-	/* Too small a buffer, try again */
-
-	buffer_size += buffer_size / 2;
-	if (buffer_size > INT_MAX) {
-	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    goto FAIL2;
-	}
-    }
-
-    *num_glyphs = gcp_results.nGlyphs;
-    *glyphs = _cairo_malloc_ab (gcp_results.nGlyphs, sizeof (cairo_glyph_t));
-    if (!*glyphs) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	goto FAIL2;
-    }
-
-    x_pos = x;
-    y_pos = y;
-
-    for (i = 0; i < gcp_results.nGlyphs; i++) {
-	(*glyphs)[i].index = glyph_indices[i];
-	(*glyphs)[i].x = x_pos ;
-	(*glyphs)[i].y = y_pos;
-
-	x_pos += x_incr * dx[i];
-	y_pos += y_incr * dx[i];
-    }
-
- FAIL2:
-    free (glyph_indices);
-    free (dx);
-
-    cairo_win32_scaled_font_done_font (&scaled_font->base);
-
- FAIL1:
-    free (utf16);
-
-    return status;
-}
-
 static unsigned long
 _cairo_win32_scaled_font_ucs4_to_index (void		*abstract_font,
 					uint32_t	 ucs4)
@@ -1843,7 +1623,7 @@ const cairo_scaled_font_backend_t _cairo_win32_scaled_font_backend = {
     CAIRO_FONT_TYPE_WIN32,
     _cairo_win32_scaled_font_fini,
     _cairo_win32_scaled_font_glyph_init,
-    NULL, /* _cairo_win32_scaled_font_text_to_glyphs, FIXME */
+    NULL, /* _cairo_win32_scaled_font_text_to_glyphs */
     _cairo_win32_scaled_font_ucs4_to_index,
     _cairo_win32_scaled_font_load_truetype_table,
     _cairo_win32_scaled_font_index_to_ucs4,
diff --git a/src/win32/cairo-win32-printing-surface.c b/src/win32/cairo-win32-printing-surface.c
index 36d17e960..c9f02215f 100644
--- a/src/win32/cairo-win32-printing-surface.c
+++ b/src/win32/cairo-win32-printing-surface.c
@@ -167,8 +167,15 @@ _cairo_win32_printing_surface_init_language_pack (cairo_win32_printing_surface_t
 
     module = GetModuleHandleW (L"GDI32.DLL");
     if (module) {
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-function-type"
+#endif
 	gdi_init_lang_pack = (gdi_init_lang_pack_func_t)
 	    GetProcAddress (module, "GdiInitializeLanguagePack");
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
 	if (gdi_init_lang_pack)
 	    gdi_init_lang_pack (0);
     }
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 3d241d814..df230e523 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -1508,9 +1508,13 @@ _cairo_test_context_run_for_target (cairo_test_context_t *ctx,
     if (! RUNNING_ON_VALGRIND) {
 	void (* volatile old_segfault_handler)(int);
 	void (* volatile old_segfpe_handler)(int);
+#ifdef SIGPIPE
 	void (* volatile old_sigpipe_handler)(int);
+#endif
 	void (* volatile old_sigabrt_handler)(int);
+#ifdef SIGALRM
 	void (* volatile old_sigalrm_handler)(int);
+#endif
 
 	/* Set up a checkpoint to get back to in case of segfaults. */
 #ifdef SIGSEGV
diff --git a/test/pdf-tagged-text.c b/test/pdf-tagged-text.c
index 8908eb25d..d0617d0d3 100644
--- a/test/pdf-tagged-text.c
+++ b/test/pdf-tagged-text.c
@@ -465,7 +465,9 @@ check_created_pdf(cairo_test_context_t *ctx, const char* filename)
     cairo_test_status_t result = CAIRO_TEST_SUCCESS;
     int fd;
     struct stat st;
+#ifdef HAVE_MMAP
     void *contents;
+#endif
 
     fd = open(filename, O_RDONLY, 0);
     if (fd < 0) {
diff --git a/util/cairo-script/csi-replay.c b/util/cairo-script/csi-replay.c
index 4c66b7752..9d9be72c2 100644
--- a/util/cairo-script/csi-replay.c
+++ b/util/cairo-script/csi-replay.c
@@ -41,7 +41,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+#if defined(CAIRO_HAS_XLIB_SURFACE) || defined(CAIRO_HAS_XLIB_XRENDER_SURFACE)
 static const cairo_user_data_key_t _key;
+#endif
 
 #define SINGLE_SURFACE 1
 
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index cc4b18c0d..bb79c85b9 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -99,8 +99,13 @@
 #define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16)
 
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \
+#ifdef __MINGW32__
+#define CAIRO_PRINTF_FORMAT(fmt_index, va_index)                        \
+	__attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index)))
+#else
+#define CAIRO_PRINTF_FORMAT(fmt_index, va_index)                        \
 	__attribute__((__format__(__printf__, fmt_index, va_index)))
+#endif
 #else
 #define CAIRO_PRINTF_FORMAT(fmt_index, va_index)
 #endif


More information about the cairo-commit mailing list