[gtk/wip/chergert/glproto: 505/526] add text glyph vertices in one batch
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto: 505/526] add text glyph vertices in one batch
- Date: Tue, 16 Feb 2021 01:14:39 +0000 (UTC)
commit 545ff590a4619ca79cff3d2a7cd54dd6f13296de
Author: Christian Hergert <chergert redhat com>
Date: Wed Feb 10 17:38:11 2021 -0800
add text glyph vertices in one batch
avoid repeated checks to grow/resize the buffer
gsk/next/gskglrenderjob.c | 62 ++++++++++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 27 deletions(-)
---
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index 69ed41ac3e..b7f6407169 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -2544,6 +2544,8 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
int x_position = 0;
GskGLGlyphKey lookup;
guint last_texture = 0;
+ GskGLDrawVertex *vertices;
+ guint used = 0;
if (num_glyphs == 0)
return;
@@ -2564,10 +2566,11 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
gsk_gl_render_job_begin_draw (job, program);
+ vertices = gsk_gl_command_queue_add_n_vertices (job->command_queue, num_glyphs);
+
/* We use one quad per character */
for (guint i = 0; i < num_glyphs; i++)
{
- GskGLDrawVertex *vertices;
const PangoGlyphInfo *gi = &glyphs[i];
const GskGLGlyphValue *glyph;
float glyph_x, glyph_y, glyph_x2, glyph_y2;
@@ -2575,6 +2578,7 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
float cx;
float cy;
guint texture_id;
+ guint base;
if (gi->glyph == PANGO_GLYPH_EMPTY)
continue;
@@ -2587,6 +2591,9 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
if (!gsk_gl_glyph_library_lookup_or_add (library, &lookup, &glyph))
goto next;
+ base = used * GSK_GL_N_VERTICES;
+ used++;
+
texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (glyph);
g_assert (texture_id > 0);
@@ -2613,42 +2620,43 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
glyph_x2 = glyph_x + glyph->ink_rect.width;
glyph_y2 = glyph_y + glyph->ink_rect.height;
- vertices = gsk_gl_command_queue_add_vertices (job->command_queue);
+ vertices[base+0].position[0] = glyph_x;
+ vertices[base+0].position[1] = glyph_y;
+ vertices[base+0].uv[0] = tx;
+ vertices[base+0].uv[1] = ty;
- vertices[0].position[0] = glyph_x;
- vertices[0].position[1] = glyph_y;
- vertices[0].uv[0] = tx;
- vertices[0].uv[1] = ty;
+ vertices[base+1].position[0] = glyph_x;
+ vertices[base+1].position[1] = glyph_y2;
+ vertices[base+1].uv[0] = tx;
+ vertices[base+1].uv[1] = ty2;
- vertices[1].position[0] = glyph_x;
- vertices[1].position[1] = glyph_y2;
- vertices[1].uv[0] = tx;
- vertices[1].uv[1] = ty2;
+ vertices[base+2].position[0] = glyph_x2;
+ vertices[base+2].position[1] = glyph_y;
+ vertices[base+2].uv[0] = tx2;
+ vertices[base+2].uv[1] = ty;
- vertices[2].position[0] = glyph_x2;
- vertices[2].position[1] = glyph_y;
- vertices[2].uv[0] = tx2;
- vertices[2].uv[1] = ty;
+ vertices[base+3].position[0] = glyph_x2;
+ vertices[base+3].position[1] = glyph_y2;
+ vertices[base+3].uv[0] = tx2;
+ vertices[base+3].uv[1] = ty2;
- vertices[3].position[0] = glyph_x2;
- vertices[3].position[1] = glyph_y2;
- vertices[3].uv[0] = tx2;
- vertices[3].uv[1] = ty2;
+ vertices[base+4].position[0] = glyph_x;
+ vertices[base+4].position[1] = glyph_y2;
+ vertices[base+4].uv[0] = tx;
+ vertices[base+4].uv[1] = ty2;
- vertices[4].position[0] = glyph_x;
- vertices[4].position[1] = glyph_y2;
- vertices[4].uv[0] = tx;
- vertices[4].uv[1] = ty2;
-
- vertices[5].position[0] = glyph_x2;
- vertices[5].position[1] = glyph_y;
- vertices[5].uv[0] = tx2;
- vertices[5].uv[1] = ty;
+ vertices[base+5].position[0] = glyph_x2;
+ vertices[base+5].position[1] = glyph_y;
+ vertices[base+5].uv[0] = tx2;
+ vertices[base+5].uv[1] = ty;
next:
x_position += gi->geometry.width;
}
+ if (used != num_glyphs)
+ gsk_gl_command_queue_retract_n_vertices (job->command_queue, num_glyphs - used);
+
gsk_gl_program_end_draw (program);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]