libgimpwidgets: simplify gimp_widget_get_color_transform()

Make sure src_profile and dest_profile always exist. Also optimize
things by not returning a transform if the profiles are equal.
This commit is contained in:
Michael Natterer 2015-05-30 01:07:34 +02:00
parent 9096ceffde
commit 263fabbb9b
1 changed files with 6 additions and 18 deletions

View File

@ -471,6 +471,9 @@ get_display_profile (GtkWidget *widget,
if (! profile)
profile = gimp_color_config_get_display_profile (config, NULL);
if (! profile)
profile = gimp_lcms_create_srgb_profile ();
return profile;
}
@ -517,12 +520,6 @@ gimp_widget_get_color_transform (GtkWidget *widget,
{
cmsUInt32Number softproof_flags = 0;
if (! src_profile)
src_profile = gimp_lcms_create_srgb_profile ();
if (! dest_profile)
dest_profile = gimp_lcms_create_srgb_profile ();
softproof_flags |= cmsFLAGS_SOFTPROOFING;
if (config->simulation_use_black_point_compensation)
@ -555,16 +552,10 @@ gimp_widget_get_color_transform (GtkWidget *widget,
gimp_lcms_profile_close (proof_profile);
}
else if (src_profile || dest_profile)
else if (! gimp_lcms_profile_is_equal (src_profile, dest_profile))
{
cmsUInt32Number display_flags = 0;
if (! src_profile)
src_profile = gimp_lcms_create_srgb_profile ();
if (! dest_profile)
dest_profile = gimp_lcms_create_srgb_profile ();
if (config->display_use_black_point_compensation)
{
display_flags |= cmsFLAGS_BLACKPOINTCOMPENSATION;
@ -577,11 +568,8 @@ gimp_widget_get_color_transform (GtkWidget *widget,
display_flags);
}
if (src_profile)
gimp_lcms_profile_close (src_profile);
if (dest_profile)
gimp_lcms_profile_close (dest_profile);
gimp_lcms_profile_close (src_profile);
gimp_lcms_profile_close (dest_profile);
return transform;
}