[lasem/filters] <svg:filter> Start the implementation.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: svn-commits-list gnome org
- Subject: [lasem/filters] <svg:filter> Start the implementation.
- Date: Sat, 11 Jul 2009 14:33:17 +0000 (UTC)
commit bc28b46058946b45b88ea30221f6e74664cce637
Author: Emmanuel Pacaud <emmanuel pacaud lapp in2p3 fr>
Date: Sat Jul 11 16:32:09 2009 +0200
<svg:filter> Start the implementation.
Which does nothing yet.
src/Makefile.am | 6 +
src/lsmsvg.h | 3 +
src/lsmsvgattributebags.c | 4 +
src/lsmsvgattributebags.h | 1 +
src/lsmsvgdocument.c | 6 +
src/lsmsvgfegaussianblur.c | 214 +++++++++++++++++++++++++++++++++++++++++++
src/lsmsvgfegaussianblur.h | 55 +++++++++++
src/lsmsvgfilterelement.c | 121 ++++++++++++++++++++++++
src/lsmsvgfilterelement.h | 60 ++++++++++++
src/lsmsvgfilterprimitive.c | 92 ++++++++++++++++++
src/lsmsvgfilterprimitive.h | 58 ++++++++++++
11 files changed, 620 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index dc76bd8..13e8461 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -84,6 +84,9 @@ liblasem_la_SOURCES = \
lsmsvgstopelement.c \
lsmsvgpatternelement.c \
lsmsvgmaskelement.c \
+ lsmsvgfilterelement.c \
+ lsmsvgfilterprimitive.c \
+ lsmsvgfegaussianblur.c \
lsmsvgenums.c \
lsmsvgattributes.c \
lsmsvgattributebags.c \
@@ -167,6 +170,9 @@ liblasem_la_HEADERS = \
lsmsvgstopelement.h \
lsmsvgpatternelement.h \
lsmsvgmaskelement.h \
+ lsmsvgfilterelement.h \
+ lsmsvgfilterprimitive.h \
+ lsmsvgfegaussianblur.h \
lsmsvgenums.h \
lsmsvgattributes.h \
lsmsvgattributebags.h \
diff --git a/src/lsmsvg.h b/src/lsmsvg.h
index 43bc421..f8102d3 100644
--- a/src/lsmsvg.h
+++ b/src/lsmsvg.h
@@ -50,6 +50,9 @@ typedef struct _LsmSvgRadialGradientElement LsmSvgRadialGradientElement;
typedef struct _LsmSvgStopElement LsmSvgStopElement;
typedef struct _LsmSvgPatternElement LsmSvgPatternElement;
typedef struct _LsmSvgMaskElement LsmSvgMaskElement;
+typedef struct _LsmSvgFilterElement LsmSvgFilterElement;
+typedef struct _LsmSvgFilterPrimitive LsmSvgFilterPrimitive;
+typedef struct _LsmSvgFeGaussianBlur LsmSvgFeGaussianBlur;
typedef struct _LsmSvgView LsmSvgView;
typedef struct _LsmSvgStyle LsmSvgStyle;
diff --git a/src/lsmsvgattributebags.c b/src/lsmsvgattributebags.c
index 923498f..c5744f7 100644
--- a/src/lsmsvgattributebags.c
+++ b/src/lsmsvgattributebags.c
@@ -61,6 +61,10 @@ lsm_dom_attribute_map_add_mask_attribute_bag (LsmDomAttributeMap *map, ptrdiff_t
offsetof (LsmSvgMaskAttributeBag, mask),
NULL,
bag_offset, &lsm_svg_mask_attribute_bag_class);
+ lsm_dom_attribute_map_add_bag_attribute (map, "filter",
+ offsetof (LsmSvgMaskAttributeBag, filter),
+ NULL,
+ bag_offset, &lsm_svg_mask_attribute_bag_class);
}
static void *
diff --git a/src/lsmsvgattributebags.h b/src/lsmsvgattributebags.h
index 73b7311..47305a6 100644
--- a/src/lsmsvgattributebags.h
+++ b/src/lsmsvgattributebags.h
@@ -32,6 +32,7 @@ typedef struct {
LsmDomAttribute clip_path;
LsmDomEnumAttribute clip_rule;
LsmDomAttribute mask;
+ LsmDomAttribute filter;
} LsmSvgMaskAttributeBag;
typedef struct {
diff --git a/src/lsmsvgdocument.c b/src/lsmsvgdocument.c
index 3c41c33..ce8d6e8 100644
--- a/src/lsmsvgdocument.c
+++ b/src/lsmsvgdocument.c
@@ -41,6 +41,8 @@
#include <lsmsvgstopelement.h>
#include <lsmsvgpatternelement.h>
#include <lsmsvgmaskelement.h>
+#include <lsmsvgfilterelement.h>
+#include <lsmsvgfegaussianblur.h>
#include <lsmsvgview.h>
#include <string.h>
@@ -99,6 +101,10 @@ lsm_svg_document_create_element (LsmDomDocument *document, const char *tag_name)
node = lsm_svg_symbol_element_new ();
else if (strcmp (tag_name, "clipPath") == 0)
node = lsm_svg_clip_path_element_new ();
+ else if (strcmp (tag_name, "filter") == 0)
+ node = lsm_svg_filter_element_new ();
+ else if (strcmp (tag_name, "feGaussianBlur") == 0)
+ node = lsm_svg_fe_gaussian_blur_new ();
if (node != NULL)
lsm_debug ("[LsmSvgDocument::create_element] Create a %s element", tag_name);
diff --git a/src/lsmsvgfegaussianblur.c b/src/lsmsvgfegaussianblur.c
new file mode 100644
index 0000000..9d343e0
--- /dev/null
+++ b/src/lsmsvgfegaussianblur.c
@@ -0,0 +1,214 @@
+/*
+ * Copyright © 2009 Emmanuel Pacaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <lsmsvgfegaussianblur.h>
+#include <lsmsvgview.h>
+#include <lsmdebug.h>
+#include <stdio.h>
+
+static GObjectClass *parent_class;
+
+/* GdomNode implementation */
+
+static const char *
+lsm_svg_fe_gaussian_blur_get_node_name (LsmDomNode *node)
+{
+ return "feGaussianBlur";
+}
+
+/* LsmSvgElement implementation */
+
+static void
+lsm_svg_fe_gaussian_blur_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
+{
+ LSM_SVG_ELEMENT_CLASS (parent_class)->update (self, parent_style);
+}
+
+#if 0
+static void
+box_blur (GdkPixbuf * in, GdkPixbuf * output, guchar * intermediate, gint kw,
+ gint kh, RsvgIRect boundarys, RsvgFilterPrimitiveOutput op)
+{
+ gint ch;
+ gint x, y;
+ gint rowstride, height, width;
+
+ guchar *in_pixels;
+ guchar *output_pixels;
+
+ gint sum;
+
+
+ height = gdk_pixbuf_get_height (in);
+ width = gdk_pixbuf_get_width (in);
+
+ in_pixels = gdk_pixbuf_get_pixels (in);
+ output_pixels = gdk_pixbuf_get_pixels (output);
+
+ rowstride = gdk_pixbuf_get_rowstride (in);
+
+ if (kw > boundarys.x1 - boundarys.x0)
+ kw = boundarys.x1 - boundarys.x0;
+
+ if (kh > boundarys.y1 - boundarys.y0)
+ kh = boundarys.y1 - boundarys.y0;
+
+
+ if (kw >= 1) {
+ for (ch = 0; ch < 4; ch++) {
+ switch (ch) {
+ case 0:
+ if (!op.Rused)
+ continue;
+ case 1:
+ if (!op.Gused)
+ continue;
+ case 2:
+ if (!op.Bused)
+ continue;
+ case 3:
+ if (!op.Aused)
+ continue;
+ }
+ for (y = boundarys.y0; y < boundarys.y1; y++) {
+ sum = 0;
+ for (x = boundarys.x0; x < boundarys.x0 + kw; x++) {
+ sum += (intermediate[x % kw] = in_pixels[4 * x + y * rowstride + ch]);
+
+ if (x - kw / 2 >= 0 && x - kw / 2 < boundarys.x1)
+ output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
+ }
+ for (x = boundarys.x0 + kw; x < boundarys.x1; x++) {
+ sum -= intermediate[x % kw];
+ sum += (intermediate[x % kw] = in_pixels[4 * x + y * rowstride + ch]);
+ output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
+ }
+ for (x = boundarys.x1; x < boundarys.x1 + kw; x++) {
+ sum -= intermediate[x % kw];
+
+ if (x - kw / 2 >= 0 && x - kw / 2 < boundarys.x1)
+ output_pixels[4 * (x - kw / 2) + y * rowstride + ch] = sum / kw;
+ }
+ }
+ }
+ in_pixels = output_pixels;
+ }
+
+ if (kh >= 1) {
+ for (ch = 0; ch < 4; ch++) {
+ switch (ch) {
+ case 0:
+ if (!op.Rused)
+ continue;
+ case 1:
+ if (!op.Gused)
+ continue;
+ case 2:
+ if (!op.Bused)
+ continue;
+ case 3:
+ if (!op.Aused)
+ continue;
+ }
+
+
+ for (x = boundarys.x0; x < boundarys.x1; x++) {
+ sum = 0;
+
+ for (y = boundarys.y0; y < boundarys.y0 + kh; y++) {
+ sum += (intermediate[y % kh] = in_pixels[4 * x + y * rowstride + ch]);
+
+ if (y - kh / 2 >= 0 && y - kh / 2 < boundarys.y1)
+ output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
+ }
+ for (; y < boundarys.y1; y++) {
+ sum -= intermediate[y % kh];
+ sum += (intermediate[y % kh] = in_pixels[4 * x + y * rowstride + ch]);
+ output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
+ }
+ for (; y < boundarys.y1 + kh; y++) {
+ sum -= intermediate[y % kh];
+
+ if (y - kh / 2 >= 0 && y - kh / 2 < boundarys.y1)
+ output_pixels[4 * x + (y - kh / 2) * rowstride + ch] = sum / kh;
+ }
+ }
+ }
+ }
+}
+
+static void
+fast_blur (GdkPixbuf * in, GdkPixbuf * output, gfloat sx,
+ gfloat sy, RsvgIRect boundarys, RsvgFilterPrimitiveOutput op)
+{
+ gint kx, ky;
+ guchar *intermediate;
+
+ kx = floor (sx * 3 * sqrt (2 * M_PI) / 4 + 0.5);
+ ky = floor (sy * 3 * sqrt (2 * M_PI) / 4 + 0.5);
+
+ if (kx < 1 && ky < 1)
+ return;
+
+ intermediate = g_new (guchar, MAX (kx, ky));
+
+ box_blur (in, output, intermediate, kx, ky, boundarys, op);
+ box_blur (output, output, intermediate, kx, ky, boundarys, op);
+ box_blur (output, output, intermediate, kx, ky, boundarys, op);
+
+ g_free (intermediate);
+}
+#endif
+
+/* LsmSvgFeGaussianBlur implementation */
+
+LsmDomNode *
+lsm_svg_fe_gaussian_blur_new (void)
+{
+ return g_object_new (LSM_TYPE_SVG_FE_GAUSSIAN_BLUR, NULL);
+}
+
+static void
+lsm_svg_fe_gaussian_blur_init (LsmSvgFeGaussianBlur *self)
+{
+}
+
+/* LsmSvgFeGaussianBlur class */
+
+static void
+lsm_svg_fe_gaussian_blur_class_init (LsmSvgFeGaussianBlurClass *klass)
+{
+ LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (klass);
+ LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ d_node_class->get_node_name = lsm_svg_fe_gaussian_blur_get_node_name;
+
+ s_element_class->update = lsm_svg_fe_gaussian_blur_update;
+
+ s_element_class->attributes = lsm_dom_attribute_map_duplicate (s_element_class->attributes);
+
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "stdDeviation",
+ offsetof (LsmSvgFeGaussianBlur, std_deviation));
+}
+
+G_DEFINE_TYPE (LsmSvgFeGaussianBlur, lsm_svg_fe_gaussian_blur, LSM_TYPE_SVG_FILTER_PRIMITIVE)
diff --git a/src/lsmsvgfegaussianblur.h b/src/lsmsvgfegaussianblur.h
new file mode 100644
index 0000000..c92ccf7
--- /dev/null
+++ b/src/lsmsvgfegaussianblur.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2009 Emmanuel Pacaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef LSM_SVG_FE_GAUSSIAN_BLUR_H
+#define LSM_SVG_FE_GAUSSIAN_BLUR_H
+
+#include <lsmsvg.h>
+#include <lsmsvgfilterprimitive.h>
+
+G_BEGIN_DECLS
+
+#define LSM_TYPE_SVG_FE_GAUSSIAN_BLUR (lsm_svg_fe_gaussian_blur_get_type ())
+#define LSM_SVG_FE_GAUSSIAN_BLUR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_SVG_FE_GAUSSIAN_BLUR, LsmSvgFeGaussianBlur))
+#define LSM_SVG_FE_GAUSSIAN_BLUR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_SVG_FE_GAUSSIAN_BLUR, LsmSvgFeGaussianBlurClass))
+#define LSM_IS_SVG_FE_GAUSSIAN_BLUR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_SVG_FE_GAUSSIAN_BLUR))
+#define LSM_IS_SVG_FE_GAUSSIAN_BLUR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_SVG_FE_GAUSSIAN_BLUR))
+#define LSM_SVG_FE_GAUSSIAN_BLUR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_SVG_FE_GAUSSIAN_BLUR, LsmSvgFeGaussianBlurClass))
+
+typedef struct _LsmSvgFeGaussianBlurClass LsmSvgFeGaussianBlurClass;
+
+struct _LsmSvgFeGaussianBlur {
+ LsmSvgFilterPrimitive primitive;
+
+ LsmDomAttribute std_deviation;
+};
+
+struct _LsmSvgFeGaussianBlurClass {
+ LsmSvgFilterPrimitiveClass parent_class;
+};
+
+GType lsm_svg_fe_gaussian_blur_get_type (void);
+
+LsmDomNode * lsm_svg_fe_gaussian_blur_new (void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/lsmsvgfilterelement.c b/src/lsmsvgfilterelement.c
new file mode 100644
index 0000000..b7fcb4f
--- /dev/null
+++ b/src/lsmsvgfilterelement.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright © 2009 Emmanuel Pacaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <lsmsvgfilterelement.h>
+#include <lsmsvgview.h>
+#include <lsmdebug.h>
+#include <stdio.h>
+
+static GObjectClass *parent_class;
+
+/* GdomNode implementation */
+
+static const char *
+_filter_element_get_node_name (LsmDomNode *node)
+{
+ return "filter";
+}
+
+/* LsmSvgElement implementation */
+
+static void
+_filter_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
+{
+ LsmSvgFilterElement *filter = LSM_SVG_FILTER_ELEMENT (self);
+ LsmSvgPatternUnits units;
+ LsmSvgLength length;
+
+ units = LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX;
+ lsm_svg_pattern_units_attribute_parse (&filter->filter_units, &units);
+
+ units = LSM_SVG_PATTERN_UNITS_USER_SPACE_ON_USE;
+ lsm_svg_pattern_units_attribute_parse (&filter->primitive_units, &units);
+
+ length.value_unit = -10.0;
+ length.type = LSM_SVG_LENGTH_TYPE_PERCENTAGE;
+ lsm_svg_animated_length_attribute_parse (&filter->x, &length);
+
+ length.value_unit = -10.0;
+ length.type = LSM_SVG_LENGTH_TYPE_PERCENTAGE;
+ lsm_svg_animated_length_attribute_parse (&filter->y, &length);
+
+ length.value_unit = 120.0;
+ length.type = LSM_SVG_LENGTH_TYPE_PERCENTAGE;
+ lsm_svg_animated_length_attribute_parse (&filter->width, &length);
+
+ length.value_unit = 120.0;
+ length.type = LSM_SVG_LENGTH_TYPE_PERCENTAGE;
+ lsm_svg_animated_length_attribute_parse (&filter->height, &length);
+
+ LSM_SVG_ELEMENT_CLASS (parent_class)->update (self, parent_style);
+}
+
+static void
+_filter_element_render_paint (LsmSvgElement *self, LsmSvgView *view)
+{
+}
+
+/* LsmSvgFilterElement implementation */
+
+LsmDomNode *
+lsm_svg_filter_element_new (void)
+{
+ return g_object_new (LSM_TYPE_SVG_FILTER_ELEMENT, NULL);
+}
+
+static void
+lsm_svg_filter_element_init (LsmSvgFilterElement *self)
+{
+}
+
+/* LsmSvgFilterElement class */
+
+static void
+lsm_svg_filter_element_class_init (LsmSvgFilterElementClass *klass)
+{
+ LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (klass);
+ LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ d_node_class->get_node_name = _filter_element_get_node_name;
+
+ s_element_class->update = _filter_element_update;
+ s_element_class->render_paint = _filter_element_render_paint;
+ s_element_class->render = NULL;
+
+ s_element_class->attributes = lsm_dom_attribute_map_duplicate (s_element_class->attributes);
+
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "x",
+ offsetof (LsmSvgFilterElement, x));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "y",
+ offsetof (LsmSvgFilterElement, y));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "width",
+ offsetof (LsmSvgFilterElement, width));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "height",
+ offsetof (LsmSvgFilterElement, height));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "filterUnits",
+ offsetof (LsmSvgFilterElement, filter_units));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "primitiveUnits",
+ offsetof (LsmSvgFilterElement, primitive_units));
+}
+
+G_DEFINE_TYPE (LsmSvgFilterElement, lsm_svg_filter_element, LSM_TYPE_SVG_GRAPHIC)
diff --git a/src/lsmsvgfilterelement.h b/src/lsmsvgfilterelement.h
new file mode 100644
index 0000000..e62073a
--- /dev/null
+++ b/src/lsmsvgfilterelement.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2009 Emmanuel Pacaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef LSM_SVG_FILTER_ELEMENT_H
+#define LSM_SVG_FILTER_ELEMENT_H
+
+#include <lsmsvg.h>
+#include <lsmsvggraphic.h>
+
+G_BEGIN_DECLS
+
+#define LSM_TYPE_SVG_FILTER_ELEMENT (lsm_svg_filter_element_get_type ())
+#define LSM_SVG_FILTER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_SVG_FILTER_ELEMENT, LsmSvgFilterElement))
+#define LSM_SVG_FILTER_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_SVG_FILTER_ELEMENT, LsmSvgFilterElementClass))
+#define LSM_IS_SVG_FILTER_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_SVG_FILTER_ELEMENT))
+#define LSM_IS_SVG_FILTER_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_SVG_FILTER_ELEMENT))
+#define LSM_SVG_FILTER_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_SVG_FILTER_ELEMENT, LsmSvgFilterElementClass))
+
+typedef struct _LsmSvgFilterElementClass LsmSvgFilterElementClass;
+
+struct _LsmSvgFilterElement {
+ LsmSvgGraphic graphic;
+
+ LsmSvgAnimatedLengthAttribute x;
+ LsmSvgAnimatedLengthAttribute y;
+ LsmSvgAnimatedLengthAttribute width;
+ LsmSvgAnimatedLengthAttribute height;
+ LsmDomEnumAttribute filter_units;
+ LsmDomEnumAttribute primitive_units;
+};
+
+struct _LsmSvgFilterElementClass {
+ LsmSvgGraphicClass parent_class;
+};
+
+GType lsm_svg_filter_element_get_type (void);
+
+LsmDomNode * lsm_svg_filter_element_new (void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/lsmsvgfilterprimitive.c b/src/lsmsvgfilterprimitive.c
new file mode 100644
index 0000000..8c14769
--- /dev/null
+++ b/src/lsmsvgfilterprimitive.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2009 Emmanuel Pacaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <lsmsvgfilterprimitive.h>
+#include <lsmsvgview.h>
+#include <lsmdebug.h>
+#include <stdio.h>
+
+static GObjectClass *parent_class;
+
+/* GdomNode implementation */
+
+/* LsmSvgElement implementation */
+
+static void
+_filter_primitive_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
+{
+ LsmSvgFilterPrimitive *primitive = LSM_SVG_FILTER_PRIMITIVE (self);
+ LsmSvgLength length;
+
+ length.value_unit = 0.0;
+ length.type = LSM_SVG_LENGTH_TYPE_PERCENTAGE;
+ lsm_svg_animated_length_attribute_parse (&primitive->x, &length);
+
+ length.value_unit = 0.0;
+ length.type = LSM_SVG_LENGTH_TYPE_PERCENTAGE;
+ lsm_svg_animated_length_attribute_parse (&primitive->y, &length);
+
+ length.value_unit = 100.0;
+ length.type = LSM_SVG_LENGTH_TYPE_PERCENTAGE;
+ lsm_svg_animated_length_attribute_parse (&primitive->width, &length);
+
+ length.value_unit = 100.0;
+ length.type = LSM_SVG_LENGTH_TYPE_PERCENTAGE;
+ lsm_svg_animated_length_attribute_parse (&primitive->height, &length);
+
+ LSM_SVG_ELEMENT_CLASS (parent_class)->update (self, parent_style);
+}
+
+/* LsmSvgFilterPrimitive implementation */
+
+static void
+lsm_svg_filter_primitive_init (LsmSvgFilterPrimitive *self)
+{
+}
+
+/* LsmSvgFilterPrimitive class */
+
+static void
+lsm_svg_filter_primitive_class_init (LsmSvgFilterPrimitiveClass *klass)
+{
+ LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ s_element_class->update = _filter_primitive_update;
+
+ s_element_class->attributes = lsm_dom_attribute_map_duplicate (s_element_class->attributes);
+
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "x",
+ offsetof (LsmSvgFilterPrimitive, x));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "y",
+ offsetof (LsmSvgFilterPrimitive, y));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "width",
+ offsetof (LsmSvgFilterPrimitive, width));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "height",
+ offsetof (LsmSvgFilterPrimitive, height));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "result",
+ offsetof (LsmSvgFilterPrimitive, result));
+ lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "in",
+ offsetof (LsmSvgFilterPrimitive, input));
+}
+
+G_DEFINE_ABSTRACT_TYPE (LsmSvgFilterPrimitive, lsm_svg_filter_primitive, LSM_TYPE_SVG_GRAPHIC)
diff --git a/src/lsmsvgfilterprimitive.h b/src/lsmsvgfilterprimitive.h
new file mode 100644
index 0000000..4cf2718
--- /dev/null
+++ b/src/lsmsvgfilterprimitive.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright © 2009 Emmanuel Pacaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef LSM_SVG_FILTER_PRIMITIVE_H
+#define LSM_SVG_FILTER_PRIMITIVE_H
+
+#include <lsmsvg.h>
+#include <lsmsvggraphic.h>
+
+G_BEGIN_DECLS
+
+#define LSM_TYPE_SVG_FILTER_PRIMITIVE (lsm_svg_filter_primitive_get_type ())
+#define LSM_SVG_FILTER_PRIMITIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_SVG_FILTER_PRIMITIVE, LsmSvgFilterPrimitive))
+#define LSM_SVG_FILTER_PRIMITIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_SVG_FILTER_PRIMITIVE, LsmSvgFilterPrimitiveClass))
+#define LSM_IS_SVG_FILTER_PRIMITIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_SVG_FILTER_PRIMITIVE))
+#define LSM_IS_SVG_FILTER_PRIMITIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_SVG_FILTER_PRIMITIVE))
+#define LSM_SVG_FILTER_PRIMITIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_SVG_FILTER_PRIMITIVE, LsmSvgFilterPrimitiveClass))
+
+typedef struct _LsmSvgFilterPrimitiveClass LsmSvgFilterPrimitiveClass;
+
+struct _LsmSvgFilterPrimitive {
+ LsmSvgGraphic graphic;
+
+ LsmSvgAnimatedLengthAttribute x;
+ LsmSvgAnimatedLengthAttribute y;
+ LsmSvgAnimatedLengthAttribute width;
+ LsmSvgAnimatedLengthAttribute height;
+ LsmDomAttribute result;
+ LsmDomAttribute input;
+};
+
+struct _LsmSvgFilterPrimitiveClass {
+ LsmSvgGraphicClass parent_class;
+};
+
+GType lsm_svg_filter_primitive_get_type (void);
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]