[mutter/gbsneto/new-nodes: 2/4] clutter/paint-nodes: Expose and cleanup ClutterTransformNode
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/new-nodes: 2/4] clutter/paint-nodes: Expose and cleanup ClutterTransformNode
- Date: Mon, 21 Oct 2019 15:05:24 +0000 (UTC)
commit fc87c0fe9f5ce9fd8759540b91f32ea66a7bd1a2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Oct 17 18:16:01 2019 +0200
clutter/paint-nodes: Expose and cleanup ClutterTransformNode
It will also be used by ClutterActor to apply it's own transform
to the paint node tree, and thus preserve it's rendering area.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/872
clutter/clutter/clutter-paint-nodes.c | 52 +++++++++++++++++++----------------
clutter/clutter/clutter-paint-nodes.h | 20 ++++++++++++++
2 files changed, 48 insertions(+), 24 deletions(-)
---
diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c
index a755a00cf..eaa5c6f9b 100644
--- a/clutter/clutter/clutter-paint-nodes.c
+++ b/clutter/clutter/clutter-paint-nodes.c
@@ -183,35 +183,31 @@ clutter_root_node_new (CoglFramebuffer *framebuffer,
}
/*
- * Transform node
- *
- * A private PaintNode, that changes the modelview of its child
- * nodes.
+ * ClutterTransformNode
*/
-#define clutter_transform_node_get_type _clutter_transform_node_get_type
-
-typedef struct _ClutterTransformNode {
+struct _ClutterTransformNode
+{
ClutterPaintNode parent_instance;
- CoglMatrix modelview;
-} ClutterTransformNode;
+ CoglMatrix transform;
+};
-typedef struct _ClutterPaintNodeClass ClutterTransformNodeClass;
+struct _ClutterTransformNodeClass
+{
+ ClutterPaintNodeClass parent_class;
+};
G_DEFINE_TYPE (ClutterTransformNode, clutter_transform_node, CLUTTER_TYPE_PAINT_NODE)
static gboolean
clutter_transform_node_pre_draw (ClutterPaintNode *node)
{
- ClutterTransformNode *tnode = (ClutterTransformNode *) node;
- CoglMatrix matrix;
-
- cogl_push_matrix ();
+ ClutterTransformNode *transform_node = (ClutterTransformNode *) node;
+ CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
- cogl_get_modelview_matrix (&matrix);
- cogl_matrix_multiply (&matrix, &matrix, &tnode->modelview);
- cogl_set_modelview_matrix (&matrix);
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_transform (fb, &transform_node->transform);
return TRUE;
}
@@ -219,7 +215,9 @@ clutter_transform_node_pre_draw (ClutterPaintNode *node)
static void
clutter_transform_node_post_draw (ClutterPaintNode *node)
{
- cogl_pop_matrix ();
+ CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
+
+ cogl_framebuffer_pop_matrix (fb);
}
static void
@@ -235,18 +233,24 @@ clutter_transform_node_class_init (ClutterTransformNodeClass *klass)
static void
clutter_transform_node_init (ClutterTransformNode *self)
{
- cogl_matrix_init_identity (&self->modelview);
+ cogl_matrix_init_identity (&self->transform);
}
+/*
+ * clutter_transform_node_new:
+ * @transform: (nullable): the transform matrix to apply
+ *
+ * Return value: (transfer full): the newly created #ClutterTransformNode.
+ * Use clutter_paint_node_unref() when done.
+ */
ClutterPaintNode *
-_clutter_transform_node_new (const CoglMatrix *modelview)
+clutter_transform_node_new (const CoglMatrix *transform)
{
ClutterTransformNode *res;
- res = _clutter_paint_node_create (_clutter_transform_node_get_type ());
-
- if (modelview != NULL)
- res->modelview = *modelview;
+ res = _clutter_paint_node_create (CLUTTER_TYPE_TRANSFORM_NODE);
+ if (transform)
+ res->transform = *transform;
return (ClutterPaintNode *) res;
}
diff --git a/clutter/clutter/clutter-paint-nodes.h b/clutter/clutter/clutter-paint-nodes.h
index 16612467c..03f45600f 100644
--- a/clutter/clutter/clutter-paint-nodes.h
+++ b/clutter/clutter/clutter-paint-nodes.h
@@ -190,6 +190,26 @@ ClutterPaintNode * clutter_layer_node_new (const CoglMatrix
guint8 opacity);
+#define CLUTTER_TYPE_TRANSFORM_NODE (clutter_transform_node_get_type ())
+#define CLUTTER_TRANSFORM_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
CLUTTER_TYPE_TRANSFORM_NODE, ClutterTransformNode))
+#define CLUTTER_IS_TRANSFORM_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
CLUTTER_TYPE_TRANSFORM_NODE))
+
+/*
+ * ClutterTransformNode:
+ *
+ * The #ClutterLayerNode structure is an opaque
+ * type whose members cannot be directly accessed.
+ *
+ * Since: 1.10
+ */
+typedef struct _ClutterTransformNode ClutterTransformNode;
+typedef struct _ClutterPaintNodeClass ClutterTransformNodeClass;
+
+CLUTTER_EXPORT
+GType clutter_transform_node_get_type (void) G_GNUC_CONST;
+
+CLUTTER_EXPORT
+ClutterPaintNode * clutter_transform_node_new (const CoglMatrix *projection);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]