[lasem] svg_filter: feSpecularLighting boilerplate.



commit 6e5ab2dcb4853e508d453c0226f79b1819435772
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Sat Oct 20 15:30:19 2012 +0200

    svg_filter: feSpecularLighting boilerplate.

 docs/reference/lasem/Makefile.am   |    1 +
 src/Makefile.am                    |    2 +
 src/lsmsvgdocument.c               |    3 +
 src/lsmsvgfilterspecularlighting.c |  127 ++++++++++++++++++++++++++++++++++++
 src/lsmsvgfilterspecularlighting.h |   60 +++++++++++++++++
 src/lsmsvgtypes.h                  |    1 +
 6 files changed, 194 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/lasem/Makefile.am b/docs/reference/lasem/Makefile.am
index feae0c0..f998752 100644
--- a/docs/reference/lasem/Makefile.am
+++ b/docs/reference/lasem/Makefile.am
@@ -154,6 +154,7 @@ IGNORE_HFILES=\
 	lsmsvgfilteroffset.h			\
 	lsmsvgfiltermerge.h			\
 	lsmsvgfiltermergenode.h			\
+	lsmsvgfilterspecularlighting.h		\
 	lsmsvgfiltertile.h
 
 # Images to copy into HTML directory.
diff --git a/src/Makefile.am b/src/Makefile.am
index e7d6510..198af3e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -133,6 +133,7 @@ LASEM_SVG_SRCS =				\
 	lsmsvgfilteroffset.c			\
 	lsmsvgfiltermerge.c			\
 	lsmsvgfiltermergenode.c			\
+	lsmsvgfilterspecularlighting.c		\
 	lsmsvgfiltertile.c
 
 LASEM_DOM_HDRS = 				\
@@ -245,6 +246,7 @@ LASEM_SVG_HDRS =				\
 	lsmsvgfilteroffset.h			\
 	lsmsvgfiltermerge.h			\
 	lsmsvgfiltermergenode.h			\
+	lsmsvgfilterspecularlighting.h		\
 	lsmsvgfiltertile.h
 
 
diff --git a/src/lsmsvgdocument.c b/src/lsmsvgdocument.c
index 4a57700..e10e6a1 100644
--- a/src/lsmsvgdocument.c
+++ b/src/lsmsvgdocument.c
@@ -53,6 +53,7 @@
 #include <lsmsvgfilteroffset.h>
 #include <lsmsvgfiltermerge.h>
 #include <lsmsvgfiltermergenode.h>
+#include <lsmsvgfilterspecularlighting.h>
 #include <lsmsvgfiltertile.h>
 #include <lsmsvgview.h>
 #include <string.h>
@@ -155,6 +156,8 @@ _create_element (LsmDomDocument *document, const char *tag_name)
 		node = lsm_svg_filter_merge_node_new ();
 	else if (strcmp (tag_name, "feOffset") == 0)
 		node = lsm_svg_filter_offset_new ();
+	else if (strcmp (tag_name, "feSpecularLighting") == 0)
+		node = lsm_svg_filter_specular_lighting_new ();
 	else if (strcmp (tag_name, "feTile") == 0)
 		node = lsm_svg_filter_tile_new ();
 
diff --git a/src/lsmsvgfilterspecularlighting.c b/src/lsmsvgfilterspecularlighting.c
new file mode 100644
index 0000000..77b50d3
--- /dev/null
+++ b/src/lsmsvgfilterspecularlighting.c
@@ -0,0 +1,127 @@
+/* Lasem
+ * 
+ * Copyright  2012 Emmanuel Pacaud
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * 	Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <lsmsvgfilterspecularlighting.h>
+#include <lsmsvgview.h>
+
+static GObjectClass *parent_class;
+
+/* GdomNode implementation */
+
+static const char *
+lsm_svg_filter_specular_lighting_get_node_name (LsmDomNode *node)
+{
+	return "feSpecularLighting";
+}
+
+/* LsmSvgElement implementation */
+
+static void
+lsm_svg_filter_specular_lighting_apply  (LsmSvgFilterPrimitive *self, LsmSvgView *view,
+				     const char *input, const char *output, const LsmBox *subregion)
+{
+/*        lsm_svg_view_apply_specular_lighting (view, output, subregion);*/
+}
+
+/* LsmSvgFilterSpecularLighting implementation */
+
+static const double surface_scale_default = 1.0;
+static const double specular_constant_default = 1.0;
+static const double specular_exponent_default = 1.0;
+static const LsmSvgOneOrTwoDouble kernel_unit_length_default = {1.0, 1.0};
+
+LsmDomNode *
+lsm_svg_filter_specular_lighting_new (void)
+{
+	return g_object_new (LSM_TYPE_SVG_FILTER_SPECULAR_LIGHTING, NULL);
+}
+
+static void
+lsm_svg_filter_specular_lighting_init (LsmSvgFilterSpecularLighting *self)
+{
+	self->surface_scale.value = surface_scale_default;
+	self->specular_constant.value = specular_constant_default;
+	self->specular_exponent.value = specular_exponent_default;
+	self->kernel_unit_length.value = kernel_unit_length_default;
+
+}
+
+static void
+lsm_svg_filter_specular_lighting_finalize (GObject *object)
+{
+	parent_class->finalize (object);
+}
+
+/* LsmSvgFilterSpecularLighting class */
+
+static const LsmAttributeInfos lsm_svg_filter_specular_lighting_attribute_infos[] = {
+	{
+		.name = "sufaceScale",
+		.attribute_offset = offsetof (LsmSvgFilterSpecularLighting, surface_scale),
+		.trait_class = &lsm_double_trait_class,
+		.trait_default = &surface_scale_default
+	},
+	{
+		.name = "specularConstant",
+		.attribute_offset = offsetof (LsmSvgFilterSpecularLighting, specular_constant),
+		.trait_class = &lsm_double_trait_class,
+		.trait_default = &specular_constant_default
+	},
+	{
+		.name = "specularExponent",
+		.attribute_offset = offsetof (LsmSvgFilterSpecularLighting, specular_exponent),
+		.trait_class = &lsm_double_trait_class,
+		.trait_default = &specular_exponent_default
+	},
+	{
+		.name = "kernelUnitLength",
+		.attribute_offset = offsetof (LsmSvgFilterSpecularLighting, kernel_unit_length),
+		.trait_class = &lsm_svg_one_or_two_double_trait_class,
+		.trait_default = &kernel_unit_length_default
+	}
+};
+
+static void
+lsm_svg_filter_specular_lighting_class_init (LsmSvgFilterSpecularLightingClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (klass);
+	LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (klass);
+	LsmSvgFilterPrimitiveClass *f_primitive_class = LSM_SVG_FILTER_PRIMITIVE_CLASS (klass);
+
+	parent_class = g_type_class_peek_parent (klass);
+
+	object_class->finalize = lsm_svg_filter_specular_lighting_finalize;
+
+	d_node_class->get_node_name = lsm_svg_filter_specular_lighting_get_node_name;
+
+	s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
+
+	lsm_attribute_manager_add_attributes (s_element_class->attribute_manager,
+					      G_N_ELEMENTS (lsm_svg_filter_specular_lighting_attribute_infos),
+					      lsm_svg_filter_specular_lighting_attribute_infos);
+
+	f_primitive_class->apply = lsm_svg_filter_specular_lighting_apply;
+}
+
+G_DEFINE_TYPE (LsmSvgFilterSpecularLighting, lsm_svg_filter_specular_lighting, LSM_TYPE_SVG_FILTER_PRIMITIVE)
diff --git a/src/lsmsvgfilterspecularlighting.h b/src/lsmsvgfilterspecularlighting.h
new file mode 100644
index 0000000..18f9225
--- /dev/null
+++ b/src/lsmsvgfilterspecularlighting.h
@@ -0,0 +1,60 @@
+/* Lasem
+ *
+ * Copyright  2012 Emmanuel Pacaud
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ * 	Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef LSM_SVG_FILTER_SPECULAR_LIGHTING_H
+#define LSM_SVG_FILTER_SPECULAR_LIGHTING_H
+
+#include <lsmsvgtypes.h>
+#include <lsmsvgfilterprimitive.h>
+
+G_BEGIN_DECLS
+
+#define LSM_TYPE_SVG_FILTER_SPECULAR_LIGHTING             (lsm_svg_filter_specular_lighting_get_type ())
+#define LSM_SVG_FILTER_SPECULAR_LIGHTING(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), LSM_TYPE_SVG_FILTER_SPECULAR_LIGHTING, LsmSvgFilterSpecularLighting))
+#define LSM_SVG_FILTER_SPECULAR_LIGHTING_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), LSM_TYPE_SVG_FILTER_SPECULAR_LIGHTING, LsmSvgFilterSpecularLightingClass))
+#define LSM_IS_SVG_FILTER_SPECULAR_LIGHTING(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LSM_TYPE_SVG_FILTER_SPECULAR_LIGHTING))
+#define LSM_IS_SVG_FILTER_SPECULAR_LIGHTING_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), LSM_TYPE_SVG_FILTER_SPECULAR_LIGHTING))
+#define LSM_SVG_FILTER_SPECULAR_LIGHTING_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), LSM_TYPE_SVG_FILTER_SPECULAR_LIGHTING, LsmSvgFilterSpecularLightingClass))
+
+typedef struct _LsmSvgFilterSpecularLightingClass LsmSvgFilterSpecularLightingClass;
+
+struct _LsmSvgFilterSpecularLighting {
+	LsmSvgFilterPrimitive base;
+
+	LsmSvgDoubleAttribute surface_scale;
+	LsmSvgDoubleAttribute specular_constant;
+	LsmSvgDoubleAttribute specular_exponent;
+	LsmSvgOneOrTwoDoubleAttribute kernel_unit_length;
+};
+
+struct _LsmSvgFilterSpecularLightingClass {
+	LsmSvgFilterPrimitiveClass  element_class;
+};
+
+GType lsm_svg_filter_specular_lighting_get_type (void);
+
+LsmDomNode * 	lsm_svg_filter_specular_lighting_new 		(void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/lsmsvgtypes.h b/src/lsmsvgtypes.h
index 01aed01..348b080 100644
--- a/src/lsmsvgtypes.h
+++ b/src/lsmsvgtypes.h
@@ -64,6 +64,7 @@ typedef struct _LsmSvgFilterGaussianBlur LsmSvgFilterGaussianBlur;
 typedef struct _LsmSvgFilterMerge LsmSvgFilterMerge;
 typedef struct _LsmSvgFilterMergeNode LsmSvgFilterMergeNode;
 typedef struct _LsmSvgFilterOffset LsmSvgFilterOffset;
+typedef struct _LsmSvgFilterSpecularLighting LsmSvgFilterSpecularLighting;
 typedef struct _LsmSvgFilterTile LsmSvgFilterTile;
 
 typedef struct _LsmSvgView LsmSvgView;



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