[gtk/wip/otte/no-clip-on-draw: 6/10] cairoblur: Move the check for early exit



commit 81f932dd6549f13c7f23d31780e2011cb77de535
Author: Benjamin Otte <otte redhat com>
Date:   Thu Feb 13 00:14:29 2020 +0100

    cairoblur: Move the check for early exit
    
    That means we only have one place where we check all kinds of early
    exits.

 gsk/gskcairoblur.c      | 11 ++++++++---
 gsk/gskrendernodeimpl.c | 10 ++--------
 2 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/gsk/gskcairoblur.c b/gsk/gskcairoblur.c
index 6b5a3d56df..fd83470f6a 100644
--- a/gsk/gskcairoblur.c
+++ b/gsk/gskcairoblur.c
@@ -281,8 +281,13 @@ gsk_cairo_blur_compute_pixels (double radius)
 }
 
 static gboolean
-needs_blur (float radius)
+needs_blur (float        radius,
+            GskBlurFlags blur_flags)
 {
+  /* Neither blurring horizontal nor vertical means no blurring at all. */
+  if ((blur_flags & (GSK_BLUR_X | GSK_BLUR_Y)) == 0)
+    return FALSE;
+
   /* The code doesn't actually do any blurring for radius 1, as it
    * ends up with box filter size 1 */
   if (radius <= 1.0)
@@ -306,7 +311,7 @@ gsk_cairo_blur_start_drawing (cairo_t         *cr,
   gboolean blur_x = (blur_flags & GSK_BLUR_X) != 0;
   gboolean blur_y = (blur_flags & GSK_BLUR_Y) != 0;
 
-  if (!needs_blur (radius))
+  if (!needs_blur (radius, blur_flags))
     return cr;
 
   gdk_cairo_get_clip_rectangle (cr, &clip_rect);
@@ -372,7 +377,7 @@ gsk_cairo_blur_finish_drawing (cairo_t         *cr,
   cairo_surface_t *surface;
   gdouble x_scale;
 
-  if (!needs_blur (radius))
+  if (!needs_blur (radius, blur_flags))
     return cr;
 
   original_cr = cairo_get_user_data (cr, &original_cr_key);
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 43844cd1e2..e35fd1b44a 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -770,17 +770,12 @@ draw_shadow (cairo_t             *cr,
             GskBlurFlags         blur_flags)
 {
   cairo_t *shadow_cr;
-  gboolean do_blur;
 
   if (has_empty_clip (cr))
     return;
 
   gdk_cairo_set_source_rgba (cr, color);
-  do_blur = (blur_flags & (GSK_BLUR_X | GSK_BLUR_Y)) != 0;
-  if (do_blur)
-    shadow_cr = gsk_cairo_blur_start_drawing (cr, radius, blur_flags);
-  else
-    shadow_cr = cr;
+  shadow_cr = gsk_cairo_blur_start_drawing (cr, radius, blur_flags);
 
   cairo_set_fill_rule (shadow_cr, CAIRO_FILL_RULE_EVEN_ODD);
   gsk_rounded_rect_path (box, shadow_cr);
@@ -791,8 +786,7 @@ draw_shadow (cairo_t             *cr,
 
   cairo_fill (shadow_cr);
 
-  if (do_blur)
-    gsk_cairo_blur_finish_drawing (shadow_cr, radius, color, blur_flags);
+  gsk_cairo_blur_finish_drawing (shadow_cr, radius, color, blur_flags);
 }
 
 typedef struct {


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