Use color glyph information from Pango

Pango now sets a bit in PangoGlyphVisAttr for
color glyphs, so we don't need to do that
ourselves anymore.
This commit is contained in:
Matthias Clasen 2021-09-01 01:38:44 -04:00
parent 8550a04bf4
commit b244f31337
2 changed files with 3 additions and 53 deletions

View File

@ -4424,46 +4424,6 @@ gsk_text_node_diff (GskRenderNode *node1,
gsk_render_node_diff_impossible (node1, node2, region);
}
static gboolean
font_has_color_glyphs (PangoFont *font)
{
hb_face_t *face = hb_font_get_face (pango_font_get_hb_font (font));
return hb_ot_color_has_layers (face) ||
hb_ot_color_has_png (face) ||
hb_ot_color_has_svg (face);
}
static gboolean
glyph_has_color (PangoFont *font,
guint glyph)
{
hb_font_t *hb_font = pango_font_get_hb_font (font);
hb_face_t *face = hb_font_get_face (hb_font);
hb_blob_t *blob;
if (hb_ot_color_glyph_get_layers (face, glyph, 0, NULL, NULL) > 0)
return TRUE;
blob = hb_ot_color_glyph_reference_png (hb_font, glyph);
if (blob)
{
guint length = hb_blob_get_length (blob);
hb_blob_destroy (blob);
return length > 0;
}
blob = hb_ot_color_glyph_reference_svg (face, glyph);
if (blob)
{
guint length = hb_blob_get_length (blob);
hb_blob_destroy (blob);
return length > 0;
}
return FALSE;
}
/**
* gsk_text_node_new:
* @font: the `PangoFont` containing the glyphs
@ -4488,7 +4448,6 @@ gsk_text_node_new (PangoFont *font,
GskRenderNode *node;
PangoRectangle ink_rect;
PangoGlyphInfo *glyph_infos;
gboolean has_color_glyphs;
int n;
pango_glyph_string_extents (glyphs, font, &ink_rect, NULL);
@ -4507,7 +4466,6 @@ gsk_text_node_new (PangoFont *font,
self->has_color_glyphs = FALSE;
glyph_infos = g_malloc_n (glyphs->num_glyphs, sizeof (PangoGlyphInfo));
has_color_glyphs = font_has_color_glyphs (font);
n = 0;
for (int i = 0; i < glyphs->num_glyphs; i++)
@ -4517,14 +4475,9 @@ gsk_text_node_new (PangoFont *font,
continue;
glyph_infos[n] = glyphs->glyphs[i];
GLYPH_CLEAR_COLOR (&glyph_infos[n]);
if (has_color_glyphs &&
glyph_has_color (font, glyph_infos[n].glyph))
{
self->has_color_glyphs = TRUE;
GLYPH_SET_COLOR (&glyph_infos[n]);
}
if (glyphs->glyphs[i].attr.is_color)
self->has_color_glyphs = TRUE;
n++;
}

View File

@ -2838,9 +2838,6 @@ compute_phase_and_pos (float value, float *pos)
}
}
#define COLOR_GLYPH_BIT 2
#define GLYPH_IS_COLOR(g) (((*(guint32*)&(g)->attr) & COLOR_GLYPH_BIT) != 0)
static inline void
gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
const GskRenderNode *node,
@ -2903,7 +2900,7 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
/* If the glyph has color, we don't need to recolor anything.
* We tell the shader by setting the color to vec4(-1).
*/
if (!force_color && GLYPH_IS_COLOR (gi))
if (!force_color && gi->attr.is_color)
c = nc;
else
c = cc;