[gtk+/wip/ebassi/gsk-renderer: 96/126] gsk: Rename set_offset() to set_anchor_point()
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer: 96/126] gsk: Rename set_offset() to set_anchor_point()
- Date: Tue, 9 Aug 2016 16:38:49 +0000 (UTC)
commit 8b9cd74413ccf7b469999d2af32b768c8e2ce730
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Aug 4 15:20:06 2016 +0100
gsk: Rename set_offset() to set_anchor_point()
The naming is consistent with other scene graph libraries, as it
represents an additional translation transformation applied on top of
the provided transformation matrices.
We can also simplify the implementation by applying the translation when
we compute the world matrix.
gsk/gskrendernode.c | 18 +++++++-----------
gsk/gskrendernode.h | 14 +++++++-------
gsk/gskrendernodeprivate.h | 2 +-
gtk/gtkwidget.c | 8 +++++---
4 files changed, 20 insertions(+), 22 deletions(-)
---
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c
index 45cdd54..ecf38a2 100644
--- a/gsk/gskrendernode.c
+++ b/gsk/gskrendernode.c
@@ -178,7 +178,8 @@ gsk_render_node_init (GskRenderNode *self)
graphene_matrix_init_identity (&self->transform);
graphene_matrix_init_identity (&self->child_transform);
- graphene_point3d_init (&self->offset, 0.f, 0.f, 0.f);
+
+ graphene_point3d_init (&self->anchor_point, 0.f, 0.f, 0.f);
self->opacity = 1.0;
@@ -935,24 +936,17 @@ gsk_render_node_set_transform (GskRenderNode *node,
else
graphene_matrix_init_from_matrix (&node->transform, transform);
- graphene_matrix_translate (&node->transform, &node->offset);
-
node->transform_set = !graphene_matrix_is_identity (&node->transform);
}
void
-gsk_render_node_set_offset (GskRenderNode *node,
- const graphene_point3d_t *offset)
+gsk_render_node_set_anchor_point (GskRenderNode *node,
+ const graphene_point3d_t *offset)
{
g_return_if_fail (GSK_IS_RENDER_NODE (node));
g_return_if_fail (node->is_mutable);
- graphene_point3d_scale (&node->offset, -1, &node->offset);
- graphene_matrix_translate (&node->transform, &node->offset);
- graphene_point3d_init_from_point (&node->offset, offset);
- graphene_matrix_translate (&node->transform, &node->offset);
-
- node->transform_set = !graphene_matrix_is_identity (&node->transform);
+ graphene_point3d_init_from_point (&node->anchor_point, offset);
}
/**
@@ -1197,6 +1191,8 @@ gsk_render_node_update_world_matrix (GskRenderNode *node,
if (node->transform_set)
graphene_matrix_multiply (&tmp, &node->transform, &tmp);
+ graphene_matrix_translate (&tmp, &node->anchor_point);
+
graphene_matrix_multiply (&tmp, &parent->world_matrix, &node->world_matrix);
}
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index 2d03b4b..ced2630 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -89,17 +89,17 @@ gboolean gsk_render_node_contains (GskRenderNode *
GskRenderNode *descendant);
GDK_AVAILABLE_IN_3_22
-void gsk_render_node_set_bounds (GskRenderNode *node,
- const graphene_rect_t *bounds);
+void gsk_render_node_set_bounds (GskRenderNode *node,
+ const graphene_rect_t *bounds);
GDK_AVAILABLE_IN_3_22
-void gsk_render_node_set_transform (GskRenderNode *node,
- const graphene_matrix_t *transform);
+void gsk_render_node_set_transform (GskRenderNode *node,
+ const graphene_matrix_t *transform);
GDK_AVAILABLE_IN_3_22
-void gsk_render_node_set_offset (GskRenderNode *node,
+void gsk_render_node_set_anchor_point (GskRenderNode *node,
const graphene_point3d_t *offset);
GDK_AVAILABLE_IN_3_22
-void gsk_render_node_set_child_transform (GskRenderNode *node,
- const graphene_matrix_t *transform);
+void gsk_render_node_set_child_transform (GskRenderNode *node,
+ const graphene_matrix_t *transform);
GDK_AVAILABLE_IN_3_22
void gsk_render_node_set_opacity (GskRenderNode *node,
double opacity);
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index 3b74eb7..0dce747 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -53,7 +53,7 @@ struct _GskRenderNode
/* Transformations applied to the node */
graphene_matrix_t transform;
- graphene_point3d_t offset;
+ graphene_point3d_t anchor_point;
/* Transformations applied to the children of the node */
graphene_matrix_t child_transform;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8cf3080..87e46be 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -17494,12 +17494,14 @@ gtk_widget_get_render_node (GtkWidget *widget,
gsk_render_node_set_name (tmp, str);
gsk_render_node_set_bounds (tmp, &bounds);
gsk_render_node_set_transform (tmp, &m);
+ gsk_render_node_set_anchor_point (tmp,
+ graphene_point3d_init (&p, clip.x - alloc.x,
+ clip.y - alloc.y,
+ 0.f));
+
cr = gsk_render_node_get_draw_context (tmp);
cairo_translate (cr, alloc.x - clip.x, alloc.y - clip.y);
- gsk_render_node_set_offset (tmp, graphene_point3d_init (&p, clip.x - alloc.x, clip.y - alloc.y, 0.f));
-
gtk_widget_draw (widget, cr);
-
cairo_destroy (cr);
g_free (str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]