[gegl] operations: make generated ops use gegl_babl_variant



commit 0726ef7fd29859c6b8d92193cc91b020e52b5f27
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Oct 31 18:59:18 2018 +0100

    operations: make generated ops use gegl_babl_variant

 operations/generated/add.c                 | 45 +-----------------------------
 operations/generated/clear.c               | 40 +++-----------------------
 operations/generated/color-burn.c          | 44 ++---------------------------
 operations/generated/color-dodge.c         | 44 ++---------------------------
 operations/generated/darken.c              | 44 ++---------------------------
 operations/generated/difference.c          | 44 ++---------------------------
 operations/generated/divide.c              | 45 +-----------------------------
 operations/generated/dst-atop.c            | 40 +++-----------------------
 operations/generated/dst-in.c              | 40 +++-----------------------
 operations/generated/dst-out.c             | 40 +++-----------------------
 operations/generated/dst-over.c            | 40 +++-----------------------
 operations/generated/dst.c                 | 40 +++-----------------------
 operations/generated/exclusion.c           | 44 ++---------------------------
 operations/generated/gamma.c               | 45 +-----------------------------
 operations/generated/hard-light.c          | 44 ++---------------------------
 operations/generated/lighten.c             | 44 ++---------------------------
 operations/generated/math.rb               | 45 +-----------------------------
 operations/generated/multiply.c            | 45 +-----------------------------
 operations/generated/overlay.c             | 44 ++---------------------------
 operations/generated/plus.c                | 44 ++---------------------------
 operations/generated/screen.c              | 44 ++---------------------------
 operations/generated/soft-light.c          | 44 ++---------------------------
 operations/generated/src-atop.c            | 40 +++-----------------------
 operations/generated/src-in.c              | 40 +++-----------------------
 operations/generated/src-out.c             | 40 +++-----------------------
 operations/generated/src.c                 | 40 +++-----------------------
 operations/generated/subtract.c            | 45 +-----------------------------
 operations/generated/svg-12-blend.rb       | 44 ++---------------------------
 operations/generated/svg-12-porter-duff.rb | 40 +++-----------------------
 operations/generated/xor.c                 | 40 +++-----------------------
 30 files changed, 90 insertions(+), 1188 deletions(-)
---
diff --git a/operations/generated/add.c b/operations/generated/add.c
index 1fb671653..9726ef9a8 100644
--- a/operations/generated/add.c
+++ b/operations/generated/add.c
@@ -47,52 +47,9 @@ property_double (value, _("Value"), 0.0)
 static void prepare (GeglOperation *operation)
 {
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space ("Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space ("YA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space ("RGB float", space);
-  }
-#if 0
-  else if (babl_model_is (model, "RGBA") ||
-           babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~") ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
-#endif
-  else
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
+  format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR);
 
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "aux", format);
diff --git a/operations/generated/clear.c b/operations/generated/clear.c
index 48687db4a..1e29d4146 100644
--- a/operations/generated/clear.c
+++ b/operations/generated/clear.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/color-burn.c b/operations/generated/color-burn.c
index b4e2f2a4e..1550010a6 100644
--- a/operations/generated/color-burn.c
+++ b/operations/generated/color-burn.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/color-dodge.c b/operations/generated/color-dodge.c
index ceb7b9443..156732f18 100644
--- a/operations/generated/color-dodge.c
+++ b/operations/generated/color-dodge.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/darken.c b/operations/generated/darken.c
index 55d181bc3..607f71dae 100644
--- a/operations/generated/darken.c
+++ b/operations/generated/darken.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/difference.c b/operations/generated/difference.c
index 3abfde3a0..8c02f9580 100644
--- a/operations/generated/difference.c
+++ b/operations/generated/difference.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/divide.c b/operations/generated/divide.c
index c52d67d54..77b489238 100644
--- a/operations/generated/divide.c
+++ b/operations/generated/divide.c
@@ -47,52 +47,9 @@ property_double (value, _("Value"), 1.0)
 static void prepare (GeglOperation *operation)
 {
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space ("Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space ("YA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space ("RGB float", space);
-  }
-#if 0
-  else if (babl_model_is (model, "RGBA") ||
-           babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~") ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
-#endif
-  else
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
+  format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR);
 
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "aux", format);
diff --git a/operations/generated/dst-atop.c b/operations/generated/dst-atop.c
index 19028a13b..48e2632bf 100644
--- a/operations/generated/dst-atop.c
+++ b/operations/generated/dst-atop.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/dst-in.c b/operations/generated/dst-in.c
index c760b6d12..f82f4ce76 100644
--- a/operations/generated/dst-in.c
+++ b/operations/generated/dst-in.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/dst-out.c b/operations/generated/dst-out.c
index ffd09e11f..66d213b54 100644
--- a/operations/generated/dst-out.c
+++ b/operations/generated/dst-out.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/dst-over.c b/operations/generated/dst-over.c
index 75602371d..a817a8550 100644
--- a/operations/generated/dst-over.c
+++ b/operations/generated/dst-over.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/dst.c b/operations/generated/dst.c
index 165288a54..a68a8d989 100644
--- a/operations/generated/dst.c
+++ b/operations/generated/dst.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/exclusion.c b/operations/generated/exclusion.c
index dd085ccc9..2d10ccbf6 100644
--- a/operations/generated/exclusion.c
+++ b/operations/generated/exclusion.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/gamma.c b/operations/generated/gamma.c
index 3594dfad5..3ca7544f2 100644
--- a/operations/generated/gamma.c
+++ b/operations/generated/gamma.c
@@ -47,52 +47,9 @@ property_double (value, _("Value"), 1.0)
 static void prepare (GeglOperation *operation)
 {
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space ("Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space ("YA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space ("RGB float", space);
-  }
-#if 0
-  else if (babl_model_is (model, "RGBA") ||
-           babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~") ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
-#endif
-  else
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
+  format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR);
 
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "aux", format);
diff --git a/operations/generated/hard-light.c b/operations/generated/hard-light.c
index eff83d937..75f4ecfff 100644
--- a/operations/generated/hard-light.c
+++ b/operations/generated/hard-light.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/lighten.c b/operations/generated/lighten.c
index 21c98a0db..af1318443 100644
--- a/operations/generated/lighten.c
+++ b/operations/generated/lighten.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/math.rb b/operations/generated/math.rb
index 0bb124caa..31218536e 100755
--- a/operations/generated/math.rb
+++ b/operations/generated/math.rb
@@ -77,52 +77,9 @@ property_double (value, _(\"Value\"), #{item[2]})
 static void prepare (GeglOperation *operation)
 {
   const Babl *format = gegl_operation_get_source_format (operation, \"input\");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, \"aux\");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, \"Y\") ||
-      babl_model_is (model, \"Y'\") ||
-      babl_model_is (model, \"Y~\"))
-  {
-    format  = babl_format_with_space (\"Y float\", space);
-  }
-  else if (babl_model_is (model, \"YA\") ||
-           babl_model_is (model, \"Y'A\") ||
-           babl_model_is (model, \"Y~A\") ||
-           babl_model_is (model, \"YaA\") ||
-           babl_model_is (model, \"Y'aA\"))
-  {
-    format  = babl_format_with_space (\"YA float\", space);
-  }
-  else if (babl_model_is (model, \"RGB\") ||
-           babl_model_is (model, \"R'G'B'\") ||
-           babl_model_is (model, \"R~G~B~\"))
-  {
-    format  = babl_format_with_space (\"RGB float\", space);
-  }
-#if 0
-  else if (babl_model_is (model, \"RGBA\") ||
-           babl_model_is (model, \"RGB\") ||
-           babl_model_is (model, \"R'G'B'A\") ||
-           babl_model_is (model, \"R'G'B'\") ||
-           babl_model_is (model, \"R~G~B~A\") ||
-           babl_model_is (model, \"R~G~B~\") ||
-           babl_model_is (model, \"RaGaBaA\") ||
-           babl_model_is (model, \"R'aG'aB'aA\"))
-  {
-    format  = babl_format_with_space (\"RGBA float\", space);
-  }
-#endif
-  else
-  {
-    format  = babl_format_with_space (\"RGBA float\", space);
-  }
+  format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR);
 
   gegl_operation_set_format (operation, \"input\", format);
   gegl_operation_set_format (operation, \"aux\", format);
diff --git a/operations/generated/multiply.c b/operations/generated/multiply.c
index b603b647d..44dca2ef5 100644
--- a/operations/generated/multiply.c
+++ b/operations/generated/multiply.c
@@ -47,52 +47,9 @@ property_double (value, _("Value"), 1.0)
 static void prepare (GeglOperation *operation)
 {
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space ("Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space ("YA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space ("RGB float", space);
-  }
-#if 0
-  else if (babl_model_is (model, "RGBA") ||
-           babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~") ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
-#endif
-  else
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
+  format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR);
 
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "aux", format);
diff --git a/operations/generated/overlay.c b/operations/generated/overlay.c
index 4d83845f5..d372bcbb9 100644
--- a/operations/generated/overlay.c
+++ b/operations/generated/overlay.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/plus.c b/operations/generated/plus.c
index 1162c59b9..c3104b338 100644
--- a/operations/generated/plus.c
+++ b/operations/generated/plus.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/screen.c b/operations/generated/screen.c
index 3122a255b..a79d5acb6 100644
--- a/operations/generated/screen.c
+++ b/operations/generated/screen.c
@@ -48,52 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/soft-light.c b/operations/generated/soft-light.c
index 430a17ebb..097f28001 100644
--- a/operations/generated/soft-light.c
+++ b/operations/generated/soft-light.c
@@ -49,52 +49,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/src-atop.c b/operations/generated/src-atop.c
index 78679c5b3..89d41d966 100644
--- a/operations/generated/src-atop.c
+++ b/operations/generated/src-atop.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/src-in.c b/operations/generated/src-in.c
index 71f1b0114..31fc955bf 100644
--- a/operations/generated/src-in.c
+++ b/operations/generated/src-in.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/src-out.c b/operations/generated/src-out.c
index b0c6a0ad4..d5406d5f0 100644
--- a/operations/generated/src-out.c
+++ b/operations/generated/src-out.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/src.c b/operations/generated/src.c
index 9fb7dc4a5..dca6aa8c5 100644
--- a/operations/generated/src.c
+++ b/operations/generated/src.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/subtract.c b/operations/generated/subtract.c
index f99c763a4..054e084fb 100644
--- a/operations/generated/subtract.c
+++ b/operations/generated/subtract.c
@@ -47,52 +47,9 @@ property_double (value, _("Value"), 0.0)
 static void prepare (GeglOperation *operation)
 {
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space ("Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space ("YA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space ("RGB float", space);
-  }
-#if 0
-  else if (babl_model_is (model, "RGBA") ||
-           babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~") ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
-#endif
-  else
-  {
-    format  = babl_format_with_space ("RGBA float", space);
-  }
+  format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR);
 
   gegl_operation_set_format (operation, "input", format);
   gegl_operation_set_format (operation, "aux", format);
diff --git a/operations/generated/svg-12-blend.rb b/operations/generated/svg-12-blend.rb
index 8221684d4..1b53c6371 100755
--- a/operations/generated/svg-12-blend.rb
+++ b/operations/generated/svg-12-blend.rb
@@ -93,52 +93,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 file_head2 = '
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
 
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y\'") ||
-      babl_model_is (model, "Y~"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~ float":"Y float", space);
-  }
-  else if (babl_model_is (model, "YA") ||
-           babl_model_is (model, "Y\'A") ||
-           babl_model_is (model, "Y~A") ||
-           babl_model_is (model, "YaA") ||
-           babl_model_is (model, "Y\'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R\'G\'B\'") ||
-           babl_model_is (model, "R~G~B~"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~G~B~ float":"RGB float", space);
-  }
-  else if (babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R\'G\'B\'A") ||
-           babl_model_is (model, "R\'G\'B\'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R\'aG\'aB\'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/svg-12-porter-duff.rb b/operations/generated/svg-12-porter-duff.rb
index 9f1826c5d..00655fd99 100755
--- a/operations/generated/svg-12-porter-duff.rb
+++ b/operations/generated/svg-12-porter-duff.rb
@@ -90,46 +90,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 file_head2 = '
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y\'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y\'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y\'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R\'G\'B\'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R\'G\'B\'A") ||
-           babl_model_is (model, "R\'G\'B\'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R\'aG\'aB\'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);
diff --git a/operations/generated/xor.c b/operations/generated/xor.c
index 4d216ffa9..76c2c28b6 100644
--- a/operations/generated/xor.c
+++ b/operations/generated/xor.c
@@ -48,46 +48,14 @@ property_boolean (srgb, _("sRGB"), FALSE)
 
 static void prepare (GeglOperation *operation)
 {
-  int use_srgb = GEGL_PROPERTIES (operation)->srgb?1:0;
   const Babl *format = gegl_operation_get_source_format (operation, "input");
-  const Babl *space = NULL;
-  const Babl *model = NULL;
   if (!format)
     format = gegl_operation_get_source_format (operation, "aux");
-  if (format)
-  {
-    model = babl_format_get_model (format);
-  }
-
-  if (babl_model_is (model, "Y") ||
-      babl_model_is (model, "Y'") ||
-      babl_model_is (model, "Y~") ||
-      babl_model_is (model, "YA") ||
-      babl_model_is (model, "Y'A") ||
-      babl_model_is (model, "Y~A") ||
-      babl_model_is (model, "YaA") ||
-      babl_model_is (model, "Y'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"Y~aA float":"YaA float", space);
-  }
-  else if (babl_model_is (model, "RGB") ||
-           babl_model_is (model, "R'G'B'") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RGBA")    ||
-           babl_model_is (model, "RGB")     ||
-           babl_model_is (model, "R'G'B'A") ||
-           babl_model_is (model, "R'G'B'")  ||
-           babl_model_is (model, "R~G~B~A") ||
-           babl_model_is (model, "R~G~B~")  ||
-           babl_model_is (model, "RaGaBaA") ||
-           babl_model_is (model, "R'aG'aB'aA"))
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+
+  if(GEGL_PROPERTIES (operation)->srgb)
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED);
   else
-  {
-    format  = babl_format_with_space (use_srgb?"R~aG~aB~aA float":"RaGaBaA float", space);
-  }
+    format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED);
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "aux",    format);


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