mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-01 16:30:15 +00:00
Merge branch 'matthiasc/for-master' into 'master'
ngl: Add padding between cached glyphs See merge request GNOME/gtk!3555
This commit is contained in:
commit
df28a57ae3
@ -194,13 +194,14 @@ static void
|
|||||||
gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
|
gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
|
||||||
const GskNglGlyphKey *key,
|
const GskNglGlyphKey *key,
|
||||||
const GskNglGlyphValue *value,
|
const GskNglGlyphValue *value,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
double device_scale)
|
double device_scale)
|
||||||
{
|
{
|
||||||
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME;
|
||||||
cairo_scaled_font_t *scaled_font;
|
cairo_scaled_font_t *scaled_font;
|
||||||
GskNglTextureAtlas *atlas;
|
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
guchar *pixel_data;
|
guchar *pixel_data;
|
||||||
guchar *free_data = NULL;
|
guchar *free_data = NULL;
|
||||||
@ -208,7 +209,6 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
|
|||||||
guint gl_type;
|
guint gl_type;
|
||||||
guint texture_id;
|
guint texture_id;
|
||||||
gsize stride;
|
gsize stride;
|
||||||
int x, y;
|
|
||||||
|
|
||||||
g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
|
g_assert (GSK_IS_NGL_GLYPH_LIBRARY (self));
|
||||||
g_assert (key != NULL);
|
g_assert (key != NULL);
|
||||||
@ -220,7 +220,6 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
|
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 (),
|
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
|
||||||
"Uploading glyph %d",
|
"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;
|
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,
|
glTexSubImage2D (GL_TEXTURE_2D, 0, x, y, width, height,
|
||||||
gl_format, gl_type, pixel_data);
|
gl_format, gl_type, pixel_data);
|
||||||
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
|
||||||
@ -310,15 +298,15 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
|
|||||||
if (key->yshift != 0)
|
if (key->yshift != 0)
|
||||||
ink_rect.height++;
|
ink_rect.height++;
|
||||||
|
|
||||||
width = ink_rect.width * key->scale / 1024;
|
width = (int) ceil (ink_rect.width * key->scale / 1024.0);
|
||||||
height = ink_rect.height * key->scale / 1024;
|
height = (int) ceil (ink_rect.height * key->scale / 1024.0);
|
||||||
|
|
||||||
value = gsk_ngl_texture_library_pack (GSK_NGL_TEXTURE_LIBRARY (self),
|
value = gsk_ngl_texture_library_pack (GSK_NGL_TEXTURE_LIBRARY (self),
|
||||||
key,
|
key,
|
||||||
sizeof *value,
|
sizeof *value,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
0,
|
1,
|
||||||
&packed_x, &packed_y);
|
&packed_x, &packed_y);
|
||||||
|
|
||||||
memcpy (&value->ink_rect, &ink_rect, sizeof ink_rect);
|
memcpy (&value->ink_rect, &ink_rect, sizeof ink_rect);
|
||||||
@ -327,6 +315,8 @@ gsk_ngl_glyph_library_add (GskNglGlyphLibrary *self,
|
|||||||
gsk_ngl_glyph_library_upload_glyph (self,
|
gsk_ngl_glyph_library_upload_glyph (self,
|
||||||
key,
|
key,
|
||||||
value,
|
value,
|
||||||
|
packed_x + 1,
|
||||||
|
packed_y + 1,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
key->scale / 1024.0);
|
key->scale / 1024.0);
|
||||||
|
@ -377,10 +377,10 @@ gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
|
|||||||
|
|
||||||
entry->atlas = atlas;
|
entry->atlas = atlas;
|
||||||
entry->is_atlased = TRUE;
|
entry->is_atlased = TRUE;
|
||||||
entry->area.x = (float)(packed_x + padding) / atlas->width;
|
entry->area.x = (packed_x + padding) / (float)atlas->width;
|
||||||
entry->area.y = (float)(packed_y + padding) / atlas->height;
|
entry->area.y = (packed_y + padding) / (float)atlas->height;
|
||||||
entry->area.x2 = entry->area.x + (float)width / atlas->width;
|
entry->area.x2 = (packed_x + padding + width) / (float)atlas->width;
|
||||||
entry->area.y2 = entry->area.y + (float)height / atlas->height;
|
entry->area.y2 = (packed_y + padding + height) / (float)atlas->height;
|
||||||
|
|
||||||
*out_packed_x = packed_x;
|
*out_packed_x = packed_x;
|
||||||
*out_packed_y = packed_y;
|
*out_packed_y = packed_y;
|
||||||
@ -394,13 +394,13 @@ gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
|
|||||||
entry->texture = texture;
|
entry->texture = texture;
|
||||||
entry->is_atlased = FALSE;
|
entry->is_atlased = FALSE;
|
||||||
entry->accessed = TRUE;
|
entry->accessed = TRUE;
|
||||||
entry->area.x = 0.0f;
|
entry->area.x = padding / (float) (padding + width + padding);
|
||||||
entry->area.y = 0.0f;
|
entry->area.y = padding / (float) (padding + height + padding);
|
||||||
entry->area.x2 = 1.0f;
|
entry->area.x2 = (padding + width) / (float) (padding + width + padding);
|
||||||
entry->area.y2 = 1.0f;
|
entry->area.y2 = (padding + height) / (float) (padding + height + padding);
|
||||||
|
|
||||||
*out_packed_x = padding;
|
*out_packed_x = 0;
|
||||||
*out_packed_y = padding;
|
*out_packed_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_insert (self->hash_table, key, entry);
|
g_hash_table_insert (self->hash_table, key, entry);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[Test]
|
[Test]
|
||||||
Exec=/bin/sh -c "env GDK_DEBUG=clipboard G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose"
|
Exec=/bin/sh -c "env GDK_DEBUG=clipboard G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose"
|
||||||
Type=session
|
Type=session-exclusive
|
||||||
Output=TAP
|
Output=TAP
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[Test]
|
[Test]
|
||||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose"
|
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose"
|
||||||
Type=session
|
Type=session-exclusive
|
||||||
Output=TAP
|
Output=TAP
|
||||||
|
Loading…
Reference in New Issue
Block a user