2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14: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
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13: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-01 13:30:56 -07:00
|
|
|
#include "config.h"
|
2001-10-29 03:47:11 -08:00
|
|
|
|
2014-06-03 16:23:41 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2012-07-05 12:42:26 -07:00
|
|
|
#include <cairo.h>
|
2013-10-14 16:58:39 -07:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2014-06-01 12:30:11 -07:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2018-03-31 05:13:36 -07:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2014-06-01 12:30:11 -07:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
#include "core-types.h"
|
2002-05-03 05:45:22 -07:00
|
|
|
|
2012-08-24 13:16:02 -07:00
|
|
|
#include "gegl/gimp-babl.h"
|
2018-05-18 11:57:19 -07:00
|
|
|
#include "gegl/gimp-gegl-loops.h"
|
2012-03-14 13:16:58 -07:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
|
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
#include "gimp.h"
|
2014-08-12 04:57:57 -07:00
|
|
|
#include "gimp-memsize.h"
|
2019-01-12 00:36:09 -08:00
|
|
|
#include "gimpchunkiterator.h"
|
2004-07-13 09:36:29 -07:00
|
|
|
#include "gimpimage.h"
|
|
|
|
|
#include "gimpmarshal.h"
|
2004-07-13 16:04:05 -07:00
|
|
|
#include "gimppickable.h"
|
2008-11-04 10:06:36 -08:00
|
|
|
#include "gimpprojectable.h"
|
2004-07-13 09:36:29 -07:00
|
|
|
#include "gimpprojection.h"
|
2017-04-22 11:22:06 -07:00
|
|
|
#include "gimptilehandlerprojectable.h"
|
2000-04-27 10:27:28 -07:00
|
|
|
|
2013-08-09 11:20:02 -07:00
|
|
|
#include "gimp-log.h"
|
2014-07-01 19:47:24 -07:00
|
|
|
#include "gimp-priorities.h"
|
2013-08-09 11:20:02 -07:00
|
|
|
|
2001-07-31 04:33:13 -07:00
|
|
|
|
2018-03-31 05:13:36 -07:00
|
|
|
/* chunk size for area updates */
|
2019-01-12 00:36:09 -08:00
|
|
|
#define GIMP_PROJECTION_UPDATE_CHUNK_WIDTH 32
|
|
|
|
|
#define GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT 32
|
2013-08-09 11:20:02 -07:00
|
|
|
|
2008-01-22 12:27:13 -08:00
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
enum
|
|
|
|
|
{
|
2004-07-13 09:36:29 -07:00
|
|
|
UPDATE,
|
|
|
|
|
LAST_SIGNAL
|
2002-05-10 06:09:19 -07:00
|
|
|
};
|
|
|
|
|
|
2013-09-05 01:37:09 -07:00
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_BUFFER
|
|
|
|
|
};
|
|
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
struct _GimpProjectionPrivate
|
|
|
|
|
{
|
|
|
|
|
GimpProjectable *projectable;
|
|
|
|
|
|
|
|
|
|
GeglBuffer *buffer;
|
2015-03-11 00:14:00 -07:00
|
|
|
GimpTileHandlerValidate *validate_handler;
|
2014-05-30 15:08:43 -07:00
|
|
|
|
2017-12-02 06:48:14 -08:00
|
|
|
gint priority;
|
|
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
cairo_region_t *update_region;
|
2019-01-12 00:36:09 -08:00
|
|
|
GeglRectangle priority_rect;
|
|
|
|
|
GimpChunkIterator *iter;
|
|
|
|
|
guint idle_id;
|
2014-05-30 15:08:43 -07:00
|
|
|
|
|
|
|
|
gboolean invalidate_preview;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2001-10-31 13:20:09 -08:00
|
|
|
/* local function prototypes */
|
2001-07-31 04:33:13 -07:00
|
|
|
|
2008-11-04 04:07:17 -08:00
|
|
|
static void gimp_projection_pickable_iface_init (GimpPickableInterface *iface);
|
|
|
|
|
|
|
|
|
|
static void gimp_projection_finalize (GObject *object);
|
2013-09-05 01:37:09 -07:00
|
|
|
static void gimp_projection_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gimp_projection_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2008-11-04 04:07:17 -08:00
|
|
|
|
|
|
|
|
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 08:20:01 -07:00
|
|
|
static const Babl * gimp_projection_get_format (GimpPickable *pickable);
|
2012-06-26 07:09:29 -07:00
|
|
|
static GeglBuffer * gimp_projection_get_buffer (GimpPickable *pickable);
|
2008-11-04 04:07:17 -08:00
|
|
|
static gboolean gimp_projection_get_pixel_at (GimpPickable *pickable,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
2012-04-21 01:03:32 -07:00
|
|
|
const Babl *format,
|
|
|
|
|
gpointer pixel);
|
2012-04-21 07:05:49 -07:00
|
|
|
static gdouble gimp_projection_get_opacity_at (GimpPickable *pickable,
|
2008-11-04 04:07:17 -08:00
|
|
|
gint x,
|
|
|
|
|
gint y);
|
2018-05-18 11:57:19 -07:00
|
|
|
static void gimp_projection_get_pixel_average (GimpPickable *pickable,
|
|
|
|
|
const GeglRectangle *rect,
|
|
|
|
|
const Babl *format,
|
|
|
|
|
gpointer pixel);
|
2016-05-22 14:28:31 -07:00
|
|
|
static void gimp_projection_pixel_to_srgb (GimpPickable *pickable,
|
|
|
|
|
const Babl *format,
|
|
|
|
|
gpointer pixel,
|
|
|
|
|
GimpRGB *color);
|
2016-05-22 16:25:35 -07:00
|
|
|
static void gimp_projection_srgb_to_pixel (GimpPickable *pickable,
|
|
|
|
|
const GimpRGB *color,
|
|
|
|
|
const Babl *format,
|
|
|
|
|
gpointer pixel);
|
2008-11-04 04:07:17 -08:00
|
|
|
|
2018-08-03 09:34:47 -07:00
|
|
|
static void gimp_projection_allocate_buffer (GimpProjection *proj);
|
2012-07-05 12:42:26 -07:00
|
|
|
static void gimp_projection_free_buffer (GimpProjection *proj);
|
2008-11-04 04: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,
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
(cherry picked from commit dac9bfe3342a0ac23da759e382d732e606796197)
2018-12-02 06:44:52 -08:00
|
|
|
gboolean now,
|
|
|
|
|
gboolean direct);
|
2013-07-28 06:57:28 -07:00
|
|
|
static void gimp_projection_chunk_render_start (GimpProjection *proj);
|
2019-01-12 00:36:09 -08:00
|
|
|
static void gimp_projection_chunk_render_stop (GimpProjection *proj,
|
|
|
|
|
gboolean merge);
|
|
|
|
|
static gboolean gimp_projection_chunk_render_callback (GimpProjection *proj);
|
|
|
|
|
static gboolean gimp_projection_chunk_render_iteration(GimpProjection *proj);
|
2008-11-04 04:07:17 -08:00
|
|
|
static void gimp_projection_paint_area (GimpProjection *proj,
|
|
|
|
|
gboolean now,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint w,
|
|
|
|
|
gint h);
|
2008-11-04 10:06:36 -08:00
|
|
|
|
2009-08-26 04:06:55 -07:00
|
|
|
static void gimp_projection_projectable_invalidate(GimpProjectable *projectable,
|
2008-11-04 04:07:17 -08:00
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint w,
|
|
|
|
|
gint h,
|
|
|
|
|
GimpProjection *proj);
|
2008-11-04 10:06:36 -08:00
|
|
|
static void gimp_projection_projectable_flush (GimpProjectable *projectable,
|
2008-11-04 04:07:17 -08:00
|
|
|
gboolean invalidate_preview,
|
|
|
|
|
GimpProjection *proj);
|
2018-08-03 09:34:47 -07:00
|
|
|
static void
|
|
|
|
|
gimp_projection_projectable_structure_changed (GimpProjectable *projectable,
|
|
|
|
|
GimpProjection *proj);
|
|
|
|
|
static void gimp_projection_projectable_bounds_changed (GimpProjectable *projectable,
|
|
|
|
|
gint old_x,
|
|
|
|
|
gint old_y,
|
|
|
|
|
gint old_w,
|
|
|
|
|
gint old_h,
|
2008-11-04 10:06:36 -08:00
|
|
|
GimpProjection *proj);
|
2004-07-13 09:36:29 -07:00
|
|
|
|
|
|
|
|
|
2005-12-10 11:24:36 -08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpProjection, gimp_projection, GIMP_TYPE_OBJECT,
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 09:09:39 -07:00
|
|
|
G_ADD_PRIVATE (GimpProjection)
|
2005-12-10 11:24:36 -08:00
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
|
2006-05-15 02:46:31 -07:00
|
|
|
gimp_projection_pickable_iface_init))
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2005-12-10 11:24:36 -08:00
|
|
|
#define parent_class gimp_projection_parent_class
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2005-12-10 11:24:36 -08:00
|
|
|
static guint projection_signals[LAST_SIGNAL] = { 0 };
|
2001-02-01 10:44:22 -08:00
|
|
|
|
2001-09-25 10:44:03 -07:00
|
|
|
|
|
|
|
|
static void
|
2004-07-13 09:36:29 -07:00
|
|
|
gimp_projection_class_init (GimpProjectionClass *klass)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2004-07-13 09:36:29 -07:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
projection_signals[UPDATE] =
|
|
|
|
|
g_signal_new ("update",
|
2006-04-12 05:49:29 -07: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-13 09:36:29 -07:00
|
|
|
G_TYPE_BOOLEAN,
|
2006-04-12 05:49:29 -07:00
|
|
|
G_TYPE_INT,
|
|
|
|
|
G_TYPE_INT,
|
|
|
|
|
G_TYPE_INT,
|
|
|
|
|
G_TYPE_INT);
|
2004-07-13 09:36:29 -07:00
|
|
|
|
|
|
|
|
object_class->finalize = gimp_projection_finalize;
|
2013-09-05 01:37:09 -07:00
|
|
|
object_class->set_property = gimp_projection_set_property;
|
|
|
|
|
object_class->get_property = gimp_projection_get_property;
|
2004-07-13 09:36:29 -07:00
|
|
|
|
|
|
|
|
gimp_object_class->get_memsize = gimp_projection_get_memsize;
|
2013-09-05 01:37:09 -07:00
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class, PROP_BUFFER, "buffer");
|
2001-09-25 10:44:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-07-13 09:36:29 -07:00
|
|
|
gimp_projection_init (GimpProjection *proj)
|
2001-09-25 10:44:03 -07:00
|
|
|
{
|
app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()
g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58. Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.
This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.
Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 09:09:39 -07:00
|
|
|
proj->priv = gimp_projection_get_instance_private (proj);
|
2001-09-25 10:44:03 -07:00
|
|
|
}
|
|
|
|
|
|
2004-07-13 16:04:05 -07:00
|
|
|
static void
|
2005-12-10 11:24:36 -08:00
|
|
|
gimp_projection_pickable_iface_init (GimpPickableInterface *iface)
|
2004-07-13 16:04:05 -07:00
|
|
|
{
|
2012-03-18 08:20:01 -07: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;
|
2018-05-18 11:57:19 -07:00
|
|
|
iface->get_pixel_average = gimp_projection_get_pixel_average;
|
2016-05-22 14:28:31 -07:00
|
|
|
iface->pixel_to_srgb = gimp_projection_pixel_to_srgb;
|
2016-05-22 16:25:35 -07:00
|
|
|
iface->srgb_to_pixel = gimp_projection_srgb_to_pixel;
|
2004-07-13 16:04:05 -07:00
|
|
|
}
|
|
|
|
|
|
2002-05-10 06:09:19 -07:00
|
|
|
static void
|
2004-07-13 09:36:29 -07:00
|
|
|
gimp_projection_finalize (GObject *object)
|
2002-05-10 06:09:19 -07:00
|
|
|
{
|
2004-07-13 09:36:29 -07:00
|
|
|
GimpProjection *proj = GIMP_PROJECTION (object);
|
2004-07-12 04:43:00 -07:00
|
|
|
|
2012-07-05 12:42:26 -07:00
|
|
|
gimp_projection_free_buffer (proj);
|
2008-11-10 14:15:40 -08:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2002-05-10 06:09:19 -07:00
|
|
|
}
|
|
|
|
|
|
2013-09-05 01:37:09 -07:00
|
|
|
static void
|
|
|
|
|
gimp_projection_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_BUFFER:
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_projection_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GimpProjection *projection = GIMP_PROJECTION (object);
|
|
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_BUFFER:
|
2014-05-30 15:08:43 -07:00
|
|
|
g_value_set_object (value, projection->priv->buffer);
|
2013-09-05 01:37:09 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
static gint64
|
|
|
|
|
gimp_projection_get_memsize (GimpObject *object,
|
|
|
|
|
gint64 *gui_size)
|
2001-09-25 10:44:03 -07:00
|
|
|
{
|
2004-07-13 09:36:29 -07:00
|
|
|
GimpProjection *projection = GIMP_PROJECTION (object);
|
2007-06-20 09:15:16 -07:00
|
|
|
gint64 memsize = 0;
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2014-06-15 09:21:05 -07:00
|
|
|
memsize += gimp_gegl_pyramid_get_memsize (projection->priv->buffer);
|
2001-10-29 03:47:11 -08:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
|
gui_size);
|
|
|
|
|
}
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2007-06-06 03:03:17 -07:00
|
|
|
/**
|
|
|
|
|
* gimp_projection_estimate_memsize:
|
2014-06-14 14:20:52 -07:00
|
|
|
* @type: the projectable's base type
|
|
|
|
|
* @component_type: the projectable's component type
|
|
|
|
|
* @width: projection width
|
|
|
|
|
* @height: projection height
|
2007-06-06 03:03:17 -07: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,
|
2014-06-14 14:20:52 -07:00
|
|
|
GimpComponentType component_type,
|
2007-06-06 03:03:17 -07:00
|
|
|
gint width,
|
|
|
|
|
gint height)
|
|
|
|
|
{
|
2012-08-24 13:16:02 -07:00
|
|
|
const Babl *format;
|
|
|
|
|
gint64 bytes;
|
2007-06-06 03:48:00 -07:00
|
|
|
|
2012-08-24 13:16:02 -07:00
|
|
|
if (type == GIMP_INDEXED)
|
|
|
|
|
type = GIMP_RGB;
|
|
|
|
|
|
2014-06-14 14:20:52 -07:00
|
|
|
format = gimp_babl_format (type,
|
|
|
|
|
gimp_babl_precision (component_type, FALSE),
|
|
|
|
|
TRUE);
|
2012-08-24 13:16:02 -07:00
|
|
|
bytes = babl_format_get_bytes_per_pixel (format);
|
2007-06-06 03:48:00 -07:00
|
|
|
|
2007-06-20 09:15:16 -07:00
|
|
|
/* The pyramid levels constitute a geometric sum with a ratio of 1/4. */
|
2007-06-06 06:45:44 -07:00
|
|
|
return bytes * (gint64) width * (gint64) height * 1.33;
|
2007-06-06 03:03:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-03-02 11:30:59 -08:00
|
|
|
static void
|
|
|
|
|
gimp_projection_pickable_flush (GimpPickable *pickable)
|
|
|
|
|
{
|
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
|
2012-12-18 10:30:33 -08:00
|
|
|
/* create the buffer if it doesn't exist */
|
|
|
|
|
gimp_projection_get_buffer (pickable);
|
|
|
|
|
|
2006-03-02 11:30:59 -08:00
|
|
|
gimp_projection_finish_draw (proj);
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
(cherry picked from commit dac9bfe3342a0ac23da759e382d732e606796197)
2018-12-02 06:44:52 -08:00
|
|
|
gimp_projection_flush_now (proj, FALSE);
|
2007-08-02 07:54:29 -07:00
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
if (proj->priv->invalidate_preview)
|
2007-08-02 07:54:29 -07:00
|
|
|
{
|
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
|
* the projection
|
|
|
|
|
*/
|
2014-05-30 15:08:43 -07:00
|
|
|
proj->priv->invalidate_preview = FALSE;
|
2007-08-02 07:54:29 -07:00
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
gimp_projectable_invalidate_preview (proj->priv->projectable);
|
2007-08-02 07:54:29 -07:00
|
|
|
}
|
2006-03-02 11:30:59 -08:00
|
|
|
}
|
|
|
|
|
|
2008-11-04 04:07:17 -08:00
|
|
|
static GimpImage *
|
|
|
|
|
gimp_projection_get_image (GimpPickable *pickable)
|
|
|
|
|
{
|
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
return gimp_projectable_get_image (proj->priv->projectable);
|
2008-11-04 04:07:17 -08:00
|
|
|
}
|
|
|
|
|
|
2012-03-17 07:21:11 -07:00
|
|
|
static const Babl *
|
2012-03-18 08:20:01 -07:00
|
|
|
gimp_projection_get_format (GimpPickable *pickable)
|
2012-03-17 07:21:11 -07:00
|
|
|
{
|
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
return gimp_projectable_get_format (proj->priv->projectable);
|
2012-03-17 07:21:11 -07:00
|
|
|
}
|
|
|
|
|
|
2012-03-15 06:38:54 -07:00
|
|
|
static GeglBuffer *
|
|
|
|
|
gimp_projection_get_buffer (GimpPickable *pickable)
|
|
|
|
|
{
|
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
if (! proj->priv->buffer)
|
2012-03-15 06:38:54 -07:00
|
|
|
{
|
2018-08-03 09:34:47 -07:00
|
|
|
gint width;
|
|
|
|
|
gint height;
|
2012-06-20 12:44:09 -07:00
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
gimp_projectable_get_size (proj->priv->projectable, &width, &height);
|
2012-03-15 06:38:54 -07:00
|
|
|
|
2018-08-03 09:34:47 -07:00
|
|
|
gimp_projection_allocate_buffer (proj);
|
2015-03-11 00:14:00 -07:00
|
|
|
|
|
|
|
|
/* This used to call gimp_tile_handler_validate_invalidate()
|
2012-12-15 10:33:21 -08:00
|
|
|
* 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);
|
2014-05-30 15:08:43 -07:00
|
|
|
proj->priv->invalidate_preview = TRUE;
|
2012-12-15 10:33:21 -08:00
|
|
|
gimp_projection_flush (proj);
|
2012-03-15 06:38:54 -07:00
|
|
|
}
|
|
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
return proj->priv->buffer;
|
2012-03-15 06:38:54 -07:00
|
|
|
}
|
|
|
|
|
|
2007-04-27 09:07:49 -07:00
|
|
|
static gboolean
|
|
|
|
|
gimp_projection_get_pixel_at (GimpPickable *pickable,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
2012-04-21 01:03:32 -07:00
|
|
|
const Babl *format,
|
|
|
|
|
gpointer pixel)
|
2007-04-27 09:07:49 -07:00
|
|
|
{
|
2012-03-19 02:46:47 -07:00
|
|
|
GeglBuffer *buffer = gimp_projection_get_buffer (pickable);
|
2007-04-27 09:07:49 -07:00
|
|
|
|
2012-03-19 02:46:47 -07:00
|
|
|
if (x < 0 ||
|
|
|
|
|
y < 0 ||
|
|
|
|
|
x >= gegl_buffer_get_width (buffer) ||
|
|
|
|
|
y >= gegl_buffer_get_height (buffer))
|
2007-04-27 09:07:49 -07:00
|
|
|
return FALSE;
|
|
|
|
|
|
2012-04-21 01:03:32 -07:00
|
|
|
gegl_buffer_sample (buffer, x, y, NULL, pixel, format,
|
2012-03-25 17:17:24 -07:00
|
|
|
GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE);
|
2007-04-27 09:07:49 -07:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-21 07:05:49 -07:00
|
|
|
static gdouble
|
2005-07-11 12:21:52 -07:00
|
|
|
gimp_projection_get_opacity_at (GimpPickable *pickable,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y)
|
|
|
|
|
{
|
2012-04-21 07:05:49 -07:00
|
|
|
return GIMP_OPACITY_OPAQUE;
|
2005-07-11 12:21:52 -07:00
|
|
|
}
|
|
|
|
|
|
2018-05-18 11:57:19 -07:00
|
|
|
static void
|
|
|
|
|
gimp_projection_get_pixel_average (GimpPickable *pickable,
|
|
|
|
|
const GeglRectangle *rect,
|
|
|
|
|
const Babl *format,
|
|
|
|
|
gpointer pixel)
|
|
|
|
|
{
|
|
|
|
|
GeglBuffer *buffer = gimp_projection_get_buffer (pickable);
|
|
|
|
|
|
|
|
|
|
return gimp_gegl_average_color (buffer, rect, TRUE, GEGL_ABYSS_NONE, format,
|
|
|
|
|
pixel);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-22 14:28:31 -07:00
|
|
|
static void
|
|
|
|
|
gimp_projection_pixel_to_srgb (GimpPickable *pickable,
|
|
|
|
|
const Babl *format,
|
|
|
|
|
gpointer pixel,
|
|
|
|
|
GimpRGB *color)
|
|
|
|
|
{
|
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
GimpImage *image = gimp_projectable_get_image (proj->priv->projectable);
|
|
|
|
|
|
|
|
|
|
gimp_pickable_pixel_to_srgb (GIMP_PICKABLE (image), format, pixel, color);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-22 16:25:35 -07:00
|
|
|
static void
|
|
|
|
|
gimp_projection_srgb_to_pixel (GimpPickable *pickable,
|
|
|
|
|
const GimpRGB *color,
|
|
|
|
|
const Babl *format,
|
|
|
|
|
gpointer pixel)
|
|
|
|
|
{
|
|
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
|
GimpImage *image = gimp_projectable_get_image (proj->priv->projectable);
|
|
|
|
|
|
|
|
|
|
gimp_pickable_srgb_to_pixel (GIMP_PICKABLE (image), color, format, pixel);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-22 14:28:31 -07:00
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
GimpProjection *
|
2008-11-04 10:06:36 -08:00
|
|
|
gimp_projection_new (GimpProjectable *projectable)
|
2004-07-13 09:36:29 -07:00
|
|
|
{
|
|
|
|
|
GimpProjection *proj;
|
|
|
|
|
|
2008-11-04 10:06:36 -08:00
|
|
|
g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
proj = g_object_new (GIMP_TYPE_PROJECTION, NULL);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
proj->priv->projectable = projectable;
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2009-08-26 04:06:55 -07:00
|
|
|
g_signal_connect_object (projectable, "invalidate",
|
|
|
|
|
G_CALLBACK (gimp_projection_projectable_invalidate),
|
|
|
|
|
proj, 0);
|
2008-11-04 10:06:36 -08:00
|
|
|
g_signal_connect_object (projectable, "flush",
|
|
|
|
|
G_CALLBACK (gimp_projection_projectable_flush),
|
2004-07-13 09:36:29 -07:00
|
|
|
proj, 0);
|
2008-11-04 15:22:45 -08:00
|
|
|
g_signal_connect_object (projectable, "structure-changed",
|
2018-08-03 09:34:47 -07:00
|
|
|
G_CALLBACK (gimp_projection_projectable_structure_changed),
|
|
|
|
|
proj, 0);
|
|
|
|
|
g_signal_connect_object (projectable, "bounds-changed",
|
|
|
|
|
G_CALLBACK (gimp_projection_projectable_bounds_changed),
|
2004-07-13 09:36:29 -07:00
|
|
|
proj, 0);
|
2001-11-09 08:54:56 -08:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
return proj;
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2017-12-02 06:48:14 -08:00
|
|
|
void
|
|
|
|
|
gimp_projection_set_priority (GimpProjection *proj,
|
|
|
|
|
gint priority)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
|
|
|
|
|
|
|
|
|
proj->priv->priority = priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gint
|
|
|
|
|
gimp_projection_get_priority (GimpProjection *proj)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_PROJECTION (proj), 0);
|
|
|
|
|
|
|
|
|
|
return proj->priv->priority;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-30 17:34:56 -07:00
|
|
|
void
|
|
|
|
|
gimp_projection_set_priority_rect (GimpProjection *proj,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
2014-05-31 06:13:32 -07:00
|
|
|
gint w,
|
|
|
|
|
gint h)
|
2014-05-30 17:34:56 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
gint off_x, off_y;
|
|
|
|
|
gint width, height;
|
2014-05-30 17:34:56 -07:00
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
|
|
|
|
|
|
|
|
|
gimp_projectable_get_offset (proj->priv->projectable, &off_x, &off_y);
|
2014-05-31 06:13:32 -07:00
|
|
|
gimp_projectable_get_size (proj->priv->projectable, &width, &height);
|
2014-05-30 17:34:56 -07:00
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
gegl_rectangle_intersect (&proj->priv->priority_rect,
|
|
|
|
|
GEGL_RECTANGLE (x, y, w, h),
|
|
|
|
|
GEGL_RECTANGLE (0, 0, width, height));
|
2014-05-30 17:34:56 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (proj->priv->iter)
|
|
|
|
|
{
|
|
|
|
|
gimp_chunk_iterator_set_priority_rect (proj->priv->iter,
|
|
|
|
|
&proj->priv->priority_rect);
|
2014-06-01 12:30:11 -07:00
|
|
|
}
|
2014-05-30 17:34:56 -07:00
|
|
|
}
|
|
|
|
|
|
2014-06-29 14:57:22 -07:00
|
|
|
void
|
|
|
|
|
gimp_projection_stop_rendering (GimpProjection *proj)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
|
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_projection_chunk_render_stop (proj, TRUE);
|
2014-06-29 14:57:22 -07:00
|
|
|
}
|
|
|
|
|
|
1998-10-01 09:22:28 -07:00
|
|
|
void
|
2004-07-13 09:36:29 -07:00
|
|
|
gimp_projection_flush (GimpProjection *proj)
|
1998-10-01 09:22:28 -07:00
|
|
|
{
|
2004-07-13 09:36:29 -07:00
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
2001-09-25 10:44:03 -07:00
|
|
|
|
2013-07-28 06:57:28 -07:00
|
|
|
/* Construct in chunks */
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
(cherry picked from commit dac9bfe3342a0ac23da759e382d732e606796197)
2018-12-02 06:44:52 -08:00
|
|
|
gimp_projection_flush_whenever (proj, FALSE, FALSE);
|
1998-10-01 09:22:28 -07:00
|
|
|
}
|
|
|
|
|
|
2001-02-20 07:15:30 -08:00
|
|
|
void
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
(cherry picked from commit dac9bfe3342a0ac23da759e382d732e606796197)
2018-12-02 06:44:52 -08:00
|
|
|
gimp_projection_flush_now (GimpProjection *proj,
|
|
|
|
|
gboolean direct)
|
2001-02-20 07:15:30 -08:00
|
|
|
{
|
2004-07-13 09:36:29 -07:00
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
2001-02-20 07:15:30 -08:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
/* Construct NOW */
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
(cherry picked from commit dac9bfe3342a0ac23da759e382d732e606796197)
2018-12-02 06:44:52 -08:00
|
|
|
gimp_projection_flush_whenever (proj, TRUE, direct);
|
2001-10-31 13:20:09 -08:00
|
|
|
}
|
2001-02-20 07:15:30 -08:00
|
|
|
|
2004-07-14 03:31:59 -07:00
|
|
|
void
|
|
|
|
|
gimp_projection_finish_draw (GimpProjection *proj)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
|
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (proj->priv->iter)
|
2004-07-14 03:31:59 -07:00
|
|
|
{
|
2019-01-13 05:20:40 -08:00
|
|
|
gimp_chunk_iterator_set_priority_rect (proj->priv->iter, NULL);
|
|
|
|
|
|
app: add GimpTileHandlerValidate::{begin,end}_validate() vfuncs
Add begin_validate() and end_validate() virtual functions, and
corresponding free functions, to GimpTileHandlerValidate. These
functions are called before/after validation happens, and should
perform any necessary steps to prepare for validation. The default
implementation suspends validation on tile access, so that the
assigned buffer may be accessed without causing validation.
Implement the new functions in GimpTileHandlerProjectable, by
calling gimp_projectable_begin_render() and
gimp_projectable_end_render(), respectively, instead of calling
these functions in the ::validate() implementation (which, in turn,
allows us to use the default ::validate() implementation.)
In GimpProjection, use the new functions in place of
gimp_projectable_{begin,end}_render().
(cherry picked from commit 5a623fc54b08c5aa4e0b03cf117357447e6955ce)
2018-11-27 10:32:55 -08:00
|
|
|
gimp_tile_handler_validate_begin_validate (proj->priv->validate_handler);
|
2017-04-22 11:22:06 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
while (gimp_projection_chunk_render_iteration (proj));
|
2017-04-22 11:22:06 -07:00
|
|
|
|
app: add GimpTileHandlerValidate::{begin,end}_validate() vfuncs
Add begin_validate() and end_validate() virtual functions, and
corresponding free functions, to GimpTileHandlerValidate. These
functions are called before/after validation happens, and should
perform any necessary steps to prepare for validation. The default
implementation suspends validation on tile access, so that the
assigned buffer may be accessed without causing validation.
Implement the new functions in GimpTileHandlerProjectable, by
calling gimp_projectable_begin_render() and
gimp_projectable_end_render(), respectively, instead of calling
these functions in the ::validate() implementation (which, in turn,
allows us to use the default ::validate() implementation.)
In GimpProjection, use the new functions in place of
gimp_projectable_{begin,end}_render().
(cherry picked from commit 5a623fc54b08c5aa4e0b03cf117357447e6955ce)
2018-11-27 10:32:55 -08:00
|
|
|
gimp_tile_handler_validate_end_validate (proj->priv->validate_handler);
|
2019-01-12 00:36:09 -08:00
|
|
|
|
|
|
|
|
gimp_projection_chunk_render_stop (proj, FALSE);
|
2004-07-14 03:31:59 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-14 06:39:35 -07:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
/* private functions */
|
2002-10-14 06:39:35 -07:00
|
|
|
|
2018-08-03 09:34:47 -07:00
|
|
|
static void
|
|
|
|
|
gimp_projection_allocate_buffer (GimpProjection *proj)
|
|
|
|
|
{
|
|
|
|
|
const Babl *format;
|
|
|
|
|
gint width;
|
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
|
|
if (proj->priv->buffer)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
format = gimp_projection_get_format (GIMP_PICKABLE (proj));
|
|
|
|
|
gimp_projectable_get_size (proj->priv->projectable, &width, &height);
|
|
|
|
|
|
|
|
|
|
proj->priv->buffer = gegl_buffer_new (GEGL_RECTANGLE (0, 0, width, height),
|
|
|
|
|
format);
|
|
|
|
|
|
|
|
|
|
proj->priv->validate_handler =
|
|
|
|
|
GIMP_TILE_HANDLER_VALIDATE (
|
|
|
|
|
gimp_tile_handler_projectable_new (proj->priv->projectable));
|
|
|
|
|
|
|
|
|
|
gimp_tile_handler_validate_assign (proj->priv->validate_handler,
|
|
|
|
|
proj->priv->buffer);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (proj), "buffer");
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-05 12:42:26 -07:00
|
|
|
static void
|
|
|
|
|
gimp_projection_free_buffer (GimpProjection *proj)
|
|
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_projection_chunk_render_stop (proj, FALSE);
|
2014-05-31 06:13:32 -07:00
|
|
|
|
2017-07-15 09:38:01 -07:00
|
|
|
g_clear_pointer (&proj->priv->update_region, cairo_region_destroy);
|
2014-05-31 06:13:32 -07:00
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
if (proj->priv->buffer)
|
2012-07-05 12:42:26 -07:00
|
|
|
{
|
2018-11-28 10:08:57 -08:00
|
|
|
gimp_tile_handler_validate_unassign (proj->priv->validate_handler,
|
|
|
|
|
proj->priv->buffer);
|
2012-07-05 12:42:26 -07:00
|
|
|
|
2017-07-15 09:38:01 -07:00
|
|
|
g_clear_object (&proj->priv->buffer);
|
2018-11-28 10:08:57 -08:00
|
|
|
g_clear_object (&proj->priv->validate_handler);
|
2012-07-05 12:42:26 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-14 03:31:59 -07:00
|
|
|
static void
|
|
|
|
|
gimp_projection_add_update_area (GimpProjection *proj,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint w,
|
|
|
|
|
gint h)
|
|
|
|
|
{
|
2018-08-09 23:36:29 -07:00
|
|
|
cairo_rectangle_int_t rect;
|
|
|
|
|
gint width, height;
|
2004-07-14 03:31:59 -07:00
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
gimp_projectable_get_size (proj->priv->projectable, &width, &height);
|
2009-08-24 06:59:14 -07:00
|
|
|
|
2018-03-31 05:13:36 -07:00
|
|
|
/* align the rectangle to the UPDATE_CHUNK_WIDTH x UPDATE_CHUNK_HEIGHT grid,
|
|
|
|
|
* to decrease the complexity of the update area.
|
|
|
|
|
*/
|
|
|
|
|
w = ceil ((gdouble) (x + w) / GIMP_PROJECTION_UPDATE_CHUNK_WIDTH ) * GIMP_PROJECTION_UPDATE_CHUNK_WIDTH;
|
|
|
|
|
h = ceil ((gdouble) (y + h) / GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT) * GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT;
|
|
|
|
|
x = floor ((gdouble) x / GIMP_PROJECTION_UPDATE_CHUNK_WIDTH ) * GIMP_PROJECTION_UPDATE_CHUNK_WIDTH;
|
|
|
|
|
y = floor ((gdouble) y / GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT) * GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT;
|
|
|
|
|
|
|
|
|
|
w -= x;
|
|
|
|
|
h -= y;
|
|
|
|
|
|
2014-06-01 12:30:11 -07:00
|
|
|
if (gimp_rectangle_intersect (x, y, w, h,
|
|
|
|
|
0, 0, width, height,
|
|
|
|
|
&rect.x, &rect.y, &rect.width, &rect.height))
|
|
|
|
|
{
|
|
|
|
|
if (proj->priv->update_region)
|
|
|
|
|
cairo_region_union_rectangle (proj->priv->update_region, &rect);
|
|
|
|
|
else
|
|
|
|
|
proj->priv->update_region = cairo_region_create_rectangle (&rect);
|
|
|
|
|
}
|
2004-07-14 03:31:59 -07:00
|
|
|
}
|
|
|
|
|
|
2001-11-10 15:03:22 -08:00
|
|
|
static void
|
2004-07-13 09:36:29 -07:00
|
|
|
gimp_projection_flush_whenever (GimpProjection *proj,
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
(cherry picked from commit dac9bfe3342a0ac23da759e382d732e606796197)
2018-12-02 06:44:52 -08:00
|
|
|
gboolean now,
|
|
|
|
|
gboolean direct)
|
2001-06-18 06:10:03 -07:00
|
|
|
{
|
2018-11-28 09:53:52 -08:00
|
|
|
if (! proj->priv->buffer)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
if (proj->priv->update_region)
|
2001-06-18 06:10:03 -07:00
|
|
|
{
|
2004-07-12 04:43:00 -07:00
|
|
|
if (now) /* Synchronous */
|
2003-07-29 09:36:56 -07:00
|
|
|
{
|
2014-05-30 16:22:54 -07:00
|
|
|
gint n_rects = cairo_region_num_rectangles (proj->priv->update_region);
|
|
|
|
|
gint i;
|
2003-07-29 09:36:56 -07:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
for (i = 0; i < n_rects; i++)
|
2003-07-29 09:36:56 -07:00
|
|
|
{
|
2014-05-30 16:22:54 -07:00
|
|
|
cairo_rectangle_int_t rect;
|
2003-07-29 09:36:56 -07:00
|
|
|
|
2014-05-30 16:22:54 -07:00
|
|
|
cairo_region_get_rectangle (proj->priv->update_region,
|
|
|
|
|
i, &rect);
|
|
|
|
|
|
|
|
|
|
gimp_projection_paint_area (proj,
|
app: add "direct" parameter to gimp_projection_flush_now()
Add a boolean "direct" parameter to gimp_projection_flush_now(),
which specifies if the projection buffer should only be invalidated
(FALSE), or rendered directly (TRUE).
Pass TRUE when flushing the projection during painting, so that the
affected regions are rendered in a single step, instead of tile-by-
tile. We previously only invalidated the projection buffer, but
since we synchronously flush the display right after that, the
invalidated regions would still get rendered, albeit less
efficiently.
Likewise, pass TRUE when benchmarking the projection through the
debug action, and avoid flushing the display, to more accurately
measure the render time.
(cherry picked from commit dac9bfe3342a0ac23da759e382d732e606796197)
2018-12-02 06:44:52 -08:00
|
|
|
direct,
|
2014-05-30 16:22:54 -07:00
|
|
|
rect.x,
|
|
|
|
|
rect.y,
|
|
|
|
|
rect.width,
|
|
|
|
|
rect.height);
|
2003-07-29 09:36:56 -07:00
|
|
|
}
|
2019-01-12 00:36:09 -08:00
|
|
|
|
|
|
|
|
/* Free the update region */
|
|
|
|
|
g_clear_pointer (&proj->priv->update_region, cairo_region_destroy);
|
2003-07-29 09:36:56 -07:00
|
|
|
}
|
2004-07-12 04:43:00 -07:00
|
|
|
else /* Asynchronous */
|
2003-07-29 09:36:56 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
/* Consumes the update region */
|
|
|
|
|
gimp_projection_chunk_render_start (proj);
|
2003-07-29 09:36:56 -07:00
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
}
|
2014-05-30 15:08:43 -07:00
|
|
|
else if (! now && proj->priv->invalidate_preview)
|
2007-06-26 14:39:51 -07:00
|
|
|
{
|
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
|
* the projection
|
|
|
|
|
*/
|
2014-05-30 15:08:43 -07:00
|
|
|
proj->priv->invalidate_preview = FALSE;
|
2007-06-26 14:39:51 -07:00
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
gimp_projectable_invalidate_preview (proj->priv->projectable);
|
2007-06-26 14:39:51 -07:00
|
|
|
}
|
2004-07-13 09:36:29 -07:00
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
|
|
|
|
|
static void
|
2013-07-28 06:57:28 -07:00
|
|
|
gimp_projection_chunk_render_start (GimpProjection *proj)
|
|
|
|
|
{
|
2019-01-12 05:29:16 -08:00
|
|
|
cairo_region_t *region = proj->priv->update_region;
|
|
|
|
|
gboolean invalidate_preview = FALSE;
|
2013-07-28 06:57:28 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (proj->priv->iter)
|
|
|
|
|
{
|
|
|
|
|
region = gimp_chunk_iterator_stop (proj->priv->iter, FALSE);
|
2013-07-28 06:57:28 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
proj->priv->iter = NULL;
|
2017-04-22 11:22:06 -07:00
|
|
|
|
2019-01-12 05:29:16 -08:00
|
|
|
if (cairo_region_is_empty (region))
|
|
|
|
|
invalidate_preview = proj->priv->invalidate_preview;
|
|
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (proj->priv->update_region)
|
2013-08-09 11:20:02 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
cairo_region_union (region, proj->priv->update_region);
|
2013-07-28 06:57:28 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
cairo_region_destroy (proj->priv->update_region);
|
2013-08-09 11:20:02 -07:00
|
|
|
}
|
2013-07-28 06:57:28 -07:00
|
|
|
}
|
|
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
proj->priv->update_region = NULL;
|
2017-04-22 11:22:06 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (region && ! cairo_region_is_empty (region))
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
proj->priv->iter = gimp_chunk_iterator_new (region);
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_chunk_iterator_set_priority_rect (proj->priv->iter,
|
|
|
|
|
&proj->priv->priority_rect);
|
2013-08-09 11:20:02 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (! proj->priv->idle_id)
|
2014-05-30 16:22:54 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
proj->priv->idle_id = g_idle_add_full (
|
|
|
|
|
GIMP_PRIORITY_PROJECTION_IDLE + proj->priv->priority,
|
|
|
|
|
(GSourceFunc) gimp_projection_chunk_render_callback,
|
|
|
|
|
proj, NULL);
|
2014-05-30 16:22:54 -07:00
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
}
|
2019-01-12 05:14:40 -08:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (region)
|
|
|
|
|
cairo_region_destroy (region);
|
|
|
|
|
|
|
|
|
|
if (proj->priv->idle_id)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (proj->priv->idle_id);
|
|
|
|
|
proj->priv->idle_id = 0;
|
|
|
|
|
}
|
2019-01-12 05:29:16 -08:00
|
|
|
|
|
|
|
|
if (invalidate_preview)
|
|
|
|
|
{
|
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
|
* the projection
|
|
|
|
|
*/
|
|
|
|
|
proj->priv->invalidate_preview = FALSE;
|
|
|
|
|
|
|
|
|
|
gimp_projectable_invalidate_preview (proj->priv->projectable);
|
|
|
|
|
}
|
2019-01-12 05:14:40 -08:00
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
}
|
|
|
|
|
|
app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height. However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.
Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes. This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
(cherry picked from commit c9c2397b0d384717187870bad95373aff065cf39)
2018-12-06 05:44:23 -08:00
|
|
|
static void
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_projection_chunk_render_stop (GimpProjection *proj,
|
|
|
|
|
gboolean merge)
|
app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height. However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.
Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes. This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
(cherry picked from commit c9c2397b0d384717187870bad95373aff065cf39)
2018-12-06 05:44:23 -08:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
if (proj->priv->idle_id)
|
app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height. However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.
Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes. This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
(cherry picked from commit c9c2397b0d384717187870bad95373aff065cf39)
2018-12-06 05:44:23 -08:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
g_source_remove (proj->priv->idle_id);
|
|
|
|
|
proj->priv->idle_id = 0;
|
app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height. However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.
Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes. This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
(cherry picked from commit c9c2397b0d384717187870bad95373aff065cf39)
2018-12-06 05:44:23 -08:00
|
|
|
}
|
|
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (proj->priv->iter)
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
if (merge)
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
cairo_region_t *region;
|
2018-08-20 00:00:10 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
region = gimp_chunk_iterator_stop (proj->priv->iter, FALSE);
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (proj->priv->update_region)
|
|
|
|
|
{
|
|
|
|
|
cairo_region_union (proj->priv->update_region, region);
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
cairo_region_destroy (region);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
proj->priv->update_region = region;
|
|
|
|
|
}
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_chunk_iterator_stop (proj->priv->iter, TRUE);
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
}
|
2019-01-12 00:36:09 -08:00
|
|
|
|
|
|
|
|
proj->priv->iter = NULL;
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
}
|
2019-01-12 00:36:09 -08:00
|
|
|
}
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
static gboolean
|
|
|
|
|
gimp_projection_chunk_render_callback (GimpProjection *proj)
|
|
|
|
|
{
|
|
|
|
|
if (gimp_projection_chunk_render_iteration (proj))
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
return G_SOURCE_CONTINUE;
|
app: use adaptive chunk size when rendering projections
In GimpProjection, use an adaptive chunk size when rendering the
projection asynchronously, rather than using a fixed chunk size.
The chunk size is determined according to the number of pixels
processed during the last frame, and the time it took to process
them, aiming for some target frame-rate (currently, 15 FPS). In
other words, the chunks become bigger when processing is fast, and
smaller when processing is slow. We're currently aiming for
generally-square chunks, whose sides are powers of 2, within a
predefined range.
Note that the chunk size represents a trade off between throughput
and responsiveness: bigger chunks result in better throughput,
since each individual chunk incurs an overhead, in particular when
rendering area filters or multithreaded ops, while smaller chunks
result in better responsiveness, since the time each chunk
individual takes to render is smaller, allowing us to more
accurately meet the target frame rate. With this commit, we aim to
find a good compromise dynamically, rather than statically.
The use of adaptive chunk sizes can be disabled by defining the
environment variable GIMP_NO_ADAPTIVE_CHUNK_SIZE, in which case we
use a fixed chunk size, as before.
(cherry picked from commit a1706bbd298dc540fbf7e0cc10b59ae9fd090511)
2018-08-20 07:47:22 -07:00
|
|
|
}
|
2019-01-12 00:36:09 -08:00
|
|
|
else
|
2001-11-10 15:03:22 -08:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
proj->priv->idle_id = 0;
|
2004-07-13 09:36:29 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
return G_SOURCE_REMOVE;
|
2001-11-10 15:03:22 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_projection_chunk_render_iteration (GimpProjection *proj)
|
2001-11-10 15:03:22 -08:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
if (gimp_chunk_iterator_next (proj->priv->iter))
|
2014-05-30 16:22:54 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
GeglRectangle rect;
|
2014-05-30 17:34:56 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_tile_handler_validate_begin_validate (proj->priv->validate_handler);
|
app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height. However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.
Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes. This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
(cherry picked from commit c9c2397b0d384717187870bad95373aff065cf39)
2018-12-06 05:44:23 -08:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
while (gimp_chunk_iterator_get_rect (proj->priv->iter, &rect))
|
|
|
|
|
{
|
|
|
|
|
gimp_projection_paint_area (proj, TRUE,
|
|
|
|
|
rect.x, rect.y, rect.width, rect.height);
|
|
|
|
|
}
|
app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height. However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.
Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes. This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
(cherry picked from commit c9c2397b0d384717187870bad95373aff065cf39)
2018-12-06 05:44:23 -08:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_tile_handler_validate_end_validate (proj->priv->validate_handler);
|
app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height. However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.
Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes. This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
(cherry picked from commit c9c2397b0d384717187870bad95373aff065cf39)
2018-12-06 05:44:23 -08:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
/* Still work to do. */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
2014-05-30 16:22:54 -07:00
|
|
|
{
|
2019-01-12 00:36:09 -08:00
|
|
|
proj->priv->iter = NULL;
|
app: in GimpProjection, fix reinit. of current row when chunk height changes
In GimpProjection's chunk renderer, when the chunk height changes
in the middle of a row, we need to merge the remainder of the
current render area back into the renderer's update region, and
refetch the remainder of the row as the new render area, so that we
don't miss any unrendered area, or re-render already-rendered area,
due to the change in chunk height. However, we should previously
fail to verify that the fetched area is, in fact, the remainder of
the current row, which could cause us to render the wrong area,
missing parts of the update region.
Fix this, by breaking up some of the chunk-renderer fucntions into
smaller sub-functions, and using those in order to explicitly set
the new render area to the remainder of the current row when the
chunk height changes. This also avoids erroneously merging the
unflushed update region of the projection into the renderer's
update region.
(cherry picked from commit c9c2397b0d384717187870bad95373aff065cf39)
2018-12-06 05:44:23 -08:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
if (proj->priv->invalidate_preview)
|
|
|
|
|
{
|
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
|
* the projection
|
|
|
|
|
*/
|
|
|
|
|
proj->priv->invalidate_preview = FALSE;
|
2014-05-30 16:22:54 -07:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_projectable_invalidate_preview (proj->priv->projectable);
|
|
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
/* FINISHED */
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2004-07-13 09:36:29 -07:00
|
|
|
gimp_projection_paint_area (GimpProjection *proj,
|
|
|
|
|
gboolean now,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint w,
|
|
|
|
|
gint h)
|
2001-11-10 15:03:22 -08:00
|
|
|
{
|
2009-08-24 06:59:14 -07:00
|
|
|
gint off_x, off_y;
|
2008-11-04 10:06:36 -08:00
|
|
|
gint width, height;
|
|
|
|
|
|
2014-05-30 15:08:43 -07:00
|
|
|
gimp_projectable_get_offset (proj->priv->projectable, &off_x, &off_y);
|
|
|
|
|
gimp_projectable_get_size (proj->priv->projectable, &width, &height);
|
2008-08-12 09:30:44 -07:00
|
|
|
|
2014-06-01 12:30:11 -07:00
|
|
|
if (gimp_rectangle_intersect (x, y, w, h,
|
|
|
|
|
0, 0, width, height,
|
|
|
|
|
&x, &y, &w, &h))
|
2013-08-02 11:43:44 -07:00
|
|
|
{
|
2014-06-01 12:30:11 -07:00
|
|
|
if (now)
|
|
|
|
|
{
|
2018-11-28 10:08:57 -08:00
|
|
|
gimp_tile_handler_validate_validate (
|
|
|
|
|
proj->priv->validate_handler,
|
|
|
|
|
proj->priv->buffer,
|
|
|
|
|
GEGL_RECTANGLE (x, y, w, h),
|
|
|
|
|
FALSE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gimp_tile_handler_validate_invalidate (
|
|
|
|
|
proj->priv->validate_handler,
|
|
|
|
|
GEGL_RECTANGLE (x, y, w, h));
|
2014-06-01 12:30:11 -07: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.
|
|
|
|
|
*/
|
|
|
|
|
g_signal_emit (proj, projection_signals[UPDATE], 0,
|
|
|
|
|
now,
|
|
|
|
|
x + off_x,
|
|
|
|
|
y + off_y,
|
|
|
|
|
w,
|
|
|
|
|
h);
|
|
|
|
|
}
|
2004-07-13 09:36:29 -07:00
|
|
|
}
|
2001-11-10 15:03:22 -08:00
|
|
|
|
2012-06-20 12:44:09 -07:00
|
|
|
|
2004-07-13 09:36:29 -07:00
|
|
|
/* image callbacks */
|
|
|
|
|
|
|
|
|
|
static void
|
2009-08-26 04:06:55 -07:00
|
|
|
gimp_projection_projectable_invalidate (GimpProjectable *projectable,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint w,
|
|
|
|
|
gint h,
|
|
|
|
|
GimpProjection *proj)
|
2004-07-13 09:36:29 -07:00
|
|
|
{
|
2018-08-09 23:36:29 -07:00
|
|
|
gint off_x, off_y;
|
|
|
|
|
|
|
|
|
|
gimp_projectable_get_offset (proj->priv->projectable, &off_x, &off_y);
|
|
|
|
|
|
|
|
|
|
/* 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-13 09:36:29 -07:00
|
|
|
gimp_projection_add_update_area (proj, x, y, w, h);
|
2001-06-18 06:10:03 -07:00
|
|
|
}
|
2004-07-13 09:36:29 -07:00
|
|
|
|
|
|
|
|
static void
|
2008-11-04 10:06:36 -08:00
|
|
|
gimp_projection_projectable_flush (GimpProjectable *projectable,
|
|
|
|
|
gboolean invalidate_preview,
|
|
|
|
|
GimpProjection *proj)
|
2004-07-13 09:36:29 -07:00
|
|
|
{
|
2008-11-04 10:06:36 -08:00
|
|
|
if (invalidate_preview)
|
2014-05-30 15:08:43 -07:00
|
|
|
proj->priv->invalidate_preview = TRUE;
|
2007-06-20 09:15:16 -07:00
|
|
|
|
2008-11-04 10:06:36 -08:00
|
|
|
gimp_projection_flush (proj);
|
2004-07-13 09:36:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-08-03 09:34:47 -07:00
|
|
|
gimp_projection_projectable_structure_changed (GimpProjectable *projectable,
|
|
|
|
|
GimpProjection *proj)
|
2004-07-13 09:36:29 -07:00
|
|
|
{
|
2008-11-04 10:06:36 -08:00
|
|
|
gint width, height;
|
|
|
|
|
|
2012-07-05 12:42:26 -07:00
|
|
|
gimp_projection_free_buffer (proj);
|
2012-03-15 06:38:54 -07:00
|
|
|
|
2018-08-09 23:36:29 -07:00
|
|
|
gimp_projectable_get_size (projectable, &width, &height);
|
2007-06-26 14:39:51 -07:00
|
|
|
|
2018-08-09 23:36:29 -07:00
|
|
|
gimp_projection_add_update_area (proj, 0, 0, width, height);
|
2014-05-30 17:34:56 -07:00
|
|
|
|
|
|
|
|
proj->priv->priority_rect.x = 0;
|
|
|
|
|
proj->priv->priority_rect.y = 0;
|
|
|
|
|
proj->priv->priority_rect.width = width;
|
|
|
|
|
proj->priv->priority_rect.height = height;
|
2004-07-13 09:36:29 -07:00
|
|
|
}
|
2018-08-03 09:34:47 -07:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_projection_projectable_bounds_changed (GimpProjectable *projectable,
|
|
|
|
|
gint old_x,
|
|
|
|
|
gint old_y,
|
|
|
|
|
gint old_w,
|
|
|
|
|
gint old_h,
|
|
|
|
|
GimpProjection *proj)
|
|
|
|
|
{
|
|
|
|
|
GeglBuffer *old_buffer = proj->priv->buffer;
|
|
|
|
|
GimpTileHandlerValidate *old_validate_handler;
|
|
|
|
|
gint x, y, w, h;
|
|
|
|
|
gint dx, dy;
|
|
|
|
|
|
|
|
|
|
if (! old_buffer)
|
|
|
|
|
{
|
|
|
|
|
gimp_projection_projectable_structure_changed (projectable, proj);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_projectable_get_offset (projectable, &x, &y);
|
|
|
|
|
gimp_projectable_get_size (projectable, &w, &h);
|
|
|
|
|
|
|
|
|
|
if (x == old_x && y == old_y && w == old_w && h == old_h)
|
|
|
|
|
return;
|
|
|
|
|
|
2018-08-03 18:58:16 -07:00
|
|
|
if (! gimp_rectangle_intersect (x, y, w, h,
|
|
|
|
|
old_x, old_y, old_w, old_h,
|
|
|
|
|
NULL, NULL, NULL, NULL))
|
|
|
|
|
{
|
|
|
|
|
gimp_projection_projectable_structure_changed (projectable, proj);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-03 09:34:47 -07:00
|
|
|
dx = old_x - x;
|
|
|
|
|
dy = old_y - y;
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
/* FIXME: when there's an offset between the new bounds and the old bounds,
|
|
|
|
|
* use gimp_projection_projectable_structure_changed(), instead of copying a
|
|
|
|
|
* shifted version of the old buffer, since the synchronous copy can take a
|
|
|
|
|
* notable amount of time for big buffers, when the offset is such that tiles
|
|
|
|
|
* are not COW-ed. while gimp_projection_projectable_structure_changed()
|
|
|
|
|
* causes the projection to be re-rendered, which is overall slower, it's
|
|
|
|
|
* done asynchronously.
|
|
|
|
|
*
|
|
|
|
|
* this needs to be improved.
|
|
|
|
|
*/
|
|
|
|
|
if (dx || dy)
|
|
|
|
|
{
|
|
|
|
|
gimp_projection_projectable_structure_changed (projectable, proj);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* reallocate the buffer, and copy the old buffer to the corresponding
|
2019-01-12 00:36:09 -08:00
|
|
|
* region of the new buffer.
|
2018-08-03 09:34:47 -07:00
|
|
|
*/
|
|
|
|
|
|
2019-01-12 00:36:09 -08:00
|
|
|
gimp_projection_chunk_render_stop (proj, TRUE);
|
|
|
|
|
|
2018-08-03 09:34:47 -07:00
|
|
|
old_validate_handler = proj->priv->validate_handler;
|
|
|
|
|
|
|
|
|
|
proj->priv->buffer = NULL;
|
|
|
|
|
proj->priv->validate_handler = NULL;
|
|
|
|
|
|
|
|
|
|
gimp_projection_allocate_buffer (proj);
|
|
|
|
|
|
|
|
|
|
gimp_tile_handler_validate_buffer_copy (old_buffer,
|
|
|
|
|
GEGL_RECTANGLE (0, 0, old_w, old_h),
|
|
|
|
|
proj->priv->buffer,
|
|
|
|
|
GEGL_RECTANGLE (dx, dy, old_w, old_h));
|
|
|
|
|
|
|
|
|
|
if (old_validate_handler)
|
|
|
|
|
{
|
|
|
|
|
gimp_tile_handler_validate_unassign (old_validate_handler, old_buffer);
|
|
|
|
|
|
|
|
|
|
g_object_unref (old_validate_handler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_unref (old_buffer);
|
|
|
|
|
|
|
|
|
|
if (proj->priv->update_region)
|
|
|
|
|
{
|
|
|
|
|
const cairo_rectangle_int_t bounds = {0, 0, w, h};
|
|
|
|
|
|
|
|
|
|
cairo_region_translate (proj->priv->update_region, dx, dy);
|
|
|
|
|
cairo_region_intersect_rectangle (proj->priv->update_region, &bounds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (proj->priv->priority_rect.width > 0 &&
|
|
|
|
|
proj->priv->priority_rect.height > 0)
|
|
|
|
|
{
|
|
|
|
|
proj->priv->priority_rect.x += dx;
|
|
|
|
|
proj->priv->priority_rect.y += dy;
|
|
|
|
|
|
|
|
|
|
gimp_rectangle_intersect (proj->priv->priority_rect.x,
|
|
|
|
|
proj->priv->priority_rect.y,
|
|
|
|
|
proj->priv->priority_rect.width,
|
|
|
|
|
proj->priv->priority_rect.height,
|
|
|
|
|
|
|
|
|
|
0, 0, w, h,
|
|
|
|
|
|
|
|
|
|
&proj->priv->priority_rect.x,
|
|
|
|
|
&proj->priv->priority_rect.y,
|
|
|
|
|
&proj->priv->priority_rect.width,
|
|
|
|
|
&proj->priv->priority_rect.height);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-03 18:45:06 -07:00
|
|
|
if (dx > 0)
|
|
|
|
|
gimp_projection_add_update_area (proj, 0, 0, dx, h);
|
|
|
|
|
if (dy > 0)
|
|
|
|
|
gimp_projection_add_update_area (proj, 0, 0, w, dy);
|
|
|
|
|
if (dx + old_w < w)
|
|
|
|
|
gimp_projection_add_update_area (proj, dx + old_w, 0, w - (dx + old_w), h);
|
|
|
|
|
if (dy + old_h < h)
|
|
|
|
|
gimp_projection_add_update_area (proj, 0, dy + old_h, w, h - (dy + old_h));
|
|
|
|
|
|
|
|
|
|
proj->priv->invalidate_preview = TRUE;
|
2018-08-03 09:34:47 -07:00
|
|
|
}
|