/* Cache eviction strategy
*
- * We mark glyphs as accessed every time we use them. Every
- * few frames, we mark glyphs that haven't been accessed since
- * the last check as old.
+ * We mark glyphs as accessed every time we use them.
+ * Every few frames, we mark glyphs that haven't been
+ * accessed since the last check as old.
*
- * We keep count of the pixels of each atlas that are taken up by old
- * data. When the fraction of old pixels gets too high, we drop the
- * atlas and all the items it contained.
+ * We keep count of the pixels of each atlas that are
+ * taken up by old data. When the fraction of old pixels
+ * gets too high, we drop the atlas and all the items it
+ * contained.
+ *
+ * Big glyphs are not stored in the atlas, they get their
+ * own texture, but they are still cached.
*/
#define MAX_FRAME_AGE (60)
{
value->atlas = NULL;
value->texture_id = gsk_gl_driver_create_texture (driver, width, height);
+ gsk_gl_driver_mark_texture_permanent (driver, value->texture_id);
gsk_gl_driver_bind_source_texture (driver, value->texture_id);
gsk_gl_driver_init_texture_empty (driver, value->texture_id, GL_LINEAR, GL_LINEAR);
void
gsk_gl_glyph_cache_begin_frame (GskGLGlyphCache *self,
+ GskGLDriver *driver,
GPtrArray *removed_atlases)
{
GHashTableIter iter;
{
if (!value->accessed)
{
- if (value->atlas && value->used)
+ if (value->atlas)
+ {
+ if (value->used)
+ {
+ gsk_gl_texture_atlas_mark_unused (value->atlas, value->draw_width, value->draw_height);
+ value->used = FALSE;
+ }
+ }
+ else
{
- gsk_gl_texture_atlas_mark_unused (value->atlas, value->draw_width, value->draw_height);
- value->used = FALSE;
+ gsk_gl_driver_destroy_texture (driver, value->texture_id);
+ g_hash_table_iter_remove (&iter);
}
}
-
- value->accessed = FALSE;
+ else
+ value->accessed = FALSE;
}
GSK_NOTE(GLYPH_CACHE, g_message ("%d glyphs cached", g_hash_table_size (self->hash_table)));
removed = g_ptr_array_new ();
gsk_gl_texture_atlases_begin_frame (self->atlases, removed);
- gsk_gl_glyph_cache_begin_frame (self->glyph_cache, removed);
+ gsk_gl_glyph_cache_begin_frame (self->glyph_cache, self->gl_driver, removed);
gsk_gl_icon_cache_begin_frame (self->icon_cache, removed);
gsk_gl_shadow_cache_begin_frame (&self->shadow_cache, self->gl_driver);
g_ptr_array_unref (removed);