[gtk] widget: Add optimizations to gtk_widget_compute_transform()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] widget: Add optimizations to gtk_widget_compute_transform()
- Date: Wed, 20 Feb 2019 04:29:40 +0000 (UTC)
commit cfc7dc016e96cc504be1bbdb8f6b3aae96031dc3
Author: Benjamin Otte <otte redhat com>
Date: Wed Feb 20 04:04:29 2019 +0100
widget: Add optimizations to gtk_widget_compute_transform()
Try to catch 2 common cases with as little work as necessary.
gtk/gtkwidget.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 45c4818ae3..d4a8284ae4 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -11259,6 +11259,13 @@ gtk_widget_compute_transform (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_WIDGET (target), FALSE);
g_return_val_if_fail (out_transform != NULL, FALSE);
+ /* optimization for common case: parent wants coordinates of a direct child */
+ if (target == widget->priv->parent)
+ {
+ graphene_matrix_init_from_matrix (out_transform, &widget->priv->transform);
+ return TRUE;
+ }
+
ancestor = gtk_widget_common_ancestor (widget, target);
if (ancestor == NULL)
return FALSE;
@@ -11271,6 +11278,13 @@ gtk_widget_compute_transform (GtkWidget *widget,
graphene_matrix_multiply (&transform, &priv->transform, &transform);
}
+ /* optimization for common case: parent wants coordinates of a non-direct child */
+ if (ancestor == target)
+ {
+ graphene_matrix_init_from_matrix (out_transform, &transform);
+ return TRUE;
+ }
+
graphene_matrix_init_identity (&inverse);
for (iter = target; iter != ancestor; iter = iter->priv->parent)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]