[gtk+/wip/pango-shadow-cache: 4/9] cssshadowvalue: Move parts of start_drawing into draw_shadow



commit 950f0d1a316dab0b2a14babbd501430db19f1ea9
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Aug 29 13:59:23 2014 -0700

    cssshadowvalue: Move parts of start_drawing into draw_shadow
    
    start_drawing is meant to be the "simple" API, and draw_shadow has more
    complex needs. Move it in here.

 gtk/gtkcssshadowvalue.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c
index 671f4f0..3007f11 100644
--- a/gtk/gtkcssshadowvalue.c
+++ b/gtk/gtkcssshadowvalue.c
@@ -497,16 +497,35 @@ draw_shadow (const GtkCssValue   *shadow,
             GtkRoundedBox       *clip_box,
             gboolean             blur)
 {
+  cairo_surface_t *shadow_surface;
   cairo_t *shadow_cr;
+  gdouble radius;
 
   if (has_empty_clip (cr))
     return;
 
+  radius = _gtk_css_number_value_get (shadow->radius, 0);
+
   gdk_cairo_set_source_rgba (cr, _gtk_css_rgba_value_get_rgba (shadow->color));
   if (blur)
-    shadow_cr = gtk_css_shadow_value_start_drawing (shadow, cr);
+    {
+      gdouble clip_radius = _gtk_cairo_blur_compute_pixels (radius);
+      cairo_rectangle_int_t clip_rect;
+
+      gdk_cairo_get_clip_rectangle (cr, &clip_rect);
+
+      shadow_surface = cairo_image_surface_create (CAIRO_FORMAT_A8,
+                                                   clip_rect.width + 2 * clip_radius,
+                                                   clip_rect.height + 2 * clip_radius);
+      cairo_surface_set_device_offset (shadow_surface,
+                                       clip_radius - clip_rect.x,
+                                       clip_radius - clip_rect.y);
+      shadow_cr = cairo_create (shadow_surface);
+    }
   else
-    shadow_cr = cr;
+    {
+      shadow_cr = cr;
+    }
 
   cairo_set_fill_rule (shadow_cr, CAIRO_FILL_RULE_EVEN_ODD);
   _gtk_rounded_box_path (box, shadow_cr);
@@ -516,7 +535,12 @@ draw_shadow (const GtkCssValue   *shadow,
   cairo_fill (shadow_cr);
 
   if (blur)
-    gtk_css_shadow_value_finish_drawing (shadow, shadow_cr);
+    {
+      _gtk_cairo_blur_surface (shadow_surface, radius);
+      cairo_mask_surface (cr, shadow_surface, 0, 0);
+      cairo_destroy (shadow_cr);
+      cairo_surface_destroy (shadow_surface);
+    }
 }
 
 void


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