summaryrefslogtreecommitdiff
path: root/src/cairo-scaled-font.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-04-07 20:38:09 -0400
committerBehdad Esfahbod <behdad@behdad.org>2017-07-29 12:30:50 +0100
commit0d8859c66fb82a00147ab77d1971111306ca2272 (patch)
tree7a01ece928a78c0376fc6837926ae7f2344d75b9 /src/cairo-scaled-font.c
parent0fadb2c56d855560810205d78975450ddce271df (diff)
Add support for color glyphs to cairo_scaled_glyph_t
With this, glyphs can have either a surface that is expected to be used as mask, or a color_surface that should be used as source, or both. This will be used to support colored emoji glyphs that are stored as PNG images in OpenType fonts.
Diffstat (limited to 'src/cairo-scaled-font.c')
-rw-r--r--src/cairo-scaled-font.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index dff305389..665395b57 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -224,6 +224,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
@@ -2830,6 +2833,24 @@ _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)
{