[babl] add the possibility to distinct format_n type from the others



commit 3ff76afb00023670fbf4a93c847f91a609d6c0b5
Author: Michael Murà <batolettre gmail com>
Date:   Fri Aug 19 22:32:07 2011 +0200

    add the possibility to distinct format_n type from the others

 babl/babl-format.c |   24 ++++++++++++++++++++++++
 babl/babl-format.h |    1 +
 babl/babl.h        |    5 +++++
 3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/babl/babl-format.c b/babl/babl-format.c
index af7af69..463a92b 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -112,6 +112,7 @@ format_new (const char     *name,
   babl->format.loss = -1.0;
   babl->format.visited = 0;
   babl->format.image_template = NULL;
+  babl->format.format_n = 0;
 
   return babl;
 }
@@ -195,6 +196,15 @@ ncomponents_create_name (Babl *type,
   return babl_strdup (buf);
 }
 
+static void
+babl_format_set_is_format_n (Babl *format)
+{
+  if (format->class_type == BABL_FORMAT)
+    {
+      format->format.format_n = 1;
+    }
+}
+
 Babl *
 babl_format_n (Babl *btype,
                int   components)
@@ -232,11 +242,25 @@ babl_format_n (Babl *btype,
                      planar, components, model,
                      component, sampling, type);
 
+  babl_format_set_is_format_n (babl);
+
   babl_db_insert (db, babl);
   babl_free (name);
   return babl;
 }
 
+int
+babl_format_is_format_n (Babl *format)
+{
+  if (format->class_type == BABL_FORMAT)
+    {
+      return format->format.format_n;
+    }
+
+  return 0;
+}
+
+
 static int
 is_format_duplicate (Babl           *babl,
                      int             planar,
diff --git a/babl/babl-format.h b/babl/babl-format.h
index fb8dfac..68fc87d 100644
--- a/babl/babl-format.h
+++ b/babl/babl-format.h
@@ -39,6 +39,7 @@ typedef struct
                              from and to RGBA double */
   int              visited; /* for convenience in code while searching
                                for conversion paths */
+  int              format_n; /* whether the format is a format_n type or not */
 } BablFormat;
 
 #endif
diff --git a/babl/babl.h b/babl/babl.h
index cddfbb7..2c248a5 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -183,6 +183,11 @@ babl_format_n (Babl *type,
                int   components);
 
 /**
+ * Returns whether the @format is a format_n type.
+ */
+int babl_format_is_format_n (Babl *format);
+
+/**
  * Defines a new conversion between either two formats, two models or
  * two types in babl.
  *



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