Commit 6a2143ab authored by Christian Hergert's avatar Christian Hergert

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
parent 3665a171
......@@ -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;
}
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment