summaryrefslogtreecommitdiff
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
parent0fadb2c56d855560810205d78975450ddce271df (diff)
downloadcairo-0d8859c66fb82a00147ab77d1971111306ca2272.tar.gz
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.
-rw-r--r--src/cairo-scaled-font-private.h1
-rw-r--r--src/cairo-scaled-font.c21
-rw-r--r--src/cairoint.h8
3 files changed, 29 insertions, 1 deletions
diff --git a/src/cairo-scaled-font-private.h b/src/cairo-scaled-font-private.h
index da7b34698..6ce6bb6dd 100644
--- a/src/cairo-scaled-font-private.h
+++ b/src/cairo-scaled-font-private.h
@@ -141,6 +141,7 @@ struct _cairo_scaled_glyph {
cairo_image_surface_t *surface; /* device-space image */
cairo_path_fixed_t *path; /* device-space outline */
cairo_surface_t *recording_surface; /* device-space recording-surface */
+ cairo_image_surface_t *color_surface; /* device-space color image */
const void *dev_private_key;
void *dev_private;
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)
{
diff --git a/src/cairoint.h b/src/cairoint.h
index 4fedf861d..a04a92e94 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -477,7 +477,8 @@ typedef enum _cairo_scaled_glyph_info {
CAIRO_SCALED_GLYPH_INFO_METRICS = (1 << 0),
CAIRO_SCALED_GLYPH_INFO_SURFACE = (1 << 1),
CAIRO_SCALED_GLYPH_INFO_PATH = (1 << 2),
- CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE = (1 << 3)
+ CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE = (1 << 3),
+ CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE = (1 << 4)
} cairo_scaled_glyph_info_t;
typedef struct _cairo_scaled_font_subset {
@@ -1255,6 +1256,11 @@ _cairo_scaled_glyph_set_recording_surface (cairo_scaled_glyph_t *scaled_glyph,
cairo_scaled_font_t *scaled_font,
cairo_surface_t *recording_surface);
+cairo_private void
+_cairo_scaled_glyph_set_color_surface (cairo_scaled_glyph_t *scaled_glyph,
+ cairo_scaled_font_t *scaled_font,
+ cairo_image_surface_t *surface);
+
cairo_private cairo_int_status_t
_cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font,
unsigned long index,