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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://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
|
|
|
|
2014-06-04 07:23:41 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-07-06 03:42:26 +08:00
|
|
|
#include <cairo.h>
|
2013-10-15 07:58:39 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2014-06-02 03:30:11 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2018-03-31 20:13:36 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2014-06-02 03:30:11 +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"
|
2018-05-19 02:57:19 +08:00
|
|
|
#include "gegl/gimp-gegl-loops.h"
|
2012-03-15 04:16:58 +08:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "gimp.h"
|
2014-08-12 19:57:57 +08:00
|
|
|
#include "gimp-memsize.h"
|
2019-01-12 16:36:09 +08:00
|
|
|
#include "gimpchunkiterator.h"
|
2004-07-14 00:36:29 +08:00
|
|
|
#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"
|
2017-04-23 02:22:06 +08:00
|
|
|
#include "gimptilehandlerprojectable.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2013-08-10 02:20:02 +08:00
|
|
|
#include "gimp-log.h"
|
2014-07-02 10:47:24 +08:00
|
|
|
#include "gimp-priorities.h"
|
2013-08-10 02:20:02 +08:00
|
|
|
|
2001-07-31 19:33:13 +08:00
|
|
|
|
2018-03-31 20:13:36 +08:00
|
|
|
/* chunk size for area updates */
|
2019-01-12 16:36:09 +08:00
|
|
|
#define GIMP_PROJECTION_UPDATE_CHUNK_WIDTH 32
|
|
|
|
#define GIMP_PROJECTION_UPDATE_CHUNK_HEIGHT 32
|
2013-08-10 02:20:02 +08:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2013-09-05 16:37:09 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_BUFFER
|
|
|
|
};
|
|
|
|
|
2002-05-10 21:09:19 +08:00
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
struct _GimpProjectionPrivate
|
|
|
|
{
|
|
|
|
GimpProjectable *projectable;
|
|
|
|
|
|
|
|
GeglBuffer *buffer;
|
2015-03-11 15:14:00 +08:00
|
|
|
GimpTileHandlerValidate *validate_handler;
|
2014-05-31 06:08:43 +08:00
|
|
|
|
2017-12-02 22:48:14 +08:00
|
|
|
gint priority;
|
|
|
|
|
2014-05-31 07:22:54 +08:00
|
|
|
cairo_region_t *update_region;
|
2019-01-12 16:36:09 +08:00
|
|
|
GeglRectangle priority_rect;
|
|
|
|
GimpChunkIterator *iter;
|
|
|
|
guint idle_id;
|
2014-05-31 06:08:43 +08:00
|
|
|
|
|
|
|
gboolean invalidate_preview;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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);
|
2013-09-05 16:37:09 +08: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 20: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 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);
|
2018-05-19 02:57:19 +08:00
|
|
|
static void gimp_projection_get_pixel_average (GimpPickable *pickable,
|
|
|
|
const GeglRectangle *rect,
|
|
|
|
const Babl *format,
|
|
|
|
gpointer pixel);
|
2016-05-23 05:28:31 +08:00
|
|
|
static void gimp_projection_pixel_to_srgb (GimpPickable *pickable,
|
|
|
|
const Babl *format,
|
|
|
|
gpointer pixel,
|
|
|
|
GimpRGB *color);
|
2016-05-23 07:25:35 +08:00
|
|
|
static void gimp_projection_srgb_to_pixel (GimpPickable *pickable,
|
|
|
|
const GimpRGB *color,
|
|
|
|
const Babl *format,
|
|
|
|
gpointer pixel);
|
2008-11-04 20:07:17 +08:00
|
|
|
|
2018-08-04 00:34:47 +08:00
|
|
|
static void gimp_projection_allocate_buffer (GimpProjection *proj);
|
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,
|
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.
2018-12-02 22:44:52 +08:00
|
|
|
gboolean now,
|
|
|
|
gboolean direct);
|
2019-03-26 16:54:59 +08:00
|
|
|
static void gimp_projection_update_priority_rect (GimpProjection *proj);
|
2013-07-28 21:57:28 +08:00
|
|
|
static void gimp_projection_chunk_render_start (GimpProjection *proj);
|
2019-01-12 16: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 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);
|
2018-08-04 00:34:47 +08: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,
|
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,
|
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-19 00:09:39 +08:00
|
|
|
G_ADD_PRIVATE (GimpProjection)
|
2005-12-11 03:24:36 +08:00
|
|
|
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;
|
2013-09-05 16:37:09 +08:00
|
|
|
object_class->set_property = gimp_projection_set_property;
|
|
|
|
object_class->get_property = gimp_projection_get_property;
|
2004-07-14 00:36:29 +08:00
|
|
|
|
|
|
|
gimp_object_class->get_memsize = gimp_projection_get_memsize;
|
2013-09-05 16:37:09 +08:00
|
|
|
|
|
|
|
g_object_class_override_property (object_class, PROP_BUFFER, "buffer");
|
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
|
|
|
{
|
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-19 00:09:39 +08:00
|
|
|
proj->priv = gimp_projection_get_instance_private (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;
|
2018-05-19 02:57:19 +08:00
|
|
|
iface->get_pixel_average = gimp_projection_get_pixel_average;
|
2016-05-23 05:28:31 +08:00
|
|
|
iface->pixel_to_srgb = gimp_projection_pixel_to_srgb;
|
2016-05-23 07:25:35 +08:00
|
|
|
iface->srgb_to_pixel = gimp_projection_srgb_to_pixel;
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-09-05 16:37:09 +08: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-31 06:08:43 +08:00
|
|
|
g_value_set_object (value, projection->priv->buffer);
|
2013-09-05 16:37:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-06-16 00:21:05 +08:00
|
|
|
memsize += gimp_gegl_pyramid_get_memsize (projection->priv->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:
|
2014-06-15 05:20:52 +08:00
|
|
|
* @type: the projectable's base type
|
|
|
|
* @component_type: the projectable's component type
|
|
|
|
* @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.
|
|
|
|
*
|
2019-08-03 06:10:14 +08:00
|
|
|
* Returns: a rough estimate of the memory requirements.
|
2007-06-06 18:03:17 +08:00
|
|
|
**/
|
|
|
|
gint64
|
|
|
|
gimp_projection_estimate_memsize (GimpImageBaseType type,
|
2014-06-15 05:20:52 +08:00
|
|
|
GimpComponentType component_type,
|
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;
|
|
|
|
|
2014-06-15 05:20:52 +08:00
|
|
|
format = gimp_babl_format (type,
|
|
|
|
gimp_babl_precision (component_type, FALSE),
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
TRUE, NULL);
|
2012-08-25 04:16:02 +08:00
|
|
|
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);
|
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.
2018-12-02 22:44:52 +08:00
|
|
|
gimp_projection_flush_now (proj, FALSE);
|
2007-08-02 22:54:29 +08:00
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
if (proj->priv->invalidate_preview)
|
2007-08-02 22:54:29 +08:00
|
|
|
{
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
* the projection
|
|
|
|
*/
|
2014-05-31 06:08:43 +08:00
|
|
|
proj->priv->invalidate_preview = FALSE;
|
2007-08-02 22:54:29 +08:00
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
gimp_projectable_invalidate_preview (proj->priv->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);
|
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
return gimp_projectable_get_image (proj->priv->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);
|
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
return gimp_projectable_get_format (proj->priv->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);
|
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
if (! proj->priv->buffer)
|
2012-03-15 21:38:54 +08:00
|
|
|
{
|
2019-08-02 04:01:58 +08:00
|
|
|
GeglRectangle bounding_box;
|
2012-06-21 03:44:09 +08:00
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
bounding_box =
|
|
|
|
gimp_projectable_get_bounding_box (proj->priv->projectable);
|
2012-03-15 21:38:54 +08:00
|
|
|
|
2018-08-04 00:34:47 +08:00
|
|
|
gimp_projection_allocate_buffer (proj);
|
2015-03-11 15:14:00 +08:00
|
|
|
|
|
|
|
/* This used to call gimp_tile_handler_validate_invalidate()
|
2012-12-16 02: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.
|
|
|
|
*/
|
2019-08-02 04:01:58 +08:00
|
|
|
gimp_projection_add_update_area (proj,
|
|
|
|
bounding_box.x, bounding_box.y,
|
|
|
|
bounding_box.width, bounding_box.height);
|
2014-05-31 06:08:43 +08:00
|
|
|
proj->priv->invalidate_preview = TRUE;
|
2012-12-16 02:33:21 +08:00
|
|
|
gimp_projection_flush (proj);
|
2012-03-15 21:38:54 +08:00
|
|
|
}
|
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
return proj->priv->buffer;
|
2012-03-15 21:38:54 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-09-04 23:23:31 +08:00
|
|
|
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
|
|
|
GeglBuffer *buffer = gimp_projection_get_buffer (pickable);
|
|
|
|
GeglRectangle bounding_box;
|
|
|
|
|
|
|
|
bounding_box = gimp_projectable_get_bounding_box (proj->priv->projectable);
|
2007-04-28 00:07:49 +08:00
|
|
|
|
2019-09-04 23:23:31 +08:00
|
|
|
if (x < bounding_box.x ||
|
|
|
|
y < bounding_box.y ||
|
|
|
|
x >= bounding_box.x + bounding_box.width ||
|
|
|
|
y >= bounding_box.y + bounding_box.height)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-04-28 00:07:49 +08:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-05-19 02:57:19 +08: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-23 05:28:31 +08: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-23 07:25:35 +08: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-23 05:28:31 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
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
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
proj->priv->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",
|
2018-08-04 00:34:47 +08: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-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
|
|
|
}
|
|
|
|
|
2017-12-02 22: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-31 08:34:56 +08:00
|
|
|
void
|
|
|
|
gimp_projection_set_priority_rect (GimpProjection *proj,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
2014-05-31 21:13:32 +08:00
|
|
|
gint w,
|
|
|
|
gint h)
|
2014-05-31 08:34:56 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
|
|
|
|
2019-03-26 16:54:59 +08:00
|
|
|
proj->priv->priority_rect = *GEGL_RECTANGLE (x, y, w, h);
|
2014-05-31 08:34:56 +08:00
|
|
|
|
2019-03-26 16:54:59 +08:00
|
|
|
gimp_projection_update_priority_rect (proj);
|
2014-05-31 08:34:56 +08:00
|
|
|
}
|
|
|
|
|
2014-06-30 05:57:22 +08:00
|
|
|
void
|
|
|
|
gimp_projection_stop_rendering (GimpProjection *proj)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_PROJECTION (proj));
|
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
gimp_projection_chunk_render_stop (proj, TRUE);
|
2014-06-30 05:57:22 +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 */
|
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.
2018-12-02 22:44:52 +08:00
|
|
|
gimp_projection_flush_whenever (proj, FALSE, FALSE);
|
1998-10-02 00:22:28 +08:00
|
|
|
}
|
|
|
|
|
2001-02-20 23: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.
2018-12-02 22:44:52 +08:00
|
|
|
gimp_projection_flush_now (GimpProjection *proj,
|
|
|
|
gboolean direct)
|
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 */
|
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.
2018-12-02 22:44:52 +08:00
|
|
|
gimp_projection_flush_whenever (proj, TRUE, direct);
|
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));
|
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
if (proj->priv->iter)
|
2004-07-14 18:31:59 +08:00
|
|
|
{
|
2019-01-13 21: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().
2018-11-28 02:32:55 +08:00
|
|
|
gimp_tile_handler_validate_begin_validate (proj->priv->validate_handler);
|
2017-04-23 02:22:06 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
while (gimp_projection_chunk_render_iteration (proj));
|
2017-04-23 02:22:06 +08: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().
2018-11-28 02:32:55 +08:00
|
|
|
gimp_tile_handler_validate_end_validate (proj->priv->validate_handler);
|
2019-01-12 16:36:09 +08:00
|
|
|
|
|
|
|
gimp_projection_chunk_render_stop (proj, FALSE);
|
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
|
|
|
|
2018-08-04 00:34:47 +08:00
|
|
|
static void
|
|
|
|
gimp_projection_allocate_buffer (GimpProjection *proj)
|
|
|
|
{
|
2019-08-02 04:01:58 +08:00
|
|
|
const Babl *format;
|
|
|
|
GeglRectangle bounding_box;
|
2018-08-04 00:34:47 +08:00
|
|
|
|
|
|
|
if (proj->priv->buffer)
|
|
|
|
return;
|
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
format = gimp_projection_get_format (GIMP_PICKABLE (proj));
|
|
|
|
bounding_box =
|
|
|
|
gimp_projectable_get_bounding_box (proj->priv->projectable);
|
2018-08-04 00:34:47 +08:00
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
proj->priv->buffer = gegl_buffer_new (&bounding_box, format);
|
2018-08-04 00:34:47 +08:00
|
|
|
|
|
|
|
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-06 03:42:26 +08:00
|
|
|
static void
|
|
|
|
gimp_projection_free_buffer (GimpProjection *proj)
|
|
|
|
{
|
2019-01-12 16:36:09 +08:00
|
|
|
gimp_projection_chunk_render_stop (proj, FALSE);
|
2014-05-31 21:13:32 +08:00
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_pointer (&proj->priv->update_region, cairo_region_destroy);
|
2014-05-31 21:13:32 +08:00
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
if (proj->priv->buffer)
|
2012-07-06 03:42:26 +08:00
|
|
|
{
|
2018-11-29 02:08:57 +08:00
|
|
|
gimp_tile_handler_validate_unassign (proj->priv->validate_handler,
|
|
|
|
proj->priv->buffer);
|
2012-07-06 03:42:26 +08:00
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&proj->priv->buffer);
|
2018-11-29 02:08:57 +08:00
|
|
|
g_clear_object (&proj->priv->validate_handler);
|
2019-09-04 17:59:23 +08:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (proj), "buffer");
|
2012-07-06 03:42:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2018-08-10 14:36:29 +08:00
|
|
|
cairo_rectangle_int_t rect;
|
2019-08-02 04:01:58 +08:00
|
|
|
GeglRectangle bounding_box;
|
2004-07-14 18:31:59 +08:00
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
bounding_box = gimp_projectable_get_bounding_box (proj->priv->projectable);
|
2009-08-24 21:59:14 +08:00
|
|
|
|
2018-03-31 20:13:36 +08: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;
|
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
if (gegl_rectangle_intersect ((GeglRectangle *) &rect,
|
|
|
|
GEGL_RECTANGLE (x, y, w, h), &bounding_box))
|
2014-06-02 03:30:11 +08:00
|
|
|
{
|
|
|
|
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 18:31:59 +08:00
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
static void
|
2004-07-14 00:36:29 +08: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.
2018-12-02 22:44:52 +08:00
|
|
|
gboolean now,
|
|
|
|
gboolean direct)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2014-05-31 07:22:54 +08:00
|
|
|
if (proj->priv->update_region)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2019-03-24 15:06:19 +08:00
|
|
|
/* Make sure we have a buffer */
|
|
|
|
gimp_projection_allocate_buffer (proj);
|
|
|
|
|
2004-07-12 19:43:00 +08:00
|
|
|
if (now) /* Synchronous */
|
2003-07-30 00:36:56 +08:00
|
|
|
{
|
2014-05-31 07:22:54 +08:00
|
|
|
gint n_rects = cairo_region_num_rectangles (proj->priv->update_region);
|
|
|
|
gint i;
|
2003-07-30 00:36:56 +08:00
|
|
|
|
2014-05-31 07:22:54 +08:00
|
|
|
for (i = 0; i < n_rects; i++)
|
2003-07-30 00:36:56 +08:00
|
|
|
{
|
2014-05-31 07:22:54 +08:00
|
|
|
cairo_rectangle_int_t rect;
|
2003-07-30 00:36:56 +08:00
|
|
|
|
2014-05-31 07:22:54 +08: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.
2018-12-02 22:44:52 +08:00
|
|
|
direct,
|
2014-05-31 07:22:54 +08:00
|
|
|
rect.x,
|
|
|
|
rect.y,
|
|
|
|
rect.width,
|
|
|
|
rect.height);
|
2003-07-30 00:36:56 +08:00
|
|
|
}
|
2019-01-12 16:36:09 +08:00
|
|
|
|
|
|
|
/* Free the update region */
|
|
|
|
g_clear_pointer (&proj->priv->update_region, cairo_region_destroy);
|
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
|
|
|
{
|
2019-01-12 16:36:09 +08:00
|
|
|
/* Consumes the update region */
|
|
|
|
gimp_projection_chunk_render_start (proj);
|
2003-07-30 00:36:56 +08:00
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
2019-09-04 17:51:27 +08:00
|
|
|
else if (! now && ! proj->priv->iter && proj->priv->invalidate_preview)
|
2007-06-27 05:39:51 +08:00
|
|
|
{
|
|
|
|
/* invalidate the preview here since it is constructed from
|
|
|
|
* the projection
|
|
|
|
*/
|
2014-05-31 06:08:43 +08:00
|
|
|
proj->priv->invalidate_preview = FALSE;
|
2007-06-27 05:39:51 +08:00
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
gimp_projectable_invalidate_preview (proj->priv->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
|
|
|
|
2019-03-26 16:54:59 +08:00
|
|
|
static void
|
|
|
|
gimp_projection_update_priority_rect (GimpProjection *proj)
|
|
|
|
{
|
|
|
|
if (proj->priv->iter)
|
|
|
|
{
|
|
|
|
GeglRectangle rect;
|
2019-08-02 04:01:58 +08:00
|
|
|
GeglRectangle bounding_box;
|
2019-03-26 16:54:59 +08:00
|
|
|
gint off_x, off_y;
|
|
|
|
|
|
|
|
rect = proj->priv->priority_rect;
|
|
|
|
|
|
|
|
gimp_projectable_get_offset (proj->priv->projectable, &off_x, &off_y);
|
2019-08-02 04:01:58 +08:00
|
|
|
bounding_box = gimp_projectable_get_bounding_box (proj->priv->projectable);
|
2019-03-26 16:54:59 +08: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.
|
|
|
|
*/
|
|
|
|
rect.x -= off_x;
|
|
|
|
rect.y -= off_y;
|
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
gegl_rectangle_intersect (&rect, &rect, &bounding_box);
|
2019-03-26 16:54:59 +08:00
|
|
|
|
|
|
|
gimp_chunk_iterator_set_priority_rect (proj->priv->iter, &rect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2019-01-12 21:29:16 +08:00
|
|
|
cairo_region_t *region = proj->priv->update_region;
|
|
|
|
gboolean invalidate_preview = FALSE;
|
2013-07-28 21:57:28 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
if (proj->priv->iter)
|
|
|
|
{
|
|
|
|
region = gimp_chunk_iterator_stop (proj->priv->iter, FALSE);
|
2013-07-28 21:57:28 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
proj->priv->iter = NULL;
|
2017-04-23 02:22:06 +08:00
|
|
|
|
2019-01-12 21:29:16 +08:00
|
|
|
if (cairo_region_is_empty (region))
|
|
|
|
invalidate_preview = proj->priv->invalidate_preview;
|
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
if (proj->priv->update_region)
|
2013-08-10 02:20:02 +08:00
|
|
|
{
|
2019-01-12 16:36:09 +08:00
|
|
|
cairo_region_union (region, proj->priv->update_region);
|
2013-07-28 21:57:28 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
cairo_region_destroy (proj->priv->update_region);
|
2013-08-10 02:20:02 +08:00
|
|
|
}
|
2013-07-28 21:57:28 +08:00
|
|
|
}
|
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
proj->priv->update_region = NULL;
|
2017-04-23 02:22:06 +08:00
|
|
|
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
{
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
|
2019-03-26 16:54:59 +08:00
|
|
|
gimp_projection_update_priority_rect (proj);
|
2013-08-10 02:20:02 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
if (! proj->priv->idle_id)
|
2014-05-31 07:22:54 +08:00
|
|
|
{
|
2019-01-12 16: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-31 07:22:54 +08:00
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
2019-01-12 21: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 21: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 21:14:40 +08:00
|
|
|
}
|
2001-11-11 07: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.
2018-12-06 21:44:23 +08:00
|
|
|
static void
|
2019-01-12 16: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.
2018-12-06 21:44:23 +08:00
|
|
|
{
|
2019-01-12 16: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.
2018-12-06 21:44:23 +08:00
|
|
|
{
|
2019-01-12 16: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.
2018-12-06 21:44:23 +08:00
|
|
|
}
|
|
|
|
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
{
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
{
|
2019-01-12 16:36:09 +08:00
|
|
|
cairo_region_t *region;
|
2018-08-20 15:00:10 +08:00
|
|
|
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
}
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
}
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
{
|
2019-01-12 16: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.
2018-08-20 22:47:22 +08:00
|
|
|
}
|
2019-01-12 16:36:09 +08:00
|
|
|
else
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2019-01-12 16:36:09 +08:00
|
|
|
proj->priv->idle_id = 0;
|
2004-07-14 00:36:29 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
return G_SOURCE_REMOVE;
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2019-01-12 16:36:09 +08:00
|
|
|
gimp_projection_chunk_render_iteration (GimpProjection *proj)
|
2001-11-11 07:03:22 +08:00
|
|
|
{
|
2019-01-12 16:36:09 +08:00
|
|
|
if (gimp_chunk_iterator_next (proj->priv->iter))
|
2014-05-31 07:22:54 +08:00
|
|
|
{
|
2019-01-12 16:36:09 +08:00
|
|
|
GeglRectangle rect;
|
2014-05-31 08:34:56 +08:00
|
|
|
|
2019-01-12 16: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.
2018-12-06 21:44:23 +08:00
|
|
|
|
2019-01-12 16: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.
2018-12-06 21:44:23 +08:00
|
|
|
|
2019-01-12 16: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.
2018-12-06 21:44:23 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
/* Still work to do. */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
2014-05-31 07:22:54 +08:00
|
|
|
{
|
2019-01-12 16: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.
2018-12-06 21:44:23 +08:00
|
|
|
|
2019-01-12 16: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-31 07:22:54 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
gimp_projectable_invalidate_preview (proj->priv->projectable);
|
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
/* FINISHED */
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2019-08-02 04:01:58 +08:00
|
|
|
gint off_x, off_y;
|
|
|
|
GeglRectangle bounding_box;
|
|
|
|
GeglRectangle rect;
|
2008-11-05 02:06:36 +08:00
|
|
|
|
2014-05-31 06:08:43 +08:00
|
|
|
gimp_projectable_get_offset (proj->priv->projectable, &off_x, &off_y);
|
2019-08-02 04:01:58 +08:00
|
|
|
bounding_box = gimp_projectable_get_bounding_box (proj->priv->projectable);
|
2008-08-13 00:30:44 +08:00
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
if (gegl_rectangle_intersect (&rect,
|
|
|
|
GEGL_RECTANGLE (x, y, w, h), &bounding_box))
|
2013-08-03 02:43:44 +08:00
|
|
|
{
|
2014-06-02 03:30:11 +08:00
|
|
|
if (now)
|
|
|
|
{
|
2018-11-29 02:08:57 +08:00
|
|
|
gimp_tile_handler_validate_validate (
|
|
|
|
proj->priv->validate_handler,
|
|
|
|
proj->priv->buffer,
|
2019-08-02 04:01:58 +08:00
|
|
|
&rect,
|
2020-03-14 19:52:01 +08:00
|
|
|
FALSE, FALSE);
|
2018-11-29 02:08:57 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_tile_handler_validate_invalidate (
|
|
|
|
proj->priv->validate_handler,
|
2019-08-02 04:01:58 +08:00
|
|
|
&rect);
|
2014-06-02 03:30:11 +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.
|
|
|
|
*/
|
|
|
|
g_signal_emit (proj, projection_signals[UPDATE], 0,
|
|
|
|
now,
|
2019-08-02 04:01:58 +08:00
|
|
|
rect.x + off_x,
|
|
|
|
rect.y + off_y,
|
|
|
|
rect.width,
|
|
|
|
rect.height);
|
2014-06-02 03:30:11 +08:00
|
|
|
}
|
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
|
|
|
{
|
2018-08-10 14:36:29 +08: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-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)
|
2014-05-31 06:08:43 +08:00
|
|
|
proj->priv->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
|
2018-08-04 00:34:47 +08:00
|
|
|
gimp_projection_projectable_structure_changed (GimpProjectable *projectable,
|
|
|
|
GimpProjection *proj)
|
2004-07-14 00:36:29 +08:00
|
|
|
{
|
2019-08-02 04:01:58 +08:00
|
|
|
GeglRectangle bounding_box;
|
2008-11-05 02:06:36 +08:00
|
|
|
|
2012-07-06 03:42:26 +08:00
|
|
|
gimp_projection_free_buffer (proj);
|
2012-03-15 21:38:54 +08:00
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
bounding_box = gimp_projectable_get_bounding_box (projectable);
|
2007-06-27 05:39:51 +08:00
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
gimp_projection_add_update_area (proj,
|
|
|
|
bounding_box.x, bounding_box.y,
|
|
|
|
bounding_box.width, bounding_box.height);
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|
2018-08-04 00:34:47 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_projection_projectable_bounds_changed (GimpProjectable *projectable,
|
|
|
|
gint old_x,
|
|
|
|
gint old_y,
|
|
|
|
GimpProjection *proj)
|
|
|
|
{
|
|
|
|
GeglBuffer *old_buffer = proj->priv->buffer;
|
|
|
|
GimpTileHandlerValidate *old_validate_handler;
|
2019-08-02 04:01:58 +08:00
|
|
|
GeglRectangle old_bounding_box;
|
|
|
|
GeglRectangle bounding_box;
|
|
|
|
GeglRectangle old_bounds;
|
|
|
|
GeglRectangle bounds;
|
|
|
|
GeglRectangle int_bounds;
|
|
|
|
gint x, y;
|
2018-08-04 00:34:47 +08:00
|
|
|
gint dx, dy;
|
|
|
|
|
|
|
|
if (! old_buffer)
|
|
|
|
{
|
|
|
|
gimp_projection_projectable_structure_changed (projectable, proj);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
old_bounding_box = *gegl_buffer_get_extent (old_buffer);
|
|
|
|
|
2018-08-04 00:34:47 +08:00
|
|
|
gimp_projectable_get_offset (projectable, &x, &y);
|
2019-08-02 04:01:58 +08:00
|
|
|
bounding_box = gimp_projectable_get_bounding_box (projectable);
|
2018-08-04 00:34:47 +08:00
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
if (x == old_x && y == old_y &&
|
|
|
|
gegl_rectangle_equal (&bounding_box, &old_bounding_box))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
old_bounds = old_bounding_box;
|
|
|
|
old_bounds.x += old_x;
|
|
|
|
old_bounds.y += old_y;
|
2018-08-04 00:34:47 +08:00
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
bounds = bounding_box;
|
|
|
|
bounds.x += x;
|
|
|
|
bounds.y += y;
|
|
|
|
|
|
|
|
if (! gegl_rectangle_intersect (&int_bounds, &bounds, &old_bounds))
|
2018-08-04 09:58:16 +08:00
|
|
|
{
|
|
|
|
gimp_projection_projectable_structure_changed (projectable, proj);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
dx = x - old_x;
|
|
|
|
dy = y - old_y;
|
2018-08-04 00:34:47 +08:00
|
|
|
|
|
|
|
#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 16:36:09 +08:00
|
|
|
* region of the new buffer.
|
2018-08-04 00:34:47 +08:00
|
|
|
*/
|
|
|
|
|
2019-01-12 16:36:09 +08:00
|
|
|
gimp_projection_chunk_render_stop (proj, TRUE);
|
|
|
|
|
2019-08-13 22:39:14 +08:00
|
|
|
if (dx == 0 && dy == 0)
|
|
|
|
{
|
|
|
|
gimp_tile_handler_validate_buffer_set_extent (old_buffer, &bounding_box);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
old_validate_handler = proj->priv->validate_handler;
|
2018-08-04 00:34:47 +08:00
|
|
|
|
2019-08-13 22:39:14 +08:00
|
|
|
proj->priv->buffer = NULL;
|
|
|
|
proj->priv->validate_handler = NULL;
|
2018-08-04 00:34:47 +08:00
|
|
|
|
2019-08-13 22:39:14 +08:00
|
|
|
gimp_projection_allocate_buffer (proj);
|
2018-08-04 00:34:47 +08:00
|
|
|
|
2019-08-13 22:39:14 +08:00
|
|
|
gimp_tile_handler_validate_buffer_copy (
|
|
|
|
old_buffer,
|
|
|
|
GEGL_RECTANGLE (int_bounds.x - old_x,
|
|
|
|
int_bounds.y - old_y,
|
|
|
|
int_bounds.width,
|
|
|
|
int_bounds.height),
|
|
|
|
proj->priv->buffer,
|
|
|
|
GEGL_RECTANGLE (int_bounds.x - x,
|
|
|
|
int_bounds.y - y,
|
|
|
|
int_bounds.width,
|
|
|
|
int_bounds.height));
|
|
|
|
|
|
|
|
gimp_tile_handler_validate_unassign (old_validate_handler,
|
|
|
|
old_buffer);
|
2018-08-04 00:34:47 +08:00
|
|
|
|
|
|
|
g_object_unref (old_validate_handler);
|
2019-08-13 22:39:14 +08:00
|
|
|
g_object_unref (old_buffer);
|
2018-08-04 00:34:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (proj->priv->update_region)
|
|
|
|
{
|
2019-08-02 04:01:58 +08:00
|
|
|
cairo_region_translate (proj->priv->update_region, dx, dy);
|
|
|
|
cairo_region_intersect_rectangle (
|
|
|
|
proj->priv->update_region,
|
|
|
|
(const cairo_rectangle_int_t *) &bounding_box);
|
2018-08-04 00:34:47 +08:00
|
|
|
}
|
|
|
|
|
2019-08-02 04:01:58 +08:00
|
|
|
int_bounds.x -= x;
|
|
|
|
int_bounds.y -= y;
|
|
|
|
|
|
|
|
if (int_bounds.x > bounding_box.x)
|
|
|
|
{
|
|
|
|
gimp_projection_add_update_area (proj,
|
|
|
|
bounding_box.x,
|
|
|
|
bounding_box.y,
|
|
|
|
int_bounds.x - bounding_box.x,
|
|
|
|
bounding_box.height);
|
|
|
|
}
|
|
|
|
if (int_bounds.y > bounding_box.y)
|
|
|
|
{
|
|
|
|
gimp_projection_add_update_area (proj,
|
|
|
|
bounding_box.x,
|
|
|
|
bounding_box.y,
|
|
|
|
bounding_box.width,
|
|
|
|
int_bounds.y - bounding_box.y);
|
|
|
|
}
|
|
|
|
if (int_bounds.x + int_bounds.width < bounding_box.x + bounding_box.width)
|
|
|
|
{
|
|
|
|
gimp_projection_add_update_area (proj,
|
|
|
|
int_bounds.x + int_bounds.width,
|
|
|
|
bounding_box.y,
|
|
|
|
bounding_box.x + bounding_box.width -
|
|
|
|
(int_bounds.x + int_bounds.width),
|
|
|
|
bounding_box.height);
|
|
|
|
}
|
|
|
|
if (int_bounds.y + int_bounds.height < bounding_box.y + bounding_box.height)
|
|
|
|
{
|
|
|
|
gimp_projection_add_update_area (proj,
|
|
|
|
bounding_box.x,
|
|
|
|
int_bounds.y + int_bounds.height,
|
|
|
|
bounding_box.width,
|
|
|
|
bounding_box.y + bounding_box.height -
|
|
|
|
(int_bounds.y + int_bounds.height));
|
|
|
|
}
|
2018-08-04 09:45:06 +08:00
|
|
|
|
|
|
|
proj->priv->invalidate_preview = TRUE;
|
2018-08-04 00:34:47 +08:00
|
|
|
}
|