[gtk] gsk: Remove offset nodes
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] gsk: Remove offset nodes
- Date: Thu, 21 Feb 2019 18:51:01 +0000 (UTC)
commit 6a4bf2b9938abbcbf531a9d64b01007dfa2e144d
Author: Benjamin Otte <otte redhat com>
Date: Wed Feb 20 03:02:23 2019 +0100
gsk: Remove offset nodes
They were a neat idea while they lasted. But now, it's time for
categorized transform nodes, where matrices with
GSK_MATRIX_CATEGORY_2D_TRANSLATE are the exact replacement.
Renderers have not been adapted for this purpose, so they (continue to)
run slow paths.
gsk/gl/gskglrenderer.c | 23 -----
gsk/gskbroadwayrenderer.c | 9 --
gsk/gskenums.h | 2 -
gsk/gskrendernode.h | 11 ---
gsk/gskrendernodeimpl.c | 202 +--------------------------------------
gsk/vulkan/gskvulkanrenderpass.c | 18 +---
gtk/gtksnapshot.c | 29 +++---
gtk/inspector/recorder.c | 13 ---
8 files changed, 18 insertions(+), 289 deletions(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index 6e7abbc3e1..d8444a9613 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -77,11 +77,6 @@ print_render_node_tree (GskRenderNode *root, int level)
print_render_node_tree (gsk_container_node_get_child (root, i), level + 1);
break;
- case GSK_OFFSET_NODE:
- g_print ("%*s Offset\n", level * INDENT, " ");
- print_render_node_tree (gsk_offset_node_get_child (root), level + 1);
- break;
-
case GSK_TRANSFORM_NODE:
g_print ("%*s Transform\n", level * INDENT, " ");
print_render_node_tree (gsk_transform_node_get_child (root), level + 1);
@@ -765,20 +760,6 @@ render_texture_node (GskGLRenderer *self,
}
}
-static inline void
-render_offset_node (GskGLRenderer *self,
- GskRenderNode *node,
- RenderOpBuilder *builder)
-{
- GskRenderNode *child = gsk_offset_node_get_child (node);
- const float dx = gsk_offset_node_get_x_offset (node);
- const float dy = gsk_offset_node_get_y_offset (node);
-
- ops_offset (builder, dx, dy);
- gsk_gl_renderer_add_render_ops (self, child, builder);
- ops_offset (builder, - dx, - dy);
-}
-
static inline void
render_transform_node (GskGLRenderer *self,
GskRenderNode *node,
@@ -2348,10 +2329,6 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
render_texture_node (self, node, builder);
break;
- case GSK_OFFSET_NODE:
- render_offset_node (self, node, builder);
- break;
-
case GSK_TRANSFORM_NODE:
render_transform_node (self, node, builder);
break;
diff --git a/gsk/gskbroadwayrenderer.c b/gsk/gskbroadwayrenderer.c
index d402cdd831..fc4507f62b 100644
--- a/gsk/gskbroadwayrenderer.c
+++ b/gsk/gskbroadwayrenderer.c
@@ -580,15 +580,6 @@ gsk_broadway_renderer_add_node (GskRenderer *renderer,
/* Bin nodes */
- case GSK_OFFSET_NODE:
- {
- gsk_broadway_renderer_add_node (renderer, nodes, node_textures,
- gsk_offset_node_get_child (node),
- offset_x - gsk_offset_node_get_x_offset (node),
- offset_y - gsk_offset_node_get_y_offset (node));
- }
- return;
-
case GSK_SHADOW_NODE:
{
gsize i, n_shadows = gsk_shadow_node_get_n_shadows (node);
diff --git a/gsk/gskenums.h b/gsk/gskenums.h
index 4c17675ef3..795a8ed37c 100644
--- a/gsk/gskenums.h
+++ b/gsk/gskenums.h
@@ -45,7 +45,6 @@
* @GSK_CROSS_FADE_NODE: A node that cross-fades between two children
* @GSK_TEXT_NODE: A node containing a glyph string
* @GSK_BLUR_NODE: A node that applies a blur
- * @GSK_OFFSET_NODE: A node that renders its child after applying a 2D translation
*
* The type of a node determines what the node is rendering.
**/
@@ -71,7 +70,6 @@ typedef enum {
GSK_CROSS_FADE_NODE,
GSK_TEXT_NODE,
GSK_BLUR_NODE,
- GSK_OFFSET_NODE,
GSK_DEBUG_NODE
} GskRenderNodeType;
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index 5abcf951fe..3099569471 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -203,17 +203,6 @@ GDK_AVAILABLE_IN_ALL
const graphene_matrix_t *
gsk_transform_node_peek_transform (GskRenderNode *node);
-GDK_AVAILABLE_IN_ALL
-GskRenderNode * gsk_offset_node_new (GskRenderNode *child,
- float x_offset,
- float y_offset);
-GDK_AVAILABLE_IN_ALL
-GskRenderNode * gsk_offset_node_get_child (GskRenderNode *node);
-GDK_AVAILABLE_IN_ALL
-float gsk_offset_node_get_x_offset (GskRenderNode *node);
-GDK_AVAILABLE_IN_ALL
-float gsk_offset_node_get_y_offset (GskRenderNode *node);
-
GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
double opacity);
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 34dd509d1f..65c8e33332 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -2590,206 +2590,6 @@ gsk_transform_node_get_category (GskRenderNode *node)
return self->category;
}
-/*** GSK_OFFSET_NODE ***/
-
-typedef struct _GskOffsetNode GskOffsetNode;
-
-struct _GskOffsetNode
-{
- GskRenderNode render_node;
-
- GskRenderNode *child;
- float x_offset;
- float y_offset;
-};
-
-static void
-gsk_offset_node_finalize (GskRenderNode *node)
-{
- GskOffsetNode *self = (GskOffsetNode *) node;
-
- gsk_render_node_unref (self->child);
-}
-
-static void
-gsk_offset_node_draw (GskRenderNode *node,
- cairo_t *cr)
-{
- GskOffsetNode *self = (GskOffsetNode *) node;
-
- cairo_translate (cr, self->x_offset, self->y_offset);
- gsk_render_node_draw (self->child, cr);
-}
-
-static gboolean
-gsk_offset_node_can_diff (GskRenderNode *node1,
- GskRenderNode *node2)
-{
- GskOffsetNode *self1 = (GskOffsetNode *) node1;
- GskOffsetNode *self2 = (GskOffsetNode *) node2;
-
- return self1->x_offset == self2->x_offset
- && self1->y_offset == self2->y_offset
- && gsk_render_node_can_diff (self1->child, self2->child);
-}
-
-static void
-gsk_offset_node_diff (GskRenderNode *node1,
- GskRenderNode *node2,
- cairo_region_t *region)
-{
- GskOffsetNode *self1 = (GskOffsetNode *) node1;
- GskOffsetNode *self2 = (GskOffsetNode *) node2;
-
- if (self1->x_offset == self2->x_offset &&
- self1->y_offset == self2->y_offset)
- {
- cairo_region_t *sub;
-
- if (self1->child == self2->child)
- return;
-
- sub = cairo_region_create ();
- gsk_render_node_diff (self1->child, self2->child, sub);
- cairo_region_translate (sub, self1->x_offset, self1->y_offset);
- cairo_region_union (region, sub);
- cairo_region_destroy (sub);
- }
- else
- {
- gsk_render_node_diff_impossible (node1, node2, region);
- }
-}
-
-#define GSK_OFFSET_NODE_VARIANT_TYPE "(dduv)"
-
-static GVariant *
-gsk_offset_node_serialize (GskRenderNode *node)
-{
- GskOffsetNode *self = (GskOffsetNode *) node;
-
- return g_variant_new (GSK_OFFSET_NODE_VARIANT_TYPE,
- self->x_offset,
- self->y_offset,
- (guint32) gsk_render_node_get_node_type (self->child),
- gsk_render_node_serialize_node (self->child));
-}
-
-static GskRenderNode *
-gsk_offset_node_deserialize (GVariant *variant,
- GError **error)
-{
- double x_offset, y_offset;
- guint32 child_type;
- GVariant *child_variant;
- GskRenderNode *result, *child;
-
- if (!check_variant_type (variant, GSK_OFFSET_NODE_VARIANT_TYPE, error))
- return NULL;
-
- g_variant_get (variant, GSK_OFFSET_NODE_VARIANT_TYPE,
- &x_offset, &y_offset,
- &child_type, &child_variant);
-
- child = gsk_render_node_deserialize_node (child_type, child_variant, error);
- g_variant_unref (child_variant);
-
- if (child == NULL)
- return NULL;
-
- result = gsk_offset_node_new (child, x_offset, y_offset);
-
- gsk_render_node_unref (child);
-
- return result;
-}
-
-static const GskRenderNodeClass GSK_OFFSET_NODE_CLASS = {
- GSK_OFFSET_NODE,
- sizeof (GskOffsetNode),
- "GskOffsetNode",
- gsk_offset_node_finalize,
- gsk_offset_node_draw,
- gsk_offset_node_can_diff,
- gsk_offset_node_diff,
- gsk_offset_node_serialize,
- gsk_offset_node_deserialize
-};
-
-/**
- * gsk_offset_node_new:
- * @child: The node to offset
- * @x_offset: The x offset to apply
- * @y_offset: The y offset to apply
- *
- * Creates a #GskRenderNode that will offset the given @child
- * with the given @x_offset and @y_offset.
- *
- * This is a common special case of the matrix transform
- * achieved by gsk_transform_node_new().
- *
- * Returns: A new #GskRenderNode
- */
-GskRenderNode *
-gsk_offset_node_new (GskRenderNode *child,
- float x_offset,
- float y_offset)
-{
- GskOffsetNode *self;
-
- g_return_val_if_fail (GSK_IS_RENDER_NODE (child), NULL);
-
- self = (GskOffsetNode *) gsk_render_node_new (&GSK_OFFSET_NODE_CLASS, 0);
-
- self->child = gsk_render_node_ref (child);
- self->x_offset = x_offset;
- self->y_offset = y_offset;
-
- graphene_rect_offset_r (&child->bounds,
- x_offset, y_offset,
- &self->render_node.bounds);
-
- return &self->render_node;
-}
-
-/**
- * gsk_offset_node_get_child:
- * @node: a offset @GskRenderNode
- *
- * Gets the child node that is getting offset by the given @node.
- *
- * Returns: (transfer none): The child that is getting offset
- **/
-GskRenderNode *
-gsk_offset_node_get_child (GskRenderNode *node)
-{
- GskOffsetNode *self = (GskOffsetNode *) node;
-
- g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OFFSET_NODE), NULL);
-
- return self->child;
-}
-
-float
-gsk_offset_node_get_x_offset (GskRenderNode *node)
-{
- GskOffsetNode *self = (GskOffsetNode *) node;
-
- g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OFFSET_NODE), 0.0);
-
- return self->x_offset;
-}
-
-float
-gsk_offset_node_get_y_offset (GskRenderNode *node)
-{
- GskOffsetNode *self = (GskOffsetNode *) node;
-
- g_return_val_if_fail (GSK_IS_RENDER_NODE_TYPE (node, GSK_OFFSET_NODE), 0.0);
-
- return self->y_offset;
-}
-
/*** GSK_DEBUG_NODE ***/
typedef struct _GskDebugNode GskDebugNode;
@@ -5320,7 +5120,7 @@ static const GskRenderNodeClass *klasses[] = {
[GSK_CROSS_FADE_NODE] = &GSK_CROSS_FADE_NODE_CLASS,
[GSK_TEXT_NODE] = &GSK_TEXT_NODE_CLASS,
[GSK_BLUR_NODE] = &GSK_BLUR_NODE_CLASS,
- [GSK_OFFSET_NODE] = &GSK_OFFSET_NODE_CLASS
+ [GSK_DEBUG_NODE] = &GSK_DEBUG_NODE_CLASS
};
GskRenderNode *
diff --git a/gsk/vulkan/gskvulkanrenderpass.c b/gsk/vulkan/gskvulkanrenderpass.c
index fa3d10ada6..4307340e7e 100644
--- a/gsk/vulkan/gskvulkanrenderpass.c
+++ b/gsk/vulkan/gskvulkanrenderpass.c
@@ -549,7 +549,6 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
gsk_vulkan_render_pass_add_node (self, render, constants, gsk_debug_node_get_child (node));
return;
- case GSK_OFFSET_NODE:
case GSK_TRANSFORM_NODE:
{
graphene_matrix_t transform, mv;
@@ -560,21 +559,8 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
FALLBACK ("Transform nodes can't deal with clip type %u\n", clip->type);
#endif
- if (gsk_render_node_get_node_type (node) == GSK_TRANSFORM_NODE)
- {
- child = gsk_transform_node_get_child (node);
- graphene_matrix_init_from_matrix (&transform, gsk_transform_node_peek_transform (node));
- }
- else
- {
- child = gsk_offset_node_get_child (node);
- graphene_matrix_init_translate (&transform,
- &GRAPHENE_POINT3D_INIT(
- gsk_offset_node_get_x_offset (node),
- gsk_offset_node_get_y_offset (node),
- 0.0
- ));
- }
+ child = gsk_transform_node_get_child (node);
+ graphene_matrix_init_from_matrix (&transform, gsk_transform_node_peek_transform (node));
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))
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index 2d31929d8a..8a85755dd5 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -349,8 +349,10 @@ gtk_snapshot_collect_offset (GtkSnapshot *snapshot,
GskRenderNode **nodes,
guint n_nodes)
{
- GskRenderNode *node, *offset_node;
+ GskRenderNode *node, *result;
GtkSnapshotState *previous_state;
+ graphene_matrix_t matrix;
+ GskMatrixCategory category;
node = gtk_snapshot_collect_default (snapshot, state, nodes, n_nodes);
if (node == NULL)
@@ -361,25 +363,24 @@ gtk_snapshot_collect_offset (GtkSnapshot *snapshot,
previous_state->translate_y == 0.0)
return node;
- if (gsk_render_node_get_node_type (node) == GSK_OFFSET_NODE)
- {
- const float dx = previous_state->translate_x;
- const float dy = previous_state->translate_y;
+ graphene_matrix_init_translate (&matrix,
+ &GRAPHENE_POINT3D_INIT (previous_state->translate_x,
+ previous_state->translate_y,
+ 0));
+ category = GSK_MATRIX_CATEGORY_2D_TRANSLATE;
- offset_node = gsk_offset_node_new (gsk_offset_node_get_child (node),
- gsk_offset_node_get_x_offset (node) + dx,
- gsk_offset_node_get_y_offset (node) + dy);
- }
- else
+ if (gsk_render_node_get_node_type (node) == GSK_TRANSFORM_NODE)
{
- offset_node = gsk_offset_node_new (node,
- previous_state->translate_x,
- previous_state->translate_y);
+ node = gsk_render_node_ref (gsk_transform_node_get_child (node));
+ graphene_matrix_multiply (&matrix, gsk_transform_node_peek_transform (node), &matrix);
+ category = MIN (category, gsk_transform_node_get_category (node));
}
+
+ result = gsk_transform_node_new_with_category (node, &matrix, category);
gsk_render_node_unref (node);
- return offset_node;
+ return result;
}
static void
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index 0a56aefb8a..7230b6bd74 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -118,9 +118,6 @@ create_list_model_for_render_node (GskRenderNode *node)
/* no children */
return NULL;
- case GSK_OFFSET_NODE:
- return create_render_node_list_model ((GskRenderNode *[1]) { gsk_offset_node_get_child (node) }, 1);
-
case GSK_TRANSFORM_NODE:
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_transform_node_get_child (node) }, 1);
@@ -230,8 +227,6 @@ node_type_name (GskRenderNodeType type)
return "Outset Shadow";
case GSK_TRANSFORM_NODE:
return "Transform";
- case GSK_OFFSET_NODE:
- return "Offset";
case GSK_OPACITY_NODE:
return "Opacity";
case GSK_COLOR_MATRIX_NODE:
@@ -283,9 +278,6 @@ node_name (GskRenderNode *node)
case GSK_BLUR_NODE:
return g_strdup (node_type_name (gsk_render_node_get_node_type (node)));
- case GSK_OFFSET_NODE:
- return g_strdup_printf ("Offset %g, %g", gsk_offset_node_get_x_offset (node),
gsk_offset_node_get_y_offset (node));
-
case GSK_DEBUG_NODE:
return g_strdup (gsk_debug_node_get_message (node));
@@ -894,11 +886,6 @@ populate_render_node_properties (GtkListStore *store,
}
break;
- case GSK_OFFSET_NODE:
- add_float_row (store, "x offset", gsk_offset_node_get_x_offset (node));
- add_float_row (store, "y offset", gsk_offset_node_get_y_offset (node));
- break;
-
case GSK_TRANSFORM_NODE:
{
static const char * category_names[] = {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]