[gegl] buffer: apply gamma curve to alpha component during filtering



commit 950dc34789c05f5c4da31b6988f19983ecbfca08
Author: Ell <ell_se yahoo com>
Date:   Wed Oct 17 10:29:20 2018 -0400

    buffer: apply gamma curve to alpha component during filtering
    
    Disable the _alpha() variant of
    gegl_{boxfilter,bilinear,downscale_2x2}_u8_nl(), and use the non-
    alpha one instead, applying the same gamma curve to the alpha
    components as we do for the color components.  This is a temporary
    hack, meant to avoid producing over-saturated pixels when using
    these functions with premultiplied-alpha formats (in particular,
    cairo-ARGB32), which can lead, most notably, to visual artifacts in
    cairo during compositing (see issue #104).

 gegl/buffer/gegl-algorithms.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/gegl/buffer/gegl-algorithms.c b/gegl/buffer/gegl-algorithms.c
index 19682b1bf..ec9291bde 100644
--- a/gegl/buffer/gegl-algorithms.c
+++ b/gegl/buffer/gegl-algorithms.c
@@ -921,6 +921,26 @@ gegl_downscale_2x2_u8_rgb (const Babl *format,
 }
 
 
+/* FIXME:  disable the _alpha() variants for now, so that we use the same gamma
+ * curve for the alpha component as we do for the color components.  this is
+ * necessary to avoid producing over-saturated pixels when using a format with
+ * premultiplied alpha (note that, either way, using such a format with these
+ * functions produces wrong results in general, when the data is not fully
+ * opaque.)  most notably, when using cairo-ARGB32 (which we do in GIMP's
+ * display code), this avoids potential overflow during compositing in cairo.
+ *
+ * see issue #104.
+ *
+ * we use the comma operator to avoid "defined but not used" warnings.
+ */
+#define gegl_boxfilter_u8_nl_alpha     ((void) gegl_boxfilter_u8_nl_alpha,     \
+                                        gegl_boxfilter_u8_nl)
+#define gegl_bilinear_u8_nl_alpha      ((void) gegl_bilinear_u8_nl_alpha,      \
+                                        gegl_bilinear_u8_nl)
+#define gegl_downscale_2x2_u8_nl_alpha ((void) gegl_downscale_2x2_u8_nl_alpha, \
+                                        gegl_downscale_2x2_u8_nl)
+
+
 GeglDownscale2x2Fun gegl_downscale_2x2_get_fun (const Babl *format)
 {
   const Babl *comp_type = babl_format_get_type (format, 0);


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