[gtk] gl renderer: Change shadow cache eviction strategy



commit 7931ab5f33991c0eddb5ce7cacc8a90db6ca6252
Author: Timm Bäder <mail baedert org>
Date:   Thu Feb 28 10:12:17 2019 +0100

    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.

 gsk/gl/gskglshadowcache.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gsk/gl/gskglshadowcache.c b/gsk/gl/gskglshadowcache.c
index 8c1f68c5a1..d2a5010a80 100644
--- a/gsk/gl/gskglshadowcache.c
+++ b/gsk/gl/gskglshadowcache.c
@@ -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;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]