static gboolean
glyph_cache_equal (gconstpointer v1, gconstpointer v2)
{
- const GlyphCacheKey *key1 = v1;
- const GlyphCacheKey *key2 = v2;
-
- return key1->font == key2->font &&
- key1->glyph == key2->glyph &&
- key1->xshift == key2->xshift &&
- key1->yshift == key2->yshift &&
- key1->scale == key2->scale;
+ return memcmp (v1, v2, sizeof (CacheKeyData)) == 0;
}
static guint
{
GlyphCacheKey *f = v;
- g_object_unref (f->font);
+ g_object_unref (f->data.font);
g_free (f);
}
int stride;
unsigned char *data;
- scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *)key->font);
+ scaled_font = pango_cairo_font_get_scaled_font ((PangoCairoFont *)key->data.font);
if (G_UNLIKELY (!scaled_font || cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS))
{
g_warning ("Failed to get a font");
return FALSE;
}
- surface_width = value->draw_width * key->scale / 1024;
- surface_height = value->draw_height * key->scale / 1024;
+ surface_width = value->draw_width * key->data.scale / 1024;
+ surface_height = value->draw_height * key->data.scale / 1024;
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, surface_width);
data = g_malloc0 (stride * surface_height);
surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32,
surface_width, surface_height,
stride);
- cairo_surface_set_device_scale (surface, key->scale / 1024.0, key->scale / 1024.0);
+ cairo_surface_set_device_scale (surface, key->data.scale / 1024.0, key->data.scale / 1024.0);
cr = cairo_create (surface);
cairo_set_scaled_font (cr, scaled_font);
cairo_set_source_rgba (cr, 1, 1, 1, 1);
- glyph_info.glyph = key->glyph;
+ glyph_info.glyph = key->data.glyph;
glyph_info.geometry.width = value->draw_width * 1024;
if (glyph_info.glyph & PANGO_GLYPH_UNKNOWN_FLAG)
glyph_info.geometry.x_offset = 0;
glyph_string.num_glyphs = 1;
glyph_string.glyphs = &glyph_info;
- pango_cairo_show_glyph_string (cr, key->font, &glyph_string);
+ pango_cairo_show_glyph_string (cr, key->data.font, &glyph_string);
cairo_destroy (cr);
cairo_surface_flush (surface);
gdk_gl_context_push_debug_group_printf (gdk_gl_context_get_current (),
"Uploading glyph %d",
- key->glyph);
+ key->data.glyph);
if (render_glyph (key, value, &r))
{
GskGLDriver *driver,
GskGLCachedGlyph *value)
{
- const int width = value->draw_width * key->scale / 1024;
- const int height = value->draw_height * key->scale / 1024;
+ const int width = value->draw_width * key->data.scale / 1024;
+ const int height = value->draw_height * key->data.scale / 1024;
if (width < MAX_GLYPH_SIZE && height < MAX_GLYPH_SIZE)
{
GlyphCacheKey *key;
PangoRectangle ink_rect;
- pango_font_get_glyph_extents (lookup->font, lookup->glyph, &ink_rect, NULL);
+ pango_font_get_glyph_extents (lookup->data.font, lookup->data.glyph, &ink_rect, NULL);
pango_extents_to_pixels (&ink_rect, NULL);
- if (lookup->xshift != 0)
+ if (lookup->data.xshift != 0)
ink_rect.width += 1;
- if (lookup->yshift != 0)
+ if (lookup->data.yshift != 0)
ink_rect.height += 1;
value = g_new0 (GskGLCachedGlyph, 1);
key = g_new0 (GlyphCacheKey, 1);
- key->font = g_object_ref (lookup->font);
- key->glyph = lookup->glyph;
- key->xshift = lookup->xshift;
- key->yshift = lookup->yshift;
- key->scale = lookup->scale;
+ key->data.font = g_object_ref (lookup->data.font);
+ key->data.glyph = lookup->data.glyph;
+ key->data.xshift = lookup->data.xshift;
+ key->data.yshift = lookup->data.yshift;
+ key->data.scale = lookup->data.scale;
key->hash = lookup->hash;
- if (key->scale > 0 &&
- value->draw_width * key->scale / 1024 > 0 &&
- value->draw_height * key->scale / 1024 > 0)
+ if (key->data.scale > 0 &&
+ value->draw_width * key->data.scale / 1024 > 0 &&
+ value->draw_height * key->data.scale / 1024 > 0)
add_to_cache (cache, key, driver, value);
*cached_glyph_out = value;