[gtk+] Fix rendering glyphs from the cache
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Fix rendering glyphs from the cache
- Date: Mon, 11 Sep 2017 18:46:09 +0000 (UTC)
commit ff45a86a1c695b88f9503a58ab241cf534e9e72f
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Sep 11 14:45:36 2017 -0400
Fix rendering glyphs from the cache
We were not quite using all the right dimensions.
gsk/gskvulkancolortextpipeline.c | 13 ++++++-------
gsk/gskvulkanrenderer.c | 18 +++++++++++-------
gsk/gskvulkanrendererprivate.h | 6 ++++--
gsk/gskvulkantextpipeline.c | 13 ++++++-------
4 files changed, 27 insertions(+), 23 deletions(-)
---
diff --git a/gsk/gskvulkancolortextpipeline.c b/gsk/gskvulkancolortextpipeline.c
index b3da054..6cca243 100644
--- a/gsk/gskvulkancolortextpipeline.c
+++ b/gsk/gskvulkancolortextpipeline.c
@@ -104,8 +104,7 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
GskVulkanColorTextInstance *instances = (GskVulkanColorTextInstance *) data;
int i, count;
int x_position = 0;
- float ascent;
- float height;
+ float dx, dy, dw, dh;
count = 0;
for (i = 0; i < glyphs->num_glyphs; i++)
@@ -126,11 +125,11 @@ gsk_vulkan_color_text_pipeline_collect_vertex_data (GskVulkanColorTextPipeline *
&instance->tex_rect[1],
&instance->tex_rect[2],
&instance->tex_rect[3],
- &ascent, &height);
- instance->rect[0] = x + cx;
- instance->rect[1] = y + cy - ascent;
- instance->rect[2] = PANGO_PIXELS_CEIL (gi->geometry.width);
- instance->rect[3] = height;
+ &dx, &dy, &dw, &dh);
+ instance->rect[0] = x + cx + dx;
+ instance->rect[1] = y + cy + dy;
+ instance->rect[2] = dw;
+ instance->rect[3] = dh;
count++;
}
diff --git a/gsk/gskvulkanrenderer.c b/gsk/gskvulkanrenderer.c
index a56fd57..d9739a0 100644
--- a/gsk/gskvulkanrenderer.c
+++ b/gsk/gskvulkanrenderer.c
@@ -419,8 +419,10 @@ gsk_vulkan_renderer_get_glyph_coords (GskVulkanRenderer *self,
float *ty,
float *tw,
float *th,
- float *ascent,
- float *height)
+ float *dx,
+ float *dy,
+ float *dw,
+ float *dh)
{
GlyphCacheValue *gv;
@@ -432,8 +434,10 @@ gsk_vulkan_renderer_get_glyph_coords (GskVulkanRenderer *self,
*ty = gv->ty;
*tw = gv->tw;
*th = gv->th;
- *ascent = - gv->draw_y;
- *height = gv->draw_height;
+ *dx = gv->draw_x;
+ *dy = gv->draw_y;
+ *dw = gv->draw_width;
+ *dh = gv->draw_height;
}
}
@@ -502,10 +506,10 @@ add_to_cache (GlyphCache *cache,
return;
cairo_set_scaled_font (cr, scaled_font);
- cairo_set_source_rgba (cr, 0, 0, 0, 1);
+ cairo_set_source_rgba (cr, 1, 1, 1, 1);
cg.index = glyph;
- cg.x = cache->x;
+ cg.x = cache->x - value->draw_x;
cg.y = cache->y0 - value->draw_y;
cairo_show_glyphs (cr, &cg, 1);
@@ -515,7 +519,7 @@ add_to_cache (GlyphCache *cache,
cache->x = cache->x + value->draw_width + 1;
cache->y = MAX (cache->y, cache->y0 + value->draw_height + 1);
- value->tx = cg.x / cache->width;
+ value->tx = (cg.x + value->draw_x) / cache->width;
value->ty = (cg.y + value->draw_y) / cache->height;
value->tw = (float)value->draw_width / cache->width;
value->th = (float)value->draw_height / cache->height;
diff --git a/gsk/gskvulkanrendererprivate.h b/gsk/gskvulkanrendererprivate.h
index fe5b0de..25b90e6 100644
--- a/gsk/gskvulkanrendererprivate.h
+++ b/gsk/gskvulkanrendererprivate.h
@@ -37,8 +37,10 @@ void gsk_vulkan_renderer_get_glyph_coords (GskVulk
float *ty,
float *tw,
float *th,
- float *ascent,
- float *height);
+ float *dx,
+ float *dy,
+ float *dw,
+ float *dh);
void gsk_vulkan_renderer_cache_glyphs (GskVulkanRenderer *renderer,
PangoFont *font,
diff --git a/gsk/gskvulkantextpipeline.c b/gsk/gskvulkantextpipeline.c
index 81eee30..def6c6e 100644
--- a/gsk/gskvulkantextpipeline.c
+++ b/gsk/gskvulkantextpipeline.c
@@ -112,8 +112,7 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
GskVulkanTextInstance *instances = (GskVulkanTextInstance *) data;
int i, count;
int x_position = 0;
- float ascent;
- float height;
+ float dx, dy, dw, dh;
count = 0;
for (i = 0; i < glyphs->num_glyphs; i++)
@@ -134,11 +133,11 @@ gsk_vulkan_text_pipeline_collect_vertex_data (GskVulkanTextPipeline *pipeline,
&instance->tex_rect[1],
&instance->tex_rect[2],
&instance->tex_rect[3],
- &ascent, &height);
- instance->rect[0] = x + cx;
- instance->rect[1] = y + cy - ascent;
- instance->rect[2] = PANGO_PIXELS_CEIL (gi->geometry.width);
- instance->rect[3] = height;
+ &dx, &dy, &dw, &dh);
+ instance->rect[0] = x + cx + dx;
+ instance->rect[1] = y + cy + dy;
+ instance->rect[2] = dw;
+ instance->rect[3] = dh;
instance->color[0] = color->red;
instance->color[1] = color->green;
instance->color[2] = color->blue;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]