Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Make lcmsengine into a static library so we can use it inside it's own tests.

Wolthera van Hövell tot Westerflierdfac06efc46a
diff --git a/plugins/color/lcms2engine/CMakeLists.txt b/plugins/color/lcms2engine/CMakeLists.txt
index 9c3b5b255f..185e4f4137 100644
--- a/plugins/color/lcms2engine/CMakeLists.txt
+++ b/plugins/color/lcms2engine/CMakeLists.txt
@@ -79,9 +79,12 @@ if (HAVE_LCMS24 AND OpenEXR_FOUND)
endif ()
-
+kis_add_library(kritalcmsengine_static STATIC ${lcmsengine_SRCS})
kis_add_library(kritalcmsengine MODULE ${lcmsengine_SRCS})
+generate_export_header(kritalcmsengine_static BASE_NAME kritalcmsengine)
+
+target_link_libraries(kritalcmsengine_static kritapigment kritawidgetutils KF${KF_MAJOR}::I18n KF${KF_MAJOR}::CoreAddons ${LCMS2_LIBRARIES} ${LINK_OPENEXR_LIB})
-target_link_libraries(kritalcmsengine kritapigment kritawidgetutils KF${KF_MAJOR}::I18n KF${KF_MAJOR}::CoreAddons ${LCMS2_LIBRARIES} ${LINK_OPENEXR_LIB})
+target_link_libraries(kritalcmsengine PRIVATE kritalcmsengine_static)
install(TARGETS kritalcmsengine DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
diff --git a/plugins/color/lcms2engine/colorprofiles/IccColorProfile.h b/plugins/color/lcms2engine/colorprofiles/IccColorProfile.h
index e434c4916e..29a2047448 100644
--- a/plugins/color/lcms2engine/colorprofiles/IccColorProfile.h
+++ b/plugins/color/lcms2engine/colorprofiles/IccColorProfile.h
@@ -11,12 +11,14 @@
#include "KoColorProfile.h"
#include "KoChannelInfo.h"
+#include "kritalcmsengine_export.h"
+
class LcmsColorProfileContainer;
/**
* This class contains an ICC color profile.
*/
-class IccColorProfile : public KoColorProfile
+class KRITALCMSENGINE_EXPORT IccColorProfile : public KoColorProfile
{
public:
diff --git a/plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.h b/plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.h
index 9ac0f2d221..d2adacd4d0 100644
--- a/plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.h
+++ b/plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.h
@@ -13,6 +13,7 @@
#include "IccColorProfile.h"
#include <lcms2.h>
+#include "kritalcmsengine_export.h"
#include <QByteArray>
#include <QString>
@@ -20,7 +21,7 @@
/**
* This class contains an LCMS color profile. Don't use it outside LcmsColorSpace.
*/
-class LcmsColorProfileContainer : public IccColorProfile::Container
+class KRITALCMSENGINE_EXPORT LcmsColorProfileContainer : public IccColorProfile::Container
{
friend class IccColorProfile;
protected:
diff --git a/plugins/color/lcms2engine/tests/CMakeLists.txt b/plugins/color/lcms2engine/tests/CMakeLists.txt
index 9f04718768..ea9218faba 100644
--- a/plugins/color/lcms2engine/tests/CMakeLists.txt
+++ b/plugins/color/lcms2engine/tests/CMakeLists.txt
@@ -8,7 +8,7 @@ kis_add_tests(
TestColorSpaceRegistry.cpp
TestLcmsRGBP2020PQColorSpace.cpp
TestProfileGeneration.cpp
- LINK_LIBRARIES kritawidgets kritapigment KF${KF_MAJOR}::I18n kritatestsdk ${LCMS2_LIBRARIES}
+ LINK_LIBRARIES kritalcmsengine_static kritawidgets kritapigment KF${KF_MAJOR}::I18n kritatestsdk ${LCMS2_LIBRARIES}
)
if (KRITA_USE_SURFACE_COLOR_MANAGEMENT_API)
@@ -16,4 +16,4 @@ if (KRITA_USE_SURFACE_COLOR_MANAGEMENT_API)
TestIccFromColorimetryConversion.cpp
LINK_LIBRARIES kritapigment kritatestsdk ${LCMS2_LIBRARIES} kritasurfacecolormanagementapi
)
-endif()
\ No newline at end of file
+endif()
diff --git a/plugins/color/lcms2engine/tests/TestIccFromColorimetryConversion.cpp b/plugins/color/lcms2engine/tests/TestIccFromColorimetryConversion.cpp
index 37587e179e..09d1e8e69c 100644
--- a/plugins/color/lcms2engine/tests/TestIccFromColorimetryConversion.cpp
+++ b/plugins/color/lcms2engine/tests/TestIccFromColorimetryConversion.cpp
@@ -219,14 +219,8 @@ void TestIccFromColorimetryConversion::testProfileConstruction()
QVERIFY(profile);
- if (QLatin1String(QTest::currentDataTag()) == "bt2020-pq") {
- // we use a fake profile with a special color space for bt2020pq space, so
- // just verify that the profile name is consistent
- QCOMPARE(profile->name(), "High Dynamic Range UHDTV Wide Color Gamut Display (Rec. 2020) - SMPTE ST 2084 PQ EOTF");
- } else {
- QCOMPARE(profile->getColorPrimaries(), expectedPrimaries);
- QCOMPARE(profile->getTransferCharacteristics(), expectedTransferFunction);
- }
+ QCOMPARE(profile->getColorPrimaries(), expectedPrimaries);
+ QCOMPARE(profile->getTransferCharacteristics(), expectedTransferFunction);
qDebug() << ppVar(profile->name()) << ppVar(profile->fileName());
}
diff --git a/plugins/color/lcms2engine/tests/TestProfileGeneration.cpp b/plugins/color/lcms2engine/tests/TestProfileGeneration.cpp
index 2c3265d54f..9ab20308fd 100644
--- a/plugins/color/lcms2engine/tests/TestProfileGeneration.cpp
+++ b/plugins/color/lcms2engine/tests/TestProfileGeneration.cpp
@@ -5,6 +5,8 @@
*/
#include "TestProfileGeneration.h"
+#include "colorprofiles/LcmsColorProfileContainer.h"
+#include "colorprofiles/IccColorProfile.h"
#include <QTest>
#include <cmath>
@@ -344,7 +346,6 @@ void TestProfileGeneration::testTransferFunctions()
}
for (double value : inputValuesRaw) {
- double cValue = value;
/*
* HLG
* for 1 >= Lc > 1 ÷ 12
@@ -359,30 +360,13 @@ void TestProfileGeneration::testTransferFunctions()
*
*/
- double a = 0.17883277;
- double b = 0.28466892;
- double c = 0.55991073;
-
-
- if (value > 1.0/12.0) {
- cValue = a*log(12*value-b) + c;
- } else {
- cValue = sqrt(3) * powf(value, 0.5);
- }
double cValue2 = applyHLGCurve(value);
-
- double lValue = (exp(((cValue2 - c) / a)) + b) / 12.0;
- if (cValue2 <= 0.5) {
- lValue = powf(cValue2, 2.0) / 3.0;
- }
-
- double lValue2 = removeHLGCurve(cValue);
+ double lValue2 = removeHLGCurve(cValue2);
//Not possible in icc v4
- QVERIFY2(fabs(lValue - value) < 0.000001, QString("Values don't match for HLG: %1 %2").arg(value).arg(lValue).toLatin1());
- QVERIFY2(fabs(lValue2 - value) < 0.000001, QString("Values don't match for HLG, 2: %1 %2").arg(value).arg(lValue2).toLatin1());
+ QVERIFY2(fabs(lValue2 - value) < 0.000001, QString("Values don't match for HLG: %1 %2").arg(value).arg(lValue2).toLatin1());
}
@@ -390,17 +374,38 @@ void TestProfileGeneration::testTransferFunctions()
}
+void TestProfileGeneration::testCICPwriting_data()
+{
+ QTest::addColumn<ColorPrimaries>("primaries");
+ QTest::addColumn<TransferCharacteristics>("transfer");
+
+ QTest::addRow("rec2020") << PRIMARIES_ITU_R_BT_2020_2_AND_2100_0 << TRC_ITU_R_BT_2020_2_12bit;
+ QTest::addRow("rec2100 PQ") << PRIMARIES_ITU_R_BT_2020_2_AND_2100_0 << TRC_ITU_R_BT_2100_0_PQ;
+ QTest::addRow("rec709") << PRIMARIES_ITU_R_BT_709_5 << TRC_ITU_R_BT_709_5;
+}
+
void TestProfileGeneration::testCICPwriting()
{
+ QFETCH(ColorPrimaries, primaries);
+ QFETCH(TransferCharacteristics, transfer);
QVector<double> colorants;
- const KoColorProfile *profile = KoColorSpaceRegistry::instance()->profileFor(colorants, PRIMARIES_ITU_R_BT_2020_2_AND_2100_0, TRC_ITU_R_BT_2020_2_12bit);
+ const KoColorProfile *profile = KoColorSpaceRegistry::instance()->profileFor(colorants, primaries, transfer);
QVERIFY(profile);
// TODO: write and reload the profile.
- QVERIFY(profile->getColorPrimaries() == PRIMARIES_ITU_R_BT_2020_2_AND_2100_0);
- QVERIFY(profile->getTransferCharacteristics() == TRC_ITU_R_BT_2020_2_12bit);
+ QVERIFY(profile->getColorPrimaries() == primaries);
+ QVERIFY(profile->getTransferCharacteristics() == transfer);
+
+ const IccColorProfile *icc = dynamic_cast<const IccColorProfile*>(profile);
+ QVERIFY(icc);
+ const LcmsColorProfileContainer *lcms = icc->asLcms();
+ QVERIFY(lcms);
+
+ QVERIFY(lcms->hasCicpValues());
+ QVERIFY(lcms->cicpPrimaries() == primaries);
+ QVERIFY(lcms->cicpTransfer() == transfer);
}
KISTEST_MAIN(TestProfileGeneration)
diff --git a/plugins/color/lcms2engine/tests/TestProfileGeneration.h b/plugins/color/lcms2engine/tests/TestProfileGeneration.h
index b1f2b51cce..fca9d8e942 100644
--- a/plugins/color/lcms2engine/tests/TestProfileGeneration.h
+++ b/plugins/color/lcms2engine/tests/TestProfileGeneration.h
@@ -13,6 +13,8 @@ class TestProfileGeneration : public QObject
Q_OBJECT
private Q_SLOTS:
void testTransferFunctions();
+
+ void testCICPwriting_data();
void testCICPwriting();
};