Commit 9d518677 authored by Michael Natterer's avatar Michael Natterer 😴

app: remove gimpdrawable-convert.[ch]

This can now be done in gimp_drawable_real_convert_type() with a few
lines of GEGL buffer copying.
parent 95cb77ed
......@@ -128,8 +128,6 @@ libappcore_a_sources = \
gimpdrawable-bucket-fill.h \
gimpdrawable-combine.c \
gimpdrawable-combine.h \
gimpdrawable-convert.c \
gimpdrawable-convert.h \
gimpdrawable-equalize.c \
gimpdrawable-equalize.h \
gimpdrawable-foreground-extract.c \
......
......@@ -446,7 +446,7 @@ gimp_channel_convert (GimpItem *item,
if (! gimp_drawable_is_gray (drawable))
{
gimp_drawable_convert_type (drawable, NULL, GIMP_GRAY, FALSE);
gimp_drawable_convert_type (drawable, dest_image, GIMP_GRAY, FALSE);
}
if (gimp_drawable_has_alpha (drawable))
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
* Copyright (C) 1997-2004 Adam D. Moss <adam@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "core-types.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimpdrawable.h"
#include "gimpdrawable-convert.h"
#include "gimpimage.h"
void
gimp_drawable_convert_rgb (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo)
{
GeglBuffer *dest_buffer;
const Babl *format;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
g_return_if_fail (! gimp_drawable_is_rgb (drawable));
format = gimp_image_get_format (dest_image, GIMP_RGB,
gimp_drawable_has_alpha (drawable));
dest_buffer =
gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable))),
format);
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
dest_buffer, NULL);
gimp_drawable_set_buffer (drawable, push_undo, NULL, dest_buffer);
g_object_unref (dest_buffer);
}
void
gimp_drawable_convert_grayscale (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo)
{
GeglBuffer *dest_buffer;
const Babl *format;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
g_return_if_fail (! gimp_drawable_is_gray (drawable));
format = gimp_image_get_format (dest_image, GIMP_GRAY,
gimp_drawable_has_alpha (drawable));
dest_buffer =
gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable))),
format);
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
dest_buffer, NULL);
gimp_drawable_set_buffer (drawable, push_undo, NULL, dest_buffer);
g_object_unref (dest_buffer);
}
void
gimp_drawable_convert_indexed (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo)
{
GeglBuffer *dest_buffer;
const Babl *format;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
g_return_if_fail (! gimp_drawable_is_indexed (drawable));
format = gimp_image_get_format (dest_image, GIMP_INDEXED,
gimp_drawable_has_alpha (drawable));
dest_buffer =
gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable))),
format);
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
dest_buffer, NULL);
gimp_drawable_set_buffer (drawable, push_undo, NULL, dest_buffer);
g_object_unref (dest_buffer);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_DRAWABLE_CONVERT_H__
#define __GIMP_DRAWABLE_CONVERT_H__
void gimp_drawable_convert_rgb (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo);
void gimp_drawable_convert_grayscale (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo);
void gimp_drawable_convert_indexed (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo);
#endif /* __GIMP_DRAWABLE_CONVERT_H__ */
......@@ -35,7 +35,6 @@
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawable-combine.h"
#include "gimpdrawable-convert.h"
#include "gimpdrawable-operation.h"
#include "gimpdrawable-preview.h"
#include "gimpdrawable-private.h"
......@@ -694,23 +693,23 @@ gimp_drawable_real_convert_type (GimpDrawable *drawable,
GimpImageBaseType new_base_type,
gboolean push_undo)
{
switch (new_base_type)
{
case GIMP_RGB:
gimp_drawable_convert_rgb (drawable, dest_image, push_undo);
break;
GeglBuffer *dest_buffer;
const Babl *format;
case GIMP_GRAY:
gimp_drawable_convert_grayscale (drawable, dest_image, push_undo);
break;
format = gimp_image_get_format (dest_image, new_base_type,
gimp_drawable_has_alpha (drawable));
case GIMP_INDEXED:
gimp_drawable_convert_indexed (drawable, dest_image, push_undo);
break;
dest_buffer =
gimp_gegl_buffer_new (GEGL_RECTANGLE (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable))),
format);
default:
break;
}
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
dest_buffer, NULL);
gimp_drawable_set_buffer (drawable, push_undo, NULL, dest_buffer);
g_object_unref (dest_buffer);
}
static GeglBuffer *
......@@ -1157,14 +1156,12 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (dest_image == NULL || GIMP_IS_IMAGE (dest_image));
g_return_if_fail (new_base_type != GIMP_INDEXED || GIMP_IS_IMAGE (dest_image));
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
g_return_if_fail (new_base_type != gimp_drawable_get_base_type (drawable));
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
push_undo = FALSE;
g_return_if_fail (new_base_type != gimp_drawable_get_base_type (drawable));
GIMP_DRAWABLE_GET_CLASS (drawable)->convert_type (drawable, dest_image,
new_base_type, push_undo);
}
......
......@@ -120,7 +120,8 @@ gimp_group_layer_undo_pop (GimpUndo *undo,
GimpImageBaseType type;
type = gimp_drawable_get_base_type (GIMP_DRAWABLE (group));
gimp_drawable_convert_type (GIMP_DRAWABLE (group), NULL,
gimp_drawable_convert_type (GIMP_DRAWABLE (group),
gimp_item_get_image (GIMP_ITEM (group)),
group_layer_undo->prev_type, FALSE);
group_layer_undo->prev_type = type;
}
......
......@@ -37,7 +37,6 @@
#include "gimpchannel-select.h"
#include "gimpcontext.h"
#include "gimpcontainer.h"
#include "gimpdrawable-convert.h"
#include "gimpdrawable-operation.h"
#include "gimperror.h"
#include "gimpimage-undo-push.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment