forked from AuroraMiddleware/gtk
inspector: Fix node recording
When attaching renderer-specific data, we need to make sure that we key it off the renderer that is in use, and cope with the absence of render data. This fixes recording nodes in the inspector.
This commit is contained in:
parent
239c178ef4
commit
ba7649b388
@ -537,18 +537,19 @@ render_fallback_node (GskGLRenderer *self,
|
||||
|
||||
typedef struct {
|
||||
int timestamp;
|
||||
int stored;
|
||||
GskGLCachedGlyph *glyphs[];
|
||||
} TextRenderData;
|
||||
|
||||
static inline TextRenderData *
|
||||
ensure_render_data (GskRenderNode *node,
|
||||
GskGLGlyphCache *cache)
|
||||
get_render_data (GskRenderNode *node,
|
||||
GskGLGlyphCache *cache)
|
||||
{
|
||||
TextRenderData *data;
|
||||
int num_glyphs;
|
||||
|
||||
num_glyphs = gsk_text_node_get_num_glyphs (node);
|
||||
data = gsk_text_node_get_render_data (node);
|
||||
data = gsk_text_node_get_render_data (node, cache);
|
||||
if (data)
|
||||
{
|
||||
if (data->timestamp < cache->atlas_timestamp)
|
||||
@ -561,13 +562,24 @@ ensure_render_data (GskRenderNode *node,
|
||||
{
|
||||
data = g_new0 (TextRenderData, sizeof (TextRenderData) + sizeof (gpointer) * num_glyphs);
|
||||
data->timestamp = cache->atlas_timestamp;
|
||||
|
||||
gsk_text_node_set_render_data (node, data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_render_data (GskRenderNode *node,
|
||||
GskGLGlyphCache *cache,
|
||||
TextRenderData *data)
|
||||
{
|
||||
if (!data->stored)
|
||||
{
|
||||
data->stored = 1;
|
||||
if (!gsk_text_node_set_render_data (node, cache, data))
|
||||
g_free (data);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
render_text_node (GskGLRenderer *self,
|
||||
GskRenderNode *node,
|
||||
@ -598,7 +610,7 @@ render_text_node (GskGLRenderer *self,
|
||||
ops_set_color (builder, color);
|
||||
}
|
||||
|
||||
render_data = ensure_render_data (node, self->glyph_cache);
|
||||
render_data = get_render_data (node, self->glyph_cache);
|
||||
|
||||
memset (&lookup, 0, sizeof (CacheKeyData));
|
||||
lookup.data.font = (PangoFont *)font;
|
||||
@ -663,6 +675,8 @@ render_text_node (GskGLRenderer *self,
|
||||
next:
|
||||
x_position += gi->geometry.width;
|
||||
}
|
||||
|
||||
set_render_data (node, self->glyph_cache, render_data);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -3414,7 +3414,9 @@ struct _GskTextNode
|
||||
GdkRGBA color;
|
||||
graphene_point_t offset;
|
||||
|
||||
gpointer render_key;
|
||||
gpointer render_data;
|
||||
|
||||
guint num_glyphs;
|
||||
PangoGlyphInfo glyphs[];
|
||||
};
|
||||
@ -3547,6 +3549,7 @@ gsk_text_node_new (PangoFont *font,
|
||||
self->has_color_glyphs = font_has_color_glyphs (font);
|
||||
self->color = *color;
|
||||
self->offset = *offset;
|
||||
self->render_key = NULL;
|
||||
self->render_data = NULL;
|
||||
self->num_glyphs = glyphs->num_glyphs;
|
||||
memcpy (self->glyphs, glyphs->glyphs, sizeof (PangoGlyphInfo) * glyphs->num_glyphs);
|
||||
@ -3628,20 +3631,31 @@ gsk_text_node_get_offset (GskRenderNode *node)
|
||||
return &self->offset;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
gsk_text_node_set_render_data (GskRenderNode *node,
|
||||
gpointer key,
|
||||
gpointer data)
|
||||
{
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
|
||||
if (self->render_key != NULL)
|
||||
return FALSE;
|
||||
|
||||
self->render_key = key;
|
||||
self->render_data = data;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gpointer
|
||||
gsk_text_node_get_render_data (GskRenderNode *node)
|
||||
gsk_text_node_get_render_data (GskRenderNode *node,
|
||||
gpointer key)
|
||||
{
|
||||
GskTextNode *self = (GskTextNode *) node;
|
||||
|
||||
if (self->render_key != key)
|
||||
return NULL;
|
||||
|
||||
return self->render_data;
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,11 @@ void gsk_render_node_diff (GskRenderNode *nod
|
||||
void gsk_render_node_diff_impossible (GskRenderNode *node1,
|
||||
GskRenderNode *node2,
|
||||
cairo_region_t *region);
|
||||
void gsk_text_node_set_render_data (GskRenderNode *node,
|
||||
gboolean gsk_text_node_set_render_data (GskRenderNode *node,
|
||||
gpointer key,
|
||||
gpointer data);
|
||||
gpointer gsk_text_node_get_render_data (GskRenderNode *node);
|
||||
gpointer gsk_text_node_get_render_data (GskRenderNode *node,
|
||||
gpointer key);
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user