diff options
-rw-r--r-- | gtk/gtkcairoblurprivate.h | 3 | ||||
-rw-r--r-- | gtk/gtkcssshadowvalue.c | 29 |
2 files changed, 29 insertions, 3 deletions
diff --git a/gtk/gtkcairoblurprivate.h b/gtk/gtkcairoblurprivate.h index 970c0826d8..68126d3b5b 100644 --- a/gtk/gtkcairoblurprivate.h +++ b/gtk/gtkcairoblurprivate.h @@ -32,7 +32,8 @@ G_BEGIN_DECLS typedef enum { GTK_BLUR_NONE = 0, GTK_BLUR_X = 1<<0, - GTK_BLUR_Y = 1<<1 + GTK_BLUR_Y = 1<<1, + GTK_BLUR_REPEAT = 1<<2 } GtkBlurFlags; void _gtk_cairo_blur_surface (cairo_surface_t *surface, diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index 341844f751..ffdc2b6250 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -328,6 +328,14 @@ gtk_css_shadow_value_start_drawing (const GtkCssValue *shadow, radius = _gtk_css_number_value_get (shadow->radius, 0); clip_radius = _gtk_cairo_blur_compute_pixels (radius); + if (blur_flags & GTK_BLUR_REPEAT) + { + if (!blur_x) + clip_rect.width = 1; + if (!blur_y) + clip_rect.height = 1; + } + /* Create a larger surface to center the blur. */ surface = cairo_surface_create_similar_image (cairo_get_target (cr), CAIRO_FORMAT_A8, @@ -350,6 +358,20 @@ gtk_css_shadow_value_start_drawing (const GtkCssValue *shadow, return blur_cr; } +void +mask_surface_repeat (cairo_t *cr, + cairo_surface_t *surface) +{ + cairo_pattern_t *pattern; + + pattern = cairo_pattern_create_for_surface (surface); + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); + + cairo_mask (cr, pattern); + + cairo_pattern_destroy (pattern); +} + static cairo_t * gtk_css_shadow_value_finish_drawing (const GtkCssValue *shadow, cairo_t *cr, @@ -370,7 +392,10 @@ gtk_css_shadow_value_finish_drawing (const GtkCssValue *shadow, _gtk_cairo_blur_surface (surface, radius, blur_flags); gdk_cairo_set_source_rgba (original_cr, _gtk_css_rgba_value_get_rgba (shadow->color)); - cairo_mask_surface (original_cr, surface, 0, 0); + if (blur_flags & GTK_BLUR_REPEAT) + mask_surface_repeat (original_cr, surface); + else + cairo_mask_surface (original_cr, surface, 0, 0); cairo_destroy (cr); @@ -740,7 +765,7 @@ _gtk_css_shadow_value_paint_box (const GtkCssValue *shadow, /* Then the sides */ for (i = 0; i < 4; i++) { - GtkBlurFlags blur_flags = 0; + GtkBlurFlags blur_flags = GTK_BLUR_REPEAT; if (i == GTK_CSS_TOP || i == GTK_CSS_BOTTOM) { |