[gtk/wip/chergert/glproto: 445/493] Revert "add text glyph vertices in one batch"




commit 70d00c2983b1e1bb0a70f0774fa0e7ef4b084a79
Author: Christian Hergert <chergert redhat com>
Date:   Wed Feb 10 19:30:23 2021 -0800

    Revert "add text glyph vertices in one batch"
    
    This reverts commit 8e6b6b51b788a4e719190852d149c39fc1ea4a72.
    
    We can't do this because we might change textures for some glyphs
    and that would mean we break batching.

 gsk/next/gskglrenderjob.c | 62 +++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 35 deletions(-)
---
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index b7f6407169..69ed41ac3e 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -2544,8 +2544,6 @@ 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;
@@ -2566,11 +2564,10 @@ 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;
@@ -2578,7 +2575,6 @@ 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;
@@ -2591,9 +2587,6 @@ 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);
@@ -2620,43 +2613,42 @@ 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[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 = gsk_gl_command_queue_add_vertices (job->command_queue);
 
-      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[0].position[0] = glyph_x;
+      vertices[0].position[1] = glyph_y;
+      vertices[0].uv[0] = tx;
+      vertices[0].uv[1] = ty;
 
-      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[1].position[0] = glyph_x;
+      vertices[1].position[1] = glyph_y2;
+      vertices[1].uv[0] = tx;
+      vertices[1].uv[1] = ty2;
 
-      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[2].position[0] = glyph_x2;
+      vertices[2].position[1] = glyph_y;
+      vertices[2].uv[0] = tx2;
+      vertices[2].uv[1] = ty;
 
-      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[3].position[0] = glyph_x2;
+      vertices[3].position[1] = glyph_y2;
+      vertices[3].uv[0] = tx2;
+      vertices[3].uv[1] = ty2;
 
-      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;
+      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;
 
 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]