[librsvg/next: 13/31] Use cairo_extend_t directly



commit c41549fa67677b7d1129663072b4cc75574ad569
Author: Christian Persch <chpe gnome org>
Date:   Thu Sep 15 15:46:05 2011 +0200

    Use cairo_extend_t directly

 rsvg-cairo-draw.c   |   12 ++----------
 rsvg-paint-server.c |   16 ++++++++--------
 rsvg-paint-server.h |   11 +++--------
 3 files changed, 13 insertions(+), 26 deletions(-)
---
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index c8ec347..716709e 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -136,11 +136,7 @@ _set_source_rsvg_linear_gradient (RsvgDrawingCtx * ctx,
     }
     cairo_matrix_invert (&matrix);
     cairo_pattern_set_matrix (pattern, &matrix);
-
-    if (linear->spread == RSVG_GRADIENT_REFLECT)
-        cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REFLECT);
-    else if (linear->spread == RSVG_GRADIENT_REPEAT)
-        cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+    cairo_pattern_set_extend (pattern, linear->spread);
 
     _pattern_add_rsvg_color_stops (pattern, linear->super.children, current_color_rgb, opacity);
 
@@ -187,11 +183,7 @@ _set_source_rsvg_radial_gradient (RsvgDrawingCtx * ctx,
 
     cairo_matrix_invert (&matrix);
     cairo_pattern_set_matrix (pattern, &matrix);
-
-    if (radial->spread == RSVG_GRADIENT_REFLECT)
-        cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REFLECT);
-    else if (radial->spread == RSVG_GRADIENT_REPEAT)
-        cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+    cairo_pattern_set_extend (pattern, radial->spread);
 
     _pattern_add_rsvg_color_stops (pattern, radial->super.children, current_color_rgb, opacity);
 
diff --git a/rsvg-paint-server.c b/rsvg-paint-server.c
index 7903684..f4a873e 100644
--- a/rsvg-paint-server.c
+++ b/rsvg-paint-server.c
@@ -258,11 +258,11 @@ rsvg_linear_gradient_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBa
         }
         if ((value = rsvg_property_bag_lookup (atts, "spreadMethod"))) {
             if (!strcmp (value, "pad")) {
-                grad->spread = RSVG_GRADIENT_PAD;
+                grad->spread = CAIRO_EXTEND_PAD;
             } else if (!strcmp (value, "reflect")) {
-                grad->spread = RSVG_GRADIENT_REFLECT;
+                grad->spread = CAIRO_EXTEND_REFLECT;
             } else if (!strcmp (value, "repeat")) {
-                grad->spread = RSVG_GRADIENT_REPEAT;
+                grad->spread = CAIRO_EXTEND_REPEAT;
             }
             grad->hasspread = TRUE;
         }
@@ -300,7 +300,7 @@ rsvg_new_linear_gradient (void)
     grad->x2 = _rsvg_css_parse_length ("1");
     grad->fallback = NULL;
     grad->obj_bbox = TRUE;
-    grad->spread = RSVG_GRADIENT_PAD;
+    grad->spread = CAIRO_EXTEND_PAD;
     grad->super.set_atts = rsvg_linear_gradient_set_atts;
     grad->hasx1 = grad->hasy1 = grad->hasx2 = grad->hasy2 = grad->hasbbox = grad->hasspread =
         grad->hastransform = FALSE;
@@ -353,11 +353,11 @@ rsvg_radial_gradient_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBa
         }
         if ((value = rsvg_property_bag_lookup (atts, "spreadMethod"))) {
             if (!strcmp (value, "pad"))
-                grad->spread = RSVG_GRADIENT_PAD;
+                grad->spread = CAIRO_EXTEND_PAD;
             else if (!strcmp (value, "reflect"))
-                grad->spread = RSVG_GRADIENT_REFLECT;
+                grad->spread = CAIRO_EXTEND_REFLECT;
             else if (!strcmp (value, "repeat"))
-                grad->spread = RSVG_GRADIENT_REPEAT;
+                grad->spread = CAIRO_EXTEND_REPEAT;
             grad->hasspread = TRUE;
         }
         if ((value = rsvg_property_bag_lookup (atts, "gradientUnits"))) {
@@ -380,7 +380,7 @@ rsvg_new_radial_gradient (void)
     _rsvg_affine_identity (grad->affine);
     grad->has_current_color = FALSE;
     grad->obj_bbox = TRUE;
-    grad->spread = RSVG_GRADIENT_PAD;
+    grad->spread = CAIRO_EXTEND_PAD;
     grad->fallback = NULL;
     grad->cx = grad->cy = grad->r = grad->fx = grad->fy = _rsvg_css_parse_length ("0.5");
     grad->super.set_atts = rsvg_radial_gradient_set_atts;
diff --git a/rsvg-paint-server.h b/rsvg-paint-server.h
index 2aab05c..01a99ea 100644
--- a/rsvg-paint-server.h
+++ b/rsvg-paint-server.h
@@ -28,6 +28,7 @@
 #define RSVG_PAINT_SERVER_H
 
 #include <glib.h>
+#include <cairo.h>
 #include "rsvg-defs.h"
 
 G_BEGIN_DECLS 
@@ -43,12 +44,6 @@ typedef struct _RsvgPaintServer RsvgPaintServer;
 
 typedef struct _RsvgPSCtx RsvgPSCtx;
 
-typedef enum {
-    RSVG_GRADIENT_PAD,
-    RSVG_GRADIENT_REFLECT,
-    RSVG_GRADIENT_REPEAT
-} RsvgGradientSpread;
-
 struct _RsvgGradientStop {
     RsvgNode super;
     double offset;
@@ -59,7 +54,7 @@ struct _RsvgLinearGradient {
     RsvgNode super;
     gboolean obj_bbox;
     double affine[6];           /* user space to actual at time of gradient def */
-    RsvgGradientSpread spread;
+    cairo_extend_t spread;
     RsvgLength x1, y1, x2, y2;
     guint32 current_color;
     gboolean has_current_color;
@@ -77,7 +72,7 @@ struct _RsvgRadialGradient {
     RsvgNode super;
     gboolean obj_bbox;
     double affine[6];           /* user space to actual at time of gradient def */
-    RsvgGradientSpread spread;
+    cairo_extend_t spread;
     RsvgLength cx, cy, r, fx, fy;
     guint32 current_color;
     gboolean has_current_color;



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