summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-09-01 01:38:44 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-09-01 01:47:06 -0400
commitb244f31337eeab5eb7d9f4556b86aeadc970f801 (patch)
treee7dd2b787f23ebe8798144262511923e276b6154
parent8550a04bf42f5e1d8af239ab953c3ff1235dc149 (diff)
downloadgtk+-b244f31337eeab5eb7d9f4556b86aeadc970f801.tar.gz
Use color glyph information from Pangocolor-glyph-info
Pango now sets a bit in PangoGlyphVisAttr for color glyphs, so we don't need to do that ourselves anymore.
-rw-r--r--gsk/gskrendernodeimpl.c51
-rw-r--r--gsk/ngl/gsknglrenderjob.c5
2 files changed, 3 insertions, 53 deletions
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 0c665a6e52..30ef0ff38b 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -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++;
}
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index ef4d075997..4b04310e66 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -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;