diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-10-20 03:19:36 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-10-20 03:19:36 +0000 |
commit | a0338805df9dc1fecaea5c73227920d26b22f393 (patch) | |
tree | 4435afcafcba9b521365e0aa803cc4af349c424f /Build/source/libs/cairo/cairo-src/src/cairo-scaled-font.c | |
parent | 85f2dd77c74d1da068da86d4c931363ea620319b (diff) |
cairo 1.16.0
git-svn-id: svn://tug.org/texlive/trunk@48952 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/cairo/cairo-src/src/cairo-scaled-font.c')
-rw-r--r-- | Build/source/libs/cairo/cairo-src/src/cairo-scaled-font.c | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/Build/source/libs/cairo/cairo-src/src/cairo-scaled-font.c b/Build/source/libs/cairo/cairo-src/src/cairo-scaled-font.c index 53a370d3acc..8dff57d9533 100644 --- a/Build/source/libs/cairo/cairo-src/src/cairo-scaled-font.c +++ b/Build/source/libs/cairo/cairo-src/src/cairo-scaled-font.c @@ -46,12 +46,6 @@ #include "cairo-scaled-font-private.h" #include "cairo-surface-backend-private.h" -#if _XOPEN_SOURCE >= 600 || defined (_ISOC99_SOURCE) -#define ISFINITE(x) isfinite (x) -#else -#define ISFINITE(x) ((x) * (x) >= 0.) /* check for NaNs */ -#endif - /** * SECTION:cairo-scaled-font * @Title: cairo_scaled_font_t @@ -85,7 +79,7 @@ static cairo_cache_t cairo_scaled_glyph_page_cache; #define CAIRO_SCALED_GLYPH_PAGE_SIZE 32 struct _cairo_scaled_glyph_page { cairo_cache_entry_t cache_entry; - + cairo_scaled_font_t *scaled_font; cairo_list_t link; unsigned int num_glyphs; @@ -224,6 +218,9 @@ _cairo_scaled_glyph_fini (cairo_scaled_font_t *scaled_font, cairo_surface_finish (scaled_glyph->recording_surface); cairo_surface_destroy (scaled_glyph->recording_surface); } + + if (scaled_glyph->color_surface != NULL) + cairo_surface_destroy (&scaled_glyph->color_surface->base); } #define ZOMBIE 0 @@ -371,7 +368,7 @@ _cairo_scaled_font_map_lock (void) CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex); if (cairo_scaled_font_map == NULL) { - cairo_scaled_font_map = malloc (sizeof (cairo_scaled_font_map_t)); + cairo_scaled_font_map = _cairo_malloc (sizeof (cairo_scaled_font_map_t)); if (unlikely (cairo_scaled_font_map == NULL)) goto CLEANUP_MUTEX_LOCK; @@ -477,7 +474,7 @@ _cairo_scaled_glyph_page_pluck (void *closure) assert (! cairo_list_is_empty (&page->link)); - scaled_font = (cairo_scaled_font_t *) page->cache_entry.hash; + scaled_font = page->scaled_font; CAIRO_MUTEX_LOCK (scaled_font->mutex); _cairo_scaled_glyph_page_destroy (scaled_font, page); @@ -512,7 +509,7 @@ _cairo_scaled_font_register_placeholder_and_unlock_font_map (cairo_scaled_font_t if (unlikely (status)) return status; - placeholder_scaled_font = malloc (sizeof (cairo_scaled_font_t)); + placeholder_scaled_font = _cairo_malloc (sizeof (cairo_scaled_font_t)); if (unlikely (placeholder_scaled_font == NULL)) return _cairo_error (CAIRO_STATUS_NO_MEMORY); @@ -1229,7 +1226,7 @@ _cairo_scaled_font_create_in_error (cairo_status_t status) CAIRO_MUTEX_LOCK (_cairo_scaled_font_error_mutex); scaled_font = _cairo_scaled_font_nil_objects[status]; if (unlikely (scaled_font == NULL)) { - scaled_font = malloc (sizeof (cairo_scaled_font_t)); + scaled_font = _cairo_malloc (sizeof (cairo_scaled_font_t)); if (unlikely (scaled_font == NULL)) { CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_error_mutex); _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); @@ -1277,8 +1274,8 @@ _cairo_scaled_font_reset_static_data (void) * @scaled_font from being destroyed until a matching call to * cairo_scaled_font_destroy() is made. * - * The number of references to a #cairo_scaled_font_t can be get using - * cairo_scaled_font_get_reference_count(). + * Use cairo_scaled_font_get_reference_count() to get the number of + * references to a #cairo_scaled_font_t. * * Returns: the referenced #cairo_scaled_font_t * @@ -2055,7 +2052,7 @@ cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, status = _cairo_error (CAIRO_STATUS_NEGATIVE_COUNT); goto DONE; } - if (num_glyphs && *glyphs == NULL) { + if (*num_glyphs != 0 && *glyphs == NULL) { status = _cairo_error (CAIRO_STATUS_NULL_POINTER); goto DONE; } @@ -2065,7 +2062,7 @@ cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, status = _cairo_error (CAIRO_STATUS_NEGATIVE_COUNT); goto DONE; } - if (num_clusters && *clusters == NULL) { + if (*num_clusters != 0 && *clusters == NULL) { status = _cairo_error (CAIRO_STATUS_NULL_POINTER); goto DONE; } @@ -2830,13 +2827,31 @@ _cairo_scaled_glyph_set_recording_surface (cairo_scaled_glyph_t *scaled_glyph, scaled_glyph->has_info &= ~CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE; } +void +_cairo_scaled_glyph_set_color_surface (cairo_scaled_glyph_t *scaled_glyph, + cairo_scaled_font_t *scaled_font, + cairo_image_surface_t *surface) +{ + if (scaled_glyph->color_surface != NULL) + cairo_surface_destroy (&scaled_glyph->color_surface->base); + + /* sanity check the backend glyph contents */ + _cairo_debug_check_image_surface_is_defined (&surface->base); + scaled_glyph->color_surface = surface; + + if (surface != NULL) + scaled_glyph->has_info |= CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE; + else + scaled_glyph->has_info &= ~CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE; +} + static cairo_bool_t _cairo_scaled_glyph_page_can_remove (const void *closure) { const cairo_scaled_glyph_page_t *page = closure; const cairo_scaled_font_t *scaled_font; - scaled_font = (cairo_scaled_font_t *) page->cache_entry.hash; + scaled_font = page->scaled_font; return scaled_font->cache_frozen == 0; } @@ -2860,11 +2875,12 @@ _cairo_scaled_font_allocate_glyph (cairo_scaled_font_t *scaled_font, } } - page = malloc (sizeof (cairo_scaled_glyph_page_t)); + page = _cairo_malloc (sizeof (cairo_scaled_glyph_page_t)); if (unlikely (page == NULL)) return _cairo_error (CAIRO_STATUS_NO_MEMORY); page->cache_entry.hash = (unsigned long) scaled_font; + page->scaled_font = scaled_font; page->cache_entry.size = 1; /* XXX occupancy weighting? */ page->num_glyphs = 0; @@ -3175,3 +3191,12 @@ cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font, _cairo_font_options_init_copy (options, &scaled_font->options); } slim_hidden_def (cairo_scaled_font_get_font_options); + +cairo_bool_t +_cairo_scaled_font_has_color_glyphs (cairo_scaled_font_t *scaled_font) +{ + if (scaled_font->backend != NULL && scaled_font->backend->has_color_glyphs != NULL) + return scaled_font->backend->has_color_glyphs (scaled_font); + else + return FALSE; +} |