[gimp/goat-invasion: 238/526] app: add a "premultiplied" property to GimpOperationPointLayerMode



commit 11225e5d6d6bb66598f6fbbad98f6ed9d3e21edb
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 24 15:35:26 2012 +0100

    app: add a "premultiplied" property to GimpOperationPointLayerMode
    
    and default to TRUE. While premultiplied is the right thing to do for
    the projection, we can't have it bleeding blackness into our pixels
    when using the mode ops for applying paint to drawables, so we will
    have to implement each layer mode with both options.

 app/gegl/gimpoperationpointlayermode.c |   26 ++++++++++++++++++++++++--
 app/gegl/gimpoperationpointlayermode.h |    1 +
 2 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/app/gegl/gimpoperationpointlayermode.c b/app/gegl/gimpoperationpointlayermode.c
index ab0e3a9..780a28a 100644
--- a/app/gegl/gimpoperationpointlayermode.c
+++ b/app/gegl/gimpoperationpointlayermode.c
@@ -70,7 +70,8 @@
 enum
 {
   PROP_0,
-  PROP_BLEND_MODE
+  PROP_BLEND_MODE,
+  PROP_PREMULTIPLIED
 };
 
 
@@ -128,6 +129,13 @@ gimp_operation_point_layer_mode_class_init (GimpOperationPointLayerModeClass *kl
                                                       GIMP_NORMAL_MODE,
                                                       GIMP_PARAM_READWRITE));
 
+  g_object_class_install_property (object_class, PROP_PREMULTIPLIED,
+                                   g_param_spec_boolean ("premultiplied",
+                                                         NULL, NULL,
+                                                         TRUE,
+                                                         GIMP_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT_ONLY));
+
   for (i = 0; i < DISSOLVE_REPEAT_WIDTH * DISSOLVE_REPEAT_HEIGHT; i++)
     dissolve_lut[i] = g_rand_int (rand);
 
@@ -153,6 +161,10 @@ gimp_operation_point_layer_mode_set_property (GObject      *object,
       self->blend_mode = g_value_get_enum (value);
       break;
 
+    case PROP_PREMULTIPLIED:
+      self->premultiplied = g_value_get_enum (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -173,6 +185,10 @@ gimp_operation_point_layer_mode_get_property (GObject    *object,
       g_value_set_enum (value, self->blend_mode);
       break;
 
+    case PROP_PREMULTIPLIED:
+      g_value_set_boolean (value, self->premultiplied);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -182,7 +198,13 @@ gimp_operation_point_layer_mode_get_property (GObject    *object,
 static void
 gimp_operation_point_layer_mode_prepare (GeglOperation *operation)
 {
-  const Babl *format = babl_format ("RaGaBaA float");
+  GimpOperationPointLayerMode *self = GIMP_OPERATION_POINT_LAYER_MODE (operation);
+  const Babl                  *format;
+
+  if (self->premultiplied)
+    format = babl_format ("RaGaBaA float");
+  else
+    format = babl_format ("RGBA float");
 
   gegl_operation_set_format (operation, "input",  format);
   gegl_operation_set_format (operation, "output", format);
diff --git a/app/gegl/gimpoperationpointlayermode.h b/app/gegl/gimpoperationpointlayermode.h
index e537111..f077024 100644
--- a/app/gegl/gimpoperationpointlayermode.h
+++ b/app/gegl/gimpoperationpointlayermode.h
@@ -42,6 +42,7 @@ struct _GimpOperationPointLayerMode
   GeglOperationPointComposer  parent_instance;
 
   GimpLayerModeEffects        blend_mode;
+  gboolean                    premultiplied;
 };
 
 



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