[gtk+] pixelcache: use factor instead of margin
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] pixelcache: use factor instead of margin
- Date: Wed, 16 Sep 2015 18:25:07 +0000 (UTC)
commit e55a8b6aefe1ef71d90c06297efb7c40f449e1bc
Author: Christian Hergert <christian hergert me>
Date: Sun Sep 13 21:08:57 2015 -0700
pixelcache: use factor instead of margin
Instead of using a fixed size, use a factor of the surface size. This
helps in situations where animations of surrounding widgets are used
and cause a rapid rate of surface destroy/create cycles.
gtk/gtkpixelcache.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkpixelcache.c b/gtk/gtkpixelcache.c
index 6661f3d..dae4044 100644
--- a/gtk/gtkpixelcache.c
+++ b/gtk/gtkpixelcache.c
@@ -29,8 +29,8 @@
/* When resizing viewport we allow this extra
size to avoid constantly reallocating when resizing */
-#define ALLOW_SMALLER_SIZE 32
-#define ALLOW_LARGER_SIZE 32
+#define ALLOW_SMALLER_SIZE_FACTOR 0.5
+#define ALLOW_LARGER_SIZE_FACTOR 1.25
struct _GtkPixelCache {
cairo_surface_t *surface;
@@ -213,10 +213,10 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache,
/* If current surface can't fit view_rect or is too large, kill it */
if (cache->surface != NULL &&
(cairo_surface_get_content (cache->surface) != content ||
- cache->surface_w < MAX(view_rect->width, surface_w - ALLOW_SMALLER_SIZE) ||
- cache->surface_w > surface_w + ALLOW_LARGER_SIZE ||
- cache->surface_h < MAX(view_rect->height, surface_h - ALLOW_SMALLER_SIZE) ||
- cache->surface_h > surface_h + ALLOW_LARGER_SIZE ||
+ cache->surface_w < MAX(view_rect->width, surface_w * ALLOW_SMALLER_SIZE_FACTOR) ||
+ cache->surface_w > surface_w * ALLOW_LARGER_SIZE_FACTOR ||
+ cache->surface_h < MAX(view_rect->height, surface_h * ALLOW_SMALLER_SIZE_FACTOR) ||
+ cache->surface_h > surface_h * ALLOW_LARGER_SIZE_FACTOR ||
cache->surface_scale != gdk_window_get_scale_factor (window)))
{
cairo_surface_destroy (cache->surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]