]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssshadowvalue.c
Rename property to be more neutral
[~andy/gtk] / gtk / gtkcssshadowvalue.c
index 7d4acbca1dd9fc536a1d11a68bfcbf4955fb463a..618288807af8d3b7e9571d013c632880a9f7f67a 100644 (file)
 
 #include "gtkcssshadowvalueprivate.h"
 
-#include <math.h>
-
 #include "gtkcairoblurprivate.h"
+#include "gtkcsscolorvalueprivate.h"
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkcssrgbavalueprivate.h"
 #include "gtkstylecontextprivate.h"
-#include "gtksymboliccolorprivate.h"
 #include "gtkthemingengineprivate.h"
 #include "gtkpango.h"
 
@@ -63,32 +61,34 @@ gtk_css_value_shadow_free (GtkCssValue *shadow)
 }
 
 static GtkCssValue *
-gtk_css_value_shadow_compute (GtkCssValue        *shadow,
-                              guint               property_id,
-                              GtkStyleContext    *context,
-                              GtkCssDependencies *dependencies)
+gtk_css_value_shadow_compute (GtkCssValue             *shadow,
+                              guint                    property_id,
+                              GtkStyleProviderPrivate *provider,
+                              GtkCssComputedValues    *values,
+                              GtkCssComputedValues    *parent_values,
+                              GtkCssDependencies      *dependencies)
 {
   GtkCssValue *hoffset, *voffset, *radius, *spread, *color;
   GtkCssDependencies child_deps;
 
   child_deps = 0;
-  hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, context, &child_deps);
+  hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, provider, values, parent_values, &child_deps);
   *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
 
   child_deps = 0;
-  voffset = _gtk_css_value_compute (shadow->voffset, property_id, context, &child_deps);
+  voffset = _gtk_css_value_compute (shadow->voffset, property_id, provider, values, parent_values, &child_deps);
   *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
 
   child_deps = 0;
-  radius = _gtk_css_value_compute (shadow->radius, property_id, context, &child_deps);
+  radius = _gtk_css_value_compute (shadow->radius, property_id, provider, values, parent_values, &child_deps);
   *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
 
   child_deps = 0;
-  spread = _gtk_css_value_compute (shadow->spread, property_id, context, &child_deps),
+  spread = _gtk_css_value_compute (shadow->spread, property_id, provider, values, parent_values, &child_deps),
   *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
 
   child_deps = 0;
-  color = _gtk_css_value_compute (shadow->color, property_id, context, &child_deps);
+  color = _gtk_css_value_compute (shadow->color, property_id, provider, values, parent_values, &child_deps);
   *dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
 
   return gtk_css_shadow_value_new (hoffset, voffset, radius, spread, shadow->inset, color);
@@ -271,7 +271,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
       }
     else if (values[COLOR] == NULL)
       {
-        values[COLOR] = _gtk_css_symbolic_value_new (parser);
+        values[COLOR] = _gtk_css_color_value_parse (parser);
 
         if (values[COLOR] == NULL)
           goto fail;
@@ -287,9 +287,7 @@ _gtk_css_shadow_value_parse (GtkCssParser *parser)
   while (values[HOFFSET] == NULL || !value_is_done_parsing (parser));
 
   if (values[COLOR] == NULL)
-    values[COLOR] = _gtk_css_symbolic_value_new_take_symbolic_color (
-                      gtk_symbolic_color_ref (
-                        _gtk_symbolic_color_get_current_color ()));
+    values[COLOR] = _gtk_css_color_value_new_current_color ();
 
   return gtk_css_shadow_value_new (values[HOFFSET], values[VOFFSET],
                                    values[RADIUS], values[SPREAD],
@@ -311,7 +309,7 @@ static cairo_t *
 gtk_css_shadow_value_start_drawing (const GtkCssValue *shadow,
                                     cairo_t           *cr)
 {
-  cairo_rectangle_t clip;
+  cairo_rectangle_int_t clip_rect;
   cairo_surface_t *surface;
   cairo_t *blur_cr;
   gdouble radius;
@@ -320,16 +318,13 @@ gtk_css_shadow_value_start_drawing (const GtkCssValue *shadow,
   if (radius == 0.0)
     return cr;
 
-  radius = ceil (radius);
-  cairo_clip_extents (cr, &clip.x, &clip.y, &clip.width, &clip.height);
-  clip.x -= radius;
-  clip.y -= radius;
-  clip.width += 2 * radius;
-  clip.height += 2 * radius;
+  gdk_cairo_get_clip_rectangle (cr, &clip_rect);
 
   /* Create a larger surface to center the blur. */
-  surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, &clip);
-  cairo_surface_set_device_offset (surface, - clip.x, - clip.y);
+  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+                                        clip_rect.width + 2 * radius,
+                                        clip_rect.height + 2 * radius);
+  cairo_surface_set_device_offset (surface, radius - clip_rect.x, radius - clip_rect.y);
   blur_cr = cairo_create (surface);
   cairo_set_user_data (blur_cr, &shadow_key, cairo_reference (cr), (cairo_destroy_func_t) cairo_destroy);
 
@@ -349,39 +344,24 @@ gtk_css_shadow_value_finish_drawing (const GtkCssValue *shadow,
                                      cairo_t           *cr)
 {
   gdouble radius;
-  cairo_t *original_cr, *image_cr;
-  cairo_surface_t *recording_surface, *image_surface;
-  cairo_rectangle_t ink;
+  cairo_t *original_cr;
+  cairo_surface_t *surface;
 
   radius = _gtk_css_number_value_get (shadow->radius, 0);
   if (radius == 0.0)
     return cr;
 
-  recording_surface = cairo_get_target (cr);
+  surface = cairo_get_target (cr);
   original_cr = cairo_get_user_data (cr, &shadow_key);
 
   /* Blur the surface. */
-  cairo_recording_surface_ink_extents (recording_surface, &ink.x, &ink.y, &ink.width, &ink.height);
-  ink.width = ceil (ink.width + ink.x - floor (ink.x)) + 2 * ceil (radius);
-  ink.height = ceil (ink.height + ink.y - floor (ink.y)) + 2 * ceil (radius);
-  ink.x = floor (ink.x) + ceil (radius);
-  ink.y = floor (ink.y) + ceil (radius);
-
-  image_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, ink.width, ink.height);
-  cairo_surface_set_device_offset (image_surface, - ink.x, - ink.y);
-  
-  image_cr = cairo_create (image_surface);
-  cairo_set_source_surface (image_cr, recording_surface, 0, 0);
-  cairo_paint (image_cr);
-  cairo_destroy (image_cr);
-
-  _gtk_cairo_blur_surface (image_surface, radius);
-
-  cairo_set_source_surface (original_cr, image_surface, 0, 0);
+  _gtk_cairo_blur_surface (surface, radius);
+
+  cairo_set_source_surface (original_cr, surface, 0, 0);
   cairo_paint (original_cr);
 
   cairo_destroy (cr);
-  cairo_surface_destroy (image_surface);
+  cairo_surface_destroy (surface);
 
   return original_cr;
 }