2023-03-31 19:11:10 +00:00
|
|
|
#pragma once
|
2016-03-17 13:48:19 +00:00
|
|
|
|
|
|
|
#include "gskrendernode.h"
|
|
|
|
#include <cairo.h>
|
|
|
|
|
2023-06-15 18:27:13 +00:00
|
|
|
#include "gdk/gdkmemoryformatprivate.h"
|
2024-07-31 22:37:02 +00:00
|
|
|
#include "gdk/gdkcolorprivate.h"
|
2023-06-15 18:27:13 +00:00
|
|
|
|
2016-03-17 13:48:19 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2016-12-11 02:57:42 +00:00
|
|
|
typedef struct _GskRenderNodeClass GskRenderNodeClass;
|
|
|
|
|
2020-04-07 22:33:54 +00:00
|
|
|
/* Keep this in sync with the GskRenderNodeType enumeration.
|
|
|
|
*
|
|
|
|
* We don't add an "n-types" value to avoid having to handle
|
|
|
|
* it in every single switch.
|
|
|
|
*/
|
2023-10-29 15:48:16 +00:00
|
|
|
#define GSK_RENDER_NODE_TYPE_N_TYPES (GSK_SUBSURFACE_NODE + 1)
|
2020-04-07 22:33:54 +00:00
|
|
|
|
2020-04-08 14:34:11 +00:00
|
|
|
extern GType gsk_render_node_types[];
|
|
|
|
|
2020-04-07 22:33:54 +00:00
|
|
|
#define GSK_IS_RENDER_NODE_TYPE(node,type) \
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS ((node), GSK_TYPE_RENDER_NODE, GskRenderNodeClass)->node_type == (type))
|
2016-12-11 02:57:42 +00:00
|
|
|
|
2023-09-27 01:36:22 +00:00
|
|
|
#define GSK_RENDER_NODE_TYPE(node) \
|
|
|
|
(G_TYPE_INSTANCE_GET_CLASS ((node), GSK_TYPE_RENDER_NODE, GskRenderNodeClass)->node_type)
|
|
|
|
|
2016-03-17 13:48:19 +00:00
|
|
|
struct _GskRenderNode
|
|
|
|
{
|
2020-04-07 22:33:54 +00:00
|
|
|
GTypeInstance parent_instance;
|
2016-12-10 20:42:01 +00:00
|
|
|
|
2020-04-07 22:33:54 +00:00
|
|
|
gatomicrefcount ref_count;
|
2016-03-17 13:48:19 +00:00
|
|
|
|
2016-12-21 10:21:38 +00:00
|
|
|
graphene_rect_t bounds;
|
2021-10-01 20:23:12 +00:00
|
|
|
|
2024-07-03 16:36:49 +00:00
|
|
|
guint preferred_depth : GDK_MEMORY_DEPTH_BITS;
|
2022-04-05 18:55:36 +00:00
|
|
|
guint offscreen_for_opacity : 1;
|
2024-07-07 16:24:53 +00:00
|
|
|
guint fully_opaque : 1;
|
2024-08-06 16:45:16 +00:00
|
|
|
guint is_hdr : 1;
|
2016-03-17 13:48:19 +00:00
|
|
|
};
|
|
|
|
|
2024-02-11 20:53:37 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
cairo_region_t *region;
|
|
|
|
GdkSurface *surface;
|
|
|
|
} GskDiffData;
|
|
|
|
|
2016-12-11 02:57:42 +00:00
|
|
|
struct _GskRenderNodeClass
|
|
|
|
{
|
2020-04-07 22:33:54 +00:00
|
|
|
GTypeClass parent_class;
|
|
|
|
|
2016-12-11 02:57:42 +00:00
|
|
|
GskRenderNodeType node_type;
|
2017-01-17 23:05:25 +00:00
|
|
|
|
2023-04-03 12:52:00 +00:00
|
|
|
void (* finalize) (GskRenderNode *node);
|
|
|
|
void (* draw) (GskRenderNode *node,
|
2024-07-02 05:02:09 +00:00
|
|
|
cairo_t *cr,
|
|
|
|
GdkColorState *ccs);
|
2023-04-03 12:52:00 +00:00
|
|
|
gboolean (* can_diff) (const GskRenderNode *node1,
|
|
|
|
const GskRenderNode *node2);
|
|
|
|
void (* diff) (GskRenderNode *node1,
|
|
|
|
GskRenderNode *node2,
|
|
|
|
GskDiffData *data);
|
|
|
|
gboolean (* get_opaque_rect) (GskRenderNode *node,
|
|
|
|
graphene_rect_t *out_opaque);
|
2017-10-20 06:06:20 +00:00
|
|
|
};
|
2016-08-24 13:07:26 +00:00
|
|
|
|
2020-04-07 22:33:54 +00:00
|
|
|
void gsk_render_node_init_types (void);
|
|
|
|
|
|
|
|
GType gsk_render_node_type_register_static (const char *node_name,
|
2023-04-03 14:39:52 +00:00
|
|
|
gsize instance_size,
|
|
|
|
GClassInitFunc class_init);
|
2016-12-17 06:44:10 +00:00
|
|
|
|
2020-04-07 22:33:54 +00:00
|
|
|
gpointer gsk_render_node_alloc (GskRenderNodeType node_type);
|
2018-03-20 00:37:05 +00:00
|
|
|
|
2023-09-27 01:28:11 +00:00
|
|
|
void _gsk_render_node_unref (GskRenderNode *node);
|
|
|
|
|
2020-04-07 22:33:54 +00:00
|
|
|
gboolean gsk_render_node_can_diff (const GskRenderNode *node1,
|
|
|
|
const GskRenderNode *node2) G_GNUC_PURE;
|
|
|
|
void gsk_render_node_diff (GskRenderNode *node1,
|
|
|
|
GskRenderNode *node2,
|
2024-02-11 20:53:37 +00:00
|
|
|
GskDiffData *data);
|
2020-04-07 22:33:54 +00:00
|
|
|
void gsk_render_node_diff_impossible (GskRenderNode *node1,
|
|
|
|
GskRenderNode *node2,
|
2024-02-11 20:53:37 +00:00
|
|
|
GskDiffData *data);
|
2021-03-28 14:18:23 +00:00
|
|
|
void gsk_container_node_diff_with (GskRenderNode *container,
|
|
|
|
GskRenderNode *other,
|
2024-02-11 20:53:37 +00:00
|
|
|
GskDiffData *data);
|
2024-07-02 05:02:09 +00:00
|
|
|
void gsk_render_node_draw_ccs (GskRenderNode *node,
|
|
|
|
cairo_t *cr,
|
|
|
|
GdkColorState *ccs);
|
|
|
|
void gsk_render_node_draw_with_color_state (GskRenderNode *node,
|
|
|
|
cairo_t *cr,
|
|
|
|
GdkColorState *color_state);
|
2023-12-26 03:53:09 +00:00
|
|
|
void gsk_render_node_draw_fallback (GskRenderNode *node,
|
|
|
|
cairo_t *cr);
|
2018-04-21 09:20:15 +00:00
|
|
|
|
2023-12-27 02:55:59 +00:00
|
|
|
bool gsk_border_node_get_uniform (const GskRenderNode *self) G_GNUC_PURE;
|
|
|
|
bool gsk_border_node_get_uniform_color (const GskRenderNode *self) G_GNUC_PURE;
|
2020-07-24 13:59:45 +00:00
|
|
|
|
2020-12-21 18:11:08 +00:00
|
|
|
void gsk_text_node_serialize_glyphs (GskRenderNode *self,
|
|
|
|
GString *str);
|
|
|
|
|
2024-09-08 15:07:28 +00:00
|
|
|
cairo_hint_style_t
|
|
|
|
gsk_text_node_get_font_hint_style (const GskRenderNode *self) G_GNUC_PURE;
|
|
|
|
|
2023-06-15 18:27:13 +00:00
|
|
|
GskRenderNode ** gsk_container_node_get_children (const GskRenderNode *node,
|
|
|
|
guint *n_children);
|
2021-07-24 13:49:09 +00:00
|
|
|
|
2023-06-15 18:27:13 +00:00
|
|
|
void gsk_transform_node_get_translate (const GskRenderNode *node,
|
|
|
|
float *dx,
|
|
|
|
float *dy);
|
2023-12-27 02:55:59 +00:00
|
|
|
GdkMemoryDepth gsk_render_node_get_preferred_depth (const GskRenderNode *node) G_GNUC_PURE;
|
2024-08-06 16:45:16 +00:00
|
|
|
gboolean gsk_render_node_is_hdr (const GskRenderNode *node) G_GNUC_PURE;
|
2021-07-24 14:48:20 +00:00
|
|
|
|
2023-12-27 02:55:59 +00:00
|
|
|
gboolean gsk_container_node_is_disjoint (const GskRenderNode *node) G_GNUC_PURE;
|
2022-04-03 23:28:53 +00:00
|
|
|
|
2023-12-27 02:55:59 +00:00
|
|
|
gboolean gsk_render_node_use_offscreen_for_opacity (const GskRenderNode *node) G_GNUC_PURE;
|
2022-04-05 18:55:36 +00:00
|
|
|
|
2023-09-27 01:28:11 +00:00
|
|
|
#define gsk_render_node_ref(node) _gsk_render_node_ref(node)
|
|
|
|
#define gsk_render_node_unref(node) _gsk_render_node_unref(node)
|
|
|
|
|
|
|
|
static inline GskRenderNode *
|
|
|
|
_gsk_render_node_ref (GskRenderNode *node)
|
|
|
|
{
|
|
|
|
g_atomic_ref_count_inc (&node->ref_count);
|
|
|
|
return node;
|
|
|
|
}
|
2021-07-24 13:49:09 +00:00
|
|
|
|
2024-08-09 23:04:54 +00:00
|
|
|
GskRenderNode * gsk_color_node_new2 (const GdkColor *color,
|
|
|
|
const graphene_rect_t *bounds);
|
|
|
|
|
|
|
|
const GdkColor * gsk_color_node_get_color2 (const GskRenderNode *node);
|
|
|
|
|
|
|
|
GskRenderNode * gsk_border_node_new2 (const GskRoundedRect *outline,
|
|
|
|
const float border_width[4],
|
|
|
|
const GdkColor border_color[4]);
|
|
|
|
const GdkColor * gsk_border_node_get_colors2 (const GskRenderNode *node);
|
|
|
|
|
|
|
|
GskRenderNode * gsk_inset_shadow_node_new2 (const GskRoundedRect *outline,
|
|
|
|
const GdkColor *color,
|
|
|
|
const graphene_point_t *offset,
|
|
|
|
float spread,
|
|
|
|
float blur_radius);
|
|
|
|
const GdkColor * gsk_inset_shadow_node_get_color2 (const GskRenderNode *node);
|
|
|
|
const graphene_point_t *gsk_inset_shadow_node_get_offset (const GskRenderNode *node);
|
|
|
|
|
|
|
|
GskRenderNode * gsk_outset_shadow_node_new2 (const GskRoundedRect *outline,
|
|
|
|
const GdkColor *color,
|
|
|
|
const graphene_point_t *offset,
|
|
|
|
float spread,
|
|
|
|
float blur_radius);
|
|
|
|
const GdkColor * gsk_outset_shadow_node_get_color2 (const GskRenderNode *node);
|
|
|
|
const graphene_point_t *gsk_outset_shadow_node_get_offset (const GskRenderNode *node);
|
2024-08-02 11:40:27 +00:00
|
|
|
|
2024-08-02 14:53:06 +00:00
|
|
|
typedef struct _GskShadow2 GskShadow2;
|
|
|
|
struct _GskShadow2
|
|
|
|
{
|
|
|
|
GdkColor color;
|
|
|
|
graphene_point_t offset;
|
|
|
|
float radius;
|
|
|
|
};
|
|
|
|
|
|
|
|
GskRenderNode * gsk_shadow_node_new2 (GskRenderNode *child,
|
|
|
|
const GskShadow2 *shadows,
|
|
|
|
gsize n_shadows);
|
|
|
|
|
|
|
|
const GskShadow2 *gsk_shadow_node_get_shadow2 (const GskRenderNode *node,
|
|
|
|
gsize i);
|
2024-08-02 11:40:27 +00:00
|
|
|
|
2024-08-02 04:41:29 +00:00
|
|
|
GskRenderNode * gsk_text_node_new2 (PangoFont *font,
|
|
|
|
PangoGlyphString *glyphs,
|
|
|
|
const GdkColor *color,
|
|
|
|
const graphene_point_t *offset);
|
|
|
|
const GdkColor *gsk_text_node_get_color2 (const GskRenderNode *node);
|
2024-08-02 11:40:27 +00:00
|
|
|
|
2024-09-08 13:47:47 +00:00
|
|
|
#define GSK_RENDER_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSK_TYPE_RENDER_NODE, GskRenderNodeClass))
|
|
|
|
|
|
|
|
#define gsk_render_node_get_node_type(node) _gsk_render_node_get_node_type (node)
|
|
|
|
|
|
|
|
G_GNUC_PURE static inline
|
|
|
|
GskRenderNodeType
|
|
|
|
_gsk_render_node_get_node_type (const GskRenderNode *node)
|
|
|
|
{
|
|
|
|
return GSK_RENDER_NODE_GET_CLASS (node)->node_type;
|
|
|
|
}
|
|
|
|
|
2016-03-17 13:48:19 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|