[cairo] [PATCH 50/71] drm/intel: destructor for glyph cache node

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Mon Apr 17 16:57:29 UTC 2017


Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
 src/drm/cairo-drm-intel.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/drm/cairo-drm-intel.c b/src/drm/cairo-drm-intel.c
index 8d9415ef9..c6b253640 100644
--- a/src/drm/cairo-drm-intel.c
+++ b/src/drm/cairo-drm-intel.c
@@ -904,6 +904,24 @@ intel_glyph_cache_add_glyph (intel_device_t *device,
     return CAIRO_INT_STATUS_SUCCESS;
 }
 
+static void
+_cairo_drm_intel_node_destroy (cairo_rtree_node_t *node)
+{
+    intel_glyph_t *priv = cairo_container_of (node, intel_glyph_t, node);
+    cairo_scaled_glyph_t *glyph;
+
+    glyph = priv->glyph;
+    if (glyph == NULL)
+	return;
+
+    if (glyph->dev_private_key == priv->cache) {
+	glyph->dev_private = NULL;
+	glyph->dev_private_key = NULL;
+    }
+    cairo_list_del (&priv->base.link);
+    priv->glyph = NULL;
+}
+
 void
 intel_scaled_glyph_fini (cairo_scaled_glyph_private_t *scaled_glyph_private,
 			 cairo_scaled_glyph_t         *scaled_glyph,
@@ -913,6 +931,8 @@ intel_scaled_glyph_fini (cairo_scaled_glyph_private_t *scaled_glyph_private,
 					     intel_glyph_t,
 					     base);
 
+    _cairo_drm_intel_node_destroy (&priv->node);
+
     /* XXX thread-safety? Probably ok due to the frozen scaled-font. */
     if (! priv->node.pinned)
 	_cairo_rtree_node_remove (&priv->cache->rtree, &priv->node);
@@ -962,7 +982,8 @@ intel_get_glyph_cache (intel_device_t *device,
 			   GLYPH_CACHE_WIDTH,
 			   GLYPH_CACHE_HEIGHT,
 			   GLYPH_CACHE_MIN_SIZE,
-			   sizeof (intel_glyph_t));
+			   sizeof (intel_glyph_t),
+			   _cairo_drm_intel_node_destroy);
     }
 
     *out = cache;
-- 
2.11.0.rc0.7.gbe5a750



More information about the cairo mailing list