[gtk+/wip/blur-2: 5/5] Add WIP spinner shadow blur support



commit b2ba7cc1d5c163d362636bf66da86cf0086a761d
Author: Andrea Cimitan <andrea cimitan canonical com>
Date:   Mon Apr 16 13:22:18 2012 +0100

    Add WIP spinner shadow blur support

 gtk/gtkshadow.c        |   55 ++++++++++++++++++++++++++++++++++++++++++++---
 gtk/gtkthemingengine.c |    4 +-
 2 files changed, 53 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkshadow.c b/gtk/gtkshadow.c
index cac4b59..eeab349 100644
--- a/gtk/gtkshadow.c
+++ b/gtk/gtkshadow.c
@@ -406,10 +406,57 @@ _gtk_icon_shadow_paint_spinner (GtkShadow        *shadow,
 
       cairo_save (cr);
 
-      cairo_translate (cr, element->hoffset, element->voffset);
-      _gtk_theming_engine_paint_spinner (cr,
-                                         radius, progress,
-                                         &element->color);
+      if (element->radius > 0)
+        {
+          cairo_t *cr_surface;
+          cairo_surface_t *surface;
+          gint bradius;
+          gdouble x, y;
+
+          bradius = element->radius;
+
+          /* Calculate coordinates. */
+          x = rect.x + element->hoffset - rect.width / 2;
+          y = rect.y + element->voffset - rect.height / 2;
+
+          /* Create a larger surface to center the blur. */
+          surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+                                                rect.width + bradius * 2,
+                                                rect.height + bradius * 2);
+          cr_surface = cairo_create (surface); 
+
+          /* Center the rendering. */
+          cairo_translate (cr_surface,
+                           bradius,
+                           bradius);
+
+          /* Create the path on the surface to blur. */
+          cairo_translate (cr_surface,
+                           rect.width / 2,
+                           rect.height / 2);
+          _gtk_theming_engine_paint_spinner (cr_surface,
+                                             radius, progress,
+                                             &element->color);
+
+          /* Blur the surface. */
+          _gtk_cairo_blur_surface (surface, bradius);
+
+          /* Paint the blurred surface to cr. */
+          cairo_set_source_surface (cr, surface,
+                                    x - bradius,
+                                    y - bradius); 
+          cairo_paint (cr);
+
+          cairo_destroy (cr_surface);
+          cairo_surface_destroy (surface); 
+        }
+      else
+        {
+          cairo_translate (cr, element->hoffset, element->voffset);
+          _gtk_theming_engine_paint_spinner (cr,
+                                             radius, progress,
+                                             &element->color);
+        }
 
       cairo_restore (cr);
     }
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 0ca4e6d..e36ea28 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -2782,8 +2782,8 @@ render_spinner (GtkThemingEngine *engine,
 
       rect.x = x;
       rect.y = y;
-      rect.width = radius;
-      rect.height = radius;
+      rect.width = radius * 2;
+      rect.height = radius * 2;
       
       _gtk_icon_shadow_paint_spinner (shadow, cr,
                                       rect,



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