2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +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
|
1997-11-25 06:05:25 +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
|
1997-11-25 06:05:25 +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/>.
|
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"
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2012-07-06 03:42:26 +08:00
|
|
|
#include <cairo.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "core-types.h"
|
2002-05-03 20:45:22 +08:00
|
|
|
|
2012-08-25 04:16:02 +08:00
|
|
|
#include "gegl/gimp-babl.h"
|
2012-03-15 04:16:58 +08:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
2012-07-06 03:42:26 +08:00
|
|
|
#include "gegl/gimptilehandlerprojection.h"
|
2012-03-15 04:16:58 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "gimp.h"
|
2012-06-21 03:44:09 +08:00
|
|
|
#include "gimp-utils.h"
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "gimparea.h"
|
|
|
|
#include "gimpimage.h"
|
|
|
|
#include "gimpmarshal.h"
|
2004-07-14 07:04:05 +08:00
|
|
|
#include "gimppickable.h"
|
2008-11-05 02:06:36 +08:00
|
|
|
#include "gimpprojectable.h"
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "gimpprojection.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2013-08-10 02:20:02 +08:00
|
|
|
#include "gimp-log.h"
|
|
|
|
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2013-08-03 02:43:44 +08:00
|
|
|
/* just a bit less than GDK_PRIORITY_REDRAW */
|
|
|
|
#define GIMP_PROJECTION_IDLE_PRIORITY (G_PRIORITY_HIGH_IDLE + 20 + 1)
|
2013-05-23 03:20:23 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
/* chunk size for one iteration of the chunk renderer */
|
|
|
|
#define GIMP_PROJECTION_CHUNK_WIDTH 256
|
|
|
|
#define GIMP_PROJECTION_CHUNK_HEIGHT 128
|
2008-01-23 04:27:13 +08:00
|
|
|
|
2013-08-10 02:20:02 +08:00
|
|
|
/* how much time, in seconds, do we allow chunk rendering to take */
|
|
|
|
#define GIMP_PROJECTION_CHUNK_TIME 0.01
|
|
|
|
|
2008-01-23 04:27:13 +08:00
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
enum
|
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
UPDATE,
|
|
|
|
LAST_SIGNAL
|
2002-05-10 21:09:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* local function prototypes */
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2008-11-04 20:07:17 +08:00
|
|
|
static void gimp_projection_pickable_iface_init (GimpPickableInterface *iface);
|
|
|
|
|
|
|
|
static void gimp_projection_finalize (GObject *object);
|
|
|
|
|
|
|
|
static gint64 gimp_projection_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
|
|
|
|
|
|
|
static void gimp_projection_pickable_flush (GimpPickable *pickable);
|
|
|
|
static GimpImage * gimp_projection_get_image (GimpPickable *pickable);
|
2012-03-18 23:20:01 +08:00
|
|
|
static const Babl * gimp_projection_get_format (GimpPickable *pickable);
|
2012-06-26 22:09:29 +08:00
|
|
|
static GeglBuffer * gimp_projection_get_buffer (GimpPickable *pickable);
|
2008-11-04 20:07:17 +08:00
|
|
|
static gboolean gimp_projection_get_pixel_at (GimpPickable *pickable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
2012-04-21 16:03:32 +08:00
|
|
|
const Babl *format,
|
|
|
|
gpointer pixel);
|
2012-04-21 22:05:49 +08:00
|
|
|
static gdouble gimp_projection_get_opacity_at (GimpPickable *pickable,
|
2008-11-04 20:07:17 +08:00
|
|
|
gint x,
|
|
|
|
gint y);
|
|
|
|
|
2012-07-06 03:42:26 +08:00
|
|
|
static void gimp_projection_free_buffer (GimpProjection *proj);
|
2008-11-04 20:07:17 +08:00
|
|
|
static void gimp_projection_add_update_area (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
|
|
|
static void gimp_projection_flush_whenever (GimpProjection *proj,
|
|
|
|
gboolean now);
|
2013-07-28 21:57:28 +08:00
|
|
|
static void gimp_projection_chunk_render_start (GimpProjection *proj);
|
|
|
|
static void gimp_projection_chunk_render_stop (GimpProjection *proj);
|
|
|
|
static gboolean gimp_projection_chunk_render_callback (gpointer data);
|
|
|
|
static void gimp_projection_chunk_render_init (GimpProjection *proj);
|
|
|
|
static gboolean gimp_projection_chunk_render_iteration(GimpProjection *proj);
|
|
|
|
static gboolean gimp_projection_chunk_render_next_area(GimpProjection *proj);
|
2008-11-04 20:07:17 +08:00
|
|
|
static void gimp_projection_paint_area (GimpProjection *proj,
|
|
|
|
gboolean now,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
2008-11-05 02:06:36 +08:00
|
|
|
|
2009-08-26 19:06:55 +08:00
|
|
|
static void gimp_projection_projectable_invalidate(GimpProjectable *projectable,
|
2008-11-04 20:07:17 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
|
|
|
GimpProjection *proj);
|
2008-11-05 02:06:36 +08:00
|
|
|
static void gimp_projection_projectable_flush (GimpProjectable *projectable,
|
2008-11-04 20:07:17 +08:00
|
|
|
gboolean invalidate_preview,
|
|
|
|
GimpProjection *proj);
|
2008-11-05 07:22:45 +08:00
|
|
|
static void gimp_projection_projectable_changed (GimpProjectable *projectable,
|
2008-11-05 02:06:36 +08:00
|
|
|
GimpProjection *proj);
|
2004-07-14 00:36:29 +08:00
|
|
|
|
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpProjection, gimp_projection, GIMP_TYPE_OBJECT,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
|
2006-05-15 17:46:31 +08:00
|
|
|
gimp_projection_pickable_iface_init))
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
#define parent_class gimp_projection_parent_class
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
static guint projection_signals[LAST_SIGNAL] = { 0 };
|
2001-02-02 02:44:22 +08:00
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
|
|
|
|
static void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_class_init (GimpProjectionClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
projection_signals[UPDATE] =
|
|
|
|
g_signal_new ("update",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpProjectionClass, update),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__BOOLEAN_INT_INT_INT_INT,
|
|
|
|
G_TYPE_NONE, 5,
|
2004-07-14 00:36:29 +08:00
|
|
|
G_TYPE_BOOLEAN,
|
2006-04-12 20:49:29 +08:00
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT,
|
|
|
|
G_TYPE_INT);
|
2004-07-14 00:36:29 +08:00
|
|
|
|
|
|
|
object_class->finalize = gimp_projection_finalize;
|
|
|
|
|
|
|
|
gimp_object_class->get_memsize = gimp_projection_get_memsize;
|
2001-09-26 01:44:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_init (GimpProjection *proj)
|
2001-09-26 01:44:03 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-07-14 07:04:05 +08:00
|
|
|
static void
|
2005-12-11 03:24:36 +08:00
|
|
|
gimp_projection_pickable_iface_init (GimpPickableInterface *iface)
|
2004-07-14 07:04:05 +08:00
|
|
|
{
|
2012-03-18 23:20:01 +08:00
|
|
|
iface->flush = gimp_projection_pickable_flush;
|
|
|
|
iface->get_image = gimp_projection_get_image;
|
|
|
|
iface->get_format = gimp_projection_get_format;
|
|
|
|
iface->get_format_with_alpha = gimp_projection_get_format; /* sic */
|
|
|
|
iface->get_buffer = gimp_projection_get_buffer;
|
|
|
|
iface->get_pixel_at = gimp_projection_get_pixel_at;
|
|
|
|
iface->get_opacity_at = gimp_projection_get_opacity_at;
|
2004-07-14 07:04:05 +08:00
|
|
|
}
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
static void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_finalize (GObject *object)
|
2002-05-10 21:09:19 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
GimpProjection *proj = GIMP_PROJECTION (object);
|
2004-07-12 19:43:00 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
if (proj->chunk_render.running)
|
|
|
|
gimp_projection_chunk_render_stop (proj);
|
2002-05-10 21:09:19 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_area_list_free (proj->update_areas);
|
2004-07-14 18:31:59 +08:00
|
|
|
proj->update_areas = NULL;
|
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_area_list_free (proj->chunk_render.update_areas);
|
|
|
|
proj->chunk_render.update_areas = NULL;
|
2002-05-10 21:09:19 +08:00
|
|
|
|
2012-07-06 03:42:26 +08:00
|
|
|
gimp_projection_free_buffer (proj);
|
2008-11-11 06:15:40 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2002-05-10 21:09:19 +08:00
|
|
|
}
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
static gint64
|
|
|
|
gimp_projection_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size)
|
2001-09-26 01:44:03 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
GimpProjection *projection = GIMP_PROJECTION (object);
|
2007-06-21 00:15:16 +08:00
|
|
|
gint64 memsize = 0;
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2012-06-21 03:44:09 +08:00
|
|
|
memsize += gimp_gegl_buffer_get_memsize (projection->buffer);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
|
|
|
}
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2007-06-06 18:03:17 +08:00
|
|
|
/**
|
|
|
|
* gimp_projection_estimate_memsize:
|
2012-08-25 04:16:02 +08:00
|
|
|
* @type: the projectable's base type
|
|
|
|
* @precision: the projectable's precision
|
|
|
|
* @width: projection width
|
|
|
|
* @height: projection height
|
2007-06-06 18:03:17 +08:00
|
|
|
*
|
|
|
|
* Calculates a rough estimate of the memory that is required for the
|
|
|
|
* projection of an image with the given @width and @height.
|
|
|
|
*
|
|
|
|
* Return value: a rough estimate of the memory requirements.
|
|
|
|
**/
|
|
|
|
gint64
|
|
|
|
gimp_projection_estimate_memsize (GimpImageBaseType type,
|
2012-08-25 04:16:02 +08:00
|
|
|
GimpPrecision precision,
|
2007-06-06 18:03:17 +08:00
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
2012-08-25 04:16:02 +08:00
|
|
|
const Babl *format;
|
|
|
|
gint64 bytes;
|
2007-06-06 18:48:00 +08:00
|
|
|
|
2012-08-25 04:16:02 +08:00
|
|
|
if (type == GIMP_INDEXED)
|
|
|
|
type = GIMP_RGB;
|
|
|
|
|
|
|
|
format = gimp_babl_format (type, precision, TRUE);
|
|
|
|
bytes = babl_format_get_bytes_per_pixel (format);
|
2007-06-06 18:48:00 +08:00
|
|
|
|
2007-06-21 00:15:16 +08:00
|
|
|
/* The pyramid levels constitute a geometric sum with a ratio of 1/4. */
|
2007-06-06 21:45:44 +08:00
|
|
|
return bytes * (gint64) width * (gint64) height * 1.33;
|
2007-06-06 18:03:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-03 03:30:59 +08:00
|
|
|
static void
|
|
|
|
gimp_projection_pickable_flush (GimpPickable *pickable)
|
|
|
|
{
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
2012-12-19 02:30:33 +08:00
|
|
|
/* create the buffer if it doesn't exist */
|
|
|
|
gimp_projection_get_buffer (pickable);
|
|
|
|
|
2006-03-03 03:30:59 +08:00
|
|
|
gimp_projection_finish_draw (proj);
|
|
|
|
gimp_projection_flush_now (proj);
|
2007-08-02 22:54:29 +08:00
|
|
|
|
|
|
|
if (proj->invalidate_preview)
|
|
|
|
{
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
* the projection
|
|
|
|
*/
|
|
|
|
proj->invalidate_preview = FALSE;
|
|
|
|
|
2008-11-05 04:13:12 +08:00
|
|
|
gimp_projectable_invalidate_preview (proj->projectable);
|
2007-08-02 22:54:29 +08:00
|
|
|
}
|
2006-03-03 03:30:59 +08:00
|
|
|
}
|
|
|
|
|
2008-11-04 20:07:17 +08:00
|
|
|
static GimpImage *
|
|
|
|
gimp_projection_get_image (GimpPickable *pickable)
|
|
|
|
{
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
2008-11-05 02:06:36 +08:00
|
|
|
return gimp_projectable_get_image (proj->projectable);
|
2008-11-04 20:07:17 +08:00
|
|
|
}
|
|
|
|
|
2012-03-17 22:21:11 +08:00
|
|
|
static const Babl *
|
2012-03-18 23:20:01 +08:00
|
|
|
gimp_projection_get_format (GimpPickable *pickable)
|
2012-03-17 22:21:11 +08:00
|
|
|
{
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
2012-03-30 03:09:37 +08:00
|
|
|
return gimp_projectable_get_format (proj->projectable);
|
2012-03-17 22:21:11 +08:00
|
|
|
}
|
|
|
|
|
2012-03-15 21:38:54 +08:00
|
|
|
static GeglBuffer *
|
|
|
|
gimp_projection_get_buffer (GimpPickable *pickable)
|
|
|
|
{
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
|
|
|
if (! proj->buffer)
|
|
|
|
{
|
2012-07-06 03:42:26 +08:00
|
|
|
GeglNode *graph;
|
2012-06-21 03:44:09 +08:00
|
|
|
const Babl *format;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
2012-07-06 03:42:26 +08:00
|
|
|
graph = gimp_projectable_get_graph (proj->projectable);
|
2012-06-21 03:44:09 +08:00
|
|
|
format = gimp_projection_get_format (GIMP_PICKABLE (proj));
|
|
|
|
gimp_projectable_get_size (proj->projectable, &width, &height);
|
2012-03-15 21:38:54 +08:00
|
|
|
|
2012-06-21 03:44:09 +08:00
|
|
|
proj->buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, width, height),
|
|
|
|
format);
|
2012-03-26 21:27:55 +08:00
|
|
|
|
2013-03-31 00:44:59 +08:00
|
|
|
proj->validate_handler = gimp_tile_handler_projection_new (graph,
|
|
|
|
width, height);
|
2012-07-06 03:42:26 +08:00
|
|
|
gegl_buffer_add_handler (proj->buffer, proj->validate_handler);
|
2012-12-16 02:33:21 +08:00
|
|
|
|
|
|
|
/* This used to call gimp_tile_handler_projection_invalidate()
|
|
|
|
* which forced the entire projection to be constructed in one
|
|
|
|
* go for new images, causing a potentially huge delay. Now we
|
|
|
|
* initially validate stuff the normal way, which makes the
|
|
|
|
* image appear incrementally, but it keeps everything
|
|
|
|
* responsive.
|
|
|
|
*/
|
|
|
|
gimp_projection_add_update_area (proj, 0, 0, width, height);
|
|
|
|
proj->invalidate_preview = TRUE;
|
|
|
|
gimp_projection_flush (proj);
|
2012-03-15 21:38:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return proj->buffer;
|
|
|
|
}
|
|
|
|
|
2007-04-28 00:07:49 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_projection_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
|
|
|
{
|
2012-03-19 17:46:47 +08:00
|
|
|
GeglBuffer *buffer = gimp_projection_get_buffer (pickable);
|
2007-04-28 00:07:49 +08:00
|
|
|
|
2012-03-19 17:46:47 +08:00
|
|
|
if (x < 0 ||
|
|
|
|
y < 0 ||
|
|
|
|
x >= gegl_buffer_get_width (buffer) ||
|
|
|
|
y >= gegl_buffer_get_height (buffer))
|
2007-04-28 00:07:49 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2012-04-21 16:03:32 +08:00
|
|
|
gegl_buffer_sample (buffer, 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;
|
|
|
|
}
|
|
|
|
|
2012-04-21 22:05:49 +08:00
|
|
|
static gdouble
|
2005-07-12 03:21:52 +08:00
|
|
|
gimp_projection_get_opacity_at (GimpPickable *pickable,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
|
|
|
{
|
2012-04-21 22:05:49 +08:00
|
|
|
return GIMP_OPACITY_OPAQUE;
|
2005-07-12 03:21:52 +08:00
|
|
|
}
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
GimpProjection *
|
2008-11-05 02:06:36 +08:00
|
|
|
gimp_projection_new (GimpProjectable *projectable)
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
|
|
|
GimpProjection *proj;
|
|
|
|
|
2008-11-05 02:06:36 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
proj = g_object_new (GIMP_TYPE_PROJECTION, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2008-11-05 02:06:36 +08:00
|
|
|
proj->projectable = projectable;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2009-08-26 19:06:55 +08:00
|
|
|
g_signal_connect_object (projectable, "invalidate",
|
|
|
|
G_CALLBACK (gimp_projection_projectable_invalidate),
|
|
|
|
proj, 0);
|
2008-11-05 02:06:36 +08:00
|
|
|
g_signal_connect_object (projectable, "flush",
|
|
|
|
G_CALLBACK (gimp_projection_projectable_flush),
|
2004-07-14 00:36:29 +08:00
|
|
|
proj, 0);
|
2008-11-05 07:22:45 +08:00
|
|
|
g_signal_connect_object (projectable, "structure-changed",
|
|
|
|
G_CALLBACK (gimp_projection_projectable_changed),
|
2004-07-14 00:36:29 +08:00
|
|
|
proj, 0);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
return proj;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-10-02 00:22:28 +08:00
|
|
|
void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_flush (GimpProjection *proj)
|
1998-10-02 00:22:28 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
2001-09-26 01:44:03 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
/* Construct in chunks */
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_flush_whenever (proj, FALSE);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
2001-02-20 23:15:30 +08:00
|
|
|
void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_flush_now (GimpProjection *proj)
|
2001-02-20 23:15:30 +08:00
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
/* Construct NOW */
|
|
|
|
gimp_projection_flush_whenever (proj, TRUE);
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
2001-02-20 23:15:30 +08:00
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
void
|
|
|
|
gimp_projection_finish_draw (GimpProjection *proj)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
if (proj->chunk_render.running)
|
2004-07-14 18:31:59 +08:00
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_projection_chunk_render_stop (proj);
|
2004-07-14 18:31:59 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
while (gimp_projection_chunk_render_iteration (proj));
|
2004-07-14 18:31:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
/* private functions */
|
2002-10-14 21:39:35 +08:00
|
|
|
|
2012-07-06 03:42:26 +08:00
|
|
|
static void
|
|
|
|
gimp_projection_free_buffer (GimpProjection *proj)
|
|
|
|
{
|
|
|
|
if (proj->buffer)
|
|
|
|
{
|
|
|
|
if (proj->validate_handler)
|
|
|
|
gegl_buffer_remove_handler (proj->buffer, proj->validate_handler);
|
|
|
|
|
|
|
|
g_object_unref (proj->buffer);
|
|
|
|
proj->buffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proj->validate_handler)
|
|
|
|
{
|
|
|
|
g_object_unref (proj->validate_handler);
|
|
|
|
proj->validate_handler = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
static void
|
|
|
|
gimp_projection_add_update_area (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
|
|
|
{
|
|
|
|
GimpArea *area;
|
2009-08-24 21:59:14 +08:00
|
|
|
gint off_x, off_y;
|
2008-11-05 02:06:36 +08:00
|
|
|
gint width, height;
|
2004-07-14 18:31:59 +08:00
|
|
|
|
2009-08-24 21:59:14 +08:00
|
|
|
gimp_projectable_get_offset (proj->projectable, &off_x, &off_y);
|
|
|
|
gimp_projectable_get_size (proj->projectable, &width, &height);
|
|
|
|
|
|
|
|
/* subtract the projectable's offsets because the list of update
|
|
|
|
* areas is in tile-pyramid coordinates, but our external API is
|
|
|
|
* always in terms of image coordinates.
|
|
|
|
*/
|
|
|
|
x -= off_x;
|
|
|
|
y -= off_y;
|
2004-07-14 18:31:59 +08:00
|
|
|
|
2008-11-05 02:06:36 +08:00
|
|
|
area = gimp_area_new (CLAMP (x, 0, width),
|
|
|
|
CLAMP (y, 0, height),
|
|
|
|
CLAMP (x + w, 0, width),
|
|
|
|
CLAMP (y + h, 0, height));
|
2004-07-14 18:31:59 +08:00
|
|
|
|
|
|
|
proj->update_areas = gimp_area_list_process (proj->update_areas, area);
|
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
static void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_flush_whenever (GimpProjection *proj,
|
|
|
|
gboolean now)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-11-11 07:03:22 +08:00
|
|
|
/* First the updates... */
|
2004-07-14 00:36:29 +08:00
|
|
|
if (proj->update_areas)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
if (now) /* Synchronous */
|
2003-07-30 00:36:56 +08:00
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
GSList *list;
|
2003-07-30 00:36:56 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
for (list = proj->update_areas; list; list = g_slist_next (list))
|
2003-07-30 00:36:56 +08:00
|
|
|
{
|
2004-07-12 19:43:00 +08:00
|
|
|
GimpArea *area = list->data;
|
2003-07-30 00:36:56 +08:00
|
|
|
|
|
|
|
if ((area->x1 != area->x2) && (area->y1 != area->y2))
|
|
|
|
{
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_paint_area (proj,
|
|
|
|
FALSE, /* sic! */
|
|
|
|
area->x1,
|
|
|
|
area->y1,
|
|
|
|
(area->x2 - area->x1),
|
|
|
|
(area->y2 - area->y1));
|
2003-07-30 00:36:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-12 19:43:00 +08:00
|
|
|
else /* Asynchronous */
|
2003-07-30 00:36:56 +08:00
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_projection_chunk_render_init (proj);
|
2003-07-30 00:36:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the update lists */
|
2007-05-23 02:52:11 +08:00
|
|
|
gimp_area_list_free (proj->update_areas);
|
|
|
|
proj->update_areas = NULL;
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
2007-06-27 05:39:51 +08:00
|
|
|
else if (! now && proj->invalidate_preview)
|
|
|
|
{
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
* the projection
|
|
|
|
*/
|
|
|
|
proj->invalidate_preview = FALSE;
|
|
|
|
|
2008-11-05 04:13:12 +08:00
|
|
|
gimp_projectable_invalidate_preview (proj->projectable);
|
2007-06-27 05:39:51 +08:00
|
|
|
}
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
static void
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_projection_chunk_render_start (GimpProjection *proj)
|
|
|
|
{
|
|
|
|
g_return_if_fail (proj->chunk_render.running == FALSE);
|
|
|
|
|
|
|
|
proj->chunk_render_idle_id =
|
|
|
|
g_idle_add_full (GIMP_PROJECTION_IDLE_PRIORITY,
|
|
|
|
gimp_projection_chunk_render_callback, proj,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
proj->chunk_render.running = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_projection_chunk_render_stop (GimpProjection *proj)
|
|
|
|
{
|
|
|
|
g_return_if_fail (proj->chunk_render.running == TRUE);
|
|
|
|
|
|
|
|
g_source_remove (proj->chunk_render_idle_id);
|
|
|
|
proj->chunk_render_idle_id = 0;
|
|
|
|
|
|
|
|
proj->chunk_render.running = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_projection_chunk_render_callback (gpointer data)
|
|
|
|
{
|
2013-08-10 02:20:02 +08:00
|
|
|
GimpProjection *proj = data;
|
|
|
|
GTimer *timer = g_timer_new ();
|
|
|
|
gint chunks = 0;
|
|
|
|
gboolean retval = TRUE;
|
2013-07-28 21:57:28 +08:00
|
|
|
|
2013-08-10 02:20:02 +08:00
|
|
|
do
|
2013-07-28 21:57:28 +08:00
|
|
|
{
|
2013-08-10 02:20:02 +08:00
|
|
|
if (! gimp_projection_chunk_render_iteration (proj))
|
|
|
|
{
|
|
|
|
gimp_projection_chunk_render_stop (proj);
|
|
|
|
|
|
|
|
retval = FALSE;
|
2013-07-28 21:57:28 +08:00
|
|
|
|
2013-08-10 02:20:02 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
chunks++;
|
2013-07-28 21:57:28 +08:00
|
|
|
}
|
2013-08-10 02:20:02 +08:00
|
|
|
while (g_timer_elapsed (timer, NULL) < GIMP_PROJECTION_CHUNK_TIME);
|
2013-07-28 21:57:28 +08:00
|
|
|
|
2013-08-10 02:20:02 +08:00
|
|
|
GIMP_LOG (PROJECTION, "%d chunks in %f seconds\n",
|
|
|
|
chunks, g_timer_elapsed (timer, NULL));
|
|
|
|
g_timer_destroy (timer);
|
|
|
|
|
|
|
|
return retval;
|
2013-07-28 21:57:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_projection_chunk_render_init (GimpProjection *proj)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2007-05-23 02:52:11 +08:00
|
|
|
GSList *list;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
/* We need to merge the ChunkRender's and the GimpProjection's
|
|
|
|
* update_areas list to keep track of which of the updates have been
|
|
|
|
* flushed and hence need to be drawn.
|
2001-11-11 07:03:22 +08:00
|
|
|
*/
|
2004-07-14 00:36:29 +08:00
|
|
|
for (list = proj->update_areas; list; list = g_slist_next (list))
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2007-05-23 02:52:11 +08:00
|
|
|
GimpArea *area = list->data;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
proj->chunk_render.update_areas =
|
|
|
|
gimp_area_list_process (proj->chunk_render.update_areas,
|
2007-05-23 02:52:11 +08:00
|
|
|
gimp_area_new (area->x1, area->y1,
|
|
|
|
area->x2, area->y2));
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
/* If a chunk renderer was already running, merge the remainder of
|
|
|
|
* its unrendered area with the update_areas list, and make it start
|
|
|
|
* work on the next unrendered area in the list.
|
2001-11-11 07:03:22 +08:00
|
|
|
*/
|
2013-07-28 21:57:28 +08:00
|
|
|
if (proj->chunk_render.running)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2007-05-23 02:52:11 +08:00
|
|
|
GimpArea *area =
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_area_new (proj->chunk_render.base_x,
|
|
|
|
proj->chunk_render.y,
|
|
|
|
proj->chunk_render.base_x + proj->chunk_render.width,
|
|
|
|
proj->chunk_render.y + (proj->chunk_render.height -
|
|
|
|
(proj->chunk_render.y -
|
|
|
|
proj->chunk_render.base_y)));
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
proj->chunk_render.update_areas =
|
|
|
|
gimp_area_list_process (proj->chunk_render.update_areas, area);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_projection_chunk_render_next_area (proj);
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
if (proj->chunk_render.update_areas == NULL)
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
g_warning ("%s: wanted to start chunk render with no update_areas",
|
2004-07-14 18:31:59 +08:00
|
|
|
G_STRFUNC);
|
2004-07-14 00:36:29 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_projection_chunk_render_next_area (proj);
|
2004-07-14 00:36:29 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_projection_chunk_render_start (proj);
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
/* Unless specified otherwise, projection re-rendering is organised by
|
2013-07-28 21:57:28 +08:00
|
|
|
* ChunkRender, which amalgamates areas to be re-rendered and breaks
|
|
|
|
* them into bite-sized chunks which are chewed on in an idle
|
|
|
|
* function. This greatly improves responsiveness for many GIMP
|
2001-11-11 07:03:22 +08:00
|
|
|
* operations. -- Adam
|
|
|
|
*/
|
|
|
|
static gboolean
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_projection_chunk_render_iteration (GimpProjection *proj)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
gint workx = proj->chunk_render.x;
|
|
|
|
gint worky = proj->chunk_render.y;
|
|
|
|
gint workw = GIMP_PROJECTION_CHUNK_WIDTH;
|
|
|
|
gint workh = GIMP_PROJECTION_CHUNK_HEIGHT;
|
2004-07-14 18:31:59 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
if (workx + workw > proj->chunk_render.base_x + proj->chunk_render.width)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
workw = proj->chunk_render.base_x + proj->chunk_render.width - workx;
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
if (worky + workh > proj->chunk_render.base_y + proj->chunk_render.height)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
workh = proj->chunk_render.base_y + proj->chunk_render.height - worky;
|
2003-10-08 22:50:26 +08:00
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
gimp_projection_paint_area (proj, TRUE /* sic! */,
|
2004-07-14 00:36:29 +08:00
|
|
|
workx, worky, workw, workh);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
proj->chunk_render.x += GIMP_PROJECTION_CHUNK_WIDTH;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
if (proj->chunk_render.x >=
|
|
|
|
proj->chunk_render.base_x + proj->chunk_render.width)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
proj->chunk_render.x = proj->chunk_render.base_x;
|
|
|
|
proj->chunk_render.y += GIMP_PROJECTION_CHUNK_HEIGHT;
|
2004-07-14 00:36:29 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
if (proj->chunk_render.y >=
|
|
|
|
proj->chunk_render.base_y + proj->chunk_render.height)
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
2013-07-28 21:57:28 +08:00
|
|
|
if (! gimp_projection_chunk_render_next_area (proj))
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
2007-06-27 05:39:51 +08:00
|
|
|
if (proj->invalidate_preview)
|
|
|
|
{
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
* the projection
|
|
|
|
*/
|
|
|
|
proj->invalidate_preview = FALSE;
|
|
|
|
|
2008-11-05 04:13:12 +08:00
|
|
|
gimp_projectable_invalidate_preview (proj->projectable);
|
2007-06-27 05:39:51 +08:00
|
|
|
}
|
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
/* FINISHED */
|
2004-07-14 00:36:29 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Still work to do. */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-07-28 21:57:28 +08:00
|
|
|
gimp_projection_chunk_render_next_area (GimpProjection *proj)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2001-11-16 23:08:59 +08:00
|
|
|
GimpArea *area;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
if (! proj->chunk_render.update_areas)
|
2001-11-16 23:08:59 +08:00
|
|
|
return FALSE;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
area = proj->chunk_render.update_areas->data;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
proj->chunk_render.update_areas =
|
|
|
|
g_slist_remove (proj->chunk_render.update_areas, area);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
proj->chunk_render.x = proj->chunk_render.base_x = area->x1;
|
|
|
|
proj->chunk_render.y = proj->chunk_render.base_y = area->y1;
|
|
|
|
proj->chunk_render.width = area->x2 - area->x1;
|
|
|
|
proj->chunk_render.height = area->y2 - area->y1;
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2007-05-23 02:52:11 +08:00
|
|
|
gimp_area_free (area);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-07-14 00:36:29 +08:00
|
|
|
gimp_projection_paint_area (GimpProjection *proj,
|
|
|
|
gboolean now,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2009-08-24 21:59:14 +08:00
|
|
|
gint off_x, off_y;
|
2008-11-05 02:06:36 +08:00
|
|
|
gint width, height;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
|
2009-08-24 21:59:14 +08:00
|
|
|
gimp_projectable_get_offset (proj->projectable, &off_x, &off_y);
|
|
|
|
gimp_projectable_get_size (proj->projectable, &width, &height);
|
2008-08-13 00:30:44 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
/* Bounds check */
|
2008-11-05 02:06:36 +08:00
|
|
|
x1 = CLAMP (x, 0, width);
|
|
|
|
y1 = CLAMP (y, 0, height);
|
|
|
|
x2 = CLAMP (x + w, 0, width);
|
|
|
|
y2 = CLAMP (y + h, 0, height);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2013-08-10 22:22:27 +08:00
|
|
|
if (proj->validate_handler)
|
|
|
|
gimp_tile_handler_projection_invalidate (proj->validate_handler,
|
2013-08-10 22:40:24 +08:00
|
|
|
x1, y1, x2 - x1, y2 - y1);
|
2013-08-03 02:43:44 +08:00
|
|
|
if (now)
|
|
|
|
{
|
|
|
|
GeglNode *graph = gimp_projectable_get_graph (proj->projectable);
|
|
|
|
|
|
|
|
gegl_node_blit_buffer (graph, proj->buffer,
|
|
|
|
GEGL_RECTANGLE (x1, y1, x2 - x1, y2 - y1));
|
2013-08-10 22:22:27 +08:00
|
|
|
|
2013-08-03 02:43:44 +08:00
|
|
|
if (proj->validate_handler)
|
2013-08-10 22:22:27 +08:00
|
|
|
gimp_tile_handler_projection_undo_invalidate (proj->validate_handler,
|
|
|
|
x1, y1, x2 - x1, y2 - y1);
|
2013-08-03 02:43:44 +08:00
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2009-08-24 21:59:14 +08:00
|
|
|
/* add the projectable's offsets because the list of update areas
|
|
|
|
* is in tile-pyramid coordinates, but our external API is always
|
|
|
|
* in terms of image coordinates.
|
|
|
|
*/
|
2004-07-14 00:36:29 +08:00
|
|
|
g_signal_emit (proj, projection_signals[UPDATE], 0,
|
2009-08-24 21:59:14 +08:00
|
|
|
now,
|
|
|
|
x1 + off_x,
|
|
|
|
y1 + off_y,
|
|
|
|
x2 - x1,
|
|
|
|
y2 - y1);
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2012-06-21 03:44:09 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
/* image callbacks */
|
|
|
|
|
|
|
|
static void
|
2009-08-26 19:06:55 +08:00
|
|
|
gimp_projection_projectable_invalidate (GimpProjectable *projectable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
|
|
|
GimpProjection *proj)
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
|
|
|
gimp_projection_add_update_area (proj, x, y, w, h);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
2004-07-14 00:36:29 +08:00
|
|
|
|
|
|
|
static void
|
2008-11-05 02:06:36 +08:00
|
|
|
gimp_projection_projectable_flush (GimpProjectable *projectable,
|
|
|
|
gboolean invalidate_preview,
|
|
|
|
GimpProjection *proj)
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
2008-11-05 02:06:36 +08:00
|
|
|
if (invalidate_preview)
|
|
|
|
proj->invalidate_preview = TRUE;
|
2007-06-21 00:15:16 +08:00
|
|
|
|
2008-11-05 02:06:36 +08:00
|
|
|
gimp_projection_flush (proj);
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-05 07:22:45 +08:00
|
|
|
gimp_projection_projectable_changed (GimpProjectable *projectable,
|
|
|
|
GimpProjection *proj)
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
2009-09-03 03:55:14 +08:00
|
|
|
gint off_x, off_y;
|
2008-11-05 02:06:36 +08:00
|
|
|
gint width, height;
|
|
|
|
|
2013-07-28 21:57:28 +08:00
|
|
|
if (proj->chunk_render.running)
|
|
|
|
gimp_projection_chunk_render_stop (proj);
|
2009-09-03 03:55:14 +08:00
|
|
|
|
|
|
|
gimp_area_list_free (proj->update_areas);
|
|
|
|
proj->update_areas = NULL;
|
|
|
|
|
2012-07-06 03:42:26 +08:00
|
|
|
gimp_projection_free_buffer (proj);
|
2012-03-15 21:38:54 +08:00
|
|
|
|
2009-09-03 03:55:14 +08:00
|
|
|
gimp_projectable_get_offset (proj->projectable, &off_x, &off_y);
|
2008-11-06 04:10:51 +08:00
|
|
|
gimp_projectable_get_size (projectable, &width, &height);
|
2007-06-27 05:39:51 +08:00
|
|
|
|
2009-09-03 03:55:14 +08:00
|
|
|
gimp_projection_add_update_area (proj, off_x, off_y, width, height);
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|