mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
cogl-pango-glyph-cache: Don't put zero-sized glyphs in the cache
It now avoids trying to reserve space for zero-sized glyphs. That happens for example when the layout contains a space. This was causing the regular glyph cache to be used because the global atlas does not support zero-sized images. That would then break up the batching. Instead it now still reserves an entry in the cache but leaves the texture as COGL_INVALID_HANDLE.
This commit is contained in:
parent
f098f8fdec
commit
b83069f3b2
@ -70,6 +70,7 @@ struct _CoglPangoGlyphCacheKey
|
||||
static void
|
||||
cogl_pango_glyph_cache_value_free (CoglPangoGlyphCacheValue *value)
|
||||
{
|
||||
if (value->texture)
|
||||
cogl_handle_unref (value->texture);
|
||||
g_slice_free (CoglPangoGlyphCacheValue, value);
|
||||
}
|
||||
@ -307,7 +308,6 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache,
|
||||
|
||||
value = g_slice_new (CoglPangoGlyphCacheValue);
|
||||
value->texture = COGL_INVALID_HANDLE;
|
||||
value->dirty = TRUE;
|
||||
|
||||
pango_font_get_glyph_extents (font, glyph, &ink_rect, NULL);
|
||||
pango_extents_to_pixels (&ink_rect, NULL);
|
||||
@ -317,11 +317,18 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache,
|
||||
value->draw_width = ink_rect.width;
|
||||
value->draw_height = ink_rect.height;
|
||||
|
||||
/* If the glyph is zero-sized then we don't need to reserve any
|
||||
space for it and we can just avoid painting anything */
|
||||
if (ink_rect.width < 1 || ink_rect.height < 1)
|
||||
value->dirty = FALSE;
|
||||
else
|
||||
{
|
||||
/* Try adding the glyph to the global atlas... */
|
||||
if (!cogl_pango_glyph_cache_add_to_global_atlas (cache,
|
||||
font,
|
||||
glyph,
|
||||
value) &&
|
||||
/* If it fails try the local atlas */
|
||||
!cogl_pango_glyph_cache_add_to_local_atlas (cache,
|
||||
font,
|
||||
glyph,
|
||||
@ -331,13 +338,15 @@ cogl_pango_glyph_cache_lookup (CoglPangoGlyphCache *cache,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
value->dirty = TRUE;
|
||||
cache->has_dirty_glyphs = TRUE;
|
||||
}
|
||||
|
||||
key = g_slice_new (CoglPangoGlyphCacheKey);
|
||||
key->font = g_object_ref (font);
|
||||
key->glyph = glyph;
|
||||
|
||||
g_hash_table_insert (cache->hash_table, key, value);
|
||||
|
||||
cache->has_dirty_glyphs = TRUE;
|
||||
}
|
||||
|
||||
return value;
|
||||
|
@ -501,6 +501,11 @@ cogl_pango_renderer_set_dirty_glyph (PangoFont *font,
|
||||
|
||||
COGL_NOTE (PANGO, "redrawing glyph %i", glyph);
|
||||
|
||||
/* Glyphs that don't take up any space will end up without a
|
||||
texture. These should never become dirty so they shouldn't end up
|
||||
here */
|
||||
g_return_if_fail (value->texture != COGL_INVALID_HANDLE);
|
||||
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_A8,
|
||||
value->draw_width,
|
||||
value->draw_height);
|
||||
@ -824,7 +829,7 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer,
|
||||
PANGO_UNKNOWN_GLYPH_WIDTH,
|
||||
PANGO_UNKNOWN_GLYPH_HEIGHT);
|
||||
}
|
||||
else
|
||||
else if (cache_value->texture)
|
||||
{
|
||||
x += (float)(cache_value->draw_x);
|
||||
y += (float)(cache_value->draw_y);
|
||||
|
Loading…
Reference in New Issue
Block a user