mirror of https://github.com/GNOME/gimp.git
app: rename GimpImageMap to GimpDrawableFilter
and gimpdrawable-filter.[ch] to gimpdrawable-filters.[ch] because of the name clash.
This commit is contained in:
parent
f7c104c6ae
commit
9fb70a44f2
|
@ -143,8 +143,8 @@ libappcore_a_sources = \
|
|||
gimpdrawable-equalize.h \
|
||||
gimpdrawable-fill.c \
|
||||
gimpdrawable-fill.h \
|
||||
gimpdrawable-filter.c \
|
||||
gimpdrawable-filter.h \
|
||||
gimpdrawable-filters.c \
|
||||
gimpdrawable-filters.h \
|
||||
gimpdrawable-foreground-extract.c \
|
||||
gimpdrawable-foreground-extract.h \
|
||||
gimpdrawable-histogram.c \
|
||||
|
@ -164,6 +164,8 @@ libappcore_a_sources = \
|
|||
gimpdrawable-stroke.h \
|
||||
gimpdrawable-transform.c \
|
||||
gimpdrawable-transform.h \
|
||||
gimpdrawablefilter.c \
|
||||
gimpdrawablefilter.h \
|
||||
gimpdrawablemodundo.c \
|
||||
gimpdrawablemodundo.h \
|
||||
gimpdrawablestack.c \
|
||||
|
@ -273,8 +275,6 @@ libappcore_a_sources = \
|
|||
gimpimageundo.h \
|
||||
gimpimagefile.c \
|
||||
gimpimagefile.h \
|
||||
gimpimagemap.c \
|
||||
gimpimagemap.h \
|
||||
gimpitem.c \
|
||||
gimpitem.h \
|
||||
gimpitem-exclusive.c \
|
||||
|
|
|
@ -1167,19 +1167,19 @@ gimp_dynamics_output_type_get_type (void)
|
|||
}
|
||||
|
||||
GType
|
||||
gimp_image_map_region_get_type (void)
|
||||
gimp_filter_region_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_IMAGE_MAP_REGION_SELECTION, "GIMP_IMAGE_MAP_REGION_SELECTION", "selection" },
|
||||
{ GIMP_IMAGE_MAP_REGION_DRAWABLE, "GIMP_IMAGE_MAP_REGION_DRAWABLE", "drawable" },
|
||||
{ GIMP_FILTER_REGION_SELECTION, "GIMP_FILTER_REGION_SELECTION", "selection" },
|
||||
{ GIMP_FILTER_REGION_DRAWABLE, "GIMP_FILTER_REGION_DRAWABLE", "drawable" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_IMAGE_MAP_REGION_SELECTION, NC_("image-map-region", "Use the selection as input"), NULL },
|
||||
{ GIMP_IMAGE_MAP_REGION_DRAWABLE, NC_("image-map-region", "Use the entire layer as input"), NULL },
|
||||
{ GIMP_FILTER_REGION_SELECTION, NC_("filter-region", "Use the selection as input"), NULL },
|
||||
{ GIMP_FILTER_REGION_DRAWABLE, NC_("filter-region", "Use the entire layer as input"), NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -1187,8 +1187,8 @@ gimp_image_map_region_get_type (void)
|
|||
|
||||
if (G_UNLIKELY (! type))
|
||||
{
|
||||
type = g_enum_register_static ("GimpImageMapRegion", values);
|
||||
gimp_type_set_translation_context (type, "image-map-region");
|
||||
type = g_enum_register_static ("GimpFilterRegion", values);
|
||||
gimp_type_set_translation_context (type, "filter-region");
|
||||
gimp_enum_set_value_descriptions (type, descs);
|
||||
}
|
||||
|
||||
|
|
|
@ -542,15 +542,15 @@ typedef enum /*< pdb-skip >*/
|
|||
} GimpDynamicsOutputType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_IMAGE_MAP_REGION (gimp_image_map_region_get_type ())
|
||||
#define GIMP_TYPE_FILTER_REGION (gimp_filter_region_get_type ())
|
||||
|
||||
GType gimp_image_map_region_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_filter_region_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum /*< pdb-skip >*/
|
||||
{
|
||||
GIMP_IMAGE_MAP_REGION_SELECTION, /*< desc="Use the selection as input" >*/
|
||||
GIMP_IMAGE_MAP_REGION_DRAWABLE /*< desc="Use the entire layer as input" >*/
|
||||
} GimpImageMapRegion;
|
||||
GIMP_FILTER_REGION_SELECTION, /*< desc="Use the selection as input" >*/
|
||||
GIMP_FILTER_REGION_DRAWABLE /*< desc="Use the entire layer as input" >*/
|
||||
} GimpFilterRegion;
|
||||
|
||||
|
||||
#define GIMP_TYPE_CHANNEL_BORDER_STYLE (gimp_channel_border_style_get_type ())
|
||||
|
|
|
@ -186,11 +186,11 @@ typedef struct _GimpMandala GimpMandala;
|
|||
/* misc objects */
|
||||
|
||||
typedef struct _GimpBuffer GimpBuffer;
|
||||
typedef struct _GimpDrawableFilter GimpDrawableFilter;
|
||||
typedef struct _GimpEnvironTable GimpEnvironTable;
|
||||
typedef struct _GimpGuide GimpGuide;
|
||||
typedef struct _GimpHistogram GimpHistogram;
|
||||
typedef struct _GimpIdTable GimpIdTable;
|
||||
typedef struct _GimpImageMap GimpImageMap;
|
||||
typedef struct _GimpImagefile GimpImagefile;
|
||||
typedef struct _GimpInterpreterDB GimpInterpreterDB;
|
||||
typedef struct _GimpParasiteList GimpParasiteList;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpdrawable-filter.c
|
||||
* gimpdrawable-filters.c
|
||||
*
|
||||
* 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
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "gimp-utils.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawable-filter.h"
|
||||
#include "gimpdrawable-filters.h"
|
||||
#include "gimpdrawable-private.h"
|
||||
#include "gimpdrawableundo.h"
|
||||
#include "gimpfilter.h"
|
|
@ -1,7 +1,7 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpdrawable-filter.h
|
||||
* gimpdrawable-filters.h
|
||||
*
|
||||
* 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
|
||||
|
@ -17,8 +17,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_DRAWABLE_FILTER_H__
|
||||
#define __GIMP_DRAWABLE_FILTER_H__
|
||||
#ifndef __GIMP_DRAWABLE_FILTERS_H__
|
||||
#define __GIMP_DRAWABLE_FILTERS_H__
|
||||
|
||||
|
||||
GimpContainer * gimp_drawable_get_filters (GimpDrawable *drawable);
|
||||
|
@ -38,4 +38,4 @@ gboolean gimp_drawable_merge_filter (GimpDrawable *drawable,
|
|||
gboolean cancellable);
|
||||
|
||||
|
||||
#endif /* __GIMP_DRAWABLE_FILTER_H__ */
|
||||
#endif /* __GIMP_DRAWABLE_FILTERS_H__ */
|
|
@ -36,7 +36,7 @@
|
|||
#include "gimpchannel.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdrawable-combine.h"
|
||||
#include "gimpdrawable-filter.h"
|
||||
#include "gimpdrawable-filters.h"
|
||||
#include "gimpdrawable-preview.h"
|
||||
#include "gimpdrawable-private.h"
|
||||
#include "gimpdrawable-shadow.h"
|
||||
|
|
|
@ -0,0 +1,768 @@
|
|||
/* 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/>.
|
||||
*/
|
||||
|
||||
/* This file contains the code necessary for generating on canvas
|
||||
* previews, by connecting a specified GEGL operation to do the
|
||||
* processing. It uses drawable filters that allow for non-destructive
|
||||
* manupulation of drawable data, with live preview on screen.
|
||||
*
|
||||
* To create a tool that uses this, see /tools/gimpimagemaptool.c for
|
||||
* the interface and /tools/gimpcolorbalancetool.c for an example of
|
||||
* using that interface.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cairo.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gegl/gimp-babl.h"
|
||||
#include "gegl/gimpapplicator.h"
|
||||
|
||||
#include "gimpchannel.h"
|
||||
#include "gimpdrawable-filters.h"
|
||||
#include "gimpdrawablefilter.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
FLUSH,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
struct _GimpDrawableFilter
|
||||
{
|
||||
GimpFilter parent_instance;
|
||||
|
||||
GimpDrawable *drawable;
|
||||
GeglNode *operation;
|
||||
|
||||
GimpFilterRegion region;
|
||||
gboolean preview_enabled;
|
||||
GimpAlignmentType preview_alignment;
|
||||
gdouble preview_position;
|
||||
gdouble opacity;
|
||||
GimpLayerModeEffects paint_mode;
|
||||
gboolean gamma_hack;
|
||||
|
||||
GeglRectangle filter_area;
|
||||
|
||||
GeglNode *translate;
|
||||
GeglNode *crop;
|
||||
GeglNode *cast_before;
|
||||
GeglNode *cast_after;
|
||||
GimpApplicator *applicator;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_drawable_filter_dispose (GObject *object);
|
||||
static void gimp_drawable_filter_finalize (GObject *object);
|
||||
|
||||
static void gimp_drawable_filter_sync_region (GimpDrawableFilter *filter);
|
||||
static void gimp_drawable_filter_sync_preview (GimpDrawableFilter *filter,
|
||||
gboolean old_enabled,
|
||||
GimpAlignmentType old_alignment,
|
||||
gdouble old_position);
|
||||
static void gimp_drawable_filter_sync_mode (GimpDrawableFilter *filter);
|
||||
static void gimp_drawable_filter_sync_affect (GimpDrawableFilter *filter);
|
||||
static void gimp_drawable_filter_sync_mask (GimpDrawableFilter *filter);
|
||||
static void gimp_drawable_filter_sync_gamma_hack (GimpDrawableFilter *filter);
|
||||
|
||||
static gboolean gimp_drawable_filter_is_filtering (GimpDrawableFilter *filter);
|
||||
static gboolean gimp_drawable_filter_add_filter (GimpDrawableFilter *filter);
|
||||
static gboolean gimp_drawable_filter_remove_filter (GimpDrawableFilter *filter);
|
||||
|
||||
static void gimp_drawable_filter_update_drawable (GimpDrawableFilter *filter,
|
||||
const GeglRectangle *area);
|
||||
|
||||
static void gimp_drawable_filter_affect_changed (GimpImage *image,
|
||||
GimpChannelType channel,
|
||||
GimpDrawableFilter *filter);
|
||||
static void gimp_drawable_filter_mask_changed (GimpImage *image,
|
||||
GimpDrawableFilter *filter);
|
||||
static void gimp_drawable_filter_drawable_removed (GimpDrawable *drawable,
|
||||
GimpDrawableFilter *filter);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpDrawableFilter, gimp_drawable_filter, GIMP_TYPE_FILTER)
|
||||
|
||||
#define parent_class gimp_drawable_filter_parent_class
|
||||
|
||||
static guint drawable_filter_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_class_init (GimpDrawableFilterClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
drawable_filter_signals[FLUSH] =
|
||||
g_signal_new ("flush",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpDrawableFilterClass, flush),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->dispose = gimp_drawable_filter_dispose;
|
||||
object_class->finalize = gimp_drawable_filter_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_init (GimpDrawableFilter *drawable_filter)
|
||||
{
|
||||
drawable_filter->region = GIMP_FILTER_REGION_SELECTION;
|
||||
drawable_filter->preview_alignment = GIMP_ALIGN_LEFT;
|
||||
drawable_filter->preview_position = 1.0;
|
||||
drawable_filter->opacity = GIMP_OPACITY_OPAQUE;
|
||||
drawable_filter->paint_mode = GIMP_REPLACE_MODE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_dispose (GObject *object)
|
||||
{
|
||||
GimpDrawableFilter *drawable_filter = GIMP_DRAWABLE_FILTER (object);
|
||||
|
||||
if (drawable_filter->drawable)
|
||||
gimp_drawable_filter_remove_filter (drawable_filter);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_finalize (GObject *object)
|
||||
{
|
||||
GimpDrawableFilter *drawable_filter = GIMP_DRAWABLE_FILTER (object);
|
||||
|
||||
if (drawable_filter->operation)
|
||||
{
|
||||
g_object_unref (drawable_filter->operation);
|
||||
drawable_filter->operation = NULL;
|
||||
}
|
||||
|
||||
if (drawable_filter->applicator)
|
||||
{
|
||||
g_object_unref (drawable_filter->applicator);
|
||||
drawable_filter->applicator = NULL;
|
||||
}
|
||||
|
||||
if (drawable_filter->drawable)
|
||||
{
|
||||
g_object_unref (drawable_filter->drawable);
|
||||
drawable_filter->drawable = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
GimpDrawableFilter *
|
||||
gimp_drawable_filter_new (GimpDrawable *drawable,
|
||||
const gchar *undo_desc,
|
||||
GeglNode *operation,
|
||||
const gchar *icon_name)
|
||||
{
|
||||
GimpDrawableFilter *filter;
|
||||
GeglNode *node;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
|
||||
g_return_val_if_fail (GEGL_IS_NODE (operation), NULL);
|
||||
g_return_val_if_fail (gegl_node_has_pad (operation, "output"), NULL);
|
||||
|
||||
filter = g_object_new (GIMP_TYPE_DRAWABLE_FILTER,
|
||||
"name", undo_desc,
|
||||
"icon-name", icon_name,
|
||||
NULL);
|
||||
|
||||
filter->drawable = g_object_ref (drawable);
|
||||
filter->operation = g_object_ref (operation);
|
||||
|
||||
node = gimp_filter_get_node (GIMP_FILTER (filter));
|
||||
|
||||
gegl_node_add_child (node, operation);
|
||||
|
||||
filter->applicator =
|
||||
gimp_applicator_new (node,
|
||||
gimp_drawable_get_linear (filter->drawable),
|
||||
TRUE, TRUE);
|
||||
|
||||
gimp_filter_set_applicator (GIMP_FILTER (filter), filter->applicator);
|
||||
|
||||
filter->translate = gegl_node_new_child (node,
|
||||
"operation", "gegl:translate",
|
||||
NULL);
|
||||
filter->crop = gegl_node_new_child (node,
|
||||
"operation", "gegl:crop",
|
||||
NULL);
|
||||
|
||||
filter->cast_before = gegl_node_new_child (node,
|
||||
"operation", "gegl:nop",
|
||||
NULL);
|
||||
filter->cast_after = gegl_node_new_child (node,
|
||||
"operation", "gegl:nop",
|
||||
NULL);
|
||||
|
||||
if (gegl_node_has_pad (filter->operation, "input"))
|
||||
{
|
||||
GeglNode *input = gegl_node_get_input_proxy (node, "input");
|
||||
|
||||
gegl_node_link_many (input,
|
||||
filter->translate,
|
||||
filter->crop,
|
||||
filter->cast_before,
|
||||
filter->operation,
|
||||
NULL);
|
||||
}
|
||||
|
||||
gegl_node_link_many (filter->operation,
|
||||
filter->cast_after,
|
||||
NULL);
|
||||
|
||||
gegl_node_connect_to (filter->cast_after, "output",
|
||||
node, "aux");
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_filter_set_region (GimpDrawableFilter *filter,
|
||||
GimpFilterRegion region)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||
|
||||
if (region != filter->region)
|
||||
{
|
||||
filter->region = region;
|
||||
|
||||
gimp_drawable_filter_sync_region (filter);
|
||||
|
||||
if (gimp_drawable_filter_is_filtering (filter))
|
||||
gimp_drawable_filter_update_drawable (filter, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_filter_set_preview (GimpDrawableFilter *filter,
|
||||
gboolean enabled,
|
||||
GimpAlignmentType alignment,
|
||||
gdouble position)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||
g_return_if_fail (alignment == GIMP_ALIGN_LEFT ||
|
||||
alignment == GIMP_ALIGN_RIGHT ||
|
||||
alignment == GIMP_ALIGN_TOP ||
|
||||
alignment == GIMP_ALIGN_BOTTOM);
|
||||
|
||||
position = CLAMP (position, 0.0, 1.0);
|
||||
|
||||
if (enabled != filter->preview_enabled ||
|
||||
alignment != filter->preview_alignment ||
|
||||
position != filter->preview_position)
|
||||
{
|
||||
gboolean old_enabled = filter->preview_enabled;
|
||||
GimpAlignmentType old_alignment = filter->preview_alignment;
|
||||
gdouble old_position = filter->preview_position;
|
||||
|
||||
filter->preview_enabled = enabled;
|
||||
filter->preview_alignment = alignment;
|
||||
filter->preview_position = position;
|
||||
|
||||
gimp_drawable_filter_sync_preview (filter,
|
||||
old_enabled,
|
||||
old_alignment, old_position);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_filter_set_mode (GimpDrawableFilter *filter,
|
||||
gdouble opacity,
|
||||
GimpLayerModeEffects paint_mode)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||
|
||||
if (opacity != filter->opacity ||
|
||||
paint_mode != filter->paint_mode)
|
||||
{
|
||||
filter->opacity = opacity;
|
||||
filter->paint_mode = paint_mode;
|
||||
|
||||
gimp_drawable_filter_sync_mode (filter);
|
||||
|
||||
if (gimp_drawable_filter_is_filtering (filter))
|
||||
gimp_drawable_filter_update_drawable (filter, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_filter_set_gamma_hack (GimpDrawableFilter *filter,
|
||||
gboolean gamma_hack)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||
|
||||
if (gamma_hack != filter->gamma_hack)
|
||||
{
|
||||
filter->gamma_hack = gamma_hack;
|
||||
|
||||
gimp_drawable_filter_sync_gamma_hack (filter);
|
||||
|
||||
if (gimp_drawable_filter_is_filtering (filter))
|
||||
gimp_drawable_filter_update_drawable (filter, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_filter_apply (GimpDrawableFilter *filter,
|
||||
const GeglRectangle *area)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (filter->drawable)));
|
||||
|
||||
gimp_drawable_filter_add_filter (filter);
|
||||
gimp_drawable_filter_update_drawable (filter, area);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_drawable_filter_commit (GimpDrawableFilter *filter,
|
||||
GimpProgress *progress,
|
||||
gboolean cancellable)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE_FILTER (filter), FALSE);
|
||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (filter->drawable)),
|
||||
FALSE);
|
||||
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
|
||||
|
||||
if (gimp_drawable_filter_is_filtering (filter))
|
||||
{
|
||||
success = gimp_drawable_merge_filter (filter->drawable,
|
||||
GIMP_FILTER (filter),
|
||||
progress,
|
||||
gimp_object_get_name (filter),
|
||||
cancellable);
|
||||
|
||||
gimp_drawable_filter_remove_filter (filter);
|
||||
|
||||
g_signal_emit (filter, drawable_filter_signals[FLUSH], 0);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_filter_abort (GimpDrawableFilter *filter)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE_FILTER (filter));
|
||||
|
||||
if (gimp_drawable_filter_remove_filter (filter))
|
||||
{
|
||||
gimp_drawable_filter_update_drawable (filter, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_sync_region (GimpDrawableFilter *filter)
|
||||
{
|
||||
if (filter->region == GIMP_FILTER_REGION_SELECTION)
|
||||
{
|
||||
gegl_node_set (filter->translate,
|
||||
"x", (gdouble) -filter->filter_area.x,
|
||||
"y", (gdouble) -filter->filter_area.y,
|
||||
NULL);
|
||||
|
||||
gegl_node_set (filter->crop,
|
||||
"width", (gdouble) filter->filter_area.width,
|
||||
"height", (gdouble) filter->filter_area.height,
|
||||
NULL);
|
||||
|
||||
gimp_applicator_set_apply_offset (filter->applicator,
|
||||
filter->filter_area.x,
|
||||
filter->filter_area.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (filter->drawable);
|
||||
gdouble width = gimp_item_get_width (item);
|
||||
gdouble height = gimp_item_get_height (item);
|
||||
|
||||
gegl_node_set (filter->translate,
|
||||
"x", (gdouble) 0.0,
|
||||
"y", (gdouble) 0.0,
|
||||
NULL);
|
||||
|
||||
gegl_node_set (filter->crop,
|
||||
"width", width,
|
||||
"height", height,
|
||||
NULL);
|
||||
|
||||
gimp_applicator_set_apply_offset (filter->applicator, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_get_preview_rect (GimpDrawableFilter *filter,
|
||||
gboolean enabled,
|
||||
GimpAlignmentType alignment,
|
||||
gdouble position,
|
||||
GeglRectangle *rect)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->width = gimp_item_get_width (GIMP_ITEM (filter->drawable));
|
||||
rect->height = gimp_item_get_height (GIMP_ITEM (filter->drawable));
|
||||
|
||||
width = rect->width;
|
||||
height = rect->height;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
switch (alignment)
|
||||
{
|
||||
case GIMP_ALIGN_LEFT:
|
||||
rect->width *= position;
|
||||
break;
|
||||
|
||||
case GIMP_ALIGN_RIGHT:
|
||||
rect->width *= (1.0 - position);
|
||||
rect->x = width - rect->width;
|
||||
break;
|
||||
|
||||
case GIMP_ALIGN_TOP:
|
||||
rect->height *= position;
|
||||
break;
|
||||
|
||||
case GIMP_ALIGN_BOTTOM:
|
||||
rect->height *= (1.0 - position);
|
||||
rect->y = height - rect->height;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_sync_preview (GimpDrawableFilter *filter,
|
||||
gboolean old_enabled,
|
||||
GimpAlignmentType old_alignment,
|
||||
gdouble old_position)
|
||||
{
|
||||
GeglRectangle old_rect;
|
||||
GeglRectangle new_rect;
|
||||
|
||||
gimp_drawable_filter_get_preview_rect (filter,
|
||||
old_enabled,
|
||||
old_alignment,
|
||||
old_position,
|
||||
&old_rect);
|
||||
|
||||
gimp_drawable_filter_get_preview_rect (filter,
|
||||
filter->preview_enabled,
|
||||
filter->preview_alignment,
|
||||
filter->preview_position,
|
||||
&new_rect);
|
||||
|
||||
gimp_applicator_set_preview (filter->applicator,
|
||||
filter->preview_enabled,
|
||||
&new_rect);
|
||||
|
||||
if (old_rect.x != new_rect.x ||
|
||||
old_rect.y != new_rect.y ||
|
||||
old_rect.width != new_rect.width ||
|
||||
old_rect.height != new_rect.height)
|
||||
{
|
||||
cairo_region_t *region;
|
||||
gint n_rects;
|
||||
gint i;
|
||||
|
||||
region = cairo_region_create_rectangle ((cairo_rectangle_int_t *)
|
||||
&old_rect);
|
||||
cairo_region_xor_rectangle (region,
|
||||
(cairo_rectangle_int_t *) &new_rect);
|
||||
|
||||
n_rects = cairo_region_num_rectangles (region);
|
||||
|
||||
for (i = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
|
||||
gimp_drawable_filter_update_drawable (filter,
|
||||
(const GeglRectangle *) &rect);
|
||||
}
|
||||
|
||||
cairo_region_destroy (region);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_sync_mode (GimpDrawableFilter *filter)
|
||||
{
|
||||
gimp_applicator_set_mode (filter->applicator,
|
||||
filter->opacity,
|
||||
filter->paint_mode);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_sync_affect (GimpDrawableFilter *filter)
|
||||
{
|
||||
GimpComponentMask active_mask;
|
||||
|
||||
active_mask = gimp_drawable_get_active_mask (filter->drawable);
|
||||
|
||||
/* don't let the filter affect the drawable projection's alpha,
|
||||
* because it can't affect the drawable buffer's alpha either when
|
||||
* finally merged (see bug #699279)
|
||||
*/
|
||||
if (! gimp_drawable_has_alpha (filter->drawable))
|
||||
active_mask &= ~GIMP_COMPONENT_MASK_ALPHA;
|
||||
|
||||
gimp_applicator_set_affect (filter->applicator, active_mask);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_sync_mask (GimpDrawableFilter *filter)
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (filter->drawable));
|
||||
GimpChannel *mask = gimp_image_get_mask (image);
|
||||
|
||||
if (gimp_channel_is_empty (mask))
|
||||
{
|
||||
gimp_applicator_set_mask_buffer (filter->applicator, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GeglBuffer *mask_buffer;
|
||||
gint offset_x, offset_y;
|
||||
|
||||
mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
|
||||
gimp_item_get_offset (GIMP_ITEM (filter->drawable),
|
||||
&offset_x, &offset_y);
|
||||
|
||||
gimp_applicator_set_mask_buffer (filter->applicator, mask_buffer);
|
||||
gimp_applicator_set_mask_offset (filter->applicator,
|
||||
-offset_x, -offset_y);
|
||||
}
|
||||
|
||||
gimp_item_mask_intersect (GIMP_ITEM (filter->drawable),
|
||||
&filter->filter_area.x,
|
||||
&filter->filter_area.y,
|
||||
&filter->filter_area.width,
|
||||
&filter->filter_area.height);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_sync_gamma_hack (GimpDrawableFilter *filter)
|
||||
{
|
||||
if (filter->gamma_hack)
|
||||
{
|
||||
const Babl *drawable_format;
|
||||
const Babl *cast_format;
|
||||
|
||||
drawable_format =
|
||||
gimp_drawable_get_format_with_alpha (filter->drawable);
|
||||
|
||||
cast_format =
|
||||
gimp_babl_format (gimp_babl_format_get_base_type (drawable_format),
|
||||
gimp_babl_precision (gimp_babl_format_get_component_type (drawable_format),
|
||||
! gimp_babl_format_get_linear (drawable_format)),
|
||||
TRUE);
|
||||
|
||||
gegl_node_set (filter->cast_before,
|
||||
"operation", "gegl:cast-format",
|
||||
"input-format", drawable_format,
|
||||
"output-format", cast_format,
|
||||
NULL);
|
||||
|
||||
gegl_node_set (filter->cast_after,
|
||||
"operation", "gegl:cast-format",
|
||||
"input-format", cast_format,
|
||||
"output-format", drawable_format,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gegl_node_set (filter->cast_before,
|
||||
"operation", "gegl:nop",
|
||||
NULL);
|
||||
|
||||
gegl_node_set (filter->cast_after,
|
||||
"operation", "gegl:nop",
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_drawable_filter_is_filtering (GimpDrawableFilter *filter)
|
||||
{
|
||||
return gimp_drawable_has_filter (filter->drawable,
|
||||
GIMP_FILTER (filter));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_drawable_filter_add_filter (GimpDrawableFilter *filter)
|
||||
{
|
||||
if (! gimp_drawable_filter_is_filtering (filter))
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (filter->drawable));
|
||||
|
||||
gimp_viewable_preview_freeze (GIMP_VIEWABLE (filter->drawable));
|
||||
|
||||
gimp_drawable_filter_sync_mask (filter);
|
||||
gimp_drawable_filter_sync_region (filter);
|
||||
gimp_drawable_filter_sync_preview (filter,
|
||||
filter->preview_enabled,
|
||||
filter->preview_alignment,
|
||||
filter->preview_position);
|
||||
gimp_drawable_filter_sync_mode (filter);
|
||||
gimp_drawable_filter_sync_affect (filter);
|
||||
gimp_drawable_filter_sync_gamma_hack (filter);
|
||||
|
||||
gimp_drawable_add_filter (filter->drawable,
|
||||
GIMP_FILTER (filter));
|
||||
|
||||
g_signal_connect (image, "component-active-changed",
|
||||
G_CALLBACK (gimp_drawable_filter_affect_changed),
|
||||
filter);
|
||||
g_signal_connect (image, "mask-changed",
|
||||
G_CALLBACK (gimp_drawable_filter_mask_changed),
|
||||
filter);
|
||||
g_signal_connect (filter->drawable, "removed",
|
||||
G_CALLBACK (gimp_drawable_filter_drawable_removed),
|
||||
filter);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_drawable_filter_remove_filter (GimpDrawableFilter *filter)
|
||||
{
|
||||
if (gimp_drawable_filter_is_filtering (filter))
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (filter->drawable));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (filter->drawable,
|
||||
gimp_drawable_filter_drawable_removed,
|
||||
filter);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_drawable_filter_mask_changed,
|
||||
filter);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_drawable_filter_affect_changed,
|
||||
filter);
|
||||
|
||||
gimp_drawable_remove_filter (filter->drawable,
|
||||
GIMP_FILTER (filter));
|
||||
|
||||
gimp_viewable_preview_thaw (GIMP_VIEWABLE (filter->drawable));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_update_drawable (GimpDrawableFilter *filter,
|
||||
const GeglRectangle *area)
|
||||
{
|
||||
GeglRectangle update_area;
|
||||
|
||||
if (area)
|
||||
{
|
||||
if (! gimp_rectangle_intersect (area->x,
|
||||
area->y,
|
||||
area->width,
|
||||
area->height,
|
||||
filter->filter_area.x,
|
||||
filter->filter_area.y,
|
||||
filter->filter_area.width,
|
||||
filter->filter_area.height,
|
||||
&update_area.x,
|
||||
&update_area.y,
|
||||
&update_area.width,
|
||||
&update_area.height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
update_area = filter->filter_area;
|
||||
}
|
||||
|
||||
if (update_area.width > 0 &&
|
||||
update_area.height > 0)
|
||||
{
|
||||
gimp_drawable_update (filter->drawable,
|
||||
update_area.x,
|
||||
update_area.y,
|
||||
update_area.width,
|
||||
update_area.height);
|
||||
|
||||
g_signal_emit (filter, drawable_filter_signals[FLUSH], 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_affect_changed (GimpImage *image,
|
||||
GimpChannelType channel,
|
||||
GimpDrawableFilter *filter)
|
||||
{
|
||||
gimp_drawable_filter_sync_affect (filter);
|
||||
gimp_drawable_filter_update_drawable (filter, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_mask_changed (GimpImage *image,
|
||||
GimpDrawableFilter *filter)
|
||||
{
|
||||
gimp_drawable_filter_update_drawable (filter, NULL);
|
||||
|
||||
gimp_drawable_filter_sync_mask (filter);
|
||||
gimp_drawable_filter_sync_region (filter);
|
||||
|
||||
gimp_drawable_filter_update_drawable (filter, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_filter_drawable_removed (GimpDrawable *drawable,
|
||||
GimpDrawableFilter *filter)
|
||||
{
|
||||
gimp_drawable_filter_remove_filter (filter);
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/* 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_FILTER_H__
|
||||
#define __GIMP_DRAWABLE_FILTER_H__
|
||||
|
||||
|
||||
#include "gimpfilter.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_DRAWABLE_FILTER (gimp_drawable_filter_get_type ())
|
||||
#define GIMP_DRAWABLE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DRAWABLE_FILTER, GimpDrawableFilter))
|
||||
#define GIMP_DRAWABLE_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_FILTER, GimpDrawableFilterClass))
|
||||
#define GIMP_IS_DRAWABLE_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DRAWABLE_FILTER))
|
||||
#define GIMP_IS_DRAWABLE_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_FILTER))
|
||||
#define GIMP_DRAWABLE_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DRAWABLE_FILTER, GimpDrawableFilterClass))
|
||||
|
||||
|
||||
typedef struct _GimpDrawableFilterClass GimpDrawableFilterClass;
|
||||
|
||||
struct _GimpDrawableFilterClass
|
||||
{
|
||||
GimpFilterClass parent_class;
|
||||
|
||||
void (* flush) (GimpDrawableFilter *filter);
|
||||
};
|
||||
|
||||
|
||||
/* Drawable Filter functions */
|
||||
|
||||
/* Successive apply() functions can be called, but eventually MUST be
|
||||
* followed with an commit() or an abort() call, both of which will
|
||||
* remove the live filter from the drawable.
|
||||
*/
|
||||
|
||||
GType gimp_drawable_filter_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpDrawableFilter *
|
||||
gimp_drawable_filter_new (GimpDrawable *drawable,
|
||||
const gchar *undo_desc,
|
||||
GeglNode *operation,
|
||||
const gchar *icon_name);
|
||||
|
||||
void gimp_drawable_filter_set_region (GimpDrawableFilter *filter,
|
||||
GimpFilterRegion region);
|
||||
void gimp_drawable_filter_set_preview (GimpDrawableFilter *filter,
|
||||
gboolean enabled,
|
||||
GimpAlignmentType alignment,
|
||||
gdouble split_position);
|
||||
void gimp_drawable_filter_set_mode (GimpDrawableFilter *filter,
|
||||
gdouble opacity,
|
||||
GimpLayerModeEffects paint_mode);
|
||||
|
||||
void gimp_drawable_filter_set_gamma_hack (GimpDrawableFilter *filter,
|
||||
gboolean gamma_hack);
|
||||
|
||||
void gimp_drawable_filter_apply (GimpDrawableFilter *filter,
|
||||
const GeglRectangle *area);
|
||||
|
||||
gboolean gimp_drawable_filter_commit (GimpDrawableFilter *filter,
|
||||
GimpProgress *progress,
|
||||
gboolean cancellable);
|
||||
void gimp_drawable_filter_abort (GimpDrawableFilter *filter);
|
||||
|
||||
|
||||
#endif /* __GIMP_DRAWABLE_FILTER_H__ */
|
|
@ -1,768 +0,0 @@
|
|||
/* 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/>.
|
||||
*/
|
||||
|
||||
/* This file contains the code necessary for generating on canvas
|
||||
* previews, by connecting a specified GEGL operation to do the
|
||||
* processing. It uses drawable filters that allow for non-destructive
|
||||
* manupulation of drawable data, with live preview on screen.
|
||||
*
|
||||
* To create a tool that uses this, see /tools/gimpimagemaptool.c for
|
||||
* the interface and /tools/gimpcolorbalancetool.c for an example of
|
||||
* using that interface.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cairo.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gegl/gimp-babl.h"
|
||||
#include "gegl/gimpapplicator.h"
|
||||
|
||||
#include "gimpchannel.h"
|
||||
#include "gimpdrawable-filter.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimagemap.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
FLUSH,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
struct _GimpImageMap
|
||||
{
|
||||
GimpFilter parent_instance;
|
||||
|
||||
GimpDrawable *drawable;
|
||||
GeglNode *operation;
|
||||
|
||||
GimpImageMapRegion region;
|
||||
gboolean preview_enabled;
|
||||
GimpAlignmentType preview_alignment;
|
||||
gdouble preview_position;
|
||||
gdouble opacity;
|
||||
GimpLayerModeEffects paint_mode;
|
||||
gboolean gamma_hack;
|
||||
|
||||
GeglRectangle filter_area;
|
||||
|
||||
GeglNode *translate;
|
||||
GeglNode *crop;
|
||||
GeglNode *cast_before;
|
||||
GeglNode *cast_after;
|
||||
GimpApplicator *applicator;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_image_map_dispose (GObject *object);
|
||||
static void gimp_image_map_finalize (GObject *object);
|
||||
|
||||
static void gimp_image_map_sync_region (GimpImageMap *image_map);
|
||||
static void gimp_image_map_sync_preview (GimpImageMap *image_map,
|
||||
gboolean old_enabled,
|
||||
GimpAlignmentType old_alignment,
|
||||
gdouble old_position);
|
||||
static void gimp_image_map_sync_mode (GimpImageMap *image_map);
|
||||
static void gimp_image_map_sync_affect (GimpImageMap *image_map);
|
||||
static void gimp_image_map_sync_mask (GimpImageMap *image_map);
|
||||
static void gimp_image_map_sync_gamma_hack (GimpImageMap *image_map);
|
||||
|
||||
static gboolean gimp_image_map_is_filtering (GimpImageMap *image_map);
|
||||
static gboolean gimp_image_map_add_filter (GimpImageMap *image_map);
|
||||
static gboolean gimp_image_map_remove_filter (GimpImageMap *image_map);
|
||||
|
||||
static void gimp_image_map_update_drawable (GimpImageMap *image_map,
|
||||
const GeglRectangle *area);
|
||||
|
||||
static void gimp_image_map_affect_changed (GimpImage *image,
|
||||
GimpChannelType channel,
|
||||
GimpImageMap *image_map);
|
||||
static void gimp_image_map_mask_changed (GimpImage *image,
|
||||
GimpImageMap *image_map);
|
||||
static void gimp_image_map_drawable_removed (GimpDrawable *drawable,
|
||||
GimpImageMap *image_map);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpImageMap, gimp_image_map, GIMP_TYPE_FILTER)
|
||||
|
||||
#define parent_class gimp_image_map_parent_class
|
||||
|
||||
static guint image_map_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
|
||||
static void
|
||||
gimp_image_map_class_init (GimpImageMapClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
image_map_signals[FLUSH] =
|
||||
g_signal_new ("flush",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageMapClass, flush),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->dispose = gimp_image_map_dispose;
|
||||
object_class->finalize = gimp_image_map_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_init (GimpImageMap *image_map)
|
||||
{
|
||||
image_map->region = GIMP_IMAGE_MAP_REGION_SELECTION;
|
||||
image_map->preview_alignment = GIMP_ALIGN_LEFT;
|
||||
image_map->preview_position = 1.0;
|
||||
image_map->opacity = GIMP_OPACITY_OPAQUE;
|
||||
image_map->paint_mode = GIMP_REPLACE_MODE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_dispose (GObject *object)
|
||||
{
|
||||
GimpImageMap *image_map = GIMP_IMAGE_MAP (object);
|
||||
|
||||
if (image_map->drawable)
|
||||
gimp_image_map_remove_filter (image_map);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_finalize (GObject *object)
|
||||
{
|
||||
GimpImageMap *image_map = GIMP_IMAGE_MAP (object);
|
||||
|
||||
if (image_map->operation)
|
||||
{
|
||||
g_object_unref (image_map->operation);
|
||||
image_map->operation = NULL;
|
||||
}
|
||||
|
||||
if (image_map->applicator)
|
||||
{
|
||||
g_object_unref (image_map->applicator);
|
||||
image_map->applicator = NULL;
|
||||
}
|
||||
|
||||
if (image_map->drawable)
|
||||
{
|
||||
g_object_unref (image_map->drawable);
|
||||
image_map->drawable = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
GimpImageMap *
|
||||
gimp_image_map_new (GimpDrawable *drawable,
|
||||
const gchar *undo_desc,
|
||||
GeglNode *operation,
|
||||
const gchar *icon_name)
|
||||
{
|
||||
GimpImageMap *image_map;
|
||||
GeglNode *filter_node;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
|
||||
g_return_val_if_fail (GEGL_IS_NODE (operation), NULL);
|
||||
g_return_val_if_fail (gegl_node_has_pad (operation, "output"), NULL);
|
||||
|
||||
image_map = g_object_new (GIMP_TYPE_IMAGE_MAP,
|
||||
"name", undo_desc,
|
||||
"icon-name", icon_name,
|
||||
NULL);
|
||||
|
||||
image_map->drawable = g_object_ref (drawable);
|
||||
image_map->operation = g_object_ref (operation);
|
||||
|
||||
filter_node = gimp_filter_get_node (GIMP_FILTER (image_map));
|
||||
|
||||
gegl_node_add_child (filter_node, operation);
|
||||
|
||||
image_map->applicator =
|
||||
gimp_applicator_new (filter_node,
|
||||
gimp_drawable_get_linear (image_map->drawable),
|
||||
TRUE, TRUE);
|
||||
|
||||
gimp_filter_set_applicator (GIMP_FILTER (image_map),
|
||||
image_map->applicator);
|
||||
|
||||
image_map->translate = gegl_node_new_child (filter_node,
|
||||
"operation", "gegl:translate",
|
||||
NULL);
|
||||
image_map->crop = gegl_node_new_child (filter_node,
|
||||
"operation", "gegl:crop",
|
||||
NULL);
|
||||
|
||||
image_map->cast_before = gegl_node_new_child (filter_node,
|
||||
"operation", "gegl:nop",
|
||||
NULL);
|
||||
image_map->cast_after = gegl_node_new_child (filter_node,
|
||||
"operation", "gegl:nop",
|
||||
NULL);
|
||||
|
||||
if (gegl_node_has_pad (image_map->operation, "input"))
|
||||
{
|
||||
GeglNode *input = gegl_node_get_input_proxy (filter_node, "input");
|
||||
|
||||
gegl_node_link_many (input,
|
||||
image_map->translate,
|
||||
image_map->crop,
|
||||
image_map->cast_before,
|
||||
image_map->operation,
|
||||
NULL);
|
||||
}
|
||||
|
||||
gegl_node_link_many (image_map->operation,
|
||||
image_map->cast_after,
|
||||
NULL);
|
||||
|
||||
gegl_node_connect_to (image_map->cast_after, "output",
|
||||
filter_node, "aux");
|
||||
|
||||
return image_map;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_map_set_region (GimpImageMap *image_map,
|
||||
GimpImageMapRegion region)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
|
||||
|
||||
if (region != image_map->region)
|
||||
{
|
||||
image_map->region = region;
|
||||
|
||||
gimp_image_map_sync_region (image_map);
|
||||
|
||||
if (gimp_image_map_is_filtering (image_map))
|
||||
gimp_image_map_update_drawable (image_map, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_map_set_preview (GimpImageMap *image_map,
|
||||
gboolean enabled,
|
||||
GimpAlignmentType alignment,
|
||||
gdouble position)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
|
||||
g_return_if_fail (alignment == GIMP_ALIGN_LEFT ||
|
||||
alignment == GIMP_ALIGN_RIGHT ||
|
||||
alignment == GIMP_ALIGN_TOP ||
|
||||
alignment == GIMP_ALIGN_BOTTOM);
|
||||
|
||||
position = CLAMP (position, 0.0, 1.0);
|
||||
|
||||
if (enabled != image_map->preview_enabled ||
|
||||
alignment != image_map->preview_alignment ||
|
||||
position != image_map->preview_position)
|
||||
{
|
||||
gboolean old_enabled = image_map->preview_enabled;
|
||||
GimpAlignmentType old_alignment = image_map->preview_alignment;
|
||||
gdouble old_position = image_map->preview_position;
|
||||
|
||||
image_map->preview_enabled = enabled;
|
||||
image_map->preview_alignment = alignment;
|
||||
image_map->preview_position = position;
|
||||
|
||||
gimp_image_map_sync_preview (image_map,
|
||||
old_enabled, old_alignment, old_position);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_map_set_mode (GimpImageMap *image_map,
|
||||
gdouble opacity,
|
||||
GimpLayerModeEffects paint_mode)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
|
||||
|
||||
if (opacity != image_map->opacity ||
|
||||
paint_mode != image_map->paint_mode)
|
||||
{
|
||||
image_map->opacity = opacity;
|
||||
image_map->paint_mode = paint_mode;
|
||||
|
||||
gimp_image_map_sync_mode (image_map);
|
||||
|
||||
if (gimp_image_map_is_filtering (image_map))
|
||||
gimp_image_map_update_drawable (image_map, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_map_set_gamma_hack (GimpImageMap *image_map,
|
||||
gboolean gamma_hack)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
|
||||
|
||||
if (gamma_hack != image_map->gamma_hack)
|
||||
{
|
||||
image_map->gamma_hack = gamma_hack;
|
||||
|
||||
gimp_image_map_sync_gamma_hack (image_map);
|
||||
|
||||
if (gimp_image_map_is_filtering (image_map))
|
||||
gimp_image_map_update_drawable (image_map, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_map_apply (GimpImageMap *image_map,
|
||||
const GeglRectangle *area)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
|
||||
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (image_map->drawable)));
|
||||
|
||||
gimp_image_map_add_filter (image_map);
|
||||
gimp_image_map_update_drawable (image_map, area);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_map_commit (GimpImageMap *image_map,
|
||||
GimpProgress *progress,
|
||||
gboolean cancellable)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE_MAP (image_map), FALSE);
|
||||
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (image_map->drawable)),
|
||||
FALSE);
|
||||
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
|
||||
|
||||
if (gimp_image_map_is_filtering (image_map))
|
||||
{
|
||||
success = gimp_drawable_merge_filter (image_map->drawable,
|
||||
GIMP_FILTER (image_map),
|
||||
progress,
|
||||
gimp_object_get_name (image_map),
|
||||
cancellable);
|
||||
|
||||
gimp_image_map_remove_filter (image_map);
|
||||
|
||||
g_signal_emit (image_map, image_map_signals[FLUSH], 0);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_map_abort (GimpImageMap *image_map)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
|
||||
|
||||
if (gimp_image_map_remove_filter (image_map))
|
||||
{
|
||||
gimp_image_map_update_drawable (image_map, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_image_map_sync_region (GimpImageMap *image_map)
|
||||
{
|
||||
if (image_map->region == GIMP_IMAGE_MAP_REGION_SELECTION)
|
||||
{
|
||||
gegl_node_set (image_map->translate,
|
||||
"x", (gdouble) -image_map->filter_area.x,
|
||||
"y", (gdouble) -image_map->filter_area.y,
|
||||
NULL);
|
||||
|
||||
gegl_node_set (image_map->crop,
|
||||
"width", (gdouble) image_map->filter_area.width,
|
||||
"height", (gdouble) image_map->filter_area.height,
|
||||
NULL);
|
||||
|
||||
gimp_applicator_set_apply_offset (image_map->applicator,
|
||||
image_map->filter_area.x,
|
||||
image_map->filter_area.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (image_map->drawable);
|
||||
gdouble width = gimp_item_get_width (item);
|
||||
gdouble height = gimp_item_get_height (item);
|
||||
|
||||
gegl_node_set (image_map->translate,
|
||||
"x", (gdouble) 0.0,
|
||||
"y", (gdouble) 0.0,
|
||||
NULL);
|
||||
|
||||
gegl_node_set (image_map->crop,
|
||||
"width", width,
|
||||
"height", height,
|
||||
NULL);
|
||||
|
||||
gimp_applicator_set_apply_offset (image_map->applicator, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_get_preview_rect (GimpImageMap *image_map,
|
||||
gboolean enabled,
|
||||
GimpAlignmentType alignment,
|
||||
gdouble position,
|
||||
GeglRectangle *rect)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->width = gimp_item_get_width (GIMP_ITEM (image_map->drawable));
|
||||
rect->height = gimp_item_get_height (GIMP_ITEM (image_map->drawable));
|
||||
|
||||
width = rect->width;
|
||||
height = rect->height;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
switch (alignment)
|
||||
{
|
||||
case GIMP_ALIGN_LEFT:
|
||||
rect->width *= position;
|
||||
break;
|
||||
|
||||
case GIMP_ALIGN_RIGHT:
|
||||
rect->width *= (1.0 - position);
|
||||
rect->x = width - rect->width;
|
||||
break;
|
||||
|
||||
case GIMP_ALIGN_TOP:
|
||||
rect->height *= position;
|
||||
break;
|
||||
|
||||
case GIMP_ALIGN_BOTTOM:
|
||||
rect->height *= (1.0 - position);
|
||||
rect->y = height - rect->height;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_sync_preview (GimpImageMap *image_map,
|
||||
gboolean old_enabled,
|
||||
GimpAlignmentType old_alignment,
|
||||
gdouble old_position)
|
||||
{
|
||||
GeglRectangle old_rect;
|
||||
GeglRectangle new_rect;
|
||||
|
||||
gimp_image_map_get_preview_rect (image_map,
|
||||
old_enabled,
|
||||
old_alignment,
|
||||
old_position,
|
||||
&old_rect);
|
||||
|
||||
gimp_image_map_get_preview_rect (image_map,
|
||||
image_map->preview_enabled,
|
||||
image_map->preview_alignment,
|
||||
image_map->preview_position,
|
||||
&new_rect);
|
||||
|
||||
gimp_applicator_set_preview (image_map->applicator,
|
||||
image_map->preview_enabled,
|
||||
&new_rect);
|
||||
|
||||
if (old_rect.x != new_rect.x ||
|
||||
old_rect.y != new_rect.y ||
|
||||
old_rect.width != new_rect.width ||
|
||||
old_rect.height != new_rect.height)
|
||||
{
|
||||
cairo_region_t *region;
|
||||
gint n_rects;
|
||||
gint i;
|
||||
|
||||
region = cairo_region_create_rectangle ((cairo_rectangle_int_t *)
|
||||
&old_rect);
|
||||
cairo_region_xor_rectangle (region,
|
||||
(cairo_rectangle_int_t *) &new_rect);
|
||||
|
||||
n_rects = cairo_region_num_rectangles (region);
|
||||
|
||||
for (i = 0; i < n_rects; i++)
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
|
||||
gimp_image_map_update_drawable (image_map,
|
||||
(const GeglRectangle *) &rect);
|
||||
}
|
||||
|
||||
cairo_region_destroy (region);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_sync_mode (GimpImageMap *image_map)
|
||||
{
|
||||
gimp_applicator_set_mode (image_map->applicator,
|
||||
image_map->opacity,
|
||||
image_map->paint_mode);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_sync_affect (GimpImageMap *image_map)
|
||||
{
|
||||
GimpComponentMask active_mask;
|
||||
|
||||
active_mask = gimp_drawable_get_active_mask (image_map->drawable);
|
||||
|
||||
/* don't let the filter affect the drawable projection's alpha,
|
||||
* because it can't affect the drawable buffer's alpha either when
|
||||
* finally merged (see bug #699279)
|
||||
*/
|
||||
if (! gimp_drawable_has_alpha (image_map->drawable))
|
||||
active_mask &= ~GIMP_COMPONENT_MASK_ALPHA;
|
||||
|
||||
gimp_applicator_set_affect (image_map->applicator, active_mask);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_sync_mask (GimpImageMap *image_map)
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (image_map->drawable));
|
||||
GimpChannel *mask = gimp_image_get_mask (image);
|
||||
|
||||
if (gimp_channel_is_empty (mask))
|
||||
{
|
||||
gimp_applicator_set_mask_buffer (image_map->applicator, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GeglBuffer *mask_buffer;
|
||||
gint offset_x, offset_y;
|
||||
|
||||
mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
|
||||
gimp_item_get_offset (GIMP_ITEM (image_map->drawable),
|
||||
&offset_x, &offset_y);
|
||||
|
||||
gimp_applicator_set_mask_buffer (image_map->applicator, mask_buffer);
|
||||
gimp_applicator_set_mask_offset (image_map->applicator,
|
||||
-offset_x, -offset_y);
|
||||
}
|
||||
|
||||
gimp_item_mask_intersect (GIMP_ITEM (image_map->drawable),
|
||||
&image_map->filter_area.x,
|
||||
&image_map->filter_area.y,
|
||||
&image_map->filter_area.width,
|
||||
&image_map->filter_area.height);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_sync_gamma_hack (GimpImageMap *image_map)
|
||||
{
|
||||
if (image_map->gamma_hack)
|
||||
{
|
||||
const Babl *drawable_format;
|
||||
const Babl *cast_format;
|
||||
|
||||
drawable_format =
|
||||
gimp_drawable_get_format_with_alpha (image_map->drawable);
|
||||
|
||||
cast_format =
|
||||
gimp_babl_format (gimp_babl_format_get_base_type (drawable_format),
|
||||
gimp_babl_precision (gimp_babl_format_get_component_type (drawable_format),
|
||||
! gimp_babl_format_get_linear (drawable_format)),
|
||||
TRUE);
|
||||
|
||||
gegl_node_set (image_map->cast_before,
|
||||
"operation", "gegl:cast-format",
|
||||
"input-format", drawable_format,
|
||||
"output-format", cast_format,
|
||||
NULL);
|
||||
|
||||
gegl_node_set (image_map->cast_after,
|
||||
"operation", "gegl:cast-format",
|
||||
"input-format", cast_format,
|
||||
"output-format", drawable_format,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gegl_node_set (image_map->cast_before,
|
||||
"operation", "gegl:nop",
|
||||
NULL);
|
||||
|
||||
gegl_node_set (image_map->cast_after,
|
||||
"operation", "gegl:nop",
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_image_map_is_filtering (GimpImageMap *image_map)
|
||||
{
|
||||
return gimp_drawable_has_filter (image_map->drawable,
|
||||
GIMP_FILTER (image_map));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_image_map_add_filter (GimpImageMap *image_map)
|
||||
{
|
||||
if (! gimp_image_map_is_filtering (image_map))
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (image_map->drawable));
|
||||
|
||||
gimp_viewable_preview_freeze (GIMP_VIEWABLE (image_map->drawable));
|
||||
|
||||
gimp_image_map_sync_mask (image_map);
|
||||
gimp_image_map_sync_region (image_map);
|
||||
gimp_image_map_sync_preview (image_map,
|
||||
image_map->preview_enabled,
|
||||
image_map->preview_alignment,
|
||||
image_map->preview_position);
|
||||
gimp_image_map_sync_mode (image_map);
|
||||
gimp_image_map_sync_affect (image_map);
|
||||
gimp_image_map_sync_gamma_hack (image_map);
|
||||
|
||||
gimp_drawable_add_filter (image_map->drawable,
|
||||
GIMP_FILTER (image_map));
|
||||
|
||||
g_signal_connect (image, "component-active-changed",
|
||||
G_CALLBACK (gimp_image_map_affect_changed),
|
||||
image_map);
|
||||
g_signal_connect (image, "mask-changed",
|
||||
G_CALLBACK (gimp_image_map_mask_changed),
|
||||
image_map);
|
||||
g_signal_connect (image_map->drawable, "removed",
|
||||
G_CALLBACK (gimp_image_map_drawable_removed),
|
||||
image_map);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_image_map_remove_filter (GimpImageMap *image_map)
|
||||
{
|
||||
if (gimp_image_map_is_filtering (image_map))
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (image_map->drawable));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (image_map->drawable,
|
||||
gimp_image_map_drawable_removed,
|
||||
image_map);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_image_map_mask_changed,
|
||||
image_map);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_image_map_affect_changed,
|
||||
image_map);
|
||||
|
||||
gimp_drawable_remove_filter (image_map->drawable,
|
||||
GIMP_FILTER (image_map));
|
||||
|
||||
gimp_viewable_preview_thaw (GIMP_VIEWABLE (image_map->drawable));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_update_drawable (GimpImageMap *image_map,
|
||||
const GeglRectangle *area)
|
||||
{
|
||||
GeglRectangle update_area;
|
||||
|
||||
if (area)
|
||||
{
|
||||
if (! gimp_rectangle_intersect (area->x,
|
||||
area->y,
|
||||
area->width,
|
||||
area->height,
|
||||
image_map->filter_area.x,
|
||||
image_map->filter_area.y,
|
||||
image_map->filter_area.width,
|
||||
image_map->filter_area.height,
|
||||
&update_area.x,
|
||||
&update_area.y,
|
||||
&update_area.width,
|
||||
&update_area.height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
update_area = image_map->filter_area;
|
||||
}
|
||||
|
||||
if (update_area.width > 0 &&
|
||||
update_area.height > 0)
|
||||
{
|
||||
gimp_drawable_update (image_map->drawable,
|
||||
update_area.x,
|
||||
update_area.y,
|
||||
update_area.width,
|
||||
update_area.height);
|
||||
|
||||
g_signal_emit (image_map, image_map_signals[FLUSH], 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_affect_changed (GimpImage *image,
|
||||
GimpChannelType channel,
|
||||
GimpImageMap *image_map)
|
||||
{
|
||||
gimp_image_map_sync_affect (image_map);
|
||||
gimp_image_map_update_drawable (image_map, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_mask_changed (GimpImage *image,
|
||||
GimpImageMap *image_map)
|
||||
{
|
||||
gimp_image_map_update_drawable (image_map, NULL);
|
||||
|
||||
gimp_image_map_sync_mask (image_map);
|
||||
gimp_image_map_sync_region (image_map);
|
||||
|
||||
gimp_image_map_update_drawable (image_map, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_drawable_removed (GimpDrawable *drawable,
|
||||
GimpImageMap *image_map)
|
||||
{
|
||||
gimp_image_map_remove_filter (image_map);
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/* 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_IMAGE_MAP_H__
|
||||
#define __GIMP_IMAGE_MAP_H__
|
||||
|
||||
|
||||
#include "gimpfilter.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_IMAGE_MAP (gimp_image_map_get_type ())
|
||||
#define GIMP_IMAGE_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_MAP, GimpImageMap))
|
||||
#define GIMP_IMAGE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_MAP, GimpImageMapClass))
|
||||
#define GIMP_IS_IMAGE_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE_MAP))
|
||||
#define GIMP_IS_IMAGE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_IMAGE_MAP))
|
||||
#define GIMP_IMAGE_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_IMAGE_MAP, GimpImageMapClass))
|
||||
|
||||
|
||||
typedef struct _GimpImageMapClass GimpImageMapClass;
|
||||
|
||||
struct _GimpImageMapClass
|
||||
{
|
||||
GimpFilterClass parent_class;
|
||||
|
||||
void (* flush) (GimpImageMap *image_map);
|
||||
};
|
||||
|
||||
|
||||
/* Image Map functions */
|
||||
|
||||
/* Successive image_map_apply functions can be called, but eventually
|
||||
* MUST be followed with an image_map_commit or an image_map_abort call,
|
||||
* both of which will remove the live filter from the drawable.
|
||||
*/
|
||||
|
||||
GType gimp_image_map_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpImageMap * gimp_image_map_new (GimpDrawable *drawable,
|
||||
const gchar *undo_desc,
|
||||
GeglNode *operation,
|
||||
const gchar *icon_name);
|
||||
|
||||
void gimp_image_map_set_region (GimpImageMap *image_map,
|
||||
GimpImageMapRegion region);
|
||||
void gimp_image_map_set_preview (GimpImageMap *image_map,
|
||||
gboolean enabled,
|
||||
GimpAlignmentType alignment,
|
||||
gdouble split_position);
|
||||
void gimp_image_map_set_mode (GimpImageMap *image_map,
|
||||
gdouble opacity,
|
||||
GimpLayerModeEffects paint_mode);
|
||||
|
||||
void gimp_image_map_set_gamma_hack (GimpImageMap *image_map,
|
||||
gboolean gamma_hack);
|
||||
|
||||
void gimp_image_map_apply (GimpImageMap *image_map,
|
||||
const GeglRectangle *area);
|
||||
|
||||
gboolean gimp_image_map_commit (GimpImageMap *image_map,
|
||||
GimpProgress *progress,
|
||||
gboolean cancellable);
|
||||
void gimp_image_map_abort (GimpImageMap *image_map);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_MAP_H__ */
|
|
@ -25,7 +25,7 @@
|
|||
#include "core-types.h"
|
||||
|
||||
#include "gimpboundary.h"
|
||||
#include "gimpdrawable-filter.h"
|
||||
#include "gimpdrawable-filters.h"
|
||||
#include "gimperror.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-undo.h"
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "dialogs-types.h"
|
||||
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable-filter.h"
|
||||
#include "core/gimpdrawable-filters.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimplayer.h"
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
#include "core/gimp-utils.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawable-blend.h"
|
||||
#include "core/gimpdrawablefilter.h"
|
||||
#include "core/gimperror.h"
|
||||
#include "core/gimpgradient.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimpprogress.h"
|
||||
#include "core/gimpprojection.h"
|
||||
|
||||
|
@ -143,9 +143,9 @@ static void gimp_blend_tool_set_gradient (GimpBlendTool *blend_
|
|||
|
||||
static gboolean gimp_blend_tool_is_shapeburst (GimpBlendTool *blend_tool);
|
||||
|
||||
static void gimp_blend_tool_create_image_map (GimpBlendTool *blend_tool,
|
||||
static void gimp_blend_tool_create_filter (GimpBlendTool *blend_tool,
|
||||
GimpDrawable *drawable);
|
||||
static void gimp_blend_tool_image_map_flush (GimpImageMap *image_map,
|
||||
static void gimp_blend_tool_filter_flush (GimpDrawableFilter *filter,
|
||||
GimpTool *tool);
|
||||
|
||||
|
||||
|
@ -359,7 +359,7 @@ gimp_blend_tool_button_press (GimpTool *tool,
|
|||
blend_tool->grabbed_point != POINT_INIT_MODE)
|
||||
{
|
||||
gimp_blend_tool_update_graph (blend_tool);
|
||||
gimp_image_map_apply (blend_tool->image_map, NULL);
|
||||
gimp_drawable_filter_apply (blend_tool->filter, NULL);
|
||||
}
|
||||
|
||||
gimp_tool_control_activate (tool->control);
|
||||
|
@ -462,7 +462,7 @@ gimp_blend_tool_motion (GimpTool *tool,
|
|||
gimp_blend_tool_update_items (blend_tool);
|
||||
|
||||
gimp_blend_tool_update_graph (blend_tool);
|
||||
gimp_image_map_apply (blend_tool->image_map, NULL);
|
||||
gimp_drawable_filter_apply (blend_tool->filter, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -547,7 +547,7 @@ gimp_blend_tool_active_modifier_key (GimpTool *tool,
|
|||
gimp_blend_tool_update_items (blend_tool);
|
||||
|
||||
gimp_blend_tool_update_graph (blend_tool);
|
||||
gimp_image_map_apply (blend_tool->image_map, NULL);
|
||||
gimp_drawable_filter_apply (blend_tool->filter, NULL);
|
||||
}
|
||||
else if (key == GDK_MOD1_MASK)
|
||||
{
|
||||
|
@ -600,8 +600,8 @@ gimp_blend_tool_options_notify (GimpTool *tool,
|
|||
{
|
||||
gimp_blend_tool_set_gradient (blend_tool, context->gradient);
|
||||
|
||||
if (blend_tool->image_map)
|
||||
gimp_image_map_apply (blend_tool->image_map, NULL);
|
||||
if (blend_tool->filter)
|
||||
gimp_drawable_filter_apply (blend_tool->filter, NULL);
|
||||
}
|
||||
else if (blend_tool->render_node &&
|
||||
gegl_node_find_property (blend_tool->render_node, pspec->name))
|
||||
|
@ -623,15 +623,15 @@ gimp_blend_tool_options_notify (GimpTool *tool,
|
|||
gimp_blend_tool_update_graph (blend_tool);
|
||||
}
|
||||
|
||||
gimp_image_map_apply (blend_tool->image_map, NULL);
|
||||
gimp_drawable_filter_apply (blend_tool->filter, NULL);
|
||||
}
|
||||
else if (blend_tool->image_map &&
|
||||
else if (blend_tool->filter &&
|
||||
(! strcmp (pspec->name, "opacity") ||
|
||||
! strcmp (pspec->name, "paint-mode")))
|
||||
{
|
||||
gimp_image_map_set_mode (blend_tool->image_map,
|
||||
gimp_context_get_opacity (context),
|
||||
gimp_context_get_paint_mode (context));
|
||||
gimp_drawable_filter_set_mode (blend_tool->filter,
|
||||
gimp_context_get_opacity (context),
|
||||
gimp_context_get_paint_mode (context));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -865,7 +865,7 @@ gimp_blend_tool_start (GimpBlendTool *blend_tool,
|
|||
tool->display = display;
|
||||
tool->drawable = drawable;
|
||||
|
||||
gimp_blend_tool_create_image_map (blend_tool, drawable);
|
||||
gimp_blend_tool_create_filter (blend_tool, drawable);
|
||||
|
||||
/* Initially sync all of the properties */
|
||||
gimp_gegl_config_sync_node (GIMP_OBJECT (options), blend_tool->render_node);
|
||||
|
@ -904,11 +904,11 @@ gimp_blend_tool_halt (GimpBlendTool *blend_tool)
|
|||
blend_tool->dist_buffer = NULL;
|
||||
}
|
||||
|
||||
if (blend_tool->image_map)
|
||||
if (blend_tool->filter)
|
||||
{
|
||||
gimp_image_map_abort (blend_tool->image_map);
|
||||
g_object_unref (blend_tool->image_map);
|
||||
blend_tool->image_map = NULL;
|
||||
gimp_drawable_filter_abort (blend_tool->filter);
|
||||
g_object_unref (blend_tool->filter);
|
||||
blend_tool->filter = NULL;
|
||||
|
||||
gimp_image_flush (gimp_display_get_image (tool->display));
|
||||
}
|
||||
|
@ -925,11 +925,12 @@ gimp_blend_tool_commit (GimpBlendTool *blend_tool)
|
|||
{
|
||||
GimpTool *tool = GIMP_TOOL (blend_tool);
|
||||
|
||||
if (blend_tool->image_map)
|
||||
if (blend_tool->filter)
|
||||
{
|
||||
gimp_image_map_commit (blend_tool->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (blend_tool->image_map);
|
||||
blend_tool->image_map = NULL;
|
||||
gimp_drawable_filter_commit (blend_tool->filter,
|
||||
GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (blend_tool->filter);
|
||||
blend_tool->filter = NULL;
|
||||
|
||||
gimp_image_flush (gimp_display_get_image (tool->display));
|
||||
}
|
||||
|
@ -1093,7 +1094,7 @@ gimp_blend_tool_update_graph (GimpBlendTool *blend_tool)
|
|||
static void
|
||||
gimp_blend_tool_gradient_dirty (GimpBlendTool *blend_tool)
|
||||
{
|
||||
if (! blend_tool->image_map)
|
||||
if (! blend_tool->filter)
|
||||
return;
|
||||
|
||||
/* Set a property on the node. Otherwise it will cache and refuse to update */
|
||||
|
@ -1101,8 +1102,8 @@ gimp_blend_tool_gradient_dirty (GimpBlendTool *blend_tool)
|
|||
"gradient", blend_tool->gradient,
|
||||
NULL);
|
||||
|
||||
/* Update the image_map */
|
||||
gimp_image_map_apply (blend_tool->image_map, NULL);
|
||||
/* Update the filter */
|
||||
gimp_drawable_filter_apply (blend_tool->filter, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1164,8 +1165,8 @@ gimp_blend_tool_is_shapeburst (GimpBlendTool *blend_tool)
|
|||
/* image map stuff */
|
||||
|
||||
static void
|
||||
gimp_blend_tool_create_image_map (GimpBlendTool *blend_tool,
|
||||
GimpDrawable *drawable)
|
||||
gimp_blend_tool_create_filter (GimpBlendTool *blend_tool,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
|
||||
GimpContext *context = GIMP_CONTEXT (options);
|
||||
|
@ -1173,26 +1174,26 @@ gimp_blend_tool_create_image_map (GimpBlendTool *blend_tool,
|
|||
if (! blend_tool->graph)
|
||||
gimp_blend_tool_create_graph (blend_tool);
|
||||
|
||||
blend_tool->image_map = gimp_image_map_new (drawable,
|
||||
C_("undo-type", "Blend"),
|
||||
blend_tool->graph,
|
||||
GIMP_STOCK_TOOL_BLEND);
|
||||
blend_tool->filter = gimp_drawable_filter_new (drawable,
|
||||
C_("undo-type", "Blend"),
|
||||
blend_tool->graph,
|
||||
GIMP_STOCK_TOOL_BLEND);
|
||||
|
||||
gimp_image_map_set_region (blend_tool->image_map,
|
||||
GIMP_IMAGE_MAP_REGION_DRAWABLE);
|
||||
gimp_drawable_filter_set_region (blend_tool->filter,
|
||||
GIMP_FILTER_REGION_DRAWABLE);
|
||||
|
||||
g_signal_connect (blend_tool->image_map, "flush",
|
||||
G_CALLBACK (gimp_blend_tool_image_map_flush),
|
||||
g_signal_connect (blend_tool->filter, "flush",
|
||||
G_CALLBACK (gimp_blend_tool_filter_flush),
|
||||
blend_tool);
|
||||
|
||||
gimp_image_map_set_mode (blend_tool->image_map,
|
||||
gimp_context_get_opacity (context),
|
||||
gimp_context_get_paint_mode (context));
|
||||
gimp_drawable_filter_set_mode (blend_tool->filter,
|
||||
gimp_context_get_opacity (context),
|
||||
gimp_context_get_paint_mode (context));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_blend_tool_image_map_flush (GimpImageMap *image_map,
|
||||
GimpTool *tool)
|
||||
gimp_blend_tool_filter_flush (GimpDrawableFilter *filter,
|
||||
GimpTool *tool)
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (tool->display);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ struct _GimpBlendTool
|
|||
#endif
|
||||
GeglNode *dist_node;
|
||||
GeglBuffer *dist_buffer;
|
||||
GimpImageMap *image_map;
|
||||
GimpDrawableFilter *filter;
|
||||
};
|
||||
|
||||
struct _GimpBlendToolClass
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
#include "core/gimpdrawable-shadow.h"
|
||||
#include "core/gimpdrawablefilter.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimpprogress.h"
|
||||
#include "core/gimpprojection.h"
|
||||
|
@ -133,11 +133,11 @@ static gint gimp_cage_tool_is_on_edge (GimpCageTool *ct,
|
|||
static gboolean gimp_cage_tool_is_complete (GimpCageTool *ct);
|
||||
static void gimp_cage_tool_remove_last_handle (GimpCageTool *ct);
|
||||
static void gimp_cage_tool_compute_coef (GimpCageTool *ct);
|
||||
static void gimp_cage_tool_create_image_map (GimpCageTool *ct,
|
||||
static void gimp_cage_tool_create_filter (GimpCageTool *ct,
|
||||
GimpDrawable *drawable);
|
||||
static void gimp_cage_tool_image_map_flush (GimpImageMap *image_map,
|
||||
static void gimp_cage_tool_filter_flush (GimpDrawableFilter *filter,
|
||||
GimpTool *tool);
|
||||
static void gimp_cage_tool_image_map_update (GimpCageTool *ct);
|
||||
static void gimp_cage_tool_filter_update (GimpCageTool *ct);
|
||||
|
||||
static void gimp_cage_tool_create_render_node (GimpCageTool *ct);
|
||||
static void gimp_cage_tool_render_node_update (GimpCageTool *ct);
|
||||
|
@ -254,11 +254,11 @@ gimp_cage_tool_start (GimpCageTool *ct,
|
|||
ct->coef = NULL;
|
||||
}
|
||||
|
||||
if (ct->image_map)
|
||||
if (ct->filter)
|
||||
{
|
||||
gimp_image_map_abort (ct->image_map);
|
||||
g_object_unref (ct->image_map);
|
||||
ct->image_map = NULL;
|
||||
gimp_drawable_filter_abort (ct->filter);
|
||||
g_object_unref (ct->filter);
|
||||
ct->filter = NULL;
|
||||
}
|
||||
|
||||
if (ct->render_node)
|
||||
|
@ -328,15 +328,15 @@ gimp_cage_tool_options_notify (GimpTool *tool,
|
|||
gimp_cage_tool_render_node_update (ct);
|
||||
}
|
||||
|
||||
if (! ct->image_map)
|
||||
if (! ct->filter)
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (tool->display);
|
||||
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||
|
||||
gimp_cage_tool_create_image_map (ct, drawable);
|
||||
gimp_cage_tool_create_filter (ct, drawable);
|
||||
}
|
||||
|
||||
gimp_cage_tool_image_map_update (ct);
|
||||
gimp_cage_tool_filter_update (ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -348,9 +348,9 @@ gimp_cage_tool_options_notify (GimpTool *tool,
|
|||
else
|
||||
{
|
||||
/* switch to edit mode */
|
||||
if (ct->image_map)
|
||||
if (ct->filter)
|
||||
{
|
||||
gimp_image_map_abort (ct->image_map);
|
||||
gimp_drawable_filter_abort (ct->filter);
|
||||
|
||||
gimp_tool_pop_status (tool, tool->display);
|
||||
ct->tool_state = CAGE_STATE_WAIT;
|
||||
|
@ -362,7 +362,7 @@ gimp_cage_tool_options_notify (GimpTool *tool,
|
|||
if (ct->tool_state == DEFORM_STATE_WAIT)
|
||||
{
|
||||
gimp_cage_tool_render_node_update (ct);
|
||||
gimp_cage_tool_image_map_update (ct);
|
||||
gimp_cage_tool_filter_update (ct);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -668,7 +668,7 @@ gimp_cage_tool_button_release (GimpTool *tool,
|
|||
break;
|
||||
|
||||
case DEFORM_STATE_MOVE_HANDLE:
|
||||
gimp_cage_tool_image_map_update (ct);
|
||||
gimp_cage_tool_filter_update (ct);
|
||||
ct->tool_state = DEFORM_STATE_WAIT;
|
||||
break;
|
||||
|
||||
|
@ -727,7 +727,7 @@ gimp_cage_tool_button_release (GimpTool *tool,
|
|||
ct->tool_state = DEFORM_STATE_WAIT;
|
||||
gimp_cage_config_commit_displacement (ct->config);
|
||||
gegl_node_set (ct->cage_node, "config", ct->config, NULL);
|
||||
gimp_cage_tool_image_map_update (ct);
|
||||
gimp_cage_tool_filter_update (ct);
|
||||
break;
|
||||
|
||||
case DEFORM_STATE_SELECTING:
|
||||
|
@ -930,13 +930,13 @@ gimp_cage_tool_halt (GimpCageTool *ct)
|
|||
ct->cage_node = NULL;
|
||||
}
|
||||
|
||||
if (ct->image_map)
|
||||
if (ct->filter)
|
||||
{
|
||||
gimp_tool_control_push_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_map_abort (ct->image_map);
|
||||
g_object_unref (ct->image_map);
|
||||
ct->image_map = NULL;
|
||||
gimp_drawable_filter_abort (ct->filter);
|
||||
g_object_unref (ct->filter);
|
||||
ct->filter = NULL;
|
||||
|
||||
gimp_tool_control_pop_preserve (tool->control);
|
||||
|
||||
|
@ -954,15 +954,15 @@ gimp_cage_tool_halt (GimpCageTool *ct)
|
|||
static void
|
||||
gimp_cage_tool_commit (GimpCageTool *ct)
|
||||
{
|
||||
if (ct->image_map)
|
||||
if (ct->filter)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (ct);
|
||||
|
||||
gimp_tool_control_push_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_map_commit (ct->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (ct->image_map);
|
||||
ct->image_map = NULL;
|
||||
gimp_drawable_filter_commit (ct->filter, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (ct->filter);
|
||||
ct->filter = NULL;
|
||||
|
||||
gimp_tool_control_pop_preserve (tool->control);
|
||||
|
||||
|
@ -1239,25 +1239,25 @@ gimp_cage_tool_render_node_update (GimpCageTool *ct)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_cage_tool_create_image_map (GimpCageTool *ct,
|
||||
GimpDrawable *drawable)
|
||||
gimp_cage_tool_create_filter (GimpCageTool *ct,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
if (!ct->render_node)
|
||||
if (! ct->render_node)
|
||||
gimp_cage_tool_create_render_node (ct);
|
||||
|
||||
ct->image_map = gimp_image_map_new (drawable,
|
||||
_("Cage transform"),
|
||||
ct->render_node,
|
||||
GIMP_STOCK_TOOL_CAGE);
|
||||
ct->filter = gimp_drawable_filter_new (drawable,
|
||||
_("Cage transform"),
|
||||
ct->render_node,
|
||||
GIMP_STOCK_TOOL_CAGE);
|
||||
|
||||
g_signal_connect (ct->image_map, "flush",
|
||||
G_CALLBACK (gimp_cage_tool_image_map_flush),
|
||||
g_signal_connect (ct->filter, "flush",
|
||||
G_CALLBACK (gimp_cage_tool_filter_flush),
|
||||
ct);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_cage_tool_image_map_flush (GimpImageMap *image_map,
|
||||
GimpTool *tool)
|
||||
gimp_cage_tool_filter_flush (GimpDrawableFilter *filter,
|
||||
GimpTool *tool)
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (tool->display);
|
||||
|
||||
|
@ -1265,7 +1265,7 @@ gimp_cage_tool_image_map_flush (GimpImageMap *image_map,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_cage_tool_image_map_update (GimpCageTool *ct)
|
||||
gimp_cage_tool_filter_update (GimpCageTool *ct)
|
||||
{
|
||||
gimp_image_map_apply (ct->image_map, NULL);
|
||||
gimp_drawable_filter_apply (ct->filter, NULL);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ struct _GimpCageTool
|
|||
|
||||
gint tool_state; /* Current state in statemachine */
|
||||
|
||||
GimpImageMap *image_map; /* For preview */
|
||||
GimpDrawableFilter *filter; /* For preview */
|
||||
};
|
||||
|
||||
struct _GimpCageToolClass
|
||||
|
|
|
@ -101,8 +101,8 @@ gimp_filter_options_class_init (GimpFilterOptionsClass *klass)
|
|||
g_object_class_install_property (object_class, PROP_REGION,
|
||||
g_param_spec_enum ("region",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_IMAGE_MAP_REGION,
|
||||
GIMP_IMAGE_MAP_REGION_SELECTION,
|
||||
GIMP_TYPE_FILTER_REGION,
|
||||
GIMP_FILTER_REGION_SELECTION,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
|
|
|
@ -34,16 +34,16 @@ typedef struct _GimpToolOptionsClass GimpFilterOptionsClass;
|
|||
|
||||
struct _GimpFilterOptions
|
||||
{
|
||||
GimpToolOptions parent_instance;
|
||||
GimpToolOptions parent_instance;
|
||||
|
||||
gboolean preview;
|
||||
gboolean preview_split;
|
||||
GimpAlignmentType preview_alignment;
|
||||
gdouble preview_position;
|
||||
GimpImageMapRegion region;
|
||||
gboolean gamma_hack;
|
||||
gboolean preview;
|
||||
gboolean preview_split;
|
||||
GimpAlignmentType preview_alignment;
|
||||
gdouble preview_position;
|
||||
GimpFilterRegion region;
|
||||
gboolean gamma_hack;
|
||||
|
||||
GFile *settings;
|
||||
GFile *settings;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -44,12 +44,12 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawablefilter.h"
|
||||
#include "core/gimperror.h"
|
||||
#include "core/gimpguide.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimpimage-pick-color.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimplist.h"
|
||||
#include "core/gimppickable.h"
|
||||
#include "core/gimpprogress.h"
|
||||
|
@ -134,7 +134,7 @@ static void gimp_filter_tool_dialog_unmap (GtkWidget *dialog,
|
|||
static void gimp_filter_tool_reset (GimpFilterTool *filter_tool);
|
||||
static void gimp_filter_tool_create_map (GimpFilterTool *filter_tool);
|
||||
|
||||
static void gimp_filter_tool_flush (GimpImageMap *filter,
|
||||
static void gimp_filter_tool_flush (GimpDrawableFilter *filter,
|
||||
GimpFilterTool *filter_tool);
|
||||
static void gimp_filter_tool_config_notify (GObject *object,
|
||||
const GParamSpec *pspec,
|
||||
|
@ -687,14 +687,14 @@ gimp_filter_tool_options_notify (GimpTool *tool,
|
|||
{
|
||||
if (filter_options->preview)
|
||||
{
|
||||
gimp_image_map_apply (filter_tool->filter, NULL);
|
||||
gimp_drawable_filter_apply (filter_tool->filter, NULL);
|
||||
|
||||
if (filter_options->preview_split)
|
||||
gimp_filter_tool_add_guide (filter_tool);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_map_abort (filter_tool->filter);
|
||||
gimp_drawable_filter_abort (filter_tool->filter);
|
||||
|
||||
if (filter_options->preview_split)
|
||||
gimp_filter_tool_remove_guide (filter_tool);
|
||||
|
@ -742,10 +742,10 @@ gimp_filter_tool_options_notify (GimpTool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
gimp_image_map_set_preview (filter_tool->filter,
|
||||
filter_options->preview_split,
|
||||
filter_options->preview_alignment,
|
||||
filter_options->preview_position);
|
||||
gimp_drawable_filter_set_preview (filter_tool->filter,
|
||||
filter_options->preview_split,
|
||||
filter_options->preview_alignment,
|
||||
filter_options->preview_position);
|
||||
|
||||
if (filter_options->preview_split)
|
||||
gimp_filter_tool_add_guide (filter_tool);
|
||||
|
@ -755,10 +755,10 @@ gimp_filter_tool_options_notify (GimpTool *tool,
|
|||
else if (! strcmp (pspec->name, "preview-alignment") &&
|
||||
filter_tool->filter)
|
||||
{
|
||||
gimp_image_map_set_preview (filter_tool->filter,
|
||||
filter_options->preview_split,
|
||||
filter_options->preview_alignment,
|
||||
filter_options->preview_position);
|
||||
gimp_drawable_filter_set_preview (filter_tool->filter,
|
||||
filter_options->preview_split,
|
||||
filter_options->preview_alignment,
|
||||
filter_options->preview_position);
|
||||
|
||||
if (filter_options->preview_split)
|
||||
gimp_filter_tool_move_guide (filter_tool);
|
||||
|
@ -766,10 +766,10 @@ gimp_filter_tool_options_notify (GimpTool *tool,
|
|||
else if (! strcmp (pspec->name, "preview-position") &&
|
||||
filter_tool->filter)
|
||||
{
|
||||
gimp_image_map_set_preview (filter_tool->filter,
|
||||
filter_options->preview_split,
|
||||
filter_options->preview_alignment,
|
||||
filter_options->preview_position);
|
||||
gimp_drawable_filter_set_preview (filter_tool->filter,
|
||||
filter_options->preview_split,
|
||||
filter_options->preview_alignment,
|
||||
filter_options->preview_position);
|
||||
|
||||
if (filter_options->preview_split)
|
||||
gimp_filter_tool_move_guide (filter_tool);
|
||||
|
@ -777,14 +777,14 @@ gimp_filter_tool_options_notify (GimpTool *tool,
|
|||
else if (! strcmp (pspec->name, "region") &&
|
||||
filter_tool->filter)
|
||||
{
|
||||
gimp_image_map_set_region (filter_tool->filter,
|
||||
filter_options->region);
|
||||
gimp_drawable_filter_set_region (filter_tool->filter,
|
||||
filter_options->region);
|
||||
}
|
||||
else if (! strcmp (pspec->name, "gamma-hack") &&
|
||||
filter_tool->filter)
|
||||
{
|
||||
gimp_image_map_set_gamma_hack (filter_tool->filter,
|
||||
filter_options->gamma_hack);
|
||||
gimp_drawable_filter_set_gamma_hack (filter_tool->filter,
|
||||
filter_options->gamma_hack);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -863,7 +863,7 @@ gimp_filter_tool_halt (GimpFilterTool *filter_tool)
|
|||
|
||||
if (filter_tool->filter)
|
||||
{
|
||||
gimp_image_map_abort (filter_tool->filter);
|
||||
gimp_drawable_filter_abort (filter_tool->filter);
|
||||
g_object_unref (filter_tool->filter);
|
||||
filter_tool->filter = NULL;
|
||||
|
||||
|
@ -886,11 +886,12 @@ gimp_filter_tool_commit (GimpFilterTool *filter_tool)
|
|||
GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (tool);
|
||||
|
||||
if (! options->preview)
|
||||
gimp_image_map_apply (filter_tool->filter, NULL);
|
||||
gimp_drawable_filter_apply (filter_tool->filter, NULL);
|
||||
|
||||
gimp_tool_control_push_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_map_commit (filter_tool->filter, GIMP_PROGRESS (tool), TRUE);
|
||||
gimp_drawable_filter_commit (filter_tool->filter,
|
||||
GIMP_PROGRESS (tool), TRUE);
|
||||
g_object_unref (filter_tool->filter);
|
||||
filter_tool->filter = NULL;
|
||||
|
||||
|
@ -951,18 +952,18 @@ gimp_filter_tool_create_map (GimpFilterTool *filter_tool)
|
|||
|
||||
if (filter_tool->filter)
|
||||
{
|
||||
gimp_image_map_abort (filter_tool->filter);
|
||||
gimp_drawable_filter_abort (filter_tool->filter);
|
||||
g_object_unref (filter_tool->filter);
|
||||
}
|
||||
|
||||
g_assert (filter_tool->operation);
|
||||
|
||||
filter_tool->filter = gimp_image_map_new (filter_tool->drawable,
|
||||
filter_tool->undo_desc,
|
||||
filter_tool->operation,
|
||||
filter_tool->icon_name);
|
||||
filter_tool->filter = gimp_drawable_filter_new (filter_tool->drawable,
|
||||
filter_tool->undo_desc,
|
||||
filter_tool->operation,
|
||||
filter_tool->icon_name);
|
||||
|
||||
gimp_image_map_set_region (filter_tool->filter, options->region);
|
||||
gimp_drawable_filter_set_region (filter_tool->filter, options->region);
|
||||
|
||||
g_signal_connect (filter_tool->filter, "flush",
|
||||
G_CALLBACK (gimp_filter_tool_flush),
|
||||
|
@ -973,12 +974,12 @@ gimp_filter_tool_create_map (GimpFilterTool *filter_tool)
|
|||
filter_tool->undo_desc);
|
||||
|
||||
if (options->preview)
|
||||
gimp_image_map_apply (filter_tool->filter, NULL);
|
||||
gimp_drawable_filter_apply (filter_tool->filter, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_filter_tool_flush (GimpImageMap *filter,
|
||||
GimpFilterTool *filter_tool)
|
||||
gimp_filter_tool_flush (GimpDrawableFilter *filter,
|
||||
GimpFilterTool *filter_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (filter_tool);
|
||||
GimpImage *image = gimp_display_get_image (tool->display);
|
||||
|
@ -994,7 +995,7 @@ gimp_filter_tool_config_notify (GObject *object,
|
|||
GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
|
||||
|
||||
if (filter_tool->filter && options->preview)
|
||||
gimp_image_map_apply (filter_tool->filter, NULL);
|
||||
gimp_drawable_filter_apply (filter_tool->filter, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1188,7 +1189,7 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
|
|||
|
||||
if (filter_tool->filter)
|
||||
{
|
||||
gimp_image_map_abort (filter_tool->filter);
|
||||
gimp_drawable_filter_abort (filter_tool->filter);
|
||||
g_object_unref (filter_tool->filter);
|
||||
filter_tool->filter = NULL;
|
||||
}
|
||||
|
@ -1302,7 +1303,7 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
|
|||
gtk_widget_hide (filter_tool->region_combo);
|
||||
|
||||
g_object_set (GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool),
|
||||
"region", GIMP_IMAGE_MAP_REGION_SELECTION,
|
||||
"region", GIMP_FILTER_REGION_SELECTION,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ struct _GimpFilterTool
|
|||
gchar *icon_name;
|
||||
gchar *help_id;
|
||||
|
||||
GimpImageMap *filter;
|
||||
GimpDrawableFilter *filter;
|
||||
|
||||
GimpGuide *percent_guide;
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimperror.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimplist.h"
|
||||
#include "core/gimpparamspecs-duplicate.h"
|
||||
#include "core/gimppickable.h"
|
||||
|
@ -396,7 +395,7 @@ gimp_operation_tool_color_picked (GimpFilterTool *filter_tool,
|
|||
|
||||
switch (options->region)
|
||||
{
|
||||
case GIMP_IMAGE_MAP_REGION_SELECTION:
|
||||
case GIMP_FILTER_REGION_SELECTION:
|
||||
if (gimp_item_mask_intersect (GIMP_ITEM (drawable),
|
||||
&off_x, &off_y, &width, &height))
|
||||
{
|
||||
|
@ -405,7 +404,7 @@ gimp_operation_tool_color_picked (GimpFilterTool *filter_tool,
|
|||
}
|
||||
break;
|
||||
|
||||
case GIMP_IMAGE_MAP_REGION_DRAWABLE:
|
||||
case GIMP_FILTER_REGION_DRAWABLE:
|
||||
width = gimp_item_get_width (GIMP_ITEM (drawable));
|
||||
height = gimp_item_get_height (GIMP_ITEM (drawable));
|
||||
break;
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpbuffer.h"
|
||||
#include "core/gimpdrawablefilter.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimpitem.h"
|
||||
#include "core/gimpprogress.h"
|
||||
#include "core/gimpprojection.h"
|
||||
|
@ -161,11 +161,11 @@ static void gimp_seamless_clone_tool_commit (GimpSeamlessClone
|
|||
|
||||
static void gimp_seamless_clone_tool_create_render_node (GimpSeamlessCloneTool *sc);
|
||||
static gboolean gimp_seamless_clone_tool_render_node_update (GimpSeamlessCloneTool *sc);
|
||||
static void gimp_seamless_clone_tool_create_image_map (GimpSeamlessCloneTool *sc,
|
||||
static void gimp_seamless_clone_tool_create_filter (GimpSeamlessCloneTool *sc,
|
||||
GimpDrawable *drawable);
|
||||
static void gimp_seamless_clone_tool_image_map_flush (GimpImageMap *image_map,
|
||||
static void gimp_seamless_clone_tool_filter_flush (GimpDrawableFilter *filter,
|
||||
GimpTool *tool);
|
||||
static void gimp_seamless_clone_tool_image_map_update (GimpSeamlessCloneTool *sc);
|
||||
static void gimp_seamless_clone_tool_filter_update (GimpSeamlessCloneTool *sc);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpSeamlessCloneTool, gimp_seamless_clone_tool,
|
||||
|
@ -308,7 +308,7 @@ gimp_seamless_clone_tool_start (GimpSeamlessCloneTool *sc,
|
|||
|
||||
tool->display = display;
|
||||
|
||||
gimp_seamless_clone_tool_create_image_map (sc, drawable);
|
||||
gimp_seamless_clone_tool_create_filter (sc, drawable);
|
||||
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (sc), display);
|
||||
|
||||
|
@ -359,11 +359,11 @@ gimp_seamless_clone_tool_stop (GimpSeamlessCloneTool *sc,
|
|||
}
|
||||
|
||||
/* This should always happen, even when we just switch a display */
|
||||
if (sc->image_map)
|
||||
if (sc->filter)
|
||||
{
|
||||
gimp_image_map_abort (sc->image_map);
|
||||
g_object_unref (sc->image_map);
|
||||
sc->image_map = NULL;
|
||||
gimp_drawable_filter_abort (sc->filter);
|
||||
g_object_unref (sc->filter);
|
||||
sc->filter = NULL;
|
||||
|
||||
if (GIMP_TOOL (sc)->display)
|
||||
gimp_image_flush (gimp_display_get_image (GIMP_TOOL (sc)->display));
|
||||
|
@ -377,13 +377,13 @@ gimp_seamless_clone_tool_commit (GimpSeamlessCloneTool *sc)
|
|||
{
|
||||
GimpTool *tool = GIMP_TOOL (sc);
|
||||
|
||||
if (sc->image_map)
|
||||
if (sc->filter)
|
||||
{
|
||||
gimp_tool_control_push_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_map_commit (sc->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (sc->image_map);
|
||||
sc->image_map = NULL;
|
||||
gimp_drawable_filter_commit (sc->filter, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (sc->filter);
|
||||
sc->filter = NULL;
|
||||
|
||||
gimp_tool_control_pop_preserve (tool->control);
|
||||
|
||||
|
@ -431,7 +431,7 @@ gimp_seamless_clone_tool_button_press (GimpTool *tool,
|
|||
|
||||
if (gimp_seamless_clone_tool_render_node_update (sc))
|
||||
{
|
||||
gimp_seamless_clone_tool_image_map_update (sc);
|
||||
gimp_seamless_clone_tool_filter_update (sc);
|
||||
}
|
||||
|
||||
sc->tool_state = SC_STATE_RENDER_MOTION;
|
||||
|
@ -475,7 +475,7 @@ gimp_seamless_clone_tool_button_release (GimpTool *tool,
|
|||
|
||||
if (gimp_seamless_clone_tool_render_node_update (sc))
|
||||
{
|
||||
gimp_seamless_clone_tool_image_map_update (sc);
|
||||
gimp_seamless_clone_tool_filter_update (sc);
|
||||
}
|
||||
|
||||
sc->tool_state = SC_STATE_RENDER_WAIT;
|
||||
|
@ -502,7 +502,7 @@ gimp_seamless_clone_tool_motion (GimpTool *tool,
|
|||
|
||||
if (gimp_seamless_clone_tool_render_node_update (sc))
|
||||
{
|
||||
gimp_seamless_clone_tool_image_map_update (sc);
|
||||
gimp_seamless_clone_tool_filter_update (sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -531,9 +531,9 @@ gimp_seamless_clone_tool_key_press (GimpTool *tool,
|
|||
* rectangle each time (in the update function) or by
|
||||
* invalidating and re-rendering all now (expensive and
|
||||
* perhaps useless */
|
||||
gimp_image_map_commit (sct->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (sct->image_map);
|
||||
sct->image_map = NULL;
|
||||
gimp_drawable_filter_commit (sct->filter, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (sct->filter);
|
||||
sct->filter = NULL;
|
||||
|
||||
gimp_tool_control_set_preserve (tool->control, FALSE);
|
||||
|
||||
|
@ -622,7 +622,7 @@ gimp_seamless_clone_tool_options_notify (GimpTool *tool,
|
|||
{
|
||||
if (gimp_seamless_clone_tool_render_node_update (sc))
|
||||
{
|
||||
gimp_seamless_clone_tool_image_map_update (sc);
|
||||
gimp_seamless_clone_tool_filter_update (sc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,27 +753,27 @@ gimp_seamless_clone_tool_render_node_update (GimpSeamlessCloneTool *sc)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_seamless_clone_tool_create_image_map (GimpSeamlessCloneTool *sc,
|
||||
GimpDrawable *drawable)
|
||||
gimp_seamless_clone_tool_create_filter (GimpSeamlessCloneTool *sc,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
if (! sc->render_node)
|
||||
gimp_seamless_clone_tool_create_render_node (sc);
|
||||
|
||||
sc->image_map = gimp_image_map_new (drawable,
|
||||
_("Seamless Clone"),
|
||||
sc->render_node,
|
||||
GIMP_STOCK_TOOL_SEAMLESS_CLONE);
|
||||
sc->filter = gimp_drawable_filter_new (drawable,
|
||||
_("Seamless Clone"),
|
||||
sc->render_node,
|
||||
GIMP_STOCK_TOOL_SEAMLESS_CLONE);
|
||||
|
||||
gimp_image_map_set_region (sc->image_map, GIMP_IMAGE_MAP_REGION_DRAWABLE);
|
||||
gimp_drawable_filter_set_region (sc->filter, GIMP_FILTER_REGION_DRAWABLE);
|
||||
|
||||
g_signal_connect (sc->image_map, "flush",
|
||||
G_CALLBACK (gimp_seamless_clone_tool_image_map_flush),
|
||||
g_signal_connect (sc->filter, "flush",
|
||||
G_CALLBACK (gimp_seamless_clone_tool_filter_flush),
|
||||
sc);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_seamless_clone_tool_image_map_flush (GimpImageMap *image_map,
|
||||
GimpTool *tool)
|
||||
gimp_seamless_clone_tool_filter_flush (GimpDrawableFilter *filter,
|
||||
GimpTool *tool)
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (tool->display);
|
||||
|
||||
|
@ -781,7 +781,7 @@ gimp_seamless_clone_tool_image_map_flush (GimpImageMap *image_map,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_seamless_clone_tool_image_map_update (GimpSeamlessCloneTool *sc)
|
||||
gimp_seamless_clone_tool_filter_update (GimpSeamlessCloneTool *sc)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (sc);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
|
@ -819,7 +819,7 @@ gimp_seamless_clone_tool_image_map_update (GimpSeamlessCloneTool *sc)
|
|||
&visible.width,
|
||||
&visible.height);
|
||||
|
||||
/* Since the image_map_apply function receives a rectangle describing
|
||||
/* Since the filter_apply function receives a rectangle describing
|
||||
* where it should update the preview, and since that rectangle should
|
||||
* be relative to the drawable's location, we now offset back by the
|
||||
* drawable's offsetts. */
|
||||
|
@ -835,7 +835,7 @@ gimp_seamless_clone_tool_image_map_update (GimpSeamlessCloneTool *sc)
|
|||
g_object_unref (op);
|
||||
|
||||
/* Now update the image map and show this area */
|
||||
gimp_image_map_apply (sc->image_map, NULL);
|
||||
gimp_drawable_filter_apply (sc->filter, NULL);
|
||||
|
||||
/* Show update progress. */
|
||||
output = gegl_node_get_output_proxy (sc->render_node, "output");
|
||||
|
|
|
@ -55,7 +55,7 @@ struct _GimpSeamlessCloneTool
|
|||
gint tool_state; /* The current state in the tool's
|
||||
* state machine */
|
||||
|
||||
GimpImageMap *image_map; /* The image map object which renders
|
||||
GimpDrawableFilter *filter; /* The filter object which renders
|
||||
* the live preview, and commits it
|
||||
* when at the end */
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpchannel.h"
|
||||
#include "core/gimpdrawablefilter.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimpprogress.h"
|
||||
#include "core/gimpprojection.h"
|
||||
|
@ -108,14 +108,14 @@ static void gimp_warp_tool_commit (GimpWarpTool *wt);
|
|||
static gboolean gimp_warp_tool_stroke_timer (GimpWarpTool *wt);
|
||||
|
||||
static void gimp_warp_tool_create_graph (GimpWarpTool *wt);
|
||||
static void gimp_warp_tool_create_image_map (GimpWarpTool *wt,
|
||||
static void gimp_warp_tool_create_filter (GimpWarpTool *wt,
|
||||
GimpDrawable *drawable);
|
||||
static void gimp_warp_tool_update_stroke (GimpWarpTool *wt,
|
||||
GeglNode *node);
|
||||
static void gimp_warp_tool_stroke_changed (GeglPath *stroke,
|
||||
const GeglRectangle *roi,
|
||||
GimpWarpTool *wt);
|
||||
static void gimp_warp_tool_image_map_flush (GimpImageMap *image_map,
|
||||
static void gimp_warp_tool_filter_flush (GimpDrawableFilter *filter,
|
||||
GimpTool *tool);
|
||||
static void gimp_warp_tool_add_op (GimpWarpTool *wt,
|
||||
GeglNode *op);
|
||||
|
@ -603,7 +603,7 @@ gimp_warp_tool_start (GimpWarpTool *wt,
|
|||
|
||||
wt->coords_buffer = gegl_buffer_new (&bbox, format);
|
||||
|
||||
gimp_warp_tool_create_image_map (wt, drawable);
|
||||
gimp_warp_tool_create_filter (wt, drawable);
|
||||
|
||||
if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (wt)))
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (wt), display);
|
||||
|
@ -639,11 +639,11 @@ gimp_warp_tool_halt (GimpWarpTool *wt)
|
|||
wt->render_node = NULL;
|
||||
}
|
||||
|
||||
if (wt->image_map)
|
||||
if (wt->filter)
|
||||
{
|
||||
gimp_image_map_abort (wt->image_map);
|
||||
g_object_unref (wt->image_map);
|
||||
wt->image_map = NULL;
|
||||
gimp_drawable_filter_abort (wt->filter);
|
||||
g_object_unref (wt->filter);
|
||||
wt->filter = NULL;
|
||||
|
||||
gimp_image_flush (gimp_display_get_image (tool->display));
|
||||
}
|
||||
|
@ -675,13 +675,13 @@ gimp_warp_tool_commit (GimpWarpTool *wt)
|
|||
{
|
||||
GimpTool *tool = GIMP_TOOL (wt);
|
||||
|
||||
if (wt->image_map)
|
||||
if (wt->filter)
|
||||
{
|
||||
gimp_tool_control_push_preserve (tool->control, TRUE);
|
||||
|
||||
gimp_image_map_commit (wt->image_map, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (wt->image_map);
|
||||
wt->image_map = NULL;
|
||||
gimp_drawable_filter_commit (wt->filter, GIMP_PROGRESS (tool), FALSE);
|
||||
g_object_unref (wt->filter);
|
||||
wt->filter = NULL;
|
||||
|
||||
gimp_tool_control_pop_preserve (tool->control);
|
||||
|
||||
|
@ -741,25 +741,25 @@ gimp_warp_tool_create_graph (GimpWarpTool *wt)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_warp_tool_create_image_map (GimpWarpTool *wt,
|
||||
GimpDrawable *drawable)
|
||||
gimp_warp_tool_create_filter (GimpWarpTool *wt,
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
if (! wt->graph)
|
||||
gimp_warp_tool_create_graph (wt);
|
||||
|
||||
wt->image_map = gimp_image_map_new (drawable,
|
||||
_("Warp transform"),
|
||||
wt->graph,
|
||||
GIMP_STOCK_TOOL_WARP);
|
||||
wt->filter = gimp_drawable_filter_new (drawable,
|
||||
_("Warp transform"),
|
||||
wt->graph,
|
||||
GIMP_STOCK_TOOL_WARP);
|
||||
|
||||
gimp_image_map_set_region (wt->image_map, GIMP_IMAGE_MAP_REGION_DRAWABLE);
|
||||
gimp_drawable_filter_set_region (wt->filter, GIMP_FILTER_REGION_DRAWABLE);
|
||||
|
||||
#if 0
|
||||
g_object_set (wt->image_map, "gegl-caching", TRUE, NULL);
|
||||
g_object_set (wt->filter, "gegl-caching", TRUE, NULL);
|
||||
#endif
|
||||
|
||||
g_signal_connect (wt->image_map, "flush",
|
||||
G_CALLBACK (gimp_warp_tool_image_map_flush),
|
||||
g_signal_connect (wt->filter, "flush",
|
||||
G_CALLBACK (gimp_warp_tool_filter_flush),
|
||||
wt);
|
||||
}
|
||||
|
||||
|
@ -797,7 +797,7 @@ gimp_warp_tool_update_stroke (GimpWarpTool *wt,
|
|||
bbox.width, bbox.height);
|
||||
#endif
|
||||
|
||||
gimp_image_map_apply (wt->image_map, &bbox);
|
||||
gimp_drawable_filter_apply (wt->filter, &bbox);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -820,12 +820,12 @@ gimp_warp_tool_stroke_changed (GeglPath *path,
|
|||
update_region.width, update_region.height);
|
||||
#endif
|
||||
|
||||
gimp_image_map_apply (wt->image_map, &update_region);
|
||||
gimp_drawable_filter_apply (wt->filter, &update_region);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_warp_tool_image_map_flush (GimpImageMap *image_map,
|
||||
GimpTool *tool)
|
||||
gimp_warp_tool_filter_flush (GimpDrawableFilter *filter,
|
||||
GimpTool *tool)
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (tool->display);
|
||||
|
||||
|
@ -890,11 +890,11 @@ gimp_warp_tool_animate (GimpWarpTool *wt)
|
|||
}
|
||||
|
||||
/* get rid of the image map so we can use wt->graph */
|
||||
if (wt->image_map)
|
||||
if (wt->filter)
|
||||
{
|
||||
gimp_image_map_abort (wt->image_map);
|
||||
g_object_unref (wt->image_map);
|
||||
wt->image_map = NULL;
|
||||
gimp_drawable_filter_abort (wt->filter);
|
||||
g_object_unref (wt->filter);
|
||||
wt->filter = NULL;
|
||||
}
|
||||
|
||||
gimp_progress_start (GIMP_PROGRESS (tool), FALSE,
|
||||
|
@ -966,8 +966,8 @@ gimp_warp_tool_animate (GimpWarpTool *wt)
|
|||
gimp_progress_end (GIMP_PROGRESS (tool));
|
||||
|
||||
/* recreate the image map */
|
||||
gimp_warp_tool_create_image_map (wt, tool->drawable);
|
||||
gimp_image_map_apply (wt->image_map, NULL);
|
||||
gimp_warp_tool_create_filter (wt, tool->drawable);
|
||||
gimp_drawable_filter_apply (wt->filter, NULL);
|
||||
|
||||
widget = GTK_WIDGET (gimp_display_get_shell (tool->display));
|
||||
gimp_create_display (orig_image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
|
|
|
@ -39,22 +39,22 @@ typedef struct _GimpWarpToolClass GimpWarpToolClass;
|
|||
|
||||
struct _GimpWarpTool
|
||||
{
|
||||
GimpDrawTool parent_instance;
|
||||
GimpDrawTool parent_instance;
|
||||
|
||||
gdouble cursor_x; /* Hold the cursor x position */
|
||||
gdouble cursor_y; /* Hold the cursor y position */
|
||||
gdouble cursor_x; /* Hold the cursor x position */
|
||||
gdouble cursor_y; /* Hold the cursor y position */
|
||||
|
||||
GeglBuffer *coords_buffer; /* Gegl buffer where coordinates are stored */
|
||||
GeglBuffer *coords_buffer; /* Buffer where coordinates are stored */
|
||||
|
||||
GeglNode *graph; /* Top level GeglNode */
|
||||
GeglNode *render_node; /* Gegl node to render the transformation */
|
||||
GeglNode *graph; /* Top level GeglNode */
|
||||
GeglNode *render_node; /* Node to render the transformation */
|
||||
|
||||
GeglPath *current_stroke;
|
||||
guint stroke_timer;
|
||||
GeglPath *current_stroke;
|
||||
guint stroke_timer;
|
||||
|
||||
GimpImageMap *image_map;
|
||||
GimpDrawableFilter *filter;
|
||||
|
||||
GList *redo_stack;
|
||||
GList *redo_stack;
|
||||
};
|
||||
|
||||
struct _GimpWarpToolClass
|
||||
|
|
Loading…
Reference in New Issue