Adds a simulation_bpc and simulation_intent to GimpImage to allow
plug-ins to access it
for CMYK import/export.
Four pdb functions were added to enable this access:
image_get_simulation_bpc (), image_set_simulation_bpc (),
image_get_simulation_intent (), and image_set_simulation_intent ().
Next, it updates menu options and code to support GimpImage's
internal simulation intent and bpc.
New 'simulation-intent-changed' and 'simulation-bpc-changed signal
are emitted via
GimpColorManagedInterface so that relevant tools
(such as the
CYMK color picker, GimpColorFrame, and future pop-overs)
are aware of these changes.
Adds a simulation_profile to GimpImage to allow plug-ins to access it
for CMYK import/export.
Two pdb functions were added to enable this access:
image_get_simulation_profile () and image_set_simulation_profile()
Next, it updates menu options and code to support GimpImage's
internal simulation profile. Menu items are moved from View to Image's
Color Management section.
New 'simulation-profile-changed' signal is emitted via
GimpColorManagedInterface so that relevant tools (such as the
CYMK color picker, GimpColorFrame, and future dockable
dialogue) are aware of these changes.
GimpColorRenderingIntent and BablIccIntent are actually 1-on-1
equivalent (for the common base values), but it's better anyway to call
with the right type. Also fixes this warning:
> libgimpcolor/gimpcolortransform.c:215:53: warning: implicit conversion
> from 'enum <anonymous>' to 'GimpColorRenderingIntent'
> [-Wenum-conversion]
This functions has 2 `(out) (array)` arguments, where the array length
is defined by the return value. This can't be expressed in GIR
annotations unfortunately, so just add it as another `(out)` argument.
Also, by default `(out)` args are assumed to be `(transfer full)`, while
these were actually `(transfer container)`.
We sometimes can get a lot of informational messages like:
gimp_color_transform_new: using babl for 'sRGB IEC61966-2.1' ->
'GIMP built-in sRGB'.
After discussion on IRC there is agreement to use g_debug for these instead
of g_printerr.
This way they can still be seen with GIMP_DEBUG=LibGimpColor, but won't
clutter the console when looking at something else.
Note that this only changes the informational message. All the error
messages are left alone as g_printerr.
Since it appeared with GLib 2.68.0, we could not change this until we
bumped the dependency which has only become possible a few days ago
(since Debian testing is our baseline for dependency bumps). Cf.
previous commit.
As this is a drop-in replacement (just a guint parameter changed to
gsize to avoid integer overflow), search-and-replace with:
> sed -i 's/g_memdup\>/g_memdup2/g' `grep -rIl 'g_memdup\>' *`
… followed by a few manual alignment tweaks when necessary.
This gets rid of the many deprecation warnings which we had lately when
building with a recent GLib version.
* Don't generate our own marshallers if they are available in GLib
already
* Don't set the c_marshaller parameter in `g_signal_new()` if it's a
default marshaller provided by GLib. See commit message of commit
39e4aa3c57 on why this is the case.
and proper callback annotations. Also move the three callback typedefs
from gimpcolortypes.h to gimpadaptivesupersample.h because they are
needed nowhere else.
libgimp is anyway processed at the very end after all other libgimp*
were built. This way, it also fixes#3746, by removing the $(top_srcdir)
everywhere from introspected files, hence making the build work again
with older automake.
Basically this commit makes sure that all return values that are marked
as "Returns:" also have a `(nullable)` annotation if it is mentioned on
the same line that NULL can also be returned.
This will prevent a few problems in GObject-introspection.
Only libgimpwidgets is not introspected yet as it didn't work from
scratch and I don't have the time right now to look into it. Anyway with
all the others, we already have so many warnings during the GObject
Introspection step now that we have a lot of work to do already!
...when generating "TRC variants"
When creating a new profile with different TRC from an existing
profile, keep all the original profile's description, model,
manufacturer and copyright strings around, but prefix them with "GIMP
from " or similar to indicate that they are different. Also make sure
we don't prefix strings with GIMP stuff multiple times when profiles
are generated repeatedly.
Don't just pass the input format's encoding because that loses the
palette. Instead, pass the input format directly so
babl_format_with_space() can do its job of preserving the palette.
... 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.
Avoid gegl_buffer_set_format() and simply construct the formats
differently to make sure reading/writing doesn't do any color space
transform. This makes it possible again to run it on different areas
of the same buffer from different threads.
Since the space invasion commit, colors entering and leaving a
GimpColorTransform were often implicitly converted up to three times,
the code was simply not properly ported to babl formats with spaces.
Fix GimpColorTransform to only ever transform colors between the
specified src and dest profiles, ignoring the space of any babl
formats involved.
Also, always return a non-NULL transform, even if the transform could
be done by a simply gegl_buffer_copy(), this way we can make sure in
one central place that transforms are done correctly, no matter if
babl or lcms is used.
Added quite some docs and comments to make clear what happens.
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.
In gimp_color_profile_new_from_icc_profile() and
gimp_image_validate_icc_profile(), don't raise a critical when
encountering an empty profile, but rather reject it gracefully with
an error.
... instead of calling g_type_register_static() ourselves.
Keep the old foo_interface_get_type() (replaced with
foo_get_type()) around as deprecated functions, to maintain ABI
compatibility. They will be removed in a separate commit in
master, so that this commit can be easily cherry-picked to
gimp-2-10.
even if we don't have private members (yet). Also make class padding 8
pointers in all headers. This commit moves nothing to private, it just
makes all headers consistent and adjusts .c files accordigly.
Added in commit 415f869f20 to drop a
workaround from commit bac042db39.
This line was not a part of the workaround and looks completely
unrelated. I assume that's just a commit mistake. :-)
and use babl to convert between profiles if possible. With the default
BABL_TOLERANCE this is about 5 times faster than lcms on my test image.
Using babl can be disabled by setting GIMP_COLOR_TRANSFORM_DISABLE_BABL.
which takes a GimpColorProfile and a Babl format, and returns a new
format which uses the profile's RGB primaries and TRC, and the
original format's pixel layout; or NULL if babl couldn't create a
space from the profile's ICC data.
Use cmsFLAGS_NOOPTIMIZE only for actual image buffer or single color
transforms, but not for previews or the image display. Makes things a
lot more responsive again.
It doesn't really "fail", we check if an error was logged during
transform creation and get rid of the transform even if lcms returned
a pointer. This totally sucks but is better than crashing on a corrupt
transform.
Which takes two profiles and returns TRUE if converting between
them works correctly without a GimpColorTransform. Use it in
gimp_color_transform_new() to return a NULL transform if none
is needed. Took the code from gimp-gegl-loops.c.
which encapsulates a cmsHTRANSFORM and does all the pixel format
conversion magic. It has API to create transforms and proofing
transforms, and to convert pixels arrays and GeglBuffers.
Before, each place which has a transform had to keep around the
transform and its input and output Babl formats, and had to implement
lots of stuff itself. Now all that lives in GimpColorTransform,
removing lots of logic from many places, and pretty much removing lcms
from the public API entirely.
This removes including <lcms2.h>, LCMS_LIBS and LCMS_CFLAGS from
almost all directories and potentially allows to replace lcms by
something else.
Trick lcms into converting cairo-RGB24 pixels directly, by using
TYPE_BGRA_8 on little endian and TYPE_ARGB_8 on big endian. They have
the same byte order, and the alpha channel (ignored by lcms anyway)
takes the place of the unused byte of cairo-RGB24.
This saves two babl conversions around cmsDoTransform().
Return "R'G'B'[A] u8" and "TYPE_RGB[A]_8" and babl and lcms formats.
I'm not sure which code triggered the warning about an unhandled
format, but now it handles indexed images too.
Rename profile constructors to say "d65_gray" instead of just "gray",
"srgb_trc" instead of "srgb_gamma", and drop the "srgb" from
"srgb_linear" because we now say "d65". This should be a naming scheme
that doesn't conflict with whatever future functions we might add.