[lasem] svg_view: reduce the number of informations stored on _start_pattern.



commit c7070406629914634f6d8768e87b57ecc3fa303f
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Fri Aug 27 15:17:19 2010 +0200

    svg_view: reduce the number of informations stored on _start_pattern.

 src/lsmsvgmaskelement.c    |    2 +-
 src/lsmsvgpatternelement.c |    1 -
 src/lsmsvgview.c           |   84 +++++++++++++++++++-------------------------
 src/lsmsvgview.h           |    1 -
 4 files changed, 37 insertions(+), 51 deletions(-)
---
diff --git a/src/lsmsvgmaskelement.c b/src/lsmsvgmaskelement.c
index 6b50de9..1213bff 100644
--- a/src/lsmsvgmaskelement.c
+++ b/src/lsmsvgmaskelement.c
@@ -94,7 +94,7 @@ lsm_svg_mask_element_render (LsmSvgElement *self, LsmSvgView *view)
 
 	if (!lsm_svg_view_create_surface_pattern (view, &viewport,
 						  mask->units.value,
-						  mask->content_units.value, NULL,
+						  NULL,
 						  LSM_SVG_VIEW_SURFACE_TYPE_IMAGE)) {
 		lsm_debug ("render", "[LsmSvgMaskElement::render] Intermediate surface creation failed");
 		lsm_svg_view_pop_style (view);
diff --git a/src/lsmsvgpatternelement.c b/src/lsmsvgpatternelement.c
index de4eab4..8fdf819 100644
--- a/src/lsmsvgpatternelement.c
+++ b/src/lsmsvgpatternelement.c
@@ -210,7 +210,6 @@ lsm_svg_pattern_element_render (LsmSvgElement *self, LsmSvgView *view)
 
 	if (!lsm_svg_view_create_surface_pattern (view, &image_box,
 						  pattern->units.value,
-						  pattern->content_units.value,
 						  &pattern->transform.matrix,
 						  LSM_SVG_VIEW_SURFACE_TYPE_AUTO)) {
 		lsm_debug ("render", "[LsmSvgPatternElement::render] Intermediate surface creation failed");
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index a17655a..3e35c7d 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -62,10 +62,6 @@ struct _LsmSvgViewPatternData {
 
 	LsmBox extents;
 
-	LsmSvgPatternUnits units;
-	LsmSvgPatternUnits content_units;
-	LsmSvgSpreadMethod spread_method;
-
 	double opacity;
 };
 
@@ -96,9 +92,6 @@ _start_pattern (LsmSvgView *view, const LsmBox *extents, double opacity)
 	view->pattern_data = g_new (LsmSvgViewPatternData, 1);
 	view->pattern_data->old_cairo = view->dom_view.cairo;
 	view->pattern_data->pattern = NULL;
-	view->pattern_data->content_units = LSM_SVG_PATTERN_UNITS_USER_SPACE_ON_USE;
-	view->pattern_data->units = LSM_SVG_PATTERN_UNITS_USER_SPACE_ON_USE;
-	view->pattern_data->spread_method = LSM_SVG_SPREAD_METHOD_REPEAT;
 	view->pattern_data->extents = *extents;
 	view->pattern_data->opacity = opacity;
 
@@ -209,9 +202,6 @@ lsm_svg_view_set_gradient_properties (LsmSvgView *view,
 	g_return_if_fail (LSM_IS_SVG_VIEW (view));
 	g_return_if_fail (view->pattern_data != NULL);
 
-	view->pattern_data->units = units;
-	view->pattern_data->spread_method = method;
-
 	if (matrix != NULL) {
 		cairo_matrix_init (&view->pattern_data->matrix,
 				   matrix->a, matrix->b,
@@ -220,13 +210,45 @@ lsm_svg_view_set_gradient_properties (LsmSvgView *view,
 		cairo_matrix_invert (&view->pattern_data->matrix);
 	} else
 		cairo_matrix_init_identity (&view->pattern_data->matrix);
+
+	if (units == LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX &&
+	    view->pattern_data->extents.width > 0.0 &&
+	    view->pattern_data->extents.height > 0.0) {
+		cairo_matrix_t matrix;
+
+		if (view->pattern_data->extents.width <= 0.0 ||
+		    view->pattern_data->extents.height <= 0.0) {
+			return;
+		}
+
+		matrix = view->pattern_data->matrix;
+
+		cairo_matrix_scale (&matrix,
+				    1.0 / view->pattern_data->extents.width,
+				    1.0 / view->pattern_data->extents.height);
+		cairo_matrix_translate (&matrix,
+					-view->pattern_data->extents.x,
+					-view->pattern_data->extents.y);
+
+		cairo_pattern_set_matrix (view->pattern_data->pattern, &matrix);
+	}
+
+	switch (method) {
+		case LSM_SVG_SPREAD_METHOD_REFLECT:
+			cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_REFLECT);
+			break;
+		case LSM_SVG_SPREAD_METHOD_REPEAT:
+			cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_REPEAT);
+			break;
+		default:
+			cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_PAD);
+	}
 }
 
 gboolean
 lsm_svg_view_create_surface_pattern (LsmSvgView *view,
 				     const LsmBox *viewport,
 				     LsmSvgPatternUnits units,
-				     LsmSvgPatternUnits content_units,
 				     const LsmSvgMatrix *matrix,
 				     LsmSvgViewSurfaceType surface_type)
 {
@@ -296,9 +318,6 @@ lsm_svg_view_create_surface_pattern (LsmSvgView *view,
 
 	_set_pattern (view, pattern);
 
-	view->pattern_data->units = units;
-	view->pattern_data->content_units = content_units;
-
 	if (matrix != NULL) {
 		cairo_matrix_init (&view->pattern_data->matrix,
 				   matrix->a, matrix->b,
@@ -311,6 +330,9 @@ lsm_svg_view_create_surface_pattern (LsmSvgView *view,
 		cairo_matrix_scale (&view->pattern_data->matrix, 1.0 / x_scale, 1.0 / y_scale);
 	}
 
+	cairo_pattern_set_matrix (view->pattern_data->pattern, &view->pattern_data->matrix);
+	cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_REPEAT);
+
 	return TRUE;
 }
 
@@ -792,40 +814,6 @@ _paint_url (LsmSvgView *view,
 		}
 #endif
 
-		if ((LSM_IS_SVG_RADIAL_GRADIENT_ELEMENT (element) || LSM_IS_SVG_LINEAR_GRADIENT_ELEMENT (element)) &&
-		    view->pattern_data->units == LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX) {
-			cairo_matrix_t matrix;
-
-			if (view->pattern_data->extents.width <= 0.0 ||
-			    view->pattern_data->extents.height <= 0.0) {
-				_end_pattern (view);
-				return;
-			}
-
-			matrix = view->pattern_data->matrix;
-
-			cairo_matrix_scale (&matrix,
-						 1.0 / view->pattern_data->extents.width,
-						 1.0 / view->pattern_data->extents.height);
-			cairo_matrix_translate (&matrix,
-						-view->pattern_data->extents.x,
-						-view->pattern_data->extents.y);
-
-			cairo_pattern_set_matrix (view->pattern_data->pattern, &matrix);
-		} else
-			cairo_pattern_set_matrix (view->pattern_data->pattern, &view->pattern_data->matrix);
-
-		switch (view->pattern_data->spread_method) {
-			case LSM_SVG_SPREAD_METHOD_REFLECT:
-				cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_REFLECT);
-				break;
-			case LSM_SVG_SPREAD_METHOD_REPEAT:
-				cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_REPEAT);
-				break;
-			default:
-				cairo_pattern_set_extend (view->pattern_data->pattern, CAIRO_EXTEND_PAD);
-		}
-
 		cairo_set_source (cairo, view->pattern_data->pattern);
 	} else
 		cairo_set_source_rgb (cairo, 0.0, 0.0, 0.0);
diff --git a/src/lsmsvgview.h b/src/lsmsvgview.h
index 62227c4..f5be44a 100644
--- a/src/lsmsvgview.h
+++ b/src/lsmsvgview.h
@@ -103,7 +103,6 @@ void 		lsm_svg_view_set_gradient_properties	(LsmSvgView *view,
 
 gboolean	lsm_svg_view_create_surface_pattern	(LsmSvgView *view, const LsmBox *viewport,
 							 LsmSvgPatternUnits units,
-							 LsmSvgPatternUnits content_units,
 							 const LsmSvgMatrix *matrix,
 							 LsmSvgViewSurfaceType surface_type) G_GNUC_WARN_UNUSED_RESULT;
 



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