pick: Take advantage of transform categories

Transform categories let us easily avoid doing matrix math
when we can just do a simple translation.
This commit is contained in:
Matthias Clasen 2020-01-19 01:12:19 -05:00
parent cec4c15f05
commit 6e88ccf7fb

View File

@ -10507,9 +10507,8 @@ gtk_widget_do_pick (GtkWidget *widget,
{
GtkWidgetPrivate *child_priv = gtk_widget_get_instance_private (child);
GskTransform *transform;
graphene_matrix_t inv;
GtkWidget *picked;
graphene_point3d_t p0, p1, res;
graphene_point3d_t res;
if (!gtk_widget_can_be_picked (child, flags))
continue;
@ -10527,6 +10526,18 @@ gtk_widget_do_pick (GtkWidget *widget,
{
transform = NULL;
}
if (gsk_transform_get_category (transform) >= GSK_TRANSFORM_CATEGORY_2D_TRANSLATE)
{
float dx, dy;
gsk_transform_to_translate (transform, &dx, &dy);
graphene_point3d_init (&res, x + dx, y + dy, 0.);
}
else
{
graphene_matrix_t inv;
graphene_point3d_t p0, p1;
gsk_transform_to_matrix (transform, &inv);
gsk_transform_unref (transform);
graphene_point3d_init (&p0, x, y, 0);
@ -10537,6 +10548,7 @@ gtk_widget_do_pick (GtkWidget *widget,
continue;
graphene_point3d_interpolate (&p0, &p1, p0.z / (p0.z - p1.z), &res);
}
picked = gtk_widget_do_pick (child, res.x, res.y, flags);
if (picked)