diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-06-04 15:20:03 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-06-04 16:16:52 +0200 |
commit | 338ae69121424368fbbe7dcff9a990aeb8e6fc52 (patch) | |
tree | 5b9ef520e016a2a17981c0bccabfdc58abe05f30 | |
parent | 1c61fcc5bc656d5c5ded34905213752ce0c4d6be (diff) | |
download | fiv-338ae69121424368fbbe7dcff9a990aeb8e6fc52.tar.gz fiv-338ae69121424368fbbe7dcff9a990aeb8e6fc52.tar.xz fiv-338ae69121424368fbbe7dcff9a990aeb8e6fc52.zip |
Add support for the Little CMS fast float plugin
On a sample of JPEGs, it improved loading speed from ~0.26s to ~0.15s.
Unfortunately, it isn't normally installed.
-rw-r--r-- | README.adoc | 5 | ||||
-rw-r--r-- | fiv.c | 10 | ||||
-rw-r--r-- | meson.build | 22 | ||||
-rw-r--r-- | meson_options.txt | 2 |
4 files changed, 36 insertions, 3 deletions
diff --git a/README.adoc b/README.adoc index 66ce631..e1fc5cc 100644 --- a/README.adoc +++ b/README.adoc @@ -42,8 +42,9 @@ Build-only dependencies: Meson, pkg-config, asciidoctor or asciidoc (recommended but optional) + Runtime dependencies: gtk+-3.0, glib>=2.64, pixman-1, shared-mime-info, libturbojpeg, libwebp, librsvg-2.0 (for icons) + -Optional dependencies: lcms2, LibRaw, librsvg-2.0, xcursor, libheif, libtiff, - ExifTool, resvg (unstable API, needs to be requested explicitly) + +Optional dependencies: lcms2, Little CMS fast float plugin, + LibRaw, librsvg-2.0, xcursor, libheif, libtiff, ExifTool, + resvg (unstable API, needs to be requested explicitly) + Runtime dependencies for reverse image search: xdg-utils, cURL, jq @@ -43,6 +43,11 @@ #include "fiv-thumbnail.h" #include "fiv-view.h" +#ifdef HAVE_LCMS2_FAST_FLOAT +#include <lcms2.h> +#include <lcms2_fast_float.h> +#endif // HAVE_LCMS2_FAST_FLOAT + // --- Utilities --------------------------------------------------------------- static void exit_fatal(const char *format, ...) G_GNUC_PRINTF(1, 2); @@ -2382,6 +2387,11 @@ on_app_handle_local_options(G_GNUC_UNUSED GApplication *app, return 0; } + // TODO(p): Use Little CMS with contexts instead. +#ifdef HAVE_LCMS2_FAST_FLOAT + cmsPlugin(cmsFastFloatExtensions()); +#endif // HAVE_LCMS2_FAST_FLOAT + // Normalize all arguments to URIs, and run thumbnailing modes first. for (gsize i = 0; o.args && o.args[i]; i++) { GFile *resolved = g_file_new_for_commandline_arg(o.args[i]); diff --git a/meson.build b/meson.build index 44dd6ba..86d4f41 100644 --- a/meson.build +++ b/meson.build @@ -25,11 +25,12 @@ libjpegqs = dependency('libjpegqs', required : get_option('libjpegqs'), lcms2 = dependency('lcms2', required : get_option('lcms2')) # Note that only libraw_r is thread-safe, but we'll just run it out-of process. libraw = dependency('libraw', required : get_option('libraw')) +# This is a direct runtime dependency, but its usage may be disabled for images. librsvg = dependency('librsvg-2.0', required : get_option('librsvg')) xcursor = dependency('xcursor', required : get_option('xcursor')) libheif = dependency('libheif', required : get_option('libheif')) libtiff = dependency('libtiff-4', required : get_option('libtiff')) -# This is a direct dependency of GTK+, but its usage may be disabled. +# This is a direct dependency of GTK+, but its usage may be disabled for images. gdkpixbuf = dependency('gdk-pixbuf-2.0', required : get_option('gdk-pixbuf')) dependencies = [ dependency('gtk+-3.0'), @@ -53,6 +54,24 @@ dependencies = [ cc.find_library('m', required : false), ] +# As of writing, no pkg-config file is produced, and the plugin is not installed +# by default. The library can be built statically, but it's a bit of a hassle. +have_lcms2_fast_float = false +if not get_option('lcms2fastfloat').disabled() + lcms2ff = dependency('lcms2_fast_float', required : false) + if not lcms2ff.found() + lcms2ff = cc.find_library( + 'lcms2_fast_float', required : get_option('lcms2fastfloat')) + if lcms2ff.found() and not cc.has_header('lcms2_fast_float.h') + error('lcms2_fast_float.h not found') + endif + endif + if lcms2ff.found() + dependencies += lcms2ff + have_lcms2_fast_float = true + endif +endif + # As of writing, the API is unstable, and no pkg-config file is produced. # Trying to wrap Cargo in Meson is a recipe for pain, so no version pinning. have_resvg = false @@ -85,6 +104,7 @@ endif conf.set('HAVE_JPEG_QS', libjpegqs.found()) conf.set('HAVE_LCMS2', lcms2.found()) +conf.set('HAVE_LCMS2_FAST_FLOAT', have_lcms2_fast_float) conf.set('HAVE_LIBRAW', libraw.found()) conf.set('HAVE_RESVG', have_resvg) conf.set('HAVE_LIBRSVG', librsvg.found()) diff --git a/meson_options.txt b/meson_options.txt index dad40f8..2aa0f9c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,6 +3,8 @@ option('tools', type : 'feature', value : 'disabled', option('lcms2', type : 'feature', value : 'auto', description : 'Build with Little CMS colour management') +option('lcms2fastfloat', type : 'feature', value : 'auto', + description : 'Build with Little CMS fast float plugin support') option('libjpegqs', type : 'feature', value : 'auto', description : 'Build with JPEG Quant Smooth integration') option('libraw', type : 'feature', value : 'auto', |