mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
gl renderer: Change shadow cache eviction strategy
Since we can do partial redraws, dropping every shadow that's been unused for one frame happens too fast. This is also a problem when a shadow gets drawn on a texture for a few frames.
This commit is contained in:
parent
416a4cf5ea
commit
7931ab5f33
@ -1,6 +1,8 @@
|
||||
|
||||
#include "gskglshadowcacheprivate.h"
|
||||
|
||||
#define MAX_UNUSED_FRAMES (16 * 5) /* 5 seconds? */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GskRoundedRect outline;
|
||||
@ -13,7 +15,7 @@ typedef struct
|
||||
float blur_radius;
|
||||
|
||||
int texture_id;
|
||||
guint used : 1;
|
||||
int unused_frames;
|
||||
} CacheItem;
|
||||
|
||||
static gboolean
|
||||
@ -67,7 +69,7 @@ gsk_gl_shadow_cache_begin_frame (GskGLShadowCache *self,
|
||||
{
|
||||
CacheItem *item = &g_array_index (self->textures, CacheItem, i);
|
||||
|
||||
if (!item->used)
|
||||
if (item->unused_frames > MAX_UNUSED_FRAMES)
|
||||
{
|
||||
gsk_gl_driver_destroy_texture (gl_driver, item->texture_id);
|
||||
g_array_remove_index_fast (self->textures, i);
|
||||
@ -76,7 +78,7 @@ gsk_gl_shadow_cache_begin_frame (GskGLShadowCache *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
item->used = FALSE;
|
||||
item->unused_frames ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,7 +115,7 @@ gsk_gl_shadow_cache_get_texture_id (GskGLShadowCache *self,
|
||||
if (item == NULL)
|
||||
return 0;
|
||||
|
||||
item->used = TRUE;
|
||||
item->unused_frames = 0;
|
||||
|
||||
g_assert (item->texture_id != 0);
|
||||
|
||||
@ -137,6 +139,6 @@ gsk_gl_shadow_cache_commit (GskGLShadowCache *self,
|
||||
|
||||
item->outline = *shadow_rect;
|
||||
item->blur_radius = blur_radius;
|
||||
item->used = TRUE;
|
||||
item->unused_frames = 0;
|
||||
item->texture_id = texture_id;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user