summaryrefslogtreecommitdiff
path: root/gsk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-07-31 11:41:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-07-31 16:34:24 -0400
commit7e8f58685912e143abb6368f6c513a9e75b5e5c9 (patch)
treee9fccfb1da3e5ea79745e6de87806e3561540e81 /gsk
parentbb9dccd7735f3bcbccc53e5f75ac21f26bc11649 (diff)
downloadgtk+-7e8f58685912e143abb6368f6c513a9e75b5e5c9.tar.gz
ngl: Use per-glyph color information
Decide per-glyph whether we need color nor not. Fixes: #4141
Diffstat (limited to 'gsk')
-rw-r--r--gsk/ngl/gsknglrenderjob.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 87c407cd9b..532157d1be 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -2835,6 +2835,9 @@ 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,
@@ -2855,7 +2858,9 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
guint last_texture = 0;
GskNglDrawVertex *vertices;
guint used = 0;
- guint16 c[4] = { FP16_MINUS_ONE, FP16_MINUS_ONE, FP16_MINUS_ONE, FP16_MINUS_ONE };
+ guint16 nc[4] = { FP16_MINUS_ONE, FP16_MINUS_ONE, FP16_MINUS_ONE, FP16_MINUS_ONE };
+ guint16 cc[4];
+ const guint16 *c;
const PangoGlyphInfo *gi;
guint i;
int yshift;
@@ -2864,16 +2869,11 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
if (num_glyphs == 0)
return;
- /* If the font has color glyphs, we don't need to recolor anything.
- * We tell the shader by setting the color to vec4(-1).
- */
- if (force_color || !gsk_text_node_has_color_glyphs (node))
- {
- if (RGBA_IS_CLEAR (color))
- return;
+ if ((force_color || !gsk_text_node_has_color_glyphs (node)) &&
+ RGBA_IS_CLEAR (color))
+ return;
- rgba_to_half (color, c);
- }
+ rgba_to_half (color, cc);
lookup.font = (PangoFont *)font;
lookup.scale = (guint) (text_scale * 1024);
@@ -2897,6 +2897,14 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
lookup.glyph = gi->glyph;
+ /* 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))
+ c = nc;
+ else
+ c = cc;
+
cx = (float)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
lookup.xshift = compute_phase_and_pos (x + cx, &cx);