[cairo] [PATCH 6/6] Support color glyphs in the xlib compositor

matthias.clasen at gmail.com matthias.clasen at gmail.com
Sat Apr 9 03:22:33 UTC 2016


From: Matthias Clasen <mclasen at redhat.com>

Since RENDER extension does not have support for using glyphs as
source, we bail out of the XRender-based implementation of
composite_glyphs when we find any color glyphs. The fallback
leads us to the mask compositor, whose glyphs() implementation
always uses an A8 maks for glyphs, so we have to bypass this
as well.

Since we don't have access to the glyphs loaded by the previous
compositor, we use the has_color_glyphs information of the font
to determine whether we can use the mask compositor.
---
 src/cairo-xlib-render-compositor.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/cairo-xlib-render-compositor.c b/src/cairo-xlib-render-compositor.c
index 861ebe6..73f1423 100644
--- a/src/cairo-xlib-render-compositor.c
+++ b/src/cairo-xlib-render-compositor.c
@@ -1216,6 +1216,11 @@ _cairo_xlib_surface_add_glyph (cairo_xlib_display_t *display,
 	already_had_glyph_surface = TRUE;
     }
 
+    if ((glyph->has_info && CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE) != 0) {
+        status = CAIRO_INT_STATUS_UNSUPPORTED;
+        goto BAIL;
+    }
+
     info = _cairo_xlib_font_get_glyphset_info_for_format (display, font,
 							  glyph_surface->format);
 
@@ -1722,6 +1727,28 @@ composite_glyphs (void				*surface,
     return status;
 }
 
+static cairo_int_status_t (*base_glyphs) (const cairo_compositor_t        *compositor,
+                                          cairo_composite_rectangles_t   *extents,
+                                          cairo_scaled_font_t            *scaled_font,
+                                          cairo_glyph_t                  *glyphs,
+                                          int                             num_glyphs,
+                                          cairo_bool_t                    overlap);
+
+static cairo_int_status_t
+glyphs (const cairo_compositor_t        *compositor,
+        cairo_composite_rectangles_t   *extents,
+        cairo_scaled_font_t            *scaled_font,
+        cairo_glyph_t                  *glyphs,
+        int                             num_glyphs,
+        cairo_bool_t                    overlap)
+{
+    if (_cairo_scaled_font_has_color_glyphs (scaled_font))
+        return CAIRO_INT_STATUS_UNSUPPORTED;
+
+    return base_glyphs (compositor, extents, scaled_font, glyphs, num_glyphs, overlap);
+}
+
+
 const cairo_compositor_t *
 _cairo_xlib_mask_compositor_get (void)
 {
@@ -1745,6 +1772,8 @@ _cairo_xlib_mask_compositor_get (void)
 	compositor.composite_boxes = composite_boxes;
 	compositor.check_composite_glyphs = check_composite_glyphs;
 	compositor.composite_glyphs = composite_glyphs;
+        base_glyphs = compositor.base.glyphs;
+        compositor.base.glyphs = glyphs;
     }
 
     return &compositor.base;
-- 
2.7.3



More information about the cairo mailing list