forked from AuroraMiddleware/gtk
GskTransform: Restructure _to_affine and _to_translation
Make the simple cases more explicit.
This commit is contained in:
parent
0ce32cd4b5
commit
fa85ec5cf5
@ -1539,7 +1539,7 @@ gsk_transform_to_2d (GskTransform *self,
|
||||
* Converts a #GskTransform to 2D affine transformation
|
||||
* factors.
|
||||
* @self must be a 2D transformation. If you are not
|
||||
* sure, use gsk_transform_get_category() >=
|
||||
* sure, use gsk_transform_get_category() >=
|
||||
* %GSK_TRANSFORM_CATEGORY_2D_AFFINE to check.
|
||||
*/
|
||||
void
|
||||
@ -1549,15 +1549,8 @@ gsk_transform_to_affine (GskTransform *self,
|
||||
float *out_dx,
|
||||
float *out_dy)
|
||||
{
|
||||
if (self == NULL ||
|
||||
self->category < GSK_TRANSFORM_CATEGORY_2D_AFFINE)
|
||||
if (self == NULL)
|
||||
{
|
||||
if (self != NULL)
|
||||
{
|
||||
char *s = gsk_transform_to_string (self);
|
||||
g_warning ("Given transform \"%s\" is not an affine 2D transform.", s);
|
||||
g_free (s);
|
||||
}
|
||||
*out_scale_x = 1.0f;
|
||||
*out_scale_y = 1.0f;
|
||||
*out_dx = 0.0f;
|
||||
@ -1565,9 +1558,32 @@ gsk_transform_to_affine (GskTransform *self,
|
||||
return;
|
||||
}
|
||||
|
||||
gsk_transform_to_affine (self->next,
|
||||
out_scale_x, out_scale_y,
|
||||
out_dx, out_dy);
|
||||
if (G_UNLIKELY (self->category < GSK_TRANSFORM_CATEGORY_2D_AFFINE))
|
||||
{
|
||||
char *s = gsk_transform_to_string (self);
|
||||
g_warning ("Given transform \"%s\" is not an affine 2D transform.", s);
|
||||
g_free (s);
|
||||
|
||||
*out_scale_x = 1.0f;
|
||||
*out_scale_y = 1.0f;
|
||||
*out_dx = 0.0f;
|
||||
*out_dy = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->next != NULL)
|
||||
{
|
||||
gsk_transform_to_affine (self->next,
|
||||
out_scale_x, out_scale_y,
|
||||
out_dx, out_dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
*out_scale_x = 1.0f;
|
||||
*out_scale_y = 1.0f;
|
||||
*out_dx = 0.0f;
|
||||
*out_dy = 0.0f;
|
||||
}
|
||||
|
||||
self->transform_class->apply_affine (self,
|
||||
out_scale_x, out_scale_y,
|
||||
@ -1592,22 +1608,34 @@ gsk_transform_to_translate (GskTransform *self,
|
||||
float *out_dx,
|
||||
float *out_dy)
|
||||
{
|
||||
if (self == NULL ||
|
||||
self->category < GSK_TRANSFORM_CATEGORY_2D_TRANSLATE)
|
||||
if (self == NULL)
|
||||
{
|
||||
if (self != NULL)
|
||||
{
|
||||
char *s = gsk_transform_to_string (self);
|
||||
g_warning ("Given transform \"%s\" is not a 2D translation.", s);
|
||||
g_free (s);
|
||||
}
|
||||
*out_dx = 0.0f;
|
||||
*out_dy = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
gsk_transform_to_translate (self->next,
|
||||
out_dx, out_dy);
|
||||
if (G_UNLIKELY (self->category < GSK_TRANSFORM_CATEGORY_2D_TRANSLATE))
|
||||
{
|
||||
char *s = gsk_transform_to_string (self);
|
||||
g_warning ("Given transform \"%s\" is not an affine 2D translation.", s);
|
||||
g_free (s);
|
||||
|
||||
*out_dx = 0.0f;
|
||||
*out_dy = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->next != NULL)
|
||||
{
|
||||
gsk_transform_to_translate (self->next,
|
||||
out_dx, out_dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
*out_dx = 0.0f;
|
||||
*out_dy = 0.0f;
|
||||
}
|
||||
|
||||
self->transform_class->apply_translate (self,
|
||||
out_dx, out_dy);
|
||||
|
Loading…
Reference in New Issue
Block a user