[lasem/properties] [SVG] Property list WIP.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [lasem/properties] [SVG] Property list WIP.
- Date: Mon, 3 Aug 2009 20:58:50 +0000 (UTC)
commit d6a2a44e8bd5a9087d1aa3bac80a795bc3cf9287
Author: Emmanuel Pacaud <emmanuel pacaud lapp in2p3 fr>
Date: Mon Aug 3 22:58:21 2009 +0200
[SVG] Property list WIP.
src/lsmattributes.c | 8 ++
src/lsmattributes.h | 2 +
src/lsmdomview.c | 3 +
src/lsmproperties.c | 155 ++++++++++++++++++++++++--
src/lsmproperties.h | 9 ++
src/lsmsvgcircleelement.c | 8 +-
src/lsmsvgcircleelement.h | 6 +-
src/lsmsvgclippathelement.c | 2 +-
src/lsmsvgclippathelement.h | 6 +-
src/lsmsvgdefselement.c | 2 +-
src/lsmsvgdefselement.h | 6 +-
src/lsmsvgelement.c | 100 +++++++++++++++--
src/lsmsvgelement.h | 13 ++-
src/lsmsvgellipseelement.c | 8 +-
src/lsmsvgellipseelement.h | 6 +-
src/lsmsvgenums.c | 2 +-
src/lsmsvggelement.c | 5 +-
src/lsmsvggelement.h | 6 +-
src/lsmsvggradientelement.c | 45 ++++++--
src/lsmsvggradientelement.h | 10 +-
src/lsmsvggraphic.c | 3 +-
src/lsmsvggraphic.h | 3 +-
src/lsmsvgimageelement.c | 8 +-
src/lsmsvgimageelement.h | 6 +-
src/lsmsvglineargradientelement.c | 20 ++-
src/lsmsvglineelement.c | 8 +-
src/lsmsvglineelement.h | 6 +-
src/lsmsvgmaskelement.c | 2 +-
src/lsmsvgmaskelement.h | 6 +-
src/lsmsvgmatrix.c | 25 ++++
src/lsmsvgmatrix.h | 7 +
src/lsmsvgpathelement.c | 8 +-
src/lsmsvgpathelement.h | 6 +-
src/lsmsvgpatternelement.c | 52 ++++++---
src/lsmsvgpatternelement.h | 8 +-
src/lsmsvgpolygonelement.c | 8 +-
src/lsmsvgpolygonelement.h | 6 +-
src/lsmsvgpolylineelement.c | 8 +-
src/lsmsvgpolylineelement.h | 6 +-
src/lsmsvgradialgradientelement.c | 20 ++-
src/lsmsvgrectelement.c | 30 +++---
src/lsmsvgrectelement.h | 6 +-
src/lsmsvgstopelement.c | 26 ++++-
src/lsmsvgstopelement.h | 6 +-
src/lsmsvgstyle.c | 221 +++++++++++++++++++++++++------------
src/lsmsvgstyle.h | 12 +-
src/lsmsvgsvgelement.c | 106 +++++++++---------
src/lsmsvgsvgelement.h | 10 +-
src/lsmsvgsymbolelement.c | 2 +-
src/lsmsvgsymbolelement.h | 6 +-
src/lsmsvgtextelement.c | 9 +-
src/lsmsvgtextelement.h | 6 +-
src/lsmsvguseelement.c | 23 +++-
src/lsmsvguseelement.h | 8 +-
src/lsmsvgview.c | 59 +++++++----
src/lsmsvgview.h | 15 ++-
56 files changed, 823 insertions(+), 340 deletions(-)
---
diff --git a/src/lsmattributes.c b/src/lsmattributes.c
index 109efd5..611a7f8 100644
--- a/src/lsmattributes.c
+++ b/src/lsmattributes.c
@@ -25,6 +25,14 @@
#include <stdlib.h>
#include <math.h>
+gboolean
+lsm_attribute_is_defined (const LsmAttribute *attribute)
+{
+ g_return_val_if_fail (attribute != NULL, FALSE);
+
+ return attribute->value != NULL;
+}
+
#define ATTRIBUTE_TRAIT(attribute) ((void *) (((void *) attribute) + sizeof (LsmAttribute)))
struct _LsmAttributeManager {
diff --git a/src/lsmattributes.h b/src/lsmattributes.h
index 26c0fb4..c00f60c 100644
--- a/src/lsmattributes.h
+++ b/src/lsmattributes.h
@@ -31,6 +31,8 @@ typedef struct {
char *value;
} LsmAttribute;
+gboolean lsm_attribute_is_defined (const LsmAttribute *attribute);
+
typedef struct {
char const * name;
ptrdiff_t attribute_offset;
diff --git a/src/lsmdomview.c b/src/lsmdomview.c
index 1b7cbb1..0f9c4c8 100644
--- a/src/lsmdomview.c
+++ b/src/lsmdomview.c
@@ -90,6 +90,9 @@ lsm_dom_view_render (LsmDomView *view, double x, double y)
view_class->render (view);
cairo_restore (view->cairo);
+
+ lsm_debug ("[LsmDomView::render] cairo status = %s",
+ cairo_status_to_string (cairo_status (view->cairo)));
}
void
diff --git a/src/lsmproperties.c b/src/lsmproperties.c
index 68fbf3f..1a1406b 100644
--- a/src/lsmproperties.c
+++ b/src/lsmproperties.c
@@ -21,6 +21,8 @@
#include <lsmproperties.h>
#include <lsmdebug.h>
+#include <lsmstr.h>
+#include <string.h>
#define PROPERTY_TRAIT(property) ((void *) (((void *) property) + sizeof (LsmProperty)))
#define PROPERTY_SIZE(trait_class) (trait_class->size + sizeof (LsmProperty))
@@ -77,18 +79,15 @@ property_free (LsmProperty *property, const LsmTraitClass *trait_class)
g_slice_free1 (PROPERTY_SIZE (trait_class), property);
}
-gboolean
-lsm_property_manager_set_property (LsmPropertyManager *manager,
- LsmPropertyBag *property_bag,
- const char *name, const char *value)
+static gboolean
+_set_property (LsmPropertyManager *manager,
+ LsmPropertyBag *property_bag,
+ const char *name, const char *value)
{
LsmProperty *property;
const LsmPropertyInfos *property_infos;
const LsmTraitClass *trait_class;
- g_return_val_if_fail (property_bag != NULL, FALSE);
- g_return_val_if_fail (manager != NULL, FALSE);
-
property_infos = g_hash_table_lookup (manager->hash_by_name, name);
if (property_infos == NULL)
return FALSE;
@@ -112,6 +111,77 @@ lsm_property_manager_set_property (LsmPropertyManager *manager,
return TRUE;
}
+gboolean
+lsm_property_manager_set_property (LsmPropertyManager *manager,
+ LsmPropertyBag *property_bag,
+ const char *name, const char *value)
+{
+ gboolean property_found;
+ char *inline_style;
+
+ g_return_val_if_fail (property_bag != NULL, FALSE);
+ g_return_val_if_fail (manager != NULL, FALSE);
+ g_return_val_if_fail (name != NULL, FALSE);
+
+ property_found = _set_property (manager, property_bag, name, value);
+ if (property_found)
+ return TRUE;
+
+ if (strcmp (name, "style") != 0)
+ return FALSE;
+
+ inline_style = g_strdup (value);
+ if (inline_style == NULL)
+ return FALSE;
+
+ {
+ char *end_ptr = inline_style;
+ char *name;
+ char *value;
+
+ while (*end_ptr != '\0') {
+
+ lsm_str_skip_spaces (&end_ptr);
+
+ name = end_ptr;
+
+ while (*end_ptr != '\0' && *end_ptr != ':' && !g_ascii_isspace (*end_ptr))
+ end_ptr++;
+
+ if (*end_ptr != '\0') {
+ *end_ptr = '\0';
+ end_ptr++;
+
+ lsm_str_skip_colon_and_spaces (&end_ptr);
+
+ if (*end_ptr != '\0') {
+ char old_char;
+
+ value = end_ptr;
+
+ while (*end_ptr != ';' && *end_ptr != '\0')
+ end_ptr++;
+
+ old_char = *end_ptr;
+ *end_ptr = '\0';
+
+ lsm_debug ("[LsmPropertyManager::set_property] inline_style %s = %s",
+ name, value);
+
+ _set_property (manager, property_bag, name, value);
+
+ *end_ptr = old_char;
+
+ lsm_str_skip_char (&end_ptr, ';');
+ }
+ }
+ }
+ g_free (inline_style);
+ }
+
+ return TRUE;
+}
+
const char *
lsm_property_manager_get_property (LsmPropertyManager *manager,
LsmPropertyBag *property_bag,
@@ -195,9 +265,78 @@ lsm_property_manager_serialize (LsmPropertyManager *manager,
}
}
-
c_string = string->str;
g_string_free (string, FALSE);
return c_string;
}
+
+void
+lsm_property_manager_apply_property_bag (LsmPropertyManager *manager,
+ LsmPropertyBag *bag,
+ void *style,
+ const void *parent_style)
+{
+ LsmProperty *property;
+ GSList *iter;
+
+ g_return_if_fail (bag != NULL);
+ g_return_if_fail (manager != NULL);
+
+ for (iter = bag->properties; iter != NULL; iter = iter->next) {
+ property = iter->data;
+
+ if (property->id < manager->n_properties) {
+ const LsmPropertyInfos *property_infos;
+
+ property_infos = &manager->property_infos[property->id];
+
+ if (g_strcmp0 (property->value, "inherit") != 0)
+ *((LsmProperty **) ((void*) style
+ + LSM_PROPERTY_ID_TO_OFFSET (property->id))) = property;
+ else
+ *((LsmProperty **) ((void*) style
+ + LSM_PROPERTY_ID_TO_OFFSET (property->id))) =
+ *((LsmProperty **) ((void*) parent_style
+ + LSM_PROPERTY_ID_TO_OFFSET (property->id)));
+ }
+ }
+}
+
+void lsm_property_manager_init_default_style (LsmPropertyManager *property_manager,
+ void *style)
+{
+ LsmProperty *property;
+ const LsmPropertyInfos *property_infos;
+ const LsmTraitClass *trait_class;
+ unsigned int i;
+
+ g_return_if_fail (property_manager != NULL);
+
+ for (i = 0; i < property_manager->n_properties; i++) {
+ property_infos = &property_manager->property_infos[i];
+ trait_class = property_infos->trait_class;
+
+ lsm_debug ("Init default property '%s' with '%s'",
+ property_infos->name, property_infos->trait_default);
+
+ property = g_slice_alloc0 (PROPERTY_SIZE (trait_class));
+ property->id = property_infos->id;
+ property->value = g_strdup (property_infos->trait_default);
+
+ if (trait_class->from_string)
+ trait_class->from_string (PROPERTY_TRAIT (property),
+ (char *) property_infos->trait_default);
+
+ *((LsmProperty **) ((void*) style
+ + LSM_PROPERTY_ID_TO_OFFSET (property->id))) = property;
+ }
+}
+
+void
+lsm_property_bag_init (LsmPropertyBag *bag)
+{
+ g_return_if_fail (bag != NULL);
+
+ bag->properties = NULL;
+}
diff --git a/src/lsmproperties.h b/src/lsmproperties.h
index a705bb1..bb944e4 100644
--- a/src/lsmproperties.h
+++ b/src/lsmproperties.h
@@ -39,6 +39,7 @@ typedef struct {
char const * name;
guint16 id;
const LsmTraitClass * trait_class;
+ const char * trait_default;
} LsmPropertyInfos;
typedef struct {
@@ -62,6 +63,14 @@ void lsm_property_manager_clean_properties (LsmPropertyManager *manager,
LsmPropertyBag *property_bag);
char * lsm_property_manager_serialize (LsmPropertyManager *property_manager,
LsmPropertyBag *property_bag);
+void lsm_property_manager_apply_property_bag (LsmPropertyManager *property_manager,
+ LsmPropertyBag *property_bag,
+ void *style,
+ const void *parent_style);
+void lsm_property_manager_init_default_style (LsmPropertyManager *property_manager,
+ void *style);
+
+void lsm_property_bag_init (LsmPropertyBag *bag);
G_END_DECLS
diff --git a/src/lsmsvgcircleelement.c b/src/lsmsvgcircleelement.c
index 9c0674e..7645438 100644
--- a/src/lsmsvgcircleelement.c
+++ b/src/lsmsvgcircleelement.c
@@ -61,7 +61,7 @@ lsm_svg_circle_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_circle_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_circle_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgCircleElement *circle = LSM_SVG_CIRCLE_ELEMENT (self);
double cx, cy, r;
@@ -126,7 +126,7 @@ lsm_svg_circle_element_class_init (LsmSvgCircleElementClass *s_rect_class)
GObjectClass *object_class = G_OBJECT_CLASS (s_rect_class);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_rect_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_rect_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);*/
parent_class = g_type_class_peek_parent (s_rect_class);
@@ -136,7 +136,7 @@ lsm_svg_circle_element_class_init (LsmSvgCircleElementClass *s_rect_class)
/* s_element_class->update = lsm_svg_circle_element_update;*/
- s_graphic_class->graphic_render = lsm_svg_circle_element_graphic_render;
+ s_element_class->render = lsm_svg_circle_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -154,4 +154,4 @@ lsm_svg_circle_element_class_init (LsmSvgCircleElementClass *s_rect_class)
/* offsetof (LsmSvgCircleElement, r));*/
}
-G_DEFINE_TYPE (LsmSvgCircleElement, lsm_svg_circle_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgCircleElement, lsm_svg_circle_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgcircleelement.h b/src/lsmsvgcircleelement.h
index 32f0f3b..b8696b8 100644
--- a/src/lsmsvgcircleelement.h
+++ b/src/lsmsvgcircleelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_CIRCLE_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
typedef struct _LsmSvgCircleElementClass LsmSvgCircleElementClass;
struct _LsmSvgCircleElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute cx;
LsmSvgLengthAttribute cy;
@@ -45,7 +45,7 @@ struct _LsmSvgCircleElement {
};
struct _LsmSvgCircleElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_circle_element_get_type (void);
diff --git a/src/lsmsvgclippathelement.c b/src/lsmsvgclippathelement.c
index e7275ec..0f03de4 100644
--- a/src/lsmsvgclippathelement.c
+++ b/src/lsmsvgclippathelement.c
@@ -136,4 +136,4 @@ lsm_svg_clip_path_element_class_init (LsmSvgClipPathElementClass *klass)
/* offsetof (LsmSvgClipPathElement, units));*/
}
-G_DEFINE_TYPE (LsmSvgClipPathElement, lsm_svg_clip_path_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgClipPathElement, lsm_svg_clip_path_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgclippathelement.h b/src/lsmsvgclippathelement.h
index 464dea0..cadfd19 100644
--- a/src/lsmsvgclippathelement.h
+++ b/src/lsmsvgclippathelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_CLIP_PATH_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,13 +37,13 @@ G_BEGIN_DECLS
typedef struct _LsmSvgClipPathElementClass LsmSvgClipPathElementClass;
struct _LsmSvgClipPathElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgPatternUnitsAttribute units;
};
struct _LsmSvgClipPathElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_clip_path_element_get_type (void);
diff --git a/src/lsmsvgdefselement.c b/src/lsmsvgdefselement.c
index 957816e..fbde796 100644
--- a/src/lsmsvgdefselement.c
+++ b/src/lsmsvgdefselement.c
@@ -65,4 +65,4 @@ lsm_svg_defs_element_class_init (LsmSvgDefsElementClass *s_g_class)
s_element_class->render = NULL;
}
-G_DEFINE_TYPE (LsmSvgDefsElement, lsm_svg_defs_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgDefsElement, lsm_svg_defs_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgdefselement.h b/src/lsmsvgdefselement.h
index 21c84fd..3c0c3f3 100644
--- a/src/lsmsvgdefselement.h
+++ b/src/lsmsvgdefselement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_DEFS_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,11 +37,11 @@ G_BEGIN_DECLS
typedef struct _LsmSvgDefsElementClass LsmSvgDefsElementClass;
struct _LsmSvgDefsElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
};
struct _LsmSvgDefsElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_defs_element_get_type (void);
diff --git a/src/lsmsvgelement.c b/src/lsmsvgelement.c
index 80cdf18..27ad1b6 100644
--- a/src/lsmsvgelement.c
+++ b/src/lsmsvgelement.c
@@ -25,6 +25,7 @@
#include <lsmdomdocument.h>
#include <lsmsvgelement.h>
#include <lsmsvgpatternelement.h>
+#include <lsmsvggradientelement.h>
#include <lsmsvgclippathelement.h>
#include <lsmsvgview.h>
#include <string.h>
@@ -70,6 +71,14 @@ lsm_svg_element_set_attribute (LsmDomElement *self, const char* name, const char
if (!lsm_attribute_manager_set_attribute (s_element_class->attribute_manager,
self, name, value))
lsm_svg_property_bag_set_property (&s_element->property_bag, name, value);
+
+ if (g_strcmp0 (name, "id") == 0) {
+ LsmDomDocument *document;
+
+ document = lsm_dom_node_get_owner_document (LSM_DOM_NODE (self));
+ if (document != NULL)
+ lsm_dom_document_register_element (document, LSM_DOM_ELEMENT (self), value);
+ }
}
const char *
@@ -140,6 +149,19 @@ lsm_svg_element_update (LsmSvgElement *self, const LsmSvgStyle *parent_style)
/* LsmSvgElement implementation */
+/*const LsmSvgMatrix **/
+/*lsm_svg_element_get_transform (LsmSvgElement *element)*/
+/*{*/
+/* LsmSvgElementClass *element_class = LSM_SVG_ELEMENT_GET_CLASS (element);*/
+
+/* g_return_val_if_fail (LSM_IS_SVG_ELEMENT (element),NULL);*/
+
+/* if (element_class->get_transform)*/
+/* return element_class->get_transform (element);*/
+
+/* return NULL;*/
+/*}*/
+
static void
_render (LsmSvgElement *element, LsmSvgView *view)
{
@@ -147,9 +169,13 @@ _render (LsmSvgElement *element, LsmSvgView *view)
lsm_debug ("[LsmSvgElement::_render");
+ lsm_svg_view_push_group_opacity (view);
+
for (node = LSM_DOM_NODE (element)->first_child; node != NULL; node = node->next_sibling)
if (LSM_IS_SVG_ELEMENT (node))
lsm_svg_element_render (LSM_SVG_ELEMENT (node), view);
+
+ lsm_svg_view_pop_group_opacity (view);
}
void
@@ -157,13 +183,18 @@ lsm_svg_element_render (LsmSvgElement *element, LsmSvgView *view)
{
LsmSvgElementClass *element_class;
const LsmSvgStyle *parent_style;
+/* const LsmSvgMatrix *matrix;*/
LsmSvgStyle *style;
g_return_if_fail (LSM_IS_SVG_ELEMENT (element));
parent_style = lsm_svg_view_get_current_style (view);
- style = lsm_svg_style_duplicate (parent_style);
- lsm_svg_style_apply_property_bag (style, &element->property_bag);
+ style = lsm_svg_style_new_inherited (parent_style, &element->property_bag);
+
+/* matrix = lsm_svg_element_get_transform (element);*/
+/* if (matrix != NULL)*/
+ if (!lsm_svg_matrix_is_identity (&element->transform.matrix))
+ lsm_svg_view_push_matrix (view, &element->transform.matrix);
lsm_svg_view_push_style (view, style);
lsm_svg_view_push_element (view, element);
@@ -179,6 +210,10 @@ lsm_svg_element_render (LsmSvgElement *element, LsmSvgView *view)
lsm_svg_view_pop_element (view);
lsm_svg_view_pop_style (view);
+
+/* if (matrix != NULL)*/
+ if (!lsm_svg_matrix_is_identity (&element->transform.matrix))
+ lsm_svg_view_pop_matrix (view);
}
static void
@@ -197,7 +232,8 @@ lsm_svg_element_enable_rendering (LsmSvgElement *element)
void
lsm_svg_element_render_paint (LsmSvgElement *element, LsmSvgView *view)
{
- g_return_if_fail (LSM_IS_SVG_PATTERN_ELEMENT (element));
+ g_return_if_fail (LSM_IS_SVG_PATTERN_ELEMENT (element) ||
+ LSM_IS_SVG_GRADIENT_ELEMENT (element));
lsm_svg_element_enable_rendering (element);
lsm_svg_element_render (element, view);
@@ -245,6 +281,47 @@ void lsm_svg_element_render_clip (LsmSvgElement *element, LsmSvgView *view)
/* }*/
/*}*/
+static void
+_get_extents (LsmSvgElement *self, LsmSvgView *view, LsmExtents *extents)
+{
+/* LsmSvgGraphic *graphic = LSM_SVG_GRAPHIC (self);*/
+ LsmDomNode *node;
+ gboolean first_child = TRUE;
+ LsmExtents element_extents = {0.0, 0.0, 0.0, 0.0};
+/* const LsmSvgMatrix *matrix;*/
+
+ lsm_debug ("[LsmSvgGraphic::_graphic_get_extents]");
+
+ for (node = LSM_DOM_NODE (self)->first_child; node != NULL; node = node->next_sibling) {
+ if (LSM_IS_SVG_ELEMENT (node)) {
+ LsmExtents child_extents;
+
+ lsm_svg_element_get_extents (LSM_SVG_ELEMENT (node), view, &child_extents);
+
+/* if (graphic->transform != NULL)*/
+/* lsm_svg_matrix_transform_bounding_box (&graphic->transform->transform.matrix,*/
+/* &child_extents.x1, &child_extents.y1,*/
+/* &child_extents.x2, &child_extents.y2);*/
+/* matrix = lsm_svg_element_get_transform (self);*/
+ if (!lsm_svg_matrix_is_identity (&self->transform.matrix))
+ lsm_svg_matrix_transform_bounding_box (&self->transform.matrix,
+ &child_extents.x1, &child_extents.y1,
+ &child_extents.x2, &child_extents.y2);
+ if (first_child) {
+ element_extents = child_extents;
+ first_child = FALSE;
+ } else {
+ element_extents.x1 = MIN (element_extents.x1, child_extents.x1);
+ element_extents.y1 = MIN (element_extents.y1, child_extents.y1);
+ element_extents.x2 = MAX (element_extents.x2, child_extents.x2);
+ element_extents.y2 = MAX (element_extents.y2, child_extents.y2);
+ }
+ }
+ }
+
+ *extents = element_extents;
+}
+
void
lsm_svg_element_get_extents (LsmSvgElement *element, LsmSvgView *view, LsmExtents *extents)
{
@@ -273,6 +350,7 @@ static void
lsm_svg_element_init (LsmSvgElement *element)
{
/* element->need_update = TRUE;*/
+ lsm_svg_matrix_init_identity (&element->transform.matrix);
}
static void
@@ -292,6 +370,8 @@ lsm_svg_element_finalize (GObject *object)
/* LsmSvgElement class */
+static const LsmSvgMatrix matrix_default = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, LSM_SVG_MATRIX_FLAGS_IDENTITY};
+
static const LsmAttributeInfos lsm_svg_attribute_infos[] = {
{
.name = "id",
@@ -304,9 +384,10 @@ static const LsmAttributeInfos lsm_svg_attribute_infos[] = {
.attribute_offset = offsetof (LsmSvgElement, class_name)
},
{
- .name = "style",
- .trait_class = &lsm_null_trait_class,
- .attribute_offset = offsetof (LsmSvgElement, style)
+ .name = "transform",
+ .attribute_offset = offsetof (LsmSvgElement, transform),
+ .trait_class = &lsm_svg_matrix_trait_class,
+ .trait_default = &matrix_default
}
};
@@ -327,16 +408,11 @@ lsm_svg_element_class_init (LsmSvgElementClass *s_element_class)
d_element_class->get_attribute = lsm_svg_element_get_attribute;
d_element_class->set_attribute = lsm_svg_element_set_attribute;
-/* s_element_class->update = NULL;*/
s_element_class->render = _render;
-/* s_element_class->render_paint = NULL;*/
+ s_element_class->get_extents = _get_extents;
s_element_class->attribute_manager = lsm_attribute_manager_new (G_N_ELEMENTS (lsm_svg_attribute_infos),
lsm_svg_attribute_infos);
-/* s_element_class->attributes = lsm_dom_attribute_map_new ();*/
-
-/* lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "id",*/
-/* offsetof (LsmSvgElement, id));*/
}
G_DEFINE_ABSTRACT_TYPE (LsmSvgElement, lsm_svg_element, LSM_TYPE_DOM_ELEMENT)
diff --git a/src/lsmsvgelement.h b/src/lsmsvgelement.h
index e8f0611..1bcba80 100644
--- a/src/lsmsvgelement.h
+++ b/src/lsmsvgelement.h
@@ -47,9 +47,10 @@ struct _LsmSvgElement {
LsmPropertyBag property_bag;
- LsmAttribute id;
- LsmAttribute class_name;
- LsmAttribute style;
+ LsmAttribute id;
+ LsmAttribute class_name;
+ LsmSvgTransformAttribute transform;
+// LsmAttribute style;
/* View */
@@ -63,11 +64,13 @@ struct _LsmSvgElementClass {
// LsmDomAttributeMap *attributes;
LsmAttributeManager *attribute_manager;
+// const LsmSvgMatrix * (*get_transform) (LsmSvgElement *element);
+
// void (*update) (LsmSvgElement *element, LsmSvgStyle *style);
void (*enable_rendering) (LsmSvgElement *element);
void (*render) (LsmSvgElement *element, LsmSvgView *view);
- void (*render_paint) (LsmSvgElement *element, LsmSvgView *view);
- void (*render_clip) (LsmSvgElement *element, LsmSvgView *view);
+// void (*render_paint) (LsmSvgElement *element, LsmSvgView *view);
+// void (*render_clip) (LsmSvgElement *element, LsmSvgView *view);
void (*get_extents) (LsmSvgElement *element, LsmSvgView *view, LsmExtents *extents);
};
diff --git a/src/lsmsvgellipseelement.c b/src/lsmsvgellipseelement.c
index e1cbaff..926fda9 100644
--- a/src/lsmsvgellipseelement.c
+++ b/src/lsmsvgellipseelement.c
@@ -64,7 +64,7 @@ lsm_svg_ellipse_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_ellipse_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_ellipse_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgEllipseElement *ellipse = LSM_SVG_ELLIPSE_ELEMENT (self);
double cx, cy, rx, ry;
@@ -133,7 +133,7 @@ lsm_svg_ellipse_element_class_init (LsmSvgEllipseElementClass *s_rect_class)
GObjectClass *object_class = G_OBJECT_CLASS (s_rect_class);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_rect_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_rect_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);*/
parent_class = g_type_class_peek_parent (s_rect_class);
@@ -143,7 +143,7 @@ lsm_svg_ellipse_element_class_init (LsmSvgEllipseElementClass *s_rect_class)
/* s_element_class->update = lsm_svg_ellipse_element_update;*/
- s_graphic_class->graphic_render = lsm_svg_ellipse_element_graphic_render;
+ s_element_class->render = lsm_svg_ellipse_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -163,4 +163,4 @@ lsm_svg_ellipse_element_class_init (LsmSvgEllipseElementClass *s_rect_class)
/* offsetof (LsmSvgEllipseElement, ry));*/
}
-G_DEFINE_TYPE (LsmSvgEllipseElement, lsm_svg_ellipse_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgEllipseElement, lsm_svg_ellipse_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgellipseelement.h b/src/lsmsvgellipseelement.h
index fe5c9b3..87a6760 100644
--- a/src/lsmsvgellipseelement.h
+++ b/src/lsmsvgellipseelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_ELLIPSE_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
typedef struct _LsmSvgEllipseElementClass LsmSvgEllipseElementClass;
struct _LsmSvgEllipseElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute cx;
LsmSvgLengthAttribute cy;
@@ -46,7 +46,7 @@ struct _LsmSvgEllipseElement {
};
struct _LsmSvgEllipseElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_ellipse_element_get_type (void);
diff --git a/src/lsmsvgenums.c b/src/lsmsvgenums.c
index 1247354..ce02e1d 100644
--- a/src/lsmsvgenums.c
+++ b/src/lsmsvgenums.c
@@ -38,7 +38,7 @@ lsm_svg_value_from_string (const char *string, const char **strings, unsigned in
}
static const char *lsm_svg_length_type_strings[] = {
- "",
+ "?",
"",
"%",
"em",
diff --git a/src/lsmsvggelement.c b/src/lsmsvggelement.c
index fb2a8c8..f3565ad 100644
--- a/src/lsmsvggelement.c
+++ b/src/lsmsvggelement.c
@@ -35,7 +35,7 @@ lsm_svg_g_element_get_node_name (LsmDomNode *node)
/* GGElement implementation */
-/* LsmSvgGraphic implementation */
+/* LsmSvgElement implementation */
/* LsmSvgGElement implementation */
@@ -52,6 +52,7 @@ lsm_svg_g_element_init (LsmSvgGElement *self)
/* LsmSvgGElement class */
+
static void
lsm_svg_g_element_class_init (LsmSvgGElementClass *s_g_class)
{
@@ -62,4 +63,4 @@ lsm_svg_g_element_class_init (LsmSvgGElementClass *s_g_class)
d_node_class->get_node_name = lsm_svg_g_element_get_node_name;
}
-G_DEFINE_TYPE (LsmSvgGElement, lsm_svg_g_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgGElement, lsm_svg_g_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvggelement.h b/src/lsmsvggelement.h
index f44e05a..cbb1ae1 100644
--- a/src/lsmsvggelement.h
+++ b/src/lsmsvggelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_G_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,11 +37,11 @@ G_BEGIN_DECLS
typedef struct _LsmSvgGElementClass LsmSvgGElementClass;
struct _LsmSvgGElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
};
struct _LsmSvgGElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_g_element_get_type (void);
diff --git a/src/lsmsvggradientelement.c b/src/lsmsvggradientelement.c
index 32deac1..0049823 100644
--- a/src/lsmsvggradientelement.c
+++ b/src/lsmsvggradientelement.c
@@ -57,12 +57,23 @@ _gradient_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
#endif
static void
-lsm_svg_gradient_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_gradient_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgGradientElement *gradient = LSM_SVG_GRADIENT_ELEMENT (self);
- LsmDomNode *iter;
- double last_offset = 0.0;
+ LsmSvgGradientElementClass *gradient_class = LSM_SVG_GRADIENT_ELEMENT_GET_CLASS (self);
+/* LsmDomNode *iter;*/
+/* double last_offset = 0.0;*/
+ if (!gradient->enable_rendering)
+ return;
+
+ gradient->enable_rendering = FALSE;
+
+ g_return_if_fail (gradient_class->create_gradient != NULL);
+
+ gradient_class->create_gradient (self, view);
+
+#if 0
for (iter = LSM_DOM_NODE (self)->first_child; iter != NULL; iter = iter->next_sibling) {
if (LSM_IS_SVG_STOP_ELEMENT (iter)) {
LsmSvgStopElement *stop;
@@ -87,26 +98,39 @@ lsm_svg_gradient_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
lsm_svg_view_add_gradient_color_stop (view, offset, color, opacity);
}
}
+#endif
lsm_svg_view_set_gradient_properties (view,
gradient->spread_method.value,
gradient->units.value,
&gradient->transform.matrix);
+
+ LSM_SVG_ELEMENT_CLASS (parent_class)->render (self, view);
+}
+
+static void
+lsm_svg_gradient_element_enable_rendering (LsmSvgElement *element)
+{
+ LSM_SVG_GRADIENT_ELEMENT (element)->enable_rendering = TRUE;
}
/* LsmSvgGradientElement implementation */
+static const LsmSvgPatternUnits units_default = LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX;
+static const LsmSvgSpreadMethod spread_method_default = LSM_SVG_SPREAD_METHOD_PAD;
+static const LsmSvgMatrix matrix_default = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0, LSM_SVG_MATRIX_FLAGS_IDENTITY};
+
static void
lsm_svg_gradient_element_init (LsmSvgGradientElement *self)
{
+ self->enable_rendering = FALSE;
+ self->units.value = units_default;
+ self->spread_method.value = spread_method_default;
+ lsm_svg_matrix_init_identity (&self->transform.matrix);
}
/* LsmSvgGradientElement class */
-static const LsmSvgPatternUnits units_default = LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX;
-static const LsmSvgSpreadMethod spread_method_default = LSM_SVG_SPREAD_METHOD_PAD;
-static const LsmSvgMatrix matrix_default = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
-
static const LsmAttributeInfos lsm_svg_gradient_element_attribute_infos[] = {
{
.name = "gradientUnits",
@@ -138,7 +162,7 @@ lsm_svg_gradient_element_class_init (LsmSvgGradientElementClass *klass)
{
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (klass);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (klass);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (klass);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (klass);*/
parent_class = g_type_class_peek_parent (klass);
@@ -148,8 +172,9 @@ lsm_svg_gradient_element_class_init (LsmSvgGradientElementClass *klass)
/* s_element_class->render_paint = s_element_class->render;*/
/* s_element_class->render = NULL;*/
/* s_element_class->render = lsm_svg_gradient_element_render;*/
- s_graphic_class->graphic_render = lsm_svg_gradient_element_graphic_render;
+ s_element_class->render = lsm_svg_gradient_element_render;
+ s_element_class->enable_rendering = lsm_svg_gradient_element_enable_rendering;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
lsm_attribute_manager_add_attributes (s_element_class->attribute_manager,
@@ -168,4 +193,4 @@ lsm_svg_gradient_element_class_init (LsmSvgGradientElementClass *klass)
/* offsetof (LsmSvgGradientElement, href));*/
}
-G_DEFINE_ABSTRACT_TYPE (LsmSvgGradientElement, lsm_svg_gradient_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_ABSTRACT_TYPE (LsmSvgGradientElement, lsm_svg_gradient_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvggradientelement.h b/src/lsmsvggradientelement.h
index d053890..6bb0c3a 100644
--- a/src/lsmsvggradientelement.h
+++ b/src/lsmsvggradientelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_GRADIENT_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,16 +37,20 @@ G_BEGIN_DECLS
typedef struct _LsmSvgGradientElementClass LsmSvgGradientElementClass;
struct _LsmSvgGradientElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgTransformAttribute transform;
LsmSvgPatternUnitsAttribute units;
LsmSvgSpreadMethodAtttribute spread_method;
LsmAttribute href;
+
+ gboolean enable_rendering;
};
struct _LsmSvgGradientElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
+
+ void (*create_gradient) (LsmSvgElement *self, LsmSvgView *view);
};
GType lsm_svg_gradient_element_get_type (void);
diff --git a/src/lsmsvggraphic.c b/src/lsmsvggraphic.c
index e3107fe..35fd283 100644
--- a/src/lsmsvggraphic.c
+++ b/src/lsmsvggraphic.c
@@ -24,6 +24,7 @@
#include <lsmstr.h>
#include <lsmdebug.h>
+#if 0
static GObjectClass *parent_class;
/*static void*/
@@ -303,4 +304,4 @@ lsm_svg_graphic_class_init (LsmSvgGraphicClass *s_graphic_class)
}
G_DEFINE_ABSTRACT_TYPE (LsmSvgGraphic, lsm_svg_graphic, LSM_TYPE_SVG_ELEMENT)
-
+#endif
diff --git a/src/lsmsvggraphic.h b/src/lsmsvggraphic.h
index 965476d..1f5e5cf 100644
--- a/src/lsmsvggraphic.h
+++ b/src/lsmsvggraphic.h
@@ -21,7 +21,7 @@
#ifndef LSM_SVG_GRAPHIC_H
#define LSM_SVG_GRAPHIC_H
-
+#if 0
#include <lsmsvg.h>
#include <lsmsvgelement.h>
@@ -63,6 +63,7 @@ struct _LsmSvgGraphicClass {
GType lsm_svg_graphic_get_type (void);
G_END_DECLS
+#endif
#endif
diff --git a/src/lsmsvgimageelement.c b/src/lsmsvgimageelement.c
index 0f5c5bc..e77a832 100644
--- a/src/lsmsvgimageelement.c
+++ b/src/lsmsvgimageelement.c
@@ -119,7 +119,7 @@ lsm_svg_image_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_image_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_image_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgImageElement *image;
LsmBox viewport;
@@ -231,7 +231,7 @@ lsm_svg_image_element_class_init (LsmSvgImageElementClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (klass);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (klass);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (klass);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (klass);*/
parent_class = g_type_class_peek_parent (klass);
@@ -242,7 +242,7 @@ lsm_svg_image_element_class_init (LsmSvgImageElementClass *klass)
/* s_element_class->update = lsm_svg_image_element_update;*/
- s_graphic_class->graphic_render = lsm_svg_image_element_graphic_render;
+ s_element_class->render = lsm_svg_image_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -266,4 +266,4 @@ lsm_svg_image_element_class_init (LsmSvgImageElementClass *klass)
/* offsetof (LsmSvgImageElement, preserve_aspect_ratio));*/
}
-G_DEFINE_TYPE (LsmSvgImageElement, lsm_svg_image_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgImageElement, lsm_svg_image_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgimageelement.h b/src/lsmsvgimageelement.h
index 4fcce7e..fc637cf 100644
--- a/src/lsmsvgimageelement.h
+++ b/src/lsmsvgimageelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_IMAGE_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
G_BEGIN_DECLS
@@ -38,7 +38,7 @@ G_BEGIN_DECLS
typedef struct _LsmSvgImageElementClass LsmSvgImageElementClass;
struct _LsmSvgImageElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute x;
LsmSvgLengthAttribute y;
@@ -53,7 +53,7 @@ struct _LsmSvgImageElement {
};
struct _LsmSvgImageElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_image_element_get_type (void);
diff --git a/src/lsmsvglineargradientelement.c b/src/lsmsvglineargradientelement.c
index ca67836..0faaf6d 100644
--- a/src/lsmsvglineargradientelement.c
+++ b/src/lsmsvglineargradientelement.c
@@ -64,7 +64,7 @@ _linear_gradient_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
#endif
static void
-_linear_gradient_element_render_paint (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_linear_gradient_element_create_gradient (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgLinearGradientElement *linear = LSM_SVG_LINEAR_GRADIENT_ELEMENT (self);
gboolean is_object_bounding_box;
@@ -92,7 +92,7 @@ _linear_gradient_element_render_paint (LsmSvgElement *self, LsmSvgView *view)
lsm_svg_view_create_linear_gradient (view, x1, y1, x2, y2);
- LSM_SVG_ELEMENT_CLASS (parent_class)->render_paint (self, view);
+/* LSM_SVG_ELEMENT_CLASS (parent_class)->render_paint (self, view);*/
}
/* LsmSvgLinearGradientElement implementation */
@@ -103,10 +103,16 @@ lsm_svg_linear_gradient_element_new (void)
return g_object_new (LSM_TYPE_SVG_LINEAR_GRADIENT_ELEMENT, NULL);
}
+static const LsmSvgLength x1_y1_y2_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
+static const LsmSvgLength x2_default = { .value_unit = 100.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
+
static void
lsm_svg_linear_gradient_element_init (LsmSvgLinearGradientElement *self)
{
-
+ self->x1.length = x1_y1_y2_default;
+ self->y1.length = x1_y1_y2_default;
+ self->x2.length = x2_default;
+ self->y2.length = x1_y1_y2_default;
}
static void
@@ -117,9 +123,6 @@ lsm_svg_linear_gradient_element_finalize (GObject *object)
/* LsmSvgLinearGradientElement class */
-static const LsmSvgLength x1_y1_y2_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
-static const LsmSvgLength x2_default = { .value_unit = 100.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
-
static const LsmAttributeInfos lsm_svg_linear_gradient_element_attribute_infos[] = {
{
.name = "x1",
@@ -153,6 +156,7 @@ lsm_svg_linear_gradient_element_class_init (LsmSvgLinearGradientElementClass *s_
GObjectClass *object_class = G_OBJECT_CLASS (s_svg_class);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_svg_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_svg_class);
+ LsmSvgGradientElementClass *s_gradient_class = LSM_SVG_GRADIENT_ELEMENT_CLASS (s_svg_class);
parent_class = g_type_class_peek_parent (s_svg_class);
@@ -161,7 +165,7 @@ lsm_svg_linear_gradient_element_class_init (LsmSvgLinearGradientElementClass *s_
d_node_class->get_node_name = lsm_svg_linear_gradient_element_get_node_name;
/* s_element_class->update = _linear_gradient_element_update;*/
- s_element_class->render_paint = _linear_gradient_element_render_paint;
+/* s_element_class->render_paint = _linear_gradient_element_render_paint;*/
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -169,6 +173,8 @@ lsm_svg_linear_gradient_element_class_init (LsmSvgLinearGradientElementClass *s_
G_N_ELEMENTS (lsm_svg_linear_gradient_element_attribute_infos),
lsm_svg_linear_gradient_element_attribute_infos);
+ s_gradient_class->create_gradient = lsm_svg_linear_gradient_element_create_gradient;
+
/* s_element_class->attributes = lsm_dom_attribute_map_duplicate (s_element_class->attributes);*/
/* lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "x1",*/
diff --git a/src/lsmsvglineelement.c b/src/lsmsvglineelement.c
index 63f55a8..dabefed 100644
--- a/src/lsmsvglineelement.c
+++ b/src/lsmsvglineelement.c
@@ -65,7 +65,7 @@ lsm_svg_line_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_line_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_line_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgLineElement *line = LSM_SVG_LINE_ELEMENT (self);
double x1, y1, x2, y2;
@@ -129,7 +129,7 @@ lsm_svg_line_element_class_init (LsmSvgLineElementClass *s_rect_class)
{
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_rect_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_rect_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);*/
parent_class = g_type_class_peek_parent (s_rect_class);
@@ -137,7 +137,7 @@ lsm_svg_line_element_class_init (LsmSvgLineElementClass *s_rect_class)
/* s_element_class->update = lsm_svg_line_element_update;*/
- s_graphic_class->graphic_render = lsm_svg_line_element_graphic_render;
+ s_element_class->render = lsm_svg_line_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -157,4 +157,4 @@ lsm_svg_line_element_class_init (LsmSvgLineElementClass *s_rect_class)
/* offsetof (LsmSvgLineElement, y2));*/
}
-G_DEFINE_TYPE (LsmSvgLineElement, lsm_svg_line_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgLineElement, lsm_svg_line_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvglineelement.h b/src/lsmsvglineelement.h
index a65c0d8..45b9234 100644
--- a/src/lsmsvglineelement.h
+++ b/src/lsmsvglineelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_LINE_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
typedef struct _LsmSvgLineElementClass LsmSvgLineElementClass;
struct _LsmSvgLineElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute x1;
LsmSvgLengthAttribute y1;
@@ -46,7 +46,7 @@ struct _LsmSvgLineElement {
};
struct _LsmSvgLineElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_line_element_get_type (void);
diff --git a/src/lsmsvgmaskelement.c b/src/lsmsvgmaskelement.c
index 45025df..5e1be92 100644
--- a/src/lsmsvgmaskelement.c
+++ b/src/lsmsvgmaskelement.c
@@ -246,4 +246,4 @@ lsm_svg_mask_element_class_init (LsmSvgMaskElementClass *klass)
/* offsetof (LsmSvgMaskElement, content_units));*/
}
-G_DEFINE_TYPE (LsmSvgMaskElement, lsm_svg_mask_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgMaskElement, lsm_svg_mask_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgmaskelement.h b/src/lsmsvgmaskelement.h
index ebac493..63e3430 100644
--- a/src/lsmsvgmaskelement.h
+++ b/src/lsmsvgmaskelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_MASK_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
typedef struct _LsmSvgMaskElementClass LsmSvgMaskElementClass;
struct _LsmSvgMaskElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute x;
LsmSvgLengthAttribute y;
@@ -48,7 +48,7 @@ struct _LsmSvgMaskElement {
};
struct _LsmSvgMaskElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_mask_element_get_type (void);
diff --git a/src/lsmsvgmatrix.c b/src/lsmsvgmatrix.c
index 99edea5..214544e 100644
--- a/src/lsmsvgmatrix.c
+++ b/src/lsmsvgmatrix.c
@@ -22,6 +22,12 @@
#include <lsmsvgmatrix.h>
#include <math.h>
+gboolean
+lsm_svg_matrix_is_identity (const LsmSvgMatrix *matrix)
+{
+ return ((matrix->flags & LSM_SVG_MATRIX_FLAGS_IDENTITY) != 0);
+}
+
void
lsm_svg_matrix_init (LsmSvgMatrix *matrix, double a, double b, double c, double d, double e, double f)
{
@@ -31,12 +37,14 @@ lsm_svg_matrix_init (LsmSvgMatrix *matrix, double a, double b, double c, double
matrix->d = d;
matrix->e = e;
matrix->f = f;
+ matrix->flags = 0;
}
void
lsm_svg_matrix_init_identity (LsmSvgMatrix *matrix)
{
lsm_svg_matrix_init (matrix, 1, 0, 0, 1, 0, 0);
+ matrix->flags |= LSM_SVG_MATRIX_FLAGS_IDENTITY;
}
void
@@ -125,6 +133,15 @@ lsm_svg_matrix_multiply (LsmSvgMatrix *result, const LsmSvgMatrix *a, const LsmS
{
LsmSvgMatrix r;
+ if ((a->flags & LSM_SVG_MATRIX_FLAGS_IDENTITY) != 0) {
+ *result = *b;
+ return;
+ }
+ if ((b->flags & LSM_SVG_MATRIX_FLAGS_IDENTITY) != 0) {
+ *result = *a;
+ return;
+ }
+
r.a = a->a * b->a + a->b * b->c;
r.b = a->a * b->b + a->b * b->d;
@@ -134,6 +151,8 @@ lsm_svg_matrix_multiply (LsmSvgMatrix *result, const LsmSvgMatrix *a, const LsmS
r.e = a->e * b->a + a->f * b->c + b->e;
r.f = a->e * b->b + a->f * b->d + b->f;
+ r.flags = 0;
+
*result = r;
}
@@ -143,6 +162,9 @@ lsm_svg_matrix_transform_point (const LsmSvgMatrix *matrix, double *x, double *y
double new_x;
double new_y;
+ if ((matrix->flags & LSM_SVG_MATRIX_FLAGS_IDENTITY) != 0)
+ return;
+
new_x = (matrix->a * *x + matrix->c * *y) + matrix->e;
new_y = (matrix->b * *x + matrix->d * *y) + matrix->f;
@@ -156,6 +178,9 @@ lsm_svg_matrix_transform_bounding_box (const LsmSvgMatrix *matrix, double *x1, d
double x12, y12, x21, y21;
double x_min, y_min, x_max, y_max;
+ if ((matrix->flags & LSM_SVG_MATRIX_FLAGS_IDENTITY) != 0)
+ return;
+
x12 = *x1;
y12 = *y2;
x21 = *x2;
diff --git a/src/lsmsvgmatrix.h b/src/lsmsvgmatrix.h
index 3a4cc5a..2fad642 100644
--- a/src/lsmsvgmatrix.h
+++ b/src/lsmsvgmatrix.h
@@ -24,10 +24,17 @@
#include <lsmsvg.h>
+typedef enum {
+ LSM_SVG_MATRIX_FLAGS_IDENTITY = 1 << 0
+} LsmSvgMatrixFlags;
+
typedef struct {
double a, b, c, d, e, f;
+ LsmSvgMatrixFlags flags;
} LsmSvgMatrix;
+gboolean lsm_svg_matrix_is_identity (const LsmSvgMatrix *matrix);
+
void lsm_svg_matrix_init (LsmSvgMatrix *matrix, double a, double b,
double c, double d,
double e, double f);
diff --git a/src/lsmsvgpathelement.c b/src/lsmsvgpathelement.c
index 5d7de2d..f515e5b 100644
--- a/src/lsmsvgpathelement.c
+++ b/src/lsmsvgpathelement.c
@@ -36,7 +36,7 @@ lsm_svg_path_element_get_node_name (LsmDomNode *node)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_path_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_path_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgPathElement *path;
@@ -83,7 +83,7 @@ lsm_svg_path_element_class_init (LsmSvgPathElementClass *s_rect_class)
GObjectClass *object_class = G_OBJECT_CLASS (s_rect_class);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_rect_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_rect_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);*/
parent_class = g_type_class_peek_parent (s_rect_class);
@@ -91,7 +91,7 @@ lsm_svg_path_element_class_init (LsmSvgPathElementClass *s_rect_class)
d_node_class->get_node_name = lsm_svg_path_element_get_node_name;
- s_graphic_class->graphic_render = lsm_svg_path_element_graphic_render;
+ s_element_class->render = lsm_svg_path_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -105,4 +105,4 @@ lsm_svg_path_element_class_init (LsmSvgPathElementClass *s_rect_class)
/* offsetof (LsmSvgPathElement, d));*/
}
-G_DEFINE_TYPE (LsmSvgPathElement, lsm_svg_path_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgPathElement, lsm_svg_path_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgpathelement.h b/src/lsmsvgpathelement.h
index 7468118..cf34419 100644
--- a/src/lsmsvgpathelement.h
+++ b/src/lsmsvgpathelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_PATH_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,14 +37,14 @@ G_BEGIN_DECLS
typedef struct _LsmSvgPathElementClass LsmSvgPathElementClass;
struct _LsmSvgPathElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmAttribute d;
LsmSvgDoubleAttribute path_length;
};
struct _LsmSvgPathElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_path_element_get_type (void);
diff --git a/src/lsmsvgpatternelement.c b/src/lsmsvgpatternelement.c
index 35acbcb..e183d43 100644
--- a/src/lsmsvgpatternelement.c
+++ b/src/lsmsvgpatternelement.c
@@ -84,6 +84,11 @@ lsm_svg_pattern_element_render (LsmSvgElement *self, LsmSvgView *view)
LsmBox viewport;
const LsmBox *pattern_extents;
+ if (!pattern->enable_rendering)
+ return;
+
+ pattern->enable_rendering = FALSE;
+
pattern_extents = lsm_svg_view_get_pattern_extents (view);
is_object_bounding_box = (pattern->units.value == LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX);
@@ -141,8 +146,7 @@ lsm_svg_pattern_element_render (LsmSvgElement *self, LsmSvgView *view)
pattern_extents->x, pattern_extents->y);
}
-/* is_viewbox_defined = lsm_dom_attribute_is_defined ((LsmDomAttribute *) &pattern->viewbox);*/
- is_viewbox_defined = FALSE;
+ is_viewbox_defined = lsm_attribute_is_defined (&pattern->viewbox.base);
if (!(is_viewbox_defined) ||
(is_viewbox_defined && pattern->viewbox.value.width > 0.0 && pattern->viewbox.value.height > 0.0)) {
@@ -161,6 +165,12 @@ lsm_svg_pattern_element_render (LsmSvgElement *self, LsmSvgView *view)
}
}
+static void
+lsm_svg_pattern_element_enable_rendering (LsmSvgElement *element)
+{
+ LSM_SVG_PATTERN_ELEMENT (element)->enable_rendering = TRUE;
+}
+
/* LsmSvgPatternElement implementation */
LsmDomNode *
@@ -169,9 +179,31 @@ lsm_svg_pattern_element_new (void)
return g_object_new (LSM_TYPE_SVG_PATTERN_ELEMENT, NULL);
}
+static const LsmSvgLength length_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_PX};
+static const LsmSvgMatrix matrix_default = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0, LSM_SVG_MATRIX_FLAGS_IDENTITY};
+static const LsmBox viewbox_default = {0.0, 0.0, 0.0, 0.0};
+static const LsmSvgPatternUnits units_default = LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX;
+static const LsmSvgPatternUnits content_units_default = LSM_SVG_PATTERN_UNITS_USER_SPACE_ON_USE;
+static const LsmSvgPreserveAspectRatio preserve_aspect_ratio_default = {
+ .defer = FALSE,
+ .align = LSM_SVG_ALIGN_X_MID_Y_MID,
+ .meet_or_slice = LSM_SVG_MEET_OR_SLICE_MEET
+};
+
static void
lsm_svg_pattern_element_init (LsmSvgPatternElement *self)
{
+ self->enable_rendering = FALSE;
+ self->x.length = length_default;
+ self->y.length = length_default;
+ self->width.length = length_default;
+ self->height.length = length_default;
+ self->transform.matrix = matrix_default;
+ self->units.value = units_default;
+ self->content_units.value = content_units_default;
+ self->preserve_aspect_ratio.value = preserve_aspect_ratio_default;
+
+#if 0
/* Hack - Force the creation of the attribute bags,
making sure the properties will be inherited from the
pattern element ancestor, not the referencing one. */
@@ -181,22 +213,11 @@ lsm_svg_pattern_element_init (LsmSvgPatternElement *self)
lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "transform", NULL);
lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "font-family", NULL);
lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stop-color", NULL);
+#endif
}
/* LsmSvgPatternElement class */
-static const LsmSvgLength length_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_PX};
-static const LsmSvgMatrix matrix_default = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
-static const LsmBox viewbox_default = {0.0, 0.0, 0.0, 0.0};
-static const LsmSvgPatternUnits units_default = LSM_SVG_PATTERN_UNITS_OBJECT_BOUNDING_BOX;
-static const LsmSvgPatternUnits content_units_default = LSM_SVG_PATTERN_UNITS_USER_SPACE_ON_USE;
-static const LsmSvgSpreadMethod spread_method_default = LSM_SVG_SPREAD_METHOD_PAD;
-static const LsmSvgPreserveAspectRatio preserve_aspect_ratio_default = {
- .defer = FALSE,
- .align = LSM_SVG_ALIGN_X_MID_Y_MID,
- .meet_or_slice = LSM_SVG_MEET_OR_SLICE_MEET
-};
-
static const LsmAttributeInfos lsm_svg_pattern_element_attribute_infos[] = {
{
.name = "x",
@@ -273,6 +294,7 @@ lsm_svg_pattern_element_class_init (LsmSvgPatternElementClass *klass)
/* s_element_class->render_paint = _pattern_element_render_paint;*/
/* s_element_class->render = NULL;*/
s_element_class->render = lsm_svg_pattern_element_render;
+ s_element_class->enable_rendering = lsm_svg_pattern_element_enable_rendering;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -304,4 +326,4 @@ lsm_svg_pattern_element_class_init (LsmSvgPatternElementClass *klass)
/* offsetof (LsmSvgPatternElement, preserve_aspect_ratio));*/
}
-G_DEFINE_TYPE (LsmSvgPatternElement, lsm_svg_pattern_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgPatternElement, lsm_svg_pattern_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgpatternelement.h b/src/lsmsvgpatternelement.h
index acbb5c4..6c717a4 100644
--- a/src/lsmsvgpatternelement.h
+++ b/src/lsmsvgpatternelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_PATTERN_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
typedef struct _LsmSvgPatternElementClass LsmSvgPatternElementClass;
struct _LsmSvgPatternElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute x;
LsmSvgLengthAttribute y;
@@ -50,10 +50,12 @@ struct _LsmSvgPatternElement {
LsmSvgViewboxAttribute viewbox;
LsmSvgPreserveAspectRatioAttribute preserve_aspect_ratio;
+
+ gboolean enable_rendering;
};
struct _LsmSvgPatternElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_pattern_element_get_type (void);
diff --git a/src/lsmsvgpolygonelement.c b/src/lsmsvgpolygonelement.c
index aa3186c..e7c7b5e 100644
--- a/src/lsmsvgpolygonelement.c
+++ b/src/lsmsvgpolygonelement.c
@@ -37,7 +37,7 @@ lsm_svg_polygon_element_get_node_name (LsmDomNode *node)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_polygon_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_polygon_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgPolygonElement *polygon = LSM_SVG_POLYGON_ELEMENT (self);
@@ -72,13 +72,13 @@ lsm_svg_polygon_element_class_init (LsmSvgPolygonElementClass *s_rect_class)
{
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_rect_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_rect_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);*/
parent_class = g_type_class_peek_parent (s_rect_class);
d_node_class->get_node_name = lsm_svg_polygon_element_get_node_name;
- s_graphic_class->graphic_render = lsm_svg_polygon_element_graphic_render;
+ s_element_class->render = lsm_svg_polygon_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -92,4 +92,4 @@ lsm_svg_polygon_element_class_init (LsmSvgPolygonElementClass *s_rect_class)
/* offsetof (LsmSvgPolygonElement, points));*/
}
-G_DEFINE_TYPE (LsmSvgPolygonElement, lsm_svg_polygon_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgPolygonElement, lsm_svg_polygon_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgpolygonelement.h b/src/lsmsvgpolygonelement.h
index 5f8be5c..90db664 100644
--- a/src/lsmsvgpolygonelement.h
+++ b/src/lsmsvgpolygonelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_POLYGON_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,13 +37,13 @@ G_BEGIN_DECLS
typedef struct _LsmSvgPolygonElementClass LsmSvgPolygonElementClass;
struct _LsmSvgPolygonElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmAttribute points;
};
struct _LsmSvgPolygonElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_polygon_element_get_type (void);
diff --git a/src/lsmsvgpolylineelement.c b/src/lsmsvgpolylineelement.c
index bcd60b1..9ec61fd 100644
--- a/src/lsmsvgpolylineelement.c
+++ b/src/lsmsvgpolylineelement.c
@@ -37,7 +37,7 @@ lsm_svg_polyline_element_get_node_name (LsmDomNode *node)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_polyline_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_polyline_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgPolylineElement *polyline = LSM_SVG_POLYLINE_ELEMENT (self);
@@ -72,13 +72,13 @@ lsm_svg_polyline_element_class_init (LsmSvgPolylineElementClass *s_rect_class)
{
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_rect_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_rect_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);*/
parent_class = g_type_class_peek_parent (s_rect_class);
d_node_class->get_node_name = lsm_svg_polyline_element_get_node_name;
- s_graphic_class->graphic_render = lsm_svg_polyline_element_graphic_render;
+ s_element_class->render = lsm_svg_polyline_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -92,4 +92,4 @@ lsm_svg_polyline_element_class_init (LsmSvgPolylineElementClass *s_rect_class)
/* offsetof (LsmSvgPolylineElement, points));*/
}
-G_DEFINE_TYPE (LsmSvgPolylineElement, lsm_svg_polyline_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgPolylineElement, lsm_svg_polyline_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgpolylineelement.h b/src/lsmsvgpolylineelement.h
index ec5947c..a96fc6a 100644
--- a/src/lsmsvgpolylineelement.h
+++ b/src/lsmsvgpolylineelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_POLYLINE_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,13 +37,13 @@ G_BEGIN_DECLS
typedef struct _LsmSvgPolylineElementClass LsmSvgPolylineElementClass;
struct _LsmSvgPolylineElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmAttribute points;
};
struct _LsmSvgPolylineElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_polyline_element_get_type (void);
diff --git a/src/lsmsvgradialgradientelement.c b/src/lsmsvgradialgradientelement.c
index bccd771..1934687 100644
--- a/src/lsmsvgradialgradientelement.c
+++ b/src/lsmsvgradialgradientelement.c
@@ -67,7 +67,7 @@ _radial_gradient_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
#endif
static void
-_radial_gradient_element_render_paint (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_radial_gradient_element_create_gradient (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgRadialGradientElement *radial = LSM_SVG_RADIAL_GRADIENT_ELEMENT (self);
gboolean is_object_bounding_box;
@@ -108,7 +108,7 @@ _radial_gradient_element_render_paint (LsmSvgElement *self, LsmSvgView *view)
lsm_svg_view_create_radial_gradient (view, cx, cy, r, fx, fy);
- LSM_SVG_ELEMENT_CLASS (parent_class)->render_paint (self, view);
+/* LSM_SVG_ELEMENT_CLASS (parent_class)->render_paint (self, view);*/
}
/* LsmSvgRadialGradientElement implementation */
@@ -119,10 +119,17 @@ lsm_svg_radial_gradient_element_new (void)
return g_object_new (LSM_TYPE_SVG_RADIAL_GRADIENT_ELEMENT, NULL);
}
+static const LsmSvgLength length_default = {.value_unit = 50.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
+static const LsmSvgLength unset_default = {.value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_UNKNOWN};
+
static void
lsm_svg_radial_gradient_element_init (LsmSvgRadialGradientElement *self)
{
-
+ self->cx.length = length_default;
+ self->cy.length = length_default;
+ self->r.length = length_default;
+ self->fx.length = unset_default;
+ self->fy.length = unset_default;
}
static void
@@ -133,9 +140,6 @@ lsm_svg_radial_gradient_element_finalize (GObject *object)
/* LsmSvgRadialGradientElement class */
-static const LsmSvgLength length_default = {.value_unit = 50.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
-static const LsmSvgLength unset_default = {.value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_UNKNOWN};
-
static const LsmAttributeInfos lsm_svg_radial_gradient_element_attribute_infos[] = {
{
.name = "cx",
@@ -175,6 +179,7 @@ lsm_svg_radial_gradient_element_class_init (LsmSvgRadialGradientElementClass *s_
GObjectClass *object_class = G_OBJECT_CLASS (s_svg_class);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_svg_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_svg_class);
+ LsmSvgGradientElementClass *s_gradient_class = LSM_SVG_GRADIENT_ELEMENT_CLASS (s_svg_class);
parent_class = g_type_class_peek_parent (s_svg_class);
@@ -183,7 +188,7 @@ lsm_svg_radial_gradient_element_class_init (LsmSvgRadialGradientElementClass *s_
d_node_class->get_node_name = lsm_svg_radial_gradient_element_get_node_name;
/* s_element_class->update = _radial_gradient_element_update;*/
- s_element_class->render_paint = _radial_gradient_element_render_paint;
+/* s_element_class->render_paint = _radial_gradient_element_render_paint;*/
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -191,6 +196,7 @@ lsm_svg_radial_gradient_element_class_init (LsmSvgRadialGradientElementClass *s_
G_N_ELEMENTS (lsm_svg_radial_gradient_element_attribute_infos),
lsm_svg_radial_gradient_element_attribute_infos);
+ s_gradient_class->create_gradient = lsm_svg_radial_gradient_element_create_gradient;
/* s_element_class->attributes = lsm_dom_attribute_map_duplicate (s_element_class->attributes);*/
/* lsm_dom_attribute_map_add_attribute (s_element_class->attributes, "cx",*/
diff --git a/src/lsmsvgrectelement.c b/src/lsmsvgrectelement.c
index b310326..18b6215 100644
--- a/src/lsmsvgrectelement.c
+++ b/src/lsmsvgrectelement.c
@@ -72,7 +72,7 @@ lsm_svg_rect_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_rect_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_rect_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgRectElement *rect = LSM_SVG_RECT_ELEMENT (self);
double x, y;
@@ -90,23 +90,23 @@ lsm_svg_rect_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
if (w == 0.0 || h == 0.0)
return;
-/* if (!lsm_dom_attribute_is_defined (&rect->rx.attr))*/
-/* rx = ry;*/
-/* else if (!lsm_dom_attribute_is_defined (&rect->ry.attr))*/
-/* ry = rx;*/
-
-
- if (rect->rx.length.type == LSM_SVG_LENGTH_TYPE_UNKNOWN) {
+ if (!lsm_attribute_is_defined (&rect->rx.base))
rx = ry;
- } else if (rect->rx.length.type == LSM_SVG_LENGTH_TYPE_UNKNOWN) {
+ else if (!lsm_attribute_is_defined (&rect->ry.base))
ry = rx;
- }
+
+
+/* if (rect->rx.length.type == LSM_SVG_LENGTH_TYPE_UNKNOWN) {*/
+/* rx = ry;*/
+/* } else if (rect->rx.length.type == LSM_SVG_LENGTH_TYPE_UNKNOWN) {*/
+/* ry = rx;*/
+/* }*/
lsm_svg_view_show_rectangle (view, x, y, w, h, rx, ry);
}
static void
-lsm_svg_rect_element_graphic_get_extents (LsmSvgElement *self, LsmSvgView *view, LsmExtents *extents)
+lsm_svg_rect_element_get_extents (LsmSvgElement *self, LsmSvgView *view, LsmExtents *extents)
{
LsmSvgRectElement *rect = LSM_SVG_RECT_ELEMENT (self);
double x, y;
@@ -192,7 +192,7 @@ lsm_svg_rect_element_class_init (LsmSvgRectElementClass *s_rect_class)
GObjectClass *object_class = G_OBJECT_CLASS (s_rect_class);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_rect_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_rect_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_rect_class);*/
parent_class = g_type_class_peek_parent (s_rect_class);
@@ -202,8 +202,8 @@ lsm_svg_rect_element_class_init (LsmSvgRectElementClass *s_rect_class)
/* s_element_class->update = lsm_svg_rect_element_update;*/
- s_graphic_class->graphic_render = lsm_svg_rect_element_graphic_render;
- s_graphic_class->graphic_get_extents = lsm_svg_rect_element_graphic_get_extents;
+ s_element_class->render = lsm_svg_rect_element_render;
+ s_element_class->get_extents = lsm_svg_rect_element_get_extents;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -227,4 +227,4 @@ lsm_svg_rect_element_class_init (LsmSvgRectElementClass *s_rect_class)
/* offsetof (LsmSvgRectElement, ry));*/
}
-G_DEFINE_TYPE (LsmSvgRectElement, lsm_svg_rect_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgRectElement, lsm_svg_rect_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgrectelement.h b/src/lsmsvgrectelement.h
index a6bdd02..0ec6552 100644
--- a/src/lsmsvgrectelement.h
+++ b/src/lsmsvgrectelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_RECT_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
typedef struct _LsmSvgRectElementClass LsmSvgRectElementClass;
struct _LsmSvgRectElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute x;
LsmSvgLengthAttribute y;
@@ -48,7 +48,7 @@ struct _LsmSvgRectElement {
};
struct _LsmSvgRectElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_rect_element_get_type (void);
diff --git a/src/lsmsvgstopelement.c b/src/lsmsvgstopelement.c
index 7463059..e93395b 100644
--- a/src/lsmsvgstopelement.c
+++ b/src/lsmsvgstopelement.c
@@ -51,8 +51,25 @@ _stop_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
}
#endif
+static void
+lsm_svg_stop_element_render (LsmSvgElement *element, LsmSvgView *view)
+{
+ LsmSvgStopElement *stop = LSM_SVG_STOP_ELEMENT (element);
+ double offset;
+
+ if (stop->offset.length.type == LSM_SVG_LENGTH_TYPE_PERCENTAGE)
+ offset = stop->offset.length.value_unit / 100.0;
+ else
+ offset = stop->offset.length.value_unit;
+
+ lsm_debug ("[LsmSvgStopElement::render] Add stop at %g", offset);
+
+ lsm_svg_view_add_gradient_color_stop (view, offset);
+}
+
/* LsmSvgStopElement implementation */
+#if 0
double
lsm_svg_stop_element_get_offset (LsmSvgStopElement *self)
{
@@ -85,6 +102,7 @@ lsm_svg_stop_element_get_opacity (LsmSvgStopElement *self)
/* else*/
return 1.0;
}
+#endif
LsmDomNode *
lsm_svg_stop_element_new (void)
@@ -92,15 +110,16 @@ lsm_svg_stop_element_new (void)
return g_object_new (LSM_TYPE_SVG_STOP_ELEMENT, NULL);
}
+static const LsmSvgLength length_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_NUMBER};
+
static void
lsm_svg_stop_element_init (LsmSvgStopElement *self)
{
+ self->offset.length = length_default;
}
/* LsmSvgStopElement class */
-static const LsmSvgLength length_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_NUMBER};
-
static const LsmAttributeInfos lsm_svg_stop_element_attribute_infos[] = {
{
.name = "offset",
@@ -122,6 +141,7 @@ lsm_svg_stop_element_class_init (LsmSvgStopElementClass *klass)
/* s_element_class->update = _stop_element_update;*/
+ s_element_class->render = lsm_svg_stop_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
lsm_attribute_manager_add_attributes (s_element_class->attribute_manager,
@@ -134,4 +154,4 @@ lsm_svg_stop_element_class_init (LsmSvgStopElementClass *klass)
/* offsetof (LsmSvgStopElement, offset));*/
}
-G_DEFINE_TYPE (LsmSvgStopElement, lsm_svg_stop_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgStopElement, lsm_svg_stop_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgstopelement.h b/src/lsmsvgstopelement.h
index 0187c9c..32075ac 100644
--- a/src/lsmsvgstopelement.h
+++ b/src/lsmsvgstopelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_STOP_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,13 +37,13 @@ G_BEGIN_DECLS
typedef struct _LsmSvgStopElementClass LsmSvgStopElementClass;
struct _LsmSvgStopElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute offset;
};
struct _LsmSvgStopElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_stop_element_get_type (void);
diff --git a/src/lsmsvgstyle.c b/src/lsmsvgstyle.c
index 06cd53b..893b46f 100644
--- a/src/lsmsvgstyle.c
+++ b/src/lsmsvgstyle.c
@@ -30,308 +30,369 @@ static const LsmPropertyInfos lsm_svg_property_infos[] = {
{
.name = "alignment-baseline",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, alignment_baseline),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto" /* FIXME specification says "see property description" */
},
{
.name = "baseline-shift",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, baseline_shift),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "baseline"
},
{
.name = "clip",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, clip),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "clip-path",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, clip_path),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "dominant-baseline",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, dominant_baseline),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "enable-background",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, enable_background),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "accumulate"
},
{
.name = "filter",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, filter),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "flood-color",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, flood_color),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "black"
},
{
.name = "flood-opacity",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, flood_opacity),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "1"
},
{
.name = "lighting-color",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, lighting_color),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "white"
},
{
.name = "mask",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, mask),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "opacity",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, opacity),
- .trait_class = &lsm_double_trait_class
+ .trait_class = &lsm_double_trait_class,
+ .trait_default = "1"
},
{
.name = "overflow",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, overflow),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = ""
},
{
.name = "stop-color",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stop_color),
- .trait_class = &lsm_svg_color_trait_class
+ .trait_class = &lsm_svg_color_trait_class,
+ .trait_default = "black"
},
{
.name = "stop-opacity",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stop_opacity),
- .trait_class = &lsm_double_trait_class
+ .trait_class = &lsm_double_trait_class,
+ .trait_default = "1"
},
{
.name = "text-decoration",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, text_decoration),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "unicode-bidi",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, unicode_bidi),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "normal"
},
/* Inherited properties */
{
.name = "clip-rule",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, clip_rule),
- .trait_class = &lsm_svg_fill_rule_trait_class
+ .trait_class = &lsm_svg_fill_rule_trait_class,
+ .trait_default = "nonzero"
},
{
.name = "color",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, color),
- .trait_class = &lsm_svg_color_trait_class
+ .trait_class = &lsm_svg_color_trait_class,
+ .trait_default = "black" /* Depends on user agent */
},
{
.name = "color-interpolation",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, color_interpolation),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "sRGB"
},
{
.name = "color-interpolation-filters",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, color_interpolation_filters),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "linearRGB"
},
{
.name = "color-profile",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, color_profile),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "color-rendering",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, color_rendering),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "cursor",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, cursor),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "direction",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, direction),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "ltr"
},
{
.name = "display",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, display),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "inline"
},
{
.name = "fill",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, fill),
- .trait_class = &lsm_svg_paint_trait_class
+ .trait_class = &lsm_svg_paint_trait_class,
+ .trait_default = "black"
},
{
.name = "fill-opacity",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, fill_opacity),
- .trait_class = &lsm_double_trait_class
+ .trait_class = &lsm_double_trait_class,
+ .trait_default = "1"
},
{
.name = "fill-rule",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, fill_rule),
- .trait_class = &lsm_svg_fill_rule_trait_class
+ .trait_class = &lsm_svg_fill_rule_trait_class,
+ .trait_default = "nonzero"
},
{
.name = "font",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, font),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = NULL /* specification says "See individual properties" */
},
{
.name = "font-family",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, font_family),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "Sans" /* Depends on user agent */
},
{
.name = "font-size",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, font_size),
- .trait_class = &lsm_svg_length_trait_class
+ .trait_class = &lsm_svg_length_trait_class,
+ .trait_default = "10pt" /* FIXME Specification says "medium" */
},
{
.name = "font-size-adjust",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, font_size_adjust),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "font-stretch",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, font_stretch),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "normal"
},
{
.name = "font-style",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, font_style),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "normal"
},
{
.name = "font-variant",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, font_variant),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "normal"
},
{
.name = "font-weight",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, font_weight),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "normal"
},
{
.name = "glyph-orientation-horizontal",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, glyph_orientation_horizontal),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "0deg"
},
{
.name = "glyph-orientation-vertical",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, glyph_orientation_vertical),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "image-rendering",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, image_rendering),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "kerning",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, kerning),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "letter-spacing",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, letter_spacing),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "normal"
},
{
.name = "marker",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, marker),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "marker-end",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, marker_end),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "marker-mid",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, marker_mid),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "marker-start",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, marker_start),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "none"
},
{
.name = "pointer-events",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, pointer_events),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "visiblePainted"
},
{
.name = "shape-rendering",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, shape_rendering),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "stroke",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stroke),
- .trait_class = &lsm_svg_paint_trait_class
+ .trait_class = &lsm_svg_paint_trait_class,
+ .trait_default = "none"
},
{
.name = "stroke-dasharray",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stroke_dash_array),
- .trait_class = &lsm_svg_dash_array_trait_class
+ .trait_class = &lsm_svg_dash_array_trait_class,
+ .trait_default = "none"
},
{
.name = "stroke-dashoffset",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stroke_dash_offset),
- .trait_class = &lsm_svg_length_trait_class
+ .trait_class = &lsm_svg_length_trait_class,
+ .trait_default = "0"
},
{
.name = "stroke-linecap",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stroke_line_cap),
- .trait_class = &lsm_svg_line_cap_trait_class
+ .trait_class = &lsm_svg_line_cap_trait_class,
+ .trait_default = "butt"
},
{
.name = "stroke-linejoin",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stroke_line_join),
- .trait_class = &lsm_svg_line_join_trait_class
+ .trait_class = &lsm_svg_line_join_trait_class,
+ .trait_default = "miter"
},
{
.name = "stroke-miterlimit",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stroke_miter_limit),
- .trait_class = &lsm_double_trait_class
+ .trait_class = &lsm_double_trait_class,
+ .trait_default = "4"
},
{
.name = "stroke-opacity",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stroke_opacity),
- .trait_class = &lsm_double_trait_class
+ .trait_class = &lsm_double_trait_class,
+ .trait_default = "1"
},
{
.name = "stroke-width",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, stroke_width),
- .trait_class = &lsm_svg_length_trait_class
+ .trait_class = &lsm_svg_length_trait_class,
+ .trait_default = "1"
},
{
.name = "text-anchor",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, text_anchor),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "start"
},
{
.name = "text-rendering",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, text_rendering),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "auto"
},
{
.name = "visibility",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, visibility),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "visible"
},
{
.name = "word-spacing",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, word_spacing),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "normal"
},
{
.name = "writing-mode",
.id = LSM_PROPERTY_OFFSET_TO_ID (LsmSvgStyle, writing_mode),
- .trait_class = &lsm_null_trait_class
+ .trait_class = &lsm_null_trait_class,
+ .trait_default = "lr-tb"
}
};
@@ -380,6 +441,22 @@ lsm_svg_property_bag_serialize (LsmPropertyBag *property_bag)
return lsm_property_manager_serialize (property_manager, property_bag);
}
+static const LsmSvgStyle *
+lsm_svg_get_default_style (void)
+{
+ static LsmSvgStyle *style = NULL;
+ LsmPropertyManager *property_manager = lsm_svg_get_property_manager ();
+
+ if (style != NULL)
+ return style;
+
+ style = g_new (LsmSvgStyle, 1);
+
+ lsm_property_manager_init_default_style (property_manager, style);
+
+ return style;
+}
+
LsmSvgStyle *
lsm_svg_style_new (void)
{
@@ -404,16 +481,26 @@ lsm_svg_style_free (LsmSvgStyle *style)
}
LsmSvgStyle *
-lsm_svg_style_duplicate (const LsmSvgStyle *from)
+lsm_svg_style_new_inherited (const LsmSvgStyle *parent_style, LsmPropertyBag *property_bag)
{
LsmSvgStyle *style;
+ const LsmSvgStyle *default_style;
- g_return_val_if_fail (from != NULL, NULL);
+ default_style = lsm_svg_get_default_style ();
style = g_new (LsmSvgStyle, 1);
- memset (style, 0, offsetof (LsmSvgStyle, clip_path));
- memcpy (&style->clip_path, &from->clip_path, sizeof (LsmSvgStyle) - offsetof (LsmSvgStyle, clip_path));
+ if (parent_style != NULL) {
+ LsmPropertyManager *property_manager = lsm_svg_get_property_manager ();
+
+ memcpy (style, default_style, offsetof (LsmSvgStyle, clip_rule));
+ memcpy (&style->clip_rule, &parent_style->clip_rule,
+ sizeof (LsmSvgStyle) - offsetof (LsmSvgStyle, clip_rule));
+
+ lsm_property_manager_apply_property_bag (property_manager, property_bag, style, parent_style);
+ } else {
+ memcpy (style, default_style, sizeof (LsmSvgStyle));
+ }
/* style->stroke.dash_array = lsm_svg_dash_array_duplicate (from->stroke.dash_array);*/
/* style->text.font_family = g_strdup (from->text.font_family);*/
@@ -421,7 +508,3 @@ lsm_svg_style_duplicate (const LsmSvgStyle *from)
return style;
}
-void
-lsm_svg_style_apply_property_bag (LsmSvgStyle *style, LsmPropertyBag *property_bag)
-{
-}
diff --git a/src/lsmsvgstyle.h b/src/lsmsvgstyle.h
index f7a7f5e..701c349 100644
--- a/src/lsmsvgstyle.h
+++ b/src/lsmsvgstyle.h
@@ -89,8 +89,8 @@ struct _LsmSvgStyle {
LsmProperty * mask;
LsmSvgDoubleProperty * opacity;
LsmProperty * overflow;
- LsmProperty * stop_color;
- LsmProperty * stop_opacity;
+ LsmSvgColorProperty * stop_color;
+ LsmSvgDoubleProperty * stop_opacity;
LsmProperty * text_decoration;
LsmProperty * unicode_bidi;
@@ -188,10 +188,10 @@ struct _LsmSvgStyle {
#endif
-LsmSvgStyle * lsm_svg_style_new (void);
-void lsm_svg_style_free (LsmSvgStyle *style);
-LsmSvgStyle * lsm_svg_style_duplicate (const LsmSvgStyle *style);
-void lsm_svg_style_apply_property_bag (LsmSvgStyle *style, LsmPropertyBag *property_bag);
+LsmSvgStyle * lsm_svg_style_new (void);
+void lsm_svg_style_free (LsmSvgStyle *style);
+LsmSvgStyle * lsm_svg_style_new_inherited (const LsmSvgStyle *parent_style,
+ LsmPropertyBag *property_bag);
G_END_DECLS
diff --git a/src/lsmsvgsvgelement.c b/src/lsmsvgsvgelement.c
index bb5c76a..74da14a 100644
--- a/src/lsmsvgsvgelement.c
+++ b/src/lsmsvgsvgelement.c
@@ -129,7 +129,7 @@ lsm_svg_svg_element_measure (LsmSvgSvgElement *self, double *width, double *heig
/* LsmSvgGraphic implementation */
static void
-lsm_svg_svg_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+_svg_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgSvgElement *svg = LSM_SVG_SVG_ELEMENT (self);
gboolean is_viewbox_defined;
@@ -140,14 +140,11 @@ lsm_svg_svg_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
viewport.width = lsm_svg_view_normalize_length (view, &svg->width.length, LSM_SVG_LENGTH_DIRECTION_HORIZONTAL);
viewport.height = lsm_svg_view_normalize_length (view, &svg->height.length, LSM_SVG_LENGTH_DIRECTION_VERTICAL);
-/* is_viewbox_defined = lsm_dom_attribute_is_defined ((LsmDomAttribute *) &svg->viewbox);*/
+ is_viewbox_defined = lsm_attribute_is_defined ((LsmAttribute *) &svg->viewbox);
-/* if (is_viewbox_defined && (svg->viewbox.value.width <= 0.0 ||*/
-/* svg->viewbox.value.height <= 0.0))*/
-/* return;*/
-
- is_viewbox_defined = svg->viewbox.value.width > 0.0 && svg->viewbox.value.height > 0.0;
-/* return;*/
+ if (is_viewbox_defined && (svg->viewbox.value.width <= 0.0 ||
+ svg->viewbox.value.height <= 0.0))
+ return;
lsm_debug ("[LsmSvgSvgElement::graphic_render] viewport %g, %g, %g, %g",
viewport.x, viewport.y, viewport.width, viewport.height);
@@ -155,20 +152,20 @@ lsm_svg_svg_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
lsm_svg_view_push_viewport (view, &viewport, is_viewbox_defined ? &svg->viewbox.value : NULL,
&svg->preserve_aspect_ratio.value);
- LSM_SVG_GRAPHIC_CLASS (parent_class)->graphic_render (self, view);
+ LSM_SVG_ELEMENT_CLASS (parent_class)->render (self, view);
lsm_svg_view_pop_viewport (view);
}
/* LsmSvgSvgElement implementation */
-LsmSvgStyle *
-lsm_svg_svg_element_get_default_style (LsmSvgSvgElement *svg_element)
-{
- g_return_val_if_fail (LSM_IS_SVG_SVG_ELEMENT (svg_element), NULL);
+/*LsmSvgStyle **/
+/*lsm_svg_svg_element_get_default_style (LsmSvgSvgElement *svg_element)*/
+/*{*/
+/* g_return_val_if_fail (LSM_IS_SVG_SVG_ELEMENT (svg_element), NULL);*/
- return svg_element->default_style;
-}
+/* return svg_element->default_style;*/
+/*}*/
/*void*/
/*lsm_svg_svg_element_update (LsmSvgSvgElement *svg_element)*/
@@ -191,11 +188,11 @@ lsm_svg_svg_element_get_default_style (LsmSvgSvgElement *svg_element)
void
lsm_svg_svg_element_render (LsmSvgSvgElement *svg, LsmSvgView *view)
{
- lsm_svg_view_push_style (view, svg->default_style);
+/* lsm_svg_view_push_style (view, svg->default_style);*/
lsm_svg_view_push_viewbox (view, &svg->svg_box);
lsm_svg_element_render (LSM_SVG_ELEMENT (svg), view);
lsm_svg_view_pop_viewbox (view);
- lsm_svg_view_pop_style (view);
+/* lsm_svg_view_pop_style (view);*/
}
LsmDomNode *
@@ -204,52 +201,59 @@ lsm_svg_svg_element_new (void)
return g_object_new (LSM_TYPE_SVG_SVG_ELEMENT, NULL);
}
+static const LsmSvgLength x_y_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
+static const LsmSvgLength width_height_default = { .value_unit = 100.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
+static const LsmBox viewbox_default = {0.0, 0.0, 0.0, 0.0};
+static const LsmSvgPreserveAspectRatio preserve_aspect_ratio_default = {
+ .defer = FALSE,
+ .align = LSM_SVG_ALIGN_X_MID_Y_MID,
+ .meet_or_slice = LSM_SVG_MEET_OR_SLICE_MEET
+};
+
static void
lsm_svg_svg_element_init (LsmSvgSvgElement *self)
{
- LsmSvgStyle *style;
-
- style = lsm_svg_style_new ();
- self->default_style = style;
- g_return_if_fail (style != NULL);
-
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "opacity", "1.0");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "fill", "black");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "fill-opacity", "1");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "fill-rule", "nonzero");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke", "none");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-width", "1px");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-opacity", "1");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-linejoin", "miter");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-linecap", "butt");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-miterlimit", "4");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "font-family", "sans");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "font-size", "10pt");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stop-color", "black");
- lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stop-opacity", "1");
+ self->x.length = x_y_default;
+ self->y.length = x_y_default;
+ self->width.length = width_height_default;
+ self->height.length = width_height_default;
+ self->viewbox.value = viewbox_default;
+ self->preserve_aspect_ratio.value = preserve_aspect_ratio_default;
+
+/* LsmSvgStyle *style;*/
+
+/* style = lsm_svg_style_new ();*/
+/* self->default_style = style;*/
+/* g_return_if_fail (style != NULL);*/
+
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "opacity", "1.0");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "fill", "black");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "fill-opacity", "1");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "fill-rule", "nonzero");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke", "none");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-width", "1px");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-opacity", "1");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-linejoin", "miter");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-linecap", "butt");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stroke-miterlimit", "4");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "font-family", "sans");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "font-size", "10pt");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stop-color", "black");*/
+/* lsm_dom_element_set_attribute (LSM_DOM_ELEMENT (self), "stop-opacity", "1");*/
}
static void
lsm_svg_svg_element_finalize (GObject *object)
{
- LsmSvgSvgElement *svg_element = LSM_SVG_SVG_ELEMENT (object);
+/* LsmSvgSvgElement *svg_element = LSM_SVG_SVG_ELEMENT (object);*/
- lsm_svg_style_free (svg_element->default_style);
+/* lsm_svg_style_free (svg_element->default_style);*/
parent_class->finalize (object);
}
/* LsmSvgSvgElement class */
-static const LsmSvgLength x_y_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
-static const LsmSvgLength width_height_default = { .value_unit = 100.0, .type = LSM_SVG_LENGTH_TYPE_PERCENTAGE};
-static const LsmBox viewbox_default = {0.0, 0.0, 0.0, 0.0};
-static const LsmSvgPreserveAspectRatio preserve_aspect_ratio_default = {
- .defer = FALSE,
- .align = LSM_SVG_ALIGN_X_MID_Y_MID,
- .meet_or_slice = LSM_SVG_MEET_OR_SLICE_MEET
-};
-
static const LsmAttributeInfos lsm_svg_svg_element_attribute_infos[] = {
{
.name = "x",
@@ -295,7 +299,7 @@ lsm_svg_svg_element_class_init (LsmSvgSvgElementClass *s_svg_class)
GObjectClass *object_class = G_OBJECT_CLASS (s_svg_class);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_svg_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_svg_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_svg_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_svg_class);*/
parent_class = g_type_class_peek_parent (s_svg_class);
@@ -305,7 +309,7 @@ lsm_svg_svg_element_class_init (LsmSvgSvgElementClass *s_svg_class)
/* s_element_class->update = _svg_element_update;*/
- s_graphic_class->graphic_render = lsm_svg_svg_element_graphic_render;
+ s_element_class->render = _svg_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -329,4 +333,4 @@ lsm_svg_svg_element_class_init (LsmSvgSvgElementClass *s_svg_class)
/* offsetof (LsmSvgSvgElement, preserve_aspect_ratio));*/
}
-G_DEFINE_TYPE (LsmSvgSvgElement, lsm_svg_svg_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgSvgElement, lsm_svg_svg_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgsvgelement.h b/src/lsmsvgsvgelement.h
index 280cee5..79e3eb2 100644
--- a/src/lsmsvgsvgelement.h
+++ b/src/lsmsvgsvgelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_SVG_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,9 +37,9 @@ G_BEGIN_DECLS
typedef struct _LsmSvgSvgElementClass LsmSvgSvgElementClass;
struct _LsmSvgSvgElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
- LsmSvgStyle *default_style;
+// LsmSvgStyle *default_style;
LsmSvgLengthAttribute x;
LsmSvgLengthAttribute y;
@@ -53,14 +53,14 @@ struct _LsmSvgSvgElement {
};
struct _LsmSvgSvgElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_svg_element_get_type (void);
LsmDomNode * lsm_svg_svg_element_new (void);
-LsmSvgStyle * lsm_svg_svg_element_get_default_style (LsmSvgSvgElement *svg_element);
+//LsmSvgStyle * lsm_svg_svg_element_get_default_style (LsmSvgSvgElement *svg_element);
//void lsm_svg_svg_element_update (LsmSvgSvgElement *svg_element);
void lsm_svg_svg_element_measure (LsmSvgSvgElement *self, double *width, double *height);
void lsm_svg_svg_element_render (LsmSvgSvgElement *svg_element, LsmSvgView *view);
diff --git a/src/lsmsvgsymbolelement.c b/src/lsmsvgsymbolelement.c
index 89c90a2..6863354 100644
--- a/src/lsmsvgsymbolelement.c
+++ b/src/lsmsvgsymbolelement.c
@@ -77,4 +77,4 @@ lsm_svg_symbol_element_class_init (LsmSvgSymbolElementClass *klass)
/* s_element_class->attributes = lsm_dom_attribute_map_duplicate (s_element_class->attributes);*/
}
-G_DEFINE_TYPE (LsmSvgSymbolElement, lsm_svg_symbol_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgSymbolElement, lsm_svg_symbol_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgsymbolelement.h b/src/lsmsvgsymbolelement.h
index c3ea1b1..40ea9e3 100644
--- a/src/lsmsvgsymbolelement.h
+++ b/src/lsmsvgsymbolelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_SYMBOL_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,11 +37,11 @@ G_BEGIN_DECLS
typedef struct _LsmSvgSymbolElementClass LsmSvgSymbolElementClass;
struct _LsmSvgSymbolElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
};
struct _LsmSvgSymbolElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_symbol_element_get_type (void);
diff --git a/src/lsmsvgtextelement.c b/src/lsmsvgtextelement.c
index f6dc929..90e205b 100644
--- a/src/lsmsvgtextelement.c
+++ b/src/lsmsvgtextelement.c
@@ -63,7 +63,7 @@ lsm_svg_text_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_text_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_text_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgTextElement *text = LSM_SVG_TEXT_ELEMENT (self);
LsmDomNode *node = LSM_DOM_NODE (self);
@@ -132,7 +132,7 @@ lsm_svg_text_element_class_init (LsmSvgTextElementClass *s_text_class)
GObjectClass *object_class = G_OBJECT_CLASS (s_text_class);
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (s_text_class);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (s_text_class);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_text_class);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (s_text_class);*/
parent_class = g_type_class_peek_parent (s_text_class);
@@ -143,8 +143,7 @@ lsm_svg_text_element_class_init (LsmSvgTextElementClass *s_text_class)
/* s_element_class->update = lsm_svg_text_element_update;*/
- s_graphic_class->graphic_render = lsm_svg_text_element_graphic_render;
-
+ s_element_class->render = lsm_svg_text_element_render;
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
lsm_attribute_manager_add_attributes (s_element_class->attribute_manager,
@@ -159,4 +158,4 @@ lsm_svg_text_element_class_init (LsmSvgTextElementClass *s_text_class)
/* offsetof (LsmSvgTextElement, y));*/
}
-G_DEFINE_TYPE (LsmSvgTextElement, lsm_svg_text_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgTextElement, lsm_svg_text_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvgtextelement.h b/src/lsmsvgtextelement.h
index c0da1f6..8e0a28f 100644
--- a/src/lsmsvgtextelement.h
+++ b/src/lsmsvgtextelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_TEXT_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,14 +37,14 @@ G_BEGIN_DECLS
typedef struct _LsmSvgTextElementClass LsmSvgTextElementClass;
struct _LsmSvgTextElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute x;
LsmSvgLengthAttribute y;
};
struct _LsmSvgTextElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_text_element_get_type (void);
diff --git a/src/lsmsvguseelement.c b/src/lsmsvguseelement.c
index bafb6ff..101eb4f 100644
--- a/src/lsmsvguseelement.c
+++ b/src/lsmsvguseelement.c
@@ -73,7 +73,7 @@ lsm_svg_use_element_update (LsmSvgElement *self, LsmSvgStyle *parent_style)
/* LsmSvgGraphic implementation */
static void
-lsm_svg_use_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
+lsm_svg_use_element_render (LsmSvgElement *self, LsmSvgView *view)
{
LsmSvgUseElement *use_element;
LsmDomDocument *document;
@@ -126,6 +126,12 @@ lsm_svg_use_element_graphic_render (LsmSvgElement *self, LsmSvgView *view)
lsm_svg_view_pop_matrix (view);
}
+/*static const LsmSvgMatrix **/
+/*lsm_svg_use_element_get_transform (LsmSvgElement *element)*/
+/*{*/
+/* return (&LSM_SVG_USE_ELEMENT (element)->transform.matrix);*/
+/*}*/
+
/* LsmSvgUseElement implementation */
LsmDomNode *
@@ -142,6 +148,7 @@ lsm_svg_use_element_init (LsmSvgUseElement *self)
/* LsmSvgUseElement class */
static const LsmSvgLength length_default = { .value_unit = 0.0, .type = LSM_SVG_LENGTH_TYPE_PX};
+static const LsmSvgMatrix matrix_default = { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
static const LsmAttributeInfos lsm_svg_use_element_attribute_infos[] = {
{
@@ -173,6 +180,13 @@ static const LsmAttributeInfos lsm_svg_use_element_attribute_infos[] = {
.attribute_offset = offsetof (LsmSvgUseElement, href),
.trait_class = &lsm_null_trait_class
}
+/* ,*/
+/* {*/
+/* .name = "transform",*/
+/* .attribute_offset = offsetof (LsmSvgUseElement, transform),*/
+/* .trait_class = &lsm_svg_matrix_trait_class,*/
+/* .trait_default = &matrix_default*/
+/* }*/
};
static void
@@ -180,7 +194,7 @@ lsm_svg_use_element_class_init (LsmSvgUseElementClass *klass)
{
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (klass);
LsmSvgElementClass *s_element_class = LSM_SVG_ELEMENT_CLASS (klass);
- LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (klass);
+/* LsmSvgGraphicClass *s_graphic_class = LSM_SVG_GRAPHIC_CLASS (klass);*/
parent_class = g_type_class_peek_parent (klass);
@@ -189,7 +203,8 @@ lsm_svg_use_element_class_init (LsmSvgUseElementClass *klass)
/* s_element_class->update = lsm_svg_use_element_update;*/
- s_graphic_class->graphic_render = lsm_svg_use_element_graphic_render;
+ s_element_class->render = lsm_svg_use_element_render;
+/* s_element_class->get_transform = lsm_svg_use_element_get_transform;*/
s_element_class->attribute_manager = lsm_attribute_manager_duplicate (s_element_class->attribute_manager);
@@ -211,4 +226,4 @@ lsm_svg_use_element_class_init (LsmSvgUseElementClass *klass)
/* offsetof (LsmSvgUseElement, href));*/
}
-G_DEFINE_TYPE (LsmSvgUseElement, lsm_svg_use_element, LSM_TYPE_SVG_GRAPHIC)
+G_DEFINE_TYPE (LsmSvgUseElement, lsm_svg_use_element, LSM_TYPE_SVG_ELEMENT)
diff --git a/src/lsmsvguseelement.h b/src/lsmsvguseelement.h
index 5b33c89..3ea6c4a 100644
--- a/src/lsmsvguseelement.h
+++ b/src/lsmsvguseelement.h
@@ -23,7 +23,7 @@
#define LSM_SVG_USE_ELEMENT_H
#include <lsmsvg.h>
-#include <lsmsvggraphic.h>
+#include <lsmsvgelement.h>
G_BEGIN_DECLS
@@ -37,7 +37,7 @@ G_BEGIN_DECLS
typedef struct _LsmSvgUseElementClass LsmSvgUseElementClass;
struct _LsmSvgUseElement {
- LsmSvgGraphic graphic;
+ LsmSvgElement element;
LsmSvgLengthAttribute x;
LsmSvgLengthAttribute y;
@@ -45,10 +45,12 @@ struct _LsmSvgUseElement {
LsmSvgLengthAttribute height;
LsmAttribute href;
+
+// LsmSvgTransformAttribute transform;
};
struct _LsmSvgUseElementClass {
- LsmSvgGraphicClass parent_class;
+ LsmSvgElementClass element_class;
};
GType lsm_svg_use_element_get_type (void);
diff --git a/src/lsmsvgview.c b/src/lsmsvgview.c
index ea1234e..87f1a23 100644
--- a/src/lsmsvgview.c
+++ b/src/lsmsvgview.c
@@ -123,6 +123,7 @@ _set_pattern (LsmSvgView *view, cairo_pattern_t *pattern)
g_return_if_fail (view->pattern_data->pattern == NULL);
view->pattern_data->pattern = pattern;
+ view->last_stop_offset = 0.0;
}
void
@@ -147,15 +148,37 @@ lsm_svg_view_create_linear_gradient (LsmSvgView *view,
}
void
-lsm_svg_view_add_gradient_color_stop (LsmSvgView *view, double offset, const LsmSvgColor *color, double opacity)
+lsm_svg_view_add_gradient_color_stop (LsmSvgView *view, double offset)
+/* , const LsmSvgColor *color, double opacity)*/
{
+ const LsmSvgStyle *style;
+
g_return_if_fail (LSM_IS_SVG_VIEW (view));
g_return_if_fail (view->pattern_data != NULL);
g_return_if_fail (view->pattern_data->pattern != NULL);
- g_return_if_fail (color != NULL);
+/* g_return_if_fail (color != NULL);*/
+
+ if (offset > 1.0)
+ offset = 1.0;
+
+ if (offset < view->last_stop_offset)
+ offset = view->last_stop_offset;
+ else
+ view->last_stop_offset = offset;
+
+ style = view->style;
+
+/* cairo_pattern_add_color_stop_rgba (view->pattern_data->pattern, offset,*/
+/* color->red, color->green, color->blue, opacity);*/
+ lsm_debug ("[LsmSvgView::add_gradient_color_stop] opacity = %g", style->stop_opacity->value);
+
cairo_pattern_add_color_stop_rgba (view->pattern_data->pattern, offset,
- color->red, color->green, color->blue, opacity);
+ style->stop_color->value.red,
+ style->stop_color->value.green,
+ style->stop_color->value.blue,
+ style->stop_opacity->value);
+/* color->red, color->green, color->blue, opacity);*/
}
void
@@ -786,7 +809,7 @@ paint (LsmSvgView *view)
{
/* LsmSvgFillAttributeBag *fill;*/
/* LsmSvgStrokeAttributeBag *stroke;*/
- LsmSvgGraphic *graphic;
+ LsmSvgElement *element;
const LsmSvgStyle *style;
cairo_t *cairo;
gboolean use_group;
@@ -796,9 +819,9 @@ paint (LsmSvgView *view)
/* g_return_if_fail (view->stroke_stack != NULL);*/
/* g_return_if_fail (view->element_stack != NULL);*/
- graphic = view->element_stack->data;
+ element = view->element_stack->data;
- g_return_if_fail (LSM_IS_SVG_GRAPHIC (graphic));
+ g_return_if_fail (LSM_IS_SVG_ELEMENT (element));
cairo = view->dom_view.cairo;
style = view->style;
@@ -806,7 +829,7 @@ paint (LsmSvgView *view)
/* fill = view->fill_stack->data;*/
/* stroke = view->stroke_stack->data;*/
-/* if (view->mask_stack != NULL && view->mask_stack->data == graphic->mask) {*/
+/* if (view->mask_stack != NULL && view->mask_stack->data == element->mask) {*/
if (style->opacity != NULL) {
/* LsmSvgMaskAttributeBag *mask;*/
@@ -1243,7 +1266,7 @@ lsm_svg_view_pop_viewport (LsmSvgView *view)
}
void
-lsm_svg_view_push_matrix (LsmSvgView *view, LsmSvgMatrix *matrix)
+lsm_svg_view_push_matrix (LsmSvgView *view, const LsmSvgMatrix *matrix)
{
cairo_matrix_t cr_matrix;
cairo_matrix_t *ctm;
@@ -1384,37 +1407,31 @@ lsm_svg_view_pop_clip (LsmSvgView *view)
cairo_restore (view->dom_view.cairo);
}
+#endif
void
lsm_svg_view_push_group_opacity (LsmSvgView *view)
{
- LsmSvgMaskAttributeBag *mask;
-
g_return_if_fail (LSM_IS_SVG_VIEW (view));
- g_return_if_fail (view->mask_stack != NULL);
+ g_return_if_fail (view->style != NULL);
- mask = view->mask_stack->data;
-
- if (mask->opacity.value < 1.0)
+ if (view->style->opacity->value < 1.0)
cairo_push_group (view->dom_view.cairo);
}
void
lsm_svg_view_pop_group_opacity (LsmSvgView *view)
{
- LsmSvgMaskAttributeBag *mask;
-
g_return_if_fail (LSM_IS_SVG_VIEW (view));
- g_return_if_fail (view->mask_stack != NULL);
+ g_return_if_fail (view->style != NULL);
- mask = view->mask_stack->data;
-
- if (mask->opacity.value < 1.0) {
+ if (view->style->opacity->value < 1.0) {
cairo_pop_group_to_source (view->dom_view.cairo);
- cairo_paint_with_alpha (view->dom_view.cairo, mask->opacity.value);
+ cairo_paint_with_alpha (view->dom_view.cairo, view->style->opacity->value);
}
}
+#if 0
void
lsm_svg_view_push_mask_attributes (LsmSvgView *view, const LsmSvgMaskAttributeBag *mask)
{
diff --git a/src/lsmsvgview.h b/src/lsmsvgview.h
index abbbfd8..7294907 100644
--- a/src/lsmsvgview.h
+++ b/src/lsmsvgview.h
@@ -68,6 +68,8 @@ struct _LsmSvgView {
gboolean is_clipping;
LsmBox clip_extents;
+
+ double last_stop_offset;
};
struct _LsmSvgViewClass {
@@ -88,8 +90,9 @@ void lsm_svg_view_create_radial_gradient (LsmSvgView *view, double cx, double
double r, double fx, double fy);
void lsm_svg_view_create_linear_gradient (LsmSvgView *view, double x1, double y1,
double x2, double y2);
-void lsm_svg_view_add_gradient_color_stop (LsmSvgView *view, double offset,
- const LsmSvgColor *color, double opacity);
+void lsm_svg_view_add_gradient_color_stop (LsmSvgView *view, double offset);
+//,
+// const LsmSvgColor *color, double opacity);
void lsm_svg_view_set_gradient_properties (LsmSvgView *view,
LsmSvgSpreadMethod method,
LsmSvgPatternUnits units,
@@ -119,20 +122,20 @@ void lsm_svg_view_push_viewport (LsmSvgView *view, const LsmBox *viewport,
const LsmBox *viewbox,
const LsmSvgPreserveAspectRatio *aspect_ratio);
void lsm_svg_view_pop_viewport (LsmSvgView *view);
-void lsm_svg_view_push_matrix (LsmSvgView *view, LsmSvgMatrix *matrix);
+void lsm_svg_view_push_matrix (LsmSvgView *view, const LsmSvgMatrix *matrix);
void lsm_svg_view_pop_matrix (LsmSvgView *view);
void lsm_svg_view_push_element (LsmSvgView *view, const LsmSvgElement *element);
void lsm_svg_view_pop_element (LsmSvgView *view);
-//void lsm_svg_view_push_group_opacity (LsmSvgView *view);
-//void lsm_svg_view_pop_group_opacity (LsmSvgView *view);
-
void lsm_svg_view_push_style (LsmSvgView *view, const LsmSvgStyle *style);
void lsm_svg_view_pop_style (LsmSvgView *view);
const LsmSvgStyle * lsm_svg_view_get_current_style (LsmSvgView *view);
+void lsm_svg_view_push_group_opacity (LsmSvgView *view);
+void lsm_svg_view_pop_group_opacity (LsmSvgView *view);
+
//void lsm_svg_view_push_mask_attributes (LsmSvgView *view, const LsmSvgMaskAttributeBag *mask);
//void lsm_svg_view_pop_mask_attributes (LsmSvgView *view);
//void lsm_svg_view_push_fill_attributes (LsmSvgView *view, const LsmSvgFillAttributeBag *fill);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]