[gtk+] Add an offset to render nodes



commit 7b204b0eeaadbb076d842b42556b09ec912bc24b
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Aug 4 01:04:25 2016 -0400

    Add an offset to render nodes
    
    This will let us account for the difference between
    clip and allocation.

 gsk/gskrendernode.c        |   18 ++++++++++++++++++
 gsk/gskrendernode.h        |    3 +++
 gsk/gskrendernodeprivate.h |    2 ++
 3 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c
index cb64408..45cdd54 100644
--- a/gsk/gskrendernode.c
+++ b/gsk/gskrendernode.c
@@ -178,6 +178,7 @@ 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);
 
   self->opacity = 1.0;
 
@@ -934,6 +935,23 @@ 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)
+{
+  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);
 }
 
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index f5a3cf1..2d03b4b 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -95,6 +95,9 @@ GDK_AVAILABLE_IN_3_22
 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,
+                                                                 const graphene_point3d_t *offset);
+GDK_AVAILABLE_IN_3_22
 void                    gsk_render_node_set_child_transform     (GskRenderNode           *node,
                                                                  const graphene_matrix_t *transform);
 GDK_AVAILABLE_IN_3_22
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index 8e6bca8..3b74eb7 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -53,6 +53,8 @@ struct _GskRenderNode
   /* Transformations applied to the node */
   graphene_matrix_t transform;
 
+  graphene_point3d_t offset;
+
   /* Transformations applied to the children of the node */
   graphene_matrix_t child_transform;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]