core/colorpipeline: add evaluate method to calculate colorpipeline results on the CPU
This is useful for autotests and some other special cases where we need to calculate the result of a color pipeline on the CPU. Long term, this should replace ColorDescription::mapTo
This commit is contained in:
parent
4b91ac8cca
commit
3f2f3cb020
2 changed files with 18 additions and 0 deletions
|
@ -225,6 +225,23 @@ ColorPipeline ColorPipeline::merge(const ColorPipeline &onTop)
|
|||
return ret;
|
||||
}
|
||||
|
||||
QVector3D ColorPipeline::evaluate(const QVector3D &input) const
|
||||
{
|
||||
QVector3D ret = input;
|
||||
for (const auto &op : ops) {
|
||||
if (const auto mat = std::get_if<ColorMatrix>(&op.operation)) {
|
||||
ret = mat->mat * ret;
|
||||
} else if (const auto mult = std::get_if<ColorMultiplier>(&op.operation)) {
|
||||
ret *= mult->factors;
|
||||
} else if (const auto tf = std::get_if<ColorTransferFunction>(&op.operation)) {
|
||||
ret = tf->tf.encodedToNits(ret, tf->referenceLuminance);
|
||||
} else if (const auto tf = std::get_if<InverseColorTransferFunction>(&op.operation)) {
|
||||
ret = tf->tf.nitsToEncoded(ret, tf->referenceLuminance);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorTransferFunction::ColorTransferFunction(TransferFunction tf, double referenceLLuminance)
|
||||
: tf(tf)
|
||||
, referenceLuminance(referenceLLuminance)
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
bool isIdentity() const;
|
||||
bool operator==(const ColorPipeline &other) const = default;
|
||||
const ValueRange ¤tOutputRange() const;
|
||||
QVector3D evaluate(const QVector3D &input) const;
|
||||
|
||||
void addMultiplier(double factor);
|
||||
void addMultiplier(const QVector3D &factors);
|
||||
|
|
Loading…
Reference in a new issue