summaryrefslogtreecommitdiff
path: root/gsk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-15 09:00:50 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-05-15 22:23:14 -0400
commit66b4f0cac4a912e9bee18104c356685a56d90dee (patch)
tree6cb193071b9b23c7678139d02c29f78bb318a5f7 /gsk
parent81e02064656ca937936b4eca292ec880e0598a3e (diff)
downloadgtk+-66b4f0cac4a912e9bee18104c356685a56d90dee.tar.gz
ngl: Reuse texture coordinates
When uploading glyphs, reuse the position that we get from gsk_ngl_texture_library_pack, instead of recomputing it.
Diffstat (limited to 'gsk')
-rw-r--r--gsk/ngl/gsknglglyphlibrary.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/gsk/ngl/gsknglglyphlibrary.c b/gsk/ngl/gsknglglyphlibrary.c
index 3f998f4a05..0339f4590f 100644
--- a/gsk/ngl/gsknglglyphlibrary.c
+++ b/gsk/ngl/gsknglglyphlibrary.c
@@ -194,13 +194,14 @@ static void
gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
const GskNglGlyphKey *key,
const GskNglGlyphValue *value,
+ int x,
+ int y,
int width,
int height,
double device_scale)
{
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
cairo_scaled_font_t *scaled_font;
- GskNglTextureAtlas *atlas;
cairo_surface_t *surface;
guchar *pixel_data;
guchar *free_data = NULL;
@@ -208,7 +209,6 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
guint gl_type;
guint texture_id;
gsize stride;
- int x, y;
g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
g_assert (key != NULL);
@@ -220,7 +220,6 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
return;
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
- atlas = value->entry.is_atlased ? value->entry.atlas : NULL;
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
"Uploading glyph %d",
@@ -256,17 +255,6 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
}
- if G_LIKELY (atlas != NULL)
- {
- x = atlas->width * value->entry.area.x;
- y = atlas->width * value->entry.area.y;
- }
- else
- {
- x = 0;
- y = 0;
- }
-
glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, width, height,
gl_format, gl_type, pixel_data);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
@@ -310,8 +298,8 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
if (key->yshift != 0)
ink_rect.height++;
- width = ink_rect.width * key->scale / 1024;
- height = ink_rect.height * key->scale / 1024;
+ width = (int) ceil (ink_rect.width * key->scale / 1024.0);
+ height = (int) ceil (ink_rect.height * key->scale / 1024.0);
value = gsk_ngl_texture_library_pack (GSK_NGL_TEXTURE_LIBRARY (self),
key,
@@ -327,6 +315,8 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
gsk_ngl_glyph_library_upload_glyph (self,
key,
value,
+ packed_x + 1,
+ packed_y + 1,
width,
height,
key->scale / 1024.0);