[gtk/matthiasc/for-master: 6/6] ngl: Reuse texture coordinates
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 6/6] ngl: Reuse texture coordinates
- Date: Sun, 16 May 2021 02:23:53 +0000 (UTC)
commit 66b4f0cac4a912e9bee18104c356685a56d90dee
Author: Matthias Clasen <mclasen redhat com>
Date: Sat May 15 09:00:50 2021 -0400
ngl: Reuse texture coordinates
When uploading glyphs, reuse the position that
we get from gsk_ngl_texture_library_pack, instead
of recomputing it.
gsk/ngl/gsknglglyphlibrary.c | 22 ++++++----------------
1 file 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]