From 39f6be3f64a6c5c0a1ec0ee8a1d905160381b71f Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sat, 27 Jan 2024 21:42:24 +0100 Subject: WIP: Thread-safe colour management --- fiv-io.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'fiv-io.c') diff --git a/fiv-io.c b/fiv-io.c index 4fd3d29..f16a245 100644 --- a/fiv-io.c +++ b/fiv-io.c @@ -447,11 +447,12 @@ load_wuffs_frame(struct load_wuffs_frame_context *ctx, GError **error) if (ctx->target) { if (ctx->expand_16_float || ctx->pack_16_10) { - fiv_io_profile_4x16le_direct( + fiv_io_cmm_4x16le_direct(fiv_io_cmm_get_default(), targetbuf, ctx->width, ctx->height, ctx->source, ctx->target); // The first one premultiplies below, the second doesn't need to. } else { - fiv_io_profile_argb32_premultiply(image, ctx->source, ctx->target); + fiv_io_cmm_argb32_premultiply(fiv_io_cmm_get_default(), + image, ctx->source, ctx->target); } } @@ -1263,9 +1264,11 @@ load_jpeg_finalize(FivIoImage *image, bool cmyk, g_bytes_get_data(image->exif, NULL), g_bytes_get_size(image->exif)); if (cmyk) - fiv_io_profile_cmyk(image, source, ctx->screen_profile); + fiv_io_cmm_cmyk(fiv_io_cmm_get_default(), + image, source, ctx->screen_profile); else - fiv_io_profile_any(image, source, ctx->screen_profile); + fiv_io_cmm_any(fiv_io_cmm_get_default(), + image, source, ctx->screen_profile); if (source) fiv_io_profile_free(source); @@ -1666,7 +1669,8 @@ open_libwebp( WebPDemuxDelete(demux); if (ctx->screen_profile) - fiv_io_profile_argb32_premultiply_page(result, ctx->screen_profile); + fiv_io_cmm_argb32_premultiply_page(fiv_io_cmm_get_default(), + result, ctx->screen_profile); fail: WebPFreeDecBuffer(&config.output); @@ -2049,7 +2053,8 @@ open_libraw( out: libraw_close(iprc); - return fiv_io_profile_finalize(result, ctx->screen_profile); + return fiv_io_cmm_finalize(fiv_io_cmm_get_default(), + result, ctx->screen_profile); } #endif // HAVE_LIBRAW --------------------------------------------------------- @@ -2226,7 +2231,8 @@ load_librsvg_render_internal(FivIoRenderClosureLibrsvg *self, double scale, fiv_io_image_unref(image); return NULL; } - return fiv_io_profile_finalize(image, target); + return fiv_io_cmm_finalize(fiv_io_cmm_get_default(), + image, target); } static FivIoImage * @@ -2600,7 +2606,8 @@ open_libheif( g_free(ids); fail_read: heif_context_free(ctx); - return fiv_io_profile_finalize(result, ioctx->screen_profile); + return fiv_io_cmm_finalize(fiv_io_cmm_get_default(), + result, ioctx->screen_profile); } #endif // HAVE_LIBHEIF -------------------------------------------------------- @@ -2831,7 +2838,8 @@ fail: TIFFSetWarningHandlerExt(whe); TIFFSetErrorHandler(eh); TIFFSetWarningHandler(wh); - return fiv_io_profile_finalize(result, ctx->screen_profile); + return fiv_io_cmm_finalize(fiv_io_cmm_get_default(), + result, ctx->screen_profile); } #endif // HAVE_LIBTIFF -------------------------------------------------------- @@ -2926,9 +2934,11 @@ open_gdkpixbuf( g_object_unref(pixbuf); if (custom_argb32) - fiv_io_profile_argb32_premultiply_page(image, ctx->screen_profile); + fiv_io_cmm_argb32_premultiply_page(fiv_io_cmm_get_default(), + image, ctx->screen_profile); else - image = fiv_io_profile_finalize(image, ctx->screen_profile); + image = fiv_io_cmm_finalize(fiv_io_cmm_get_default(), + image, ctx->screen_profile); return image; } -- cgit v1.2.3-70-g09d2