2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-06-30 23:31:32 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-06-30 23:31:32 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1998-06-30 23:31:32 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1998-06-30 23:31:32 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2011-04-28 21:50:39 +08:00
|
|
|
#include <cairo.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2010-03-18 06:21:33 +08:00
|
|
|
#include <gegl-plugin.h>
|
2012-05-03 09:36:22 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2006-08-29 22:46:32 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
#include "gegl/gimpapplicator.h"
|
2012-04-22 05:55:40 +08:00
|
|
|
#include "gegl/gimp-babl.h"
|
2012-10-22 22:14:56 +08:00
|
|
|
#include "gegl/gimp-gegl-apply-operation.h"
|
2010-06-07 01:54:44 +08:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
|
|
|
|
2012-03-30 19:03:51 +08:00
|
|
|
#include "gimp-utils.h"
|
2001-02-02 02:44:22 +08:00
|
|
|
#include "gimpchannel.h"
|
2001-07-08 06:49:01 +08:00
|
|
|
#include "gimpcontext.h"
|
2003-10-06 22:40:12 +08:00
|
|
|
#include "gimpdrawable-combine.h"
|
2013-04-12 21:53:19 +08:00
|
|
|
#include "gimpdrawable-filter.h"
|
2001-02-07 08:06:58 +08:00
|
|
|
#include "gimpdrawable-preview.h"
|
2009-02-04 07:57:11 +08:00
|
|
|
#include "gimpdrawable-private.h"
|
2008-04-22 01:20:51 +08:00
|
|
|
#include "gimpdrawable-shadow.h"
|
2003-05-13 21:57:11 +08:00
|
|
|
#include "gimpdrawable-transform.h"
|
2013-04-12 01:06:23 +08:00
|
|
|
#include "gimpfilterstack.h"
|
2000-12-30 08:16:50 +08:00
|
|
|
#include "gimpimage.h"
|
2006-04-07 17:21:18 +08:00
|
|
|
#include "gimpimage-colormap.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
#include "gimpimage-undo-push.h"
|
2004-04-13 21:54:54 +08:00
|
|
|
#include "gimplayer.h"
|
2001-11-23 07:46:13 +08:00
|
|
|
#include "gimpmarshal.h"
|
2004-01-06 22:02:08 +08:00
|
|
|
#include "gimppattern.h"
|
2004-07-14 07:04:05 +08:00
|
|
|
#include "gimppickable.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "gimpprogress.h"
|
2001-05-25 01:09:57 +08:00
|
|
|
|
2010-01-03 06:41:52 +08:00
|
|
|
#include "gimp-log.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
UPDATE,
|
2003-05-21 19:34:00 +08:00
|
|
|
ALPHA_CHANGED,
|
1998-06-30 23:31:32 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2012-11-12 17:55:41 +08:00
|
|
|
enum
|
|
|
|
{
|
2013-04-11 09:14:33 +08:00
|
|
|
PROP_0
|
2012-11-12 17:55:41 +08:00
|
|
|
};
|
|
|
|
|
2001-01-20 21:21:49 +08:00
|
|
|
|
2001-07-11 20:39:49 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
static void gimp_drawable_pickable_iface_init (GimpPickableInterface *iface);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2011-09-24 01:55:24 +08:00
|
|
|
static void gimp_drawable_dispose (GObject *object);
|
2003-02-11 21:52:47 +08:00
|
|
|
static void gimp_drawable_finalize (GObject *object);
|
2012-11-12 17:55:41 +08:00
|
|
|
static void gimp_drawable_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_drawable_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2003-11-17 01:51:36 +08:00
|
|
|
static gint64 gimp_drawable_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2005-05-25 18:05:17 +08:00
|
|
|
static gboolean gimp_drawable_get_size (GimpViewable *viewable,
|
|
|
|
gint *width,
|
|
|
|
gint *height);
|
2003-02-11 21:52:47 +08:00
|
|
|
|
2013-04-11 08:54:42 +08:00
|
|
|
static GeglNode * gimp_drawable_get_node (GimpFilter *filter);
|
|
|
|
|
2008-04-22 01:20:51 +08:00
|
|
|
static void gimp_drawable_removed (GimpItem *item);
|
2008-10-15 02:32:07 +08:00
|
|
|
static void gimp_drawable_visibility_changed (GimpItem *item);
|
2003-02-11 21:52:47 +08:00
|
|
|
static GimpItem * gimp_drawable_duplicate (GimpItem *item,
|
2008-01-08 19:46:15 +08:00
|
|
|
GType new_type);
|
2003-05-07 19:09:00 +08:00
|
|
|
static void gimp_drawable_scale (GimpItem *item,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint new_offset_x,
|
|
|
|
gint new_offset_y,
|
2004-02-09 08:09:20 +08:00
|
|
|
GimpInterpolationType interp_type,
|
2007-12-04 19:30:31 +08:00
|
|
|
GimpProgress *progress);
|
2003-05-07 21:01:17 +08:00
|
|
|
static void gimp_drawable_resize (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-07 21:01:17 +08:00
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y);
|
2003-05-13 21:57:11 +08:00
|
|
|
static void gimp_drawable_flip (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-13 21:57:11 +08:00
|
|
|
GimpOrientationType flip_type,
|
|
|
|
gdouble axis,
|
|
|
|
gboolean clip_result);
|
2003-05-20 18:36:29 +08:00
|
|
|
static void gimp_drawable_rotate (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-20 18:36:29 +08:00
|
|
|
GimpRotationType rotate_type,
|
|
|
|
gdouble center_x,
|
|
|
|
gdouble center_y,
|
|
|
|
gboolean clip_result);
|
2003-05-13 21:57:11 +08:00
|
|
|
static void gimp_drawable_transform (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-07-07 21:50:48 +08:00
|
|
|
const GimpMatrix3 *matrix,
|
2007-12-04 19:30:31 +08:00
|
|
|
GimpTransformDirection direction,
|
|
|
|
GimpInterpolationType interpolation_type,
|
2004-03-14 01:45:58 +08:00
|
|
|
gint recursion_level,
|
2007-12-04 19:30:31 +08:00
|
|
|
GimpTransformResize clip_result,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2007-04-28 00:07:49 +08:00
|
|
|
static gboolean gimp_drawable_get_pixel_at (GimpPickable *pickable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
2012-04-21 16:03:32 +08:00
|
|
|
const Babl *format,
|
|
|
|
gpointer pixel);
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
static void gimp_drawable_real_update (GimpDrawable *drawable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
|
|
|
|
2007-12-04 19:30:31 +08:00
|
|
|
static gint64 gimp_drawable_real_estimate_memsize (const GimpDrawable *drawable,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
|
|
|
|
2009-09-12 03:23:35 +08:00
|
|
|
static void gimp_drawable_real_convert_type (GimpDrawable *drawable,
|
|
|
|
GimpImage *dest_image,
|
2012-10-14 04:56:32 +08:00
|
|
|
const Babl *new_format,
|
2009-09-14 01:24:19 +08:00
|
|
|
GimpImageBaseType new_base_type,
|
2012-04-25 18:09:45 +08:00
|
|
|
GimpPrecision new_precision,
|
2012-10-14 03:46:56 +08:00
|
|
|
gint layer_dither_type,
|
|
|
|
gint mask_dither_type,
|
2009-09-14 01:24:19 +08:00
|
|
|
gboolean push_undo);
|
2009-09-12 03:23:35 +08:00
|
|
|
|
2012-03-22 07:07:48 +08:00
|
|
|
static GeglBuffer * gimp_drawable_real_get_buffer (GimpDrawable *drawable);
|
2012-03-22 06:37:16 +08:00
|
|
|
static void gimp_drawable_real_set_buffer (GimpDrawable *drawable,
|
2004-03-13 21:56:09 +08:00
|
|
|
gboolean push_undo,
|
|
|
|
const gchar *undo_desc,
|
2012-03-22 06:37:16 +08:00
|
|
|
GeglBuffer *buffer,
|
2004-03-16 03:34:35 +08:00
|
|
|
gint offset_x,
|
|
|
|
gint offset_y);
|
2004-03-13 21:56:09 +08:00
|
|
|
|
2004-04-01 22:51:58 +08:00
|
|
|
static void gimp_drawable_real_push_undo (GimpDrawable *drawable,
|
|
|
|
const gchar *undo_desc,
|
2012-03-22 21:13:17 +08:00
|
|
|
GeglBuffer *buffer,
|
2004-04-01 22:51:58 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height);
|
2004-03-15 22:10:30 +08:00
|
|
|
static void gimp_drawable_real_swap_pixels (GimpDrawable *drawable,
|
2012-03-22 21:13:17 +08:00
|
|
|
GeglBuffer *buffer,
|
2004-03-15 22:10:30 +08:00
|
|
|
gint x,
|
2012-03-22 21:25:45 +08:00
|
|
|
gint y);
|
2004-03-15 22:10:30 +08:00
|
|
|
|
2013-04-12 01:06:23 +08:00
|
|
|
static void gimp_drawable_sync_fs_filter (GimpDrawable *drawable,
|
2009-01-27 06:05:07 +08:00
|
|
|
gboolean detach_fs);
|
|
|
|
static void gimp_drawable_fs_notify (GimpLayer *fs,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpDrawable *drawable);
|
2013-04-13 00:26:34 +08:00
|
|
|
static void gimp_drawable_fs_affect_changed (GimpImage *image,
|
2013-04-12 21:53:19 +08:00
|
|
|
GimpChannelType channel,
|
|
|
|
GimpDrawable *drawable);
|
2013-04-13 00:26:34 +08:00
|
|
|
static void gimp_drawable_fs_mask_changed (GimpImage *image,
|
|
|
|
GimpDrawable *drawable);
|
2009-08-31 23:37:22 +08:00
|
|
|
static void gimp_drawable_fs_update (GimpLayer *fs,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpDrawable *drawable);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2001-01-10 08:36:54 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpDrawable, gimp_drawable, GIMP_TYPE_ITEM,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
|
2006-05-15 17:46:31 +08:00
|
|
|
gimp_drawable_pickable_iface_init))
|
2001-01-20 21:21:49 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
#define parent_class gimp_drawable_parent_class
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
static guint gimp_drawable_signals[LAST_SIGNAL] = { 0 };
|
2000-12-29 00:19:55 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
|
|
|
|
static void
|
2000-12-29 00:19:55 +08:00
|
|
|
gimp_drawable_class_init (GimpDrawableClass *klass)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2004-07-14 18:31:59 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
2013-04-11 08:54:42 +08:00
|
|
|
GimpFilterClass *filter_class = GIMP_FILTER_CLASS (klass);
|
2004-07-14 18:31:59 +08:00
|
|
|
GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
|
2001-01-10 08:36:54 +08:00
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
gimp_drawable_signals[UPDATE] =
|
|
|
|
g_signal_new ("update",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDrawableClass, update),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__INT_INT_INT_INT,
|
|
|
|
G_TYPE_NONE, 4,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT);
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
|
2003-05-21 19:34:00 +08:00
|
|
|
gimp_drawable_signals[ALPHA_CHANGED] =
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_new ("alpha-changed",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDrawableClass, alpha_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2003-05-21 19:34:00 +08:00
|
|
|
|
2011-09-24 01:55:24 +08:00
|
|
|
object_class->dispose = gimp_drawable_dispose;
|
2001-08-11 22:39:19 +08:00
|
|
|
object_class->finalize = gimp_drawable_finalize;
|
2012-11-12 17:55:41 +08:00
|
|
|
object_class->set_property = gimp_drawable_set_property;
|
|
|
|
object_class->get_property = gimp_drawable_get_property;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2002-01-31 00:14:26 +08:00
|
|
|
gimp_object_class->get_memsize = gimp_drawable_get_memsize;
|
2001-01-10 11:13:03 +08:00
|
|
|
|
2005-05-25 18:05:17 +08:00
|
|
|
viewable_class->get_size = gimp_drawable_get_size;
|
2012-06-21 03:44:09 +08:00
|
|
|
viewable_class->get_new_preview = gimp_drawable_get_new_preview;
|
2001-02-05 06:10:54 +08:00
|
|
|
|
2013-04-11 08:54:42 +08:00
|
|
|
filter_class->get_node = gimp_drawable_get_node;
|
|
|
|
|
2008-04-22 01:20:51 +08:00
|
|
|
item_class->removed = gimp_drawable_removed;
|
2008-10-15 02:32:07 +08:00
|
|
|
item_class->visibility_changed = gimp_drawable_visibility_changed;
|
2003-02-11 21:52:47 +08:00
|
|
|
item_class->duplicate = gimp_drawable_duplicate;
|
2003-05-07 19:09:00 +08:00
|
|
|
item_class->scale = gimp_drawable_scale;
|
2003-05-07 21:01:17 +08:00
|
|
|
item_class->resize = gimp_drawable_resize;
|
2003-05-13 21:57:11 +08:00
|
|
|
item_class->flip = gimp_drawable_flip;
|
2003-05-20 18:36:29 +08:00
|
|
|
item_class->rotate = gimp_drawable_rotate;
|
2003-05-13 21:57:11 +08:00
|
|
|
item_class->transform = gimp_drawable_transform;
|
2003-02-11 21:52:47 +08:00
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
klass->update = gimp_drawable_real_update;
|
2003-05-21 19:34:00 +08:00
|
|
|
klass->alpha_changed = NULL;
|
2007-12-04 19:30:31 +08:00
|
|
|
klass->estimate_memsize = gimp_drawable_real_estimate_memsize;
|
2003-09-04 19:33:06 +08:00
|
|
|
klass->invalidate_boundary = NULL;
|
2003-10-06 22:40:12 +08:00
|
|
|
klass->get_active_components = NULL;
|
2012-04-26 05:23:31 +08:00
|
|
|
klass->get_active_mask = NULL;
|
2009-09-12 03:23:35 +08:00
|
|
|
klass->convert_type = gimp_drawable_real_convert_type;
|
2012-03-23 06:45:11 +08:00
|
|
|
klass->apply_buffer = gimp_drawable_real_apply_buffer;
|
2012-03-23 19:31:21 +08:00
|
|
|
klass->replace_buffer = gimp_drawable_real_replace_buffer;
|
2012-03-22 07:07:48 +08:00
|
|
|
klass->get_buffer = gimp_drawable_real_get_buffer;
|
2012-03-22 06:37:16 +08:00
|
|
|
klass->set_buffer = gimp_drawable_real_set_buffer;
|
2004-04-01 22:51:58 +08:00
|
|
|
klass->push_undo = gimp_drawable_real_push_undo;
|
2004-03-15 22:10:30 +08:00
|
|
|
klass->swap_pixels = gimp_drawable_real_swap_pixels;
|
2009-02-04 07:57:11 +08:00
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (GimpDrawablePrivate));
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
2001-01-20 21:21:49 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_init (GimpDrawable *drawable)
|
|
|
|
{
|
2010-06-08 16:10:04 +08:00
|
|
|
drawable->private = G_TYPE_INSTANCE_GET_PRIVATE (drawable,
|
|
|
|
GIMP_TYPE_DRAWABLE,
|
|
|
|
GimpDrawablePrivate);
|
2013-04-12 01:06:23 +08:00
|
|
|
|
|
|
|
drawable->private->filter_stack = gimp_filter_stack_new (GIMP_TYPE_FILTER);
|
2001-01-20 21:21:49 +08:00
|
|
|
}
|
|
|
|
|
2006-11-25 06:41:03 +08:00
|
|
|
/* sorry for the evil casts */
|
|
|
|
|
2004-07-14 07:04:05 +08:00
|
|
|
static void
|
2005-12-11 03:24:36 +08:00
|
|
|
gimp_drawable_pickable_iface_init (GimpPickableInterface *iface)
|
2004-07-14 07:04:05 +08:00
|
|
|
{
|
2012-03-18 23:20:01 +08:00
|
|
|
iface->get_image = (GimpImage * (*) (GimpPickable *pickable)) gimp_item_get_image;
|
|
|
|
iface->get_format = (const Babl * (*) (GimpPickable *pickable)) gimp_drawable_get_format;
|
|
|
|
iface->get_format_with_alpha = (const Babl * (*) (GimpPickable *pickable)) gimp_drawable_get_format_with_alpha;
|
2012-03-21 07:42:44 +08:00
|
|
|
iface->get_buffer = (GeglBuffer * (*) (GimpPickable *pickable)) gimp_drawable_get_buffer;
|
2012-03-18 23:20:01 +08:00
|
|
|
iface->get_pixel_at = gimp_drawable_get_pixel_at;
|
2004-07-14 07:04:05 +08:00
|
|
|
}
|
|
|
|
|
2001-01-20 21:21:49 +08:00
|
|
|
static void
|
2011-09-24 01:55:24 +08:00
|
|
|
gimp_drawable_dispose (GObject *object)
|
2001-01-20 21:21:49 +08:00
|
|
|
{
|
2003-09-02 21:43:26 +08:00
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (object);
|
2001-01-20 21:21:49 +08:00
|
|
|
|
2011-09-24 01:55:24 +08:00
|
|
|
if (gimp_drawable_get_floating_sel (drawable))
|
|
|
|
gimp_drawable_detach_floating_sel (drawable);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (object);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2012-03-21 07:42:44 +08:00
|
|
|
if (drawable->private->buffer)
|
2012-03-15 09:42:59 +08:00
|
|
|
{
|
2012-03-21 07:42:44 +08:00
|
|
|
g_object_unref (drawable->private->buffer);
|
|
|
|
drawable->private->buffer = NULL;
|
2012-03-15 09:42:59 +08:00
|
|
|
}
|
|
|
|
|
2012-03-23 02:10:12 +08:00
|
|
|
gimp_drawable_free_shadow_buffer (drawable);
|
2012-03-22 04:26:05 +08:00
|
|
|
|
2009-02-04 07:57:11 +08:00
|
|
|
if (drawable->private->source_node)
|
2008-10-10 04:44:23 +08:00
|
|
|
{
|
2009-02-04 07:57:11 +08:00
|
|
|
g_object_unref (drawable->private->source_node);
|
|
|
|
drawable->private->source_node = NULL;
|
2008-10-10 04:44:23 +08:00
|
|
|
}
|
|
|
|
|
2013-04-12 01:06:23 +08:00
|
|
|
if (drawable->private->filter_stack)
|
|
|
|
{
|
|
|
|
g_object_unref (drawable->private->filter_stack);
|
|
|
|
drawable->private->filter_stack = NULL;
|
|
|
|
}
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-01-20 21:21:49 +08:00
|
|
|
}
|
|
|
|
|
2012-11-12 17:55:41 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-17 01:51:36 +08:00
|
|
|
static gint64
|
2003-08-25 18:49:33 +08:00
|
|
|
gimp_drawable_get_memsize (GimpObject *object,
|
2003-11-17 01:51:36 +08:00
|
|
|
gint64 *gui_size)
|
2002-01-31 00:14:26 +08:00
|
|
|
{
|
2004-07-14 18:31:59 +08:00
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (object);
|
|
|
|
gint64 memsize = 0;
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2012-03-22 07:07:48 +08:00
|
|
|
memsize += gimp_gegl_buffer_get_memsize (gimp_drawable_get_buffer (drawable));
|
2012-03-23 02:10:12 +08:00
|
|
|
memsize += gimp_gegl_buffer_get_memsize (drawable->private->shadow);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
}
|
|
|
|
|
2005-05-25 18:05:17 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_drawable_get_size (GimpViewable *viewable,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
|
|
|
{
|
|
|
|
GimpItem *item = GIMP_ITEM (viewable);
|
|
|
|
|
2008-11-03 08:09:01 +08:00
|
|
|
*width = gimp_item_get_width (item);
|
|
|
|
*height = gimp_item_get_height (item);
|
2005-05-25 18:05:17 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-04-11 08:54:42 +08:00
|
|
|
static GeglNode *
|
|
|
|
gimp_drawable_get_node (GimpFilter *filter)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (filter);
|
|
|
|
GeglNode *node;
|
|
|
|
GeglNode *input;
|
|
|
|
GeglNode *output;
|
|
|
|
|
|
|
|
node = GIMP_FILTER_CLASS (parent_class)->get_node (filter);
|
|
|
|
|
|
|
|
g_warn_if_fail (drawable->private->mode_node == NULL);
|
|
|
|
|
|
|
|
drawable->private->mode_node =
|
|
|
|
gegl_node_new_child (node,
|
|
|
|
"operation", "gimp:normal-mode",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
input = gegl_node_get_input_proxy (node, "input");
|
|
|
|
output = gegl_node_get_output_proxy (node, "output");
|
|
|
|
|
|
|
|
if (gimp_item_get_visible (GIMP_ITEM (drawable)))
|
|
|
|
{
|
|
|
|
gegl_node_connect_to (input, "output",
|
|
|
|
drawable->private->mode_node, "input");
|
|
|
|
gegl_node_connect_to (drawable->private->mode_node, "output",
|
|
|
|
output, "input");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gegl_node_connect_to (input, "output",
|
|
|
|
output, "input");
|
|
|
|
}
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2008-04-22 01:20:51 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_removed (GimpItem *item)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
|
|
|
|
2012-03-23 02:10:12 +08:00
|
|
|
gimp_drawable_free_shadow_buffer (drawable);
|
2008-04-22 01:20:51 +08:00
|
|
|
|
|
|
|
if (GIMP_ITEM_CLASS (parent_class)->removed)
|
|
|
|
GIMP_ITEM_CLASS (parent_class)->removed (item);
|
|
|
|
}
|
|
|
|
|
2008-10-15 02:32:07 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_visibility_changed (GimpItem *item)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
2010-12-20 03:39:18 +08:00
|
|
|
GeglNode *node;
|
2008-10-15 02:32:07 +08:00
|
|
|
|
2013-04-11 08:54:42 +08:00
|
|
|
/* don't use gimp_filter_get_node() because that would create
|
2009-02-13 23:35:13 +08:00
|
|
|
* the node.
|
|
|
|
*/
|
2013-04-11 08:54:42 +08:00
|
|
|
node = gimp_filter_peek_node (GIMP_FILTER (item));
|
2010-02-14 20:55:45 +08:00
|
|
|
|
2010-12-20 03:39:18 +08:00
|
|
|
if (node)
|
2008-10-15 02:32:07 +08:00
|
|
|
{
|
2010-12-20 03:39:18 +08:00
|
|
|
GeglNode *input = gegl_node_get_input_proxy (node, "input");
|
|
|
|
GeglNode *output = gegl_node_get_output_proxy (node, "output");
|
2008-10-15 02:32:07 +08:00
|
|
|
|
2012-04-05 19:59:16 +08:00
|
|
|
if (gimp_item_get_visible (item))
|
2008-10-15 02:32:07 +08:00
|
|
|
{
|
2009-02-04 07:57:11 +08:00
|
|
|
gegl_node_connect_to (input, "output",
|
|
|
|
drawable->private->mode_node, "input");
|
|
|
|
gegl_node_connect_to (drawable->private->mode_node, "output",
|
|
|
|
output, "input");
|
2008-10-15 02:32:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-04 07:57:11 +08:00
|
|
|
gegl_node_disconnect (drawable->private->mode_node, "input");
|
2009-01-27 05:20:03 +08:00
|
|
|
|
|
|
|
gegl_node_connect_to (input, "output",
|
|
|
|
output, "input");
|
2008-10-15 02:32:07 +08:00
|
|
|
}
|
2009-01-27 05:20:03 +08:00
|
|
|
|
2009-07-20 17:53:02 +08:00
|
|
|
/* FIXME: chain up again when above floating sel special case is gone */
|
2009-01-27 05:20:03 +08:00
|
|
|
return;
|
2008-10-15 02:32:07 +08:00
|
|
|
}
|
|
|
|
|
2008-11-17 08:06:23 +08:00
|
|
|
GIMP_ITEM_CLASS (parent_class)->visibility_changed (item);
|
2008-10-15 02:32:07 +08:00
|
|
|
}
|
|
|
|
|
2003-02-11 21:52:47 +08:00
|
|
|
static GimpItem *
|
|
|
|
gimp_drawable_duplicate (GimpItem *item,
|
2008-01-08 19:46:15 +08:00
|
|
|
GType new_type)
|
2001-12-13 07:48:18 +08:00
|
|
|
{
|
2005-12-23 09:15:19 +08:00
|
|
|
GimpItem *new_item;
|
2001-12-13 07:48:18 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
|
|
|
|
|
2008-01-08 19:46:15 +08:00
|
|
|
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
|
2003-02-11 21:52:47 +08:00
|
|
|
|
2005-12-23 09:15:19 +08:00
|
|
|
if (GIMP_IS_DRAWABLE (new_item))
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
|
|
|
GimpDrawable *new_drawable = GIMP_DRAWABLE (new_item);
|
2011-02-01 17:46:53 +08:00
|
|
|
|
2012-03-22 04:26:05 +08:00
|
|
|
if (new_drawable->private->buffer)
|
|
|
|
g_object_unref (new_drawable->private->buffer);
|
2005-12-23 09:15:19 +08:00
|
|
|
|
2012-03-22 04:26:05 +08:00
|
|
|
new_drawable->private->buffer =
|
2012-06-21 03:44:09 +08:00
|
|
|
gegl_buffer_dup (gimp_drawable_get_buffer (drawable));
|
2005-12-23 09:15:19 +08:00
|
|
|
}
|
2001-12-13 07:48:18 +08:00
|
|
|
|
2003-02-11 21:52:47 +08:00
|
|
|
return new_item;
|
|
|
|
}
|
|
|
|
|
2003-05-07 19:09:00 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_scale (GimpItem *item,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint new_offset_x,
|
|
|
|
gint new_offset_y,
|
2004-02-09 08:09:20 +08:00
|
|
|
GimpInterpolationType interpolation_type,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress)
|
2003-05-07 19:09:00 +08:00
|
|
|
{
|
2004-03-16 04:05:31 +08:00
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
2012-03-22 04:46:03 +08:00
|
|
|
GeglBuffer *new_buffer;
|
2003-05-07 19:09:00 +08:00
|
|
|
|
2012-06-21 03:44:09 +08:00
|
|
|
new_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
new_width, new_height),
|
|
|
|
gimp_drawable_get_format (drawable));
|
2003-05-07 19:09:00 +08:00
|
|
|
|
2012-11-01 06:47:45 +08:00
|
|
|
gimp_gegl_apply_scale (gimp_drawable_get_buffer (drawable),
|
|
|
|
progress, C_("undo-type", "Scale"),
|
|
|
|
new_buffer,
|
|
|
|
interpolation_type,
|
|
|
|
((gdouble) new_width /
|
|
|
|
gimp_item_get_width (item)),
|
|
|
|
((gdouble) new_height /
|
|
|
|
gimp_item_get_height (item)));
|
2003-05-07 19:09:00 +08:00
|
|
|
|
2012-03-22 04:46:03 +08:00
|
|
|
gimp_drawable_set_buffer_full (drawable, gimp_item_is_attached (item), NULL,
|
2012-03-22 06:37:16 +08:00
|
|
|
new_buffer,
|
2012-03-22 04:46:03 +08:00
|
|
|
new_offset_x, new_offset_y);
|
|
|
|
g_object_unref (new_buffer);
|
2003-05-07 19:09:00 +08:00
|
|
|
}
|
|
|
|
|
2003-05-07 21:01:17 +08:00
|
|
|
static void
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_drawable_resize (GimpItem *item,
|
|
|
|
GimpContext *context,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
2003-05-07 21:01:17 +08:00
|
|
|
{
|
2004-03-16 04:05:31 +08:00
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
2012-03-21 17:10:20 +08:00
|
|
|
GeglBuffer *new_buffer;
|
2003-05-14 23:32:07 +08:00
|
|
|
gint new_offset_x;
|
|
|
|
gint new_offset_y;
|
|
|
|
gint copy_x, copy_y;
|
|
|
|
gint copy_width, copy_height;
|
2003-05-07 21:01:17 +08:00
|
|
|
|
2004-11-23 17:32:54 +08:00
|
|
|
/* if the size doesn't change, this is a nop */
|
2008-11-03 08:09:01 +08:00
|
|
|
if (new_width == gimp_item_get_width (item) &&
|
|
|
|
new_height == gimp_item_get_height (item) &&
|
2007-12-24 00:58:41 +08:00
|
|
|
offset_x == 0 &&
|
2004-11-26 22:45:10 +08:00
|
|
|
offset_y == 0)
|
2004-11-23 17:32:54 +08:00
|
|
|
return;
|
|
|
|
|
2008-12-28 20:43:07 +08:00
|
|
|
new_offset_x = gimp_item_get_offset_x (item) - offset_x;
|
|
|
|
new_offset_y = gimp_item_get_offset_y (item) - offset_y;
|
2003-05-07 21:01:17 +08:00
|
|
|
|
2008-12-28 20:43:07 +08:00
|
|
|
gimp_rectangle_intersect (gimp_item_get_offset_x (item),
|
|
|
|
gimp_item_get_offset_y (item),
|
|
|
|
gimp_item_get_width (item),
|
2008-11-03 08:09:01 +08:00
|
|
|
gimp_item_get_height (item),
|
2008-12-28 20:43:07 +08:00
|
|
|
new_offset_x,
|
|
|
|
new_offset_y,
|
|
|
|
new_width,
|
|
|
|
new_height,
|
|
|
|
©_x,
|
|
|
|
©_y,
|
|
|
|
©_width,
|
|
|
|
©_height);
|
2003-05-07 21:01:17 +08:00
|
|
|
|
2012-06-21 03:44:09 +08:00
|
|
|
new_buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
new_width, new_height),
|
|
|
|
gimp_drawable_get_format (drawable));
|
2012-03-16 09:21:26 +08:00
|
|
|
|
2003-05-14 23:32:07 +08:00
|
|
|
if (copy_width != new_width ||
|
|
|
|
copy_height != new_height)
|
2003-05-07 21:01:17 +08:00
|
|
|
{
|
2012-03-16 09:21:26 +08:00
|
|
|
/* Clear the new tiles if needed */
|
2003-05-14 23:32:07 +08:00
|
|
|
|
2012-03-18 23:52:07 +08:00
|
|
|
GimpRGB bg;
|
2012-03-16 09:21:26 +08:00
|
|
|
GeglColor *col;
|
2003-05-07 21:01:17 +08:00
|
|
|
|
2003-05-14 23:32:07 +08:00
|
|
|
if (! gimp_drawable_has_alpha (drawable) && ! GIMP_IS_CHANNEL (drawable))
|
2012-03-18 23:52:07 +08:00
|
|
|
gimp_context_get_background (context, &bg);
|
|
|
|
else
|
|
|
|
gimp_rgba_set (&bg, 0.0, 0.0, 0.0, 0.0);
|
2003-05-14 23:32:07 +08:00
|
|
|
|
2012-03-20 17:27:28 +08:00
|
|
|
col = gimp_gegl_color_new (&bg);
|
2012-03-16 09:21:26 +08:00
|
|
|
|
2012-03-21 17:10:20 +08:00
|
|
|
gegl_buffer_set_color (new_buffer, NULL, col);
|
2012-03-16 09:21:26 +08:00
|
|
|
g_object_unref (col);
|
2003-05-07 21:01:17 +08:00
|
|
|
}
|
|
|
|
|
2003-05-14 23:32:07 +08:00
|
|
|
if (copy_width && copy_height)
|
2003-05-07 21:01:17 +08:00
|
|
|
{
|
2012-03-16 09:21:26 +08:00
|
|
|
/* Copy the pixels in the intersection */
|
2012-03-21 10:57:53 +08:00
|
|
|
gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (copy_x - gimp_item_get_offset_x (item),
|
2012-03-21 10:57:53 +08:00
|
|
|
copy_y - gimp_item_get_offset_y (item),
|
|
|
|
copy_width,
|
|
|
|
copy_height),
|
2012-03-21 17:10:20 +08:00
|
|
|
new_buffer,
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (copy_x - new_offset_x,
|
2012-03-21 10:57:53 +08:00
|
|
|
copy_y - new_offset_y, 0, 0));
|
2003-05-07 21:01:17 +08:00
|
|
|
}
|
|
|
|
|
2012-03-21 17:10:20 +08:00
|
|
|
gimp_drawable_set_buffer_full (drawable, gimp_item_is_attached (item), NULL,
|
2012-03-22 06:37:16 +08:00
|
|
|
new_buffer,
|
2012-03-21 17:10:20 +08:00
|
|
|
new_offset_x, new_offset_y);
|
|
|
|
g_object_unref (new_buffer);
|
2003-05-07 21:01:17 +08:00
|
|
|
}
|
|
|
|
|
2003-05-13 21:57:11 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_flip (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-13 21:57:11 +08:00
|
|
|
GimpOrientationType flip_type,
|
|
|
|
gdouble axis,
|
|
|
|
gboolean clip_result)
|
|
|
|
{
|
2004-04-13 19:43:27 +08:00
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
2012-03-21 21:30:47 +08:00
|
|
|
GeglBuffer *buffer;
|
2003-05-13 21:57:11 +08:00
|
|
|
gint off_x, off_y;
|
2011-03-26 15:30:15 +08:00
|
|
|
gint new_off_x, new_off_y;
|
2003-05-13 21:57:11 +08:00
|
|
|
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (item, &off_x, &off_y);
|
2003-05-13 21:57:11 +08:00
|
|
|
|
2012-03-21 21:30:47 +08:00
|
|
|
buffer = gimp_drawable_transform_buffer_flip (drawable, context,
|
|
|
|
gimp_drawable_get_buffer (drawable),
|
|
|
|
off_x, off_y,
|
|
|
|
flip_type, axis,
|
|
|
|
clip_result,
|
|
|
|
&new_off_x, &new_off_y);
|
2003-05-13 21:57:11 +08:00
|
|
|
|
2012-03-21 21:30:47 +08:00
|
|
|
if (buffer)
|
2003-05-27 01:02:06 +08:00
|
|
|
{
|
2012-03-21 21:30:47 +08:00
|
|
|
gimp_drawable_transform_paste (drawable, buffer,
|
2011-03-26 15:30:15 +08:00
|
|
|
new_off_x, new_off_y, FALSE);
|
2012-03-21 21:30:47 +08:00
|
|
|
g_object_unref (buffer);
|
2003-05-27 01:02:06 +08:00
|
|
|
}
|
2003-05-13 21:57:11 +08:00
|
|
|
}
|
|
|
|
|
2003-05-20 18:36:29 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_rotate (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-20 18:36:29 +08:00
|
|
|
GimpRotationType rotate_type,
|
|
|
|
gdouble center_x,
|
|
|
|
gdouble center_y,
|
|
|
|
gboolean clip_result)
|
|
|
|
{
|
2004-04-13 19:43:27 +08:00
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
2012-03-21 21:30:47 +08:00
|
|
|
GeglBuffer *buffer;
|
2003-05-20 18:36:29 +08:00
|
|
|
gint off_x, off_y;
|
2011-03-26 15:30:15 +08:00
|
|
|
gint new_off_x, new_off_y;
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (item, &off_x, &off_y);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2012-03-21 21:30:47 +08:00
|
|
|
buffer = gimp_drawable_transform_buffer_rotate (drawable, context,
|
|
|
|
gimp_drawable_get_buffer (drawable),
|
|
|
|
off_x, off_y,
|
|
|
|
rotate_type, center_x, center_y,
|
|
|
|
clip_result,
|
|
|
|
&new_off_x, &new_off_y);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2012-03-21 21:30:47 +08:00
|
|
|
if (buffer)
|
2003-05-27 01:02:06 +08:00
|
|
|
{
|
2012-03-21 21:30:47 +08:00
|
|
|
gimp_drawable_transform_paste (drawable, buffer,
|
2011-03-26 15:30:15 +08:00
|
|
|
new_off_x, new_off_y, FALSE);
|
2012-03-21 21:30:47 +08:00
|
|
|
g_object_unref (buffer);
|
2003-05-27 01:02:06 +08:00
|
|
|
}
|
2003-05-20 18:36:29 +08:00
|
|
|
}
|
|
|
|
|
2003-05-13 21:57:11 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_transform (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-07-07 21:50:48 +08:00
|
|
|
const GimpMatrix3 *matrix,
|
2003-05-13 21:57:11 +08:00
|
|
|
GimpTransformDirection direction,
|
|
|
|
GimpInterpolationType interpolation_type,
|
2004-03-14 01:45:58 +08:00
|
|
|
gint recursion_level,
|
2006-12-25 00:48:08 +08:00
|
|
|
GimpTransformResize clip_result,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress)
|
2003-05-13 21:57:11 +08:00
|
|
|
{
|
2004-04-13 19:43:27 +08:00
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
2012-03-21 21:30:47 +08:00
|
|
|
GeglBuffer *buffer;
|
2003-05-13 21:57:11 +08:00
|
|
|
gint off_x, off_y;
|
2011-03-26 15:30:15 +08:00
|
|
|
gint new_off_x, new_off_y;
|
2003-05-13 21:57:11 +08:00
|
|
|
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (item, &off_x, &off_y);
|
2003-05-13 21:57:11 +08:00
|
|
|
|
2012-03-21 21:30:47 +08:00
|
|
|
buffer = gimp_drawable_transform_buffer_affine (drawable, context,
|
|
|
|
gimp_drawable_get_buffer (drawable),
|
|
|
|
off_x, off_y,
|
|
|
|
matrix, direction,
|
|
|
|
interpolation_type,
|
|
|
|
recursion_level,
|
|
|
|
clip_result,
|
|
|
|
&new_off_x, &new_off_y,
|
|
|
|
progress);
|
|
|
|
|
|
|
|
if (buffer)
|
2003-05-27 01:02:06 +08:00
|
|
|
{
|
2012-03-21 21:30:47 +08:00
|
|
|
gimp_drawable_transform_paste (drawable, buffer,
|
2011-03-26 23:50:38 +08:00
|
|
|
new_off_x, new_off_y, FALSE);
|
2012-03-21 21:30:47 +08:00
|
|
|
g_object_unref (buffer);
|
2003-05-27 01:02:06 +08:00
|
|
|
}
|
2003-05-13 21:57:11 +08:00
|
|
|
}
|
|
|
|
|
2007-04-28 00:07:49 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_drawable_get_pixel_at (GimpPickable *pickable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
2012-04-21 16:03:32 +08:00
|
|
|
const Babl *format,
|
|
|
|
gpointer pixel)
|
2007-04-28 00:07:49 +08:00
|
|
|
{
|
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (pickable);
|
|
|
|
|
|
|
|
/* do not make this a g_return_if_fail() */
|
2008-11-03 08:09:01 +08:00
|
|
|
if (x < 0 || x >= gimp_item_get_width (GIMP_ITEM (drawable)) ||
|
|
|
|
y < 0 || y >= gimp_item_get_height (GIMP_ITEM (drawable)))
|
2007-04-28 00:07:49 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2012-03-21 07:42:44 +08:00
|
|
|
gegl_buffer_sample (gimp_drawable_get_buffer (drawable),
|
2012-04-21 16:03:32 +08:00
|
|
|
x, y, NULL, pixel, format,
|
2012-03-26 08:17:24 +08:00
|
|
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
2007-04-28 00:07:49 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_real_update (GimpDrawable *drawable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
2012-03-22 07:18:22 +08:00
|
|
|
if (drawable->private->buffer_source_node)
|
2008-10-10 20:24:56 +08:00
|
|
|
{
|
2012-03-17 19:40:34 +08:00
|
|
|
GObject *operation = NULL;
|
2008-10-10 20:24:56 +08:00
|
|
|
|
2012-03-22 07:18:22 +08:00
|
|
|
g_object_get (drawable->private->buffer_source_node,
|
2008-10-10 20:24:56 +08:00
|
|
|
"gegl-operation", &operation,
|
|
|
|
NULL);
|
|
|
|
|
2012-03-14 17:05:01 +08:00
|
|
|
if (operation)
|
|
|
|
{
|
2012-03-21 10:57:53 +08:00
|
|
|
gegl_operation_invalidate (GEGL_OPERATION (operation),
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (x,y,width,height), FALSE);
|
2012-03-14 17:05:01 +08:00
|
|
|
g_object_unref (operation);
|
|
|
|
}
|
2008-10-10 20:24:56 +08:00
|
|
|
}
|
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (drawable));
|
|
|
|
}
|
|
|
|
|
2007-12-04 19:30:31 +08:00
|
|
|
static gint64
|
|
|
|
gimp_drawable_real_estimate_memsize (const GimpDrawable *drawable,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
2012-04-25 19:35:37 +08:00
|
|
|
const Babl *format = gimp_drawable_get_format (drawable);
|
|
|
|
|
|
|
|
return (gint64) babl_format_get_bytes_per_pixel (format) * width * height;
|
2007-12-04 19:30:31 +08:00
|
|
|
}
|
|
|
|
|
2012-10-14 03:46:56 +08:00
|
|
|
/* FIXME: this default impl is currently unused because no subclass
|
|
|
|
* chins up. the goal is to handle the almost identical subclass code
|
|
|
|
* here again.
|
|
|
|
*/
|
2009-09-12 03:23:35 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_real_convert_type (GimpDrawable *drawable,
|
|
|
|
GimpImage *dest_image,
|
2012-10-14 04:56:32 +08:00
|
|
|
const Babl *new_format,
|
2009-09-14 01:24:19 +08:00
|
|
|
GimpImageBaseType new_base_type,
|
2012-04-25 18:09:45 +08:00
|
|
|
GimpPrecision new_precision,
|
2012-10-14 03:46:56 +08:00
|
|
|
gint layer_dither_type,
|
|
|
|
gint mask_dither_type,
|
2009-09-14 01:24:19 +08:00
|
|
|
gboolean push_undo)
|
2009-09-12 03:23:35 +08:00
|
|
|
{
|
2012-04-12 00:50:57 +08:00
|
|
|
GeglBuffer *dest_buffer;
|
|
|
|
const Babl *format;
|
2009-09-12 03:23:35 +08:00
|
|
|
|
2012-05-08 03:46:47 +08:00
|
|
|
format = gimp_image_get_format (dest_image,
|
|
|
|
new_base_type,
|
|
|
|
new_precision,
|
|
|
|
gimp_drawable_has_alpha (drawable));
|
2009-09-12 03:23:35 +08:00
|
|
|
|
2012-04-12 00:50:57 +08:00
|
|
|
dest_buffer =
|
2012-06-21 03:44:09 +08:00
|
|
|
gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (drawable))),
|
|
|
|
format);
|
2012-03-18 05:53:17 +08:00
|
|
|
|
2012-04-12 00:50:57 +08:00
|
|
|
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
|
|
|
|
dest_buffer, NULL);
|
|
|
|
|
|
|
|
gimp_drawable_set_buffer (drawable, push_undo, NULL, dest_buffer);
|
|
|
|
g_object_unref (dest_buffer);
|
2009-09-12 03:23:35 +08:00
|
|
|
}
|
|
|
|
|
2012-03-22 07:07:48 +08:00
|
|
|
static GeglBuffer *
|
|
|
|
gimp_drawable_real_get_buffer (GimpDrawable *drawable)
|
2007-12-18 19:20:23 +08:00
|
|
|
{
|
2012-06-21 03:44:09 +08:00
|
|
|
#if 0
|
2012-03-22 07:07:48 +08:00
|
|
|
gegl_buffer_flush (drawable->private->buffer);
|
|
|
|
gimp_gegl_buffer_refetch_tiles (drawable->private->buffer);
|
2012-06-21 03:44:09 +08:00
|
|
|
#endif
|
2012-03-22 07:07:48 +08:00
|
|
|
|
|
|
|
return drawable->private->buffer;
|
2007-12-18 19:20:23 +08:00
|
|
|
}
|
|
|
|
|
2004-03-13 21:56:09 +08:00
|
|
|
static void
|
2012-03-22 06:37:16 +08:00
|
|
|
gimp_drawable_real_set_buffer (GimpDrawable *drawable,
|
|
|
|
gboolean push_undo,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GeglBuffer *buffer,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
2004-03-13 21:56:09 +08:00
|
|
|
{
|
2012-03-22 06:37:16 +08:00
|
|
|
GimpItem *item = GIMP_ITEM (drawable);
|
2004-03-16 03:34:35 +08:00
|
|
|
gboolean old_has_alpha;
|
2004-03-15 23:37:12 +08:00
|
|
|
|
|
|
|
old_has_alpha = gimp_drawable_has_alpha (drawable);
|
|
|
|
|
2004-03-16 01:53:55 +08:00
|
|
|
gimp_drawable_invalidate_boundary (drawable);
|
|
|
|
|
2004-03-16 04:58:07 +08:00
|
|
|
if (push_undo)
|
|
|
|
gimp_image_undo_push_drawable_mod (gimp_item_get_image (item), undo_desc,
|
2010-03-18 17:25:18 +08:00
|
|
|
drawable, FALSE);
|
2004-03-16 04:58:07 +08:00
|
|
|
|
2004-03-17 00:23:06 +08:00
|
|
|
/* ref new before unrefing old, they might be the same */
|
2012-03-22 06:37:16 +08:00
|
|
|
g_object_ref (buffer);
|
2004-03-17 00:23:06 +08:00
|
|
|
|
2012-03-22 04:26:05 +08:00
|
|
|
if (drawable->private->buffer)
|
|
|
|
g_object_unref (drawable->private->buffer);
|
2004-03-13 21:56:09 +08:00
|
|
|
|
2012-03-22 06:37:16 +08:00
|
|
|
drawable->private->buffer = buffer;
|
2012-03-15 09:42:59 +08:00
|
|
|
|
2008-11-03 07:16:47 +08:00
|
|
|
gimp_item_set_offset (item, offset_x, offset_y);
|
2009-08-26 19:03:40 +08:00
|
|
|
gimp_item_set_size (item,
|
2012-03-22 06:37:16 +08:00
|
|
|
gegl_buffer_get_width (buffer),
|
|
|
|
gegl_buffer_get_height (buffer));
|
2004-03-16 03:34:35 +08:00
|
|
|
|
2004-03-15 23:37:12 +08:00
|
|
|
if (old_has_alpha != gimp_drawable_has_alpha (drawable))
|
|
|
|
gimp_drawable_alpha_changed (drawable);
|
2008-10-10 04:44:23 +08:00
|
|
|
|
2012-03-22 07:18:22 +08:00
|
|
|
if (drawable->private->buffer_source_node)
|
|
|
|
gegl_node_set (drawable->private->buffer_source_node,
|
2012-03-21 07:42:44 +08:00
|
|
|
"buffer", gimp_drawable_get_buffer (drawable),
|
2012-03-15 09:42:59 +08:00
|
|
|
NULL);
|
2004-03-13 21:56:09 +08:00
|
|
|
}
|
|
|
|
|
2004-04-01 22:51:58 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_real_push_undo (GimpDrawable *drawable,
|
|
|
|
const gchar *undo_desc,
|
2012-03-22 21:13:17 +08:00
|
|
|
GeglBuffer *buffer,
|
2004-04-01 22:51:58 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
2012-03-22 21:13:17 +08:00
|
|
|
if (! buffer)
|
2004-04-01 22:51:58 +08:00
|
|
|
{
|
2012-05-21 04:00:27 +08:00
|
|
|
buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, width, height),
|
|
|
|
gimp_drawable_get_format (drawable));
|
2012-03-15 19:30:41 +08:00
|
|
|
|
2012-03-21 10:57:53 +08:00
|
|
|
gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (x, y, width, height),
|
2012-03-22 21:13:17 +08:00
|
|
|
buffer,
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (0, 0, 0, 0));
|
2012-03-22 21:13:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_object_ref (buffer);
|
2004-04-01 22:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_undo_push_drawable (gimp_item_get_image (GIMP_ITEM (drawable)),
|
|
|
|
undo_desc, drawable,
|
2012-03-22 21:25:45 +08:00
|
|
|
buffer, x, y);
|
2004-04-01 22:51:58 +08:00
|
|
|
|
2012-03-22 21:13:17 +08:00
|
|
|
g_object_unref (buffer);
|
2004-04-01 22:51:58 +08:00
|
|
|
}
|
|
|
|
|
2004-03-15 22:10:30 +08:00
|
|
|
static void
|
2006-04-07 17:21:18 +08:00
|
|
|
gimp_drawable_real_swap_pixels (GimpDrawable *drawable,
|
2012-03-22 21:13:17 +08:00
|
|
|
GeglBuffer *buffer,
|
2006-04-07 17:21:18 +08:00
|
|
|
gint x,
|
2012-03-22 21:25:45 +08:00
|
|
|
gint y)
|
2004-03-15 22:10:30 +08:00
|
|
|
{
|
2012-03-22 21:13:17 +08:00
|
|
|
GeglBuffer *tmp;
|
2012-03-22 21:25:45 +08:00
|
|
|
gint width = gegl_buffer_get_width (buffer);
|
|
|
|
gint height = gegl_buffer_get_height (buffer);
|
2004-03-15 22:10:30 +08:00
|
|
|
|
2012-05-21 04:00:27 +08:00
|
|
|
tmp = gegl_buffer_dup (buffer);
|
2004-03-15 22:10:30 +08:00
|
|
|
|
2012-03-22 21:13:17 +08:00
|
|
|
gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (x, y, width, height),
|
2012-03-22 21:13:17 +08:00
|
|
|
buffer,
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (0, 0, 0, 0));
|
2012-03-22 21:13:17 +08:00
|
|
|
gegl_buffer_copy (tmp,
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (0, 0, width, height),
|
2012-03-22 21:13:17 +08:00
|
|
|
gimp_drawable_get_buffer (drawable),
|
2012-04-02 21:19:47 +08:00
|
|
|
GEGL_RECTANGLE (x, y, 0, 0));
|
2004-03-15 22:10:30 +08:00
|
|
|
|
2012-03-22 21:13:17 +08:00
|
|
|
g_object_unref (tmp);
|
2004-03-15 22:10:30 +08:00
|
|
|
|
|
|
|
gimp_drawable_update (drawable, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2009-01-27 06:05:07 +08:00
|
|
|
static void
|
2013-04-12 01:06:23 +08:00
|
|
|
gimp_drawable_sync_fs_filter (GimpDrawable *drawable,
|
|
|
|
gboolean detach_fs)
|
2009-01-27 06:05:07 +08:00
|
|
|
{
|
2013-04-13 03:07:56 +08:00
|
|
|
GimpDrawablePrivate *private = drawable->private;
|
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
GimpLayer *fs = gimp_drawable_get_floating_sel (drawable);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-13 03:07:56 +08:00
|
|
|
if (! private->source_node)
|
2009-01-27 06:05:07 +08:00
|
|
|
return;
|
|
|
|
|
2011-09-24 01:31:50 +08:00
|
|
|
if (fs && ! detach_fs)
|
2009-01-27 06:05:07 +08:00
|
|
|
{
|
2013-04-13 00:26:34 +08:00
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
GimpChannel *mask = gimp_image_get_mask (image);
|
|
|
|
gint off_x, off_y;
|
|
|
|
gint fs_off_x, fs_off_y;
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-13 03:07:56 +08:00
|
|
|
if (! private->fs_filter)
|
2009-01-27 06:05:07 +08:00
|
|
|
{
|
2013-04-15 07:44:18 +08:00
|
|
|
GeglNode *node;
|
2009-01-27 06:05:07 +08:00
|
|
|
GeglNode *fs_source;
|
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
private->fs_filter = gimp_filter_new ("Floating Selection");
|
2013-04-17 02:30:13 +08:00
|
|
|
gimp_viewable_set_stock_id (GIMP_VIEWABLE (private->fs_filter),
|
|
|
|
"gimp-floating-selection");
|
2013-04-15 07:44:18 +08:00
|
|
|
|
|
|
|
node = gimp_filter_get_node (private->fs_filter);
|
|
|
|
|
2009-01-27 06:05:07 +08:00
|
|
|
fs_source = gimp_drawable_get_source_node (GIMP_DRAWABLE (fs));
|
2009-02-13 23:35:13 +08:00
|
|
|
|
|
|
|
/* rip the fs' source node out of its graph */
|
2012-05-17 01:45:18 +08:00
|
|
|
if (fs->layer_offset_node)
|
2009-02-13 23:35:13 +08:00
|
|
|
{
|
2012-05-17 01:45:18 +08:00
|
|
|
gegl_node_disconnect (fs->layer_offset_node, "input");
|
2013-04-11 08:54:42 +08:00
|
|
|
gegl_node_remove_child (gimp_filter_get_node (GIMP_FILTER (fs)),
|
2009-02-13 23:35:13 +08:00
|
|
|
fs_source);
|
|
|
|
}
|
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
gegl_node_add_child (node, fs_source);
|
|
|
|
|
|
|
|
private->fs_applicator = gimp_applicator_new (node);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
private->fs_crop_node =
|
|
|
|
gegl_node_new_child (node,
|
|
|
|
"operation", "gegl:crop",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gegl_node_connect_to (fs_source, "output",
|
|
|
|
private->fs_crop_node, "input");
|
|
|
|
gegl_node_connect_to (private->fs_crop_node, "output",
|
|
|
|
node, "aux");
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-13 03:07:56 +08:00
|
|
|
gimp_drawable_add_filter (drawable, private->fs_filter);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
|
|
|
g_signal_connect (fs, "notify",
|
|
|
|
G_CALLBACK (gimp_drawable_fs_notify),
|
|
|
|
drawable);
|
2013-04-12 21:53:19 +08:00
|
|
|
g_signal_connect (image, "component-active-changed",
|
2013-04-13 00:26:34 +08:00
|
|
|
G_CALLBACK (gimp_drawable_fs_affect_changed),
|
|
|
|
drawable);
|
|
|
|
g_signal_connect (image, "mask-changed",
|
|
|
|
G_CALLBACK (gimp_drawable_fs_mask_changed),
|
2013-04-12 21:53:19 +08:00
|
|
|
drawable);
|
2009-01-27 06:05:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (fs), &fs_off_x, &fs_off_y);
|
|
|
|
|
2013-04-13 03:07:56 +08:00
|
|
|
gegl_node_set (private->fs_crop_node,
|
2009-02-13 23:35:13 +08:00
|
|
|
"x", (gdouble) (off_x - fs_off_x),
|
|
|
|
"y", (gdouble) (off_y - fs_off_y),
|
|
|
|
"width", (gdouble) gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
|
|
"height", (gdouble) gimp_item_get_height (GIMP_ITEM (drawable)),
|
|
|
|
NULL);
|
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
gimp_applicator_set_apply_offset (private->fs_applicator,
|
|
|
|
fs_off_x - off_x,
|
|
|
|
fs_off_y - off_y);
|
2013-04-13 00:26:34 +08:00
|
|
|
|
|
|
|
if (gimp_channel_is_empty (mask))
|
|
|
|
{
|
2013-04-15 07:44:18 +08:00
|
|
|
gimp_applicator_set_mask_buffer (private->fs_applicator, NULL);
|
2013-04-13 00:26:34 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-15 07:44:18 +08:00
|
|
|
GeglBuffer *buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
|
2013-04-13 00:26:34 +08:00
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
gimp_applicator_set_mask_buffer (private->fs_applicator, buffer);
|
|
|
|
gimp_applicator_set_mask_offset (private->fs_applicator,
|
|
|
|
-off_x, -off_y);
|
|
|
|
}
|
2013-04-12 21:53:19 +08:00
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
gimp_applicator_set_mode (private->fs_applicator,
|
|
|
|
gimp_layer_get_opacity (fs),
|
|
|
|
gimp_layer_get_mode (fs));
|
|
|
|
gimp_applicator_set_affect (private->fs_applicator,
|
|
|
|
gimp_drawable_get_active_mask (drawable));
|
2009-01-27 06:05:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-13 03:07:56 +08:00
|
|
|
if (private->fs_filter)
|
2009-01-27 06:05:07 +08:00
|
|
|
{
|
2013-04-15 07:44:18 +08:00
|
|
|
GeglNode *node;
|
2009-01-27 06:05:07 +08:00
|
|
|
GeglNode *fs_source;
|
|
|
|
|
2013-04-12 01:06:23 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (fs,
|
|
|
|
gimp_drawable_fs_notify,
|
|
|
|
drawable);
|
2013-04-12 21:53:19 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (image,
|
2013-04-13 00:26:34 +08:00
|
|
|
gimp_drawable_fs_affect_changed,
|
|
|
|
drawable);
|
|
|
|
g_signal_handlers_disconnect_by_func (image,
|
|
|
|
gimp_drawable_fs_mask_changed,
|
2013-04-12 21:53:19 +08:00
|
|
|
drawable);
|
2013-04-12 01:06:23 +08:00
|
|
|
|
2013-04-13 03:07:56 +08:00
|
|
|
gimp_drawable_remove_filter (drawable, private->fs_filter);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
node = gimp_filter_get_node (private->fs_filter);
|
|
|
|
|
2009-01-27 06:05:07 +08:00
|
|
|
fs_source = gimp_drawable_get_source_node (GIMP_DRAWABLE (fs));
|
2013-04-12 01:06:23 +08:00
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
gegl_node_remove_child (node, fs_source);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2009-02-13 23:35:13 +08:00
|
|
|
/* plug the fs' source node back into its graph */
|
2012-05-17 01:45:18 +08:00
|
|
|
if (fs->layer_offset_node)
|
2009-02-13 23:35:13 +08:00
|
|
|
{
|
2013-04-11 08:54:42 +08:00
|
|
|
gegl_node_add_child (gimp_filter_get_node (GIMP_FILTER (fs)),
|
2009-02-13 23:35:13 +08:00
|
|
|
fs_source);
|
2012-05-17 01:45:18 +08:00
|
|
|
gegl_node_connect_to (fs_source, "output",
|
|
|
|
fs->layer_offset_node, "input");
|
2009-02-13 23:35:13 +08:00
|
|
|
}
|
|
|
|
|
2013-04-13 03:07:56 +08:00
|
|
|
g_object_unref (private->fs_filter);
|
|
|
|
private->fs_filter = NULL;
|
2009-02-13 23:35:13 +08:00
|
|
|
|
2013-04-15 07:44:18 +08:00
|
|
|
g_object_unref (private->fs_applicator);
|
|
|
|
private->fs_applicator = NULL;
|
|
|
|
|
|
|
|
private->fs_crop_node = NULL;
|
2009-01-27 06:05:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_fs_notify (GimpLayer *fs,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
if (! strcmp (pspec->name, "offset-x") ||
|
|
|
|
! strcmp (pspec->name, "offset-y") ||
|
|
|
|
! strcmp (pspec->name, "visible") ||
|
|
|
|
! strcmp (pspec->name, "mode") ||
|
|
|
|
! strcmp (pspec->name, "opacity"))
|
|
|
|
{
|
2013-04-12 01:06:23 +08:00
|
|
|
gimp_drawable_sync_fs_filter (drawable, FALSE);
|
2009-01-27 06:05:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-12 21:53:19 +08:00
|
|
|
static void
|
2013-04-13 00:26:34 +08:00
|
|
|
gimp_drawable_fs_affect_changed (GimpImage *image,
|
|
|
|
GimpChannelType channel,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GimpLayer *fs = gimp_drawable_get_floating_sel (drawable);
|
|
|
|
|
|
|
|
gimp_drawable_sync_fs_filter (drawable, FALSE);
|
|
|
|
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (fs),
|
|
|
|
0, 0,
|
|
|
|
gimp_item_get_width (GIMP_ITEM (fs)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (fs)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_fs_mask_changed (GimpImage *image,
|
|
|
|
GimpDrawable *drawable)
|
2013-04-12 21:53:19 +08:00
|
|
|
{
|
2013-04-12 21:58:42 +08:00
|
|
|
GimpLayer *fs = gimp_drawable_get_floating_sel (drawable);
|
|
|
|
|
2013-04-12 21:53:19 +08:00
|
|
|
gimp_drawable_sync_fs_filter (drawable, FALSE);
|
2013-04-12 21:58:42 +08:00
|
|
|
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (fs),
|
|
|
|
0, 0,
|
|
|
|
gimp_item_get_width (GIMP_ITEM (fs)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (fs)));
|
2013-04-12 21:53:19 +08:00
|
|
|
}
|
|
|
|
|
2009-08-31 23:37:22 +08:00
|
|
|
static void
|
|
|
|
gimp_drawable_fs_update (GimpLayer *fs,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
gint fs_off_x, fs_off_y;
|
|
|
|
gint off_x, off_y;
|
|
|
|
gint dr_x, dr_y, dr_width, dr_height;
|
|
|
|
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (fs), &fs_off_x, &fs_off_y);
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
|
|
|
|
|
|
|
if (gimp_rectangle_intersect (x + fs_off_x,
|
|
|
|
y + fs_off_y,
|
|
|
|
width,
|
|
|
|
height,
|
2011-09-24 04:34:25 +08:00
|
|
|
off_x,
|
2009-08-31 23:37:22 +08:00
|
|
|
off_y,
|
|
|
|
gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (drawable)),
|
|
|
|
&dr_x,
|
|
|
|
&dr_y,
|
|
|
|
&dr_width,
|
|
|
|
&dr_height))
|
|
|
|
{
|
|
|
|
gimp_drawable_update (drawable,
|
|
|
|
dr_x - off_x, dr_y - off_y,
|
|
|
|
dr_width, dr_height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-15 22:10:30 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2011-02-01 19:47:24 +08:00
|
|
|
GimpDrawable *
|
|
|
|
gimp_drawable_new (GType type,
|
|
|
|
GimpImage *image,
|
|
|
|
const gchar *name,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
2012-03-22 03:21:11 +08:00
|
|
|
const Babl *format)
|
2011-02-01 19:47:24 +08:00
|
|
|
{
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
|
|
|
g_return_val_if_fail (g_type_is_a (type, GIMP_TYPE_DRAWABLE), NULL);
|
|
|
|
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
2012-03-22 03:21:11 +08:00
|
|
|
g_return_val_if_fail (format != NULL, NULL);
|
2011-02-01 19:47:24 +08:00
|
|
|
|
|
|
|
drawable = GIMP_DRAWABLE (gimp_item_new (type,
|
|
|
|
image, name,
|
|
|
|
offset_x, offset_y,
|
|
|
|
width, height));
|
|
|
|
|
2012-06-21 03:44:09 +08:00
|
|
|
drawable->private->buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0,
|
|
|
|
width, height),
|
|
|
|
format);
|
2011-02-01 19:47:24 +08:00
|
|
|
|
|
|
|
return drawable;
|
|
|
|
}
|
|
|
|
|
2007-12-04 19:30:31 +08:00
|
|
|
gint64
|
|
|
|
gimp_drawable_estimate_memsize (const GimpDrawable *drawable,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0);
|
|
|
|
|
|
|
|
return GIMP_DRAWABLE_GET_CLASS (drawable)->estimate_memsize (drawable,
|
|
|
|
width, height);
|
|
|
|
}
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_update (GimpDrawable *drawable,
|
2004-07-14 18:31:59 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
2001-07-08 06:49:01 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
2010-04-18 21:03:16 +08:00
|
|
|
g_signal_emit (drawable, gimp_drawable_signals[UPDATE], 0,
|
|
|
|
x, y, width, height);
|
2001-07-08 06:49:01 +08:00
|
|
|
}
|
|
|
|
|
2003-10-06 22:40:12 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_alpha_changed (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
g_signal_emit (drawable, gimp_drawable_signals[ALPHA_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_invalidate_boundary (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GimpDrawableClass *drawable_class;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
drawable_class = GIMP_DRAWABLE_GET_CLASS (drawable);
|
|
|
|
|
|
|
|
if (drawable_class->invalidate_boundary)
|
|
|
|
drawable_class->invalidate_boundary (drawable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_get_active_components (const GimpDrawable *drawable,
|
|
|
|
gboolean *active)
|
|
|
|
{
|
|
|
|
GimpDrawableClass *drawable_class;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (active != NULL);
|
|
|
|
|
|
|
|
drawable_class = GIMP_DRAWABLE_GET_CLASS (drawable);
|
|
|
|
|
|
|
|
if (drawable_class->get_active_components)
|
|
|
|
drawable_class->get_active_components (drawable, active);
|
|
|
|
}
|
|
|
|
|
2012-04-26 05:23:31 +08:00
|
|
|
GimpComponentMask
|
|
|
|
gimp_drawable_get_active_mask (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GimpDrawableClass *drawable_class;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0);
|
|
|
|
|
|
|
|
drawable_class = GIMP_DRAWABLE_GET_CLASS (drawable);
|
|
|
|
|
|
|
|
if (drawable_class->get_active_mask)
|
|
|
|
return drawable_class->get_active_mask (drawable);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-12 03:23:35 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_convert_type (GimpDrawable *drawable,
|
|
|
|
GimpImage *dest_image,
|
2009-09-14 01:24:19 +08:00
|
|
|
GimpImageBaseType new_base_type,
|
2012-04-25 18:09:45 +08:00
|
|
|
GimpPrecision new_precision,
|
2012-10-14 03:46:56 +08:00
|
|
|
gint layer_dither_type,
|
|
|
|
gint mask_dither_type,
|
2009-09-14 01:24:19 +08:00
|
|
|
gboolean push_undo)
|
2009-09-12 03:23:35 +08:00
|
|
|
{
|
2012-10-14 04:56:32 +08:00
|
|
|
const Babl *new_format;
|
|
|
|
|
2009-09-12 03:23:35 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2012-04-12 00:50:57 +08:00
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
|
2012-04-25 18:09:45 +08:00
|
|
|
g_return_if_fail (new_base_type != gimp_drawable_get_base_type (drawable) ||
|
|
|
|
new_precision != gimp_drawable_get_precision (drawable));
|
2009-09-12 03:23:35 +08:00
|
|
|
|
2009-09-14 01:24:19 +08:00
|
|
|
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
2012-10-14 04:56:32 +08:00
|
|
|
new_format = gimp_image_get_format (dest_image,
|
|
|
|
new_base_type,
|
|
|
|
new_precision,
|
|
|
|
gimp_drawable_has_alpha (drawable));
|
|
|
|
|
2009-09-12 03:23:35 +08:00
|
|
|
GIMP_DRAWABLE_GET_CLASS (drawable)->convert_type (drawable, dest_image,
|
2012-10-14 04:56:32 +08:00
|
|
|
new_format,
|
2012-04-25 18:09:45 +08:00
|
|
|
new_base_type,
|
|
|
|
new_precision,
|
2012-10-14 03:46:56 +08:00
|
|
|
layer_dither_type,
|
|
|
|
mask_dither_type,
|
2012-04-25 18:09:45 +08:00
|
|
|
push_undo);
|
2009-09-12 03:23:35 +08:00
|
|
|
}
|
|
|
|
|
2012-03-23 01:40:40 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_apply_buffer (GimpDrawable *drawable,
|
|
|
|
GeglBuffer *buffer,
|
2012-03-23 06:45:11 +08:00
|
|
|
const GeglRectangle *buffer_region,
|
2012-03-23 01:40:40 +08:00
|
|
|
gboolean push_undo,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
gdouble opacity,
|
|
|
|
GimpLayerModeEffects mode,
|
2012-03-23 07:12:13 +08:00
|
|
|
GeglBuffer *base_buffer,
|
2012-03-24 07:57:11 +08:00
|
|
|
gint base_x,
|
2012-05-19 06:14:51 +08:00
|
|
|
gint base_y)
|
2012-03-23 01:40:40 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
|
|
|
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
2012-03-23 06:45:11 +08:00
|
|
|
g_return_if_fail (buffer_region != NULL);
|
2012-03-23 07:12:13 +08:00
|
|
|
g_return_if_fail (base_buffer == NULL || GEGL_IS_BUFFER (base_buffer));
|
2003-10-06 22:40:12 +08:00
|
|
|
|
2012-03-23 06:45:11 +08:00
|
|
|
GIMP_DRAWABLE_GET_CLASS (drawable)->apply_buffer (drawable, buffer,
|
|
|
|
buffer_region,
|
2003-10-06 22:40:12 +08:00
|
|
|
push_undo, undo_desc,
|
|
|
|
opacity, mode,
|
2012-03-23 07:12:13 +08:00
|
|
|
base_buffer,
|
2012-05-19 06:14:51 +08:00
|
|
|
base_x, base_y);
|
2003-10-06 22:40:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-23 19:31:21 +08:00
|
|
|
gimp_drawable_replace_buffer (GimpDrawable *drawable,
|
|
|
|
GeglBuffer *buffer,
|
|
|
|
const GeglRectangle *buffer_region,
|
|
|
|
gboolean push_undo,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
gdouble opacity,
|
2012-04-23 06:32:14 +08:00
|
|
|
GeglBuffer *mask,
|
|
|
|
const GeglRectangle *mask_region,
|
2012-03-23 19:31:21 +08:00
|
|
|
gint x,
|
|
|
|
gint y)
|
2003-10-06 22:40:12 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2004-11-16 21:41:55 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
2012-03-23 19:31:21 +08:00
|
|
|
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
2012-04-23 06:32:14 +08:00
|
|
|
g_return_if_fail (GEGL_IS_BUFFER (mask));
|
2003-10-06 22:40:12 +08:00
|
|
|
|
2012-03-23 19:31:21 +08:00
|
|
|
GIMP_DRAWABLE_GET_CLASS (drawable)->replace_buffer (drawable, buffer,
|
|
|
|
buffer_region,
|
2003-10-06 22:40:12 +08:00
|
|
|
push_undo, undo_desc,
|
2012-04-23 06:32:14 +08:00
|
|
|
opacity,
|
|
|
|
mask, mask_region,
|
2003-10-06 22:40:12 +08:00
|
|
|
x, y);
|
|
|
|
}
|
2008-11-08 08:16:40 +08:00
|
|
|
|
2012-03-15 09:42:59 +08:00
|
|
|
GeglBuffer *
|
2012-03-21 07:42:44 +08:00
|
|
|
gimp_drawable_get_buffer (GimpDrawable *drawable)
|
2012-03-15 09:42:59 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
2012-03-22 07:07:48 +08:00
|
|
|
return GIMP_DRAWABLE_GET_CLASS (drawable)->get_buffer (drawable);
|
2012-03-15 09:42:59 +08:00
|
|
|
}
|
|
|
|
|
2004-03-13 21:56:09 +08:00
|
|
|
void
|
2012-03-22 06:37:16 +08:00
|
|
|
gimp_drawable_set_buffer (GimpDrawable *drawable,
|
|
|
|
gboolean push_undo,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GeglBuffer *buffer)
|
2004-03-16 03:34:35 +08:00
|
|
|
{
|
|
|
|
gint offset_x, offset_y;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2012-03-22 06:37:16 +08:00
|
|
|
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
2004-03-16 03:34:35 +08:00
|
|
|
|
2004-11-16 21:41:55 +08:00
|
|
|
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &offset_x, &offset_y);
|
2004-03-16 03:34:35 +08:00
|
|
|
|
2012-03-22 06:37:16 +08:00
|
|
|
gimp_drawable_set_buffer_full (drawable, push_undo, undo_desc, buffer,
|
|
|
|
offset_x, offset_y);
|
2004-03-16 03:34:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-22 06:37:16 +08:00
|
|
|
gimp_drawable_set_buffer_full (GimpDrawable *drawable,
|
|
|
|
gboolean push_undo,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
GeglBuffer *buffer,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
2004-03-13 21:56:09 +08:00
|
|
|
{
|
2011-05-02 05:23:19 +08:00
|
|
|
GimpItem *item;
|
2004-03-16 04:05:31 +08:00
|
|
|
|
2004-03-13 21:56:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2012-03-22 06:37:16 +08:00
|
|
|
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
2004-03-13 21:56:09 +08:00
|
|
|
|
2011-05-02 05:23:19 +08:00
|
|
|
item = GIMP_ITEM (drawable);
|
2004-04-13 21:54:54 +08:00
|
|
|
|
2004-11-16 21:41:55 +08:00
|
|
|
if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
2012-03-22 06:37:16 +08:00
|
|
|
if (gimp_item_get_width (item) != gegl_buffer_get_width (buffer) ||
|
|
|
|
gimp_item_get_height (item) != gegl_buffer_get_height (buffer) ||
|
|
|
|
gimp_item_get_offset_x (item) != offset_x ||
|
2008-12-28 20:43:07 +08:00
|
|
|
gimp_item_get_offset_y (item) != offset_y)
|
2004-03-16 04:05:31 +08:00
|
|
|
{
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_drawable_update (drawable,
|
|
|
|
0, 0,
|
2008-11-03 08:09:01 +08:00
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item));
|
2004-03-16 04:05:31 +08:00
|
|
|
}
|
|
|
|
|
2009-08-26 19:20:18 +08:00
|
|
|
g_object_freeze_notify (G_OBJECT (drawable));
|
|
|
|
|
2012-03-22 06:37:16 +08:00
|
|
|
GIMP_DRAWABLE_GET_CLASS (drawable)->set_buffer (drawable,
|
|
|
|
push_undo, undo_desc,
|
|
|
|
buffer,
|
|
|
|
offset_x, offset_y);
|
2004-03-16 04:05:31 +08:00
|
|
|
|
2009-08-26 19:20:18 +08:00
|
|
|
g_object_thaw_notify (G_OBJECT (drawable));
|
|
|
|
|
2007-12-24 00:58:41 +08:00
|
|
|
gimp_drawable_update (drawable,
|
|
|
|
0, 0,
|
2008-11-03 08:09:01 +08:00
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item));
|
2004-03-13 21:56:09 +08:00
|
|
|
}
|
|
|
|
|
2008-10-10 04:44:23 +08:00
|
|
|
GeglNode *
|
|
|
|
gimp_drawable_get_source_node (GimpDrawable *drawable)
|
|
|
|
{
|
2013-04-12 01:06:23 +08:00
|
|
|
GeglNode *filter;
|
|
|
|
GeglNode *output;
|
|
|
|
|
2008-10-10 04:44:23 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
2009-02-04 07:57:11 +08:00
|
|
|
if (drawable->private->source_node)
|
|
|
|
return drawable->private->source_node;
|
2008-10-10 04:44:23 +08:00
|
|
|
|
2009-02-04 07:57:11 +08:00
|
|
|
drawable->private->source_node = gegl_node_new ();
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2012-03-22 07:18:22 +08:00
|
|
|
drawable->private->buffer_source_node =
|
2009-02-04 07:57:11 +08:00
|
|
|
gegl_node_new_child (drawable->private->source_node,
|
2012-03-14 17:05:01 +08:00
|
|
|
"operation", "gegl:buffer-source",
|
2012-03-21 07:42:44 +08:00
|
|
|
"buffer", gimp_drawable_get_buffer (drawable),
|
2009-01-27 06:05:07 +08:00
|
|
|
NULL);
|
|
|
|
|
2013-04-12 01:06:23 +08:00
|
|
|
filter = gimp_filter_stack_get_graph (GIMP_FILTER_STACK (drawable->private->filter_stack));
|
|
|
|
|
|
|
|
gegl_node_add_child (drawable->private->source_node, filter);
|
|
|
|
|
|
|
|
gegl_node_connect_to (drawable->private->buffer_source_node, "output",
|
|
|
|
filter, "input");
|
|
|
|
|
|
|
|
output = gegl_node_get_output_proxy (drawable->private->source_node, "output");
|
|
|
|
|
|
|
|
gegl_node_connect_to (filter, "output",
|
|
|
|
output, "input");
|
|
|
|
|
|
|
|
gimp_drawable_sync_fs_filter (drawable, FALSE);
|
2008-10-10 04:44:23 +08:00
|
|
|
|
2009-02-04 07:57:11 +08:00
|
|
|
return drawable->private->source_node;
|
2008-10-10 04:44:23 +08:00
|
|
|
}
|
|
|
|
|
2008-10-15 02:32:07 +08:00
|
|
|
GeglNode *
|
|
|
|
gimp_drawable_get_mode_node (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
2009-02-04 07:57:11 +08:00
|
|
|
if (! drawable->private->mode_node)
|
2013-04-11 08:54:42 +08:00
|
|
|
gimp_filter_get_node (GIMP_FILTER (drawable));
|
2008-10-11 03:36:17 +08:00
|
|
|
|
2009-02-04 07:57:11 +08:00
|
|
|
return drawable->private->mode_node;
|
2008-10-11 03:36:17 +08:00
|
|
|
}
|
|
|
|
|
2004-03-15 22:10:30 +08:00
|
|
|
void
|
|
|
|
gimp_drawable_swap_pixels (GimpDrawable *drawable,
|
2012-03-22 21:13:17 +08:00
|
|
|
GeglBuffer *buffer,
|
2004-03-15 22:10:30 +08:00
|
|
|
gint x,
|
2012-03-22 21:25:45 +08:00
|
|
|
gint y)
|
2004-03-15 22:10:30 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2012-03-22 21:13:17 +08:00
|
|
|
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
2004-03-15 22:10:30 +08:00
|
|
|
|
2012-03-22 21:25:45 +08:00
|
|
|
GIMP_DRAWABLE_GET_CLASS (drawable)->swap_pixels (drawable, buffer, x, y);
|
2004-03-15 22:10:30 +08:00
|
|
|
}
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
void
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_drawable_push_undo (GimpDrawable *drawable,
|
|
|
|
const gchar *undo_desc,
|
2012-03-22 21:13:17 +08:00
|
|
|
GeglBuffer *buffer,
|
2009-06-17 04:59:07 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
2012-03-22 21:13:17 +08:00
|
|
|
gint height)
|
2001-07-08 06:49:01 +08:00
|
|
|
{
|
2004-03-15 22:10:30 +08:00
|
|
|
GimpItem *item;
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2012-03-22 21:13:17 +08:00
|
|
|
g_return_if_fail (buffer == NULL || GEGL_IS_BUFFER (buffer));
|
2004-03-15 22:10:30 +08:00
|
|
|
|
|
|
|
item = GIMP_ITEM (drawable);
|
|
|
|
|
2004-11-16 21:41:55 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2004-03-15 22:10:30 +08:00
|
|
|
|
2012-03-22 21:13:17 +08:00
|
|
|
if (! buffer &&
|
|
|
|
! gimp_rectangle_intersect (x, y,
|
2009-06-17 04:59:07 +08:00
|
|
|
width, height,
|
2004-03-15 22:10:30 +08:00
|
|
|
0, 0,
|
2008-11-03 08:09:01 +08:00
|
|
|
gimp_item_get_width (item),
|
|
|
|
gimp_item_get_height (item),
|
2004-03-15 22:10:30 +08:00
|
|
|
&x, &y, &width, &height))
|
|
|
|
{
|
2004-05-12 16:13:33 +08:00
|
|
|
g_warning ("%s: tried to push empty region", G_STRFUNC);
|
2004-03-15 22:10:30 +08:00
|
|
|
return;
|
|
|
|
}
|
2001-07-08 06:49:01 +08:00
|
|
|
|
2004-04-01 22:51:58 +08:00
|
|
|
GIMP_DRAWABLE_GET_CLASS (drawable)->push_undo (drawable, undo_desc,
|
2012-03-22 21:13:17 +08:00
|
|
|
buffer,
|
2004-04-01 22:51:58 +08:00
|
|
|
x, y, width, height);
|
2001-07-08 06:49:01 +08:00
|
|
|
}
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
void
|
2004-01-06 22:02:08 +08:00
|
|
|
gimp_drawable_fill (GimpDrawable *drawable,
|
2004-07-14 18:31:59 +08:00
|
|
|
const GimpRGB *color,
|
2004-01-06 22:02:08 +08:00
|
|
|
const GimpPattern *pattern)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2004-01-06 22:02:08 +08:00
|
|
|
g_return_if_fail (color != NULL || pattern != NULL);
|
|
|
|
g_return_if_fail (pattern == NULL || GIMP_IS_PATTERN (pattern));
|
2000-02-17 19:44:27 +08:00
|
|
|
|
2004-01-06 22:02:08 +08:00
|
|
|
if (color)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2012-03-18 05:04:11 +08:00
|
|
|
GimpRGB c = *color;
|
2012-03-16 09:21:26 +08:00
|
|
|
GeglColor *col;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2012-03-18 05:04:11 +08:00
|
|
|
if (! gimp_drawable_has_alpha (drawable))
|
|
|
|
gimp_rgb_set_alpha (&c, 1.0);
|
2003-09-06 21:41:58 +08:00
|
|
|
|
2012-03-20 17:27:28 +08:00
|
|
|
col = gimp_gegl_color_new (&c);
|
2012-03-21 07:42:44 +08:00
|
|
|
gegl_buffer_set_color (gimp_drawable_get_buffer (drawable),
|
2012-03-16 09:21:26 +08:00
|
|
|
NULL, col);
|
|
|
|
g_object_unref (col);
|
2004-01-06 22:02:08 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-18 05:04:11 +08:00
|
|
|
GeglBuffer *src_buffer = gimp_pattern_create_buffer (pattern);
|
2012-03-16 09:21:26 +08:00
|
|
|
|
2012-03-21 07:42:44 +08:00
|
|
|
gegl_buffer_set_pattern (gimp_drawable_get_buffer (drawable),
|
2012-03-16 09:21:26 +08:00
|
|
|
NULL, src_buffer, 0, 0);
|
|
|
|
g_object_unref (src_buffer);
|
2004-01-06 22:02:08 +08:00
|
|
|
}
|
2001-07-08 06:49:01 +08:00
|
|
|
|
|
|
|
gimp_drawable_update (drawable,
|
2004-07-14 18:31:59 +08:00
|
|
|
0, 0,
|
2012-03-18 05:04:11 +08:00
|
|
|
gimp_item_get_width (GIMP_ITEM (drawable)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (drawable)));
|
2001-07-08 06:49:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_fill_by_type (GimpDrawable *drawable,
|
2004-07-14 18:31:59 +08:00
|
|
|
GimpContext *context,
|
|
|
|
GimpFillType fill_type)
|
2001-07-08 06:49:01 +08:00
|
|
|
{
|
2004-01-06 22:02:08 +08:00
|
|
|
GimpRGB color;
|
|
|
|
GimpPattern *pattern = NULL;
|
2001-07-08 06:49:01 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
switch (fill_type)
|
|
|
|
{
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_FOREGROUND_FILL:
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_context_get_foreground (context, &color);
|
|
|
|
break;
|
|
|
|
|
2003-09-06 21:41:58 +08:00
|
|
|
case GIMP_BACKGROUND_FILL:
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_context_get_background (context, &color);
|
|
|
|
break;
|
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_WHITE_FILL:
|
2003-09-06 21:41:58 +08:00
|
|
|
gimp_rgba_set (&color, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
|
2001-07-08 06:49:01 +08:00
|
|
|
break;
|
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_TRANSPARENT_FILL:
|
2002-03-04 01:38:12 +08:00
|
|
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, GIMP_OPACITY_TRANSPARENT);
|
2001-07-08 06:49:01 +08:00
|
|
|
break;
|
|
|
|
|
2004-01-06 22:02:08 +08:00
|
|
|
case GIMP_PATTERN_FILL:
|
|
|
|
pattern = gimp_context_get_pattern (context);
|
|
|
|
break;
|
|
|
|
|
2003-09-06 21:41:58 +08:00
|
|
|
case GIMP_NO_FILL:
|
2001-07-08 06:49:01 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2004-05-12 16:13:33 +08:00
|
|
|
g_warning ("%s: unknown fill type %d", G_STRFUNC, fill_type);
|
2001-07-08 06:49:01 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-01-06 22:02:08 +08:00
|
|
|
gimp_drawable_fill (drawable, pattern ? NULL : &color, pattern);
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
2012-03-16 07:01:34 +08:00
|
|
|
const Babl *
|
2012-03-18 23:20:01 +08:00
|
|
|
gimp_drawable_get_format (const GimpDrawable *drawable)
|
2012-03-16 07:01:34 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
2012-03-30 05:19:27 +08:00
|
|
|
return gegl_buffer_get_format (drawable->private->buffer);
|
2012-03-16 07:01:34 +08:00
|
|
|
}
|
|
|
|
|
2012-03-18 04:21:36 +08:00
|
|
|
const Babl *
|
2012-03-18 23:20:01 +08:00
|
|
|
gimp_drawable_get_format_with_alpha (const GimpDrawable *drawable)
|
2012-03-18 04:21:36 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
2012-04-12 00:40:30 +08:00
|
|
|
return gimp_image_get_format (gimp_item_get_image (GIMP_ITEM (drawable)),
|
|
|
|
gimp_drawable_get_base_type (drawable),
|
2012-05-08 03:46:47 +08:00
|
|
|
gimp_drawable_get_precision (drawable),
|
2012-04-12 00:40:30 +08:00
|
|
|
TRUE);
|
2012-03-18 04:21:36 +08:00
|
|
|
}
|
|
|
|
|
2012-03-18 23:24:29 +08:00
|
|
|
const Babl *
|
|
|
|
gimp_drawable_get_format_without_alpha (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
2012-04-12 00:40:30 +08:00
|
|
|
return gimp_image_get_format (gimp_item_get_image (GIMP_ITEM (drawable)),
|
|
|
|
gimp_drawable_get_base_type (drawable),
|
2012-05-08 03:46:47 +08:00
|
|
|
gimp_drawable_get_precision (drawable),
|
2012-04-12 00:40:30 +08:00
|
|
|
FALSE);
|
2012-03-18 23:24:29 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
2000-12-29 00:19:55 +08:00
|
|
|
gimp_drawable_has_alpha (const GimpDrawable *drawable)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
2012-03-30 05:19:27 +08:00
|
|
|
const Babl *format;
|
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2012-03-30 05:19:27 +08:00
|
|
|
format = gegl_buffer_get_format (drawable->private->buffer);
|
|
|
|
|
|
|
|
return babl_format_has_alpha (format);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
1998-10-14 10:54:02 +08:00
|
|
|
|
2012-04-07 07:51:08 +08:00
|
|
|
GimpImageBaseType
|
2012-04-07 07:34:44 +08:00
|
|
|
gimp_drawable_get_base_type (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
const Babl *format;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
format = gegl_buffer_get_format (drawable->private->buffer);
|
|
|
|
|
2012-04-07 08:27:58 +08:00
|
|
|
return gimp_babl_format_get_base_type (format);
|
2012-04-07 07:34:44 +08:00
|
|
|
}
|
|
|
|
|
2012-04-22 23:31:32 +08:00
|
|
|
GimpPrecision
|
|
|
|
gimp_drawable_get_precision (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
const Babl *format;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
format = gegl_buffer_get_format (drawable->private->buffer);
|
|
|
|
|
|
|
|
return gimp_babl_format_get_precision (format);
|
|
|
|
}
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_rgb (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2012-04-07 08:27:58 +08:00
|
|
|
return (gimp_drawable_get_base_type (drawable) == GIMP_RGB);
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_gray (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2012-04-07 08:27:58 +08:00
|
|
|
return (gimp_drawable_get_base_type (drawable) == GIMP_GRAY);
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_drawable_is_indexed (const GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
2012-04-07 08:27:58 +08:00
|
|
|
return (gimp_drawable_get_base_type (drawable) == GIMP_INDEXED);
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
2011-09-24 01:31:50 +08:00
|
|
|
const guchar *
|
|
|
|
gimp_drawable_get_colormap (const GimpDrawable *drawable)
|
2004-04-13 21:54:54 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-04-13 21:54:54 +08:00
|
|
|
|
2011-09-24 01:31:50 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
2004-04-13 21:54:54 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
image = gimp_item_get_image (GIMP_ITEM (drawable));
|
2004-04-13 21:54:54 +08:00
|
|
|
|
2011-09-24 01:31:50 +08:00
|
|
|
return image ? gimp_image_get_colormap (image) : NULL;
|
2004-04-13 21:54:54 +08:00
|
|
|
}
|
|
|
|
|
2011-09-24 01:31:50 +08:00
|
|
|
GimpLayer *
|
|
|
|
gimp_drawable_get_floating_sel (const GimpDrawable *drawable)
|
2001-12-13 07:48:18 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
2011-09-24 01:31:50 +08:00
|
|
|
return drawable->private->floating_selection;
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
2009-01-27 06:05:07 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_attach_floating_sel (GimpDrawable *drawable,
|
2013-04-12 22:57:39 +08:00
|
|
|
GimpLayer *fs)
|
2009-01-27 06:05:07 +08:00
|
|
|
{
|
2009-02-08 03:23:32 +08:00
|
|
|
GimpImage *image;
|
|
|
|
|
2009-01-27 06:05:07 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2009-02-08 03:23:32 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
2011-09-24 01:31:50 +08:00
|
|
|
g_return_if_fail (gimp_drawable_get_floating_sel (drawable) == NULL);
|
2013-04-12 22:57:39 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (fs));
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2010-01-03 06:41:52 +08:00
|
|
|
GIMP_LOG (FLOATING_SELECTION, "%s", G_STRFUNC);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2009-02-08 03:23:32 +08:00
|
|
|
image = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
|
2013-04-12 22:57:39 +08:00
|
|
|
drawable->private->floating_selection = fs;
|
|
|
|
gimp_image_set_floating_selection (image, fs);
|
2009-02-08 03:23:32 +08:00
|
|
|
|
2009-02-08 03:09:55 +08:00
|
|
|
/* clear the selection */
|
2013-04-12 22:57:39 +08:00
|
|
|
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (fs));
|
2009-02-08 03:09:55 +08:00
|
|
|
|
2013-04-12 01:06:23 +08:00
|
|
|
gimp_drawable_sync_fs_filter (drawable, FALSE);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-12 22:57:39 +08:00
|
|
|
g_signal_connect (fs, "update",
|
2009-08-31 23:37:22 +08:00
|
|
|
G_CALLBACK (gimp_drawable_fs_update),
|
|
|
|
drawable);
|
|
|
|
|
2013-04-12 22:57:39 +08:00
|
|
|
gimp_drawable_fs_update (fs,
|
2009-08-31 23:37:22 +08:00
|
|
|
0, 0,
|
2013-04-12 22:57:39 +08:00
|
|
|
gimp_item_get_width (GIMP_ITEM (fs)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (fs)),
|
2009-08-31 23:37:22 +08:00
|
|
|
drawable);
|
2009-01-27 06:05:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-24 01:31:50 +08:00
|
|
|
gimp_drawable_detach_floating_sel (GimpDrawable *drawable)
|
2009-01-27 06:05:07 +08:00
|
|
|
{
|
2009-02-08 03:23:32 +08:00
|
|
|
GimpImage *image;
|
2013-04-12 22:57:39 +08:00
|
|
|
GimpLayer *fs;
|
2009-02-08 03:23:32 +08:00
|
|
|
|
2009-01-27 06:05:07 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2011-09-24 01:31:50 +08:00
|
|
|
g_return_if_fail (gimp_drawable_get_floating_sel (drawable) != NULL);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2010-01-03 06:41:52 +08:00
|
|
|
GIMP_LOG (FLOATING_SELECTION, "%s", G_STRFUNC);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-12 22:57:39 +08:00
|
|
|
image = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
fs = drawable->private->floating_selection;
|
2009-02-08 03:23:32 +08:00
|
|
|
|
2013-04-12 01:06:23 +08:00
|
|
|
gimp_drawable_sync_fs_filter (drawable, TRUE);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-12 22:57:39 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (fs,
|
2009-08-31 23:37:22 +08:00
|
|
|
gimp_drawable_fs_update,
|
|
|
|
drawable);
|
2009-01-27 06:05:07 +08:00
|
|
|
|
2013-04-12 22:57:39 +08:00
|
|
|
gimp_drawable_fs_update (fs,
|
2009-08-31 23:37:22 +08:00
|
|
|
0, 0,
|
2013-04-12 22:57:39 +08:00
|
|
|
gimp_item_get_width (GIMP_ITEM (fs)),
|
|
|
|
gimp_item_get_height (GIMP_ITEM (fs)),
|
2009-08-31 23:37:22 +08:00
|
|
|
drawable);
|
2009-02-08 03:09:55 +08:00
|
|
|
|
|
|
|
/* clear the selection */
|
2013-04-12 22:57:39 +08:00
|
|
|
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (fs));
|
2009-02-08 03:23:32 +08:00
|
|
|
|
|
|
|
gimp_image_set_floating_selection (image, NULL);
|
2011-09-24 01:31:50 +08:00
|
|
|
drawable->private->floating_selection = NULL;
|
2009-01-27 06:05:07 +08:00
|
|
|
}
|
2013-04-12 22:57:39 +08:00
|
|
|
|
|
|
|
GimpFilter *
|
|
|
|
gimp_drawable_get_floating_sel_filter (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
g_return_val_if_fail (gimp_drawable_get_floating_sel (drawable) != NULL, NULL);
|
|
|
|
|
|
|
|
return drawable->private->fs_filter;
|
|
|
|
}
|