[cairo-commit] goocanvas/src goocanvasitem.c, 1.21,
1.22 goocanvasitem.h, 1.14, 1.15 goocanvasitemmodel.c, 1.9,
1.10 goocanvasitemmodel.h, 1.7, 1.8 goocanvasitemsimple.c,
1.26, 1.27
Damon Chaplin
commit at pdx.freedesktop.org
Mon Feb 26 17:28:44 PST 2007
Committed by: damon
Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv22088/src
Modified Files:
goocanvasitem.c goocanvasitem.h goocanvasitemmodel.c
goocanvasitemmodel.h goocanvasitemsimple.c
Log Message:
2007-02-27 Damon Chaplin <damon at gnome.org>
* src/goocanvasitemmodel.[hc]:
* src/goocanvasitem.[hc]: changed get_transform() method to take a
cairo_matrix_t* to fill in, and return a boolean if a transform is set.
This is better for bindings.
* src/goocanvasitemsimple.c: updated get_transform() methods.
Index: goocanvasitem.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- goocanvasitem.c 27 Feb 2007 01:01:39 -0000 1.21
+++ goocanvasitem.c 27 Feb 2007 01:28:38 -0000 1.22
@@ -754,17 +754,19 @@
/**
* goo_canvas_item_get_transform:
* @item: an item.
+ * @transform: the place to store the transform.
*
* Gets the transformation matrix of an item.
*
- * Returns: the item's transformation matrix.
+ * Returns: %TRUE if a transform is set.
**/
-cairo_matrix_t*
-goo_canvas_item_get_transform (GooCanvasItem *item)
+gboolean
+goo_canvas_item_get_transform (GooCanvasItem *item,
+ cairo_matrix_t *matrix)
{
GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
- return iface->get_transform ? iface->get_transform (item) : NULL;
+ return iface->get_transform ? iface->get_transform (item, matrix) : FALSE;
}
@@ -786,21 +788,13 @@
cairo_matrix_t *transform)
{
GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
- cairo_matrix_t *item_transform;
if (child && iface->get_transform_for_child)
return iface->get_transform_for_child (item, child, transform);
/* We fallback to the standard get_transform method. */
if (iface->get_transform)
- {
- item_transform = iface->get_transform (item);
- if (item_transform)
- {
- *transform = *item_transform;
- return TRUE;
- }
- }
+ return iface->get_transform (item, transform);
return FALSE;
}
@@ -863,11 +857,9 @@
gdouble ty)
{
GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
- cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t new_matrix = { 1, 0, 0, 1, 0, 0 };
- matrix = iface->get_transform (item);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (item, &new_matrix);
cairo_matrix_translate (&new_matrix, tx, ty);
iface->set_transform (item, &new_matrix);
}
@@ -887,11 +879,9 @@
gdouble sy)
{
GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
- cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t new_matrix = { 1, 0, 0, 1, 0, 0 };
- matrix = iface->get_transform (item);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (item, &new_matrix);
cairo_matrix_scale (&new_matrix, sx, sy);
iface->set_transform (item, &new_matrix);
}
@@ -914,12 +904,10 @@
gdouble cy)
{
GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
- cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t new_matrix = { 1, 0, 0, 1, 0, 0 };
double radians = degrees * (M_PI / 180);
- matrix = iface->get_transform (item);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (item, &new_matrix);
cairo_matrix_translate (&new_matrix, cx, cy);
cairo_matrix_rotate (&new_matrix, radians);
cairo_matrix_translate (&new_matrix, -cx, -cy);
@@ -944,12 +932,10 @@
gdouble cy)
{
GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
- cairo_matrix_t *matrix, tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
double radians = degrees * (M_PI / 180);
- matrix = iface->get_transform (item);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (item, &new_matrix);
cairo_matrix_translate (&new_matrix, cx, cy);
cairo_matrix_init (&tmp, 1, 0, tan (radians), 1, 0, 0);
cairo_matrix_multiply (&new_matrix, &tmp, &new_matrix);
@@ -975,12 +961,10 @@
gdouble cy)
{
GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
- cairo_matrix_t *matrix, tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
double radians = degrees * (M_PI / 180);
- matrix = iface->get_transform (item);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (item, &new_matrix);
cairo_matrix_translate (&new_matrix, cx, cy);
cairo_matrix_init (&tmp, 1, tan (radians), 0, 1, 0, 0);
cairo_matrix_multiply (&new_matrix, &tmp, &new_matrix);
@@ -1154,19 +1138,19 @@
GooCanvasAnimateType type)
{
GObject *object;
- cairo_matrix_t *matrix;
+ cairo_matrix_t matrix = { 1, 0, 0, 1, 0, 0 };
GooCanvasItemAnimation *anim;
if (item)
{
GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
- matrix = iface->get_transform (item);
+ iface->get_transform (item, &matrix);
object = (GObject*) item;
}
else
{
GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
- matrix = iface->get_transform (model);
+ iface->get_transform (model, &matrix);
object = (GObject*) model;
}
@@ -1176,10 +1160,7 @@
anim->model = model;
anim->step = 0;
anim->total_steps = duration / step_time;
- if (matrix)
- anim->start = *matrix;
- else
- cairo_matrix_init_identity (&anim->start);
+ anim->start = matrix;
anim->absolute = absolute;
anim->forward = TRUE;
Index: goocanvasitem.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- goocanvasitem.h 27 Feb 2007 01:01:39 -0000 1.14
+++ goocanvasitem.h 27 Feb 2007 01:28:38 -0000 1.15
@@ -214,7 +214,8 @@
gdouble y_offset);
/* Virtual methods that canvas items may implement. */
- cairo_matrix_t* (* get_transform) (GooCanvasItem *item);
+ gboolean (* get_transform) (GooCanvasItem *item,
+ cairo_matrix_t *matrix);
void (* set_transform) (GooCanvasItem *item,
cairo_matrix_t *matrix);
GooCanvasStyle* (* get_style) (GooCanvasItem *item);
@@ -326,7 +327,8 @@
void goo_canvas_item_lower (GooCanvasItem *item,
GooCanvasItem *below);
-cairo_matrix_t* goo_canvas_item_get_transform (GooCanvasItem *item);
+gboolean goo_canvas_item_get_transform (GooCanvasItem *item,
+ cairo_matrix_t *matrix);
void goo_canvas_item_set_transform (GooCanvasItem *item,
cairo_matrix_t *matrix);
void goo_canvas_item_set_simple_transform (GooCanvasItem *item,
Index: goocanvasitemmodel.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- goocanvasitemmodel.c 17 Feb 2007 13:48:37 -0000 1.9
+++ goocanvasitemmodel.c 27 Feb 2007 01:28:38 -0000 1.10
@@ -519,17 +519,19 @@
/**
* goo_canvas_item_model_get_transform:
* @model: an item model.
+ * @transform: the place to store the transform.
*
* Gets the transformation matrix of an item model.
*
- * Returns: the model's transformation matrix.
+ * Returns: %TRUE if a transform is set.
**/
-cairo_matrix_t*
-goo_canvas_item_model_get_transform (GooCanvasItemModel *model)
+gboolean
+goo_canvas_item_model_get_transform (GooCanvasItemModel *model,
+ cairo_matrix_t *matrix)
{
GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
- return iface->get_transform ? iface->get_transform (model) : NULL;
+ return iface->get_transform ? iface->get_transform (model, matrix) : FALSE;
}
@@ -590,11 +592,9 @@
gdouble ty)
{
GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
- cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t new_matrix = { 1, 0, 0, 1, 0, 0 };
- matrix = iface->get_transform (model);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (model, &new_matrix);
cairo_matrix_translate (&new_matrix, tx, ty);
iface->set_transform (model, &new_matrix);
}
@@ -614,11 +614,9 @@
gdouble sy)
{
GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
- cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t new_matrix = { 1, 0, 0, 1, 0, 0 };
- matrix = iface->get_transform (model);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (model, &new_matrix);
cairo_matrix_scale (&new_matrix, sx, sy);
iface->set_transform (model, &new_matrix);
}
@@ -641,12 +639,10 @@
gdouble cy)
{
GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
- cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t new_matrix = { 1, 0, 0, 1, 0, 0 };
double radians = degrees * (M_PI / 180);
- matrix = iface->get_transform (model);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (model, &new_matrix);
cairo_matrix_translate (&new_matrix, cx, cy);
cairo_matrix_rotate (&new_matrix, radians);
cairo_matrix_translate (&new_matrix, -cx, -cy);
@@ -671,12 +667,10 @@
gdouble cy)
{
GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
- cairo_matrix_t *matrix, tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
double radians = degrees * (M_PI / 180);
- matrix = iface->get_transform (model);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (model, &new_matrix);
cairo_matrix_translate (&new_matrix, cx, cy);
cairo_matrix_init (&tmp, 1, 0, tan (radians), 1, 0, 0);
cairo_matrix_multiply (&new_matrix, &tmp, &new_matrix);
@@ -702,12 +696,10 @@
gdouble cy)
{
GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
- cairo_matrix_t *matrix, tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_matrix_t tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
double radians = degrees * (M_PI / 180);
- matrix = iface->get_transform (model);
- if (matrix)
- new_matrix = *matrix;
+ iface->get_transform (model, &new_matrix);
cairo_matrix_translate (&new_matrix, cx, cy);
cairo_matrix_init (&tmp, 1, tan (radians), 0, 1, 0, 0);
cairo_matrix_multiply (&new_matrix, &tmp, &new_matrix);
Index: goocanvasitemmodel.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- goocanvasitemmodel.h 13 Feb 2007 12:32:44 -0000 1.7
+++ goocanvasitemmodel.h 27 Feb 2007 01:28:38 -0000 1.8
@@ -114,7 +114,8 @@
GooCanvas *canvas);
/* Virtual methods that all item models may implement. */
- cairo_matrix_t* (* get_transform) (GooCanvasItemModel *model);
+ gboolean (* get_transform) (GooCanvasItemModel *model,
+ cairo_matrix_t *matrix);
void (* set_transform) (GooCanvasItemModel *model,
cairo_matrix_t *matrix);
GooCanvasStyle* (* get_style) (GooCanvasItemModel *model);
@@ -191,7 +192,8 @@
void goo_canvas_item_model_lower (GooCanvasItemModel *model,
GooCanvasItemModel *below);
-cairo_matrix_t* goo_canvas_item_model_get_transform (GooCanvasItemModel *model);
+gboolean goo_canvas_item_model_get_transform (GooCanvasItemModel *model,
+ cairo_matrix_t *matrix);
void goo_canvas_item_model_set_transform (GooCanvasItemModel *model,
cairo_matrix_t *matrix);
void goo_canvas_item_model_set_simple_transform (GooCanvasItemModel *model,
Index: goocanvasitemsimple.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemsimple.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- goocanvasitemsimple.c 27 Feb 2007 01:01:39 -0000 1.26
+++ goocanvasitemsimple.c 27 Feb 2007 01:28:38 -0000 1.27
@@ -872,10 +872,18 @@
}
-static cairo_matrix_t*
-goo_canvas_item_simple_get_transform (GooCanvasItem *item)
+static gboolean
+goo_canvas_item_simple_get_transform (GooCanvasItem *item,
+ cairo_matrix_t *matrix)
{
- return GOO_CANVAS_ITEM_SIMPLE (item)->simple_data->transform;
+ GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
+ GooCanvasItemSimpleData *simple_data = simple->simple_data;
+
+ if (!simple_data->transform)
+ return FALSE;
+
+ *matrix = *simple_data->transform;
+ return TRUE;
}
@@ -1860,11 +1868,18 @@
}
-static cairo_matrix_t*
-goo_canvas_item_model_simple_get_transform (GooCanvasItemModel *model)
+static gboolean
+goo_canvas_item_model_simple_get_transform (GooCanvasItemModel *model,
+ cairo_matrix_t *matrix)
{
GooCanvasItemModelSimple *smodel = (GooCanvasItemModelSimple*) model;
- return smodel->simple_data.transform;
+ GooCanvasItemSimpleData *simple_data = &smodel->simple_data;
+
+ if (!simple_data->transform)
+ return FALSE;
+
+ *matrix = *simple_data->transform;
+ return TRUE;
}
More information about the cairo-commit
mailing list