[gimp/goat-invasion: 292/325] app: use the same indexed Babl formats during an image's lifetime



commit c68894d994670a118fd3ebee8ce2ee7fa6bd4261
Author: Michael Natterer <mitch gimp org>
Date:   Wed Mar 28 16:59:02 2012 +0200

    app: use the same indexed Babl formats during an image's lifetime
    
    And only reconfigure them when the colormap changes. This way
    undo/redo of layer adding/removing works across type conversions,
    because the layers need to be in the same format as the image's
    indexed format.

 app/core/gimpimage-colormap.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/app/core/gimpimage-colormap.c b/app/core/gimpimage-colormap.c
index fbcb887..67168a1 100644
--- a/app/core/gimpimage-colormap.c
+++ b/app/core/gimpimage-colormap.c
@@ -71,10 +71,14 @@ gimp_image_colormap_init (GimpImage *image)
   private->colormap = g_new0 (guchar, GIMP_IMAGE_COLORMAP_SIZE);
   private->palette  = GIMP_PALETTE (gimp_palette_new (NULL, palette_name));
 
-  /* FIXME name palette */
-  babl_new_palette (NULL, &private->babl_palette_rgb, &private->babl_palette_rgba);
+  if (! private->babl_palette_rgb)
+    {
+      babl_new_palette (NULL,
+                        &private->babl_palette_rgb,
+                        &private->babl_palette_rgba);
+    }
 
-  gimp_palette_set_columns  (private->palette, 16);
+  gimp_palette_set_columns (private->palette, 16);
 
   gimp_data_make_internal (GIMP_DATA (private->palette), palette_id);
 
@@ -122,10 +126,10 @@ gimp_image_colormap_free (GimpImage *image)
   g_object_unref (private->palette);
   private->palette = NULL;
 
-  babl_palette_reset (private->babl_palette_rgb);
-  babl_palette_reset (private->babl_palette_rgba);
-  private->babl_palette_rgb = NULL;
-  private->babl_palette_rgba = NULL;
+  /* don't touch the image's babl_palettes because we might still have
+   * buffers with that palette on the undo stack, and on undoing the
+   * image back to indexed, we must have exactly these palettes around
+   */
 }
 
 const Babl *



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