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 | |
| 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')
| -rw-r--r-- | src/object/color-profile.cpp | 116 | ||||
| -rw-r--r-- | src/object/color-profile.h | 4 | ||||
| -rw-r--r-- | src/object/sp-image.cpp | 33 | ||||
| -rw-r--r-- | src/object/sp-image.h | 8 |
4 files changed, 58 insertions, 103 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: diff --git a/src/object/color-profile.h b/src/object/color-profile.h index a0b320b02..5120b92fc 100644 --- a/src/object/color-profile.h +++ b/src/object/color-profile.h @@ -74,7 +74,7 @@ public: static std::set<FilePlusHome> getBaseProfileDirs(); static std::set<FilePlusHome> getProfileFiles(); static std::set<FilePlusHomeAndName> getProfileFilesWithNames(); -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) //icColorSpaceSignature getColorSpace() const; ColorSpaceSig getColorSpace() const; //icProfileClassSignature getProfileClass() const; @@ -84,7 +84,7 @@ public: cmsHTRANSFORM getTransfGamutCheck(); bool GamutCheck(SPColor color); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) char* href; char* local; diff --git a/src/object/sp-image.cpp b/src/object/sp-image.cpp index 6c3854cb4..03f42c904 100644 --- a/src/object/sp-image.cpp +++ b/src/object/sp-image.cpp @@ -41,15 +41,10 @@ #include "preferences.h" #include "io/sys.h" -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) #include "cms-system.h" #include "color-profile.h" - -#if HAVE_LIBLCMS2 -# include <lcms2.h> -#elif HAVE_LIBLCMS1 -# include <lcms.h> -#endif // HAVE_LIBLCMS2 +#include <lcms2.h> //#define DEBUG_LCMS #ifdef DEBUG_LCMS @@ -61,7 +56,7 @@ #else #define DEBUG_MESSAGE(key, ...) #endif // DEBUG_LCMS -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) /* * SPImage */ @@ -125,9 +120,9 @@ SPImage::SPImage() : SPItem(), SPViewBox() { this->curve = nullptr; this->href = nullptr; -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) this->color_profile = nullptr; -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) this->pixbuf = nullptr; } @@ -163,12 +158,12 @@ void SPImage::release() { delete this->pixbuf; this->pixbuf = nullptr; -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) if (this->color_profile) { g_free (this->color_profile); this->color_profile = nullptr; } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) if (this->curve) { this->curve = this->curve->unref(); @@ -230,7 +225,7 @@ void SPImage::set(SPAttributeEnum key, const gchar* value) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) case SP_PROP_COLOR_PROFILE: if ( this->color_profile ) { g_free (this->color_profile); @@ -248,7 +243,7 @@ void SPImage::set(SPAttributeEnum key, const gchar* value) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_IMAGE_HREF_MODIFIED_FLAG); break; -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) default: SPItem::set(key, value); @@ -259,7 +254,7 @@ void SPImage::set(SPAttributeEnum key, const gchar* value) { } // BLIP -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) void SPImage::apply_profile(Inkscape::Pixbuf *pixbuf) { // TODO: this will prevent using MIME data when exporting. @@ -327,7 +322,7 @@ void SPImage::apply_profile(Inkscape::Pixbuf *pixbuf) { } } } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) void SPImage::update(SPCtx *ctx, unsigned int flags) { @@ -348,7 +343,7 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { this->getRepr()->attribute("sodipodi:absref"), doc->getDocumentBase(), svgdpi); if (pixbuf) { -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) if ( this->color_profile ) apply_profile( pixbuf ); #endif this->pixbuf = pixbuf; @@ -481,11 +476,11 @@ Inkscape::XML::Node *SPImage::write(Inkscape::XML::Document *xml_doc, Inkscape:: repr->setAttribute("inkscape:svg-dpi", this->getRepr()->attribute("inkscape:svg-dpi")); //XML Tree being used directly here while it shouldn't be... repr->setAttribute("preserveAspectRatio", this->getRepr()->attribute("preserveAspectRatio")); -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) if (this->color_profile) { repr->setAttribute("color-profile", this->color_profile); } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) SPItem::write(xml_doc, repr, flags); diff --git a/src/object/sp-image.h b/src/object/sp-image.h index 2bc5e49a2..d591a499e 100644 --- a/src/object/sp-image.h +++ b/src/object/sp-image.h @@ -46,9 +46,9 @@ public: SPCurve *curve; // This curve is at the image's boundary for snapping char *href; -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) char *color_profile; -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) Inkscape::Pixbuf *pixbuf; @@ -67,9 +67,9 @@ public: void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const override; Geom::Affine set_transform(Geom::Affine const &transform) override; -#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#if defined(HAVE_LIBLCMS2) void apply_profile(Inkscape::Pixbuf *pixbuf); -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +#endif // defined(HAVE_LIBLCMS2) SPCurve *get_curve () const; void refresh_if_outdated(); |
