mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-02 03:48:00 +02:00
scaled-font: Always hold the mutex even for single glyph probes
The freeze/thaw routines have a side-effect of managing the global glyph cache in addition to taking the mutex on the font. If we don't call them, we may end up indefinitely keeping the global glyph cache frozen (effectively leaking glyphs to the maximum of all open fonts) and triggering asserts. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
80cc532271
commit
44a093eb95
1 changed files with 21 additions and 20 deletions
|
|
@ -2131,36 +2131,37 @@ _cairo_scaled_font_single_glyph_device_extents (cairo_scaled_font_t *scaled_fon
|
|||
const cairo_glyph_t *glyph,
|
||||
cairo_rectangle_int_t *extents)
|
||||
{
|
||||
cairo_round_glyph_positions_t round_xy;
|
||||
cairo_scaled_glyph_t *scaled_glyph;
|
||||
cairo_status_t status;
|
||||
cairo_box_t box;
|
||||
cairo_fixed_t v;
|
||||
|
||||
_cairo_scaled_font_freeze_cache (scaled_font);
|
||||
status = _cairo_scaled_glyph_lookup (scaled_font,
|
||||
glyph->index,
|
||||
CAIRO_SCALED_GLYPH_INFO_METRICS,
|
||||
&scaled_glyph);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
cairo_bool_t round_xy = _cairo_font_options_get_round_glyph_positions (&scaled_font->options) == CAIRO_ROUND_GLYPH_POS_ON;
|
||||
cairo_box_t box;
|
||||
cairo_fixed_t v;
|
||||
|
||||
round_xy = _cairo_font_options_get_round_glyph_positions (&scaled_font->options);
|
||||
if (round_xy == CAIRO_ROUND_GLYPH_POS_ON)
|
||||
v = _cairo_fixed_from_int (_cairo_lround (glyph->x));
|
||||
else
|
||||
v = _cairo_fixed_from_double (glyph->x);
|
||||
box.p1.x = v + scaled_glyph->bbox.p1.x;
|
||||
box.p2.x = v + scaled_glyph->bbox.p2.x;
|
||||
if (round_xy)
|
||||
v = _cairo_fixed_from_int (_cairo_lround (glyph->x));
|
||||
else
|
||||
v = _cairo_fixed_from_double (glyph->x);
|
||||
box.p1.x = v + scaled_glyph->bbox.p1.x;
|
||||
box.p2.x = v + scaled_glyph->bbox.p2.x;
|
||||
|
||||
if (round_xy == CAIRO_ROUND_GLYPH_POS_ON)
|
||||
v = _cairo_fixed_from_int (_cairo_lround (glyph->y));
|
||||
else
|
||||
v = _cairo_fixed_from_double (glyph->y);
|
||||
box.p1.y = v + scaled_glyph->bbox.p1.y;
|
||||
box.p2.y = v + scaled_glyph->bbox.p2.y;
|
||||
if (round_xy)
|
||||
v = _cairo_fixed_from_int (_cairo_lround (glyph->y));
|
||||
else
|
||||
v = _cairo_fixed_from_double (glyph->y);
|
||||
box.p1.y = v + scaled_glyph->bbox.p1.y;
|
||||
box.p2.y = v + scaled_glyph->bbox.p2.y;
|
||||
|
||||
_cairo_box_round_to_rectangle (&box, extents);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
_cairo_box_round_to_rectangle (&box, extents);
|
||||
}
|
||||
_cairo_scaled_font_thaw_cache (scaled_font);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue