QtGui: fix build with GCC 13's support for FP16
Conversion must be explicit from float, but doesn't need to be from int. qimage.cpp:1915:33: error: converting to ‘qfloat16::NativeType’ {aka ‘_Float16’} from ‘float’ with greater conversion rank [-Werror] Change-Id: Ide4dbd0777a44ed0870efffd17390a0e86f1fd7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 03b72188f45e72d313f8af2e16cb7067b6084f99) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
636fe7beb6
commit
384528cbdb
@ -1912,7 +1912,7 @@ void QImage::fill(const QColor &color)
|
||||
if (!hasAlphaChannel())
|
||||
a = 1.0f;
|
||||
if (depth() == 64) {
|
||||
QRgbaFloat16 c16{r, g, b, a};
|
||||
QRgbaFloat16 c16{qfloat16(r), qfloat16(g), qfloat16(b), qfloat16(a)};
|
||||
if (d->format == Format_RGBA16FPx4_Premultiplied)
|
||||
c16 = c16.premultiplied();
|
||||
qt_rectfill<QRgbaFloat16>(reinterpret_cast<QRgbaFloat16 *>(d->data), c16,
|
||||
@ -1998,11 +1998,11 @@ void QImage::invertPixels(InvertMode mode)
|
||||
qfloat16 *p = reinterpret_cast<qfloat16 *>(d->data);
|
||||
qfloat16 *end = reinterpret_cast<qfloat16 *>(d->data + d->nbytes);
|
||||
while (p < end) {
|
||||
p[0] = 1.0f - p[0];
|
||||
p[1] = 1.0f - p[1];
|
||||
p[2] = 1.0f - p[2];
|
||||
p[0] = qfloat16(1) - p[0];
|
||||
p[1] = qfloat16(1) - p[1];
|
||||
p[2] = qfloat16(1) - p[2];
|
||||
if (mode == InvertRgba)
|
||||
p[3] = 1.0f - p[3];
|
||||
p[3] = qfloat16(1) - p[3];
|
||||
p += 4;
|
||||
}
|
||||
} else if (format() >= QImage::Format_RGBX32FPx4 && format() <= QImage::Format_RGBA32FPx4_Premultiplied) {
|
||||
@ -2805,7 +2805,7 @@ void QImage::setPixelColor(int x, int y, const QColor &color)
|
||||
color.getRgbF(&r, &g, &b, &a);
|
||||
if (d->format == Format_RGBX16FPx4)
|
||||
a = 1.0f;
|
||||
QRgbaFloat16 c16f{r, g, b, a};
|
||||
QRgbaFloat16 c16f{qfloat16(r), qfloat16(g), qfloat16(b), qfloat16(a)};
|
||||
if (d->format == Format_RGBA16FPx4_Premultiplied)
|
||||
c16f = c16f.premultiplied();
|
||||
((QRgbaFloat16 *)s)[x] = c16f;
|
||||
|
@ -1483,7 +1483,7 @@ void QColor::setAlpha(int alpha)
|
||||
QCOLOR_INT_RANGE_CHECK("QColor::setAlpha", alpha);
|
||||
if (cspec == ExtendedRgb) {
|
||||
constexpr float f = 1.0f / 255;
|
||||
castF16(ct.argbExtended.alphaF16) = alpha * f;
|
||||
castF16(ct.argbExtended.alphaF16) = qfloat16(alpha * f);
|
||||
return;
|
||||
}
|
||||
ct.argb.alpha = alpha * 0x101;
|
||||
@ -1512,7 +1512,7 @@ void QColor::setAlphaF(float alpha)
|
||||
{
|
||||
QCOLOR_REAL_RANGE_CHECK("QColor::setAlphaF", alpha);
|
||||
if (cspec == ExtendedRgb) {
|
||||
castF16(ct.argbExtended.alphaF16) = alpha;
|
||||
castF16(ct.argbExtended.alphaF16) = qfloat16(alpha);
|
||||
return;
|
||||
}
|
||||
float tmp = alpha * USHRT_MAX;
|
||||
@ -1630,7 +1630,7 @@ void QColor::setRedF(float red)
|
||||
if (cspec == Rgb && red >= 0.0f && red <= 1.0f)
|
||||
ct.argb.red = qRound(red * USHRT_MAX);
|
||||
else if (cspec == ExtendedRgb)
|
||||
castF16(ct.argbExtended.redF16) = red;
|
||||
castF16(ct.argbExtended.redF16) = qfloat16(red);
|
||||
else
|
||||
setRgbF(red, greenF(), blueF(), alphaF());
|
||||
}
|
||||
@ -1662,7 +1662,7 @@ void QColor::setGreenF(float green)
|
||||
if (cspec == Rgb && green >= 0.0f && green <= 1.0f)
|
||||
ct.argb.green = qRound(green * USHRT_MAX);
|
||||
else if (cspec == ExtendedRgb)
|
||||
castF16(ct.argbExtended.greenF16) = green;
|
||||
castF16(ct.argbExtended.greenF16) = qfloat16(green);
|
||||
else
|
||||
setRgbF(redF(), green, blueF(), alphaF());
|
||||
}
|
||||
@ -1692,7 +1692,7 @@ void QColor::setBlueF(float blue)
|
||||
if (cspec == Rgb && blue >= 0.0f && blue <= 1.0f)
|
||||
ct.argb.blue = qRound(blue * USHRT_MAX);
|
||||
else if (cspec == ExtendedRgb)
|
||||
castF16(ct.argbExtended.blueF16) = blue;
|
||||
castF16(ct.argbExtended.blueF16) = qfloat16(blue);
|
||||
else
|
||||
setRgbF(redF(), greenF(), blue, alphaF());
|
||||
}
|
||||
|
@ -237,9 +237,9 @@ QRgbaFloat16 QColorTransform::map(QRgbaFloat16 rgbafp16) const
|
||||
c.y = d->colorSpaceIn->trc[1].applyExtended(rgbafp16.g);
|
||||
c.z = d->colorSpaceIn->trc[2].applyExtended(rgbafp16.b);
|
||||
c = d->colorMatrix.map(c);
|
||||
rgbafp16.r = d->colorSpaceOut->trc[0].applyInverseExtended(c.x);
|
||||
rgbafp16.g = d->colorSpaceOut->trc[1].applyInverseExtended(c.y);
|
||||
rgbafp16.b = d->colorSpaceOut->trc[2].applyInverseExtended(c.z);
|
||||
rgbafp16.r = qfloat16(d->colorSpaceOut->trc[0].applyInverseExtended(c.x));
|
||||
rgbafp16.g = qfloat16(d->colorSpaceOut->trc[1].applyInverseExtended(c.y));
|
||||
rgbafp16.b = qfloat16(d->colorSpaceOut->trc[2].applyInverseExtended(c.z));
|
||||
return rgbafp16;
|
||||
}
|
||||
|
||||
|
@ -2226,7 +2226,7 @@ static void QT_FASTCALL storeRGBX16FFromRGBA32F(uchar *dest, const QRgbaFloat32
|
||||
QRgbaFloat16 *d = reinterpret_cast<QRgbaFloat16 *>(dest) + index;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto s = src[i].unpremultiplied();
|
||||
d[i] = QRgbaFloat16{ s.r, s.g, s.b, 1.0f };
|
||||
d[i] = QRgbaFloat16{ qfloat16(s.r), qfloat16(s.g), qfloat16(s.b), qfloat16(1.0f) };
|
||||
}
|
||||
}
|
||||
|
||||
@ -2236,7 +2236,7 @@ static void QT_FASTCALL storeRGBA16FFromRGBA32F(uchar *dest, const QRgbaFloat32
|
||||
QRgbaFloat16 *d = reinterpret_cast<QRgbaFloat16 *>(dest) + index;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto s = src[i].unpremultiplied();
|
||||
d[i] = QRgbaFloat16{ s.r, s.g, s.b, s.a };
|
||||
d[i] = QRgbaFloat16{ qfloat16(s.r), qfloat16(s.g), qfloat16(s.b), qfloat16(s.a) };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,21 +28,23 @@ public:
|
||||
static constexpr
|
||||
QRgbaFloat fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha)
|
||||
{
|
||||
constexpr FastType scale = 1.0f / 65535.0f;
|
||||
return QRgbaFloat{
|
||||
red * (1.0f / 65535.0f),
|
||||
green * (1.0f / 65535.0f),
|
||||
blue * (1.0f / 65535.0f),
|
||||
alpha * (1.0f / 65535.0f) };
|
||||
F(red * scale),
|
||||
F(green * scale),
|
||||
F(blue * scale),
|
||||
F(alpha * scale) };
|
||||
}
|
||||
|
||||
static constexpr
|
||||
QRgbaFloat fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha)
|
||||
{
|
||||
constexpr FastType scale = 1.0f / 255.0f;
|
||||
return QRgbaFloat{
|
||||
red * (1.0f / 255.0f),
|
||||
green * (1.0f / 255.0f),
|
||||
blue * (1.0f / 255.0f),
|
||||
alpha * (1.0f / 255.0f) };
|
||||
F(red * scale),
|
||||
F(green * scale),
|
||||
F(blue * scale),
|
||||
F(alpha * scale) };
|
||||
}
|
||||
static constexpr
|
||||
QRgbaFloat fromArgb32(uint rgb)
|
||||
@ -57,10 +59,10 @@ public:
|
||||
constexpr FastType green() const { return g; }
|
||||
constexpr FastType blue() const { return b; }
|
||||
constexpr FastType alpha() const { return a; }
|
||||
void setRed(FastType _red) { r = _red; }
|
||||
void setGreen(FastType _green) { g = _green; }
|
||||
void setBlue(FastType _blue) { b = _blue; }
|
||||
void setAlpha(FastType _alpha) { a = _alpha; }
|
||||
void setRed(FastType _red) { r = F(_red); }
|
||||
void setGreen(FastType _green) { g = F(_green); }
|
||||
void setBlue(FastType _blue) { b = F(_blue); }
|
||||
void setAlpha(FastType _alpha) { a = F(_alpha); }
|
||||
|
||||
constexpr FastType redNormalized() const { return std::clamp(static_cast<FastType>(r), 0.0f, 1.0f); }
|
||||
constexpr FastType greenNormalized() const { return std::clamp(static_cast<FastType>(g), 0.0f, 1.0f); }
|
||||
@ -87,12 +89,12 @@ public:
|
||||
}
|
||||
constexpr Q_ALWAYS_INLINE QRgbaFloat unpremultiplied() const
|
||||
{
|
||||
if (a <= 0.0f)
|
||||
return QRgbaFloat{0.0f, 0.0f, 0.0f, 0.0f};
|
||||
if (a >= 1.0f)
|
||||
if (a <= F{0.0f})
|
||||
return QRgbaFloat{}; // default-initialization: zeroes
|
||||
if (a >= F{1.0f})
|
||||
return *this;
|
||||
const FastType ia = 1.0f / a;
|
||||
return QRgbaFloat{r * ia, g * ia, b * ia, a};
|
||||
return QRgbaFloat{F(r * ia), F(g * ia), F(b * ia), F(a)};
|
||||
}
|
||||
constexpr bool operator==(QRgbaFloat f) const
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user