[gtk+/gtk-3-16] shadow-box: Bail out blur early if radius is 1px



commit d370d130fbf1205262a53605d1d9dd9da9dedc57
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Mar 20 14:31:57 2015 +0100

    shadow-box: Bail out blur early if radius is 1px
    
    For radius 1px the current implementation rounds down to a 1 px box
    filter which is a no-op. Rather than creating useless shadow masks
    in this case we bail out blurring early.
    
    Another alternative would be to make radius 1px round up to a 2 px box
    filter, but that would change the rendering of Adwaita which is probably
    not a great idea this late in the cycle.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746468

 gtk/gtkcairoblur.c      |    4 +++-
 gtk/gtkcssshadowvalue.c |    5 ++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcairoblur.c b/gtk/gtkcairoblur.c
index 170f460..8d67c8c 100644
--- a/gtk/gtkcairoblur.c
+++ b/gtk/gtkcairoblur.c
@@ -215,7 +215,9 @@ _gtk_cairo_blur_surface (cairo_surface_t* surface,
   g_return_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE);
   g_return_if_fail (cairo_image_surface_get_format (surface) == CAIRO_FORMAT_A8);
 
-  if (radius == 0)
+  /* The code doesn't actually do any blurring for radius 1, as it
+   * ends up with box filter size 1 */
+  if (radius <= 1)
     return;
 
   /* Before we mess with the surface, execute any pending drawing. */
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 36e9840..d14520e 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -313,7 +313,10 @@ static gboolean
 needs_blur (const GtkCssValue *shadow)
 {
   double radius = _gtk_css_number_value_get (shadow->radius, 0);
-  if (radius == 0.0)
+
+  /* The code doesn't actually do any blurring for radius 1, as it
+   * ends up with box filter size 1 */
+  if (radius <= 1.0)
     return FALSE;
 
   return TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]