[gtk/wip/chergert/glyphy: 20/20] gsk/gl: load glyph from glyphy texture library




commit 3712ec91c0b38b7b70be394fc43fbbbc4a7579dc
Author: Christian Hergert <chergert redhat com>
Date:   Tue Mar 15 16:04:51 2022 -0700

    gsk/gl: load glyph from glyphy texture library
    
    This commit is not yet comprehensive but gets some plumbing in place to
    lookup a glyph from the glyphy texture library. Much more is needed to
    use the shaders to actually render these.

 gsk/gl/gskglrenderjob.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
---
diff --git a/gsk/gl/gskglrenderjob.c b/gsk/gl/gskglrenderjob.c
index d02424f117..720592c6fb 100644
--- a/gsk/gl/gskglrenderjob.c
+++ b/gsk/gl/gskglrenderjob.c
@@ -3129,6 +3129,61 @@ gsk_gl_render_job_visit_text_node_glyphy (GskGLRenderJob      *job,
                                           const GdkRGBA       *color,
                                           gboolean             force_color)
 {
+  const graphene_point_t *offset;
+  const PangoGlyphInfo *glyphs;
+  const PangoGlyphInfo *gi;
+  GskGLGlyphyLibrary *library;
+  GskGLCommandBatch *batch;
+  const PangoFont *font;
+  GskGLDrawVertex *vertices;
+  GskGLGlyphyKey lookup;
+  float x;
+  float y;
+  guint last_texture = 0;
+  guint num_glyphs;
+  guint used = 0;
+  guint i;
+
+  g_assert (!gsk_text_node_has_color_glyphs (node));
+
+  if (!(num_glyphs = gsk_text_node_get_num_glyphs (node)))
+    return;
+
+  font = gsk_text_node_get_font (node);
+  glyphs = gsk_text_node_get_glyphs (node, NULL);
+  library = job->driver->glyphy;
+  offset = gsk_text_node_get_offset (node);
+  x = offset->x + job->offset_x;
+  y = offset->y + job->offset_y;
+
+  gsk_gl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
+
+  batch = gsk_gl_command_queue_get_batch (job->command_queue);
+  vertices = gsk_gl_command_queue_add_n_vertices (job->command_queue, num_glyphs);
+
+  lookup.font = (PangoFont *)font;
+
+  for (i = 0, gi = glyphs; i < num_glyphs; i++, gi++)
+    {
+      const GskGLGlyphyValue *glyph;
+      float glyph_x, glyph_y, glyph_x2, glyph_y2;
+      float tx, ty, tx2, ty2;
+      float cx;
+      float cy;
+      guint texture_id;
+
+      lookup.glyph = gi->glyph;
+
+      texture_id = gsk_gl_glyphy_library_lookup_or_add (library, &lookup, &glyph);
+      if G_UNLIKELY (texture_id == 0)
+        continue;
+
+    }
+
+  if (used != num_glyphs)
+    gsk_gl_command_queue_retract_n_vertices (job->command_queue, num_glyphs - used);
+
+  gsk_gl_render_job_end_draw (job);
 }
 
 static inline void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]