summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-05-02 15:13:03 +0200
committerAlexander Larsson <alexl@redhat.com>2013-05-02 15:13:03 +0200
commit2ce9c8cff22ceae4df6740572dfbafbb94080318 (patch)
treebfdd39acbc90d3928fdbccdfb51446f7d2533e93
parent76add3ec3968ee9cd159bb4f705f1d9bdb33d523 (diff)
downloadgtk+-wip/simple-draw3.tar.gz
gtkpixelcache: Use CONTENT_COLOR for solid bg windowswip/simple-draw3
-rw-r--r--gtk/gtkpixelcache.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gtk/gtkpixelcache.c b/gtk/gtkpixelcache.c
index e93c3932f3..91b9d8fb26 100644
--- a/gtk/gtkpixelcache.c
+++ b/gtk/gtkpixelcache.c
@@ -126,6 +126,17 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache,
{
cairo_rectangle_int_t rect;
int surface_w, surface_h;
+ cairo_content_t content;
+ cairo_pattern_t *bg;
+ double red, green, blue, alpha;
+
+ 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)
+ content = CAIRO_CONTENT_COLOR;
surface_w = view_rect->width;
if (canvas_rect->width > surface_w)
@@ -137,7 +148,8 @@ _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 &&
- (cache->surface_w < view_rect->width ||
+ (cairo_surface_get_content (cache->surface) != content ||
+ cache->surface_w < view_rect->width ||
cache->surface_w > surface_w + ALLOW_LARGER_SIZE ||
cache->surface_h < view_rect->height ||
cache->surface_h > surface_h + ALLOW_LARGER_SIZE))
@@ -159,9 +171,9 @@ _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache,
cache->surface_y = -canvas_rect->y;
cache->surface_w = surface_w;
cache->surface_h = surface_h;
+
cache->surface =
- gdk_window_create_similar_surface (window,
- CAIRO_CONTENT_COLOR_ALPHA,
+ gdk_window_create_similar_surface (window, content,
surface_w, surface_h);
rect.x = 0;
rect.y = 0;