1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <string.h>
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
#include <glib-object.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/temp-buf.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
#include "base/tile.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
2003-02-13 19:23:50 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
#include "core/gimppaintinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "gimppaintcore.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
#include "gimppaintcore-undo.h"
|
2002-06-17 18:34:28 +08:00
|
|
|
#include "gimppaintoptions.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-03-05 08:06:11 +08:00
|
|
|
|
2000-05-29 16:40:29 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
/* local function prototypes */
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2004-05-26 20:55:10 +08:00
|
|
|
static void gimp_paint_core_class_init (GimpPaintCoreClass *klass);
|
|
|
|
static void gimp_paint_core_init (GimpPaintCore *core);
|
|
|
|
|
|
|
|
static void gimp_paint_core_finalize (GObject *object);
|
|
|
|
|
|
|
|
static gboolean gimp_paint_core_real_start (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpCoords *coords);
|
|
|
|
static gboolean gimp_paint_core_real_pre_paint (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *options,
|
|
|
|
GimpPaintCoreState paint_state);
|
|
|
|
static void gimp_paint_core_real_paint (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *options,
|
|
|
|
GimpPaintCoreState paint_state);
|
|
|
|
static void gimp_paint_core_real_interpolate (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *options);
|
|
|
|
static TempBuf * gimp_paint_core_real_get_paint_area (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *options);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
static void paint_mask_to_canvas_tiles (GimpPaintCore *core,
|
2004-05-26 19:37:23 +08:00
|
|
|
PixelRegion *paint_maskPR,
|
2004-05-26 04:41:09 +08:00
|
|
|
gdouble paint_opacity);
|
|
|
|
static void paint_mask_to_canvas_buf (GimpPaintCore *core,
|
2004-05-26 19:37:23 +08:00
|
|
|
PixelRegion *paint_maskPR,
|
2004-05-26 04:41:09 +08:00
|
|
|
gdouble paint_opacity);
|
|
|
|
static void canvas_tiles_to_canvas_buf (GimpPaintCore *core);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
static GimpObjectClass *parent_class = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
static gint global_core_ID = 1;
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_get_type (void)
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
static GType core_type = 0;
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (! core_type)
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
static const GTypeInfo core_info =
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
sizeof (GimpPaintCoreClass),
|
2004-05-26 04:41:09 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_paint_core_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpPaintCore),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_paint_core_init,
|
2001-02-27 13:21:12 +08:00
|
|
|
};
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core_type = g_type_register_static (GIMP_TYPE_OBJECT,
|
2004-05-26 04:41:09 +08:00
|
|
|
"GimpPaintCore",
|
2002-02-15 03:31:16 +08:00
|
|
|
&core_info, 0);
|
2001-02-27 13:21:12 +08:00
|
|
|
}
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
return core_type;
|
2001-02-27 13:21:12 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_class_init (GimpPaintCoreClass *klass)
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2001-02-28 03:18:01 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
object_class->finalize = gimp_paint_core_finalize;
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2004-05-26 20:55:10 +08:00
|
|
|
klass->start = gimp_paint_core_real_start;
|
|
|
|
klass->pre_paint = gimp_paint_core_real_pre_paint;
|
|
|
|
klass->paint = gimp_paint_core_real_paint;
|
|
|
|
klass->interpolate = gimp_paint_core_real_interpolate;
|
|
|
|
klass->get_paint_area = gimp_paint_core_real_get_paint_area;
|
2001-02-27 13:21:12 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 03:18:01 +08:00
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_init (GimpPaintCore *core)
|
2001-02-28 03:18:01 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
core->ID = global_core_ID++;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
core->distance = 0.0;
|
|
|
|
core->x1 = 0;
|
|
|
|
core->y1 = 0;
|
|
|
|
core->x2 = 0;
|
|
|
|
core->y2 = 0;
|
2003-07-14 22:50:41 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
core->flags = 0;
|
|
|
|
core->use_pressure = FALSE;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
core->undo_tiles = NULL;
|
|
|
|
core->canvas_tiles = NULL;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
core->orig_buf = NULL;
|
|
|
|
core->canvas_buf = NULL;
|
2002-02-13 22:50:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_finalize (GObject *object)
|
2002-02-13 22:50:37 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpPaintCore *core = GIMP_PAINT_CORE (object);
|
2002-02-13 22:50:37 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_cleanup (core);
|
2002-02-13 22:50:37 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-02-28 03:18:01 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-05-26 20:55:10 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_paint_core_real_start (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpCoords *coords)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_paint_core_real_pre_paint (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpPaintCoreState paint_state)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_paint_core_real_paint (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpPaintCoreState paint_state)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_paint_core_real_interpolate (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options)
|
|
|
|
{
|
|
|
|
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
|
|
|
|
|
|
|
|
core->last_coords = core->cur_coords;
|
|
|
|
}
|
|
|
|
|
|
|
|
static TempBuf *
|
|
|
|
gimp_paint_core_real_get_paint_area (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_paint (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
2002-02-22 00:02:30 +08:00
|
|
|
GimpPaintOptions *paint_options,
|
2002-02-15 03:31:16 +08:00
|
|
|
GimpPaintCoreState paint_state)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2004-05-26 04:41:09 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
2003-03-04 02:43:11 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options));
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2004-05-26 20:55:10 +08:00
|
|
|
if (GIMP_PAINT_CORE_GET_CLASS (core)->pre_paint (core, drawable,
|
|
|
|
paint_options,
|
|
|
|
paint_state))
|
2002-02-16 01:44:05 +08:00
|
|
|
{
|
2004-05-26 17:32:03 +08:00
|
|
|
if (paint_state == MOTION_PAINT)
|
|
|
|
{
|
|
|
|
/* Save coordinates for gimp_paint_core_interpolate() */
|
|
|
|
core->last_paint.x = core->cur_coords.x;
|
|
|
|
core->last_paint.y = core->cur_coords.y;
|
|
|
|
}
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
GIMP_PAINT_CORE_GET_CLASS (core)->paint (core, drawable,
|
|
|
|
paint_options,
|
|
|
|
paint_state);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-03-05 08:06:11 +08:00
|
|
|
gboolean
|
2002-06-17 18:34:28 +08:00
|
|
|
gimp_paint_core_start (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
GimpCoords *coords)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-05-26 20:55:10 +08:00
|
|
|
GimpItem *item;
|
2001-07-07 20:17:23 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
2004-05-26 04:41:09 +08:00
|
|
|
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
|
2003-03-04 02:43:11 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), FALSE);
|
2002-02-15 03:31:16 +08:00
|
|
|
g_return_val_if_fail (coords != NULL, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
item = GIMP_ITEM (drawable);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core->cur_coords = *coords;
|
1998-06-06 11:49:01 +08:00
|
|
|
|
2004-05-26 20:55:10 +08:00
|
|
|
if (! GIMP_PAINT_CORE_GET_CLASS (core)->start (core, drawable,
|
|
|
|
paint_options,
|
|
|
|
coords))
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
return FALSE;
|
2003-07-25 00:35:25 +08:00
|
|
|
}
|
2002-02-13 22:50:37 +08:00
|
|
|
|
2002-02-07 19:33:01 +08:00
|
|
|
/* Allocate the undo structure */
|
2002-02-15 03:31:16 +08:00
|
|
|
if (core->undo_tiles)
|
2003-05-27 01:02:06 +08:00
|
|
|
tile_manager_unref (core->undo_tiles);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-05-08 21:12:46 +08:00
|
|
|
core->undo_tiles = tile_manager_new (gimp_item_width (item),
|
|
|
|
gimp_item_height (item),
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_drawable_bytes (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Allocate the canvas blocks structure */
|
2002-02-15 03:31:16 +08:00
|
|
|
if (core->canvas_tiles)
|
2003-05-27 01:02:06 +08:00
|
|
|
tile_manager_unref (core->canvas_tiles);
|
2002-02-07 19:33:01 +08:00
|
|
|
|
2003-05-08 21:12:46 +08:00
|
|
|
core->canvas_tiles = tile_manager_new (gimp_item_width (item),
|
|
|
|
gimp_item_height (item),
|
2002-02-15 03:31:16 +08:00
|
|
|
1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Get the initial undo extents */
|
|
|
|
|
2002-06-13 03:18:34 +08:00
|
|
|
core->x1 = core->x2 = core->cur_coords.x;
|
|
|
|
core->y1 = core->y2 = core->cur_coords.y;
|
|
|
|
|
|
|
|
core->last_paint.x = -1e6;
|
|
|
|
core->last_paint.y = -1e6;
|
2003-07-10 20:13:21 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
void
|
|
|
|
gimp_paint_core_finish (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
GimpPaintInfo *paint_info;
|
|
|
|
GimpImage *gimage;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2004-05-26 04:41:09 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
/* Determine if any part of the image has been altered--
|
|
|
|
* if nothing has, then just return...
|
|
|
|
*/
|
2003-02-14 22:14:29 +08:00
|
|
|
if ((core->x2 == core->x1) || (core->y2 == core->y1))
|
2002-02-16 01:44:05 +08:00
|
|
|
return;
|
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
paint_info = (GimpPaintInfo *)
|
|
|
|
gimp_container_get_child_by_name (gimage->gimp->paint_info_list,
|
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (core)));
|
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_PAINT,
|
2003-02-14 22:14:29 +08:00
|
|
|
paint_info ? paint_info->blurb : _("Paint"));
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_paint_core_push_undo (gimage, NULL, core);
|
2002-02-16 01:44:05 +08:00
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_drawable_push_undo (drawable, NULL,
|
2002-06-07 03:44:05 +08:00
|
|
|
core->x1, core->y1,
|
|
|
|
core->x2, core->y2,
|
|
|
|
core->undo_tiles,
|
|
|
|
TRUE);
|
2003-05-27 01:02:06 +08:00
|
|
|
|
|
|
|
tile_manager_unref (core->undo_tiles);
|
2002-02-16 01:44:05 +08:00
|
|
|
core->undo_tiles = NULL;
|
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
2002-02-16 01:44:05 +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
|
|
|
/* invalidate the previews -- have to do it here, because
|
2002-02-16 01:44:05 +08:00
|
|
|
* it is not done during the actual painting.
|
|
|
|
*/
|
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (drawable));
|
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 (gimage));
|
2002-02-16 01:44:05 +08:00
|
|
|
}
|
|
|
|
|
2003-09-17 20:05:11 +08:00
|
|
|
static void
|
|
|
|
gimp_paint_core_copy_valid_tiles (TileManager *src_tiles,
|
|
|
|
TileManager *dest_tiles,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
|
|
|
{
|
|
|
|
Tile *src_tile;
|
|
|
|
gint i, j;
|
|
|
|
|
|
|
|
for (i = y; i < (y + h); i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
|
|
|
|
{
|
|
|
|
for (j = x; j < (x + w); j += (TILE_WIDTH - (j % TILE_WIDTH)))
|
|
|
|
{
|
|
|
|
src_tile = tile_manager_get_tile (src_tiles,
|
|
|
|
j, i, FALSE, FALSE);
|
|
|
|
|
2004-02-19 02:57:43 +08:00
|
|
|
if (tile_is_valid (src_tile))
|
2003-09-17 20:05:11 +08:00
|
|
|
{
|
|
|
|
src_tile = tile_manager_get_tile (src_tiles,
|
|
|
|
j, i, TRUE, FALSE);
|
|
|
|
|
|
|
|
tile_manager_map_tile (dest_tiles, j, i, src_tile);
|
|
|
|
|
|
|
|
tile_release (src_tile, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_paint_core_cancel (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2004-05-26 04:41:09 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
2003-09-17 20:05:11 +08:00
|
|
|
|
|
|
|
/* Determine if any part of the image has been altered--
|
|
|
|
* if nothing has, then just return...
|
|
|
|
*/
|
|
|
|
if ((core->x2 == core->x1) || (core->y2 == core->y1))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gimp_paint_core_copy_valid_tiles (core->undo_tiles,
|
|
|
|
gimp_drawable_data (drawable),
|
|
|
|
core->x1, core->y1,
|
|
|
|
core->x2 - core->x1,
|
|
|
|
core->y2 - core->y1);
|
|
|
|
|
|
|
|
tile_manager_unref (core->undo_tiles);
|
|
|
|
core->undo_tiles = NULL;
|
|
|
|
|
|
|
|
gimp_drawable_update (drawable,
|
|
|
|
core->x1, core->y1,
|
|
|
|
core->x2 - core->x1, core->y2 - core->y1);
|
|
|
|
}
|
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
void
|
|
|
|
gimp_paint_core_cleanup (GimpPaintCore *core)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
|
|
|
|
|
|
|
|
if (core->undo_tiles)
|
|
|
|
{
|
2003-05-27 01:02:06 +08:00
|
|
|
tile_manager_unref (core->undo_tiles);
|
2002-02-16 01:44:05 +08:00
|
|
|
core->undo_tiles = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (core->canvas_tiles)
|
|
|
|
{
|
2003-05-27 01:02:06 +08:00
|
|
|
tile_manager_unref (core->canvas_tiles);
|
2002-02-16 01:44:05 +08:00
|
|
|
core->canvas_tiles = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (core->orig_buf)
|
|
|
|
{
|
|
|
|
temp_buf_free (core->orig_buf);
|
|
|
|
core->orig_buf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (core->canvas_buf)
|
|
|
|
{
|
|
|
|
temp_buf_free (core->canvas_buf);
|
|
|
|
core->canvas_buf = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-23 21:22:38 +08:00
|
|
|
/**
|
|
|
|
* gimp_paint_core_constrain_helper:
|
|
|
|
* @dx: the (fixed) delta-x
|
|
|
|
* @dy: a suggested delta-y
|
2003-07-10 20:13:21 +08:00
|
|
|
*
|
2003-05-23 21:22:38 +08:00
|
|
|
* Returns an adjusted dy' near dy such that the slope (dx,dy') is a
|
|
|
|
* multiple of 15 degrees.
|
|
|
|
**/
|
|
|
|
static gdouble
|
|
|
|
gimp_paint_core_constrain_helper (gdouble dx,
|
|
|
|
gdouble dy)
|
|
|
|
{
|
2004-05-26 20:55:10 +08:00
|
|
|
static gdouble slope[4] = { 0, 0.26795, 0.57735, 1 };
|
2003-05-23 21:22:38 +08:00
|
|
|
static gdouble divider[3] = { 0.13165, 0.41421, 0.76732 };
|
2004-05-26 20:55:10 +08:00
|
|
|
gint i;
|
2003-05-23 21:22:38 +08:00
|
|
|
|
|
|
|
if (dy < 0)
|
|
|
|
return - gimp_paint_core_constrain_helper (dx,-dy);
|
|
|
|
dx = fabs (dx);
|
|
|
|
for (i = 0; i < 3; i ++)
|
|
|
|
if (dy < dx * divider[i])
|
|
|
|
break;
|
|
|
|
dy = dx * slope[i];
|
|
|
|
return dy;
|
|
|
|
}
|
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
/**
|
|
|
|
* gimp_paint_core_constrain:
|
|
|
|
* @core: the #GimpPaintCore.
|
2003-05-23 21:22:38 +08:00
|
|
|
*
|
|
|
|
* Restricts the (core->last_coords, core->cur_coords) vector to 15
|
|
|
|
* degree steps, possibly changing core->cur_coords.
|
2002-02-16 01:44:05 +08:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_paint_core_constrain (GimpPaintCore *core)
|
|
|
|
{
|
2003-05-23 21:22:38 +08:00
|
|
|
gdouble dx, dy;
|
2002-02-16 01:44:05 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
|
|
|
|
|
|
|
|
dx = core->cur_coords.x - core->last_coords.x;
|
|
|
|
dy = core->cur_coords.y - core->last_coords.y;
|
|
|
|
|
2003-05-23 21:22:38 +08:00
|
|
|
/* This algorithm changes only one of dx and dy, and does not try
|
|
|
|
* to constrain the resulting dx and dy to integers. This gives
|
|
|
|
* at least two benefits:
|
|
|
|
* 1. gimp_paint_core_constrain is idempotent, even if followed by
|
|
|
|
* a rounding operation.
|
|
|
|
* 2. For any two lines with the same starting-point and ideal
|
|
|
|
* 15-degree direction, the points plotted by
|
|
|
|
* gimp_paint_core_interpolate for the shorter line will always
|
|
|
|
* be a superset of those plotted for the longer line.
|
|
|
|
*/
|
2004-05-26 20:55:10 +08:00
|
|
|
if (fabs (dx) > fabs (dy))
|
2003-05-23 21:22:38 +08:00
|
|
|
core->cur_coords.y = core->last_coords.y +
|
|
|
|
gimp_paint_core_constrain_helper (dx,dy);
|
|
|
|
else
|
|
|
|
core->cur_coords.x = core->last_coords.x +
|
|
|
|
gimp_paint_core_constrain_helper (dy,dx);
|
2002-02-16 01:44:05 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2002-02-22 00:02:30 +08:00
|
|
|
gimp_paint_core_interpolate (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PAINT_CORE (core));
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2004-05-26 04:41:09 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
2003-03-04 02:43:11 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options));
|
2002-02-15 03:31:16 +08:00
|
|
|
|
2004-05-26 20:55:10 +08:00
|
|
|
GIMP_PAINT_CORE_GET_CLASS (core)->interpolate (core, drawable,
|
|
|
|
paint_options);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-06-06 11:49:01 +08:00
|
|
|
|
2002-02-16 01:44:05 +08:00
|
|
|
/* protected functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
TempBuf *
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_get_paint_area (GimpPaintCore *core,
|
2001-02-28 03:18:01 +08:00
|
|
|
GimpDrawable *drawable,
|
2004-05-26 17:32:03 +08:00
|
|
|
GimpPaintOptions *paint_options)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
|
2004-05-26 17:32:03 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), NULL);
|
1998-07-25 02:52:03 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
return GIMP_PAINT_CORE_GET_CLASS (core)->get_paint_area (core, drawable,
|
2004-05-26 17:32:03 +08:00
|
|
|
paint_options);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TempBuf *
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_paint_core_get_orig_image (GimpPaintCore *core,
|
2001-02-28 03:18:01 +08:00
|
|
|
GimpDrawable *drawable,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-06 06:08:45 +08:00
|
|
|
PixelRegion srcPR;
|
|
|
|
PixelRegion destPR;
|
|
|
|
Tile *undo_tile;
|
|
|
|
gint h;
|
|
|
|
gint refd;
|
|
|
|
gint pixelwidth;
|
|
|
|
gint dwidth;
|
|
|
|
gint dheight;
|
|
|
|
guchar *s;
|
|
|
|
guchar *d;
|
|
|
|
gpointer pr;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
core->orig_buf = temp_buf_resize (core->orig_buf,
|
|
|
|
gimp_drawable_bytes (drawable),
|
|
|
|
x1, y1,
|
|
|
|
(x2 - x1), (y2 - y1));
|
1998-07-25 02:52:03 +08:00
|
|
|
|
2003-05-08 21:12:46 +08:00
|
|
|
dwidth = gimp_item_width (GIMP_ITEM (drawable));
|
|
|
|
dheight = gimp_item_height (GIMP_ITEM (drawable));
|
1998-07-25 02:52:03 +08:00
|
|
|
|
2000-01-26 07:06:12 +08:00
|
|
|
x1 = CLAMP (x1, 0, dwidth);
|
|
|
|
y1 = CLAMP (y1, 0, dheight);
|
|
|
|
x2 = CLAMP (x2, 0, dwidth);
|
|
|
|
y2 = CLAMP (y2, 0, dheight);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* configure the pixel regions */
|
2002-02-13 22:50:37 +08:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
|
|
|
x1, y1,
|
|
|
|
(x2 - x1), (y2 - y1),
|
|
|
|
FALSE);
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
destPR.bytes = core->orig_buf->bytes;
|
2002-02-13 22:50:37 +08:00
|
|
|
destPR.x = 0;
|
|
|
|
destPR.y = 0;
|
|
|
|
destPR.w = (x2 - x1);
|
|
|
|
destPR.h = (y2 - y1);
|
2002-02-15 03:31:16 +08:00
|
|
|
destPR.rowstride = core->orig_buf->bytes * core->orig_buf->width;
|
|
|
|
destPR.data = (temp_buf_data (core->orig_buf) +
|
|
|
|
(y1 - core->orig_buf->y) * destPR.rowstride +
|
|
|
|
(x1 - core->orig_buf->x) * destPR.bytes);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-25 02:52:03 +08:00
|
|
|
for (pr = pixel_regions_register (2, &srcPR, &destPR);
|
|
|
|
pr != NULL;
|
|
|
|
pr = pixel_regions_process (pr))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* If the undo tile corresponding to this location is valid, use it */
|
2002-02-15 03:31:16 +08:00
|
|
|
undo_tile = tile_manager_get_tile (core->undo_tiles,
|
2002-02-13 22:50:37 +08:00
|
|
|
srcPR.x, srcPR.y,
|
1998-08-16 03:17:36 +08:00
|
|
|
FALSE, FALSE);
|
2004-02-19 02:57:43 +08:00
|
|
|
|
|
|
|
if (tile_is_valid (undo_tile))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-07-10 12:33:21 +08:00
|
|
|
refd = 1;
|
2002-02-15 03:31:16 +08:00
|
|
|
undo_tile = tile_manager_get_tile (core->undo_tiles,
|
2002-02-13 22:50:37 +08:00
|
|
|
srcPR.x, srcPR.y,
|
1998-08-16 03:17:36 +08:00
|
|
|
TRUE, FALSE);
|
2004-02-19 02:57:43 +08:00
|
|
|
s = (guchar *) tile_data_pointer (undo_tile, 0, 0) +
|
1998-08-12 01:35:34 +08:00
|
|
|
srcPR.rowstride * (srcPR.y % TILE_HEIGHT) +
|
|
|
|
srcPR.bytes * (srcPR.x % TILE_WIDTH); /* dubious... */
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-07-11 22:00:55 +08:00
|
|
|
refd = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
s = srcPR.data;
|
|
|
|
}
|
|
|
|
|
|
|
|
d = destPR.data;
|
|
|
|
pixelwidth = srcPR.w * srcPR.bytes;
|
|
|
|
h = srcPR.h;
|
|
|
|
while (h --)
|
|
|
|
{
|
|
|
|
memcpy (d, s, pixelwidth);
|
|
|
|
s += srcPR.rowstride;
|
|
|
|
d += destPR.rowstride;
|
|
|
|
}
|
|
|
|
|
1998-07-10 12:33:21 +08:00
|
|
|
if (refd)
|
|
|
|
tile_release (undo_tile, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
return core->orig_buf;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-19 23:05:38 +08:00
|
|
|
gimp_paint_core_paste (GimpPaintCore *core,
|
2004-05-26 19:37:23 +08:00
|
|
|
PixelRegion *paint_maskPR,
|
2002-03-19 23:05:38 +08:00
|
|
|
GimpDrawable *drawable,
|
2004-05-26 04:41:09 +08:00
|
|
|
gdouble paint_opacity,
|
2002-03-19 23:05:38 +08:00
|
|
|
gdouble image_opacity,
|
|
|
|
GimpLayerModeEffects paint_mode,
|
|
|
|
GimpPaintApplicationMode mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-06 06:08:45 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
PixelRegion srcPR;
|
1997-11-25 06:05:25 +08:00
|
|
|
TileManager *alt = NULL;
|
2000-06-06 06:08:45 +08:00
|
|
|
gint offx;
|
|
|
|
gint offy;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* set undo blocks */
|
2004-05-26 19:37:23 +08:00
|
|
|
gimp_paint_core_validate_undo_tiles (core, drawable,
|
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* If the mode is CONSTANT:
|
2004-05-26 04:41:09 +08:00
|
|
|
* combine the canvas buf, the paint mask to the canvas tiles
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2002-03-19 23:05:38 +08:00
|
|
|
if (mode == GIMP_PAINT_CONSTANT)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-05-26 19:37:23 +08:00
|
|
|
/* Some tools (ink) paint the mask to paint_core->canvas_tiles
|
|
|
|
* directly. Don't need to copy it in this case.
|
|
|
|
*/
|
|
|
|
if (paint_maskPR->tiles != core->canvas_tiles)
|
|
|
|
{
|
|
|
|
/* initialize any invalid canvas tiles */
|
|
|
|
gimp_paint_core_validate_canvas_tiles (core,
|
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height);
|
|
|
|
|
|
|
|
paint_mask_to_canvas_tiles (core, paint_maskPR, paint_opacity);
|
|
|
|
}
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
canvas_tiles_to_canvas_buf (core);
|
|
|
|
alt = core->undo_tiles;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
/* Otherwise:
|
2004-05-26 04:41:09 +08:00
|
|
|
* combine the canvas buf and the paint mask to the canvas buf
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-31 12:07:42 +08:00
|
|
|
else
|
|
|
|
{
|
2004-05-26 19:37:23 +08:00
|
|
|
paint_mask_to_canvas_buf (core, paint_maskPR, paint_opacity);
|
2000-12-31 12:07:42 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* intialize canvas buf source pixel regions */
|
2002-02-15 03:31:16 +08:00
|
|
|
srcPR.bytes = core->canvas_buf->bytes;
|
2002-02-13 22:50:37 +08:00
|
|
|
srcPR.x = 0;
|
|
|
|
srcPR.y = 0;
|
2002-02-15 03:31:16 +08:00
|
|
|
srcPR.w = core->canvas_buf->width;
|
|
|
|
srcPR.h = core->canvas_buf->height;
|
|
|
|
srcPR.rowstride = core->canvas_buf->width * core->canvas_buf->bytes;
|
|
|
|
srcPR.data = temp_buf_data (core->canvas_buf);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* apply the paint area to the gimage */
|
2003-10-06 22:40:12 +08:00
|
|
|
gimp_drawable_apply_region (drawable, &srcPR,
|
|
|
|
FALSE, NULL,
|
|
|
|
image_opacity, paint_mode,
|
|
|
|
alt, /* specify an alternative src1 */
|
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Update the undo extents */
|
2002-02-15 03:31:16 +08:00
|
|
|
core->x1 = MIN (core->x1, core->canvas_buf->x);
|
|
|
|
core->y1 = MIN (core->y1, core->canvas_buf->y);
|
|
|
|
core->x2 = MAX (core->x2, core->canvas_buf->x + core->canvas_buf->width);
|
|
|
|
core->y2 = MAX (core->y2, core->canvas_buf->y + core->canvas_buf->height);
|
1997-11-25 06:05:25 +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
|
|
|
/* Update the gimage -- It is important to call gimp_image_update()
|
|
|
|
* instead of gimp_drawable_update() because we don't want the
|
|
|
|
* drawable and image previews to be constantly invalidated
|
1997-12-08 09:13:10 +08:00
|
|
|
*/
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &offx, &offy);
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_image_update (gimage,
|
2002-02-15 03:31:16 +08:00
|
|
|
core->canvas_buf->x + offx,
|
|
|
|
core->canvas_buf->y + offy,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height);
|
1997-12-08 09:13:10 +08:00
|
|
|
}
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
/* This works similarly to gimp_paint_core_paste. However, instead of
|
|
|
|
* combining the canvas to the paint core drawable using one of the
|
|
|
|
* combination modes, it uses a "replace" mode (i.e. transparent
|
|
|
|
* pixels in the canvas erase the paint core drawable).
|
1997-12-08 09:13:10 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
* When not drawing on alpha-enabled images, it just paints using
|
|
|
|
* NORMAL mode.
|
|
|
|
*/
|
2004-05-26 04:41:09 +08:00
|
|
|
void
|
2002-03-19 23:05:38 +08:00
|
|
|
gimp_paint_core_replace (GimpPaintCore *core,
|
2004-05-26 19:37:23 +08:00
|
|
|
PixelRegion *paint_maskPR,
|
2002-03-19 23:05:38 +08:00
|
|
|
GimpDrawable *drawable,
|
2004-05-26 04:41:09 +08:00
|
|
|
gdouble paint_opacity,
|
2002-03-19 23:05:38 +08:00
|
|
|
gdouble image_opacity,
|
|
|
|
GimpPaintApplicationMode mode)
|
1997-12-08 09:13:10 +08:00
|
|
|
{
|
2000-06-06 06:08:45 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
PixelRegion srcPR;
|
|
|
|
gint offx;
|
|
|
|
gint offy;
|
1997-12-08 09:13:10 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
if (! gimp_drawable_has_alpha (drawable))
|
1997-12-08 09:13:10 +08:00
|
|
|
{
|
2004-05-26 19:37:23 +08:00
|
|
|
gimp_paint_core_paste (core, paint_maskPR, drawable,
|
2004-05-26 04:41:09 +08:00
|
|
|
paint_opacity,
|
2002-03-04 01:38:12 +08:00
|
|
|
image_opacity, GIMP_NORMAL_MODE,
|
2001-02-28 03:18:01 +08:00
|
|
|
mode);
|
1997-12-08 09:13:10 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
1997-12-08 09:13:10 +08:00
|
|
|
|
|
|
|
/* set undo blocks */
|
2004-05-26 19:37:23 +08:00
|
|
|
gimp_paint_core_validate_undo_tiles (core, drawable,
|
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height);
|
1997-12-08 09:13:10 +08:00
|
|
|
|
2002-03-19 23:05:38 +08:00
|
|
|
if (mode == GIMP_PAINT_CONSTANT)
|
2000-03-05 08:06:11 +08:00
|
|
|
{
|
2004-05-26 19:37:23 +08:00
|
|
|
/* Some tools (ink) paint the mask to paint_core->canvas_tiles
|
|
|
|
* directly. Don't need to copy it in this case.
|
|
|
|
*/
|
|
|
|
if (paint_maskPR->tiles != core->canvas_tiles)
|
|
|
|
{
|
|
|
|
/* initialize any invalid canvas tiles */
|
|
|
|
gimp_paint_core_validate_canvas_tiles (core,
|
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height);
|
|
|
|
|
|
|
|
/* combine the paint mask and the canvas tiles */
|
|
|
|
paint_mask_to_canvas_tiles (core, paint_maskPR, paint_opacity);
|
|
|
|
|
|
|
|
/* initialize the maskPR from the canvas tiles */
|
|
|
|
pixel_region_init (paint_maskPR, core->canvas_tiles,
|
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height,
|
|
|
|
FALSE);
|
|
|
|
}
|
2000-03-05 08:06:11 +08:00
|
|
|
}
|
2000-12-31 12:07:42 +08:00
|
|
|
else
|
2000-03-05 08:06:11 +08:00
|
|
|
{
|
2004-05-26 19:37:23 +08:00
|
|
|
/* The mask is just the paint_maskPR */
|
2000-03-05 08:06:11 +08:00
|
|
|
}
|
2000-12-31 12:07:42 +08:00
|
|
|
|
1997-12-08 09:13:10 +08:00
|
|
|
/* intialize canvas buf source pixel regions */
|
2002-02-15 03:31:16 +08:00
|
|
|
srcPR.bytes = core->canvas_buf->bytes;
|
2001-02-27 13:21:12 +08:00
|
|
|
srcPR.x = 0;
|
2000-06-06 06:08:45 +08:00
|
|
|
srcPR.y = 0;
|
2002-02-15 03:31:16 +08:00
|
|
|
srcPR.w = core->canvas_buf->width;
|
|
|
|
srcPR.h = core->canvas_buf->height;
|
|
|
|
srcPR.rowstride = core->canvas_buf->width * core->canvas_buf->bytes;
|
|
|
|
srcPR.data = temp_buf_data (core->canvas_buf);
|
1997-12-08 09:13:10 +08:00
|
|
|
|
|
|
|
/* apply the paint area to the gimage */
|
2003-10-06 22:40:12 +08:00
|
|
|
gimp_drawable_replace_region (drawable, &srcPR,
|
|
|
|
FALSE, NULL,
|
|
|
|
image_opacity,
|
2004-05-26 19:37:23 +08:00
|
|
|
paint_maskPR,
|
2003-10-06 22:40:12 +08:00
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y);
|
1997-12-08 09:13:10 +08:00
|
|
|
|
|
|
|
/* Update the undo extents */
|
2002-02-15 03:31:16 +08:00
|
|
|
core->x1 = MIN (core->x1, core->canvas_buf->x);
|
|
|
|
core->y1 = MIN (core->y1, core->canvas_buf->y);
|
|
|
|
core->x2 = MAX (core->x2, core->canvas_buf->x + core->canvas_buf->width) ;
|
|
|
|
core->y2 = MAX (core->y2, core->canvas_buf->y + core->canvas_buf->height) ;
|
1997-12-08 09:13:10 +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
|
|
|
/* Update the gimage -- It is important to call gimp_image_update()
|
|
|
|
* instead of gimp_drawable_update() because we don't want the
|
|
|
|
* drawable and image previews to be constantly invalidated
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &offx, &offy);
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_image_update (gimage,
|
2002-02-15 03:31:16 +08:00
|
|
|
core->canvas_buf->x + offx,
|
|
|
|
core->canvas_buf->y + offy,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-07-02 00:52:50 +08:00
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
canvas_tiles_to_canvas_buf (GimpPaintCore *core)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2000-06-06 06:08:45 +08:00
|
|
|
PixelRegion srcPR;
|
|
|
|
PixelRegion maskPR;
|
1999-07-02 00:52:50 +08:00
|
|
|
|
|
|
|
/* combine the canvas tiles and the canvas buf */
|
2002-02-15 03:31:16 +08:00
|
|
|
srcPR.bytes = core->canvas_buf->bytes;
|
2001-02-27 13:21:12 +08:00
|
|
|
srcPR.x = 0;
|
2000-06-06 06:08:45 +08:00
|
|
|
srcPR.y = 0;
|
2002-02-15 03:31:16 +08:00
|
|
|
srcPR.w = core->canvas_buf->width;
|
|
|
|
srcPR.h = core->canvas_buf->height;
|
|
|
|
srcPR.rowstride = core->canvas_buf->width * core->canvas_buf->bytes;
|
|
|
|
srcPR.data = temp_buf_data (core->canvas_buf);
|
|
|
|
|
|
|
|
pixel_region_init (&maskPR, core->canvas_tiles,
|
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height,
|
2002-02-13 22:50:37 +08:00
|
|
|
FALSE);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
|
|
|
/* apply the canvas tiles to the canvas buf */
|
|
|
|
apply_mask_to_region (&srcPR, &maskPR, OPAQUE_OPACITY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-26 04:41:09 +08:00
|
|
|
paint_mask_to_canvas_tiles (GimpPaintCore *core,
|
2004-05-26 19:37:23 +08:00
|
|
|
PixelRegion *paint_maskPR,
|
2004-05-26 04:41:09 +08:00
|
|
|
gdouble paint_opacity)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2000-06-06 06:08:45 +08:00
|
|
|
PixelRegion srcPR;
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
/* combine the paint mask and the canvas tiles */
|
2002-02-15 03:31:16 +08:00
|
|
|
pixel_region_init (&srcPR, core->canvas_tiles,
|
|
|
|
core->canvas_buf->x,
|
|
|
|
core->canvas_buf->y,
|
|
|
|
core->canvas_buf->width,
|
|
|
|
core->canvas_buf->height,
|
2002-02-13 22:50:37 +08:00
|
|
|
TRUE);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
|
|
|
/* combine the mask to the canvas tiles */
|
2004-05-26 19:37:23 +08:00
|
|
|
combine_mask_and_region (&srcPR, paint_maskPR, paint_opacity * 255.999);
|
1999-07-02 00:52:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-05-26 04:41:09 +08:00
|
|
|
paint_mask_to_canvas_buf (GimpPaintCore *core,
|
2004-05-26 19:37:23 +08:00
|
|
|
PixelRegion *paint_maskPR,
|
2004-05-26 04:41:09 +08:00
|
|
|
gdouble paint_opacity)
|
1999-07-02 00:52:50 +08:00
|
|
|
{
|
2000-06-06 06:08:45 +08:00
|
|
|
PixelRegion srcPR;
|
1999-07-02 00:52:50 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
/* combine the canvas buf and the paint mask to the canvas buf */
|
2002-02-15 03:31:16 +08:00
|
|
|
srcPR.bytes = core->canvas_buf->bytes;
|
2001-02-27 13:21:12 +08:00
|
|
|
srcPR.x = 0;
|
2000-06-06 06:08:45 +08:00
|
|
|
srcPR.y = 0;
|
2002-02-15 03:31:16 +08:00
|
|
|
srcPR.w = core->canvas_buf->width;
|
|
|
|
srcPR.h = core->canvas_buf->height;
|
|
|
|
srcPR.rowstride = core->canvas_buf->width * core->canvas_buf->bytes;
|
|
|
|
srcPR.data = temp_buf_data (core->canvas_buf);
|
1999-07-02 00:52:50 +08:00
|
|
|
|
|
|
|
/* apply the mask */
|
2004-05-26 19:37:23 +08:00
|
|
|
apply_mask_to_region (&srcPR, paint_maskPR, paint_opacity * 255.999);
|
1999-07-02 00:52:50 +08:00
|
|
|
}
|
|
|
|
|
2004-05-26 19:37:23 +08:00
|
|
|
void
|
|
|
|
gimp_paint_core_validate_undo_tiles (GimpPaintCore *core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-06 06:08:45 +08:00
|
|
|
gint i;
|
|
|
|
gint j;
|
1997-11-25 06:05:25 +08:00
|
|
|
Tile *src_tile;
|
|
|
|
Tile *dest_tile;
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
if (! core->undo_tiles)
|
1998-08-16 03:17:36 +08:00
|
|
|
{
|
1999-11-23 06:38:02 +08:00
|
|
|
g_warning ("set_undo_tiles: undo_tiles is null");
|
1998-08-16 03:17:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = y; i < (y + h); i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
|
|
|
|
{
|
|
|
|
for (j = x; j < (x + w); j += (TILE_WIDTH - (j % TILE_WIDTH)))
|
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
dest_tile = tile_manager_get_tile (core->undo_tiles, j, i,
|
2002-02-13 22:50:37 +08:00
|
|
|
FALSE, FALSE);
|
|
|
|
|
2004-02-19 02:57:43 +08:00
|
|
|
if (! tile_is_valid (dest_tile))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-15 05:11:52 +08:00
|
|
|
src_tile = tile_manager_get_tile (gimp_drawable_data (drawable),
|
|
|
|
j, i, TRUE, FALSE);
|
2002-02-15 03:31:16 +08:00
|
|
|
tile_manager_map_tile (core->undo_tiles, j, i, src_tile);
|
1998-07-10 10:43:12 +08:00
|
|
|
tile_release (src_tile, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-26 19:37:23 +08:00
|
|
|
void
|
|
|
|
gimp_paint_core_validate_canvas_tiles (GimpPaintCore *core,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-06-06 06:08:45 +08:00
|
|
|
gint i;
|
|
|
|
gint j;
|
1997-11-25 06:05:25 +08:00
|
|
|
Tile *tile;
|
|
|
|
|
|
|
|
for (i = y; i < (y + h); i += (TILE_HEIGHT - (i % TILE_HEIGHT)))
|
|
|
|
{
|
|
|
|
for (j = x; j < (x + w); j += (TILE_WIDTH - (j % TILE_WIDTH)))
|
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
tile = tile_manager_get_tile (core->canvas_tiles, j, i,
|
2002-02-13 22:50:37 +08:00
|
|
|
FALSE, FALSE);
|
|
|
|
|
2004-02-19 02:57:43 +08:00
|
|
|
if (! tile_is_valid (tile))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
tile = tile_manager_get_tile (core->canvas_tiles, j, i,
|
2002-02-13 22:50:37 +08:00
|
|
|
TRUE, TRUE);
|
2000-06-06 06:08:45 +08:00
|
|
|
memset (tile_data_pointer (tile, 0, 0), 0, tile_size (tile));
|
1998-07-10 10:43:12 +08:00
|
|
|
tile_release (tile, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|