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



commit c2947d46c90bcfebf46fe0a48e87d82a776e3231
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 71fe531..b463136 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
 };
 
 
@@ -125,6 +126,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);
 
@@ -150,6 +158,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;
@@ -170,6 +182,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;
@@ -179,7 +195,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]