Commit Graph

542 Commits

Author SHA1 Message Date
Jehan 2b27feb2fd app, libgimp*, modules, pdb, plug-ins: new GimpParamColor.
This is meant to obsolete GeglParamColor with at least an additional argument
has_alpha which we need in GIMP. It allows to advertize when a parameter wants
an opaque color, which in particular means we know when displaying a GUI to pick
colors with alpha or not.
2024-04-19 23:25:13 +02:00
Alx Sa 0c26cd442a operations: Port semi-flatten to GeglColor
After the color space invasion, the
Semi-Flatten GUI was broken since it still
used GimpRGB as its color property.
This patch fixes this by porting to
GeglColor. The GimpRGB conversion was
also removed from the PDB interface
since the GeglColor comes directly from
GimpContext.
2024-03-05 18:30:53 +00:00
Øyvind Kolås 4463c1e0b1 app: make hue-saturation op use HSLA float as processing space
This should be quite a bit quicker than the per pixel overhead of
function call converting rgb<->hsl.
2024-02-21 19:41:11 +00:00
Øyvind Kolås 992cd783ac app: do processing with non-linear RGB in threshold op 2024-02-21 15:54:20 +01:00
Øyvind Kolås bc7f0f5fc2 app: make posterize op operate with a perceptual gamma 2024-02-21 09:03:08 +01:00
Øyvind Kolås 2d1a02298d app: gimpoperationhuesaturation, do processing in non-linear
Address a regression of hue-sector sizes. The HSL model math in gimp_rgb_to_hsl
and gimp_hsl_to_rgb uses R'G'B' values rather than RGB.

Fixes #10756.
2024-02-17 06:03:40 +00:00
Øyvind Kolås 597c52b92e app: gimpoperationgradient keep achromatic colors under dither
Use the same amount of dithering on R,G and B if they initially were all equal.
This allows us to keep achromatic gradients achromatic, while providing the
same amount of dither as before for colored gradients. Discrepancy uncovered in
issue #10756.
2024-02-16 22:25:25 +00:00
Øyvind Kolås 5a0a3a1263 app: special-case achromatic pixels in hue-saturation
Issue #10756, without this grayscale pixels are affected by
the red part of the manipulation configuration, after this
change pixels with original saturation == 0.0 are only
changed by the master adjustment.
2024-02-16 00:16:08 +00:00
Jehan 8bb79dc671 app: port Colorize to GeglColor property.
While doing this, I could find a lot of problems in the algorithm:

1. It looks like the original intent (from GUI and code) is that you set hue and
   saturation but not really the intended lightness, rather its increase or
   decrease, relatively to every pixel current lightness. I.e. that every pixel
   will be set to the selected hue and saturation, and only the lightness will
   change. The "lightness" field is therefore a relative value (pixel per
   pixel). The first problem is that instead of lightness, we compute the
   luminance, which is related but different and set this in the lightness
   field.
2. The second issue is that we were using gimp_hsl_to_rgb() which after testing
   (because its documentation doesn't give any TRC/space info at all) looks like
   it computes a color from HSL to non-linear RGB of the same space. Yet we were
   outputting to a linear RGB space. So we compute the wrong values. On the
   other hand, because of the first problem, I realize (after testing) that it
   makes our render closer to the intended render by chance (at least when the
   TRC is sRGB's). It's still wrong, but if we were to change the output to
   "R'G'B'A float" instead, the render would be much darker. In both cases, it's
   wrong anyway.
   I would not say that the 2 problems are canceling each others, but they are
   making the final result somewhat OK.
3. Ideally we should be using babl to convert colors, and this is the best way
   to actually implement the original filter intent. Unfortunately so far, doing
   this is much slower (though I save a lot of time by moving out of the samples
   loop and processing data in chunks, it's still slower than the current,
   nearly instant, implementation).
4. Because of all previous implementation irregularities, the render is
   different depending on the actual image space. I.e. that the exact same image
   filtered through Colorize with the exact same operation parameters will
   render differently. I would need to test further, and maybe it's normal since
   HSL is also space-dependant (and that's where we work on in this operation),
   but I'm wondering if the result should not be independant of the working
   space.
5. I implemented our own prepare() method because the one in
   GimpOperationPointFilter parent seems to allow other input or output models.
   Even though in all my tests, it was always linear RGB (which is what we want
   here), let's make sure by having a custom prepare() method explicitly setting
   these. It's also the opportunity to create some babl fishes.

In any case, I'm leaving the code as-is for now, because it's how this operation
has been since forever (at least for as long as I was around) and I don't think
it's the right idea to change it on a whim.

This raises even more the concern of versionning GEGL operation, which we have
been discussing with pippin on IRC lately, because if ever we want to change
this one, now that operations are not just applied, but possibly
non-destructively recreated at load, we need to make sure that we recreate the
render expected at the time of creation of a XCF while allowing us to have the
filters improving when needed.
2024-02-15 23:55:06 +01:00
Jehan 77420957d8 app: use GEGL/babl to convert to HSL in gimp_operation_hue_saturation_map(). 2024-02-12 18:30:00 +01:00
Jehan 02546da780 app: layer layer modes to use babl conversions directly. 2024-02-11 23:28:04 +01:00
Jehan 924dbb44a8 app, libgimpconfig: GimpFilterTool color_picked() now uses GeglColor.
In particular, the Curves, Levels and Operation tools method implemented
are updated. Also GeglColor arguments in GEGL operations are not
transformed into GimpRGB arguments anymore in GIMP. GeglColor GParamSpec
stay GeglColor now.
2024-02-11 23:28:04 +01:00
Jehan b6856af9d8 app: GimpGradient now uses GeglColor.
I still see some limitations in GimpGradient, and in particular, they are still
always stored as RGB in GGR files. It would be nice if we could store the actual
color format. This way, if someone chooses a gradient stop as Lab or CMYK color,
that's what the gradient file would keep track of. But also even storing the
space of a color (instead of storing/loading always in sRGB, even though this
may still work fine as we store unbounded double values). This might warrant for
a v2 of GGR file format.

This commit also fixes loading of SVG gradient which was apparently broken
regarding hexadecimal color parsing.

Finally I improve gegl_color_set_alpha() by adding an alpha channel when the
initial format had none.
2024-02-11 23:28:03 +01:00
Jehan dbbcfb16d5 app, libgimp*, pdb, plug-ins: GimpContext is now using only GeglColor.
- app: gimp_context_get_(foreground|background)() are now returning a GeglColor.
- libgimp: PDB functions named similarly in libgimp are returning a newly
  allocated GeglColor too.
- A few other PDB functions (the ones using these functions) were updated and
  their signature changed to use GeglColor too, when relevant. Plug-ins which
  use any of the changed libgimp functions were fixed.
- GimpContext: signals "(foreground|background)-changed" are now passing a
  GeglColor.
- libgimpconfig: new macro GIMP_CONFIG_PROP_COLOR using gegl_param_spec_color().
- GimpContext: properties "foreground" and "background" are now GeglParamColor
  properties.
- app: All code interacting with GimpContext objects were updated to receive a
  GeglColor (that they may still convert, or no, to GimpRGB for now).
- app: gimp_prop_gegl_color_button_new() was added as an alternative to
  gimp_prop_color_button_new() when the property is a GeglParamColor. Eventually
  the former should replace completely the latter.
- libgimpwidgets: gimp_prop_color_area_new() now works on GeglParamColor
  properties only.
- libgimp: gimp_procedure_dialog_get_widget() will generate a GimpColorArea for
  GeglTypeParamColor arguments.
2024-02-11 23:28:02 +01:00
Jehan 3f54d83bac app: do not maintain manually the list of core ops with custom config object.
The list of objects where the config object is a dedicated custom class (instead
of a runtime-registered class) is well known. These are the operations
registered inside gimp_operations_init().

The list inside gimp_gegl_procedure_execute_async() which the previous commit
was updating was not right: it was still missing "gimp:hue-saturation" and
"gimp:threshold" should not have been on the list (this was generating a
CRITICAL when trying to get the "config" property on this object).

Instead let's add some init/exit() functions in gimp-operation-config API to
distinguish the operations with custom config (registered during init) with all
the others. Then we add gimp_operation_config_is_custom() which can be used
everywhere where we want to verify if an operation is using a custom-made config
object or a generated class just mirroring the operation properties.

This way, we should not get out-of-sync anymore.
2024-01-23 15:39:09 +00:00
Øyvind Kolås 21411047ee app,pdb,plug-ins: %s/gegl_node_connect_to/gegl_node_connect/ 2023-06-13 19:58:42 +02:00
Michael Natterer 26dce72d2c Remove autotools 2023-05-27 00:03:52 +02:00
Jehan 7f29543895 app: fix global-buffer-overflow in "gimp:dissolve" implementation.
In case of negative y in the region to process, we were accessing invalid memory
(negative array index).

I hesitated between make so that a given ordinate always use the same index or
if we just want the start ordinate (whatever it is) to use index 0. The later
could have just been `(y - result->y) % RANDOM_TABLE_SIZE`.

I just decided to keep the existing logic (former case) though to be fair, not
sure it matters much.

(cherry picked from commit a86560bb57)
2023-02-16 20:31:41 +01:00
Jehan ca230cb770 meson: fix warnings of deprecated features.
Now that we bumped our meson requirement, meson is complaining about
several features now deprecated even in the minimum required meson
version:

s/meson.source_root/meson.project_source_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.

s/meson.build_root/meson.project_build_root/ to fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': meson.build_root. use meson.project_build_root() or meson.global_build_root() instead.

Fixing using path() on xdg_email and python ExternalProgram variables:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead

s/get_pkgconfig_variable *(\([^)]*\))/get_variable(pkgconfig: \1)/ to
fix:

> WARNING: Project targets '>=0.56.0' but uses feature deprecated since '0.56.0': dependency.get_pkgconfig_variable. use dependency.get_variable(pkgconfig : ...) instead
2022-08-31 01:29:37 +02:00
Jehan ccbf3c4bb0 app, libgimp*: add various stamp files to CLEANFILES.
Fixes:

> ERROR: files left in build directory after distclean:
2022-08-01 23:34:50 +02:00
Jehan 83e465ec16 app, libgimp*: updating autotools script in sync with meson.
Generated *enums.c now have an additional stamp no-op header include
(see last 2 commits). Sync this change into the autotools generation
scripts to prevent back and forth useless generation of these files each
time we switch from one build system to another.
2022-08-01 20:00:01 +02:00
Jehan 979acaaae2 app, libgimp*: commit the newly generated *enums.c files.
They are nearly the same as initially, except that now they include an
intermediate stamp header which will be generated by the build system.

The only 2 enums which don't need these includes (and are not versioned)
are libgimp/gimpenums.c and libgimpthumb/gimpthumb-enums.c.
2022-08-01 20:00:01 +02:00
Jehan 106f2a061d Issue #8145: meson: generation of '*-enums.c' files.
Our meson build system was not properly building the enums.c file,
because they are versionned.

I did a similar trick as what I did for the pdbgen, which is that I used
a wrapper script around the existing perl script, which sets proper
options and generate a stamp file in the end (which is considered by
meson as the actual custom target, not the C file since it is generated
in the source dir).

The most important part is that the stamp file is a generated header
source (not just a random text file) which is **included** by the
generated C file. This is what will force meson to regenerate the C file
if the header is updated, **then** build using this new version, not use
an outdated versionned version (which would make for hard to diagnose
bugs), through the indirection of the intermediate stamp header.

See #4201.
See also: https://github.com/mesonbuild/meson/issues/10196#issuecomment-1080742592
2022-08-01 19:59:53 +02:00
Massimo Valentini 3b2a8f79f0 Issue #5267: Cage transform tool causes artifacts.
I somewhat bisected GEGL commits between 0.4.20 and 0.4.24 and found
that the one that introduced the env var GEGL_OPERATION_INIT_OUTPUT is
the first showing the problem.

Reviewer (Jehan) note: so it would be commit 6e9610e65c on GEGL repo.
This fix makes sense as it means that since this commit, the output
buffer could have random values. It's not a problem for any operation
where we fill every value, but I guess it's not the case for
"gimp:cage-coef-calc" which was likely relying on the old behavior of
being 0-initialized.
2021-08-05 16:58:55 +02:00
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 75e6f1062e app: fix "Luma Lighten/Darken only" layer modes.
This is a continuation of #5888 as I realized that most layer modes were
fixed with my commit b3fc24268a (and follow-up f40dc40cbc) but at least
2 were still crashing GIMP: "Luma Lighten/Darken only" modes.

There were 2 bugs here:

* The first bug was that when gimp_operation_layer_mode_real_process()
  ran, gimp_operation_layer_mode_prepare() had not been run yet.
  prepare() is called before the process() of GeglOperation, but it
  would seem the process() of GimpOperationLayerMode on the other end
  happens before GeglOperation's prepare() is run. I am absolutely
  unsure if this is expected or not and have a hard time figuring out
  all the details of the C/C++ cohabitation.
  As a solution, I am moving out the fish caching (the needed part
  inside gimp_operation_layer_mode_real_process()) in its own function
  so that I can easily call it separately before inspecting the fishes.

* The second issue was that some blend functions needed more than a
  GeglOperation alone. E.g. blend_function() for luma lighten
  gimp_operation_layer_mode_blend_luma_lighten_only() would call
  gegl_operation_get_source_space() which requires the node to exist.
  Similarly for the Luma darken only mode. So I keep both the node and
  operation around, and when finalizing, I free the node (which in turn
  frees the operation).

Ell > if you are reading our commits, I would really appreciate your
review (or fixes) of my code here! :)
2020-11-10 17:25:34 +01: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
Ell 59f3b07c5f app: remove ANTI_ERASE from filter mode set
It used to be included in "Edit -> Fade", but it's too low-level.
2020-05-08 14:42:22 +03:00
Ell 987447f18f app: maintain common settings when editing Brightness-Contrast/Levels as Levels/Curves
When converting Brightness-Contrast to Levels, and Levels to
Curves, make sure to copy the common settings as well as the
operation-specific settings.
2020-04-14 18:03:05 +03:00
Ell 0096e563f6 app: apply "trc" setting when repeating curves and levels
In gimp_operation_config_sync_node(), when the operation has a
property of the config object's type, don't skip the other
properties.  This makes sure to set the "trc" property of
GimpOperation{Curves,Levels} according to the config object.  We'd
previously done it manually in GimpFilterTool, but the setting was
not applied when repeating the filter.
2020-04-13 02:03:40 +03:00
Ell 38059dc5fd app: rename "Fade" section of GimpFilterTool to "Blending Options"
... and GIMP_LAYER_MODE_CONTEXT_FADE to
GIMP_LAYER_MODE_CONTEXT_FILTER.
2020-04-08 15:59:33 +03:00
Ell d25cddae8c app: add gimpoperationsettings.c to meson.build 2020-04-07 20:11:53 +03:00
Ell 8384d37e66 app: add "Fade" options to filter tools
As per commit ed7ea51fb7, reintroduce
the "Fade" functionality for filters, by incorporating it directly
into GimpFilterTool.

Add "mode" and "opacity" options to GimpOperationSettings, and add
a corresponding "Fade" expander to the GimpFilterTool dialog
allowing to control them.

Reintroduce the FADE layer-mode context, and use it to mark the
layer modes avaialable for fading.
2020-04-07 19:40:05 +03:00
Ell a1ff1601ee app: add GimpOperationSettings
Add a new GimpOperationSettings class, to be used as a base class
for all operation-config types.  The class provides options common
to all operations (namely, the clipping mode, input region, and
color options), which were previously stored in GimpFilterOptions,
and were therefore bound to the filter tool, instead of being
stored as part of the operation settings; as a result, these
options would have no effect when reapplying a filter, or when
restoring a preset.

The GimpOperationSettings options do not affect the operation
node, but rather the associated GimpDrawableFilter object.  The
class provides a gimp_operation_settings_sync_drawable_filter()
function, which applies the options to the filter.

Modify all custom and auto-generated operation-config types to
derive from GimpOperationSettings, and modify the GimpConfig
functions of the former to account for the GimpOperationSettings
properties, using a set of protected functions provided by the
class.
2020-04-07 19:26:28 +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 646c804c04 app: fix compositing of layers with masks, outside the mask bounds
In GimpOperationLayerMode, when the op has a mask connected, and
we're processing an area outside the mask bounds, set the op's
opacity to 0, so that the backdrop shows through.  The actual
process() function gets a NULL mask pointer in this case, and so
would composite the layer as if it had no mask, exposing areas that
should be masked out.

Add a GimpOperationLayerMode::parent_process() function, which
subclasses can override instead of GeglOperation::process(), and
make sure to update the GimpOperationLayerMode::opacity field
before calling this function (and, subsequently, before calling
GimpOperationLayerMode::process()).

Clean up the rest of the fields, and adjust the rest of the code.
2020-02-21 22:54:16 +02:00
Ell 2eaaa950a5 app: in gimp:replace, add fast path when compositing a layer over itself
In gimp:replace, when compositing the same content over itself,
i.e., when the input and aux buffers share the same storage and
same tile alignment, pass the input buffer directly as output,
instead of doing actual processing.

In particular, this happens when processing a pass-through group
outside of its actual bounds.
2020-02-20 13:03:10 +02:00
Ell bb8ee0e686 app: handle GimpTileHandlerValidate::invalidated in gimp:buffer-source-validate
In gimp:buffer-source-validate, invalidate the node in response to
GimpTileHandlerValidate::invalidated, added in the previous commit,
in addition to GeglBuffer::changed.
2020-01-15 21:50:11 +02:00
Ell fc17f0ed0c app: streamline GimpHistogram; avoid spurious channel switch in histogram view
In GimpHistogram, get rid of the "n-channels" property and
corresponding gimp_histogram_n_channels() function.  The former
returned the actual number of channels, but this wasn't too useful,
as channel values may not be sequential; the latter returned the
number of components.  Instead, add an "n-components" property and
a corresponding gimp_histogram_n_components() function, both of
which return the number of components.  Furthermore, add a
gimp_histogram_has_channel() function, which determines if the
histogram has a given channel; this allows for simple testing for
channel availability, which was done wrong in various places.

Adjust the GimpHistogram code for the changes, and clean it up,
fixing a few bugs.

Adjust users of GimpHisotgram for the changes.  In particular,
in GimpHisotgramView, fix the channel-availability test when
setting the view's histogram (which happens whenever the active
drawable's preview is frozen), to avoid erroneously swithcing the
view's channel back to "Value" when a non-RGB channel is selected.
2019-10-22 15:50:13 +03: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 04280690b2 app: fix offset handling in spiral gradients
In gimp:gradient, properly scale the "offset" property in spiral
graidnets.
2019-09-27 16:07:21 +03:00
Ell 6bd5deea89 app: add offset support to shaped gradients
In gimp:gradient, handle the "offset" property in shaped gradients.
2019-09-22 21:59:07 +03:00
Michael Natterer dbd793d631 libgimpconfig: get rid of filenames in all config related APIs
and rename function names which say "gfile" to just "file".
2019-09-21 12:55:12 +02:00
Michael Natterer 3598722020 libgimpconfig: add gimp_config_type_register()
which implements a generalized (not GEGL operation specific) version
of the dynamic config type creation code from gimp-operation-config.c.
2019-09-16 10:48:32 +02:00
Michael Natterer 8cdab31393 app, libgimpconfig: move gimp_param_spec_duplicate() to libgimpconfig 2019-09-14 17:35:32 +02:00
Michael Natterer f73f813e1f app: gimp_param_spec_duplicate(): don't warn
about unsupported GParamSpecs, simply return NULL and move the warning
to the only caller instead.
2019-09-14 12:23:13 +02:00
Félix Piédallu 65eff6f150 Meson port. 2019-09-11 16:42:04 +02:00
Massimo Valentini 44cc7d239e Issue 3100: cage transform tool -> always blurred without any action
Makes sure the tool doesn't offset everything by 0.5 pixels.
2019-09-07 01:23:54 +02:00
Elle Stone 7880711fef Allow full range to Hue-Saturation Lightness slider
Issue #427: Hue-saturation dialog: lightness in 'Master'

For whatever reason that made sense at the time, the current
Hue-Saturation code divides the result of Lightness slider
adjustments by 2, which means the user can't ever move the
Lightness slider to produce a solid white or black image, and
requires multiple iterations if the user wants to make the image
very light or very dark.

This patch just removes the division by 2, thus allowing the full
range of Lightness changes without having to use multiple
iterations.
2019-09-06 10:31:54 +02:00