Add get_type() functions for GskRenderNode subclasses

The introspection scanner tries to match a type name with a get_type()
function, in order to correctly identify a type as a class.

If the function is not available, we have two choices:

 - add some special case inside the introspection scanner, similar to
   how GParamSpec subclasses are handled in GObject
 - add a simple get_type() function

The latter is the simplest approach, and we don't need to change that
much, since we still register all render nodes at once.
This commit is contained in:
Emmanuele Bassi 2020-04-08 15:34:11 +01:00
parent cd5cded430
commit e0323fcdc2
3 changed files with 116 additions and 54 deletions

View File

@ -99,30 +99,27 @@ GskRenderNode * gsk_render_node_deserialize (GBytes
GskParseErrorFunc error_func, GskParseErrorFunc error_func,
gpointer user_data); gpointer user_data);
#define GSK_TYPE_DEBUG_NODE (gsk_render_node_types[GSK_DEBUG_NODE]) #define GSK_TYPE_DEBUG_NODE (gsk_debug_node_get_type())
#define GSK_TYPE_COLOR_NODE (gsk_render_node_types[GSK_COLOR_NODE]) #define GSK_TYPE_COLOR_NODE (gsk_color_node_get_type())
#define GSK_TYPE_TEXTURE_NODE (gsk_render_node_types[GSK_TEXTURE_NODE]) #define GSK_TYPE_TEXTURE_NODE (gsk_texture_node_get_type())
#define GSK_TYPE_LINEAR_GRADIENT_NODE (gsk_render_node_types[GSK_LINEAR_GRADIENT_NODE]) #define GSK_TYPE_LINEAR_GRADIENT_NODE (gsk_linear_gradient_node_get_type())
#define GSK_TYPE_REPEATING_LINEAR_GRADIENT_NODE (gsk_render_node_types[GSK_REPEATING_LINEAR_GRADIENT_NODE]) #define GSK_TYPE_REPEATING_LINEAR_GRADIENT_NODE (gsk_repeating_linear_gradient_node_get_type())
#define GSK_TYPE_BORDER_NODE (gsk_render_node_types[GSK_BORDER_NODE]) #define GSK_TYPE_BORDER_NODE (gsk_border_node_get_type())
#define GSK_TYPE_INSET_SHADOW_NODE (gsk_render_node_types[GSK_INSET_SHADOW_NODE]) #define GSK_TYPE_INSET_SHADOW_NODE (gsk_inset_shadow_node_get_type())
#define GSK_TYPE_OUTSET_SHADOW_NODE (gsk_render_node_types[GSK_OUTSET_SHADOW_NODE]) #define GSK_TYPE_OUTSET_SHADOW_NODE (gsk_outset_shadow_node_get_type())
#define GSK_TYPE_CAIRO_NODE (gsk_render_node_types[GSK_CAIRO_NODE]) #define GSK_TYPE_CAIRO_NODE (gsk_cairo_node_get_type())
#define GSK_TYPE_CONTAINER_NODE (gsk_render_node_types[GSK_CONTAINER_NODE]) #define GSK_TYPE_CONTAINER_NODE (gsk_container_node_get_type())
#define GSK_TYPE_TRANSFORM_NODE (gsk_render_node_types[GSK_TRANSFORM_NODE]) #define GSK_TYPE_TRANSFORM_NODE (gsk_transform_node_get_type())
#define GSK_TYPE_OPACITY_NODE (gsk_render_node_types[GSK_OPACITY_NODE]) #define GSK_TYPE_OPACITY_NODE (gsk_opacity_node_get_type())
#define GSK_TYPE_COLOR_MATRIX_NODE (gsk_render_node_types[GSK_COLOR_MATRIX_NODE]) #define GSK_TYPE_COLOR_MATRIX_NODE (gsk_color_matrix_node_get_type())
#define GSK_TYPE_REPEAT_NODE (gsk_render_node_types[GSK_REPEAT_NODE]) #define GSK_TYPE_REPEAT_NODE (gsk_repeat_node_get_type())
#define GSK_TYPE_CLIP_NODE (gsk_render_node_types[GSK_CLIP_NODE]) #define GSK_TYPE_CLIP_NODE (gsk_clip_node_get_type())
#define GSK_TYPE_ROUNDED_CLIP_NODE (gsk_render_node_types[GSK_ROUNDED_CLIP_NODE]) #define GSK_TYPE_ROUNDED_CLIP_NODE (gsk_rounded_clip_node_get_type())
#define GSK_TYPE_SHADOW_NODE (gsk_render_node_types[GSK_SHADOW_NODE]) #define GSK_TYPE_SHADOW_NODE (gsk_shadow_node_get_type())
#define GSK_TYPE_BLEND_NODE (gsk_render_node_types[GSK_BLEND_NODE]) #define GSK_TYPE_BLEND_NODE (gsk_blend_node_get_type())
#define GSK_TYPE_CROSS_FADE_NODE (gsk_render_node_types[GSK_CROSS_FADE_NODE]) #define GSK_TYPE_CROSS_FADE_NODE (gsk_cross_fade_node_get_type())
#define GSK_TYPE_TEXT_NODE (gsk_render_node_types[GSK_TEXT_NODE]) #define GSK_TYPE_TEXT_NODE (gsk_text_node_get_type())
#define GSK_TYPE_BLUR_NODE (gsk_render_node_types[GSK_BLUR_NODE]) #define GSK_TYPE_BLUR_NODE (gsk_blur_node_get_type())
/*< private >*/
GDK_EXTERN_VAR GType gsk_render_node_types[];
typedef struct _GskDebugNode GskDebugNode; typedef struct _GskDebugNode GskDebugNode;
typedef struct _GskColorNode GskColorNode; typedef struct _GskColorNode GskColorNode;
@ -146,6 +143,8 @@ typedef struct _GskCrossFadeNode GskCrossFadeNode;
typedef struct _GskTextNode GskTextNode; typedef struct _GskTextNode GskTextNode;
typedef struct _GskBlurNode GskBlurNode; typedef struct _GskBlurNode GskBlurNode;
GDK_AVAILABLE_IN_ALL
GType gsk_debug_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_debug_node_new (GskRenderNode *child, GskRenderNode * gsk_debug_node_new (GskRenderNode *child,
char *message); char *message);
@ -154,18 +153,24 @@ GskRenderNode * gsk_debug_node_get_child (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const char * gsk_debug_node_get_message (GskRenderNode *node); const char * gsk_debug_node_get_message (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_color_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_color_node_new (const GdkRGBA *rgba, GskRenderNode * gsk_color_node_new (const GdkRGBA *rgba,
const graphene_rect_t *bounds); const graphene_rect_t *bounds);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const GdkRGBA * gsk_color_node_peek_color (GskRenderNode *node); const GdkRGBA * gsk_color_node_peek_color (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_texture_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_texture_node_new (GdkTexture *texture, GskRenderNode * gsk_texture_node_new (GdkTexture *texture,
const graphene_rect_t *bounds); const graphene_rect_t *bounds);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GdkTexture * gsk_texture_node_get_texture (GskRenderNode *node); GdkTexture * gsk_texture_node_get_texture (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_linear_gradient_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_linear_gradient_node_new (const graphene_rect_t *bounds, GskRenderNode * gsk_linear_gradient_node_new (const graphene_rect_t *bounds,
const graphene_point_t *start, const graphene_point_t *start,
@ -182,6 +187,8 @@ GDK_AVAILABLE_IN_ALL
const GskColorStop * gsk_linear_gradient_node_peek_color_stops (GskRenderNode *node, const GskColorStop * gsk_linear_gradient_node_peek_color_stops (GskRenderNode *node,
gsize *n_stops); gsize *n_stops);
GDK_AVAILABLE_IN_ALL
GType gsk_repeating_linear_gradient_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_repeating_linear_gradient_node_new (const graphene_rect_t *bounds, GskRenderNode * gsk_repeating_linear_gradient_node_new (const graphene_rect_t *bounds,
const graphene_point_t *start, const graphene_point_t *start,
@ -189,6 +196,8 @@ GskRenderNode * gsk_repeating_linear_gradient_node_new (const graph
const GskColorStop *color_stops, const GskColorStop *color_stops,
gsize n_color_stops); gsize n_color_stops);
GDK_AVAILABLE_IN_ALL
GType gsk_border_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_border_node_new (const GskRoundedRect *outline, GskRenderNode * gsk_border_node_new (const GskRoundedRect *outline,
const float border_width[4], const float border_width[4],
@ -200,6 +209,8 @@ const float * gsk_border_node_peek_widths (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const GdkRGBA * gsk_border_node_peek_colors (GskRenderNode *node); const GdkRGBA * gsk_border_node_peek_colors (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_inset_shadow_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_inset_shadow_node_new (const GskRoundedRect *outline, GskRenderNode * gsk_inset_shadow_node_new (const GskRoundedRect *outline,
const GdkRGBA *color, const GdkRGBA *color,
@ -220,6 +231,8 @@ float gsk_inset_shadow_node_get_spread (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
float gsk_inset_shadow_node_get_blur_radius (GskRenderNode *node); float gsk_inset_shadow_node_get_blur_radius (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_outset_shadow_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_outset_shadow_node_new (const GskRoundedRect *outline, GskRenderNode * gsk_outset_shadow_node_new (const GskRoundedRect *outline,
const GdkRGBA *color, const GdkRGBA *color,
@ -240,6 +253,8 @@ float gsk_outset_shadow_node_get_spread (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
float gsk_outset_shadow_node_get_blur_radius (GskRenderNode *node); float gsk_outset_shadow_node_get_blur_radius (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_cairo_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_cairo_node_new (const graphene_rect_t *bounds); GskRenderNode * gsk_cairo_node_new (const graphene_rect_t *bounds);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
@ -247,6 +262,8 @@ cairo_t * gsk_cairo_node_get_draw_context (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
cairo_surface_t * gsk_cairo_node_peek_surface (GskRenderNode *node); cairo_surface_t * gsk_cairo_node_peek_surface (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_container_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_container_node_new (GskRenderNode **children, GskRenderNode * gsk_container_node_new (GskRenderNode **children,
guint n_children); guint n_children);
@ -256,6 +273,8 @@ GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_container_node_get_child (GskRenderNode *node, GskRenderNode * gsk_container_node_get_child (GskRenderNode *node,
guint idx); guint idx);
GDK_AVAILABLE_IN_ALL
GType gsk_transform_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_transform_node_new (GskRenderNode *child, GskRenderNode * gsk_transform_node_new (GskRenderNode *child,
GskTransform *transform); GskTransform *transform);
@ -264,6 +283,8 @@ GskRenderNode * gsk_transform_node_get_child (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskTransform * gsk_transform_node_get_transform (GskRenderNode *node); GskTransform * gsk_transform_node_get_transform (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_opacity_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_opacity_node_new (GskRenderNode *child, GskRenderNode * gsk_opacity_node_new (GskRenderNode *child,
float opacity); float opacity);
@ -272,6 +293,8 @@ GskRenderNode * gsk_opacity_node_get_child (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
float gsk_opacity_node_get_opacity (GskRenderNode *node); float gsk_opacity_node_get_opacity (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_color_matrix_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_color_matrix_node_new (GskRenderNode *child, GskRenderNode * gsk_color_matrix_node_new (GskRenderNode *child,
const graphene_matrix_t *color_matrix, const graphene_matrix_t *color_matrix,
@ -284,6 +307,8 @@ const graphene_matrix_t *
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const graphene_vec4_t * gsk_color_matrix_node_peek_color_offset (GskRenderNode *node); const graphene_vec4_t * gsk_color_matrix_node_peek_color_offset (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_repeat_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_repeat_node_new (const graphene_rect_t *bounds, GskRenderNode * gsk_repeat_node_new (const graphene_rect_t *bounds,
GskRenderNode *child, GskRenderNode *child,
@ -293,6 +318,8 @@ GskRenderNode * gsk_repeat_node_get_child (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const graphene_rect_t * gsk_repeat_node_peek_child_bounds (GskRenderNode *node); const graphene_rect_t * gsk_repeat_node_peek_child_bounds (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_clip_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_clip_node_new (GskRenderNode *child, GskRenderNode * gsk_clip_node_new (GskRenderNode *child,
const graphene_rect_t *clip); const graphene_rect_t *clip);
@ -301,6 +328,8 @@ GskRenderNode * gsk_clip_node_get_child (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const graphene_rect_t * gsk_clip_node_peek_clip (GskRenderNode *node); const graphene_rect_t * gsk_clip_node_peek_clip (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_rounded_clip_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_rounded_clip_node_new (GskRenderNode *child, GskRenderNode * gsk_rounded_clip_node_new (GskRenderNode *child,
const GskRoundedRect *clip); const GskRoundedRect *clip);
@ -309,6 +338,8 @@ GskRenderNode * gsk_rounded_clip_node_get_child (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const GskRoundedRect * gsk_rounded_clip_node_peek_clip (GskRenderNode *node); const GskRoundedRect * gsk_rounded_clip_node_peek_clip (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_shadow_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_shadow_node_new (GskRenderNode *child, GskRenderNode * gsk_shadow_node_new (GskRenderNode *child,
const GskShadow *shadows, const GskShadow *shadows,
@ -321,6 +352,8 @@ const GskShadow * gsk_shadow_node_peek_shadow (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gsize gsk_shadow_node_get_n_shadows (GskRenderNode *node); gsize gsk_shadow_node_get_n_shadows (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_blend_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_blend_node_new (GskRenderNode *bottom, GskRenderNode * gsk_blend_node_new (GskRenderNode *bottom,
GskRenderNode *top, GskRenderNode *top,
@ -332,6 +365,8 @@ GskRenderNode * gsk_blend_node_get_top_child (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskBlendMode gsk_blend_node_get_blend_mode (GskRenderNode *node); GskBlendMode gsk_blend_node_get_blend_mode (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_cross_fade_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_cross_fade_node_new (GskRenderNode *start, GskRenderNode * gsk_cross_fade_node_new (GskRenderNode *start,
GskRenderNode *end, GskRenderNode *end,
@ -343,6 +378,8 @@ GskRenderNode * gsk_cross_fade_node_get_end_child (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
float gsk_cross_fade_node_get_progress (GskRenderNode *node); float gsk_cross_fade_node_get_progress (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_text_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_text_node_new (PangoFont *font, GskRenderNode * gsk_text_node_new (PangoFont *font,
PangoGlyphString *glyphs, PangoGlyphString *glyphs,
@ -361,6 +398,8 @@ const GdkRGBA * gsk_text_node_peek_color (GskRenderNode
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const graphene_point_t *gsk_text_node_get_offset (GskRenderNode *node); const graphene_point_t *gsk_text_node_get_offset (GskRenderNode *node);
GDK_AVAILABLE_IN_ALL
GType gsk_blur_node_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GskRenderNode * gsk_blur_node_new (GskRenderNode *child, GskRenderNode * gsk_blur_node_new (GskRenderNode *child,
float radius); float radius);

View File

@ -30,8 +30,6 @@
#include "gdk/gdktextureprivate.h" #include "gdk/gdktextureprivate.h"
#include <cairo-ft.h> #include <cairo-ft.h>
GType gsk_render_node_types[GSK_RENDER_NODE_TYPE_N_TYPES];
static inline void static inline void
gsk_cairo_rectangle (cairo_t *cr, gsk_cairo_rectangle (cairo_t *cr,
const graphene_rect_t *rect) const graphene_rect_t *rect)
@ -4088,17 +4086,44 @@ gsk_debug_node_get_message (GskRenderNode *node)
return self->message; return self->message;
} }
GType gsk_render_node_types[GSK_RENDER_NODE_TYPE_N_TYPES];
#ifndef I_ #ifndef I_
# define I_(str) g_intern_static_string ((str)) # define I_(str) g_intern_static_string ((str))
#endif #endif
/*< private > #define GSK_DEFINE_RENDER_NODE_TYPE(type_name, TYPE_ENUM_VALUE) \
* gsk_render_node_init_types: GType \
* type_name ## _get_type (void) { \
* Initialize all the #GskRenderNode types provided by GSK. gsk_render_node_init_types (); \
*/ g_assert (gsk_render_node_types[TYPE_ENUM_VALUE] != G_TYPE_INVALID); \
void return gsk_render_node_types[TYPE_ENUM_VALUE]; \
gsk_render_node_init_types (void) }
GSK_DEFINE_RENDER_NODE_TYPE (gsk_container_node, GSK_CONTAINER_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_cairo_node, GSK_CAIRO_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_color_node, GSK_COLOR_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_linear_gradient_node, GSK_LINEAR_GRADIENT_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_repeating_linear_gradient_node, GSK_REPEATING_LINEAR_GRADIENT_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_border_node, GSK_BORDER_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_texture_node, GSK_TEXTURE_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_inset_shadow_node, GSK_INSET_SHADOW_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_outset_shadow_node, GSK_OUTSET_SHADOW_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_transform_node, GSK_TRANSFORM_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_opacity_node, GSK_OPACITY_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_color_matrix_node, GSK_COLOR_MATRIX_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_repeat_node, GSK_REPEAT_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_clip_node, GSK_CLIP_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_rounded_clip_node, GSK_ROUNDED_CLIP_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_shadow_node, GSK_SHADOW_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_blend_node, GSK_BLEND_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_cross_fade_node, GSK_CROSS_FADE_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_text_node, GSK_TEXT_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_blur_node, GSK_BLUR_NODE)
GSK_DEFINE_RENDER_NODE_TYPE (gsk_debug_node, GSK_DEBUG_NODE)
static void
gsk_render_node_init_types_once (void)
{ {
{ {
const GskRenderNodeTypeInfo node_info = const GskRenderNodeTypeInfo node_info =
@ -4114,7 +4139,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskContainerNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskContainerNode"), &node_info);
gsk_render_node_types[GSK_CONTAINER_NODE] = node_type; gsk_render_node_types[GSK_CONTAINER_NODE] = node_type;
g_assert (GSK_TYPE_CONTAINER_NODE == node_type);
} }
{ {
@ -4131,7 +4155,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskCairoNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskCairoNode"), &node_info);
gsk_render_node_types[GSK_CAIRO_NODE] = node_type; gsk_render_node_types[GSK_CAIRO_NODE] = node_type;
g_assert (GSK_TYPE_CAIRO_NODE == node_type);
} }
{ {
@ -4148,7 +4171,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskColorNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskColorNode"), &node_info);
gsk_render_node_types[GSK_COLOR_NODE] = node_type; gsk_render_node_types[GSK_COLOR_NODE] = node_type;
g_assert (GSK_TYPE_COLOR_NODE == node_type);
} }
{ {
@ -4165,7 +4187,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskLinearGradientNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskLinearGradientNode"), &node_info);
gsk_render_node_types[GSK_LINEAR_GRADIENT_NODE] = node_type; gsk_render_node_types[GSK_LINEAR_GRADIENT_NODE] = node_type;
g_assert (GSK_TYPE_LINEAR_GRADIENT_NODE == node_type);
} }
{ {
@ -4182,7 +4203,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskRepeatingLinearGradientNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskRepeatingLinearGradientNode"), &node_info);
gsk_render_node_types[GSK_REPEATING_LINEAR_GRADIENT_NODE] = node_type; gsk_render_node_types[GSK_REPEATING_LINEAR_GRADIENT_NODE] = node_type;
g_assert (GSK_TYPE_REPEATING_LINEAR_GRADIENT_NODE == node_type);
} }
{ {
@ -4199,7 +4219,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskBorderNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskBorderNode"), &node_info);
gsk_render_node_types[GSK_BORDER_NODE] = node_type; gsk_render_node_types[GSK_BORDER_NODE] = node_type;
g_assert (GSK_TYPE_BORDER_NODE == node_type);
} }
{ {
@ -4216,7 +4235,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskTextureNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskTextureNode"), &node_info);
gsk_render_node_types[GSK_TEXTURE_NODE] = node_type; gsk_render_node_types[GSK_TEXTURE_NODE] = node_type;
g_assert (GSK_TYPE_TEXTURE_NODE == node_type);
} }
{ {
@ -4233,7 +4251,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskInsetShadowNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskInsetShadowNode"), &node_info);
gsk_render_node_types[GSK_INSET_SHADOW_NODE] = node_type; gsk_render_node_types[GSK_INSET_SHADOW_NODE] = node_type;
g_assert (GSK_TYPE_INSET_SHADOW_NODE == node_type);
} }
{ {
@ -4250,7 +4267,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskOutsetShadowNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskOutsetShadowNode"), &node_info);
gsk_render_node_types[GSK_OUTSET_SHADOW_NODE] = node_type; gsk_render_node_types[GSK_OUTSET_SHADOW_NODE] = node_type;
g_assert (GSK_TYPE_OUTSET_SHADOW_NODE == node_type);
} }
{ {
@ -4267,7 +4283,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskTransformNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskTransformNode"), &node_info);
gsk_render_node_types[GSK_TRANSFORM_NODE] = node_type; gsk_render_node_types[GSK_TRANSFORM_NODE] = node_type;
g_assert (GSK_TYPE_TRANSFORM_NODE == node_type);
} }
{ {
@ -4284,7 +4299,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskOpacityNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskOpacityNode"), &node_info);
gsk_render_node_types[GSK_OPACITY_NODE] = node_type; gsk_render_node_types[GSK_OPACITY_NODE] = node_type;
g_assert (GSK_TYPE_OPACITY_NODE == node_type);
} }
{ {
@ -4301,7 +4315,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskColorMatrixNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskColorMatrixNode"), &node_info);
gsk_render_node_types[GSK_COLOR_MATRIX_NODE] = node_type; gsk_render_node_types[GSK_COLOR_MATRIX_NODE] = node_type;
g_assert (GSK_TYPE_COLOR_MATRIX_NODE == node_type);
} }
{ {
@ -4318,7 +4331,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskRepeatNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskRepeatNode"), &node_info);
gsk_render_node_types[GSK_REPEAT_NODE] = node_type; gsk_render_node_types[GSK_REPEAT_NODE] = node_type;
g_assert (GSK_TYPE_REPEAT_NODE == node_type);
} }
{ {
@ -4335,7 +4347,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskClipNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskClipNode"), &node_info);
gsk_render_node_types[GSK_CLIP_NODE] = node_type; gsk_render_node_types[GSK_CLIP_NODE] = node_type;
g_assert (GSK_TYPE_CLIP_NODE == node_type);
} }
{ {
@ -4352,7 +4363,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskRoundedClipNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskRoundedClipNode"), &node_info);
gsk_render_node_types[GSK_ROUNDED_CLIP_NODE] = node_type; gsk_render_node_types[GSK_ROUNDED_CLIP_NODE] = node_type;
g_assert (GSK_TYPE_ROUNDED_CLIP_NODE == node_type);
} }
{ {
@ -4369,7 +4379,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskShadowNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskShadowNode"), &node_info);
gsk_render_node_types[GSK_SHADOW_NODE] = node_type; gsk_render_node_types[GSK_SHADOW_NODE] = node_type;
g_assert (GSK_TYPE_SHADOW_NODE == node_type);
} }
{ {
@ -4386,7 +4395,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskBlendNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskBlendNode"), &node_info);
gsk_render_node_types[GSK_BLEND_NODE] = node_type; gsk_render_node_types[GSK_BLEND_NODE] = node_type;
g_assert (GSK_TYPE_BLEND_NODE == node_type);
} }
{ {
@ -4403,7 +4411,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskCrossFadeNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskCrossFadeNode"), &node_info);
gsk_render_node_types[GSK_CROSS_FADE_NODE] = node_type; gsk_render_node_types[GSK_CROSS_FADE_NODE] = node_type;
g_assert (GSK_TYPE_CROSS_FADE_NODE == node_type);
} }
{ {
@ -4420,7 +4427,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskTextNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskTextNode"), &node_info);
gsk_render_node_types[GSK_TEXT_NODE] = node_type; gsk_render_node_types[GSK_TEXT_NODE] = node_type;
g_assert (GSK_TYPE_TEXT_NODE == node_type);
} }
{ {
@ -4437,7 +4443,6 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskBlurNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskBlurNode"), &node_info);
gsk_render_node_types[GSK_BLUR_NODE] = node_type; gsk_render_node_types[GSK_BLUR_NODE] = node_type;
g_assert (GSK_TYPE_BLUR_NODE == node_type);
} }
{ {
@ -4454,6 +4459,22 @@ gsk_render_node_init_types (void)
GType node_type = gsk_render_node_type_register_static (I_("GskDebugNode"), &node_info); GType node_type = gsk_render_node_type_register_static (I_("GskDebugNode"), &node_info);
gsk_render_node_types[GSK_DEBUG_NODE] = node_type; gsk_render_node_types[GSK_DEBUG_NODE] = node_type;
g_assert (GSK_TYPE_DEBUG_NODE == node_type);
} }
} }
/*< private >
* gsk_render_node_init_types:
*
* Initialize all the #GskRenderNode types provided by GSK.
*/
void
gsk_render_node_init_types (void)
{
static volatile gsize register_types__volatile;
if (g_once_init_enter (&register_types__volatile))
{
gboolean initialized = TRUE;
gsk_render_node_init_types_once ();
g_once_init_leave (&register_types__volatile, initialized);
}
}

View File

@ -15,6 +15,8 @@ typedef struct _GskRenderNodeClass GskRenderNodeClass;
*/ */
#define GSK_RENDER_NODE_TYPE_N_TYPES (GSK_DEBUG_NODE + 1) #define GSK_RENDER_NODE_TYPE_N_TYPES (GSK_DEBUG_NODE + 1)
extern GType gsk_render_node_types[];
#define GSK_IS_RENDER_NODE_TYPE(node,type) \ #define GSK_IS_RENDER_NODE_TYPE(node,type) \
(G_TYPE_INSTANCE_GET_CLASS ((node), GSK_TYPE_RENDER_NODE, GskRenderNodeClass)->node_type == (type)) (G_TYPE_INSTANCE_GET_CLASS ((node), GSK_TYPE_RENDER_NODE, GskRenderNodeClass)->node_type == (type))