[lasem] svg_filter: actually do something for feTile.



commit 01518d64803c674b63565dd4f3470cd9d7e4a18e
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Fri Oct 19 23:11:29 2012 +0200

    svg_filter: actually do something for feTile.

 src/lsmcairo.c              |   29 +++++++++++++++++++++++++++++
 src/lsmcairo.h              |    2 ++
 src/lsmsvgfilterprimitive.c |    2 +-
 src/lsmsvgview.c            |   15 +++++++++++++++
 4 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/src/lsmcairo.c b/src/lsmcairo.c
index c2f1313..d031042 100644
--- a/src/lsmcairo.c
+++ b/src/lsmcairo.c
@@ -419,6 +419,35 @@ lsm_filter_surface_merge (LsmFilterSurface *input,
 }
 
 void
+lsm_filter_surface_tile (LsmFilterSurface *input, LsmFilterSurface *output, const LsmBox *subregion)
+{
+	cairo_t *cairo;
+	cairo_surface_t *surface;
+	cairo_pattern_t *pattern;
+
+	g_return_if_fail (input != NULL);
+	g_return_if_fail (output != NULL);
+
+	surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, input->subregion.width, input->subregion.height);
+	cairo = cairo_create (surface);
+	cairo_set_source_surface (cairo, input->surface, input->subregion.x, input->subregion.y);
+	cairo_paint (cairo);
+	cairo_destroy (cairo);
+
+	cairo = cairo_create (output->surface);
+	if (subregion != NULL) {
+		cairo_rectangle (cairo, subregion->x, subregion->y, subregion->width, subregion->height);
+		cairo_clip (cairo);
+	}
+	cairo_set_source_surface (cairo, surface, 0, 0);
+	pattern = cairo_get_source (cairo);
+	cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+	cairo_paint (cairo);
+	cairo_destroy (cairo);
+	cairo_surface_destroy (surface);
+}
+
+void
 lsm_filter_surface_alpha (LsmFilterSurface *input, LsmFilterSurface *output)
 {
 	cairo_t *cairo;
diff --git a/src/lsmcairo.h b/src/lsmcairo.h
index 782c038..4068f37 100644
--- a/src/lsmcairo.h
+++ b/src/lsmcairo.h
@@ -62,6 +62,8 @@ void 			lsm_filter_surface_offset 		(LsmFilterSurface *input, LsmFilterSurface *
 								const LsmBox *subregion, int dx, int dy);
 void 			lsm_filter_surface_merge 		(LsmFilterSurface *input, LsmFilterSurface *output,
 								 const LsmBox *subregion);
+void 			lsm_filter_surface_tile 		(LsmFilterSurface *input, LsmFilterSurface *output,
+								 const LsmBox *subregion);
 
 void 			lsm_cairo_box_user_to_device 		(cairo_t *cairo, LsmBox *to, const LsmBox *from);
 void 			lsm_cairo_box_device_to_user 		(cairo_t *cairo, LsmBox *to, const LsmBox *from);
diff --git a/src/lsmsvgfilterprimitive.c b/src/lsmsvgfilterprimitive.c
index 5d2ec14..1393667 100644
--- a/src/lsmsvgfilterprimitive.c
+++ b/src/lsmsvgfilterprimitive.c
@@ -59,7 +59,7 @@ lsm_svg_filter_primitive_apply  (LsmSvgFilterPrimitive *self, LsmSvgView *view)
 	is_width_defined = lsm_attribute_is_defined (&self->width.base);
 	is_height_defined = lsm_attribute_is_defined (&self->height.base);
 
-	subregion = lsm_svg_view_get_filter_surface_extents (view, self->in.value);
+	subregion = lsm_svg_view_get_filter_surface_extents (view, "SourceGraphic");
 
 	if (is_x_defined)
 		subregion.x = lsm_svg_view_normalize_length (view, &self->x.length, LSM_SVG_LENGTH_DIRECTION_HORIZONTAL);
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index d6aa406..32ceda0 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -2245,6 +2245,21 @@ lsm_svg_view_apply_merge (LsmSvgView *view, const char *input, const char *outpu
 void
 lsm_svg_view_apply_tile (LsmSvgView *view, const char *input, const char *output, const LsmBox *subregion)
 {
+	LsmFilterSurface *input_surface;
+	LsmFilterSurface *output_surface;
+	LsmBox subregion_px;
+
+	input_surface = _get_filter_surface (view, input);
+
+	if (input_surface == NULL) {
+		lsm_debug_render ("[SvgView::apply_offset] Input '%s' not found", input);
+		return;
+	}
+
+	lsm_cairo_box_user_to_device (view->dom_view.cairo, &subregion_px, subregion);
+	output_surface = _create_filter_surface (view, output, input_surface, &subregion_px);
+
+	lsm_filter_surface_tile (input_surface, output_surface, &subregion_px);
 }
 
 void



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