summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcolortrc_p.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-07-02 13:20:39 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-04-12 14:57:02 +0000
commit8f44aeb10317664dd7cae92e628fb0814e432e17 (patch)
treeb42a61974c713886d79287254866249fcdf62307 /src/gui/painting/qcolortrc_p.h
parent6dca11e1af05ddd06439709a210ec225c41276c4 (diff)
Add Extended RGB model to QColor
Can be used to represent wide-gamut and HDR colors. Change-Id: I1cca442069ce2f2c070f723fe930fe1f2f5580ad Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/painting/qcolortrc_p.h')
-rw-r--r--src/gui/painting/qcolortrc_p.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/painting/qcolortrc_p.h b/src/gui/painting/qcolortrc_p.h
index 3a649f3756..3ef9d442fc 100644
--- a/src/gui/painting/qcolortrc_p.h
+++ b/src/gui/painting/qcolortrc_p.h
@@ -91,7 +91,16 @@ public:
return m_fun.apply(x);
return x;
}
-
+ float applyExtended(float x) const
+ {
+ if (x >= 0.0f && x <= 1.0f)
+ return apply(x);
+ if (m_type == Type::Function)
+ return std::copysign(m_fun.apply(std::abs(x)), x);
+ if (m_type == Type::Table)
+ return x < 0.0f ? 0.0f : 1.0f;
+ return x;
+ }
float applyInverse(float x) const
{
if (m_type == Type::Table)
@@ -100,6 +109,16 @@ public:
return m_fun.inverted().apply(x);
return x;
}
+ float applyInverseExtended(float x) const
+ {
+ if (x >= 0.0f && x <= 1.0f)
+ return applyInverse(x);
+ if (m_type == Type::Function)
+ return std::copysign(applyInverse(x), x);
+ if (m_type == Type::Table)
+ return x < 0.0f ? 0.0f : 1.0f;
+ return x;
+ }
friend inline bool operator!=(const QColorTrc &o1, const QColorTrc &o2);
friend inline bool operator==(const QColorTrc &o1, const QColorTrc &o2);