[goffice] Make GOPath a boxed type.
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Make GOPath a boxed type.
- Date: Fri, 9 Apr 2010 20:20:21 +0000 (UTC)
commit 2e2ab385f2bf0d89142c38e4d9088acb23dcdd24
Author: Jean Brefort <jean brefort normalesup org>
Date: Fri Apr 9 22:20:42 2010 +0200
Make GOPath a boxed type.
ChangeLog | 6 ++++
goffice/utils/go-path.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++-
goffice/utils/go-path.h | 8 +++++
3 files changed, 80 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a62f1f6..a2473f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2010-04-09 Jean Brefort <jean brefort normalesup org>
+ * goffice/utils/go-path.c (go_path_new), (go_path_free),
+ (go_path_ref), (go_path_get_type), (go_path_to_cairo): new GOPath functions.
+ * goffice/utils/go-path.h: ditto.
+
+2010-04-09 Jean Brefort <jean brefort normalesup org>
+
* goffice/app/go-plugin.c (go_plugins_init), (go_plugins_add): fixed issues
related to components intialization.
* goffice/component/go-component-factory.c
diff --git a/goffice/utils/go-path.c b/goffice/utils/go-path.c
index d908ecb..3236d24 100644
--- a/goffice/utils/go-path.c
+++ b/goffice/utils/go-path.c
@@ -70,6 +70,7 @@ struct _GOPath {
GOPathDataBuffer *data_buffer_tail;
GOPathOptions options;
+ unsigned refs;
};
static void
@@ -161,6 +162,8 @@ go_path_new (void)
return NULL;
}
+ path->refs = 1;
+
return path;
}
@@ -187,7 +190,8 @@ go_path_clear (GOPath *path)
* go_path_free:
* @path: a #GOPath
*
- * Frees all memory allocated for @path.
+ * Decrements references count and frees all memory allocated for @path if
+ * references count reaches 0.
**/
void
@@ -197,6 +201,10 @@ go_path_free (GOPath *path)
g_return_if_fail (path != NULL);
+ path->refs--;
+ if (path->refs > 0)
+ return;
+
while (path->data_buffer_head != NULL) {
buffer = path->data_buffer_head->next;
go_path_data_buffer_free (path->data_buffer_head);
@@ -206,6 +214,35 @@ go_path_free (GOPath *path)
}
/**
+ * go_path_ref:
+ * @path: a #GOPath
+ *
+ * Increments references count to @path.
+ **/
+
+void
+go_path_ref (GOPath *path)
+{
+ g_return_if_fail (path != NULL);
+
+ path->refs++;
+}
+
+GType
+go_path_get_type (void)
+{
+ static GType type_path = 0;
+
+ if (!type_path)
+ type_path = g_boxed_type_register_static
+ ("GOPath",
+ (GBoxedCopyFunc) go_path_ref,
+ (GBoxedFreeFunc) go_path_free);
+
+ return type_path;
+}
+
+/**
* go_path_set_options:
* @path: a #GOPath
* @options: #GOPathOptions
@@ -533,3 +570,31 @@ go_path_interpret (GOPath const *path,
}
}
+static void
+go_path_cairo_move_to (cairo_t *cr, GOPathPoint const *point)
+{
+ cairo_move_to (cr, point->x, point->y);
+}
+
+static void
+go_path_cairo_line_to (cairo_t *cr, GOPathPoint const *point)
+{
+ cairo_line_to (cr, point->x, point->y);
+}
+
+static void
+go_path_cairo_curve_to (cairo_t *cr, GOPathPoint const *point0,
+ GOPathPoint const *point1, GOPathPoint const *point2)
+{
+ cairo_curve_to (cr, point0->x, point0->y, point1->x, point1->y, point2->x, point2->y);
+}
+
+void
+go_path_to_cairo (GOPath const *path, GOPathDirection direction, cairo_t *cr)
+{
+ go_path_interpret (path, direction,
+ (GOPathMoveToFunc *) go_path_cairo_move_to,
+ (GOPathLineToFunc *) go_path_cairo_line_to,
+ (GOPathCurveToFunc *) go_path_cairo_curve_to,
+ (GOPathClosePathFunc *) cairo_close_path, cr);
+}
diff --git a/goffice/utils/go-path.h b/goffice/utils/go-path.h
index ac676d9..08a9730 100644
--- a/goffice/utils/go-path.h
+++ b/goffice/utils/go-path.h
@@ -58,10 +58,14 @@ typedef void (GOPathCurveToFunc) (void *closure, GOPathPoint const *point0,
GOPathPoint const *point2);
typedef void (GOPathClosePathFunc) (void *closure);
+GType go_path_get_type (void);
+
+#define GO_TYPE_PATH go_path_get_type ()
#define GO_IS_PATH(x) ((x) != NULL)
GOPath *go_path_new (void);
void go_path_clear (GOPath *path);
+void go_path_ref (GOPath *path);
void go_path_free (GOPath *path);
void go_path_set_options (GOPath *path, GOPathOptions options);
@@ -100,6 +104,10 @@ void go_path_interpret (GOPath const *path,
GOPathClosePathFunc *close_path,
void *closure);
+void go_path_to_cairo (GOPath const *path,
+ GOPathDirection direction,
+ cairo_t *cr);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]