libgimpcolor, *: change GimpColorProfile to be a GObject

it used to be a typedef to gpointer and actually was a cmsHPROFILE.

Change its API to be more "standard", remove the public close()
function. The object caches both the cmsHPROFILE and the data/length
ICC blob, so conversions between the two become obsolete (simply call
get_lcms_profile() or get_icc_profile()).

Adapt everything to the new API, but port it in a naive way for now,
the code doesn't take advantage of the new possibilities yet (like
refcounting).
This commit is contained in:
Michael Natterer
2015-07-10 22:43:53 +02:00
parent 763e459a92
commit c102dde92b
33 changed files with 730 additions and 512 deletions

View File

@ -352,10 +352,10 @@ gimp_get_monitor_at_pointer (GdkScreen **screen)
return gdk_screen_get_monitor_at_point (*screen, x, y);
}
GimpColorProfile
GimpColorProfile *
gimp_widget_get_color_profile (GtkWidget *widget)
{
GimpColorProfile profile = NULL;
GimpColorProfile *profile = NULL;
GdkScreen *screen;
gint monitor;
@ -391,7 +391,8 @@ gimp_widget_get_color_profile (GtkWidget *widget)
0, 64 * 1024 * 1024, FALSE,
&type, &format, &nitems, &data) && nitems > 0)
{
profile = gimp_color_profile_open_from_data (data, nitems, NULL);
profile = gimp_color_profile_new_from_icc_profile (data, nitems,
NULL);
g_free (data);
}
@ -421,9 +422,9 @@ gimp_widget_get_color_profile (GtkWidget *widget)
CFDataGetBytes (data, CFRangeMake (0, CFDataGetLength (data)),
buffer);
profile = gimp_color_profile_open_from_data (data,
CFDataGetLength (data),
NULL);
profile = gimp_color_profile_new_from_icc_profile (data,
CFDataGetLength (data),
NULL);
g_free (buffer);
CFRelease (data);
@ -446,7 +447,7 @@ gimp_widget_get_color_profile (GtkWidget *widget)
{
GFile *file = g_file_new_for_path (path);
profile = gimp_color_profile_open_from_file (file, NULL);
profile = gimp_color_profile_new_from_file (file, NULL);
g_object_unref (file);
}
@ -459,11 +460,11 @@ gimp_widget_get_color_profile (GtkWidget *widget)
return profile;
}
static GimpColorProfile
static GimpColorProfile *
get_display_profile (GtkWidget *widget,
GimpColorConfig *config)
{
GimpColorProfile profile = NULL;
GimpColorProfile *profile = NULL;
if (config->display_profile_from_gdk)
profile = gimp_widget_get_color_profile (widget);
@ -484,13 +485,15 @@ gimp_widget_get_color_transform (GtkWidget *widget,
const Babl **src_format,
const Babl **dest_format)
{
GimpColorTransform transform = NULL;
GimpColorProfile src_profile = NULL;
GimpColorProfile dest_profile = NULL;
GimpColorProfile proof_profile = NULL;
cmsUInt32Number lcms_src_format;
cmsUInt32Number lcms_dest_format;
cmsUInt16Number alarmCodes[cmsMAXCHANNELS] = { 0, };
GimpColorTransform transform = NULL;
GimpColorProfile *src_profile = NULL;
GimpColorProfile *dest_profile = NULL;
GimpColorProfile *proof_profile = NULL;
cmsHPROFILE src_lcms;
cmsHPROFILE dest_lcms;
cmsUInt32Number lcms_src_format;
cmsUInt32Number lcms_dest_format;
cmsUInt16Number alarmCodes[cmsMAXCHANNELS] = { 0, };
g_return_val_if_fail (widget == NULL || GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (GIMP_IS_COLOR_MANAGED (managed), NULL);
@ -513,13 +516,19 @@ gimp_widget_get_color_transform (GtkWidget *widget,
break;
}
src_lcms = gimp_color_profile_get_lcms_profile (src_profile);
dest_lcms = gimp_color_profile_get_lcms_profile (dest_profile);
*src_format = gimp_color_profile_get_format (*src_format, &lcms_src_format);
*dest_format = gimp_color_profile_get_format (*dest_format, &lcms_dest_format);
if (proof_profile)
{
cmsHPROFILE proof_lcms;
cmsUInt32Number softproof_flags = cmsFLAGS_SOFTPROOFING;
proof_lcms = gimp_color_profile_get_lcms_profile (proof_profile);
if (config->simulation_use_black_point_compensation)
{
softproof_flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
@ -540,14 +549,14 @@ gimp_widget_get_color_transform (GtkWidget *widget,
cmsSetAlarmCodes (alarmCodes);
}
transform = cmsCreateProofingTransform (src_profile, lcms_src_format,
dest_profile, lcms_dest_format,
proof_profile,
transform = cmsCreateProofingTransform (src_lcms, lcms_src_format,
dest_lcms, lcms_dest_format,
proof_lcms,
config->simulation_intent,
config->display_intent,
softproof_flags);
gimp_color_profile_close (proof_profile);
g_object_unref (proof_profile);
}
else if (! gimp_color_profile_is_equal (src_profile, dest_profile))
{
@ -558,14 +567,14 @@ gimp_widget_get_color_transform (GtkWidget *widget,
display_flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
}
transform = cmsCreateTransform (src_profile, lcms_src_format,
dest_profile, lcms_dest_format,
transform = cmsCreateTransform (src_lcms, lcms_src_format,
dest_lcms, lcms_dest_format,
config->display_intent,
display_flags);
}
gimp_color_profile_close (src_profile);
gimp_color_profile_close (dest_profile);
g_object_unref (src_profile);
g_object_unref (dest_profile);
return transform;
}