[gtk/ngl-coloring-underlines: 4/4] ngl: Optimize underlines in text
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ngl-coloring-underlines: 4/4] ngl: Optimize underlines in text
- Date: Fri, 9 Apr 2021 03:15:24 +0000 (UTC)
commit b9748287326f37218a6f4fa0e9ca2f91ae3e7d8c
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Apr 8 23:11:06 2021 -0400
ngl: Optimize underlines in text
Opportunistically use the coloring program for
drawing underlines instead of the color program.
This avoids program changes in the middle of
text.
For the Emoji text scrolling benchmark, this reduces
the program changes per frame from > 1000 to around 100.
gsk/ngl/gsknglrenderjob.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
---
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 3e823dedab..e12260a2de 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -1349,15 +1349,45 @@ blur_node (GskNglRenderJob *job,
*max_y = job->offset_y + node->bounds.origin.y + node->bounds.size.height + half_blur_extra;
}
+#define ATLAS_SIZE 512
+
static inline void
gsk_ngl_render_job_visit_color_node (GskNglRenderJob *job,
const GskRenderNode *node)
{
- gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
- gsk_ngl_render_job_draw_rect_with_color (job,
- &node->bounds,
- gsk_color_node_get_color (node));
- gsk_ngl_render_job_end_draw (job);
+ GskNglCommandBatch *batch;
+ GskNglProgram *program = CHOOSE_PROGRAM (job, coloring);
+
+ batch = gsk_ngl_command_queue_get_batch (job->command_queue);
+
+ if (batch->any.kind == GSK_NGL_COMMAND_KIND_DRAW &&
+ batch->any.program == program->id)
+ {
+ GskNglRenderOffscreen offscreen = {0};
+
+ gsk_ngl_render_job_begin_draw (job, program);
+
+ offscreen.was_offscreen = FALSE;
+ offscreen.area.x = 1.f / ATLAS_SIZE;
+ offscreen.area.y = 1.f / ATLAS_SIZE;
+ offscreen.area.x2 = 2.f / ATLAS_SIZE;
+ offscreen.area.y2 = 2.f / ATLAS_SIZE;
+
+ gsk_ngl_render_job_draw_offscreen_with_color (job,
+ &node->bounds,
+ &offscreen,
+ gsk_color_node_get_color (node));
+
+ gsk_ngl_render_job_end_draw (job);
+ }
+ else
+ {
+ gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
+ gsk_ngl_render_job_draw_rect_with_color (job,
+ &node->bounds,
+ gsk_color_node_get_color (node));
+ gsk_ngl_render_job_end_draw (job);
+ }
}
static inline void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]