diff options
author | Christian Hergert <christian@hergert.me> | 2015-06-16 16:46:24 -0700 |
---|---|---|
committer | Christian Hergert <christian@hergert.me> | 2015-06-16 18:08:22 -0700 |
commit | 6a2143ab31beaa69fb685a3db6882831fc372cc2 (patch) | |
tree | cbaab48132ffa90ba412acf24950e0dad287872c | |
parent | 3665a17102b3d2c0b8289f6925dd71ce0e067c5e (diff) | |
download | gtk+-6a2143ab31beaa69fb685a3db6882831fc372cc2.tar.gz |
pixelcache: allow widgets to always require cached content
Some widgets have very expensive drawing paths. So caching the content
can be useful even when not scrolling.
This can help speed up widgets that are part of animation sequences and
thereby go through spurious expose events.
https://bugzilla.gnome.org/show_bug.cgi?id=751082
-rw-r--r-- | gtk/gtkpixelcache.c | 23 | ||||
-rw-r--r-- | gtk/gtkpixelcacheprivate.h | 45 |
2 files changed, 44 insertions, 24 deletions
diff --git a/gtk/gtkpixelcache.c b/gtk/gtkpixelcache.c index 3e88302199..a6a85cbb87 100644 --- a/gtk/gtkpixelcache.c +++ b/gtk/gtkpixelcache.c @@ -49,6 +49,8 @@ struct _GtkPixelCache { guint extra_width; guint extra_height; + + guint always_cache : 1; }; GtkPixelCache * @@ -224,10 +226,12 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache, } /* Don't allocate a surface if view >= canvas, as we won't - be scrolling then anyway */ + * be scrolling then anyway, unless the widget requested it. + */ if (cache->surface == NULL && - (view_rect->width < canvas_rect->width || - view_rect->height < canvas_rect->height)) + (cache->always_cache || + (view_rect->width < canvas_rect->width || + view_rect->height < canvas_rect->height))) { cache->surface_x = -canvas_rect->x; cache->surface_y = -canvas_rect->y; @@ -483,3 +487,16 @@ _gtk_pixel_cache_unmap (GtkPixelCache *cache) { gtk_pixel_cache_blow_cache (cache); } + +gboolean +_gtk_pixel_cache_get_always_cache (GtkPixelCache *cache) +{ + return cache->always_cache; +} + +void +_gtk_pixel_cache_set_always_cache (GtkPixelCache *cache, + gboolean always_cache) +{ + cache->always_cache = !!always_cache; +} diff --git a/gtk/gtkpixelcacheprivate.h b/gtk/gtkpixelcacheprivate.h index c31693e140..8e1122c36f 100644 --- a/gtk/gtkpixelcacheprivate.h +++ b/gtk/gtkpixelcacheprivate.h @@ -30,27 +30,30 @@ typedef struct _GtkPixelCache GtkPixelCache; typedef void (*GtkPixelCacheDrawFunc) (cairo_t *cr, gpointer user_data); -GtkPixelCache *_gtk_pixel_cache_new (void); -void _gtk_pixel_cache_free (GtkPixelCache *cache); -void _gtk_pixel_cache_map (GtkPixelCache *cache); -void _gtk_pixel_cache_unmap (GtkPixelCache *cache); -void _gtk_pixel_cache_invalidate (GtkPixelCache *cache, - cairo_region_t *region); -void _gtk_pixel_cache_draw (GtkPixelCache *cache, - cairo_t *cr, - GdkWindow *window, - cairo_rectangle_int_t *view_rect, - cairo_rectangle_int_t *canvas_rect, - GtkPixelCacheDrawFunc draw, - gpointer user_data); -void _gtk_pixel_cache_get_extra_size (GtkPixelCache *cache, - guint *extra_width, - guint *extra_height); -void _gtk_pixel_cache_set_extra_size (GtkPixelCache *cache, - guint extra_width, - guint extra_height); -void _gtk_pixel_cache_set_content (GtkPixelCache *cache, - cairo_content_t content); +GtkPixelCache *_gtk_pixel_cache_new (void); +void _gtk_pixel_cache_free (GtkPixelCache *cache); +void _gtk_pixel_cache_map (GtkPixelCache *cache); +void _gtk_pixel_cache_unmap (GtkPixelCache *cache); +void _gtk_pixel_cache_invalidate (GtkPixelCache *cache, + cairo_region_t *region); +void _gtk_pixel_cache_draw (GtkPixelCache *cache, + cairo_t *cr, + GdkWindow *window, + cairo_rectangle_int_t *view_rect, + cairo_rectangle_int_t *canvas_rect, + GtkPixelCacheDrawFunc draw, + gpointer user_data); +void _gtk_pixel_cache_get_extra_size (GtkPixelCache *cache, + guint *extra_width, + guint *extra_height); +void _gtk_pixel_cache_set_extra_size (GtkPixelCache *cache, + guint extra_width, + guint extra_height); +void _gtk_pixel_cache_set_content (GtkPixelCache *cache, + cairo_content_t content); +gboolean _gtk_pixel_cache_get_always_cache (GtkPixelCache *cache); +void _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache, + gboolean always_cache); G_END_DECLS |