4#ifndef QCOLORTRANSFERTABLE_P_H
5#define QCOLORTRANSFERTABLE_P_H
18#include <QtGui/private/qtguiglobal_p.h>
48 return m_tableSize == 0;
56 if (!m_table8.isEmpty() && !m_table16.isEmpty())
62 if (!m_table8.isEmpty()) {
64 for (
uint i = 0;
i < m_tableSize; ++
i) {
65 if (m_table8[
i] <
val)
70 if (!m_table16.isEmpty()) {
72 for (
uint i = 0;
i < m_tableSize; ++
i) {
73 if (m_table16[
i] <
val)
83 x = std::clamp(
x, 0.0f, 1.0f);
85 const uint32_t lo =
static_cast<uint32_t
>(std::floor(
x));
86 const uint32_t hi = std::min(lo + 1, m_tableSize - 1);
87 const float frac =
x - lo;
88 if (!m_table16.isEmpty())
89 return (m_table16[lo] * (1.0f - frac) + m_table16[hi] * frac) * (1.0f/65535.0f);
90 if (!m_table8.isEmpty())
91 return (m_table8[lo] * (1.0f - frac) + m_table8[hi] * frac) * (1.0f/255.0f);
98 Q_ASSERT(resultLargerThan >= 0.0f && resultLargerThan <= 1.0f);
103 if (!m_table16.isEmpty()) {
104 const float v =
x * 65535.0f;
105 uint32_t
i =
static_cast<uint32_t
>(std::floor(resultLargerThan * (m_tableSize - 1)));
106 auto it = std::lower_bound(m_table16.cbegin() +
i, m_table16.cend(),
v);
110 if (
i >= m_tableSize - 1)
112 const float y1 = m_table16[
i - 1];
113 const float y2 = m_table16[
i];
115 const float fr = (
v -
y1) / (
y2 -
y1);
116 return (
i + fr) * (1.0f / (m_tableSize - 1));
119 if (!m_table8.isEmpty()) {
120 const float v =
x * 255.0f;
121 uint32_t
i =
static_cast<uint32_t
>(std::floor(resultLargerThan * (m_tableSize - 1)));
122 auto it = std::lower_bound(m_table8.cbegin() +
i, m_table8.cend(),
v);
126 if (
i >= m_tableSize - 1)
128 const float y1 = m_table8[
i - 1];
129 const float y2 = m_table8[
i];
131 const float fr = (
v -
y1) / (
y2 -
y1);
132 return (
i + fr) * (1.0f / (m_tableSize - 1));
142 if (!m_table8.isEmpty() && (m_table8[0] != 0 || m_table8[m_tableSize - 1] != 255))
144 if (!m_table16.isEmpty() && (m_table16[0] != 0 || m_table16[m_tableSize - 1] != 65535))
146 if (m_tableSize == 2) {
151 if (m_tableSize == 26 && !m_table16.isEmpty()) {
153 if (m_table16[6] != 3062)
155 if (m_table16[12] != 12824)
157 if (m_table16[18] != 31237)
162 if (m_tableSize == 1024 && !m_table16.isEmpty()) {
164 if (m_table16[257] != 3366)
166 if (m_table16[513] != 14116)
168 if (m_table16[768] != 34318)
173 if (m_tableSize == 4096 && !m_table16.isEmpty()) {
175 if (m_table16[515] != 960)
177 if (m_table16[1025] != 3342)
179 if (m_table16[2051] != 14079)
196 if (
t1.m_tableSize !=
t2.m_tableSize)
198 if (
t1.m_table8.isEmpty() !=
t2.m_table8.isEmpty())
200 if (
t1.m_table16.isEmpty() !=
t2.m_table16.isEmpty())
202 if (!
t1.m_table8.isEmpty()) {
203 for (uint32_t
i = 0;
i <
t1.m_tableSize; ++
i) {
204 if (
t1.m_table8[
i] !=
t2.m_table8[
i])
208 if (!
t1.m_table16.isEmpty()) {
209 for (uint32_t
i = 0;
i <
t1.m_tableSize; ++
i) {
210 if (
t1.m_table16[
i] !=
t2.m_table16[
i])
static QColorTransferFunction fromSRgb()
float applyInverse(float x, float resultLargerThan=0.0f) const
QColorTransferTable(uint32_t size, const QList< uint16_t > &table) noexcept
float apply(float x) const
QList< uint8_t > m_table8
bool checkValidity() const
QList< uint16_t > m_table16
QColorTransferTable() noexcept
bool asColorTransferFunction(QColorTransferFunction *transferFn)
QColorTransferTable(uint32_t size, const QList< uint8_t > &table) noexcept
const_iterator cbegin() const noexcept
QSet< QString >::iterator it
Combined button and popup list for selecting options.
bool operator==(const QColorTransferTable &t1, const QColorTransferTable &t2)
bool operator!=(const QColorTransferTable &t1, const QColorTransferTable &t2)
constexpr bool operator!=(const timespec &t1, const timespec &t2)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLfixed GLfixed GLfixed y2
GLenum GLenum GLsizei void * table
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)