diff options
author | Benjamin Otte <otte@redhat.com> | 2023-04-03 16:39:52 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2023-04-03 19:27:58 +0200 |
commit | 6e8c3fc3ff5e41472c674580b66b1314668a6f9f (patch) | |
tree | 4981ccfd5ee0a43ef3ec0a6b4e69c4f98c1d4152 /gsk | |
parent | 0d139a81c742c94647e4d5328ae8e3e2604f1077 (diff) | |
download | gtk+-6e8c3fc3ff5e41472c674580b66b1314668a6f9f.tar.gz |
rendernode: Get rid of GskRenderNodeTypeInfo
Instead, use class_init functions.
Diffstat (limited to 'gsk')
-rw-r--r-- | gsk/gskrendernode.c | 72 | ||||
-rw-r--r-- | gsk/gskrendernodeimpl.c | 726 | ||||
-rw-r--r-- | gsk/gskrendernodeprivate.h | 35 |
3 files changed, 438 insertions, 395 deletions
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c index 4ae09f7deb..26a8ea5031 100644 --- a/gsk/gskrendernode.c +++ b/gsk/gskrendernode.c @@ -148,7 +148,7 @@ static gboolean gsk_render_node_real_can_diff (const GskRenderNode *node1, const GskRenderNode *node2) { - return FALSE; + return TRUE; } static void @@ -156,6 +156,7 @@ gsk_render_node_real_diff (GskRenderNode *node1, GskRenderNode *node2, cairo_region_t *region) { + gsk_render_node_diff_impossible (node1, node2, region); } static void @@ -229,50 +230,6 @@ gsk_render_node_get_type (void) return render_node_type__volatile; } -typedef struct -{ - GskRenderNodeType node_type; - - void (* finalize) (GskRenderNode *node); - void (* draw) (GskRenderNode *node, - cairo_t *cr); - gboolean (* can_diff) (const GskRenderNode *node1, - const GskRenderNode *node2); - void (* diff) (GskRenderNode *node1, - GskRenderNode *node2, - cairo_region_t *region); -} RenderNodeClassData; - -static void -gsk_render_node_generic_class_init (gpointer g_class, - gpointer class_data) -{ - GskRenderNodeClass *node_class = g_class; - RenderNodeClassData *node_data = class_data; - - /* Mandatory */ - node_class->node_type = node_data->node_type; - - /* Optional */ - if (node_data->finalize != NULL) - node_class->finalize = node_data->finalize; - if (node_data->can_diff != NULL) - node_class->can_diff = node_data->can_diff; - - /* Mandatory */ - node_class->draw = node_data->draw; - node_class->diff = node_data->diff; - - g_free (node_data); -} - -static gboolean -gsk_render_node_can_diff_true (const GskRenderNode *node1, - const GskRenderNode *node2) -{ - return TRUE; -} - /*< private > * gsk_render_node_type_register_static: * @node_name: the name of the node @@ -284,33 +241,18 @@ gsk_render_node_can_diff_true (const GskRenderNode *node1, * Returns: the newly registered GType */ GType -gsk_render_node_type_register_static (const char *node_name, - const GskRenderNodeTypeInfo *node_info) +gsk_render_node_type_register_static (const char *node_name, + gsize instance_size, + GClassInitFunc class_init) { GTypeInfo info; info.class_size = sizeof (GskRenderNodeClass); info.base_init = NULL; info.base_finalize = NULL; - info.class_init = gsk_render_node_generic_class_init; + info.class_init = class_init; info.class_finalize = NULL; - - /* Avoid having a class_init() and a class struct for every GskRenderNode, - * by passing the various virtual functions and class data when initializing - * the base class - */ - info.class_data = g_new (RenderNodeClassData, 1); - ((RenderNodeClassData *) info.class_data)->node_type = node_info->node_type; - ((RenderNodeClassData *) info.class_data)->finalize = node_info->finalize; - ((RenderNodeClassData *) info.class_data)->draw = node_info->draw; - ((RenderNodeClassData *) info.class_data)->can_diff = node_info->can_diff != NULL - ? node_info->can_diff - : gsk_render_node_can_diff_true; - ((RenderNodeClassData *) info.class_data)->diff = node_info->diff != NULL - ? node_info->diff - : gsk_render_node_diff_impossible; - - info.instance_size = node_info->instance_size; + info.instance_size = instance_size; info.n_preallocs = 0; info.instance_init = NULL; info.value_table = NULL; diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 01e20a7cb2..0a09a353d5 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -115,6 +115,18 @@ gsk_color_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_color_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_COLOR_NODE; + + node_class->draw = gsk_color_node_draw; + node_class->diff = gsk_color_node_diff; +} + /** * gsk_color_node_get_color: * @node: (type GskColorNode): a `GskRenderNode` @@ -263,6 +275,32 @@ gsk_linear_gradient_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_linear_gradient_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_LINEAR_GRADIENT_NODE; + + node_class->finalize = gsk_linear_gradient_node_finalize; + node_class->draw = gsk_linear_gradient_node_draw; + node_class->diff = gsk_linear_gradient_node_diff; +} + +static void +gsk_repeating_linear_gradient_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_REPEATING_LINEAR_GRADIENT_NODE; + + node_class->finalize = gsk_linear_gradient_node_finalize; + node_class->draw = gsk_linear_gradient_node_draw; + node_class->diff = gsk_linear_gradient_node_diff; +} + /** * gsk_linear_gradient_node_new: * @bounds: the rectangle to render the linear gradient into @@ -553,6 +591,32 @@ gsk_radial_gradient_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_radial_gradient_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_RADIAL_GRADIENT_NODE; + + node_class->finalize = gsk_radial_gradient_node_finalize; + node_class->draw = gsk_radial_gradient_node_draw; + node_class->diff = gsk_radial_gradient_node_diff; +} + +static void +gsk_repeating_radial_gradient_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_REPEATING_RADIAL_GRADIENT_NODE; + + node_class->finalize = gsk_radial_gradient_node_finalize; + node_class->draw = gsk_radial_gradient_node_draw; + node_class->diff = gsk_radial_gradient_node_diff; +} + /** * gsk_radial_gradient_node_new: * @bounds: the bounds of the node @@ -1013,6 +1077,19 @@ gsk_conic_gradient_node_diff (GskRenderNode *node1, } } +static void +gsk_conic_gradient_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_CONIC_GRADIENT_NODE; + + node_class->finalize = gsk_conic_gradient_node_finalize; + node_class->draw = gsk_conic_gradient_node_draw; + node_class->diff = gsk_conic_gradient_node_diff; +} + /** * gsk_conic_gradient_node_new: * @bounds: the bounds of the node @@ -1359,6 +1436,18 @@ gsk_border_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_border_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_BORDER_NODE; + + node_class->draw = gsk_border_node_draw; + node_class->diff = gsk_border_node_diff; +} + /** * gsk_border_node_get_outline: * @node: (type GskBorderNode): a `GskRenderNode` for a border @@ -1549,6 +1638,19 @@ gsk_texture_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_texture_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_TEXTURE_NODE; + + node_class->finalize = gsk_texture_node_finalize; + node_class->draw = gsk_texture_node_draw; + node_class->diff = gsk_texture_node_diff; +} + /** * gsk_texture_node_get_texture: * @node: (type GskTextureNode): a `GskRenderNode` of type %GSK_TEXTURE_NODE @@ -1715,6 +1817,19 @@ gsk_texture_scale_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_texture_scale_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_TEXTURE_SCALE_NODE; + + node_class->finalize = gsk_texture_scale_node_finalize; + node_class->draw = gsk_texture_scale_node_draw; + node_class->diff = gsk_texture_scale_node_diff; +} + /** * gsk_texture_scale_node_get_texture: * @node: (type GskTextureScaleNode): a `GskRenderNode` of type %GSK_TEXTURE_SCALE_NODE @@ -2215,6 +2330,18 @@ gsk_inset_shadow_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_inset_shadow_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_INSET_SHADOW_NODE; + + node_class->draw = gsk_inset_shadow_node_draw; + node_class->diff = gsk_inset_shadow_node_diff; +} + /** * gsk_inset_shadow_node_new: * @outline: outline of the region containing the shadow @@ -2515,6 +2642,18 @@ gsk_outset_shadow_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_outset_shadow_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_OUTSET_SHADOW_NODE; + + node_class->draw = gsk_outset_shadow_node_draw; + node_class->diff = gsk_outset_shadow_node_diff; +} + /** * gsk_outset_shadow_node_new: * @outline: outline of the region surrounded by shadow @@ -2702,6 +2841,18 @@ gsk_cairo_node_draw (GskRenderNode *node, cairo_paint (cr); } +static void +gsk_cairo_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_CAIRO_NODE; + + node_class->finalize = gsk_cairo_node_finalize; + node_class->draw = gsk_cairo_node_draw; +} + /** * gsk_cairo_node_get_surface: * @node: (type GskCairoNode): a `GskRenderNode` for a Cairo surface @@ -2941,6 +3092,19 @@ gsk_container_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_container_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_CONTAINER_NODE; + + node_class->finalize = gsk_container_node_finalize; + node_class->draw = gsk_container_node_draw; + node_class->diff = gsk_container_node_diff; +} + /** * gsk_container_node_new: * @children: (array length=n_children) (transfer none): The children of the node @@ -3201,6 +3365,20 @@ gsk_transform_node_diff (GskRenderNode *node1, } } +static void +gsk_transform_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_TRANSFORM_NODE; + + node_class->finalize = gsk_transform_node_finalize; + node_class->draw = gsk_transform_node_draw; + node_class->can_diff = gsk_transform_node_can_diff; + node_class->diff = gsk_transform_node_diff; +} + /** * gsk_transform_node_new: * @child: The node to transform @@ -3348,6 +3526,19 @@ gsk_opacity_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_opacity_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_OPACITY_NODE; + + node_class->finalize = gsk_opacity_node_finalize; + node_class->draw = gsk_opacity_node_draw; + node_class->diff = gsk_opacity_node_diff; +} + /** * gsk_opacity_node_new: * @child: The node to draw @@ -3564,6 +3755,19 @@ nope: return; } +static void +gsk_color_matrix_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_COLOR_MATRIX_NODE; + + node_class->finalize = gsk_color_matrix_node_finalize; + node_class->draw = gsk_color_matrix_node_draw; + node_class->diff = gsk_color_matrix_node_diff; +} + /** * gsk_color_matrix_node_new: * @child: The node to draw @@ -3718,6 +3922,18 @@ gsk_repeat_node_draw (GskRenderNode *node, cairo_fill (cr); } +static void +gsk_repeat_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_REPEAT_NODE; + + node_class->finalize = gsk_repeat_node_finalize; + node_class->draw = gsk_repeat_node_draw; +} + /** * gsk_repeat_node_new: * @bounds: The bounds of the area to be painted @@ -3859,6 +4075,19 @@ gsk_clip_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } } + +static void +gsk_clip_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_CLIP_NODE; + + node_class->finalize = gsk_clip_node_finalize; + node_class->draw = gsk_clip_node_draw; + node_class->diff = gsk_clip_node_diff; +} /** * gsk_clip_node_new: @@ -3995,6 +4224,19 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1, } } +static void +gsk_rounded_clip_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_ROUNDED_CLIP_NODE; + + node_class->finalize = gsk_rounded_clip_node_finalize; + node_class->draw = gsk_rounded_clip_node_draw; + node_class->diff = gsk_rounded_clip_node_diff; +} + /** * gsk_rounded_clip_node_new: * @child: The node to draw @@ -4213,6 +4455,19 @@ gsk_shadow_node_get_bounds (GskShadowNode *self, bounds->size.height += top + bottom; } +static void +gsk_shadow_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_SHADOW_NODE; + + node_class->finalize = gsk_shadow_node_finalize; + node_class->draw = gsk_shadow_node_draw; + node_class->diff = gsk_shadow_node_diff; +} + /** * gsk_shadow_node_new: * @child: The node to draw @@ -4412,6 +4667,19 @@ gsk_blend_node_diff (GskRenderNode *node1, } } +static void +gsk_blend_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_BLEND_NODE; + + node_class->finalize = gsk_blend_node_finalize; + node_class->draw = gsk_blend_node_draw; + node_class->diff = gsk_blend_node_diff; +} + /** * gsk_blend_node_new: * @bottom: The bottom node to be drawn @@ -4564,6 +4832,19 @@ gsk_cross_fade_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_cross_fade_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_CROSS_FADE_NODE; + + node_class->finalize = gsk_cross_fade_node_finalize; + node_class->draw = gsk_cross_fade_node_draw; + node_class->diff = gsk_cross_fade_node_diff; +} + /** * gsk_cross_fade_node_new: * @start: The start node to be drawn @@ -4741,6 +5022,19 @@ gsk_text_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } +static void +gsk_text_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_TEXT_NODE; + + node_class->finalize = gsk_text_node_finalize; + node_class->draw = gsk_text_node_draw; + node_class->diff = gsk_text_node_diff; +} + /** * gsk_text_node_new: * @font: the `PangoFont` containing the glyphs @@ -5164,6 +5458,19 @@ gsk_blur_node_diff (GskRenderNode *node1, } } +static void +gsk_blur_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_BLUR_NODE; + + node_class->finalize = gsk_blur_node_finalize; + node_class->draw = gsk_blur_node_draw; + node_class->diff = gsk_blur_node_diff; +} + /** * gsk_blur_node_new: * @child: the child node to blur @@ -5332,6 +5639,19 @@ gsk_mask_node_diff (GskRenderNode *node1, gsk_render_node_diff (self1->mask, self2->mask, region); } +static void +gsk_mask_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_MASK_NODE; + + node_class->finalize = gsk_mask_node_finalize; + node_class->draw = gsk_mask_node_draw; + node_class->diff = gsk_mask_node_diff; +} + /** * gsk_mask_node_new: * @source: The source node to be drawn @@ -5487,6 +5807,20 @@ gsk_debug_node_diff (GskRenderNode *node1, gsk_render_node_diff (self1->child, self2->child, region); } +static void +gsk_debug_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_DEBUG_NODE; + + node_class->finalize = gsk_debug_node_finalize; + node_class->draw = gsk_debug_node_draw; + node_class->can_diff = gsk_debug_node_can_diff; + node_class->diff = gsk_debug_node_diff; +} + /** * gsk_debug_node_new: * @child: The child to add debug info for @@ -5624,6 +5958,19 @@ gsk_gl_shader_node_diff (GskRenderNode *node1, } } +static void +gsk_gl_shader_node_class_init (gpointer g_class, + gpointer class_data) +{ + GskRenderNodeClass *node_class = g_class; + + node_class->node_type = GSK_GL_SHADER_NODE; + + node_class->finalize = gsk_gl_shader_node_finalize; + node_class->draw = gsk_gl_shader_node_draw; + node_class->diff = gsk_gl_shader_node_diff; +} + /** * gsk_gl_shader_node_new: * @shader: the `GskGLShader` @@ -5808,407 +6155,192 @@ static void gsk_render_node_init_types_once (void) { { - const GskRenderNodeTypeInfo node_info = - { - GSK_CONTAINER_NODE, - sizeof (GskContainerNode), - gsk_container_node_finalize, - gsk_container_node_draw, - NULL, - gsk_container_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskContainerNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskContainerNode"), + sizeof (GskContainerNode), + gsk_container_node_class_init); gsk_render_node_types[GSK_CONTAINER_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_CAIRO_NODE, - sizeof (GskCairoNode), - gsk_cairo_node_finalize, - gsk_cairo_node_draw, - NULL, - NULL, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskCairoNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskCairoNode"), + sizeof (GskCairoNode), + gsk_cairo_node_class_init); gsk_render_node_types[GSK_CAIRO_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_COLOR_NODE, - sizeof (GskColorNode), - NULL, - gsk_color_node_draw, - NULL, - gsk_color_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskColorNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskColorNode"), + sizeof (GskColorNode), + gsk_color_node_class_init); gsk_render_node_types[GSK_COLOR_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_LINEAR_GRADIENT_NODE, - sizeof (GskLinearGradientNode), - gsk_linear_gradient_node_finalize, - gsk_linear_gradient_node_draw, - NULL, - gsk_linear_gradient_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskLinearGradientNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskLinearGradientNode"), + sizeof (GskLinearGradientNode), + gsk_linear_gradient_node_class_init); gsk_render_node_types[GSK_LINEAR_GRADIENT_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_REPEATING_LINEAR_GRADIENT_NODE, - sizeof (GskLinearGradientNode), - gsk_linear_gradient_node_finalize, - gsk_linear_gradient_node_draw, - NULL, - gsk_linear_gradient_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskRepeatingLinearGradientNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskRepeatingLinearGradientNode"), + sizeof (GskLinearGradientNode), + gsk_repeating_linear_gradient_node_class_init); gsk_render_node_types[GSK_REPEATING_LINEAR_GRADIENT_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_RADIAL_GRADIENT_NODE, - sizeof (GskRadialGradientNode), - gsk_radial_gradient_node_finalize, - gsk_radial_gradient_node_draw, - NULL, - gsk_radial_gradient_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskRadialGradientNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskRadialGradientNode"), + sizeof (GskRadialGradientNode), + gsk_radial_gradient_node_class_init); gsk_render_node_types[GSK_RADIAL_GRADIENT_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_REPEATING_RADIAL_GRADIENT_NODE, - sizeof (GskRadialGradientNode), - gsk_radial_gradient_node_finalize, - gsk_radial_gradient_node_draw, - NULL, - gsk_radial_gradient_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskRepeatingRadialGradientNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskRepeatingRadialGradientNode"), + sizeof (GskRadialGradientNode), + gsk_repeating_radial_gradient_node_class_init); gsk_render_node_types[GSK_REPEATING_RADIAL_GRADIENT_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_CONIC_GRADIENT_NODE, - sizeof (GskConicGradientNode), - gsk_conic_gradient_node_finalize, - gsk_conic_gradient_node_draw, - NULL, - gsk_conic_gradient_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskConicGradientNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskConicGradientNode"), + sizeof (GskConicGradientNode), + gsk_conic_gradient_node_class_init); gsk_render_node_types[GSK_CONIC_GRADIENT_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_BORDER_NODE, - sizeof (GskBorderNode), - NULL, - gsk_border_node_draw, - NULL, - gsk_border_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskBorderNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskBorderNode"), + sizeof (GskBorderNode), + gsk_border_node_class_init); gsk_render_node_types[GSK_BORDER_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_TEXTURE_NODE, - sizeof (GskTextureNode), - gsk_texture_node_finalize, - gsk_texture_node_draw, - NULL, - gsk_texture_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskTextureNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskTextureNode"), + sizeof (GskTextureNode), + gsk_texture_node_class_init); gsk_render_node_types[GSK_TEXTURE_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_TEXTURE_SCALE_NODE, - sizeof (GskTextureScaleNode), - gsk_texture_scale_node_finalize, - gsk_texture_scale_node_draw, - NULL, - gsk_texture_scale_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskTextureScaleNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskTextureScaleNode"), + sizeof (GskTextureScaleNode), + gsk_texture_scale_node_class_init); gsk_render_node_types[GSK_TEXTURE_SCALE_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_INSET_SHADOW_NODE, - sizeof (GskInsetShadowNode), - NULL, - gsk_inset_shadow_node_draw, - NULL, - gsk_inset_shadow_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskInsetShadowNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskInsetShadowNode"), + sizeof (GskInsetShadowNode), + gsk_inset_shadow_node_class_init); gsk_render_node_types[GSK_INSET_SHADOW_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_OUTSET_SHADOW_NODE, - sizeof (GskOutsetShadowNode), - NULL, - gsk_outset_shadow_node_draw, - NULL, - gsk_outset_shadow_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskOutsetShadowNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskOutsetShadowNode"), + sizeof (GskOutsetShadowNode), + gsk_outset_shadow_node_class_init); gsk_render_node_types[GSK_OUTSET_SHADOW_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_TRANSFORM_NODE, - sizeof (GskTransformNode), - gsk_transform_node_finalize, - gsk_transform_node_draw, - gsk_transform_node_can_diff, - gsk_transform_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskTransformNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskTransformNode"), + sizeof (GskTransformNode), + gsk_transform_node_class_init); gsk_render_node_types[GSK_TRANSFORM_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_OPACITY_NODE, - sizeof (GskOpacityNode), - gsk_opacity_node_finalize, - gsk_opacity_node_draw, - NULL, - gsk_opacity_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskOpacityNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskOpacityNode"), + sizeof (GskOpacityNode), + gsk_opacity_node_class_init); gsk_render_node_types[GSK_OPACITY_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_COLOR_MATRIX_NODE, - sizeof (GskColorMatrixNode), - gsk_color_matrix_node_finalize, - gsk_color_matrix_node_draw, - NULL, - gsk_color_matrix_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskColorMatrixNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskColorMatrixNode"), + sizeof (GskColorMatrixNode), + gsk_color_matrix_node_class_init); gsk_render_node_types[GSK_COLOR_MATRIX_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_REPEAT_NODE, - sizeof (GskRepeatNode), - gsk_repeat_node_finalize, - gsk_repeat_node_draw, - NULL, - NULL, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskRepeatNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskRepeatNode"), + sizeof (GskRepeatNode), + gsk_repeat_node_class_init); gsk_render_node_types[GSK_REPEAT_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_CLIP_NODE, - sizeof (GskClipNode), - gsk_clip_node_finalize, - gsk_clip_node_draw, - NULL, - gsk_clip_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskClipNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskClipNode"), + sizeof (GskClipNode), + gsk_clip_node_class_init); gsk_render_node_types[GSK_CLIP_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_ROUNDED_CLIP_NODE, - sizeof (GskRoundedClipNode), - gsk_rounded_clip_node_finalize, - gsk_rounded_clip_node_draw, - NULL, - gsk_rounded_clip_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskRoundedClipNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskRoundedClipNode"), + sizeof (GskRoundedClipNode), + gsk_rounded_clip_node_class_init); gsk_render_node_types[GSK_ROUNDED_CLIP_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_SHADOW_NODE, - sizeof (GskShadowNode), - gsk_shadow_node_finalize, - gsk_shadow_node_draw, - NULL, - gsk_shadow_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskShadowNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskShadowNode"), + sizeof (GskShadowNode), + gsk_shadow_node_class_init); gsk_render_node_types[GSK_SHADOW_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_BLEND_NODE, - sizeof (GskBlendNode), - gsk_blend_node_finalize, - gsk_blend_node_draw, - NULL, - gsk_blend_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskBlendNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskBlendNode"), + sizeof (GskBlendNode), + gsk_blend_node_class_init); gsk_render_node_types[GSK_BLEND_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_CROSS_FADE_NODE, - sizeof (GskCrossFadeNode), - gsk_cross_fade_node_finalize, - gsk_cross_fade_node_draw, - NULL, - gsk_cross_fade_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskCrossFadeNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskCrossFadeNode"), + sizeof (GskCrossFadeNode), + gsk_cross_fade_node_class_init); gsk_render_node_types[GSK_CROSS_FADE_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_TEXT_NODE, - sizeof (GskTextNode), - gsk_text_node_finalize, - gsk_text_node_draw, - NULL, - gsk_text_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskTextNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskTextNode"), + sizeof (GskTextNode), + gsk_text_node_class_init); gsk_render_node_types[GSK_TEXT_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_BLUR_NODE, - sizeof (GskBlurNode), - gsk_blur_node_finalize, - gsk_blur_node_draw, - NULL, - gsk_blur_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskBlurNode"), &node_info); + + GType node_type = gsk_render_node_type_register_static (I_("GskBlurNode"), + sizeof (GskBlurNode), + gsk_blur_node_class_init); gsk_render_node_types[GSK_BLUR_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_MASK_NODE, - sizeof (GskMaskNode), - gsk_mask_node_finalize, - gsk_mask_node_draw, - NULL, - gsk_mask_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskMaskNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskMaskNode"), + sizeof (GskMaskNode), + gsk_mask_node_class_init); gsk_render_node_types[GSK_MASK_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_GL_SHADER_NODE, - sizeof (GskGLShaderNode), - gsk_gl_shader_node_finalize, - gsk_gl_shader_node_draw, - NULL, - gsk_gl_shader_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskGLShaderNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskGLShaderNode"), + sizeof (GskGLShaderNode), + gsk_gl_shader_node_class_init); gsk_render_node_types[GSK_GL_SHADER_NODE] = node_type; } { - const GskRenderNodeTypeInfo node_info = - { - GSK_DEBUG_NODE, - sizeof (GskDebugNode), - gsk_debug_node_finalize, - gsk_debug_node_draw, - gsk_debug_node_can_diff, - gsk_debug_node_diff, - }; - - GType node_type = gsk_render_node_type_register_static (I_("GskDebugNode"), &node_info); + GType node_type = gsk_render_node_type_register_static (I_("GskDebugNode"), + sizeof (GskDebugNode), + gsk_debug_node_class_init); gsk_render_node_types[GSK_DEBUG_NODE] = node_type; } } diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h index ffcd0bb478..04135ec971 100644 --- a/gsk/gskrendernodeprivate.h +++ b/gsk/gskrendernodeprivate.h @@ -47,42 +47,11 @@ struct _GskRenderNodeClass cairo_region_t *region); }; -/*< private > - * GskRenderNodeTypeInfo: - * @node_type: the render node type in the `GskRenderNodeType` enumeration - * @instance_size: the size of the render node instance - * @instance_init: (nullable): the instance initialization function - * @finalize: (nullable): the instance finalization function; must chain up to the - * implementation of the parent class - * @draw: the function called by gsk_render_node_draw() - * @can_diff: (nullable): the function called by gsk_render_node_can_diff(); if - * unset, gsk_render_node_can_diff_true() will be used - * @diff: (nullable): the function called by gsk_render_node_diff(); if unset, - * gsk_render_node_diff_impossible() will be used - * - * A struction that contains the type information for a `GskRenderNode` subclass, - * to be used by gsk_render_node_type_register_static(). - */ -typedef struct -{ - GskRenderNodeType node_type; - - gsize instance_size; - - void (* finalize) (GskRenderNode *node); - void (* draw) (GskRenderNode *node, - cairo_t *cr); - gboolean (* can_diff) (const GskRenderNode *node1, - const GskRenderNode *node2); - void (* diff) (GskRenderNode *node1, - GskRenderNode *node2, - cairo_region_t *region); -} GskRenderNodeTypeInfo; - void gsk_render_node_init_types (void); GType gsk_render_node_type_register_static (const char *node_name, - const GskRenderNodeTypeInfo *node_info); + gsize instance_size, + GClassInitFunc class_init); gpointer gsk_render_node_alloc (GskRenderNodeType node_type); |