[gimp] app: make sure the layer mask's precision gets converted too



commit 17e36e9b3fd1ebdd0e3a4b8fc88c39532a05482b
Author: Michael Natterer <mitch gimp org>
Date:   Wed Apr 25 16:10:27 2012 +0200

    app: make sure the layer mask's precision gets converted too
    
    when the layer's precision is converted.

 app/core/gimpgrouplayer.c |   11 +++++++++++
 app/core/gimplayer.c      |   28 ++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 514f4bc..45d5030 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -853,6 +853,7 @@ gimp_group_layer_convert_type (GimpDrawable      *drawable,
 {
   GimpGroupLayer        *group   = GIMP_GROUP_LAYER (drawable);
   GimpGroupLayerPrivate *private = GET_PRIVATE (drawable);
+  GimpLayerMask         *mask;
   GeglBuffer            *buffer;
 
   if (push_undo)
@@ -880,6 +881,16 @@ gimp_group_layer_convert_type (GimpDrawable      *drawable,
 
   /*  reset, the actual format is right now  */
   private->convert_format = NULL;
+
+  mask = gimp_layer_get_mask (GIMP_LAYER (group));
+
+  if (mask &&
+      new_precision != gimp_drawable_get_precision (GIMP_DRAWABLE (mask)))
+    {
+      gimp_drawable_convert_type (GIMP_DRAWABLE (mask), dest_image,
+                                  GIMP_GRAY, new_precision, push_undo);
+    }
+
 }
 
 static const Babl *
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index c3aae91..ff8f433 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -155,6 +155,11 @@ static GeglNode * gimp_layer_get_node           (GimpItem           *item);
 static gint64  gimp_layer_estimate_memsize      (const GimpDrawable *drawable,
                                                  gint                width,
                                                  gint                height);
+static void    gimp_layer_convert_type          (GimpDrawable       *drawable,
+                                                 GimpImage          *dest_image,
+                                                 GimpImageBaseType   new_base_type,
+                                                 GimpPrecision       new_precision,
+                                                 gboolean            push_undo);
 static void    gimp_layer_invalidate_boundary   (GimpDrawable       *drawable);
 static void    gimp_layer_get_active_components (const GimpDrawable *drawable,
                                                  gboolean           *active);
@@ -297,6 +302,7 @@ gimp_layer_class_init (GimpLayerClass *klass)
   item_class->lower_failed            = _("Layer cannot be lowered more.");
 
   drawable_class->estimate_memsize      = gimp_layer_estimate_memsize;
+  drawable_class->convert_type          = gimp_layer_convert_type;
   drawable_class->invalidate_boundary   = gimp_layer_invalidate_boundary;
   drawable_class->get_active_components = gimp_layer_get_active_components;
   drawable_class->project_region        = gimp_layer_project_region;
@@ -930,6 +936,28 @@ gimp_layer_estimate_memsize (const GimpDrawable *drawable,
 }
 
 static void
+gimp_layer_convert_type (GimpDrawable      *drawable,
+                         GimpImage         *dest_image,
+                         GimpImageBaseType  new_base_type,
+                         GimpPrecision      new_precision,
+                         gboolean           push_undo)
+{
+  GimpLayer *layer = GIMP_LAYER (drawable);
+
+  if (layer->mask &&
+      new_precision != gimp_drawable_get_precision (GIMP_DRAWABLE (layer->mask)))
+    {
+      gimp_drawable_convert_type (GIMP_DRAWABLE (layer->mask), dest_image,
+                                  GIMP_GRAY, new_precision, push_undo);
+    }
+
+  GIMP_DRAWABLE_CLASS (parent_class)->convert_type (drawable, dest_image,
+                                                    new_base_type,
+                                                    new_precision,
+                                                    push_undo);
+}
+
+static void
 gimp_layer_invalidate_boundary (GimpDrawable *drawable)
 {
   GimpLayer   *layer = GIMP_LAYER (drawable);



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