transform: Move gsk_transform_dihedral

This is a transform function, so put it in gsktransform.c.
This commit is contained in:
Matthias Clasen 2024-12-05 19:02:39 -05:00
parent 305fad9a24
commit ec9b2e531b
3 changed files with 32 additions and 17 deletions

View File

@ -1431,22 +1431,6 @@ gsk_gpu_node_processor_add_first_rounded_clip_node (GskGpuNodeProcessor *self,
gsk_rounded_clip_node_get_child (node));
}
static GskTransform *
gsk_transform_dihedral (GskTransform *transform,
GdkDihedral dihedral)
{
int rotate = dihedral & 3;
int flip = dihedral & 4;
if (flip)
transform = gsk_transform_scale (transform, -1.0, 1.0);
if (rotate)
transform = gsk_transform_rotate (transform, rotate * 90.0f);
return transform;
}
static void
gsk_gpu_node_processor_add_transform_node (GskGpuNodeProcessor *self,
GskRenderNode *node)

View File

@ -290,7 +290,7 @@ gsk_matrix_transform_to_matrix (GskTransform *transform,
graphene_matrix_init_from_matrix (out_matrix, &self->matrix);
}
static void
static void
gsk_matrix_transform_apply_2d (GskTransform *transform,
float *out_xx,
float *out_yx,
@ -2109,6 +2109,34 @@ gsk_transform_to_dihedral (GskTransform *self,
out_dx, out_dy);
}
/*< private >
* gsk_transform_dihedral:
* @next: (nullable) (transfer full): the next transform
* @dihedral: dihedral tansform to apply
*
* Applies a dihedral transform to @next.
*
* This function consumes @next. Use [method@Gsk.Transform.ref] first
* if you want to keep it around.
*
* Returns: (nullable): The new transform
**/
GskTransform *
gsk_transform_dihedral (GskTransform *next,
GdkDihedral dihedral)
{
int rotate = dihedral & 3;
int flip = dihedral & 4;
if (flip)
next = gsk_transform_scale (next, -1.0, 1.0);
if (rotate)
next = gsk_transform_rotate (next, rotate * 90.0f);
return next;
}
/**
* gsk_transform_to_translate:
* @self: a `GskTransform`

View File

@ -97,6 +97,9 @@ void gsk_transform_to_dihedral (GskTransform
float *out_dx,
float *out_dy);
GskTransform * gsk_transform_dihedral (GskTransform * next,
GdkDihedral dihedral);
void gsk_matrix_transform_point (const graphene_matrix_t *m,
const graphene_point_t *p,
graphene_point_t *res);