aboutsummaryrefslogtreecommitdiff
path: root/fiv-thumbnail.c
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-01-24 04:03:19 +0100
committerPřemysl Eric Janouch <p@janouch.name>2022-01-24 05:48:13 +0100
commit788485d81eefcd43f0a66cf4cc664f8bde4423f5 (patch)
tree8c005e62f5ba11c8834e62334d40301515b137b4 /fiv-thumbnail.c
parent991e74b99bbf344effe456f71c544a284f7afe14 (diff)
downloadfiv-788485d81eefcd43f0a66cf4cc664f8bde4423f5.tar.gz
fiv-788485d81eefcd43f0a66cf4cc664f8bde4423f5.tar.xz
fiv-788485d81eefcd43f0a66cf4cc664f8bde4423f5.zip
Redirect warnings to the info bar
And speed up thumbnailing of animated images while at it. Also, fix thumbnailing SVGs with external links.
Diffstat (limited to 'fiv-thumbnail.c')
-rw-r--r--fiv-thumbnail.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/fiv-thumbnail.c b/fiv-thumbnail.c
index c6a616b..ef84079 100644
--- a/fiv-thumbnail.c
+++ b/fiv-thumbnail.c
@@ -252,15 +252,24 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error)
return FALSE;
}
- // TODO(p): Add a flag to avoid loading all pages and frames.
- FivIoProfile sRGB = fiv_io_profile_new_sRGB();
+ FivIoOpenContext ctx = {
+ .uri = g_file_get_uri(target),
+ .screen_profile = fiv_io_profile_new_sRGB(),
+ .screen_dpi = 96,
+ .first_frame_only = TRUE,
+ // Only using this array as a redirect.
+ .warnings = g_ptr_array_new_with_free_func(g_free),
+ };
+
gsize filesize = g_mapped_file_get_length(mf);
cairo_surface_t *surface = fiv_io_open_from_data(
- g_mapped_file_get_contents(mf), filesize, path, sRGB, FALSE, error);
-
+ g_mapped_file_get_contents(mf), filesize, &ctx, error);
g_mapped_file_unref(mf);
- if (sRGB)
- fiv_io_profile_free(sRGB);
+
+ g_free((gchar *) ctx.uri);
+ g_ptr_array_free(ctx.warnings, TRUE);
+ if (ctx.screen_profile)
+ fiv_io_profile_free(ctx.screen_profile);
if (!surface)
return FALSE;
@@ -285,7 +294,7 @@ fiv_thumbnail_produce(GFile *target, FivThumbnailSize max_size, GError **error)
}
// Without a CMM, no conversion is attempted.
- if (sRGB) {
+ if (ctx.screen_profile) {
g_string_append_printf(
thum, "%s%c%s%c", THUMB_COLORSPACE, 0, THUMB_COLORSPACE_SRGB, 0);
}
@@ -347,7 +356,8 @@ read_wide_thumbnail(
if (!thumbnail_uri)
return NULL;
- cairo_surface_t *surface = fiv_io_open(thumbnail_uri, NULL, FALSE, error);
+ cairo_surface_t *surface =
+ fiv_io_open(&(FivIoOpenContext){.uri = thumbnail_uri}, error);
g_free(thumbnail_uri);
if (!surface)
return NULL;