Commit Graph

778 Commits

Author SHA1 Message Date
Niels De Graef def862bae4 meson: Always enable CPU extensions
Don't enable conditionally based on the buildtype.

Further, don't use `add_project_arguments()` to enable the instructions:
this will lead to crashes within g-ir-scanner, which can't properly
parse these instructions.

https://gitlab.gnome.org/GNOME/gimp/-/issues/5053
2021-06-15 21:15:32 +00:00
Jehan f40dc40cbc app: fix autotools build.
My previous commit broke the autotools build. Apparently when using
g_object_unref(), some C++ symbol leaked into libapppaint.a archive
library, hence the main binaries (e.g. gimp-2.99) could not be linked
without adding -lstdc++ flag:

> /usr/bin/ld: paint/libapppaint.a(gimppaintcore-loops.o): undefined reference to symbol '__gxx_personality_v0@@CXXABI_1.3'
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line

Not exactly sure why using this GLib function in particular caused this,
but let's just try another approach in order not to link the main binary
with C++ standard lib.
Instead let's manage all GeglOperation allocation in gimp-layer-modes.c
by adding a gimp_layer_modes_exit() function and some static array for
storing operation object of each layer mode.
2020-11-10 12:52:01 +01:00
Jehan b3fc24268a Issue #5888: GIMP 2.99.2 crash when using brush in multiply mode.
The GimpOperationLayerMode variable member in DoLayerBlend was not
properly constructed. C++ class constructor can be called by creating
object variables, but with GObject, we have to do it with pointers.
Otherwise here we were only allocating the memory for the struct, but
not actually calling any initialization functions.

Also it would seem that the struct was not initialized at zero, as the
space_fish variable was not NULL when it should (i.e. even with same
composite and blend space), hence composite_to_blend_fish was not NULL
and since the operation was not a valid GeglOperation when entering
gimp_operation_layer_mode_real_process(), we crashed.
Not sure how it went unseen for so long!

So instead let's make the layer_mode class member into a pointer. As
such, I have to properly allocate and free it. This is also why I am
adding a copy constructor which will ref the pointer (otherwise we unref
more than we ref as the default copy constructor would just copy the
pointer).
2020-11-10 01:11:01 +01:00
santouits 6e00a19fd0 Don't compile gimpmarshal source file many times
Also, removes gimpmarshal.h from a source file that didn't need it.
2020-09-13 18:13:29 +03:00
Jehan 2b764c6542 app: do not try to copy a buffer result from a canceled GEGL operation.
This fixes:
> GEGL-WARNING: (../../src/gegl/gegl/buffer/gegl-tile.c:127):gegl_tile_dup: runtime check failed: (! src->damage)

Which happened when a GEGL operation was running and you canceled it in
the middle, say with the ESC key (easy to reproduce with long operations
such as "Color to Gray"). In such case, obviously don't try to copy the
unfinished operation result into the dest buffer.
2020-05-18 11:22:34 +02:00
Ell 8c619bf0b2 app: add gimp_gegl_node_has_key()
... which determines if a node's operation-class has a specific
key, and can be used instead of gimp_gegl_node_get_key() when only
existence is important, to avoid compiler warnings.

Update the rest of the code to use the new function.
2020-04-07 19:02:18 +03:00
Ell e324e2d4b3 app: add gimp_applicator_set_active()
... which allows temporarily turning the applicator into a NOP,
without destroying cached data.

This commit also improves gimp_applicator_set_{src,dest}_buffer().
2020-04-02 18:54:18 +03:00
Ell faf6acfb67 app: add "chunked" parameter to gimp_tile_handler_validate_validate()
... which allows validating the area in chunks, instead of in a
single step.
2020-03-14 13:54:57 +02:00
Ell 24534338e7 app: add support for offset buffers in gimp_channel_select_buffer() ...
... and gimp_gegl_mask_combine_buffer()

Allow the functions to work with buffers whose top-left corner is
not at (0, 0).
2020-02-03 21:21:08 +02:00
Ell fcc1c3d380 app: suspend tile validation while setting extent of validate-handler buffer
In gimp_tile_handler_validate_buffer_set_extent(), suspend tile
validation while calling gimp_gegl_buffer_set_extent(), so that if
the call triggers clearing of partial tiles, these tiles don't get
unnecessarily validated.
2020-01-18 12:43:06 +02:00
Ell bed825ab3d app: add gimp_gegl_node_get_key()
... which gets an operation-class key for the operation associated
with the node, if any.
2020-01-17 12:08:30 +02:00
Ell d39822bcd7 app: in GimpTileHandlerValidate, fix tile-data pointer for negative coords
In gimp_tile_handler_validate_validate_tile(), when validating a
partial tile with negative coordinates, make sure to adjust the
result of the modulo when calculating the tile-realtive coordinates
so that they're non-negative, to fix the tile-data pointer offset.
2020-01-16 01:58:55 +02:00
Ell 3ea391602e app: add GimpTileHandlerValidate::invalidated signal
Add a new GimpTileHandlerValidate::invalidated signal, which is
emitted when a region of the buffer is invalidated.  This would
allow us to properly invalidate the graph in response; this
normally happens in response to GeglBuffer::changed, but this
signal is not emitted when a region is merely invalidated.
2020-01-15 21:50:11 +02:00
Ell ba6040bbcd app: allow calling gimp_tile_handler_validate_validate() with a NULL rect
... and validate the entire buffer.
2020-01-15 21:50:11 +02:00
Ell f1c448e0f4 app: fix integer overflow when reporting operation progress
In gimp_gegl_apply_cached_operation(), use gint64 for storing the
total and processed pixel counts used for reporting progress, to
avoid overflowing when applying an operation to a large image.
2020-01-08 11:40:02 +02:00
Jehan b8d8424ae0 app, libgimp*: (meson) fix all the generated `*-enums.c`.
More of the files were wrong, or at least not absolutely identical to
the files generated by the autotools. I am not doing any code change
other than trying to make both build systems produce identical files
(except for slight differences on 2 files not worth the effort) even
though maybe some things can be improved (especially on the include
list). Maybe to be improved later.

Also fixing 2 of the previously autotools-generated files because of
space typos which should have been committed earlier.

Finally it is to be noted that there is no logics to copy the generated
files back to the source directory in the meson rules. I am not sure
anyway this is really worth it and maybe we should just stop tracking
these generated files eventually.
2019-10-19 22:32:29 +02:00
Ell 076d9b2a28 app: restore behavior of gimp_gegl_apply_operation() with NULL src_buffer
Restore the behavior of gimp_gegl_apply_operation() prior to
11629fde66 when src_buffer is NULL:
keep the existing operation-node input, instead of using an empty
input.  Unlike gimp_gegl_apply_cached_operation(),
gimp_gegl_apply_operation() doesn't have an explicit
connect_src_buffer parameter.

This fixes empty output when merging layers.
2019-10-05 09:43:22 +03:00
Ell 11629fde66 app: avoid dropping cached data when committing filters
In gimp_gegl_apply_cached_operation(), add a boolean
connect_src_buffer parameter, which determines whether to connect
the source buffer to the operation-node's input, or to use its
existing input.  In gimp_drawable_merge_filter(), pass FALSE for
connect_src_buffer, so that the existing filter-node input is used.
This produces an equivalent result, however, it avoids invalidating
the filter node, and dropping cached data as a result.  In
operations that cache larger areas than the ROI, this avoids
reprocessing already-cached data when processing the rest of the
operation.

Additionally, in gimp_gegl_apply_cached_operation(), use an empty
input for the operation if src_buffer is NULL and
connect_src_buffer is TRUE; previously, we'd use the operation-
node's existing input when src_buffer was NULL.  Furthermore, crop
the operation-node's input to the destination rect when crop_input
is TRUE, even if connect_src_buffer is FALSE.
2019-10-03 20:12:17 +03:00
Ell 88c6f8296d Issue #3994 - Artifacts when committing half-cached filters
In gimp_gegl_apply_cached_operation(), when applying a non-point
filter with the same source and destination buffers, render the
result to a temporary buffer to avoid chunking artifacts.  We'd
previously duplicate the source buffer instead (with commit
35729ee02a erroneously copying the
cached results to the source/destination buffer before duplicating
it, causing this bug), but we now use a temporary result buffer
instead; this has roughly the same overhead, but would allow us to
keep the original operation-node input when committing a drawable
filter in a future commit, which would avoid dropping any cached
data.
2019-09-30 10:25:17 +03:00
Ell 1664ecbf1d app: add "Swap compression" option to the preferences
Add a new "Swap compression" option to the preferences, allowing
explicit control over the tile-swap compression algorithm.
Previously, control over swap compression was only possible through
GEGL command-line options/environment variables.  Since the GEGL
API to list all available compression algorithms is still private
for now, we currently only list the three predefined compression
levels -- "best performance" (the default), "balanced", and "best
compression" -- and a "none" option, to disable compression
altogether.  Selecting a custom compression algorithm is possible
by entering its name manually.
2019-09-22 17:35:14 +03:00
Ell 4fc345183b app, meson.build: fix a bunch of warnings in C++ files 2019-09-12 20:04:50 +03:00
Félix Piédallu 65eff6f150 Meson port. 2019-09-11 16:42:04 +02:00
Ell 6df0be91ba app: in gimp_gegl_mask_bounds(), add support for arbitrary buffer extents 2019-09-05 18:04:11 +03:00
Ell ddbff867a1 app: fix gimp_gegl_mask_bounds() 2019-09-05 18:04:10 +03:00
Ell 564afeda8b app: in gimp_gegl_buffer_set_extent(), clear full OOB region
In gimp_gegl_buffer_set_extent(), clear the full now-out-of-bounds
region of the buffer, instead of only full out-of-bounds tiles;
however, we still make sure to clear full tiles, instead of partial
tiles, as much as possible.  This prevents (parts of) the old
content of the buffer from showing when it's enlarged again.  This
is especially relevant for the image projection, once we add
support for a dynamically-expanding canvas in the following
commits, since the projection of a reexpanded buffer can be
temporarily rendered to the display before it's fully
reconstructed, exposing parts of the old content.
2019-09-04 19:16:40 +03:00
Ell b4ee9ff055 app: add gimp_tile_handler_validate_buffer_set_extent()
... which sets the extent of a buffer with an assigned
GimpTileHandlerValidate, clipping the dirty region to the new
extent.
2019-08-13 17:44:10 +03:00
Ell 90610ac87e app: add gimp_gegl_buffer_set_extent()
.... as a drop-in replacement for gegl_buffer_set_extent(), which,
in addition to setting the buffer's extent, clears any now-out-of-
bounds tiles, to free memory.
2019-08-13 17:44:10 +03:00
Ell 35729ee02a app: in gimp_gegl_apply_cached_operation(), copy cached result *before* rejigging graph
In gimp_gegl_apply_cached_operation(), copy the cached results to
the destination buffer *before* reconnecting the operation node, as
this may cause the cache to be cleared (see commit
gegl@4347255cd9d5031e6757c70fdde5c63539d5f508).
2019-08-02 00:40:01 +03:00
Michael Natterer 63695b4b21 libgimbase: merge gimpparam.h into gimpparamspecs.h
which means that it's now included normally via gimpbase.h
and not any longer via gimpbasetypes.h which we only did out
of lazyness. A *lot* of files in libgimp* and app/ now need to
2019-07-31 10:16:21 +02:00
Ell 2d80d4d138 app: use gimp_gegl_buffer_dup() everywhere
... instead of gegl_buffer_dup().
2019-07-30 20:32:41 +03:00
Ell 5798cefe1b app: add gimp_gegl_buffer_dup()
... as a drop-in replacement for gegl_buffer_dup(), which COWs all
tiles of the source buffer, including ones that aren't fully
included within buffer's extent.
2019-07-30 20:32:10 +03:00
Ell 69ce5e7e02 app: in gimp_gegl_buffer_copy(), allow tiles outside the abyss to be COWed
In gimp_gegl_buffer_copy(), assume that the area outside the abyss
is empty, and so, when the abyss policy is NONE, allow data otuside
the source/destination abyss to be copied, by temporarily modifying
the abyss.  This allows tiles that aren't fully contained within
the abyss to be COWed, unlike gegl_buffer_copy(), which has to be
more general.
2019-07-30 20:32:09 +03:00
Ell ab94251ae9 app: remove gimp_gegl_rectangle_align_to_tile_grid()
... and replace it with gegl_rectangle_align_to_buffer().
2019-07-30 20:32:08 +03:00
Ell 5a500b4a12 app: use longer iteration inteval (= bigger chunks) when applyng an op
In gimp_gegl_apply_[cached_]operation(), use a longer iteration
interval (resulying in bigger chunks) when processing the op, than
the iteration interval used for rendering the projection.  In
particular, use an even longer interval when processing area
filters, since their may be particularly sensitive to the chunk
size (see, for example, issue #3711).  Likewise, use the asme
longer interval when not showing progress indication, since we
don't need to stay responsive in this case (but don't avoid
chunking altogether, to reduce the space required for intermediate
results).

This allows us to process an op faster when committing a filter,
while still remaining responsive (if overall slower) during
preview.
2019-07-28 12:10:18 +03:00
Ell f6c4e4912a app: add gimp_gegl_node_is_area_filter_operation()
... which determines if a node is an area filter operation.  If the
node is a meta op, we conservatively return TRUE, as it may involve
an area-filter op.
2019-07-28 12:10:18 +03:00
Michael Natterer aace6b179b Issue #3512 - feather selection doesn't work at edges of images
Add a "gboolean edge_lock" parameter to GimpChannel::feather() and a
"Selected areas continue outside the image" toggle to the "Feather
Selection" dialog, just like they exist for shrink selection and
border selection. At the end, convert the boolean to the right abyss
policy for gegl:gaussian-blur.
2019-06-16 16:51:30 +02:00
Ell a6393e6c55 app: add support for offset buffers in gimp_gegl_apply_[cached_]operation()
In gimp_gegl_apply_[cached_]operation(), add support for output
buffers whose extent's top-left corner is not (0, 0).  This is
needed by the previous commit.
2019-05-29 05:38:58 -04:00
Ell 3895dc07a9 app: add gimp_gegl_create_transform_node()
... which takes a GimpMatrix3, and returns a corresponding
gegl:transform node.
2019-05-29 05:26:42 -04:00
Ell a5962e4049 app: disregard composite space in non-union alpha-only layer modes
In gimp_layer_mode_get_format(), disregard the requested composite
space when selecting the format, if the input layer mode is alpha-
only, and the requested composite mode is not UNION, since, in this
case, the layer mode doesn't combine the layer/backdrop colors, and
rather only modifies the alpha of one of them.  This allows us to
use the preferred format, avoiding gamma conversion.

This particularly improves the performance of the Eraser tool in
perceptual images.
2019-05-24 01:43:20 -04:00
Ell 928e5957e3 app: in gimp-gegl-nodes, set underlying operation
In the vairous gimp_gegl_create_foo_node() functions, set the
parent node's underlying operation node, so that
gimp_gegl_apply_cached_operation() avoids duplicating the source
buffer when applying these nodes (all underlying operations are
currently point ops.)
2019-04-30 14:32:18 -04:00
Ell 213b126c6e app: use underlying operation in gimp_gegl_apply_cached_operation()
In gimp_gegl_apply_cached_operation(), use the underlying
operation, as returned from
gimp_gegl_node_get_underlying_operation(), for testing whether the
operation is a point operation, for the purpose of avoiding
duplicating the input buffer.  Likewise, avoid duplicating the
buffer when the underlying operation is a source operation.
2019-03-27 15:45:57 -04:00
Ell eb5e473665 app: add gimp_gegl_node_{set,get}_underlying_oepration()
... which allow setting/getting the "underlying operation" node of
a graph node.  For example, GimpDrawableFilter constructs a complex
graph around a given operation node, which would be the underlying
operation of the graph.  This allows querying the properties of the
underlying operation, given only the graph.

In recursive cases, gimp_gegl_node_get_underlying_operation()
returns the most-nested underlying operation; when no underlying
operation has been set, gimp_gegl_node_get_underlying_operation()
returns the input node.
2019-03-27 15:45:55 -04:00
Ell ff13e55c16 app: add gimp_gegl_node_is_source_operation()
... which determines if a node is a source operation.
2019-03-27 15:45:31 -04:00
Ell 733a6ec01c app: skip cache and format conversion when merging a drawable filter
In gimp_drawable_merge_filter(), disable the filter applicator's
cache and output-format conversion nodes before processing the
uncached region of the filter, so that the result is written
directly to the drawable's buffer.
2019-03-25 09:02:27 -04:00
Ell d4689441fe app: small fix to gimp_gegl_mask_combine_ellipse_rect() 2019-03-24 14:45:45 -04:00
Ell a227c8e94d app: improve gimp_gegl_mask_combine_buffer()
Simplify code, use gimp_gegl_buffer_copy() for CHANNEL_OP_REPLACE
when possible, improve value clipping, and parallelize processing.
2019-03-20 16:01:57 -04:00
Ell 1044342393 app: improve gimp_gegl_mask_combine_ellipse[_rect]()
Improve gimp_gegl_mask_combine_ellipse_rect() -- the funciton
responsible for rendering ellipse/rounded-rectangle selections.

Most notably, this commit significantly improves the function's
performance, by identifying whole tiles, whole rows, or parts of a
row, that are fully inside, or fully outside, the ellipse, and
filling them in bulk, instead of calculating the anti-aliasing
value at each pixel, which is now only done along the
circumference.

This commit also improves anti-aliasing, by more accurately
approximating the distance from a pixel to the ellipse, and by
normalizing the distance according to the pixel's cross-section
length in the direction of the said point.  In particular, we
guarantee that pixels that are fully inside/outside the ellipse
have a value of 1/0, respectively, facilitating the aforementioned
optimization.

Additionally, this commit fixes various edge cases where several
primitives coincide at a single pixel (in the rounded-rectangle
case), adds support for CHANNEL_OP_INTERSECT, and parallelizes
processing.
2019-03-20 15:58:29 -04:00
Ell 8a6e1c907d app: improve gimp_gegl_mask_combine_rect()
Simplify the code, and add support for CHANNEL_OP_INTERSECT.
2019-03-20 15:58:29 -04:00
Ell 5198d3c32d app: convert gimp-gegl-mask-combine to C++
... in preparation for next commits.
2019-03-20 15:58:28 -04:00
Ell ffaaa81c8a app: add gimp_babl_format_change_{component_type,trc}()
... which change a format's component-type/TRC, without otherwise
affecting it.
2019-03-20 15:57:05 -04:00