mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-19 21:40:22 +00:00
gpu: Evict stale textures from the cache
This is straightforward. If a texture hasn't been used for 4 seconds, we consider it stale, and drop it the next time gc comes around. The choice of 4 seconds is arbitrary. Fixes: #6346
This commit is contained in:
parent
e8599bd36e
commit
bd9ea05ebb
@ -20,6 +20,8 @@ G_STATIC_ASSERT (MAX_ATLAS_ITEM_SIZE < ATLAS_SIZE);
|
||||
|
||||
#define CACHE_GC_TIMEOUT 15 /* seconds */
|
||||
|
||||
#define CACHE_MAX_AGE (G_TIME_SPAN_SECOND * 4) /* 4 seconds, in µs */
|
||||
|
||||
typedef struct _GskGpuCached GskGpuCached;
|
||||
typedef struct _GskGpuCachedClass GskGpuCachedClass;
|
||||
typedef struct _GskGpuCachedAtlas GskGpuCachedAtlas;
|
||||
@ -64,6 +66,8 @@ struct _GskGpuCached
|
||||
GskGpuCachedAtlas *atlas;
|
||||
GskGpuCached *next;
|
||||
GskGpuCached *prev;
|
||||
|
||||
gint64 timestamp;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -120,7 +124,7 @@ gsk_gpu_cached_use (GskGpuDevice *device,
|
||||
GskGpuCached *cached,
|
||||
gint64 timestamp)
|
||||
{
|
||||
/* FIXME */
|
||||
cached->timestamp = timestamp;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
@ -207,8 +211,7 @@ gsk_gpu_cached_texture_should_collect (GskGpuDevice *device,
|
||||
GskGpuCached *cached,
|
||||
gint64 timestamp)
|
||||
{
|
||||
/* FIXME */
|
||||
return FALSE;
|
||||
return timestamp - cached->timestamp > CACHE_MAX_AGE;
|
||||
}
|
||||
|
||||
static const GskGpuCachedClass GSK_GPU_CACHED_TEXTURE_CLASS =
|
||||
|
Loading…
Reference in New Issue
Block a user