[babl] babl: add babl_model_is, utility function for checking model equivalence



commit 2c8961d7af3d246bbc4a379d447c400def01e0da
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Jul 11 23:35:59 2018 +0200

    babl: add babl_model_is, utility function for checking model equivalence
    
    This creates an on the fly model with the same space as the one compared with
    and does pointer equivalence. Using it makes for less verbose code.

 babl/babl.c    | 8 ++++++++
 babl/babl.h    | 3 +++
 export-symbols | 1 +
 3 files changed, 12 insertions(+)
---
diff --git a/babl/babl.c b/babl/babl.c
index c734fb3..3d7573e 100644
--- a/babl/babl.c
+++ b/babl/babl.c
@@ -180,3 +180,11 @@ babl_exit (void)
 #endif
     }
 }
+
+#undef babl_model_is
+
+int babl_model_is (const Babl *babl, const char *model)
+{
+  return ((babl)==babl_model_with_space(model, babl));
+}
+
diff --git a/babl/babl.h b/babl/babl.h
index 660138f..f0dc852 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -501,6 +501,9 @@ const Babl * babl_trc (const char *name);
  * query thechromaticities of white point and primaries as well as trcs
  * used for r g a nd b, all arguments mights be NULL.
  */
+int babl_model_is (const Babl *babl, const char *model);
+
+#define babl_model_is(babl,model)  ((babl)==babl_model_with_space(model,babl))
 
 void babl_space_get (const Babl *space,
                      double *xw, double *yw,
diff --git a/export-symbols b/export-symbols
index f9d0a1c..130f616 100644
--- a/export-symbols
+++ b/export-symbols
@@ -31,6 +31,7 @@ babl_init
 babl_introspect
 babl_malloc
 babl_model
+babl_model_is
 babl_model_with_space
 babl_model_new
 babl_new_palette


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]