mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-03 17:21:11 +00:00
widget: Store category of widget transform
And pass that category through to the transform node that we create for it.
This commit is contained in:
parent
c24f32619f
commit
f5b44c11c8
@ -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);
|
||||
|
||||
@ -306,6 +308,16 @@ gtk_snapshot_collect_transform (GtkSnapshot *snapshot,
|
||||
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;
|
||||
@ -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 *
|
||||
|
@ -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__ */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user