Commit e09e563a authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent 5c94ebae
......@@ -244,19 +244,19 @@ static const GimpRadioActionEntry image_convert_precision_actions[] =
GIMP_COMPONENT_TYPE_DOUBLE, GIMP_HELP_IMAGE_CONVERT_DOUBLE }
};
static const GimpRadioActionEntry image_convert_gamma_actions[] =
static const GimpRadioActionEntry image_convert_trc_actions[] =
{
{ "image-convert-gamma", NULL,
NC_("image-convert-action", "Perceptual gamma (sRGB)"), NULL,
NC_("image-convert-action",
"Convert the image to perceptual (sRGB) gamma"),
FALSE, GIMP_HELP_IMAGE_CONVERT_GAMMA },
GIMP_TRC_NON_LINEAR, GIMP_HELP_IMAGE_CONVERT_GAMMA },
{ "image-convert-linear", NULL,
NC_("image-convert-action", "Linear light"), NULL,
NC_("image-convert-action",
"Convert the image to linear light"),
TRUE, GIMP_HELP_IMAGE_CONVERT_GAMMA }
GIMP_TRC_LINEAR, GIMP_HELP_IMAGE_CONVERT_GAMMA }
};
static const GimpEnumActionEntry image_flip_actions[] =
......@@ -320,10 +320,10 @@ image_actions_setup (GimpActionGroup *group)
G_CALLBACK (image_convert_precision_cmd_callback));
gimp_action_group_add_radio_actions (group, "image-convert-action",
image_convert_gamma_actions,
G_N_ELEMENTS (image_convert_gamma_actions),
image_convert_trc_actions,
G_N_ELEMENTS (image_convert_trc_actions),
NULL, 0,
G_CALLBACK (image_convert_gamma_cmd_callback));
G_CALLBACK (image_convert_trc_cmd_callback));
gimp_action_group_add_enum_actions (group, "image-action",
image_flip_actions,
......@@ -393,8 +393,9 @@ image_actions_update (GimpActionGroup *group,
gimp_action_group_set_action_active (group, action, TRUE);
if (gimp_babl_format_get_linear (gimp_image_get_layer_format (image,
FALSE)))
if (gimp_babl_format_get_trc (gimp_image_get_layer_format (image,
FALSE)) ==
GIMP_TRC_LINEAR)
{
gimp_action_group_set_action_active (group, "image-convert-linear",
TRUE);
......@@ -406,7 +407,7 @@ image_actions_update (GimpActionGroup *group,
}
is_indexed = (base_type == GIMP_INDEXED);
is_u8_gamma = (precision == GIMP_PRECISION_U8_GAMMA);
is_u8_gamma = (precision == GIMP_PRECISION_U8_NON_LINEAR);
is_double = (component_type == GIMP_COMPONENT_TYPE_DOUBLE);
aux = (gimp_image_get_active_channel (image) != NULL);
lp = ! gimp_image_is_empty (image);
......
......@@ -268,30 +268,28 @@ image_convert_base_type_cmd_callback (GtkAction *action,
GimpColorProfileCallback callback;
GimpColorProfile *current_profile;
GimpColorProfile *default_profile;
const Babl *format;
GimpTRCType trc;
current_profile =
gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
trc = gimp_babl_trc (gimp_image_get_precision (image));
if (value == GIMP_RGB)
{
dialog_type = COLOR_PROFILE_DIALOG_CONVERT_TO_RGB;
callback = image_convert_rgb_callback;
format = gimp_babl_format (GIMP_RGB,
gimp_image_get_precision (image),
TRUE);
default_profile = gimp_babl_format_get_color_profile (format);
default_profile = gimp_babl_get_builtin_color_profile (GIMP_RGB,
trc);
}
else
{
dialog_type = COLOR_PROFILE_DIALOG_CONVERT_TO_GRAY;
callback = image_convert_gray_callback;
format = gimp_babl_format (GIMP_GRAY,
gimp_image_get_precision (image),
TRUE);
default_profile = gimp_babl_format_get_color_profile (format);
default_profile = gimp_babl_get_builtin_color_profile (GIMP_GRAY,
trc);
}
dialog = color_profile_dialog_new (dialog_type,
......@@ -394,21 +392,21 @@ image_convert_precision_cmd_callback (GtkAction *action,
}
void
image_convert_gamma_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data)
image_convert_trc_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data)
{
GimpImage *image;
GimpDisplay *display;
gboolean value;
GimpTRCType value;
GimpPrecision precision;
return_if_no_image (image, data);
return_if_no_display (display, data);
value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
if (value == gimp_babl_format_get_linear (gimp_image_get_layer_format (image,
FALSE)))
if (value == gimp_babl_format_get_trc (gimp_image_get_layer_format (image,
FALSE)))
return;
precision = gimp_babl_precision (gimp_image_get_component_type (image),
......@@ -530,7 +528,7 @@ image_color_profile_discard_cmd_callback (GtkAction *action,
GimpImage *image;
return_if_no_image (image, data);
gimp_image_set_color_profile (image, NULL, NULL);
gimp_image_assign_color_profile (image, NULL, NULL, NULL);
gimp_image_flush (image);
}
......@@ -1191,7 +1189,7 @@ image_convert_precision_callback (GtkWidget *dialog,
/* random formats with the right precision */
old_format = gimp_image_get_layer_format (image, FALSE);
new_format = gimp_babl_format (GIMP_RGB, precision, FALSE);
new_format = gimp_babl_format (GIMP_RGB, precision, FALSE, NULL);
old_bits = (babl_format_get_bytes_per_pixel (old_format) * 8 /
babl_format_get_n_components (old_format));
......@@ -1242,11 +1240,7 @@ image_profile_assign_callback (GtkWidget *dialog,
{
GError *error = NULL;
gimp_image_undo_group_start (image,
GIMP_UNDO_GROUP_PARASITE_ATTACH,
_("Assign color profile"));
if (! gimp_image_set_color_profile (image, new_profile, &error))
if (! gimp_image_assign_color_profile (image, new_profile, NULL, &error))
{
gimp_message (image->gimp, G_OBJECT (dialog),
GIMP_MESSAGE_ERROR,
......@@ -1259,13 +1253,6 @@ image_profile_assign_callback (GtkWidget *dialog,
return;
}
gimp_image_set_is_color_managed (image, TRUE, TRUE);
/* omg... */
gimp_image_parasite_detach (image, "icc-profile-name");
gimp_image_undo_group_end (image);
gimp_image_flush (image);
gtk_widget_destroy (dialog);
......
......@@ -30,7 +30,7 @@ void image_convert_base_type_cmd_callback (GtkAction *action,
void image_convert_precision_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
void image_convert_gamma_cmd_callback (GtkAction *action,
void image_convert_trc_cmd_callback (GtkAction *action,
GtkAction *current,
gpointer data);
......
......@@ -923,6 +923,37 @@ gimp_thumbnail_size_get_type (void)
return type;
}
GType
gimp_trc_type_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_TRC_LINEAR, "GIMP_TRC_LINEAR", "linear" },
{ GIMP_TRC_NON_LINEAR, "GIMP_TRC_NON_LINEAR", "non-linear" },
{ GIMP_TRC_PERCEPTUAL, "GIMP_TRC_PERCEPTUAL", "perceptual" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_TRC_LINEAR, NC_("trc-type", "Linear"), NULL },
{ GIMP_TRC_NON_LINEAR, NC_("trc-type", "Non-Linear"), NULL },
{ GIMP_TRC_PERCEPTUAL, NC_("trc-type", "Perceptual"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("GimpTRCType", values);
gimp_type_set_translation_context (type, "trc-type");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_undo_event_get_type (void)
{
......
......@@ -407,6 +407,18 @@ typedef enum /*< pdb-skip >*/
} GimpThumbnailSize;
#define GIMP_TYPE_TRC_TYPE (gimp_trc_type_get_type ())
GType gimp_trc_type_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_TRC_LINEAR, /*< desc="Linear" >*/
GIMP_TRC_NON_LINEAR, /*< desc="Non-Linear" >*/
GIMP_TRC_PERCEPTUAL /*< desc="Perceptual" >*/
} GimpTRCType;
#define GIMP_TYPE_UNDO_EVENT (gimp_undo_event_get_type ())
GType gimp_undo_event_get_type (void) G_GNUC_CONST;
......
......@@ -139,6 +139,7 @@ gimp_buffer_get_memsize (GimpObject *object,
memsize += gimp_gegl_buffer_get_memsize (buffer->buffer);
memsize += gimp_g_object_get_memsize (G_OBJECT (buffer->color_profile));
memsize += gimp_g_object_get_memsize (G_OBJECT (buffer->format_profile));
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
......@@ -229,13 +230,16 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
GimpTempBuf *preview;
if (babl_format_is_palette (format))
format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8_GAMMA,
babl_format_has_alpha (format));
format = gimp_babl_format (GIMP_RGB,
GIMP_PRECISION_U8_NON_LINEAR,
babl_format_has_alpha (format),
babl_format_get_space (format));
else
format = gimp_babl_format (gimp_babl_format_get_base_type (format),
gimp_babl_precision (GIMP_COMPONENT_TYPE_U8,
gimp_babl_format_get_linear (format)),
babl_format_has_alpha (format));
gimp_babl_format_get_trc (format)),
babl_format_has_alpha (format),
babl_format_get_space (format));
preview = gimp_temp_buf_new (width, height, format);
......@@ -332,14 +336,17 @@ gimp_buffer_get_description (GimpViewable *viewable,
static const guint8 *
gimp_buffer_color_managed_get_icc_profile (GimpColorManaged *managed,
gsize *len)
gsize *len)
{
GimpBuffer *buffer = GIMP_BUFFER (managed);
if (buffer->color_profile)
return gimp_color_profile_get_icc_profile (buffer->color_profile, len);
return NULL;
/* creates buffer->format_profile */
gimp_color_managed_get_color_profile (managed);
return gimp_color_profile_get_icc_profile (buffer->format_profile, len);
}
static GimpColorProfile *
......@@ -350,7 +357,11 @@ gimp_buffer_color_managed_get_color_profile (GimpColorManaged *managed)
if (buffer->color_profile)
return buffer->color_profile;
return gimp_babl_format_get_color_profile (gimp_buffer_get_format (buffer));
if (! buffer->format_profile)
buffer->format_profile =
gimp_babl_format_get_color_profile (gimp_buffer_get_format (buffer));
return buffer->format_profile;
}
static void
......@@ -524,11 +535,10 @@ gimp_buffer_set_color_profile (GimpBuffer *buffer,
if (profile != buffer->color_profile)
{
g_clear_object (&buffer->color_profile);
if (profile)
buffer->color_profile = g_object_ref (profile);
g_set_object (&buffer->color_profile, profile);
}
g_clear_object (&buffer->format_profile);
}
GimpColorProfile *
......
......@@ -45,6 +45,7 @@ struct _GimpBuffer
GimpUnit unit;
GimpColorProfile *color_profile;
GimpColorProfile *format_profile;
};
struct _GimpBufferClass
......
......@@ -32,6 +32,7 @@
#include "paint/gimppaintcore-stroke.h"
#include "paint/gimppaintoptions.h"
#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-apply-operation.h"
#include "gegl/gimp-gegl-loops.h"
#include "gegl/gimp-gegl-mask.h"
......@@ -406,10 +407,11 @@ gimp_channel_get_node (GimpFilter *filter)
g_warn_if_fail (channel->color_node == NULL);
if (gimp_drawable_get_linear (drawable))
color_format = babl_format ("RGBA float");
else
color_format = babl_format ("R'G'B'A float");
color_format =
gimp_babl_format (GIMP_RGB,
gimp_babl_precision (GIMP_COMPONENT_TYPE_FLOAT,
gimp_drawable_get_trc (drawable)),
TRUE, NULL);
channel->color_node = gegl_node_new_child (node,
"operation", "gegl:color",
......@@ -1040,12 +1042,11 @@ gimp_channel_set_buffer (GimpDrawable *drawable,
if (gimp_filter_peek_node (GIMP_FILTER (channel)))
{
const Babl *color_format;
if (gimp_drawable_get_linear (drawable))
color_format = babl_format ("RGBA float");
else
color_format = babl_format ("R'G'B'A float");
const Babl *color_format =
gimp_babl_format (GIMP_RGB,
gimp_babl_precision (GIMP_COMPONENT_TYPE_FLOAT,
gimp_drawable_get_trc (drawable)),
TRUE, NULL);
gegl_node_set (channel->color_node,
"format", color_format,
......
......@@ -113,6 +113,8 @@ gimp_drawable_fill_buffer (GimpDrawable *drawable,
TRUE,
NULL);
g_object_unref (src_profile);
gegl_buffer_set_pattern (buffer, NULL, dest_buffer,
pattern_offset_x, pattern_offset_y);
......
......@@ -139,33 +139,30 @@ gimp_drawable_get_new_pixbuf (GimpViewable *viewable,
const Babl *
gimp_drawable_get_preview_format (GimpDrawable *drawable)
{
gboolean alpha;
gboolean linear;
const Babl *space;
gboolean alpha;
GimpTRCType trc;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
alpha = gimp_drawable_has_alpha (drawable);
linear = gimp_drawable_get_linear (drawable);
space = gimp_drawable_get_space (drawable);
alpha = gimp_drawable_has_alpha (drawable);
trc = gimp_drawable_get_trc (drawable);
switch (gimp_drawable_get_base_type (drawable))
{
case GIMP_GRAY:
return gimp_babl_format (GIMP_GRAY,
gimp_babl_precision (GIMP_COMPONENT_TYPE_U8,
linear),
alpha);
trc),
alpha, space);
case GIMP_RGB:
case GIMP_INDEXED:
return gimp_babl_format (GIMP_RGB,
gimp_babl_precision (GIMP_COMPONENT_TYPE_U8,
linear),
alpha);
case GIMP_INDEXED:
if (alpha)
return babl_format ("R'G'B'A u8");
else
return babl_format ("R'G'B' u8");
trc),
alpha, space);
}
g_return_val_if_reached (NULL);
......
......@@ -20,25 +20,27 @@
struct _GimpDrawablePrivate
{
GeglBuffer *buffer; /* buffer for drawable data */
GeglBuffer *shadow; /* shadow buffer */
GeglBuffer *buffer; /* buffer for drawable data */
GeglBuffer *shadow; /* shadow buffer */
GeglNode *source_node;
GeglNode *buffer_source_node;
GimpContainer *filter_stack;
GeglNode *convert_format;
GimpColorProfile *format_profile;
GimpLayer *floating_selection;
GimpFilter *fs_filter;
GeglNode *fs_crop_node;
GimpApplicator *fs_applicator;
GeglNode *source_node;
GeglNode *buffer_source_node;
GimpContainer *filter_stack;
GeglNode *convert_format;
GeglNode *mode_node;
GimpLayer *floating_selection;
GimpFilter *fs_filter;
GeglNode *fs_crop_node;
GimpApplicator *fs_applicator;
gint paint_count;
GeglBuffer *paint_buffer;
cairo_region_t *paint_copy_region;
cairo_region_t *paint_update_region;
GeglNode *mode_node;
gint paint_count;
GeglBuffer *paint_buffer;
cairo_region_t *paint_copy_region;
cairo_region_t *paint_update_region;
};
#endif /* __GIMP_DRAWABLE_PRIVATE_H__ */
......@@ -331,6 +331,7 @@ gimp_drawable_finalize (GObject *object)
gimp_drawable_end_paint (drawable);
g_clear_object (&drawable->private->buffer);
g_clear_object (&drawable->private->format_profile);
gimp_drawable_free_shadow_buffer (drawable);
......@@ -686,9 +687,14 @@ gimp_drawable_get_icc_profile (GimpColorManaged *managed,
static GimpColorProfile *
gimp_drawable_get_color_profile (GimpColorManaged *managed)
{
const Babl *format = gimp_drawable_get_format (GIMP_DRAWABLE (managed));
GimpDrawable *drawable = GIMP_DRAWABLE (managed);
const Babl *format = gimp_drawable_get_format (drawable);
return gimp_babl_format_get_color_profile (format);
if (! drawable->private->format_profile)
drawable->private->format_profile =
gimp_babl_format_get_color_profile (format);
return drawable->private->format_profile;
}
static void
......@@ -746,14 +752,15 @@ gimp_drawable_real_estimate_memsize (GimpDrawable *drawable,
gint width,
gint height)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gboolean linear = gimp_drawable_get_linear (drawable);
const Babl *format;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpTRCType trc = gimp_drawable_get_trc (drawable);
const Babl *format;
format = gimp_image_get_format (image,
gimp_drawable_get_base_type (drawable),
gimp_babl_precision (component_type, linear),
gimp_drawable_has_alpha (drawable));
gimp_babl_precision (component_type, trc),
gimp_drawable_has_alpha (drawable),
NULL);
return (gint64) babl_format_get_bytes_per_pixel (format) * width * height;
}
......@@ -817,6 +824,7 @@ gimp_drawable_real_set_buffer (GimpDrawable *drawable,
old_has_alpha = gimp_drawable_has_alpha (drawable);
g_set_object (&drawable->private->buffer, buffer);
g_clear_object (&drawable->private->format_profile);
if (drawable->private->buffer_source_node)
gegl_node_set (drawable->private->buffer_source_node,
......@@ -1124,7 +1132,8 @@ gimp_drawable_convert_type (GimpDrawable *drawable,
new_format = gimp_image_get_format (dest_image,
new_base_type,
new_precision,
new_has_alpha);
new_has_alpha,
NULL /* handled by layer */);
old_bits = (babl_format_get_bytes_per_pixel (old_format) * 8 /
babl_format_get_n_components (old_format));
......@@ -1428,6 +1437,14 @@ gimp_drawable_push_undo (GimpDrawable *drawable,
x, y, width, height);
}
const Babl *
gimp_drawable_get_space (GimpDrawable *drawable)
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
return babl_format_get_space (gimp_drawable_get_format (drawable));
}
const Babl *
gimp_drawable_get_format (GimpDrawable *drawable)
{
......@@ -1444,7 +1461,8 @@ gimp_drawable_get_format_with_alpha (GimpDrawable *drawable)
return gimp_image_get_format (gimp_item_get_image (GIMP_ITEM (drawable)),
gimp_drawable_get_base_type (drawable),
gimp_drawable_get_precision (drawable),
TRUE);
TRUE,
gimp_drawable_get_space (drawable));
}
const Babl *
......@@ -1455,11 +1473,12 @@ gimp_drawable_get_format_without_alpha (GimpDrawable *drawable)
return gimp_image_get_format (gimp_item_get_image (GIMP_ITEM (drawable)),
gimp_drawable_get_base_type (drawable),
gimp_drawable_get_precision (drawable),
FALSE);
FALSE,
gimp_drawable_get_space (drawable));
}
gboolean
gimp_drawable_get_linear (GimpDrawable *drawable)
GimpTRCType
gimp_drawable_get_trc (GimpDrawable *drawable)
{
const Babl *format;
......@@ -1467,7 +1486,7 @@ gimp_drawable_get_linear (GimpDrawable *drawable)
format = gegl_buffer_get_format (drawable->private->buffer);
return gimp_babl_format_get_linear (format);
return gimp_babl_format_get_trc (format);
}
gboolean
......
......@@ -208,11 +208,12 @@ void gimp_drawable_push_undo (GimpDrawable *drawable,
gint width,
gint height);
const Babl * gimp_drawable_get_space (GimpDrawable *drawable);
const Babl * gimp_drawable_get_format (GimpDrawable *drawable);
const Babl * gimp_drawable_get_format_with_alpha(GimpDrawable *drawable);
const Babl * gimp_drawable_get_format_without_alpha
(GimpDrawable *drawable);
gboolean gimp_drawable_get_linear (GimpDrawable *drawable);
GimpTRCType gimp_drawable_get_trc (GimpDrawable *drawable);
gboolean gimp_drawable_has_alpha (GimpDrawable *drawable);
GimpImageBaseType gimp_drawable_get_base_type (GimpDrawable *drawable);
GimpComponentType gimp_drawable_get_component_type (GimpDrawable *drawable);
......
......@@ -713,8 +713,9 @@ gimp_drawable_filter_sync_transform (GimpDrawableFilter *filter)
drawable_format =
gimp_babl_format (gimp_babl_format_get_base_type (drawable_format),
gimp_babl_precision (GIMP_COMPONENT_TYPE_FLOAT,
gimp_babl_format_get_linear (drawable_format)),
babl_format_has_alpha (drawable_format));
gimp_babl_format_get_trc (drawable_format)),
babl_format_has_alpha (drawable_format),
babl_format_get_space (drawable_format));
/* convert the filter input/output formats to something we have
* built-in color profiles for (see the get_color_profile()
......@@ -764,8 +765,16 @@ gimp_drawable_filter_sync_transform (GimpDrawableFilter *filter)
"dest-format", drawable_format,
NULL);
if (filter->has_input)
g_object_unref (input_profile);
g_object_unref (output_profile);
return;
}
if (filter->has_input)
g_object_unref (input_profile);
g_object_unref (output_profile);
}
g_printerr ("using gegl copy\n");
......@@ -787,8 +796,16 @@ gimp_drawable_filter_sync_gamma_hack (GimpDrawableFilter *filter)
{
if (filter->gamma_hack)
{
const Babl *drawable_format;
const Babl *cast_format;
const Babl *drawable_format;
const Babl *cast_format;
GimpTRCType trc = GIMP_TRC_LINEAR;
switch (gimp_drawable_get_trc (filter->drawable))
{
case GIMP_TRC_LINEAR: trc = GIMP_TRC_NON_LINEAR; break;
case GIMP_TRC_NON_LINEAR: trc = GIMP_TRC_LINEAR; break;
case GIMP_TRC_PERCEPTUAL: trc = GIMP_TRC_LINEAR; break;
}
drawable_format =
gimp_drawable_get_format_with_alpha (filter->drawable);
......@@ -796,8 +813,9 @@ gimp_drawable_filter_sync_gamma_hack (GimpDrawableFilter *filter)
cast_format =
gimp_babl_format (gimp_babl_format_get_base_type (drawable_format),
gimp_babl_precision (gimp_babl_format_get_component_type (drawable_format),
! gimp_babl_format_get_linear (drawable_format)),
TRUE);
trc),
TRUE,
babl_format_get_space (drawable_format));
if (filter->has_input)
{
......
......@@ -947,10 +947,12 @@ get_projection_format (GimpProjectable *projectable,
{
case GIMP_RGB:
case GIMP_INDEXED:
return gimp_image_get_format (image, GIMP_RGB, precision, TRUE);
return gimp_image_get_format (image, GIMP_RGB, precision, TRUE,
gimp_image_get_layer_space (image));
case GIMP_GRAY:
return gimp_image_get_format (image, GIMP_GRAY, precision, TRUE);
return gimp_image_get_format (image, GIMP_GRAY, precision, TRUE,
gimp_image_get_layer_space (image));
}
g_return_val_if_reached (NULL);
......
......@@ -53,11 +53,11 @@ enum
struct _GimpHistogramPrivate
{
gboolean linear;
gint n_channels;
gint n_bins;
gdouble *values;
GimpAsync *calculate_async;
GimpTRCType trc;
gint n_channels;
gint n_bins;
gdouble *values;
GimpAsync *calculate_async;
};
typedef struct
......@@ -230,11 +230,11 @@ gimp_histogram_get_memsize (GimpObject *object,
/* public functions */
GimpHistogram *
gimp_histogram_new (gboolean linear)
gimp_histogram_new (GimpTRCType trc)
{
GimpHistogram *histogram = g_object_new (GIMP_TYPE_HISTOGRAM, NULL);
histogram->priv->linear = linear;
histogram->priv->trc = trc;
return histogram;
}
......@@ -258,7 +258,7 @@ gimp_histogram_duplicate (GimpHistogram *histogram)
if (histogram->priv->calculate_async)
gimp_waitable_wait (GIMP_WAITABLE (histogram->priv->calculate_async));
dup = gimp_histogram_new (histogram->priv->linear);