diff options
| author | Karl Cheng <qantas94heavy@gmail.com> | 2019-05-10 07:56:07 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marc@jeanmougin.fr> | 2019-05-12 12:45:27 +0000 |
| commit | e6ad8433954db069908bac240f39911fc32e5025 (patch) | |
| tree | e655e16ddc932b6e936ca8ff85626ee5c0fdf023 /src/object/color-profile.cpp | |
| parent | rename to avoid name clashes. (diff) | |
| download | inkscape-e6ad8433954db069908bac240f39911fc32e5025.tar.gz inkscape-e6ad8433954db069908bac240f39911fc32e5025.zip | |
Remove support for LCMS 1
Now that all platforms (including macOS) now support LCMS 2, we no
longer need to support LCMS 1.
Fixes: https://bugs.launchpad.net/inkscape/+bug/1133014
Diffstat (limited to 'src/object/color-profile.cpp')
| -rw-r--r-- | src/object/color-profile.cpp | 116 |
1 files changed, 38 insertions, 78 deletions
diff --git a/src/object/color-profile.cpp b/src/object/color-profile.cpp index 0e6d5e08d..36bb32142 100644 --- a/src/object/color-profile.cpp +++ b/src/object/color-profile.cpp @@ -38,8 +38,6 @@ #if HAVE_LIBLCMS2 # include <lcms2.h> -#elif HAVE_LIBLCMS1 -# include <lcms.h> #endif // HAVE_LIBLCMS2 #include "xml/repr.h" @@ -64,12 +62,12 @@ using Inkscape::ColorProfileImpl; namespace { -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) cmsHPROFILE getSystemProfileHandle(); cmsHPROFILE getProofProfileHandle(); void loadProfiles(); Glib::ustring getNameFromProfile(cmsHPROFILE profile); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) } #ifdef DEBUG_LCMS @@ -116,14 +114,14 @@ namespace Inkscape { class ColorProfileImpl { public: -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) static cmsHPROFILE _sRGBProf; static cmsHPROFILE _NullProf; -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) ColorProfileImpl(); -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) static cmsUInt32Number _getInputFormat( cmsColorSpaceSignature space ); static cmsHPROFILE getNULLProfile(); @@ -137,10 +135,10 @@ public: cmsHTRANSFORM _transf; cmsHTRANSFORM _revTransf; cmsHTRANSFORM _gamutTransf; -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) }; -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) cmsColorSpaceSignature asICColorSpaceSig(ColorSpaceSig const & sig) { return ColorSpaceSigWrapper(sig); @@ -150,12 +148,12 @@ cmsProfileClassSignature asICColorProfileClassSig(ColorProfileClassSig const & s { return ColorProfileClassSigWrapper(sig); } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) } // namespace Inkscape ColorProfileImpl::ColorProfileImpl() -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) : _profHandle(nullptr), _profileClass(cmsSigInputClass), @@ -163,11 +161,11 @@ ColorProfileImpl::ColorProfileImpl() _transf(nullptr), _revTransf(nullptr), _gamutTransf(nullptr) -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) { } -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) cmsHPROFILE ColorProfileImpl::_sRGBProf = nullptr; @@ -187,7 +185,7 @@ cmsHPROFILE ColorProfileImpl::getNULLProfile() { return _NullProf; } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) ColorProfile::FilePlusHome::FilePlusHome(Glib::ustring filename, bool isInHome) : filename(std::move(filename)), isInHome(isInHome) { } @@ -265,15 +263,15 @@ void ColorProfile::release() { this->intentStr = nullptr; } -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) this->impl->_clearProfile(); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) delete this->impl; this->impl = nullptr; } -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) void ColorProfileImpl::_clearProfile() { _profileSpace = cmsSigRgbData; @@ -295,7 +293,7 @@ void ColorProfileImpl::_clearProfile() _profHandle = nullptr; } } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) /** * Callback: set attributes from associated repr. @@ -334,10 +332,7 @@ void ColorProfile::set(SPAttributeEnum key, gchar const *value) { if ( value ) { this->href = g_strdup( value ); if ( *this->href ) { -#if HAVE_LIBLCMS1 - cmsErrorAction( LCMS_ERROR_SHOW ); -#endif -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) // TODO open filename and URIs properly //FILE* fp = fopen_utf8name( filename, "r" ); @@ -372,7 +367,7 @@ void ColorProfile::set(SPAttributeEnum key, gchar const *value) { this->impl->_profileClass = cmsGetDeviceClass( this->impl->_profHandle ); } DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)this->impl->_profHandle ); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) } } this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -461,7 +456,7 @@ Inkscape::XML::Node* ColorProfile::write(Inkscape::XML::Document *xml_doc, Inksc } -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) struct MapMap { cmsColorSpaceSignature space; @@ -599,19 +594,13 @@ bool ColorProfile::GamutCheck(SPColor color) { guint32 val = color.toRGBA32(0); -#if HAVE_LIBLCMS1 - int alarm_r = 0; - int alarm_g = 0; - int alarm_b = 0; - cmsGetAlarmCodes(&alarm_r, &alarm_g, &alarm_b); - cmsSetAlarmCodes(255, 255, 255); -#elif HAVE_LIBLCMS2 +#if HAVE_LIBLCMS2 cmsUInt16Number oldAlarmCodes[cmsMAXCHANNELS] = {0}; cmsGetAlarmCodes(oldAlarmCodes); cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0}; newAlarmCodes[0] = ~0; cmsSetAlarmCodes(newAlarmCodes); -#endif // HAVE_LIBLCMS1 +#endif cmsUInt8Number outofgamut = 0; guchar check_color[4] = { @@ -625,11 +614,9 @@ bool ColorProfile::GamutCheck(SPColor color) cmsDoTransform(gamutCheck, &check_color, &outofgamut, 1); } -#if HAVE_LIBLCMS1 - cmsSetAlarmCodes(alarm_r, alarm_g, alarm_b); -#elif HAVE_LIBLCMS2 +#if HAVE_LIBLCMS2 cmsSetAlarmCodes(oldAlarmCodes); -#endif // HAVE_LIBLCMS1 +#endif return (outofgamut != 0); } @@ -727,29 +714,24 @@ gint Inkscape::CMSSystem::getChannelCount(ColorProfile const *profile) { gint count = 0; if ( profile ) { -#if HAVE_LIBLCMS1 - count = _cmsChannelsOf( asICColorSpaceSig(profile->getColorSpace()) ); -#elif HAVE_LIBLCMS2 +#if HAVE_LIBLCMS2 count = cmsChannelsOf( asICColorSpaceSig(profile->getColorSpace()) ); #endif } return count; } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) // the bool return value tells if it's a user's directory or a system location // note that this will treat places under $HOME as system directories when they are found via $XDG_DATA_DIRS std::set<ColorProfile::FilePlusHome> ColorProfile::getBaseProfileDirs() { -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) static bool warnSet = false; if (!warnSet) { -#if HAVE_LIBLCMS1 - cmsErrorAction( LCMS_ERROR_SHOW ); -#endif warnSet = true; } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) std::set<ColorProfile::FilePlusHome> sources; // first try user's local dir @@ -831,7 +813,7 @@ static bool isIccFile( gchar const *filepath ) } close(fd); -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) if (isIccFile) { cmsHPROFILE prof = cmsOpenProfileFromFile( filepath, "r" ); if ( prof ) { @@ -842,7 +824,7 @@ static bool isIccFile( gchar const *filepath ) cmsCloseProfile( prof ); } } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) } } return isIccFile; @@ -868,7 +850,7 @@ std::set<ColorProfile::FilePlusHomeAndName> ColorProfile::getProfileFilesWithNam { std::set<FilePlusHomeAndName> result; -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) for (auto &profile: getProfileFiles()) { cmsHPROFILE hProfile = cmsOpenProfileFromFile(profile.filename.c_str(), "r"); if ( hProfile ) { @@ -877,20 +859,13 @@ std::set<ColorProfile::FilePlusHomeAndName> ColorProfile::getProfileFilesWithNam cmsCloseProfile(hProfile); } } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) return result; } -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -#if HAVE_LIBLCMS1 -int errorHandlerCB(int ErrorCode, const char *ErrorText) -{ - g_message("lcms: Error %d; %s", ErrorCode, ErrorText); - - return 1; -} -#elif HAVE_LIBLCMS2 +#if defined(HAVE_LIBLCMS2) +#if HAVE_LIBLCMS2 void errorHandlerCB(cmsContext /*contextID*/, cmsUInt32Number errorCode, char const *errorText) { g_message("lcms: Error %d", errorCode); @@ -906,16 +881,7 @@ Glib::ustring getNameFromProfile(cmsHPROFILE profile) { Glib::ustring nameStr; if ( profile ) { -#if HAVE_LIBLCMS1 - gchar const *name = cmsTakeProductDesc(profile); - if ( !name ) { - name = cmsTakeProductName(profile); - } - if ( name && !g_utf8_validate(name, -1, NULL) ) { - name = _("(invalid UTF-8 string)"); - } - nameStr = (name) ? name : C_("Profile name", "None"); -#elif HAVE_LIBLCMS2 +#if HAVE_LIBLCMS2 cmsUInt32Number byteLen = cmsGetProfileInfo(profile, cmsInfoDescription, "en", "US", nullptr, 0); if (byteLen > 0) { // TODO investigate wchar_t and cmsGetProfileInfo() @@ -944,9 +910,7 @@ void loadProfiles() { static bool error_handler_set = false; if (!error_handler_set) { -#if HAVE_LIBLCMS1 - cmsSetErrorHandler(errorHandlerCB); -#elif HAVE_LIBLCMS2 +#if HAVE_LIBLCMS2 //cmsSetLogErrorHandler(errorHandlerCB); //g_message("LCMS error handler set"); #endif @@ -1166,9 +1130,7 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayTransform() auto gamutColor_g = gamutColor.get_green_u(); auto gamutColor_b = gamutColor.get_blue_u(); -#if HAVE_LIBLCMS1 - cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8); -#elif HAVE_LIBLCMS2 +#if HAVE_LIBLCMS2 cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0}; newAlarmCodes[0] = gamutColor_r; newAlarmCodes[1] = gamutColor_g; @@ -1328,9 +1290,7 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayPer( Glib::ustring const& id ) auto gamutColor_g = gamutColor.get_green_u(); auto gamutColor_b = gamutColor.get_blue_u(); -#if HAVE_LIBLCMS1 - cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8); -#elif HAVE_LIBLCMS2 +#if HAVE_LIBLCMS2 cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0}; newAlarmCodes[0] = gamutColor_r; newAlarmCodes[1] = gamutColor_g; @@ -1363,7 +1323,7 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayPer( Glib::ustring const& id ) -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) /* Local Variables: |
