mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
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.
This commit is contained in:
parent
702befc697
commit
a146618de0
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -15872,12 +15872,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);
|
||||
|
Loading…
Reference in New Issue
Block a user