Commit Graph

51520 Commits

Author SHA1 Message Date
Jehan 89b80b5b63 libgimpwidgets: don't unnecessarily redraw color previews.
When changing the selected color, we have no reason to redraw the Z preview.
This preview should only be redrawn if the allocation size changed, or if we
change the previewed model or the Z component.

As for the XY preview, it should only be redrawn if the Z value is changed (and
of course, similarly, if the allocation changed or if model or Z component
changed).
2024-02-11 23:28:04 +01:00
Jehan 3a787e8892 app: fix test-config.
Fixes broken unit test:

> stderr:
> ../babl/babl-internal.h:223 babl_fatal()
	babl_format("RGBA float"): you must call babl_init first
2024-02-11 23:28:04 +01:00
Jehan e6e7fa8f8d libgimpcolor: work around babl_format_has_alpha() bug with some formats.
With "HSVA" and a few others, the function was not returning the right value (it
could not see it was encoding alpha channel.

I had fixed it on babl directly with commit a28309c yet I had forgotten to push
it! Let's just add some #ifdef and a comment.
2024-02-11 23:28:04 +01:00
Jehan f8ddc94a8b build: fix splash2installer.py with updated API using GeglColor instead of GimpRGB.
Fixes:

> TypeError: argument background: Expected Gegl.Color, but got gi.repository.Gimp.RGB
2024-02-11 23:28:04 +01:00
Jehan 65f8afee68 app, libgimp, libgimpbase, pdb: GimpColorArray as a typedef to…
… NULL-terminated array of GeglColor is now a boxed type usable in PDB.
2024-02-11 23:28:04 +01:00
Jehan cfd0389c37 app: no more GimpRGB in GimpDashboard and related. 2024-02-11 23:28:04 +01:00
Jehan 6a2aee1fce libgimpwidgets: render GimpColorSelect with babl conversion.
No custom conversion code anymore. This also fixes some bugs in HSV when
I was wrongfully multiplying the hue by 360 when mixing babl and custom
code paths.
2024-02-11 23:28:04 +01:00
Jehan 47c1cb8504 app: use GeglColor in GimpTextBuffer and GimpTextTag.
It's actually not enough to get proper colors for inner text tags. The
main color is correct, but color for subtext is currently not managed.
This must be fixed.
2024-02-11 23:28:04 +01:00
Jehan cbd970a92d app: add memory size for GeglColor. 2024-02-11 23:28:04 +01:00
Jehan bab9ed18c4 app: color drag'n drop is now space-invaded.
We can now drop any color model and encoding with any space. The exact
color information is passed with.
2024-02-11 23:28:04 +01:00
Jehan ba26fc26e7 libgimpwidgets: direct binding between a GimpLabelColor and its color area. 2024-02-11 23:28:04 +01:00
Jehan c13683a710 app: revert fg and bg colors stored as GeglColor-s. 2024-02-11 23:28:04 +01:00
Jehan caaee9a174 app: test should have used GeglColor already. 2024-02-11 23:28:04 +01:00
Jehan 4960ed72c1 app: GimpFgBgEditor draw() method to use GeglColor directly too. 2024-02-11 23:28:04 +01:00
Jehan 02546da780 app: layer layer modes to use babl conversions directly. 2024-02-11 23:28:04 +01:00
Jehan 95ac889f6c app, pdb: this PDB function should have been using GeglColor already. 2024-02-11 23:28:04 +01:00
Jehan 57fda090df app: GimpFgBgView draw() methods uses GeglColor directly. 2024-02-11 23:28:04 +01:00
Jehan 6f408e9d48 app: GimpMenuModel uses GeglColor. 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 0239d05409 app: gimp_pickable_contiguous_region_by_line_art() now uses GeglColor. 2024-02-11 23:28:04 +01:00
Jehan 3ec13730c5 app: gimp_layer_mask_new() uses GeglColor. 2024-02-11 23:28:04 +01:00
Jehan cf213d1051 app: some GimpAction color which was forgotten after the port. 2024-02-11 23:28:03 +01:00
Jehan 46121685b8 app: get rid of rgb_to_pixel() GimpPickable method and related functions.
We don't try anymore to convert early from a pickable color to another
format/space. Now we are able to get a GeglColor and move it around,
doing only last-second (when needed) conversions.
2024-02-11 23:28:03 +01:00
Jehan d55325829f app: no more GimpRGB/GimpHSL/GimpHSV usage in paint code at all anymore.
I'm a bit unsure about the GimpMyBrushCore which doesn't have much
indication on which color space we are working in, but the new code
should not be worse than the old one (if wrong, color-wise, it should be
the same wrong as before).
2024-02-11 23:28:03 +01:00
Jehan fcfb574715 app: get_paint_params() now uses GeglColor. 2024-02-11 23:28:03 +01:00
Jehan c892de85df app: port some of the paint and fill code to GeglColor. 2024-02-11 23:28:03 +01:00
Jehan ae31cf0b18 app: GimpCurveView using GeglColor. 2024-02-11 23:28:03 +01:00
Jehan 20b9f9bc06 app: GimpColorBar to use GeglColor.
It's still internally loading data as a sRGB buffer. More work will need
to be done.
2024-02-11 23:28:03 +01:00
Jehan d1c3b104bf libgimpcolor: gimp_color_is_perceptually_identical() also checks transparency.
When I implemented CIEDE2000 distance for verifying perceptual identity,
I mistakenly lost checking the alpha channel.
2024-02-11 23:28:03 +01:00
Jehan b53da69f3c app, libgimp, pdb, plug-ins: canvas grid now using GeglColor. 2024-02-11 23:28:03 +01:00
Jehan f9c97aeb72 app: mask colors are GeglColor. 2024-02-11 23:28:03 +01:00
Jehan 636a33aed2 app: GimpColorDialog now fully uses GeglColor. 2024-02-11 23:28:03 +01:00
Jehan 4b3702bfc1 libgimpwidgets, libgimpcolor: RGB and HSV should also show out-of-gamut…
… in soft-proof space when soft-proofing is enabled.
2024-02-11 23:28:03 +01:00
Jehan de83bca814 app, libgimpwidgets: make GimpColorSelector sync with soft-proofing.
Until now we only had the case of the CMYK color selector using the
soft-proofing profile. Yet this is also interesting for other color
selectors, in particular to show out-of-gamut colors. Indeed if we
enable soft-proofing on the active image, it is interesting to show the
intersection of the current RGB/Grayscale space gamut with the
soft-proofing gamut.

Right now, this is only used in GimpColorSelect when showing colors in
LCh color space.
2024-02-11 23:28:03 +01:00
Jehan 12b2abce7c libgimpcolor: implement CIEDE2000 distance algorithm to compare colors.
This is used for the gimp_color_is_perceptually_identical() function,
because the Euclidean distance in LCH is extremely limited, if not wrong
in many cases. Indeed LCH is not perfectly perceptually uniform, and for
this exact reason, the CIE defined the specific Delta E algorithms.
Later versions are also based on LCH values, so my intuition to use it
for distance was on a good start, yet these algorithms were refined a
few times to allow for corrections in perceptual uniformity
imperfections.

This was in particular needed to verify if a color is out of a CMYK
space gamut. The idea is to compare the distance of the RGB (or other)
and the CMYK version, since we cannot just check if the CMYK color is
out of the [0; 1] range (it never is). Instead if both colors are
perceptually identical, then we consider that the RGB color was inside
the CMYK space gamut.
The naive algorithm was giving any (or nearly) color as out-of-gamut.
Now using CIEDE2000, I get a much nicer results.
2024-02-11 23:28:03 +01:00
Jehan 4d2acac506 libgimpwidgets, modules: display the exact space/profile name for…
… relevant color selectors.
2024-02-11 23:28:03 +01:00
Jehan 3c3f3030f1 libgimpwidgets: GimpColorSelect is now also aware of active image space. 2024-02-11 23:28:03 +01:00
Jehan ebb93a07a5 modules: the color wheel selector now displays and select in the active…
… image's space!
2024-02-11 23:28:03 +01:00
Jehan 1066229ba6 modules: Watercolor selector now shows the actual target gamut. 2024-02-11 23:28:03 +01:00
Jehan 69b7cbe111 libgimpcolor: add support for "CIE LCH(ab)" to gimp_babl_format_get_with_alpha().
It seems I had forgotten about this one!
2024-02-11 23:28:03 +01:00
Jehan e104196cb7 app, libgimpwidgets: "Scales" color selection now space-aware.
This commit adds gimp_color_selector_set_format() which is meant to give
awareness of the target color format for which we are selecting colors.
Right now, I am only using this information on the Scales selection
method, which means that now colors you read and select are in the
target space. Even better, the out-of-gamut shown happens in the with
LCH scales is for the target space too. As tested, it already makes
quite a difference for an image in sRGB vs. say adobeRGB.

Note that right now, I only use the format information as a space, but
in fact, I made the API to be about a format because the actual format
can be used wisely too. First we may want to do different thing
depending on the color model itself (which the space may give away or
not, especially when using default spaces or when we'll have images
using models with no space in the future, such as CIE Lab). But also
whether the image is following the space TRC or is linear (or
perceptual) would change how we represent the data. If we were to show
non-linear values in the Colors dockable but when painting, the color
picker shows linear values for instance, it might be puzzling to people.
2024-02-11 23:28:03 +01:00
Jehan 881baba59b app: update the simulation profile in Colors dockable.
Only the color dialog was getting simulation updates when the active
image changed, or when the simulation profile changed (while the active
image stayed the same). Now the Colors dockable also get updates.
2024-02-11 23:28:03 +01:00
Jehan b7610b1db7 app: re-run gtk_event_box_set_above_child() when showing the event box.
Somehow, in some cases, the event box is not getting button events. I
had the case when creating new images (though it was working fine when
loading images!). I could not yet understand the issue looking at both
GIMP and GTK code and could not even reproduce by creating simple code
sample reproducing a similar pattern (an inactive button inside an event
box placed above the button and meant to catch click events).
This works as a workaround for the time being.
2024-02-11 23:28:03 +01:00
Jehan 9833ebd0ee app, libgimpwidgets, modules: color selectors are now partly space-invaded.
What this commit does is keep the same code logic while moving to
GeglColor. Yet it's not **really** space-invaded yet. What we need to do
now:

1. Take into account the image space, and this is what we must navigate
   through, in particular for various representations of RGB or HSV.
   I.e. that if the active image is in anyRGB, the RGB values shown must
   be within anyRGB. Right now, everything is still shown/used as sRGB
   (even though it's properly retrieved and transformed to the target
   space thanks to GeglColor).
2. Show space info to make things clear and explicit, by adding some
   label somewhere.
3. Allow to switch between image and softproof spaces, regarding
   out-of-gamut display. I.e. that while RGB/HSV must be shown within
   the image space (assuming it's anyRGB), we may want to show
   out-of-gamut area (pink areas) within the softproof space. This may
   mean adding a checkbox. Or maybe simply taking into account whether
   we are in softproof mode or not?
4. We can likely move off gimp_widget_get_color_transform() into using
   gimp_widget_get_render_space() for display drawing. We don't need any
   soft-proofing or black point compensation for any of these widgets so
   pure babl is fine. Indeed we want to show any in-gamut color
   correctly (and not transformed according to specific intents or
   through soft-proofing). We will take care of the proofing case with
   out-of-gamut area showing only.
5. In the various drawing functions, we should move to
   CAIRO_FORMAT_RGBA128F. The color selection area might be wide enough
   that it makes sense to be more accurate, especially as we are
   essentially showing color gradients in 1 or 2 directions in these
   various widgets.
2024-02-11 23:28:03 +01:00
Jehan 4d798ecfed libgimpcolor: improve warning to help with debugging. 2024-02-11 23:28:03 +01:00
Jehan ce887767e7 app, libgimpconfig: color history is now space-invaded.
I also changed a bit the new color serialization by adding a (color …)
symbol framing the contents, for cases where we don't have a specific
property name, e.g. for the color history list stored in colorrc, unlike
for GimpConfig GeglColor properties.

While doing this, I moved GeglColor property deserialization code into
gimp_scanner_parse_color() which is now able to recognize both older
(color-rgb|rgba|hsv|hsva with no color space) and newer serialization
formats ("color", color model agnostic and space aware).
2024-02-11 23:28:03 +01:00
Jehan 1a901e0bb9 libgimpcolor: get the proper alpha variant of a palette format. 2024-02-11 23:28:03 +01:00
Jehan 1be7892862 libgimpconfig: serialize indexed colors as RGB instead.
Serializing palette colors is not possible right now as far too much
additional data are required, and anyway we likely wouldn't be able to
associate back the color to the right palette on deserialization,
removing any interest of keeping the index data anyway.

With that context in mind, let's just serialize palette data as basic
RGB within the palette's space.
2024-02-11 23:28:03 +01:00
Jehan 91d3b51bf2 app: when creating a palette from an image, colors must be space-aware. 2024-02-11 23:28:03 +01:00
Jehan b6c1b20737 app: colors generated when converting to indexed must be within the image space.
Colors must not be clamped to sRGB, which could lose colors on wide
gamut indexed images.
2024-02-11 23:28:03 +01:00