mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
pixelcache: use GtkStyleContext to determine cairo_content_t for surface
We can take a fast path if the background for a widget is opaque by using a CAIRO_CONTENT_COLOR instead of a CAIRO_CONTENT_COLOR_ALPHA surface. Most blit'ing backends have a fast path for this, including Pixman and Quartz. https://bugzilla.gnome.org/show_bug.cgi?id=754658
This commit is contained in:
parent
c1691a4964
commit
d7eb90779f
@ -45,6 +45,9 @@ struct _GtkPixelCache {
|
||||
/* may be null if not dirty */
|
||||
cairo_region_t *surface_dirty;
|
||||
|
||||
/* background tracking for rgb/rgba */
|
||||
GtkStyleContext *style_context;
|
||||
|
||||
guint timeout_tag;
|
||||
|
||||
guint extra_width;
|
||||
@ -88,6 +91,8 @@ _gtk_pixel_cache_free (GtkPixelCache *cache)
|
||||
if (cache->surface_dirty != NULL)
|
||||
cairo_region_destroy (cache->surface_dirty);
|
||||
|
||||
g_clear_object (&cache->style_context);
|
||||
|
||||
g_free (cache);
|
||||
}
|
||||
|
||||
@ -193,11 +198,8 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache,
|
||||
if (!content)
|
||||
{
|
||||
content = CAIRO_CONTENT_COLOR_ALPHA;
|
||||
bg = gdk_window_get_background_pattern (window);
|
||||
if (bg != NULL &&
|
||||
cairo_pattern_get_type (bg) == CAIRO_PATTERN_TYPE_SOLID &&
|
||||
cairo_pattern_get_rgba (bg, &red, &green, &blue, &alpha) == CAIRO_STATUS_SUCCESS &&
|
||||
alpha == 1.0)
|
||||
if (cache->style_context &&
|
||||
_gtk_style_context_is_background_opaque (cache->style_context))
|
||||
content = CAIRO_CONTENT_COLOR;
|
||||
}
|
||||
|
||||
@ -500,3 +502,11 @@ _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache,
|
||||
{
|
||||
cache->always_cache = !!always_cache;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_pixel_cache_set_style_context (GtkPixelCache *cache,
|
||||
GtkStyleContext *style_context)
|
||||
{
|
||||
if (g_set_object (&cache->style_context, style_context))
|
||||
_gtk_pixel_cache_invalidate (cache, NULL);
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ void _gtk_pixel_cache_set_content (GtkPixelCache *cache,
|
||||
gboolean _gtk_pixel_cache_get_always_cache (GtkPixelCache *cache);
|
||||
void _gtk_pixel_cache_set_always_cache (GtkPixelCache *cache,
|
||||
gboolean always_cache);
|
||||
void _gtk_pixel_cache_set_style_context(GtkPixelCache *cache,
|
||||
GtkStyleContext *style_context);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user