aboutsummaryrefslogtreecommitdiffstats
path: root/libgnomecanvas/gnome-canvas.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-10-15 07:25:40 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-30 01:50:00 +0800
commit24e39b9fb54cad437cc12b24e953be890519d86a (patch)
tree554da00fae5be782689f20ada6b3259c633663d5 /libgnomecanvas/gnome-canvas.c
parent9c183ab12ae27089ce972e29aab7000c2edfd466 (diff)
downloadgsoc2013-evolution-24e39b9fb54cad437cc12b24e953be890519d86a.tar.gz
gsoc2013-evolution-24e39b9fb54cad437cc12b24e953be890519d86a.tar.zst
gsoc2013-evolution-24e39b9fb54cad437cc12b24e953be890519d86a.zip
gnome-canvas: Rewrite GnomeCanvasShape to use Cairo
Dashing properties were commented out in the process. They are not used inside Evolution.
Diffstat (limited to 'libgnomecanvas/gnome-canvas.c')
-rw-r--r--libgnomecanvas/gnome-canvas.c90
1 files changed, 86 insertions, 4 deletions
diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c
index 958fc45e1c..203f36d909 100644
--- a/libgnomecanvas/gnome-canvas.c
+++ b/libgnomecanvas/gnome-canvas.c
@@ -1044,6 +1044,44 @@ gnome_canvas_item_i2w_affine (GnomeCanvasItem *item, gdouble affine[6])
}
}
+void
+gnome_canvas_item_i2w_matrix (GnomeCanvasItem *item, cairo_matrix_t *matrix)
+{
+ g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
+ g_return_if_fail (matrix != NULL);
+
+ cairo_matrix_init_identity (matrix);
+
+ while (item) {
+ if (item->xform != NULL) {
+ cairo_matrix_t tmp;
+ gnome_canvas_matrix_from_affine (&tmp, item->xform);
+ cairo_matrix_multiply (matrix, matrix, &tmp);
+ }
+
+ item = item->parent;
+ }
+}
+
+void
+gnome_canvas_item_w2i_matrix (GnomeCanvasItem *item, cairo_matrix_t *matrix)
+{
+ g_return_if_fail (GNOME_IS_CANVAS_ITEM (item));
+ g_return_if_fail (matrix != NULL);
+
+ cairo_matrix_init_identity (matrix);
+
+ while (item) {
+ if (item->xform != NULL) {
+ cairo_matrix_t tmp;
+ gnome_canvas_matrix_from_affine (&tmp, item->xform);
+ cairo_matrix_multiply (matrix, &tmp, matrix);
+ }
+
+ item = item->parent;
+ }
+}
+
/**
* gnome_canvas_item_w2i:
* @item: A canvas item.
@@ -1128,11 +1166,11 @@ gnome_canvas_item_i2c_affine (GnomeCanvasItem *item, gdouble affine[6])
void
gnome_canvas_item_i2c_matrix (GnomeCanvasItem *item, cairo_matrix_t *matrix)
{
- gdouble affine;
-
- gnome_canvas_item_i2c_affine (item, &affine);
+ cairo_matrix_t i2w, w2c;
- gnome_canvas_matrix_from_affine (matrix, &affine);
+ gnome_canvas_item_i2w_matrix (item, &i2w);
+ gnome_canvas_w2c_matrix (item->canvas, &w2c);
+ cairo_matrix_multiply (matrix, &i2w, &w2c);
}
/* Returns whether the item is an inferior of or is equal to the parent. */
@@ -3841,6 +3879,50 @@ gnome_canvas_w2c_affine (GnomeCanvas *canvas, gdouble affine[6])
}
/**
+ * gnome_canvas_w2c_matrix:
+ * @canvas: A canvas.
+ * @matrix: (out): matrix to initialize
+ *
+ * Gets the transformtion matrix that converts from world coordinates to canvas
+ * pixel coordinates.
+ **/
+void
+gnome_canvas_w2c_matrix (GnomeCanvas *canvas, cairo_matrix_t *matrix)
+{
+ g_return_if_fail (GNOME_IS_CANVAS (canvas));
+ g_return_if_fail (matrix != NULL);
+
+ cairo_matrix_init_scale (matrix,
+ canvas->pixels_per_unit,
+ canvas->pixels_per_unit);
+ cairo_matrix_translate (matrix,
+ -canvas->scroll_x1,
+ -canvas->scroll_y1);
+}
+
+/**
+ * gnome_canvas_c2w_matrix:
+ * @canvas: A canvas.
+ * @matrix: (out): matrix to initialize
+ *
+ * Gets the transformtion matrix that converts from canvas pixel coordinates to
+ * world coordinates.
+ **/
+void
+gnome_canvas_c2w_matrix (GnomeCanvas *canvas, cairo_matrix_t *matrix)
+{
+ g_return_if_fail (GNOME_IS_CANVAS (canvas));
+ g_return_if_fail (matrix != NULL);
+
+ cairo_matrix_init_translate (matrix,
+ canvas->scroll_x1,
+ canvas->scroll_y1);
+ cairo_matrix_scale (matrix,
+ 1 / canvas->pixels_per_unit,
+ 1 / canvas->pixels_per_unit);
+}
+
+/**
* gnome_canvas_w2c:
* @canvas: A canvas.
* @wx: World X coordinate.