Call QColorTransformPrivate::applyReturnGray directly

Change-Id: I03434d11cf0ee734b4c0300db9b675fe393ccfab
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Allan Sandfeld Jensen 2024-02-23 13:55:29 +01:00
parent d9b63c90bf
commit 3fc1adcda5
4 changed files with 15 additions and 29 deletions

View File

@ -1423,7 +1423,7 @@ static void convert_ARGB_to_gray8(QImageData *dest, const QImageData *src, Qt::I
for (int i = 0; i < src->height; ++i) {
const QRgb *src_line = reinterpret_cast<const QRgb *>(src_data);
tfd->apply(dest_data, src_line, src->width, flags);
tfd->applyReturnGray(dest_data, src_line, src->width, flags);
src_data += sbpl;
dest_data += dbpl;
}
@ -1460,7 +1460,7 @@ static void convert_ARGB_to_gray16(QImageData *dest, const QImageData *src, Qt::
const int len = std::min(src->width - j, BufferSize);
for (int k = 0; k < len; ++k)
tmp_line[k] = QRgba64::fromArgb32(src_line[j + k]);
tfd->apply(dest_line + j, tmp_line, len, flags);
tfd->applyReturnGray(dest_line + j, tmp_line, len, flags);
j += len;
}
src_data += sbpl;
@ -1497,7 +1497,7 @@ static void convert_RGBA64_to_gray8(QImageData *dest, const QImageData *src, Qt:
int j = 0;
while (j < src->width) {
const int len = std::min(src->width - j, BufferSize);
tfd->apply(gray_line, src_line + j, len, flags);
tfd->applyReturnGray(gray_line, src_line + j, len, flags);
for (int k = 0; k < len; ++k)
dest_line[j + k] = qt_div_257(gray_line[k]);
j += len;
@ -1532,7 +1532,7 @@ static void convert_RGBA64_to_gray16(QImageData *dest, const QImageData *src, Qt
for (int i = 0; i < src->height; ++i) {
const QRgba64 *src_line = reinterpret_cast<const QRgba64 *>(src_data);
quint16 *dest_line = reinterpret_cast<quint16 *>(dest_data);
tfd->apply(dest_line, src_line, src->width, flags);
tfd->applyReturnGray(dest_line, src_line, src->width, flags);
src_data += sbpl;
dest_data += dbpl;
}

View File

@ -1254,6 +1254,11 @@ void QColorTransformPrivate::apply(T *dst, const T *src, qsizetype count, Transf
}
}
/*!
\internal
Is to be called on a color-transform to XYZ, returns only luminance values.
*/
template<typename D, typename S>
void QColorTransformPrivate::applyReturnGray(D *dst, const S *src, qsizetype count, TransformFlags flags) const
{
@ -1358,26 +1363,9 @@ void QColorTransformPrivate::apply(QRgbaFloat32 *dst, const QRgbaFloat32 *src, q
apply<QRgbaFloat32>(dst, src, count, flags);
}
/*!
\internal
Is to be called on a color-transform to XYZ, returns only luminance values.
*/
void QColorTransformPrivate::apply(quint8 *dst, const QRgb *src, qsizetype count, TransformFlags flags) const
{
applyReturnGray<quint8, QRgb>(dst, src, count, flags);
}
/*!
\internal
Is to be called on a color-transform to XYZ, returns only luminance values.
*/
void QColorTransformPrivate::apply(quint16 *dst, const QRgba64 *src, qsizetype count, TransformFlags flags) const
{
applyReturnGray<quint16, QRgba64>(dst, src, count, flags);
}
template void QColorTransformPrivate::applyReturnGray<quint8, QRgb>(quint8 *dst, const QRgb *src, qsizetype count, TransformFlags flags) const;
template void QColorTransformPrivate::applyReturnGray<quint16, QRgba64>(quint16 *dst, const QRgba64 *src, qsizetype count, TransformFlags flags) const;
/*!
\internal

View File

@ -51,8 +51,6 @@ public:
void apply(QRgba64 *dst, const QRgba64 *src, qsizetype count, TransformFlags flags = Unpremultiplied) const;
void apply(QRgbaFloat32 *dst, const QRgbaFloat32 *src, qsizetype count,
TransformFlags flags = Unpremultiplied) const;
void apply(quint8 *dst, const QRgb *src, qsizetype count, TransformFlags flags = Unpremultiplied) const;
void apply(quint16 *dst, const QRgba64 *src, qsizetype count, TransformFlags flags = Unpremultiplied) const;
template<typename T>
void apply(T *dst, const T *src, qsizetype count, TransformFlags flags) const;

View File

@ -629,7 +629,7 @@ static void QT_FASTCALL destStoreGray8(QRasterBuffer *rasterBuffer, int x, int y
QColorTransform tf = QColorSpacePrivate::get(fromCS)->transformationToXYZ();
QColorTransformPrivate *tfd = QColorTransformPrivate::get(tf);
tfd->apply(data, buffer, length, QColorTransformPrivate::InputPremultiplied);
tfd->applyReturnGray(data, buffer, length, QColorTransformPrivate::InputPremultiplied);
}
}
@ -653,7 +653,7 @@ static void QT_FASTCALL destStoreGray16(QRasterBuffer *rasterBuffer, int x, int
QRgba64 tmp_line[BufferSize];
for (int k = 0; k < length; ++k)
tmp_line[k] = QRgba64::fromArgb32(buffer[k]);
tfd->apply(data, tmp_line, length, QColorTransformPrivate::InputPremultiplied);
tfd->applyReturnGray(data, tmp_line, length, QColorTransformPrivate::InputPremultiplied);
}
}
@ -731,7 +731,7 @@ static void QT_FASTCALL destStore64Gray8(QRasterBuffer *rasterBuffer, int x, int
QColorTransformPrivate *tfd = QColorTransformPrivate::get(tf);
quint16 gray_line[BufferSize];
tfd->apply(gray_line, buffer, length, QColorTransformPrivate::InputPremultiplied);
tfd->applyReturnGray(gray_line, buffer, length, QColorTransformPrivate::InputPremultiplied);
for (int k = 0; k < length; ++k)
data[k] = qt_div_257(gray_line[k]);
}
@ -753,7 +753,7 @@ static void QT_FASTCALL destStore64Gray16(QRasterBuffer *rasterBuffer, int x, in
QColorSpace fromCS = rasterBuffer->colorSpace.isValid() ? rasterBuffer->colorSpace : QColorSpace::SRgb;
QColorTransform tf = QColorSpacePrivate::get(fromCS)->transformationToXYZ();
QColorTransformPrivate *tfd = QColorTransformPrivate::get(tf);
tfd->apply(data, buffer, length, QColorTransformPrivate::InputPremultiplied);
tfd->applyReturnGray(data, buffer, length, QColorTransformPrivate::InputPremultiplied);
}
}