[graphics/krita] /: Fix unittests to support multiple ref. white posibilities
Wolthera van Hövell <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit b4a76ecfc3d54e0d212712bcf94f682e6fa367ea by Wolthera van Hövell, on behalf of Dmitry Kazakov.
Committed on 16/07/2026 at 16:26.
Pushed by woltherav into branch 'master'.
Fix unittests to support multiple ref. white posibilities
M +4 -1 libs/pigment/KoColorProfileQuery.h
M +6 -5 plugins/impex/libkra/tests/kis_kra_loader_test.cpp
M +25 -6 plugins/impex/libkra/tests/kis_kra_saver_test.cpp
M +10 -1 plugins/impex/tiff/tests/kis_tiff_test.cpp
https://invent.kde.org/graphics/krita/-/commit/b4a76ecfc3d54e0d212712bcf94f682e6fa367ea
diff --git a/libs/pigment/KoColorProfileQuery.h b/libs/pigment/KoColorProfileQuery.h
index 859faa5a85d..92c32cfb8b1 100644
--- a/libs/pigment/KoColorProfileQuery.h
+++ b/libs/pigment/KoColorProfileQuery.h
@@ -17,9 +17,12 @@
* a KoColorProfile for either search or generation.
*/
struct KoColorProfileQuery {
- KoColorProfileQuery(ColorPrimaries primaries = PRIMARIES_UNSPECIFIED, TransferCharacteristics transfer = TRC_UNSPECIFIED)
+ KoColorProfileQuery(ColorPrimaries primaries = PRIMARIES_UNSPECIFIED,
+ TransferCharacteristics transfer = TRC_UNSPECIFIED,
+ std::optional<qreal> hdrReferenceWhite = std::nullopt)
: primaries(primaries)
, transfer(transfer)
+ , hdrReferenceWhite(hdrReferenceWhite)
{}
KoColorProfileQuery(const KoColorProfileQuery &rhs) = default;
diff --git a/plugins/impex/libkra/tests/kis_kra_loader_test.cpp b/plugins/impex/libkra/tests/kis_kra_loader_test.cpp
index a630fb6ecd3..08d09c9e296 100644
--- a/plugins/impex/libkra/tests/kis_kra_loader_test.cpp
+++ b/plugins/impex/libkra/tests/kis_kra_loader_test.cpp
@@ -180,8 +180,9 @@ void KisKraLoaderTest::testLoadingOldHdrProfileNoCicp()
doc->loadNativeFormat(QString(FILES_DATA_DIR) + '/' + "hdr_gem_old_profile_no_cicp.kra");
KisImageSP image = doc->image();
image->waitForDone();
- QVERIFY(image->colorSpace()->profile()->getColorPrimaries() == PRIMARIES_ITU_R_BT_2020_2_AND_2100_0);
- QVERIFY(image->colorSpace()->profile()->getTransferCharacteristics() == TRC_ITU_R_BT_2100_0_PQ);
+ QCOMPARE(image->colorSpace()->profile()->getColorPrimaries(), PRIMARIES_ITU_R_BT_2020_2_AND_2100_0);
+ QCOMPARE(image->colorSpace()->profile()->getTransferCharacteristics(), TRC_ITU_R_BT_2100_0_PQ);
+ QCOMPARE(*image->colorSpace()->profile()->hdrReferenceWhite(), 80.0);
}
void KisKraLoaderTest::testLoadingUncommonHdrProfileWithCicp()
@@ -190,9 +191,9 @@ void KisKraLoaderTest::testLoadingUncommonHdrProfileWithCicp()
doc->loadNativeFormat(QString(FILES_DATA_DIR) + '/' + "hdr_gem_180nits_rec2100pq_profile.kra");
KisImageSP image = doc->image();
image->waitForDone();
- QVERIFY(image->colorSpace()->profile()->getColorPrimaries() == PRIMARIES_ITU_R_BT_2020_2_AND_2100_0);
- QVERIFY(image->colorSpace()->profile()->getTransferCharacteristics() == TRC_ITU_R_BT_2100_0_PQ);
- QVERIFY(image->colorSpace()->profile()->name().contains("180nits"));
+ QCOMPARE(image->colorSpace()->profile()->getColorPrimaries(), PRIMARIES_ITU_R_BT_2020_2_AND_2100_0);
+ QCOMPARE(image->colorSpace()->profile()->getTransferCharacteristics(), TRC_ITU_R_BT_2100_0_PQ);
+ QCOMPARE(*image->colorSpace()->profile()->hdrReferenceWhite(), 180.0);
}
diff --git a/plugins/impex/libkra/tests/kis_kra_saver_test.cpp b/plugins/impex/libkra/tests/kis_kra_saver_test.cpp
index 2e8bf58db28..9fc19603365 100644
--- a/plugins/impex/libkra/tests/kis_kra_saver_test.cpp
+++ b/plugins/impex/libkra/tests/kis_kra_saver_test.cpp
@@ -579,19 +579,29 @@ void KisKraSaverTest::testRoundTripCicp_data()
{
QTest::addColumn<ColorPrimaries>("primaries");
QTest::addColumn<TransferCharacteristics>("transfer");
+ QTest::addColumn<qreal>("hdrReferenceWhite");
- 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;
+ QTest::addRow("rec2020") << PRIMARIES_ITU_R_BT_2020_2_AND_2100_0 << TRC_ITU_R_BT_2020_2_12bit << -1.0;
+ QTest::addRow("rec2100 PQ 80 nits") << PRIMARIES_ITU_R_BT_2020_2_AND_2100_0 << TRC_ITU_R_BT_2100_0_PQ << 80.0;
+ QTest::addRow("rec2100 PQ 203 nits") << PRIMARIES_ITU_R_BT_2020_2_AND_2100_0 << TRC_ITU_R_BT_2100_0_PQ << 203.0;
+ QTest::addRow("rec709") << PRIMARIES_ITU_R_BT_709_5 << TRC_ITU_R_BT_709_5 << -1.0;
}
void KisKraSaverTest::testRoundTripCicp()
{
QFETCH(ColorPrimaries, primaries);
QFETCH(TransferCharacteristics, transfer);
+ QFETCH(qreal, hdrReferenceWhite);
QVector<double> colorants;
- const KoColorProfile *profile = KoColorSpaceRegistry::instance()->profileFor(KoColorProfileQuery(primaries, transfer));
+ std::optional<qreal> hdrReferenceWhiteOpt;
+ if (hdrReferenceWhite > 0) {
+ hdrReferenceWhiteOpt = hdrReferenceWhite;
+ }
+
+ const KoColorProfile *profile =
+ KoColorSpaceRegistry::instance()->profileFor(KoColorProfileQuery(primaries, transfer, hdrReferenceWhiteOpt));
+ QVERIFY(profile);
QRect imageRect(0,0,512,512);
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->colorSpace(RGBAColorModelID.id(), Integer8BitsColorDepthID.id(), profile);
@@ -606,8 +616,17 @@ void KisKraSaverTest::testRoundTripCicp()
bool result = doc2->loadNativeFormat(name);
QVERIFY(result);
doc2->image()->waitForDone();
- QVERIFY(doc2->image()->colorSpace()->profile()->getColorPrimaries() == primaries);
- QVERIFY(doc2->image()->colorSpace()->profile()->getTransferCharacteristics() == transfer);
+
+ {
+ const KoColorProfile *profile = doc2->image()->colorSpace()->profile();
+ QCOMPARE(profile->getColorPrimaries(), primaries);
+ QCOMPARE(profile->getTransferCharacteristics(), transfer);
+ if (hdrReferenceWhite > 0.0) {
+ QCOMPARE(*profile->hdrReferenceWhite(), hdrReferenceWhite);
+ } else {
+ QVERIFY(!profile->hdrReferenceWhite().has_value());
+ }
+ }
// De-Duplication test.
QList<const KoColorProfile*> profiles = KoColorSpaceRegistry::instance()->profilesFor(cs->id());
diff --git a/plugins/impex/tiff/tests/kis_tiff_test.cpp b/plugins/impex/tiff/tests/kis_tiff_test.cpp
index b263a97d842..fda4475de8d 100644
--- a/plugins/impex/tiff/tests/kis_tiff_test.cpp
+++ b/plugins/impex/tiff/tests/kis_tiff_test.cpp
@@ -139,6 +139,14 @@ void KisTiffTest::testImportIncorrectFormat()
void KisTiffTest::testLoadTiffWithLegacyPQProfile()
{
+ const QString legacyProfileName = "High Dynamic Range UHDTV Wide Color Gamut Display (Rec. 2020) - SMPTE ST 2084 PQ EOTF";
+
+ if (KoColorSpaceRegistry::instance()->profileByName(legacyProfileName)->name() == legacyProfileName) {
+ qWarning() << "WARNING: the legacy Rec2020PQ profile is present in the Krita installation directory!";
+ qWarning() << " It will cause Krita to use it instead of the embedded (better) one.";
+ QSKIP("The installed profile will prevent this test from succeeding");
+ }
+
const QString tiffFilePath = TestUtil::fetchDataFileLazy("test-tiff-with-legacy-hdr-profile.tif");
KIS_ASSERT(QFile::exists(tiffFilePath));
@@ -158,9 +166,10 @@ void KisTiffTest::testLoadTiffWithLegacyPQProfile()
*/
const KoColorProfile *profile = doc->image()->colorSpace()->profile();
- QCOMPARE(profile->name(), KoColorSpaceRegistry::instance()->p2020PQProfile()->name());
QCOMPARE(profile->getColorPrimaries(), PRIMARIES_ITU_R_BT_2020_2_AND_2100_0);
QCOMPARE(profile->getTransferCharacteristics(), TRC_ITU_R_BT_2100_0_PQ);
+ QVERIFY(profile->hdrReferenceWhite().has_value());
+ QCOMPARE(*profile->hdrReferenceWhite(), 203.0);
}