diff options
author | Benjamin Otte <otte@redhat.com> | 2019-02-19 08:24:59 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2019-02-21 19:47:28 +0100 |
commit | f5b44c11c824d65d4db5478b2eba0fcbdfb23ce2 (patch) | |
tree | 331d037fca52cf730f8c46c81e2f195c6d99d55e | |
parent | c24f32619f4ccdd299eec7c0768be9e7adf7edd4 (diff) | |
download | gtk+-f5b44c11c824d65d4db5478b2eba0fcbdfb23ce2.tar.gz |
widget: Store category of widget transform
And pass that category through to the transform node that we create for
it.
-rw-r--r-- | gtk/gtksnapshot.c | 18 | ||||
-rw-r--r-- | gtk/gtksnapshotprivate.h | 6 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 14 | ||||
-rw-r--r-- | gtk/gtkwidgetprivate.h | 3 |
4 files changed, 32 insertions, 9 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 3f7f100608..2d31929d8a 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -296,7 +296,9 @@ gtk_snapshot_collect_transform (GtkSnapshot *snapshot, if (node == NULL) return NULL; - transform_node = gsk_transform_node_new (node, &state->data.transform.transform); + transform_node = gsk_transform_node_new_with_category (node, + &state->data.transform.transform, + state->data.transform.category); gsk_render_node_unref (node); @@ -307,6 +309,16 @@ void gtk_snapshot_push_transform (GtkSnapshot *snapshot, const graphene_matrix_t *transform) { + gtk_snapshot_push_transform_with_category (snapshot, + transform, + GSK_MATRIX_CATEGORY_UNKNOWN); +} + +void +gtk_snapshot_push_transform_with_category (GtkSnapshot *snapshot, + const graphene_matrix_t *transform, + GskMatrixCategory category) +{ GtkSnapshotState *previous_state; GtkSnapshotState *state; graphene_matrix_t offset; @@ -325,6 +337,10 @@ gtk_snapshot_push_transform (GtkSnapshot *snapshot, )); graphene_matrix_multiply (transform, &offset, &state->data.transform.transform); + if (previous_state->translate_x || previous_state->translate_y) + state->data.transform.category = MIN (GSK_MATRIX_CATEGORY_2D_TRANSLATE, category); + else + state->data.transform.category = category; } static GskRenderNode * diff --git a/gtk/gtksnapshotprivate.h b/gtk/gtksnapshotprivate.h index 5e554ca85e..b03205d5cd 100644 --- a/gtk/gtksnapshotprivate.h +++ b/gtk/gtksnapshotprivate.h @@ -20,6 +20,8 @@ #include "gtksnapshot.h" +#include "gsk/gskrendernodeprivate.h" + G_BEGIN_DECLS typedef struct _GtkSnapshotState GtkSnapshotState; @@ -40,6 +42,7 @@ struct _GtkSnapshotState { union { struct { graphene_matrix_t transform; + GskMatrixCategory category; } transform; struct { double opacity; @@ -103,6 +106,9 @@ void gtk_snapshot_append_node_internal (GtkSnapshot GtkSnapshot * gtk_snapshot_new_with_parent (GtkSnapshot *parent_snapshot); +void gtk_snapshot_push_transform_with_category (GtkSnapshot *snapshot, + const graphene_matrix_t*transform, + GskMatrixCategory category); G_END_DECLS #endif /* __GTK_SNAPSHOT_PRIVATE_H__ */ diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index a0f5a5d72c..feecd3774e 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -61,7 +61,7 @@ #include "gtksnapshotprivate.h" #include "gtkstylecontextprivate.h" #include "gtktooltipprivate.h" -#include "gtktransform.h" +#include "gtktransformprivate.h" #include "gtktypebuiltins.h" #include "gtkversion.h" #include "gtkwidgetpaintableprivate.h" @@ -4348,6 +4348,9 @@ gtk_widget_allocate (GtkWidget *widget, graphene_matrix_init_translate (&priv->transform, &GRAPHENE_POINT3D_INIT (adjusted.x, adjusted.y, 0)); gtk_transform_to_matrix (transform, &transform_matrix); graphene_matrix_multiply (&priv->transform, &transform_matrix, &priv->transform); + priv->transform_category = gtk_transform_categorize (transform); + if (adjusted.x || adjusted.y) + priv->transform_category = MIN (priv->transform_category, GSK_MATRIX_CATEGORY_2D_TRANSLATE); if (!alloc_needed && !size_changed && !baseline_changed) { @@ -13511,20 +13514,15 @@ gtk_widget_snapshot_child (GtkWidget *widget, GtkSnapshot *snapshot) { GtkWidgetPrivate *priv = gtk_widget_get_instance_private (child); - gboolean needs_transform; g_return_if_fail (_gtk_widget_get_parent (child) == widget); g_return_if_fail (snapshot != NULL); - needs_transform = !graphene_matrix_is_identity (&priv->transform); - - if (needs_transform) - gtk_snapshot_push_transform (snapshot, &priv->transform); + gtk_snapshot_push_transform_with_category (snapshot, &priv->transform, priv->transform_category); gtk_widget_snapshot (child, snapshot); - if (needs_transform) - gtk_snapshot_pop (snapshot); + gtk_snapshot_pop (snapshot); } /** diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index 8b1e672a87..8b4bf94e67 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -38,6 +38,8 @@ #include "gtkinvisibleprivate.h" #include "gtkgesture.h" +#include "gsk/gskrendernodeprivate.h" + G_BEGIN_DECLS #define GTK_STATE_FLAGS_BITS 14 @@ -150,6 +152,7 @@ struct _GtkWidgetPrivate gint allocated_size_baseline; graphene_matrix_t transform; + GskMatrixCategory transform_category; int width; int height; int baseline; |