Compare commits

...

3 Commits

Author SHA1 Message Date
Matthias Clasen
34990b6dc2 gsk: Give up on text nodes with unuploadable glyphs
If we can't upload the glyphs, just give up and use fallback.
2024-01-11 14:54:34 -05:00
Matthias Clasen
8d74defbc1 gsk: Don't try to upload NULL images
It doesn't work. Just return NULL and let the caller handle it,
like we do in other cases where obtaining an image fails.
2024-01-11 06:26:23 -05:00
Matthias Clasen
fe95da256b gpu: Plug a memory leak 2024-01-11 06:25:22 -05:00
2 changed files with 28 additions and 2 deletions

View File

@@ -661,7 +661,6 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
return cache->image;
}
cache = g_new (GskGpuCachedGlyph, 1);
pango_font_get_glyph_extents (font, glyph, &ink_rect, NULL);
origin.x = floor (ink_rect.x * scale / PANGO_SCALE);
origin.y = floor (ink_rect.y * scale / PANGO_SCALE);
@@ -682,7 +681,10 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
}
else
{
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, rect.size.width, rect.size.height),
image = gsk_gpu_device_create_upload_image (self, FALSE, GDK_MEMORY_DEFAULT, rect.size.width, rect.size.height);
if (!image)
return NULL;
rect.origin.x = 0;
rect.origin.y = 0;
padding = 0;

View File

@@ -3015,6 +3015,27 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
&glyph_bounds,
&glyph_offset);
if (!image)
{
if (GSK_DEBUG_CHECK (FALLBACK))
{
PangoFontDescription *desc;
char *name;
desc = pango_font_describe (font);
name = pango_font_description_to_string (desc);
gdk_debug_message ("failed to cache glyph %u for font %s at scale %g",
glyphs[i].glyph,
name,
scale);
g_free (name);
pango_font_description_free (desc);
}
gsk_gpu_node_processor_add_fallback_node (self, node);
return;
}
graphene_rect_scale (&GRAPHENE_RECT_INIT (-glyph_bounds.origin.x, -glyph_bounds.origin.y, gsk_gpu_image_get_width (image), gsk_gpu_image_get_height (image)), inv_scale, inv_scale, &glyph_tex_rect);
graphene_rect_scale (&GRAPHENE_RECT_INIT(0, 0, glyph_bounds.size.width, glyph_bounds.size.height), inv_scale, inv_scale, &glyph_bounds);
glyph_offset = GRAPHENE_POINT_INIT (offset.x - glyph_offset.x * inv_scale + (float) glyphs[i].geometry.x_offset / PANGO_SCALE,
@@ -3090,6 +3111,9 @@ gsk_gpu_node_processor_create_glyph_pattern (GskGpuPatternWriter *self,
&glyph_bounds,
&glyph_offset);
if (!image)
return FALSE;
if (image != last_image)
{
if (!gsk_gpu_pattern_writer_add_image (self, image, GSK_GPU_SAMPLER_DEFAULT, &tex_id))