mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +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,
|
||||
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,15 +298,15 @@ 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,
|
||||
sizeof *value,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
1,
|
||||
&packed_x, &packed_y);
|
||||
|
||||
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,
|
||||
key,
|
||||
value,
|
||||
packed_x + 1,
|
||||
packed_y + 1,
|
||||
width,
|
||||
height,
|
||||
key->scale / 1024.0);
|
||||
|
@ -377,10 +377,10 @@ gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
|
||||
|
||||
entry->atlas = atlas;
|
||||
entry->is_atlased = TRUE;
|
||||
entry->area.x = (float)(packed_x + padding) / atlas->width;
|
||||
entry->area.y = (float)(packed_y + padding) / atlas->height;
|
||||
entry->area.x2 = entry->area.x + (float)width / atlas->width;
|
||||
entry->area.y2 = entry->area.y + (float)height / atlas->height;
|
||||
entry->area.x = (packed_x + padding) / (float)atlas->width;
|
||||
entry->area.y = (packed_y + padding) / (float)atlas->height;
|
||||
entry->area.x2 = (packed_x + padding + width) / (float)atlas->width;
|
||||
entry->area.y2 = (packed_y + padding + height) / (float)atlas->height;
|
||||
|
||||
*out_packed_x = packed_x;
|
||||
*out_packed_y = packed_y;
|
||||
@ -394,13 +394,13 @@ gsk_ngl_texture_library_pack (GskNglTextureLibrary *self,
|
||||
entry->texture = texture;
|
||||
entry->is_atlased = FALSE;
|
||||
entry->accessed = TRUE;
|
||||
entry->area.x = 0.0f;
|
||||
entry->area.y = 0.0f;
|
||||
entry->area.x2 = 1.0f;
|
||||
entry->area.y2 = 1.0f;
|
||||
entry->area.x = padding / (float) (padding + width + padding);
|
||||
entry->area.y = padding / (float) (padding + height + padding);
|
||||
entry->area.x2 = (padding + width) / (float) (padding + width + padding);
|
||||
entry->area.y2 = (padding + height) / (float) (padding + height + padding);
|
||||
|
||||
*out_packed_x = padding;
|
||||
*out_packed_y = padding;
|
||||
*out_packed_x = 0;
|
||||
*out_packed_y = 0;
|
||||
}
|
||||
|
||||
g_hash_table_insert (self->hash_table, key, entry);
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose"
|
||||
Type=session
|
||||
Type=session-exclusive
|
||||
Output=TAP
|
||||
|
Loading…
Reference in New Issue
Block a user