4#ifndef QCOLORTRANSFERTABLE_P_H
5#define QCOLORTRANSFERTABLE_P_H
18#include <QtGui/private/qtguiglobal_p.h>
50 return m_tableSize == 0;
59 if (!m_table8.isEmpty())
60 return m_table8[0] == 0 && m_table8[1] == 255;
61 return m_table16[0] == 0 && m_table16[1] == 65535;
69 if (!m_table8.isEmpty() && !m_table16.isEmpty())
74 return (m_type == OneWay) || checkInvertibility();
79 if (!m_table8.isEmpty()) {
81 for (
uint i = 0;
i < m_tableSize; ++
i) {
82 if (m_table8[
i] <
val)
87 if (!m_table16.isEmpty()) {
89 for (
uint i = 0;
i < m_tableSize; ++
i) {
90 if (m_table16[
i] <
val)
102 x = std::clamp(
x, 0.0f, 1.0f);
103 x *= m_tableSize - 1;
104 const uint32_t lo =
static_cast<uint32_t
>(
x);
105 const uint32_t hi = std::min(lo + 1, m_tableSize - 1);
106 const float frac =
x - lo;
107 if (!m_table16.isEmpty())
108 return (m_table16[lo] + (m_table16[hi] - m_table16[lo]) * frac) * (1.0f/65535.0f);
109 if (!m_table8.isEmpty())
110 return (m_table8[lo] + (m_table8[hi] - m_table8[lo]) * frac) * (1.0f/255.0f);
117 Q_ASSERT(resultLargerThan >= 0.0f && resultLargerThan <= 1.0f);
123 if (!m_table16.isEmpty())
124 return inverseLookup(
x * 65535.0f, resultLargerThan, m_table16, m_tableSize - 1);
125 if (!m_table8.isEmpty())
126 return inverseLookup(
x * 255.0f, resultLargerThan, m_table8, m_tableSize - 1);
139 if (!m_table8.isEmpty() && (m_table8[0] != 0 || m_table8[m_tableSize - 1] != 255))
141 if (!m_table16.isEmpty() && (m_table16[0] != 0 || m_table16[m_tableSize - 1] != 65535))
143 if (m_tableSize == 2) {
148 if (m_tableSize == 26 && !m_table16.isEmpty()) {
150 if (m_table16[6] != 3062)
152 if (m_table16[12] != 12824)
154 if (m_table16[18] != 31237)
159 if (m_tableSize == 1024 && !m_table16.isEmpty()) {
161 if (m_table16[257] != 3366)
163 if (m_table16[513] != 14116)
165 if (m_table16[768] != 34318)
170 if (m_tableSize == 4096 && !m_table16.isEmpty()) {
172 if (m_table16[515] != 960)
174 if (m_table16[1025] != 3342)
176 if (m_table16[2051] != 14079)
187 uint32_t m_tableSize = 0;
192 static float inverseLookup(
float needle,
float resultLargerThan,
const QList<T> &
table,
quint32 tableMax)
194 uint32_t
i =
static_cast<uint32_t
>(resultLargerThan * tableMax);
195 auto it = std::lower_bound(
table.cbegin() +
i,
table.cend(), needle);
204 const float fr = (needle -
y1) / (
y2 -
y1);
205 return (
i + fr) * (1.0f / tableMax);
212 if (
t1.m_tableSize !=
t2.m_tableSize)
214 if (
t1.m_type !=
t2.m_type)
216 if (
t1.m_table8.isEmpty() !=
t2.m_table8.isEmpty())
218 if (
t1.m_table16.isEmpty() !=
t2.m_table16.isEmpty())
220 if (!
t1.m_table8.isEmpty()) {
221 for (uint32_t
i = 0;
i <
t1.m_tableSize; ++
i) {
222 if (
t1.m_table8[
i] !=
t2.m_table8[
i])
226 if (!
t1.m_table16.isEmpty()) {
227 for (uint32_t
i = 0;
i <
t1.m_tableSize; ++
i) {
228 if (
t1.m_table16[
i] !=
t2.m_table16[
i])
static QColorTransferFunction fromSRgb()
bool isEmpty() const noexcept
float applyInverse(float x, float resultLargerThan=0.0f) const
float apply(float x) const
QColorTransferTable(uint32_t size, const QList< uint16_t > &table, Type type=TwoWay) noexcept
QList< uint8_t > m_table8
QColorTransferTable() noexcept=default
bool checkValidity() const
QList< uint16_t > m_table16
bool checkInvertibility() const
bool asColorTransferFunction(QColorTransferFunction *transferFn)
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)
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)