forked from AuroraMiddleware/gtk
rendernode: Make the transform node take a GskTransform
This is an attempt to push GskTransform deeper into the stack.
This commit is contained in:
parent
4916280883
commit
3a3c2d14ab
@ -8,13 +8,14 @@
|
||||
#include "gskglprofilerprivate.h"
|
||||
#include "gskprofilerprivate.h"
|
||||
#include "gskrendererprivate.h"
|
||||
#include "gskrendernodeprivate.h"
|
||||
#include "gsktransformprivate.h"
|
||||
#include "gskshaderbuilderprivate.h"
|
||||
#include "gskglglyphcacheprivate.h"
|
||||
#include "gskglrenderopsprivate.h"
|
||||
#include "gskcairoblurprivate.h"
|
||||
#include "gskglshadowcacheprivate.h"
|
||||
#include "gskglnodesampleprivate.h"
|
||||
#include "gsktransform.h"
|
||||
|
||||
#include "gskprivate.h"
|
||||
|
||||
@ -794,8 +795,8 @@ render_transform_node (GskGLRenderer *self,
|
||||
GskRenderNode *node,
|
||||
RenderOpBuilder *builder)
|
||||
{
|
||||
const GskMatrixCategory category = gsk_transform_node_get_category (node);
|
||||
const graphene_matrix_t *node_transform = gsk_transform_node_peek_transform (node);
|
||||
GskTransform *node_transform = gsk_transform_node_get_transform (node);
|
||||
const GskMatrixCategory category = gsk_transform_categorize (node_transform);
|
||||
GskRenderNode *child = gsk_transform_node_get_child (node);
|
||||
|
||||
switch (category)
|
||||
@ -806,8 +807,12 @@ render_transform_node (GskGLRenderer *self,
|
||||
|
||||
case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
|
||||
{
|
||||
const float dx = graphene_matrix_get_value (node_transform, 3, 0);
|
||||
const float dy = graphene_matrix_get_value (node_transform, 3, 1);
|
||||
float dx, dy;
|
||||
|
||||
if (!gsk_transform_to_translate (node_transform, &dx, &dy))
|
||||
{
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
ops_offset (builder, dx, dy);
|
||||
gsk_gl_renderer_add_render_ops (self, child, builder);
|
||||
@ -817,7 +822,10 @@ render_transform_node (GskGLRenderer *self,
|
||||
|
||||
case GSK_MATRIX_CATEGORY_2D_AFFINE:
|
||||
{
|
||||
ops_push_modelview (builder, node_transform, category);
|
||||
graphene_matrix_t mat;
|
||||
|
||||
gsk_transform_to_matrix (node_transform, &mat);
|
||||
ops_push_modelview (builder, &mat, category);
|
||||
gsk_gl_renderer_add_render_ops (self, child, builder);
|
||||
ops_pop_modelview (builder);
|
||||
}
|
||||
@ -834,8 +842,10 @@ render_transform_node (GskGLRenderer *self,
|
||||
const float max_y = min_y + child->bounds.size.height;
|
||||
int texture_id;
|
||||
gboolean is_offscreen;
|
||||
graphene_matrix_t mat;
|
||||
|
||||
ops_push_modelview (builder, node_transform, category);
|
||||
gsk_transform_to_matrix (node_transform, &mat);
|
||||
ops_push_modelview (builder, &mat, category);
|
||||
|
||||
if (node_supports_transform (child))
|
||||
{
|
||||
|
@ -196,12 +196,11 @@ GskRenderNode * gsk_container_node_get_child (GskRenderNode
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_transform_node_new (GskRenderNode *child,
|
||||
const graphene_matrix_t *transform);
|
||||
GskTransform *transform);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_transform_node_get_child (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const graphene_matrix_t *
|
||||
gsk_transform_node_peek_transform (GskRenderNode *node);
|
||||
GskTransform * gsk_transform_node_get_transform (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "gskdiffprivate.h"
|
||||
#include "gskrendererprivate.h"
|
||||
#include "gskroundedrectprivate.h"
|
||||
#include "gsktransformprivate.h"
|
||||
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
|
||||
@ -2387,8 +2388,7 @@ struct _GskTransformNode
|
||||
GskRenderNode render_node;
|
||||
|
||||
GskRenderNode *child;
|
||||
graphene_matrix_t transform;
|
||||
GskMatrixCategory category;
|
||||
GskTransform *transform;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -2397,6 +2397,7 @@ gsk_transform_node_finalize (GskRenderNode *node)
|
||||
GskTransformNode *self = (GskTransformNode *) node;
|
||||
|
||||
gsk_render_node_unref (self->child);
|
||||
gsk_transform_unref (self->transform);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2404,10 +2405,12 @@ gsk_transform_node_draw (GskRenderNode *node,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GskTransformNode *self = (GskTransformNode *) node;
|
||||
cairo_matrix_t ctm;
|
||||
float xx, yx, xy, yy, dx, dy;
|
||||
|
||||
if (graphene_matrix_to_2d (&self->transform, &ctm.xx, &ctm.yx, &ctm.xy, &ctm.yy, &ctm.x0, &ctm.y0))
|
||||
if (gsk_transform_to_2d (self->transform, &xx, &yx, &xy, &yy, &dx, &dy))
|
||||
{
|
||||
cairo_matrix_t ctm = { xx, yx, xy, yy, dx, dy };
|
||||
|
||||
GSK_NOTE (CAIRO, g_message ("CTM = { .xx = %g, .yx = %g, .xy = %g, .yy = %g, .x0 = %g, .y0 = %g }",
|
||||
ctm.xx, ctm.yx,
|
||||
ctm.xy, ctm.yy,
|
||||
@ -2430,12 +2433,15 @@ static GVariant *
|
||||
gsk_transform_node_serialize (GskRenderNode *node)
|
||||
{
|
||||
GskTransformNode *self = (GskTransformNode *) node;
|
||||
graphene_matrix_t matrix;
|
||||
float mat[16];
|
||||
|
||||
graphene_matrix_to_float (&self->transform, mat);
|
||||
/* XXX: serialize transforms properly */
|
||||
gsk_transform_to_matrix (self->transform, &matrix);
|
||||
graphene_matrix_to_float (&matrix, mat);
|
||||
|
||||
return g_variant_new (GSK_TRANSFORM_NODE_VARIANT_TYPE,
|
||||
self->category,
|
||||
gsk_transform_categorize (self->transform),
|
||||
(double) mat[0], (double) mat[1], (double) mat[2], (double) mat[3],
|
||||
(double) mat[4], (double) mat[5], (double) mat[6], (double) mat[7],
|
||||
(double) mat[8], (double) mat[9], (double) mat[10], (double) mat[11],
|
||||
@ -2448,7 +2454,8 @@ static GskRenderNode *
|
||||
gsk_transform_node_deserialize (GVariant *variant,
|
||||
GError **error)
|
||||
{
|
||||
graphene_matrix_t transform;
|
||||
graphene_matrix_t matrix;
|
||||
GskTransform *transform;
|
||||
double mat[16];
|
||||
guint32 child_type;
|
||||
gint32 category;
|
||||
@ -2472,15 +2479,16 @@ gsk_transform_node_deserialize (GVariant *variant,
|
||||
if (child == NULL)
|
||||
return NULL;
|
||||
|
||||
graphene_matrix_init_from_float (&transform,
|
||||
graphene_matrix_init_from_float (&matrix,
|
||||
(float[16]) {
|
||||
mat[0], mat[1], mat[2], mat[3],
|
||||
mat[4], mat[5], mat[6], mat[7],
|
||||
mat[8], mat[9], mat[10], mat[11],
|
||||
mat[12], mat[13], mat[14], mat[15]
|
||||
});
|
||||
|
||||
result = gsk_transform_node_new_with_category (child, &transform, category);
|
||||
transform = gsk_transform_matrix_with_category (NULL, &matrix, category);
|
||||
result = gsk_transform_node_new (child, transform);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
gsk_render_node_unref (child);
|
||||
|
||||
@ -2502,7 +2510,7 @@ static const GskRenderNodeClass GSK_TRANSFORM_NODE_CLASS = {
|
||||
/**
|
||||
* gsk_transform_node_new:
|
||||
* @child: The node to transform
|
||||
* @transform: The transform to apply
|
||||
* @transform: (transfer none): The transform to apply
|
||||
*
|
||||
* Creates a #GskRenderNode that will transform the given @child
|
||||
* with the given @transform.
|
||||
@ -2510,66 +2518,22 @@ static const GskRenderNodeClass GSK_TRANSFORM_NODE_CLASS = {
|
||||
* Returns: A new #GskRenderNode
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_transform_node_new (GskRenderNode *child,
|
||||
const graphene_matrix_t *transform)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE (child), NULL);
|
||||
g_return_val_if_fail (transform != NULL, NULL);
|
||||
|
||||
return gsk_transform_node_new_with_category (child, transform, GSK_MATRIX_CATEGORY_UNKNOWN);
|
||||
}
|
||||
|
||||
/*<private>
|
||||
* gsk_transform_node_new_with_category:
|
||||
* @child: The node to transform
|
||||
* @transform: The transform to apply
|
||||
* @category: The category @transform belongs to
|
||||
*
|
||||
* Creates a #GskRenderNode that will transform the given @child
|
||||
* with the given @transform.
|
||||
*
|
||||
* The given @category will be used by renderers for optimizations and must
|
||||
* be correct. If you do not know the category of @transform, use
|
||||
* %GSK_MATRIX_CATEGORY_UNKNOWN.
|
||||
*
|
||||
* Returns: A new #GskRenderNode
|
||||
**/
|
||||
GskRenderNode *
|
||||
gsk_transform_node_new_with_category (GskRenderNode *child,
|
||||
const graphene_matrix_t *transform,
|
||||
GskMatrixCategory category)
|
||||
gsk_transform_node_new (GskRenderNode *child,
|
||||
GskTransform *transform)
|
||||
{
|
||||
GskTransformNode *self;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE (child), NULL);
|
||||
g_return_val_if_fail (transform != NULL, NULL);
|
||||
|
||||
self = (GskTransformNode *) gsk_render_node_new (&GSK_TRANSFORM_NODE_CLASS, 0);
|
||||
|
||||
self->child = gsk_render_node_ref (child);
|
||||
graphene_matrix_init_from_matrix (&self->transform, transform);
|
||||
self->category = category;
|
||||
self->transform = gsk_transform_ref (transform);
|
||||
|
||||
switch (category)
|
||||
{
|
||||
case GSK_MATRIX_CATEGORY_IDENTITY:
|
||||
graphene_rect_init_from_rect (&self->render_node.bounds, &child->bounds);
|
||||
break;
|
||||
|
||||
case GSK_MATRIX_CATEGORY_2D_TRANSLATE:
|
||||
{
|
||||
graphene_rect_init_from_rect (&self->render_node.bounds, &child->bounds);
|
||||
self->render_node.bounds.origin.x += graphene_matrix_get_value (transform, 3, 0);
|
||||
self->render_node.bounds.origin.y += graphene_matrix_get_value (transform, 3, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_MATRIX_CATEGORY_2D_AFFINE:
|
||||
case GSK_MATRIX_CATEGORY_ANY:
|
||||
case GSK_MATRIX_CATEGORY_UNKNOWN:
|
||||
case GSK_MATRIX_CATEGORY_INVERTIBLE:
|
||||
default:
|
||||
graphene_matrix_transform_bounds (&self->transform,
|
||||
&child->bounds,
|
||||
&self->render_node.bounds);
|
||||
}
|
||||
gsk_transform_transform_bounds (self->transform,
|
||||
&child->bounds,
|
||||
&self->render_node.bounds);
|
||||
|
||||
return &self->render_node;
|
||||
}
|
||||
@ -2592,24 +2556,14 @@ gsk_transform_node_get_child (GskRenderNode *node)
|
||||
return self->child;
|
||||
}
|
||||
|
||||
const graphene_matrix_t *
|
||||
gsk_transform_node_peek_transform (GskRenderNode *node)
|
||||
GskTransform *
|
||||
gsk_transform_node_get_transform (GskRenderNode *node)
|
||||
{
|
||||
GskTransformNode *self = (GskTransformNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TRANSFORM_NODE), NULL);
|
||||
|
||||
return &self->transform;
|
||||
}
|
||||
|
||||
GskMatrixCategory
|
||||
gsk_transform_node_get_category (GskRenderNode *node)
|
||||
{
|
||||
GskTransformNode *self = (GskTransformNode *) node;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_TRANSFORM_NODE), GSK_MATRIX_CATEGORY_UNKNOWN);
|
||||
|
||||
return self->category;
|
||||
return self->transform;
|
||||
}
|
||||
|
||||
/*** GSK_DEBUG_NODE ***/
|
||||
|
@ -96,11 +96,6 @@ GskRenderNode * gsk_render_node_deserialize_node (GskRenderNodeType typ
|
||||
GskRenderNode * gsk_cairo_node_new_for_surface (const graphene_rect_t *bounds,
|
||||
cairo_surface_t *surface);
|
||||
|
||||
GskRenderNode * gsk_transform_node_new_with_category (GskRenderNode *child,
|
||||
const graphene_matrix_t *transform,
|
||||
GskMatrixCategory category);
|
||||
GskMatrixCategory gsk_transform_node_get_category (GskRenderNode *node);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "gskrenderer.h"
|
||||
#include "gskrendererprivate.h"
|
||||
#include "gskroundedrectprivate.h"
|
||||
#include "gsktransform.h"
|
||||
#include "gskvulkanblendmodepipelineprivate.h"
|
||||
#include "gskvulkanblurpipelineprivate.h"
|
||||
#include "gskvulkanborderpipelineprivate.h"
|
||||
@ -560,7 +561,7 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
|
||||
#endif
|
||||
|
||||
child = gsk_transform_node_get_child (node);
|
||||
graphene_matrix_init_from_matrix (&transform, gsk_transform_node_peek_transform (node));
|
||||
gsk_transform_to_matrix (gsk_transform_node_get_transform (node), &transform);
|
||||
graphene_matrix_init_from_matrix (&mv, &self->mv);
|
||||
graphene_matrix_multiply (&transform, &mv, &self->mv);
|
||||
if (!gsk_vulkan_push_constants_transform (&op.constants.constants, constants, &transform, &child->bounds))
|
||||
|
@ -242,14 +242,15 @@ gtk_snapshot_collect_autopush_transform (GtkSnapshot *snapshot,
|
||||
guint n_nodes)
|
||||
{
|
||||
GskRenderNode *node, *transform_node;
|
||||
GtkSnapshotState *previous_state;
|
||||
|
||||
previous_state = gtk_snapshot_get_previous_state (snapshot);
|
||||
|
||||
node = gtk_snapshot_collect_default (snapshot, state, nodes, n_nodes);
|
||||
if (node == NULL)
|
||||
return NULL;
|
||||
|
||||
transform_node = gsk_transform_node_new_with_category (node,
|
||||
&state->data.transform.transform,
|
||||
state->data.transform.category);
|
||||
transform_node = gsk_transform_node_new (node, previous_state->transform);
|
||||
|
||||
gsk_render_node_unref (node);
|
||||
|
||||
@ -259,17 +260,9 @@ gtk_snapshot_collect_autopush_transform (GtkSnapshot *snapshot,
|
||||
static void
|
||||
gtk_snapshot_autopush_transform (GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkSnapshotState *previous_state;
|
||||
GtkSnapshotState *state;
|
||||
|
||||
state = gtk_snapshot_push_state (snapshot,
|
||||
NULL,
|
||||
gtk_snapshot_collect_autopush_transform);
|
||||
|
||||
previous_state = gtk_snapshot_get_previous_state (snapshot);
|
||||
|
||||
gsk_transform_to_matrix (previous_state->transform, &state->data.transform.transform);
|
||||
state->data.transform.category = gsk_transform_categorize (previous_state->transform);
|
||||
gtk_snapshot_push_state (snapshot,
|
||||
NULL,
|
||||
gtk_snapshot_collect_autopush_transform);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -40,14 +40,10 @@ struct _GtkSnapshotState {
|
||||
GtkSnapshotCollectFunc collect_func;
|
||||
union {
|
||||
struct {
|
||||
graphene_matrix_t transform;
|
||||
GskMatrixCategory category;
|
||||
} transform;
|
||||
struct {
|
||||
double opacity;
|
||||
double opacity;
|
||||
} opacity;
|
||||
struct {
|
||||
double radius;
|
||||
double radius;
|
||||
} blur;
|
||||
struct {
|
||||
graphene_matrix_t matrix;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <gsk/gskrendererprivate.h>
|
||||
#include <gsk/gskrendernodeprivate.h>
|
||||
#include <gsk/gskroundedrectprivate.h>
|
||||
#include <gsk/gsktransformprivate.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gdk/gdktextureprivate.h>
|
||||
@ -896,19 +897,14 @@ populate_render_node_properties (GtkListStore *store,
|
||||
[GSK_MATRIX_CATEGORY_2D_TRANSLATE] = "2D transform",
|
||||
[GSK_MATRIX_CATEGORY_IDENTITY] = "identity"
|
||||
};
|
||||
float f[16];
|
||||
guint i;
|
||||
GskTransform *transform;
|
||||
char *s;
|
||||
|
||||
graphene_matrix_to_float (gsk_transform_node_peek_transform (node), f);
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
char *row_string = g_strdup_printf ("%.2f, %.2f, %.2f, %.2f",
|
||||
f[4 * i], f[4 * i + 1],
|
||||
f[4 * i + 2], f[4 * i + 3]);
|
||||
add_text_row (store, i == 0 ? "Matrix" : "", row_string);
|
||||
g_free (row_string);
|
||||
}
|
||||
add_text_row (store, "Category", category_names[gsk_transform_node_get_category (node)]);
|
||||
transform = gsk_transform_node_get_transform (node);
|
||||
s = gsk_transform_to_string (transform);
|
||||
add_text_row (store, "Matrix", s);
|
||||
g_free (s);
|
||||
add_text_row (store, "Category", category_names[gsk_transform_categorize (transform)]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -183,7 +183,7 @@ repeat (void)
|
||||
GskRenderNode *child;
|
||||
GskRenderNode *transform;
|
||||
GskRenderNode *container;
|
||||
graphene_matrix_t matrix;
|
||||
GskTransform *matrix;
|
||||
|
||||
child = cairo ();
|
||||
|
||||
@ -202,18 +202,21 @@ repeat (void)
|
||||
|
||||
gsk_render_node_unref (child);
|
||||
|
||||
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 0, 20, 0 });
|
||||
transform = gsk_transform_node_new (repeat[1], &matrix);
|
||||
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 0, 20 });
|
||||
transform = gsk_transform_node_new (repeat[1], matrix);
|
||||
gsk_transform_unref (matrix);
|
||||
gsk_render_node_unref (repeat[1]);
|
||||
repeat[1] = transform;
|
||||
|
||||
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 0, 40, 0 });
|
||||
transform = gsk_transform_node_new (repeat[2], &matrix);
|
||||
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 0, 40 });
|
||||
transform = gsk_transform_node_new (repeat[2], matrix);
|
||||
gsk_transform_unref (matrix);
|
||||
gsk_render_node_unref (repeat[2]);
|
||||
repeat[2] = transform;
|
||||
|
||||
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 220, -100, 0 });
|
||||
transform = gsk_transform_node_new (repeat[3], &matrix);
|
||||
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 220, -100 });
|
||||
transform = gsk_transform_node_new (repeat[3], matrix);
|
||||
gsk_transform_unref (matrix);
|
||||
gsk_render_node_unref (repeat[3]);
|
||||
repeat[3] = transform;
|
||||
|
||||
@ -234,13 +237,14 @@ blendmode (void)
|
||||
GskRenderNode *child2;
|
||||
GskRenderNode *transform;
|
||||
GskRenderNode *container;
|
||||
graphene_matrix_t matrix;
|
||||
GskTransform *matrix;
|
||||
|
||||
child1 = cairo ();
|
||||
child2 = cairo2 ();
|
||||
|
||||
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 50, 50, 0 });
|
||||
transform = gsk_transform_node_new (child2, &matrix);
|
||||
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 50, 50 });
|
||||
transform = gsk_transform_node_new (child2, matrix);
|
||||
gsk_transform_unref (matrix);
|
||||
gsk_render_node_unref (child2);
|
||||
child2 = transform;
|
||||
|
||||
@ -303,11 +307,12 @@ blendmodes (void)
|
||||
for (j = 0; j < 4; j++, mode++)
|
||||
{
|
||||
GskRenderNode *b;
|
||||
graphene_matrix_t matrix;
|
||||
GskTransform *transform;
|
||||
|
||||
b = gsk_blend_node_new (child1, child2, mode);
|
||||
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { i * 110, j * 110, 0 });
|
||||
blend[mode] = gsk_transform_node_new (b, &matrix);
|
||||
transform = gsk_transform_translate (NULL, &(const graphene_point_t) { i * 110, j * 110 });
|
||||
blend[mode] = gsk_transform_node_new (b, transform);
|
||||
gsk_transform_unref (transform);
|
||||
gsk_render_node_unref (b);
|
||||
}
|
||||
|
||||
@ -329,13 +334,14 @@ cross_fade (void)
|
||||
GskRenderNode *child2;
|
||||
GskRenderNode *transform;
|
||||
GskRenderNode *container;
|
||||
graphene_matrix_t matrix;
|
||||
GskTransform *matrix;
|
||||
|
||||
child1 = cairo ();
|
||||
child2 = cairo2 ();
|
||||
|
||||
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { 50, 50, 0 });
|
||||
transform = gsk_transform_node_new (child2, &matrix);
|
||||
matrix = gsk_transform_translate (NULL, &(const graphene_point_t) { 50, 50 });
|
||||
transform = gsk_transform_node_new (child2, matrix);
|
||||
gsk_transform_unref (matrix);
|
||||
gsk_render_node_unref (child2);
|
||||
child2 = transform;
|
||||
|
||||
@ -355,7 +361,7 @@ cross_fades (void)
|
||||
GskRenderNode *node;
|
||||
GskRenderNode *nodes[5];
|
||||
GskRenderNode *container;
|
||||
graphene_matrix_t matrix;
|
||||
GskTransform *transform;
|
||||
int i;
|
||||
|
||||
child1 = cairo2 ();
|
||||
@ -364,8 +370,9 @@ cross_fades (void)
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
node = gsk_cross_fade_node_new (child1, child2, i / 4.0);
|
||||
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { i* 210, 0, 0 });
|
||||
nodes[i] = gsk_transform_node_new (node, &matrix);
|
||||
transform = gsk_transform_translate (NULL, &(const graphene_point_t) { i* 210, 0 });
|
||||
nodes[i] = gsk_transform_node_new (node, transform);
|
||||
gsk_transform_unref (transform);
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
@ -386,21 +393,17 @@ transform (void)
|
||||
GskRenderNode *node;
|
||||
GskRenderNode *nodes[10];
|
||||
GskRenderNode *container;
|
||||
graphene_matrix_t scale;
|
||||
graphene_matrix_t translate;
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec3_t axis;
|
||||
graphene_vec3_init (&axis, 0.0, 0.0, 1.0);
|
||||
GskTransform *transform;
|
||||
int i;
|
||||
|
||||
node = ducky ();
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
graphene_matrix_init_rotate (&scale, 20.0 * i, &axis);
|
||||
graphene_matrix_init_translate (&translate, &(const graphene_point3d_t) { i* 110, 0, 0 });
|
||||
graphene_matrix_multiply (&scale, &translate, &matrix);
|
||||
nodes[i] = gsk_transform_node_new (node, &matrix);
|
||||
transform = gsk_transform_rotate (NULL, 20.0 * i);
|
||||
transform = gsk_transform_translate (transform, &(const graphene_point_t) { i* 110, 0 });
|
||||
nodes[i] = gsk_transform_node_new (node, transform);
|
||||
gsk_transform_unref (transform);
|
||||
}
|
||||
|
||||
container = gsk_container_node_new (nodes, 5);
|
||||
@ -420,7 +423,7 @@ opacity (void)
|
||||
GskRenderNode *node;
|
||||
GskRenderNode *nodes[5];
|
||||
GskRenderNode *container;
|
||||
graphene_matrix_t matrix;
|
||||
GskTransform *transform;
|
||||
int i;
|
||||
|
||||
child = ducky ();
|
||||
@ -428,8 +431,9 @@ opacity (void)
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
node = gsk_opacity_node_new (child, i / 4.0);
|
||||
graphene_matrix_init_translate (&matrix, &(const graphene_point3d_t) { i* 210, 0, 0 });
|
||||
nodes[i] = gsk_transform_node_new (node, &matrix);
|
||||
transform = gsk_transform_translate (NULL, &(const graphene_point_t) { i* 210, 0 });
|
||||
nodes[i] = gsk_transform_node_new (node, transform);
|
||||
gsk_transform_unref (transform);
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
@ -454,7 +458,7 @@ color_matrix1 (void)
|
||||
GskRenderNode *child_nodes[N];
|
||||
graphene_matrix_t matrix;
|
||||
graphene_vec4_t offset;
|
||||
graphene_matrix_t transform;
|
||||
GskTransform *transform;
|
||||
float cairo_width = 150;
|
||||
graphene_rect_t bounds;
|
||||
|
||||
@ -470,14 +474,16 @@ color_matrix1 (void)
|
||||
offset = *graphene_vec4_zero ();
|
||||
graphene_matrix_init_scale (&matrix, 0.3, 0.3, 0.3); /* Should make the node darker */
|
||||
n = gsk_color_matrix_node_new (cairo_node, &matrix, &offset);
|
||||
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (cairo_width, 0, 0));
|
||||
child_nodes[1] = gsk_transform_node_new (n, &transform);
|
||||
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (cairo_width, 0));
|
||||
child_nodes[1] = gsk_transform_node_new (n, transform);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
/* Same as above, but this time we stuff the transform node in the color matrix node, and not vice versa */
|
||||
offset = *graphene_vec4_zero ();
|
||||
graphene_matrix_init_scale (&matrix, 0.3, 0.3, 0.3);
|
||||
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (2 * cairo_width, 0, 0));
|
||||
n = gsk_transform_node_new (cairo_node, &transform);
|
||||
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (2 * cairo_width, 0));
|
||||
n = gsk_transform_node_new (cairo_node, transform);
|
||||
gsk_transform_unref (transform);
|
||||
child_nodes[2] = gsk_color_matrix_node_new (n, &matrix, &offset);
|
||||
|
||||
/* Color matrix inside color matrix, one reversing the other's effect */
|
||||
@ -491,8 +497,9 @@ color_matrix1 (void)
|
||||
|
||||
graphene_matrix_init_scale (&matrix, 2, 2, 2);
|
||||
n = gsk_color_matrix_node_new (inner_color_matrix_node, &matrix, &offset);
|
||||
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (3 * cairo_width, 0, 0));
|
||||
child_nodes[3] = gsk_transform_node_new (n, &transform);
|
||||
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (3 * cairo_width, 0));
|
||||
child_nodes[3] = gsk_transform_node_new (n, transform);
|
||||
gsk_transform_unref (transform);
|
||||
}
|
||||
|
||||
/* Color matrix in color matrix in transform */
|
||||
@ -507,11 +514,12 @@ color_matrix1 (void)
|
||||
graphene_matrix_init_scale (&matrix, 2, 2, 2);
|
||||
offset = *graphene_vec4_zero ();
|
||||
n = gsk_color_matrix_node_new (inner_color_matrix_node, &matrix, &offset);
|
||||
graphene_matrix_init_scale (&transform, 1, 1, 1);
|
||||
graphene_matrix_rotate_z (&transform, 350);
|
||||
graphene_matrix_translate (&transform, &GRAPHENE_POINT3D_INIT (4 * cairo_width, 0, 0));
|
||||
transform = gsk_transform_scale (NULL, 1, 1);
|
||||
transform = gsk_transform_rotate (transform, 350);
|
||||
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (4 * cairo_width, 0));
|
||||
|
||||
child_nodes[4] = gsk_transform_node_new (n, &transform);
|
||||
child_nodes[4] = gsk_transform_node_new (n, transform);
|
||||
gsk_transform_unref (transform);
|
||||
}
|
||||
|
||||
container_node = gsk_container_node_new (child_nodes, N);
|
||||
@ -528,36 +536,37 @@ transformed_clip (void)
|
||||
GskRenderNode *transform_node;
|
||||
GskRenderNode *clip_node;
|
||||
GskRenderNode *nodes[4];
|
||||
graphene_matrix_t transform;
|
||||
GskTransform *transform;
|
||||
|
||||
{
|
||||
clip_node = gsk_clip_node_new (ducky (),
|
||||
&GRAPHENE_RECT_INIT (0, 0, 200, 500));
|
||||
|
||||
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (180, 0, 0));
|
||||
nodes[0] = gsk_transform_node_new (clip_node, &transform);
|
||||
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (180, 0));
|
||||
nodes[0] = gsk_transform_node_new (clip_node, transform);
|
||||
gsk_transform_unref (transform);
|
||||
}
|
||||
|
||||
{
|
||||
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (0, 200, 0));
|
||||
transform_node = gsk_transform_node_new (ducky (), &transform);
|
||||
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (0, 200));
|
||||
transform_node = gsk_transform_node_new (ducky (), transform);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
nodes[1] = gsk_clip_node_new (transform_node,
|
||||
&GRAPHENE_RECT_INIT (0, 0, 500, 250));
|
||||
}
|
||||
|
||||
{
|
||||
graphene_vec3_t axis_vec;
|
||||
|
||||
graphene_matrix_init_translate (&transform, &GRAPHENE_POINT3D_INIT (150, 200, 0));
|
||||
transform_node = gsk_transform_node_new (ducky (), &transform);
|
||||
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (150, 200));
|
||||
transform_node = gsk_transform_node_new (ducky (), transform);
|
||||
gsk_transform_unref (transform);
|
||||
clip_node = gsk_clip_node_new (transform_node,
|
||||
&GRAPHENE_RECT_INIT (150, 200, 91, 100));
|
||||
|
||||
graphene_vec3_init (&axis_vec, 0, 0, 1);
|
||||
graphene_matrix_init_rotate (&transform, 20, &axis_vec);
|
||||
transform = gsk_transform_rotate (NULL, 20);
|
||||
/*graphene_matrix_init_identity (&transform);*/
|
||||
nodes[2] = gsk_transform_node_new (clip_node, &transform);
|
||||
nodes[2] = gsk_transform_node_new (clip_node, transform);
|
||||
gsk_transform_unref (transform);
|
||||
|
||||
|
||||
|
||||
@ -576,12 +585,10 @@ transformed_clip (void)
|
||||
}
|
||||
|
||||
{
|
||||
graphene_vec3_t axis_vec;
|
||||
|
||||
graphene_vec3_init (&axis_vec, 0, 0, 1);
|
||||
graphene_matrix_init_rotate (&transform, 20, &axis_vec);
|
||||
graphene_matrix_translate (&transform, &GRAPHENE_POINT3D_INIT (350, 200, 0));
|
||||
transform_node = gsk_transform_node_new (ducky (), &transform);
|
||||
transform = gsk_transform_rotate (NULL, 20);
|
||||
transform = gsk_transform_translate (transform, &GRAPHENE_POINT_INIT (350, 200));
|
||||
transform_node = gsk_transform_node_new (ducky (), transform);
|
||||
gsk_transform_unref (transform);
|
||||
nodes[3] = gsk_clip_node_new (transform_node,
|
||||
&GRAPHENE_RECT_INIT (350, 200, 91, 100));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user