[gtk+] gsk: Fix hexbox drawing for the Vulkan renderer



commit 550f4bc854d81e601d11d8d6d294d3dc65ab4521
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 5 20:30:14 2018 -0500

    gsk: Fix hexbox drawing for the Vulkan renderer
    
    Just as in the cairo renderer, we can get this back
    by using pango_cairo_show_glyph_string for populating
    the cache.

 gsk/gskvulkancolortextpipeline.c |   28 ++++++++++++----------------
 gsk/gskvulkanglyphcache.c        |   25 +++++++++++++------------
 gsk/gskvulkanrenderpass.c        |   29 +++++++++++++----------------
 gsk/gskvulkantextpipeline.c      |   36 ++++++++++++++++--------------------
 4 files changed, 54 insertions(+), 64 deletions(-)
---
diff --git a/gsk/gskvulkancolortextpipeline.c b/gsk/gskvulkancolortextpipeline.c
index dd236da..9770b27 100644
--- a/gsk/gskvulkancolortextpipeline.c
+++ b/gsk/gskvulkancolortextpipeline.c
@@ -122,26 +122,22 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
         {
           double cx = (double)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
           double cy = (double)(gi->geometry.y_offset) / PANGO_SCALE;
+          GskVulkanColorTextInstance *instance = &instances[count];
+          GskVulkanCachedGlyph *glyph;
 
-          if (!(gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG))
-            {
-              GskVulkanColorTextInstance *instance = &instances[count];
-              GskVulkanCachedGlyph *glyph;
+          glyph = gsk_vulkan_renderer_get_cached_glyph (renderer, font, gi->glyph, scale);
 
-              glyph = gsk_vulkan_renderer_get_cached_glyph (renderer, font, gi->glyph, scale);
+          instance->tex_rect[0] = glyph->tx;
+          instance->tex_rect[1] = glyph->ty;
+          instance->tex_rect[2] = glyph->tw;
+          instance->tex_rect[3] = glyph->th;
 
-              instance->tex_rect[0] = glyph->tx;
-              instance->tex_rect[1] = glyph->ty;
-              instance->tex_rect[2] = glyph->tw;
-              instance->tex_rect[3] = glyph->th;
+          instance->rect[0] = x + cx + glyph->draw_x;
+          instance->rect[1] = y + cy + glyph->draw_y;
+          instance->rect[2] = glyph->draw_width;
+          instance->rect[3] = glyph->draw_height;
 
-              instance->rect[0] = x + cx + glyph->draw_x;
-              instance->rect[1] = y + cy + glyph->draw_y;
-              instance->rect[2] = glyph->draw_width;
-              instance->rect[3] = glyph->draw_height;
-
-              count++;
-           }
+          count++;
        }
      x_position += gi->geometry.width;
    }
diff --git a/gsk/gskvulkanglyphcache.c b/gsk/gskvulkanglyphcache.c
index a17717f..8d12f5c 100644
--- a/gsk/gskvulkanglyphcache.c
+++ b/gsk/gskvulkanglyphcache.c
@@ -251,8 +251,8 @@ render_glyph (Atlas          *atlas,
   GskVulkanCachedGlyph *value = glyph->value;
   cairo_surface_t *surface;
   cairo_t *cr;
-  cairo_scaled_font_t *scaled_font;
-  cairo_glyph_t cg;
+  PangoGlyphString glyphs;
+  PangoGlyphInfo gi;
 
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                         value->draw_width * key->scale / 1024,
@@ -260,19 +260,20 @@ render_glyph (Atlas          *atlas,
   cairo_surface_set_device_scale (surface, key->scale / 1024.0, key->scale / 1024.0);
 
   cr = cairo_create (surface);
-
-  scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *)key->font);
-  if (G_UNLIKELY (!scaled_font || cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS))
-    return;
-
-  cairo_set_scaled_font (cr, scaled_font);
   cairo_set_source_rgba (cr, 1, 1, 1, 1);
 
-  cg.index = key->glyph;
-  cg.x = - value->draw_x;
-  cg.y = - value->draw_y;
+  gi.glyph = key->glyph;
+  gi.geometry.width = value->draw_width * 1024;
+  if (key->glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+    gi.geometry.x_offset = 0;
+  else
+    gi.geometry.x_offset = - value->draw_x * 1024;
+  gi.geometry.y_offset = - value->draw_y * 1024;
+
+  glyphs.num_glyphs = 1;
+  glyphs.glyphs = &gi;
 
-  cairo_show_glyphs (cr, &cg, 1);
+  pango_cairo_show_glyph_string (cr, key->font, &glyphs);
 
   cairo_destroy (cr);
 
diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c
index d902a90..83fff2d 100644
--- a/gsk/gskvulkanrenderpass.c
+++ b/gsk/gskvulkanrenderpass.c
@@ -413,24 +413,21 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass           *self,
           {
             const PangoGlyphInfo *gi = &glyphs[i];
 
-            if (gi->glyph != PANGO_GLYPH_EMPTY && !(gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG))
+            texture_index = gsk_vulkan_renderer_cache_glyph (renderer, (PangoFont *)font, gi->glyph, 
op.text.scale);
+            if (op.text.texture_index == G_MAXUINT)
+              op.text.texture_index = texture_index;
+            if (texture_index != op.text.texture_index)
               {
-                texture_index = gsk_vulkan_renderer_cache_glyph (renderer, (PangoFont *)font, gi->glyph, 
op.text.scale);
-                if (op.text.texture_index == G_MAXUINT)
-                  op.text.texture_index = texture_index;
-                if (texture_index != op.text.texture_index)
-                  {
-                     op.text.num_glyphs = count;
-
-                     g_array_append_val (self->render_ops, op);
-
-                     count = 1;
-                     op.text.start_glyph = i;
-                     op.text.texture_index = texture_index;
-                  }
-                else
-                  count++;
+                op.text.num_glyphs = count;
+
+                g_array_append_val (self->render_ops, op);
+
+                count = 1;
+                op.text.start_glyph = i;
+                op.text.texture_index = texture_index;
               }
+            else
+              count++;
           }
 
         if (op.text.texture_index != G_MAXUINT && count != 0)
diff --git a/gsk/gskvulkantextpipeline.c b/gsk/gskvulkantextpipeline.c
index 5ca2d7e..361c536 100644
--- a/gsk/gskvulkantextpipeline.c
+++ b/gsk/gskvulkantextpipeline.c
@@ -130,31 +130,27 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline  *pipeline,
         {
           double cx = (double)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
           double cy = (double)(gi->geometry.y_offset) / PANGO_SCALE;
+          GskVulkanTextInstance *instance = &instances[count];
+          GskVulkanCachedGlyph *glyph;
 
-          if (!(gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG))
-            {
-              GskVulkanTextInstance *instance = &instances[count];
-              GskVulkanCachedGlyph *glyph;
+          glyph = gsk_vulkan_renderer_get_cached_glyph (renderer, font, gi->glyph, scale);
 
-              glyph = gsk_vulkan_renderer_get_cached_glyph (renderer, font, gi->glyph, scale);
+          instance->tex_rect[0] = glyph->tx;
+          instance->tex_rect[1] = glyph->ty;
+          instance->tex_rect[2] = glyph->tw;
+          instance->tex_rect[3] = glyph->th;
 
-              instance->tex_rect[0] = glyph->tx;
-              instance->tex_rect[1] = glyph->ty;
-              instance->tex_rect[2] = glyph->tw;
-              instance->tex_rect[3] = glyph->th;
+          instance->rect[0] = x + cx + glyph->draw_x;
+          instance->rect[1] = y + cy + glyph->draw_y;
+          instance->rect[2] = glyph->draw_width;
+          instance->rect[3] = glyph->draw_height;
 
-              instance->rect[0] = x + cx + glyph->draw_x;
-              instance->rect[1] = y + cy + glyph->draw_y;
-              instance->rect[2] = glyph->draw_width;
-              instance->rect[3] = glyph->draw_height;
+          instance->color[0] = color->red;
+          instance->color[1] = color->green;
+          instance->color[2] = color->blue;
+          instance->color[3] = color->alpha;
 
-              instance->color[0] = color->red;
-              instance->color[1] = color->green;
-              instance->color[2] = color->blue;
-              instance->color[3] = color->alpha;
-
-              count++;
-            }
+          count++;
         }
       x_position += gi->geometry.width;
     }


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