summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2019-02-19 08:24:59 +0100
committerBenjamin Otte <otte@redhat.com>2019-02-19 08:25:54 +0100
commitb4960eed8ac7b36f262b20a3b67b872d73b6f139 (patch)
treebcf31a2f1350cc5cc2f1c79696722137ae5f5e12
parent80be6ec08d7786a68caf7ad20771d5cddc613413 (diff)
downloadgtk+-wip/otte/matrix.tar.gz
widget: Store category of widget transformwip/otte/matrix
And pass that category through to the transform node that we create for it.
-rw-r--r--gtk/gtksnapshot.c18
-rw-r--r--gtk/gtksnapshotprivate.h6
-rw-r--r--gtk/gtkwidget.c14
-rw-r--r--gtk/gtkwidgetprivate.h3
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 0762ca8d49..2d51b7a474 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -49,7 +49,7 @@
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
-#include "gtkmatrix.h"
+#include "gtkmatrixprivate.h"
#include "gtkmenu.h"
#include "gtkpopover.h"
#include "gtkprivate.h"
@@ -4335,6 +4335,9 @@ gtk_widget_allocate (GtkWidget *widget,
graphene_matrix_init_translate (&priv->transform, &GRAPHENE_POINT3D_INIT (adjusted.x, adjusted.y, 0));
gtk_matrix_compute (transform, &computed);
graphene_matrix_multiply (&priv->transform, &computed, &priv->transform);
+ priv->transform_category = gtk_matrix_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)
{
@@ -13453,20 +13456,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 6908ec9360..c7b9cf99f2 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;