4#ifndef QCOLORTRCLUT_P_H
5#define QCOLORTRCLUT_P_H
18#include <QtGui/private/qtguiglobal_p.h>
19#include <QtGui/qrgb.h>
20#include <QtGui/qrgba64.h>
27#elif defined(__ARM_NEON__) || defined(__ARM_NEON)
39 static std::shared_ptr<QColorTrcLut> fromGamma(
qreal gamma);
41 static std::shared_ptr<QColorTrcLut> fromTransferTable(
const QColorTransferTable &transTable);
48 __m128i
v = _mm_cvtsi32_si128(rgb32);
49 v = _mm_unpacklo_epi8(
v, _mm_setzero_si128());
50 const __m128i vidx = _mm_slli_epi16(
v, 4);
51 const int ridx = _mm_extract_epi16(vidx, 2);
52 const int gidx = _mm_extract_epi16(vidx, 1);
53 const int bidx = _mm_extract_epi16(vidx, 0);
54 v = _mm_slli_epi16(
v, 8);
55 v = _mm_insert_epi16(
v, m_toLinear[ridx], 0);
56 v = _mm_insert_epi16(
v, m_toLinear[gidx], 1);
57 v = _mm_insert_epi16(
v, m_toLinear[bidx], 2);
58 v = _mm_add_epi16(
v, _mm_srli_epi16(
v, 8));
60 _mm_storel_epi64(
reinterpret_cast<__m128i *
>(&rgba64),
v);
62#elif (defined(__ARM_NEON__) || defined(__ARM_NEON)) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN
63 uint8x8_t v8 = vreinterpret_u8_u32(vmov_n_u32(rgb32));
64 uint16x4_t v16 = vget_low_u16(vmovl_u8(v8));
65 const uint16x4_t vidx = vshl_n_u16(v16, 4);
66 const int ridx = vget_lane_u16(vidx, 2);
67 const int gidx = vget_lane_u16(vidx, 1);
68 const int bidx = vget_lane_u16(vidx, 0);
69 v16 = vshl_n_u16(v16, 8);
70 v16 = vset_lane_u16(m_toLinear[ridx], v16, 0);
71 v16 = vset_lane_u16(m_toLinear[gidx], v16, 1);
72 v16 = vset_lane_u16(m_toLinear[bidx], v16, 2);
73 v16 = vadd_u16(v16, vshr_n_u16(v16, 8));
89 return convertWithTable(rgb32, m_toLinear);
94 return convertWithTable(rgb64, m_toLinear);
100 return v * (1.0f / (255*256));
107 return v * (1.0f / (255*256));
112 ushort v = m_toLinear[(int)(
f * (255 * 16) + 0.5f)];
113 return v * (1.0f / (255*256));
119 __m128i
v = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(&rgb64));
120 v = _mm_sub_epi16(
v, _mm_srli_epi16(
v, 8));
121 const __m128i vidx = _mm_srli_epi16(
v, 4);
122 const int ridx = _mm_extract_epi16(vidx, 0);
123 const int gidx = _mm_extract_epi16(vidx, 1);
124 const int bidx = _mm_extract_epi16(vidx, 2);
125 v = _mm_insert_epi16(
v, m_fromLinear[ridx], 2);
126 v = _mm_insert_epi16(
v, m_fromLinear[gidx], 1);
127 v = _mm_insert_epi16(
v, m_fromLinear[bidx], 0);
128 v = _mm_add_epi16(
v, _mm_set1_epi16(0x80));
129 v = _mm_srli_epi16(
v, 8);
130 v = _mm_packus_epi16(
v,
v);
131 return _mm_cvtsi128_si32(
v);
132#elif (defined(__ARM_NEON__) || defined(__ARM_NEON)) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN
133 uint16x4_t
v = vreinterpret_u16_u64(vmov_n_u64(rgb64));
134 v = vsub_u16(
v, vshr_n_u16(
v, 8));
135 const uint16x4_t vidx = vshr_n_u16(
v, 4);
136 const int ridx = vget_lane_u16(vidx, 0);
137 const int gidx = vget_lane_u16(vidx, 1);
138 const int bidx = vget_lane_u16(vidx, 2);
139 v = vset_lane_u16(m_fromLinear[ridx],
v, 2);
140 v = vset_lane_u16(m_fromLinear[gidx],
v, 1);
141 v = vset_lane_u16(m_fromLinear[bidx],
v, 0);
142 uint8x8_t v8 = vrshrn_n_u16(vcombine_u16(
v,
v), 8);
143 return vget_lane_u32(vreinterpret_u32_u8(v8), 0);
154 r = (m_fromLinear[
r >> 4] + 0x80) >> 8;
155 g = (m_fromLinear[
g >> 4] + 0x80) >> 8;
156 b = (m_fromLinear[
b >> 4] + 0x80) >> 8;
157 return (
a << 24) | (
r << 16) | (
g << 8) |
b;
163 return convertWithTable(rgb32, m_fromLinear);
168 return convertWithTable(rgb64, m_fromLinear);
173 ushort v = m_fromLinear[(int)(
f * (255 * 16) + 0.5f)];
174 return (
v + 0x80) >> 8;
178 ushort v = m_fromLinear[(int)(
f * (255 * 16) + 0.5f)];
183 ushort v = m_fromLinear[(int)(
f * (255 * 16) + 0.5f)];
184 return v * (1.0f / (255*256));
197 static std::shared_ptr<QColorTrcLut>
create();
201 const int r = (
table[
qRed(rgb32) << 4] + 0x80) >> 8;
203 const int b = (
table[
qBlue(rgb32) << 4] + 0x80) >> 8;
204 return (rgb32 & 0xff000000) | (
r << 16) | (
g << 8) |
b;
209 __m128i
v = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(&rgb64));
210 v = _mm_sub_epi16(
v, _mm_srli_epi16(
v, 8));
211 const __m128i vidx = _mm_srli_epi16(
v, 4);
212 const int ridx = _mm_extract_epi16(vidx, 2);
213 const int gidx = _mm_extract_epi16(vidx, 1);
214 const int bidx = _mm_extract_epi16(vidx, 0);
215 v = _mm_insert_epi16(
v,
table[ridx], 2);
216 v = _mm_insert_epi16(
v,
table[gidx], 1);
217 v = _mm_insert_epi16(
v,
table[bidx], 0);
218 v = _mm_add_epi16(
v, _mm_srli_epi16(
v, 8));
220 _mm_storel_epi64(
reinterpret_cast<__m128i *
>(&rgba64),
v);
222#elif (defined(__ARM_NEON__) || defined(__ARM_NEON)) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN
223 uint16x4_t
v = vreinterpret_u16_u64(vmov_n_u64(rgb64));
224 v = vsub_u16(
v, vshr_n_u16(
v, 8));
225 const uint16x4_t vidx = vshr_n_u16(
v, 4);
226 const int ridx = vget_lane_u16(vidx, 2);
227 const int gidx = vget_lane_u16(vidx, 1);
228 const int bidx = vget_lane_u16(vidx, 0);
229 v = vset_lane_u16(
table[ridx],
v, 2);
230 v = vset_lane_u16(
table[gidx],
v, 1);
231 v = vset_lane_u16(
table[bidx],
v, 0);
232 v = vadd_u16(
v, vshr_n_u16(
v, 8));
int u16FromLinearF32(float f) const
int u8FromLinearF32(float f) const
float toLinear(float f) const
float u8ToLinearF32(int c) const
QRgb toLinear(QRgb rgb32) const
QRgb fromLinear(QRgb rgb32) const
QRgba64 toLinear(QRgba64 rgb64) const
float fromLinear(float f) const
QRgb fromLinear64(QRgba64 rgb64) const
float u16ToLinearF32(int c) const
QRgba64 fromLinear(QRgba64 rgb64) const
QRgba64 toLinear64(QRgb rgb32) const
QRgba64 toLinear64(QRgba64) const =delete
constexpr quint16 red() const
constexpr quint16 alpha() const
constexpr quint16 green() const
constexpr quint16 blue() const
static constexpr QRgba64 fromRgba64(quint64 c)
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLenum GLsizei void * table
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
constexpr int qRed(QRgb rgb)
constexpr int qGreen(QRgb rgb)
constexpr int qBlue(QRgb rgb)
constexpr int qAlpha(QRgb rgb)