summaryrefslogtreecommitdiff
path: root/gtk/gtkpixelcache.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-08-26 21:13:05 +0200
committerAlexander Larsson <alexl@redhat.com>2013-08-26 21:17:45 +0200
commit2d0bdee075edbbdcec9bc945db9c681ff927b002 (patch)
tree32bce62c5b0dfedd3598c766e0f2adda8f58bb0a /gtk/gtkpixelcache.c
parentd96882bc163ee18969c760f1065ec26a3b5a34c2 (diff)
downloadgtk+-2d0bdee075edbbdcec9bc945db9c681ff927b002.tar.gz
pixel cache: Allow growing of cache surface
If the new requested surface size is enough larger than the previous one (but the old is still larger than the absolute minimum), reallocate it anyway. This fixes an issue where the text view initially requested a really small extra size which was then increased but that didn't "take".
Diffstat (limited to 'gtk/gtkpixelcache.c')
-rw-r--r--gtk/gtkpixelcache.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gtk/gtkpixelcache.c b/gtk/gtkpixelcache.c
index bffa618d33..fd44f206c4 100644
--- a/gtk/gtkpixelcache.c
+++ b/gtk/gtkpixelcache.c
@@ -26,8 +26,9 @@
to make scrolling more efficient */
#define DEFAULT_EXTRA_SIZE 64
-/* When resizing viewport to smaller we allow this extra
+/* When resizing viewport we allow this extra
size to avoid constantly reallocating when resizing */
+#define ALLOW_SMALLER_SIZE 32
#define ALLOW_LARGER_SIZE 32
struct _GtkPixelCache {
@@ -184,9 +185,9 @@ _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 < view_rect->width ||
+ cache->surface_w < MAX(view_rect->width, surface_w - ALLOW_SMALLER_SIZE) ||
cache->surface_w > surface_w + ALLOW_LARGER_SIZE ||
- cache->surface_h < view_rect->height ||
+ cache->surface_h < MAX(view_rect->height, surface_h - ALLOW_SMALLER_SIZE) ||
cache->surface_h > surface_h + ALLOW_LARGER_SIZE ||
cache->surface_scale != gdk_window_get_scale_factor (window)))
{