summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-04-15 14:19:48 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-12-10 11:03:12 +0100
commit48346e8d2df287dd4b7e6d51de491c3bd3020255 (patch)
treeb2db9b6ebd8ded1e239124cd40e30961783193b2 /tests
parent667e5b1210cf8783c5b16445a09f30d14bc83c0f (diff)
Add colorspace transfer functions based on tables of inputs
This is the most basic way to represent custom transfer functions. Change-Id: I529fb647ece82c03e85ef77b056d9daf13fe5a61 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
index 3564700fe5..4acbfbba74 100644
--- a/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
+++ b/tests/auto/gui/painting/qcolorspace/tst_qcolorspace.cpp
@@ -74,6 +74,8 @@ private slots:
void changeTransferFunction();
void changePrimaries();
+
+ void transferFunctionTable();
};
tst_QColorSpace::tst_QColorSpace()
@@ -468,5 +470,32 @@ void tst_QColorSpace::changePrimaries()
QCOMPARE(cs, QColorSpace(QColorSpace::SRgbLinear));
}
+void tst_QColorSpace::transferFunctionTable()
+{
+ QVector<quint16> linearTable = { 0, 65535 };
+
+ // Check linearSRgb is recognized
+ QColorSpace linearSRgb(QColorSpace::Primaries::SRgb, linearTable);
+ QCOMPARE(linearSRgb.primaries(), QColorSpace::Primaries::SRgb);
+ QCOMPARE(linearSRgb.transferFunction(), QColorSpace::TransferFunction::Linear);
+ QCOMPARE(linearSRgb.gamma(), 1.0);
+ QCOMPARE(linearSRgb, QColorSpace::SRgbLinear);
+
+ // Check other linear is recognized
+ QColorSpace linearARgb(QColorSpace::Primaries::AdobeRgb, linearTable);
+ QCOMPARE(linearARgb.primaries(), QColorSpace::Primaries::AdobeRgb);
+ QCOMPARE(linearARgb.transferFunction(), QColorSpace::TransferFunction::Linear);
+ QCOMPARE(linearARgb.gamma(), 1.0);
+
+ // Check custom transfer function.
+ QVector<quint16> customTable = { 0, 10, 100, 10000, 65535 };
+ QColorSpace customSRgb(QColorSpace::Primaries::SRgb, customTable);
+ QCOMPARE(customSRgb.primaries(), QColorSpace::Primaries::SRgb);
+ QCOMPARE(customSRgb.transferFunction(), QColorSpace::TransferFunction::Custom);
+
+ customSRgb.setTransferFunction(linearTable);
+ QCOMPARE(customSRgb, QColorSpace::SRgbLinear);
+}
+
QTEST_MAIN(tst_QColorSpace)
#include "tst_qcolorspace.moc"