[gtk+] box-shadow: For top/bottom and left/right parts, repeat a single line
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] box-shadow: For top/bottom and left/right parts, repeat a single line
- Date: Sat, 21 Mar 2015 20:50:12 +0000 (UTC)
commit 8e032622c864c5259786a72ca1b811603ae9ca09
Author: Alexander Larsson <alexl redhat com>
Date: Fri Mar 20 14:56:42 2015 +0100
box-shadow: For top/bottom and left/right parts, repeat a single line
Since these part really are the same in all of the x or y direction
and we don't blur in that direction we can just blur one line and
repeat it during drawing.
https://bugzilla.gnome.org/show_bug.cgi?id=746468
gtk/gtkcairoblurprivate.h | 3 ++-
gtk/gtkcssshadowvalue.c | 29 +++++++++++++++++++++++++++--
2 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcairoblurprivate.h b/gtk/gtkcairoblurprivate.h
index 970c082..68126d3 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 341844f..ffdc2b6 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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]