gpu: Reduce per-glyph overhead

Pull the shader clip computation out of the loop in the common
case that the entire node is contained in the clip.
This commit is contained in:
Matthias Clasen 2024-09-08 12:57:31 -04:00
parent c18cd6050b
commit 76a13596aa

View File

@ -3013,6 +3013,7 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
GdkColorState *alt;
GskGpuColorStates color_states;
GdkColor color2;
GskGpuShaderClip node_clip;
if (self->opacity < 1.0 &&
gsk_text_node_has_color_glyphs (node))
@ -3034,6 +3035,8 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
color_states = gsk_gpu_color_states_create (self->ccs, TRUE, alt, FALSE);
gdk_color_convert (&color2, alt, color);
node_clip = gsk_gpu_clip_get_shader_clip (&self->clip, &self->offset, &node->bounds),
offset.x += self->offset.x;
offset.y += self->offset.y;
@ -3060,6 +3063,7 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
graphene_rect_t glyph_bounds, glyph_tex_rect;
graphene_point_t glyph_offset, glyph_origin;
GskGpuGlyphLookupFlags flags;
GskGpuShaderClip glyph_clip;
glyph_origin = GRAPHENE_POINT_INIT (offset.x + glyphs[i].geometry.x_offset * inv_pango_scale,
offset.y + glyphs[i].geometry.y_offset * inv_pango_scale);
@ -3090,9 +3094,14 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
glyph_origin = GRAPHENE_POINT_INIT (glyph_origin.x - glyph_offset.x / scale,
glyph_origin.y - glyph_offset.y / scale);
if (node_clip == GSK_GPU_SHADER_CLIP_NONE)
glyph_clip = GSK_GPU_SHADER_CLIP_NONE;
else
glyph_clip = gsk_gpu_clip_get_shader_clip (&self->clip, &glyph_origin, &glyph_bounds);
if (glyphs[i].attr.is_color)
gsk_gpu_texture_op (self->frame,
gsk_gpu_clip_get_shader_clip (&self->clip, &glyph_origin, &glyph_bounds),
glyph_clip,
&glyph_origin,
&(GskGpuShaderImage) {
image,
@ -3102,7 +3111,7 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
});
else
gsk_gpu_colorize_op2 (self->frame,
gsk_gpu_clip_get_shader_clip (&self->clip, &glyph_origin, &glyph_bounds),
glyph_clip,
color_states,
self->opacity,
&glyph_origin,