2010-02-03 20:31:25 +01:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (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-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2010-02-03 20:31:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GIMP_IMAGE_PRIVATE_H__
|
|
|
|
#define __GIMP_IMAGE_PRIVATE_H__
|
|
|
|
|
|
|
|
|
2010-02-05 09:13:25 +01:00
|
|
|
typedef struct _GimpImageFlushAccumulator GimpImageFlushAccumulator;
|
|
|
|
|
|
|
|
struct _GimpImageFlushAccumulator
|
|
|
|
{
|
|
|
|
gboolean alpha_changed;
|
|
|
|
gboolean mask_changed;
|
|
|
|
gboolean floating_selection_changed;
|
|
|
|
gboolean preview_invalidated;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-02-03 20:31:25 +01:00
|
|
|
struct _GimpImagePrivate
|
|
|
|
{
|
|
|
|
gint ID; /* provides a unique ID */
|
|
|
|
|
|
|
|
GimpPlugInProcedure *load_proc; /* procedure used for loading */
|
|
|
|
GimpPlugInProcedure *save_proc; /* last save procedure used */
|
2014-07-02 14:24:02 +02:00
|
|
|
GimpPlugInProcedure *export_proc; /* last export procedure used */
|
2010-02-03 20:31:25 +01:00
|
|
|
|
|
|
|
gchar *display_name; /* display basename */
|
2012-07-17 22:52:49 +02:00
|
|
|
gchar *display_path; /* display full path */
|
2010-02-03 20:31:25 +01:00
|
|
|
gint width; /* width in pixels */
|
|
|
|
gint height; /* height in pixels */
|
|
|
|
gdouble xresolution; /* image x-res, in dpi */
|
|
|
|
gdouble yresolution; /* image y-res, in dpi */
|
|
|
|
GimpUnit resolution_unit; /* resolution unit */
|
2019-10-12 16:38:05 +02:00
|
|
|
gboolean resolution_set; /* resolution explicitly set */
|
2010-02-03 20:31:25 +01:00
|
|
|
GimpImageBaseType base_type; /* base gimp_image type */
|
2012-04-22 17:07:35 +02:00
|
|
|
GimpPrecision precision; /* image's precision */
|
2017-08-21 20:04:25 +02:00
|
|
|
GimpLayerMode new_layer_mode; /* default mode of new layers */
|
2010-02-03 20:31:25 +01:00
|
|
|
|
2019-09-04 14:31:52 +03:00
|
|
|
gint show_all; /* render full image content */
|
|
|
|
GeglRectangle bounding_box; /* image content bounding box */
|
2019-09-28 11:34:44 +03:00
|
|
|
gint bounding_box_freeze_count;
|
|
|
|
gboolean bounding_box_update_pending;
|
2019-09-04 14:42:55 +03:00
|
|
|
GeglBuffer *pickable_buffer;
|
2019-09-04 14:31:52 +03:00
|
|
|
|
2010-10-27 15:40:43 +02:00
|
|
|
GimpPalette *palette; /* palette of colormap */
|
2012-03-18 16:48:42 +00:00
|
|
|
const Babl *babl_palette_rgb; /* palette's RGB Babl format */
|
|
|
|
const Babl *babl_palette_rgba; /* palette's RGBA Babl format */
|
2015-09-20 21:17:54 +02:00
|
|
|
|
2015-08-16 19:38:11 +02:00
|
|
|
GimpColorProfile *color_profile; /* image's color profile */
|
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 14:23:01 +02:00
|
|
|
const Babl *layer_space; /* image's Babl layer space */
|
2018-10-07 16:16:21 +02:00
|
|
|
GimpColorProfile *hidden_profile; /* hidden by "use sRGB" */
|
2022-08-10 15:01:15 +00:00
|
|
|
|
|
|
|
/* image's simulation/soft-proofing settings */
|
|
|
|
GimpColorProfile *simulation_profile;
|
|
|
|
GimpColorRenderingIntent simulation_intent;
|
|
|
|
gboolean simulation_bpc;
|
2016-04-15 16:49:36 +01:00
|
|
|
|
app: fix a crash when converting to higher precision.
gimp_display_shell_render() writes to a GeglBuffer backed by allocated memory
(shell->profile_data). Unfortunately while converting prevision in
gimp_image_convert_precision(), we change the "precision" property (hence the
source format) first, hence end up trying to write data in a too small buffer.
This crash was hard to find as it was not showing up on my machine (though it
did produce rendering artifacts!), unless I built both GIMP and babl with
`b_sanitize=address`.
Note that an alternate fix was to make sure that the profile_data buffer is big
enough (by calling gimp_display_shell_profile_update() before rendering), but
anyway the image is in an inconsistent state while conversion is in progress:
whereas the `src_format` is the new one, the `src_profile` is still the old one
(and cannot be changed before we finish converting).
Moreover the render happen regularly on progress signals, once after each
converted drawable. So each of these rendering step happens in an inconsistent
state, with the wrong profile set, some of the drawables converted and others
not yet.
We could still render properly if each drawable's buffer used space-aware format
(thus allowing different drawables to use different profiles/spaces), but it
feels over-engineering the problem. It might be much better to ignore rendering
steps while converting the image precision. Moreover it would obviously make a
faster conversion.
See discussions in #9136 for this crash, which didn't have dedicated report
AFAIK.
(cherry picked from commit de25be92104e6883cb35ea7bf0ea12408c8ca722)
Note: on the `master` branch, even with sanitized code, I don't get the crash.
Yet this change seems relevant enough that I'm adding it.
2023-02-19 13:54:03 +01:00
|
|
|
gboolean converting; /* color model or profile in middle of conversion? */
|
|
|
|
|
2016-04-15 16:49:36 +01:00
|
|
|
/* Cached color transforms: from layer to sRGB u8 and double, and back */
|
2016-07-25 00:04:12 +02:00
|
|
|
gboolean color_transforms_created;
|
2016-05-25 21:35:54 +02:00
|
|
|
GimpColorTransform *transform_to_srgb_u8;
|
|
|
|
GimpColorTransform *transform_from_srgb_u8;
|
|
|
|
GimpColorTransform *transform_to_srgb_double;
|
|
|
|
GimpColorTransform *transform_from_srgb_double;
|
2010-02-03 20:31:25 +01:00
|
|
|
|
2013-10-19 18:38:01 +02:00
|
|
|
GimpMetadata *metadata; /* image's metadata */
|
|
|
|
|
2014-07-08 00:03:08 +02:00
|
|
|
GFile *file; /* the image's XCF file */
|
|
|
|
GFile *imported_file; /* the image's source file */
|
|
|
|
GFile *exported_file; /* the image's export file */
|
|
|
|
GFile *save_a_copy_file; /* the image's save-a-copy file */
|
2014-07-08 00:15:41 +02:00
|
|
|
GFile *untitled_file; /* a file saying "Untitled" */
|
2014-07-07 00:46:25 +02:00
|
|
|
|
2017-03-23 18:03:27 +01:00
|
|
|
gboolean xcf_compression; /* XCF compression enabled? */
|
2014-10-04 02:26:36 +02:00
|
|
|
|
2010-02-03 20:31:25 +01:00
|
|
|
gint dirty; /* dirty flag -- # of ops */
|
2014-08-25 13:34:17 +05:30
|
|
|
gint64 dirty_time; /* time when image became dirty */
|
2010-02-03 20:31:25 +01:00
|
|
|
gint export_dirty; /* 'dirty' but for export */
|
|
|
|
|
|
|
|
gint undo_freeze_count; /* counts the _freeze's */
|
2010-02-03 21:20:29 +01:00
|
|
|
|
|
|
|
gint instance_count; /* number of instances */
|
|
|
|
gint disp_count; /* number of displays */
|
2010-02-03 21:31:27 +01:00
|
|
|
|
|
|
|
GimpTattoo tattoo_state; /* the last used tattoo */
|
2010-02-03 21:46:09 +01:00
|
|
|
|
|
|
|
GimpProjection *projection; /* projection layers & channels */
|
|
|
|
GeglNode *graph; /* GEGL projection graph */
|
2012-10-06 23:58:46 +02:00
|
|
|
GeglNode *visible_mask; /* component visibility node */
|
2010-02-03 22:16:02 +01:00
|
|
|
|
2016-01-27 19:13:17 +01:00
|
|
|
GList *symmetries; /* Painting symmetries */
|
2016-02-03 21:25:17 +01:00
|
|
|
GimpSymmetry *active_symmetry; /* Active symmetry */
|
2016-01-27 19:13:17 +01:00
|
|
|
|
2010-02-03 22:16:02 +01:00
|
|
|
GList *guides; /* guides */
|
|
|
|
GimpGrid *grid; /* grid */
|
|
|
|
GList *sample_points; /* color sample points */
|
2010-02-03 23:00:31 +01:00
|
|
|
|
|
|
|
/* Layer/Channel attributes */
|
2010-02-06 13:41:16 +01:00
|
|
|
GimpItemTree *layers; /* the tree of layers */
|
|
|
|
GimpItemTree *channels; /* the tree of masks */
|
|
|
|
GimpItemTree *vectors; /* the tree of vectors */
|
2010-02-03 23:00:31 +01:00
|
|
|
GSList *layer_stack; /* the layers in MRU order */
|
2021-12-16 00:35:20 +01:00
|
|
|
|
2022-03-01 16:09:47 +01:00
|
|
|
GList *hidden_items; /* internal process-only items */
|
|
|
|
|
2021-12-16 00:35:20 +01:00
|
|
|
GList *stored_layer_sets;
|
|
|
|
GList *stored_channel_sets;
|
|
|
|
GList *stored_vectors_sets;
|
2010-02-03 23:05:49 +01:00
|
|
|
|
2019-09-04 14:31:52 +03:00
|
|
|
GQuark layer_offset_x_handler;
|
|
|
|
GQuark layer_offset_y_handler;
|
|
|
|
GQuark layer_bounding_box_handler;
|
2010-02-03 23:05:49 +01:00
|
|
|
GQuark layer_alpha_handler;
|
|
|
|
GQuark channel_name_changed_handler;
|
|
|
|
GQuark channel_color_changed_handler;
|
2010-02-03 23:12:22 +01:00
|
|
|
|
2010-02-03 23:24:18 +01:00
|
|
|
GimpLayer *floating_sel; /* the FS layer */
|
|
|
|
GimpChannel *selection_mask; /* the selection mask channel */
|
2010-02-03 23:42:32 +01:00
|
|
|
|
|
|
|
GimpParasiteList *parasites; /* Plug-in parasite data */
|
2010-02-04 09:08:50 +01:00
|
|
|
|
|
|
|
gboolean visible[MAX_CHANNELS]; /* visible channels */
|
|
|
|
gboolean active[MAX_CHANNELS]; /* active channels */
|
2010-02-04 09:49:45 +01:00
|
|
|
|
|
|
|
gboolean quick_mask_state; /* TRUE if quick mask is on */
|
|
|
|
gboolean quick_mask_inverted; /* TRUE if quick mask is inverted */
|
|
|
|
GimpRGB quick_mask_color; /* rgba triplet of the color */
|
2010-02-04 20:06:49 +01:00
|
|
|
|
|
|
|
/* Undo apparatus */
|
|
|
|
GimpUndoStack *undo_stack; /* stack for undo operations */
|
|
|
|
GimpUndoStack *redo_stack; /* stack for redo operations */
|
|
|
|
gint group_count; /* nested undo groups */
|
|
|
|
GimpUndoType pushing_undo_group; /* undo group status flag */
|
2010-02-04 21:09:19 +01:00
|
|
|
|
2013-01-27 17:52:38 +02:00
|
|
|
/* Signal emission accumulator */
|
2010-02-05 09:13:25 +01:00
|
|
|
GimpImageFlushAccumulator flush_accum;
|
2010-02-03 20:31:25 +01: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-18 12:09:39 -04:00
|
|
|
#define GIMP_IMAGE_GET_PRIVATE(image) (((GimpImage *) (image))->priv)
|
2010-02-03 20:31:25 +01:00
|
|
|
|
2012-05-14 01:44:41 +02:00
|
|
|
void gimp_image_take_mask (GimpImage *image,
|
|
|
|
GimpChannel *mask);
|
|
|
|
|
2010-02-03 20:31:25 +01:00
|
|
|
|
|
|
|
#endif /* __GIMP_IMAGE_PRIVATE_H__ */
|