Removed image format specific template functions in raster engine.
Simplified the raster engine by treating image formats in a more generic way and removed some unused code. Change-Id: Ib3979a1a6e3e6f17c5002248545779ec36fff7c9 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>bb10
parent
fe2344bd44
commit
ba1cf5dae3
|
|
@ -74,30 +74,6 @@ static inline bool isLocked(QImageData *data)
|
|||
return data != 0 && data->is_locked;
|
||||
}
|
||||
|
||||
static inline bool checkPixelSize(const QImage::Format format)
|
||||
{
|
||||
switch (format) {
|
||||
case QImage::Format_ARGB8565_Premultiplied:
|
||||
return (sizeof(qargb8565) == 3);
|
||||
case QImage::Format_RGB666:
|
||||
return (sizeof(qrgb666) == 3);
|
||||
case QImage::Format_ARGB6666_Premultiplied:
|
||||
return (sizeof(qargb6666) == 3);
|
||||
case QImage::Format_RGB555:
|
||||
return (sizeof(qrgb555) == 2);
|
||||
case QImage::Format_ARGB8555_Premultiplied:
|
||||
return (sizeof(qargb8555) == 3);
|
||||
case QImage::Format_RGB888:
|
||||
return (sizeof(qrgb888) == 3);
|
||||
case QImage::Format_RGB444:
|
||||
return (sizeof(qrgb444) == 2);
|
||||
case QImage::Format_ARGB4444_Premultiplied:
|
||||
return (sizeof(qargb4444) == 2);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001)
|
||||
#pragma message disable narrowptr
|
||||
#endif
|
||||
|
|
@ -141,12 +117,6 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu
|
|||
if (!size.isValid() || numColors < 0 || format == QImage::Format_Invalid)
|
||||
return 0; // invalid parameter(s)
|
||||
|
||||
if (!checkPixelSize(format)) {
|
||||
qWarning("QImageData::create(): Invalid pixel size for format %i",
|
||||
format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint width = size.width();
|
||||
uint height = size.height();
|
||||
uint depth = qt_depthForFormat(format);
|
||||
|
|
@ -793,12 +763,6 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm
|
|||
if (format == QImage::Format_Invalid)
|
||||
return d;
|
||||
|
||||
if (!checkPixelSize(format)) {
|
||||
qWarning("QImageData::create(): Invalid pixel size for format %i",
|
||||
format);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int depth = qt_depthForFormat(format);
|
||||
const int calc_bytes_per_line = ((width * depth + 31)/32) * 4;
|
||||
const int min_bytes_per_line = (width * depth + 7)/8;
|
||||
|
|
@ -1708,9 +1672,8 @@ void QImage::fill(const QColor &color)
|
|||
pixel = PREMUL(pixel);
|
||||
fill((uint) pixel);
|
||||
|
||||
} else if (d->depth == 16 && d->format == QImage::Format_RGB16) {
|
||||
qrgb565 p(color.rgba());
|
||||
fill((uint) p.rawValue());
|
||||
} else if (d->format == QImage::Format_RGB16) {
|
||||
fill((uint) qConvertRgb32To16(color.rgba()));
|
||||
|
||||
} else if (d->depth == 1) {
|
||||
if (color == Qt::color1)
|
||||
|
|
@ -2025,12 +1988,12 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers
|
|||
quint16 colorTableRGB16[256];
|
||||
if (data->colortable.isEmpty()) {
|
||||
for (int i = 0; i < 256; ++i)
|
||||
colorTableRGB16[i] = qt_colorConvert<quint16, quint32>(qRgb(i, i, i), 0);
|
||||
colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i));
|
||||
} else {
|
||||
// 1) convert the existing colors to RGB16
|
||||
const int tableSize = data->colortable.size();
|
||||
for (int i = 0; i < tableSize; ++i)
|
||||
colorTableRGB16[i] = qt_colorConvert<quint16, quint32>(data->colortable.at(i), 0);
|
||||
colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i));
|
||||
data->colortable = QVector<QRgb>();
|
||||
|
||||
// 2) fill the rest of the table in case src_data > colortable.size()
|
||||
|
|
@ -2068,7 +2031,8 @@ static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFl
|
|||
quint16 *dst_data = (quint16 *) data->data;
|
||||
|
||||
for (int i = 0; i < data->height; ++i) {
|
||||
qt_memconvert(dst_data, src_data, data->width);
|
||||
for (int j = 0; j < data->width; ++j)
|
||||
dst_data[j] = qConvertRgb32To16(src_data[j]);
|
||||
src_data = (quint32 *) (((char*)src_data) + src_bytes_per_line);
|
||||
dst_data = (quint16 *) (((char*)dst_data) + dst_bytes_per_line);
|
||||
}
|
||||
|
|
@ -2878,60 +2842,33 @@ static void convert_Mono_to_Indexed8(QImageData *dest, const QImageData *src, Qt
|
|||
}
|
||||
}
|
||||
|
||||
#define CONVERT_DECL(DST, SRC) \
|
||||
static void convert_##SRC##_to_##DST(QImageData *dest, \
|
||||
const QImageData *src, \
|
||||
Qt::ImageConversionFlags) \
|
||||
{ \
|
||||
qt_rectconvert<DST, SRC>(reinterpret_cast<DST*>(dest->data), \
|
||||
reinterpret_cast<const SRC*>(src->data), \
|
||||
0, 0, src->width, src->height, \
|
||||
dest->bytes_per_line, src->bytes_per_line); \
|
||||
// Cannot be used with indexed formats.
|
||||
static void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
|
||||
{
|
||||
const int buffer_size = 2048;
|
||||
uint buffer[buffer_size];
|
||||
const QPixelLayout *srcLayout = &qPixelLayouts[src->format];
|
||||
const QPixelLayout *destLayout = &qPixelLayouts[dest->format];
|
||||
const uchar *srcData = src->data;
|
||||
uchar *destData = dest->data;
|
||||
|
||||
FetchPixelsFunc fetch = qFetchPixels[srcLayout->bpp];
|
||||
StorePixelsFunc store = qStorePixels[destLayout->bpp];
|
||||
|
||||
for (int y = 0; y < src->height; ++y) {
|
||||
int x = 0;
|
||||
while (x < src->width) {
|
||||
int l = qMin(src->width - x, buffer_size);
|
||||
const uint *ptr = fetch(buffer, srcData, x, l);
|
||||
ptr = srcLayout->convertToARGB32PM(buffer, ptr, l, srcLayout, 0);
|
||||
ptr = destLayout->convertFromARGB32PM(buffer, ptr, l, destLayout, 0);
|
||||
store(destData, ptr, x, l);
|
||||
x += l;
|
||||
}
|
||||
srcData += src->bytes_per_line;
|
||||
destData += dest->bytes_per_line;
|
||||
}
|
||||
|
||||
CONVERT_DECL(quint32, quint16)
|
||||
CONVERT_DECL(quint16, quint32)
|
||||
CONVERT_DECL(quint32, qargb8565)
|
||||
CONVERT_DECL(qargb8565, quint32)
|
||||
CONVERT_DECL(quint32, qrgb555)
|
||||
CONVERT_DECL(qrgb666, quint32)
|
||||
CONVERT_DECL(quint32, qrgb666)
|
||||
CONVERT_DECL(qargb6666, quint32)
|
||||
CONVERT_DECL(quint32, qargb6666)
|
||||
CONVERT_DECL(qrgb555, quint32)
|
||||
#if (defined(QT_QWS_DEPTH_15) && defined(QT_QWS_DEPTH_16))
|
||||
CONVERT_DECL(quint16, qrgb555)
|
||||
CONVERT_DECL(qrgb555, quint16)
|
||||
#endif
|
||||
CONVERT_DECL(quint32, qrgb888)
|
||||
CONVERT_DECL(qrgb888, quint32)
|
||||
CONVERT_DECL(quint32, qargb8555)
|
||||
CONVERT_DECL(qargb8555, quint32)
|
||||
CONVERT_DECL(quint32, qrgb444)
|
||||
CONVERT_DECL(qrgb444, quint32)
|
||||
CONVERT_DECL(quint32, qargb4444)
|
||||
CONVERT_DECL(qargb4444, quint32)
|
||||
#undef CONVERT_DECL
|
||||
#define CONVERT_PTR(DST, SRC) convert_##SRC##_to_##DST
|
||||
|
||||
/*
|
||||
Format_Invalid,
|
||||
Format_Mono,
|
||||
Format_MonoLSB,
|
||||
Format_Indexed8,
|
||||
Format_RGB32,
|
||||
Format_ARGB32,
|
||||
Format_ARGB32_Premultiplied,
|
||||
Format_RGB16,
|
||||
Format_ARGB8565_Premultiplied,
|
||||
Format_RGB666,
|
||||
Format_ARGB6666_Premultiplied,
|
||||
Format_RGB555,
|
||||
Format_ARGB8555_Premultiplied,
|
||||
Format_RGB888
|
||||
Format_RGB444
|
||||
Format_ARGB4444_Premultiplied
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
// first index source, second dest
|
||||
|
|
@ -3005,15 +2942,15 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
mask_alpha_converter,
|
||||
mask_alpha_converter,
|
||||
CONVERT_PTR(quint16, quint32),
|
||||
CONVERT_PTR(qargb8565, quint32),
|
||||
CONVERT_PTR(qrgb666, quint32),
|
||||
CONVERT_PTR(qargb6666, quint32),
|
||||
CONVERT_PTR(qrgb555, quint32),
|
||||
CONVERT_PTR(qargb8555, quint32),
|
||||
CONVERT_PTR(qrgb888, quint32),
|
||||
CONVERT_PTR(qrgb444, quint32),
|
||||
CONVERT_PTR(qargb4444, quint32)
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic
|
||||
}, // Format_RGB32
|
||||
|
||||
{
|
||||
|
|
@ -3024,15 +2961,15 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
mask_alpha_converter,
|
||||
0,
|
||||
convert_ARGB_to_ARGB_PM,
|
||||
CONVERT_PTR(quint16, quint32),
|
||||
CONVERT_PTR(qargb8565, quint32),
|
||||
CONVERT_PTR(qrgb666, quint32),
|
||||
CONVERT_PTR(qargb6666, quint32),
|
||||
CONVERT_PTR(qrgb555, quint32),
|
||||
CONVERT_PTR(qargb8555, quint32),
|
||||
CONVERT_PTR(qrgb888, quint32),
|
||||
CONVERT_PTR(qrgb444, quint32),
|
||||
CONVERT_PTR(qargb4444, quint32)
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic
|
||||
}, // Format_ARGB32
|
||||
|
||||
{
|
||||
|
|
@ -3059,15 +2996,15 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, quint16),
|
||||
CONVERT_PTR(quint32, quint16),
|
||||
CONVERT_PTR(quint32, quint16),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
#if defined(QT_QWS_DEPTH_15) && defined(QT_QWS_DEPTH_16)
|
||||
CONVERT_PTR(qrgb555, quint16),
|
||||
convert_generic,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
|
|
@ -3082,9 +3019,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, qargb8565),
|
||||
CONVERT_PTR(quint32, qargb8565),
|
||||
CONVERT_PTR(quint32, qargb8565),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -3101,9 +3038,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, qrgb666),
|
||||
CONVERT_PTR(quint32, qrgb666),
|
||||
CONVERT_PTR(quint32, qrgb666),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -3120,9 +3057,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, qargb6666),
|
||||
CONVERT_PTR(quint32, qargb6666),
|
||||
CONVERT_PTR(quint32, qargb6666),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -3139,11 +3076,11 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, qrgb555),
|
||||
CONVERT_PTR(quint32, qrgb555),
|
||||
CONVERT_PTR(quint32, qrgb555),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
#if defined(QT_QWS_DEPTH_15) && defined(QT_QWS_DEPTH_16)
|
||||
CONVERT_PTR(quint16, qrgb555),
|
||||
convert_generic,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
|
|
@ -3162,9 +3099,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, qargb8555),
|
||||
CONVERT_PTR(quint32, qargb8555),
|
||||
CONVERT_PTR(quint32, qargb8555),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -3181,9 +3118,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, qrgb888),
|
||||
CONVERT_PTR(quint32, qrgb888),
|
||||
CONVERT_PTR(quint32, qrgb888),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -3200,9 +3137,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, qrgb444),
|
||||
CONVERT_PTR(quint32, qrgb444),
|
||||
CONVERT_PTR(quint32, qrgb444),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -3219,9 +3156,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
CONVERT_PTR(quint32, qargb4444),
|
||||
CONVERT_PTR(quint32, qargb4444),
|
||||
CONVERT_PTR(quint32, qargb4444),
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
convert_generic,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
|
@ -3626,35 +3563,28 @@ QRgb QImage::pixel(int x, int y) const
|
|||
qWarning("QImage::pixel: coordinate (%d,%d) out of range", x, y);
|
||||
return 12345;
|
||||
}
|
||||
const uchar * s = scanLine(y);
|
||||
|
||||
const uchar * s = constScanLine(y);
|
||||
switch(d->format) {
|
||||
case Format_Mono:
|
||||
return d->colortable.at((*(s + (x >> 3)) >> (7- (x & 7))) & 1);
|
||||
return d->colortable.at((*(s + (x >> 3)) >> (~x & 7)) & 1);
|
||||
case Format_MonoLSB:
|
||||
return d->colortable.at((*(s + (x >> 3)) >> (x & 7)) & 1);
|
||||
case Format_Indexed8:
|
||||
return d->colortable.at((int)s[x]);
|
||||
case Format_ARGB8565_Premultiplied:
|
||||
return qt_colorConvert<quint32, qargb8565>(reinterpret_cast<const qargb8565*>(s)[x], 0);
|
||||
case Format_RGB666:
|
||||
return qt_colorConvert<quint32, qrgb666>(reinterpret_cast<const qrgb666*>(s)[x], 0);
|
||||
case Format_ARGB6666_Premultiplied:
|
||||
return qt_colorConvert<quint32, qargb6666>(reinterpret_cast<const qargb6666*>(s)[x], 0);
|
||||
case Format_RGB555:
|
||||
return qt_colorConvert<quint32, qrgb555>(reinterpret_cast<const qrgb555*>(s)[x], 0);
|
||||
case Format_ARGB8555_Premultiplied:
|
||||
return qt_colorConvert<quint32, qargb8555>(reinterpret_cast<const qargb8555*>(s)[x], 0);
|
||||
case Format_RGB888:
|
||||
return qt_colorConvert<quint32, qrgb888>(reinterpret_cast<const qrgb888*>(s)[x], 0);
|
||||
case Format_RGB444:
|
||||
return qt_colorConvert<quint32, qrgb444>(reinterpret_cast<const qrgb444*>(s)[x], 0);
|
||||
case Format_ARGB4444_Premultiplied:
|
||||
return qt_colorConvert<quint32, qargb4444>(reinterpret_cast<const qargb4444*>(s)[x], 0);
|
||||
case Format_RGB32:
|
||||
case Format_ARGB32: // Keep old behaviour.
|
||||
case Format_ARGB32_Premultiplied:
|
||||
return reinterpret_cast<const QRgb *>(s)[x];
|
||||
case Format_RGB16:
|
||||
return qt_colorConvert<quint32, quint16>(reinterpret_cast<const quint16*>(s)[x], 0);
|
||||
return qConvertRgb16To32(reinterpret_cast<const quint16 *>(s)[x]);
|
||||
default:
|
||||
return ((QRgb*)s)[x];
|
||||
break;
|
||||
}
|
||||
const QPixelLayout *layout = &qPixelLayouts[d->format];
|
||||
uint result;
|
||||
const uint *ptr = qFetchPixels[layout->bpp](&result, s, x, 1);
|
||||
return *layout->convertToARGB32PM(&result, ptr, 1, layout, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -3693,7 +3623,6 @@ void QImage::setPixel(int x, int y, uint index_or_rgb)
|
|||
}
|
||||
// detach is called from within scanLine
|
||||
uchar * s = scanLine(y);
|
||||
const quint32p p = quint32p::fromRawData(index_or_rgb);
|
||||
switch(d->format) {
|
||||
case Format_Mono:
|
||||
case Format_MonoLSB:
|
||||
|
|
@ -3710,54 +3639,38 @@ void QImage::setPixel(int x, int y, uint index_or_rgb)
|
|||
else
|
||||
*(s + (x >> 3)) |= (1 << (7-(x & 7)));
|
||||
}
|
||||
break;
|
||||
return;
|
||||
case Format_Indexed8:
|
||||
if (index_or_rgb >= (uint)d->colortable.size()) {
|
||||
qWarning("QImage::setPixel: Index %d out of range", index_or_rgb);
|
||||
return;
|
||||
}
|
||||
s[x] = index_or_rgb;
|
||||
break;
|
||||
return;
|
||||
case Format_RGB32:
|
||||
//make sure alpha is 255, we depend on it in qdrawhelper for cases
|
||||
// when image is set as a texture pattern on a qbrush
|
||||
((uint *)s)[x] = uint(255 << 24) | index_or_rgb;
|
||||
break;
|
||||
return;
|
||||
case Format_ARGB32:
|
||||
case Format_ARGB32_Premultiplied:
|
||||
((uint *)s)[x] = index_or_rgb;
|
||||
break;
|
||||
return;
|
||||
case Format_RGB16:
|
||||
((quint16 *)s)[x] = qt_colorConvert<quint16, quint32p>(p, 0);
|
||||
break;
|
||||
case Format_ARGB8565_Premultiplied:
|
||||
((qargb8565*)s)[x] = qt_colorConvert<qargb8565, quint32p>(p, 0);
|
||||
break;
|
||||
case Format_RGB666:
|
||||
((qrgb666*)s)[x] = qt_colorConvert<qrgb666, quint32p>(p, 0);
|
||||
break;
|
||||
case Format_ARGB6666_Premultiplied:
|
||||
((qargb6666*)s)[x] = qt_colorConvert<qargb6666, quint32p>(p, 0);
|
||||
break;
|
||||
case Format_RGB555:
|
||||
((qrgb555*)s)[x] = qt_colorConvert<qrgb555, quint32p>(p, 0);
|
||||
break;
|
||||
case Format_ARGB8555_Premultiplied:
|
||||
((qargb8555*)s)[x] = qt_colorConvert<qargb8555, quint32p>(p, 0);
|
||||
break;
|
||||
case Format_RGB888:
|
||||
((qrgb888*)s)[x] = qt_colorConvert<qrgb888, quint32p>(p, 0);
|
||||
break;
|
||||
case Format_RGB444:
|
||||
((qrgb444*)s)[x] = qt_colorConvert<qrgb444, quint32p>(p, 0);
|
||||
break;
|
||||
case Format_ARGB4444_Premultiplied:
|
||||
((qargb4444*)s)[x] = qt_colorConvert<qargb4444, quint32p>(p, 0);
|
||||
break;
|
||||
((quint16 *)s)[x] = qConvertRgb32To16(INV_PREMUL(index_or_rgb));
|
||||
return;
|
||||
case Format_Invalid:
|
||||
case NImageFormats:
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const QPixelLayout *layout = &qPixelLayouts[d->format];
|
||||
uint result;
|
||||
const uint *ptr = layout->convertFromARGB32PM(&result, &index_or_rgb, 1, layout, 0);
|
||||
qStorePixels[layout->bpp](s, ptr, x, 1);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -3774,30 +3687,56 @@ bool QImage::allGray() const
|
|||
if (!d)
|
||||
return true;
|
||||
|
||||
if (d->depth == 32) {
|
||||
int p = width()*height();
|
||||
const QRgb* b = (const QRgb*)bits();
|
||||
while (p--)
|
||||
if (!qIsGray(*b++))
|
||||
return false;
|
||||
} else if (d->depth == 16) {
|
||||
int p = width()*height();
|
||||
const ushort* b = (const ushort *)bits();
|
||||
while (p--)
|
||||
if (!qIsGray(qt_colorConvert<quint32, quint16>(*b++, 0)))
|
||||
return false;
|
||||
} else if (d->format == QImage::Format_RGB888) {
|
||||
int p = width()*height();
|
||||
const qrgb888* b = (const qrgb888 *)bits();
|
||||
while (p--)
|
||||
if (!qIsGray(qt_colorConvert<quint32, qrgb888>(*b++, 0)))
|
||||
return false;
|
||||
} else {
|
||||
if (d->colortable.isEmpty())
|
||||
return true;
|
||||
for (int i = 0; i < colorCount(); i++)
|
||||
switch (d->format) {
|
||||
case Format_Mono:
|
||||
case Format_MonoLSB:
|
||||
case Format_Indexed8:
|
||||
for (int i = 0; i < d->colortable.size(); ++i) {
|
||||
if (!qIsGray(d->colortable.at(i)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case Format_RGB32:
|
||||
case Format_ARGB32:
|
||||
case Format_ARGB32_Premultiplied:
|
||||
for (int j = 0; j < d->height; ++j) {
|
||||
const QRgb *b = (const QRgb *)constScanLine(j);
|
||||
for (int i = 0; i < d->width; ++i) {
|
||||
if (!qIsGray(b[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case Format_RGB16:
|
||||
for (int j = 0; j < d->height; ++j) {
|
||||
const quint16 *b = (const quint16 *)constScanLine(j);
|
||||
for (int i = 0; i < d->width; ++i) {
|
||||
if (!qIsGray(qConvertRgb16To32(b[i])))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const int buffer_size = 2048;
|
||||
uint buffer[buffer_size];
|
||||
const QPixelLayout *layout = &qPixelLayouts[d->format];
|
||||
FetchPixelsFunc fetch = qFetchPixels[layout->bpp];
|
||||
for (int j = 0; j < d->height; ++j) {
|
||||
const uchar *b = constScanLine(j);
|
||||
int x = 0;
|
||||
while (x < d->width) {
|
||||
int l = qMin(d->width - x, buffer_size);
|
||||
const uint *ptr = fetch(buffer, b, x, l);
|
||||
ptr = layout->convertToARGB32PM(buffer, ptr, l, layout, 0);
|
||||
for (int i = 0; i < l; ++i) {
|
||||
if (!qIsGray(ptr[i]))
|
||||
return false;
|
||||
}
|
||||
x += l;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -4320,7 +4259,7 @@ QImage QImage::rgbSwapped() const
|
|||
case Format_Invalid:
|
||||
case NImageFormats:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
return res;
|
||||
case Format_Mono:
|
||||
case Format_MonoLSB:
|
||||
case Format_Indexed8:
|
||||
|
|
@ -4329,7 +4268,7 @@ QImage QImage::rgbSwapped() const
|
|||
QRgb c = res.d->colortable.at(i);
|
||||
res.d->colortable[i] = QRgb(((c << 16) & 0xff0000) | ((c >> 16) & 0xff) | (c & 0xff00ff00));
|
||||
}
|
||||
break;
|
||||
return res;
|
||||
case Format_RGB32:
|
||||
case Format_ARGB32:
|
||||
case Format_ARGB32_Premultiplied:
|
||||
|
|
@ -4345,7 +4284,7 @@ QImage QImage::rgbSwapped() const
|
|||
q++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
return res;
|
||||
case Format_RGB16:
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
|
|
@ -4359,113 +4298,41 @@ QImage QImage::rgbSwapped() const
|
|||
q++;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
default:
|
||||
break;
|
||||
case Format_ARGB8565_Premultiplied:
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
for (int i = 0; i < d->height; i++) {
|
||||
const quint8 *p = constScanLine(i);
|
||||
quint8 *q = res.scanLine(i);
|
||||
const quint8 *end = p + d->width * sizeof(qargb8565);
|
||||
while (p < end) {
|
||||
q[0] = p[0];
|
||||
q[1] = (p[1] & 0xe0) | (p[2] >> 3);
|
||||
q[2] = (p[2] & 0x07) | (p[1] << 3);
|
||||
p += sizeof(qargb8565);
|
||||
q += sizeof(qargb8565);
|
||||
}
|
||||
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
const QPixelLayout *layout = &qPixelLayouts[d->format];
|
||||
Q_ASSERT(layout->redWidth == layout->blueWidth);
|
||||
FetchPixelsFunc fetch = qFetchPixels[layout->bpp];
|
||||
StorePixelsFunc store = qStorePixels[layout->bpp];
|
||||
|
||||
const uint redBlueMask = (1 << layout->redWidth) - 1;
|
||||
const uint alphaGreenMask = (((1 << layout->alphaWidth) - 1) << layout->alphaShift)
|
||||
| (((1 << layout->greenWidth) - 1) << layout->greenShift);
|
||||
|
||||
const int buffer_size = 2048;
|
||||
uint buffer[buffer_size];
|
||||
for (int i = 0; i < d->height; ++i) {
|
||||
uchar *q = res.scanLine(i);
|
||||
const uchar *p = constScanLine(i);
|
||||
int x = 0;
|
||||
while (x < d->width) {
|
||||
int l = qMin(d->width - x, buffer_size);
|
||||
const uint *ptr = fetch(buffer, p, x, l);
|
||||
for (int j = 0; j < l; ++j) {
|
||||
uint red = (ptr[j] >> layout->redShift) & redBlueMask;
|
||||
uint blue = (ptr[j] >> layout->blueShift) & redBlueMask;
|
||||
buffer[j] = (ptr[j] & alphaGreenMask)
|
||||
| (red << layout->blueShift)
|
||||
| (blue << layout->redShift);
|
||||
}
|
||||
store(q, buffer, x, l);
|
||||
x += l;
|
||||
}
|
||||
break;
|
||||
case Format_RGB666:
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
for (int i = 0; i < d->height; i++) {
|
||||
qrgb666 *q = reinterpret_cast<qrgb666*>(res.scanLine(i));
|
||||
const qrgb666 *p = reinterpret_cast<const qrgb666*>(constScanLine(i));
|
||||
const qrgb666 *end = p + d->width;
|
||||
while (p < end) {
|
||||
const QRgb rgb = quint32(*p++);
|
||||
*q++ = qRgb(qBlue(rgb), qGreen(rgb), qRed(rgb));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Format_ARGB6666_Premultiplied:
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
for (int i = 0; i < d->height; i++) {
|
||||
const quint8 *p = constScanLine(i);
|
||||
const quint8 *end = p + d->width * sizeof(qargb6666);
|
||||
quint8 *q = res.scanLine(i);
|
||||
while (p < end) {
|
||||
q[0] = (p[1] >> 4) | ((p[2] & 0x3) << 4) | (p[0] & 0xc0);
|
||||
q[1] = (p[1] & 0xf) | (p[0] << 4);
|
||||
q[2] = (p[2] & 0xfc) | ((p[0] >> 4) & 0x3);
|
||||
p += sizeof(qargb6666);
|
||||
q += sizeof(qargb6666);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Format_RGB555:
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
for (int i = 0; i < d->height; i++) {
|
||||
quint16 *q = (quint16*)res.scanLine(i);
|
||||
const quint16 *p = (const quint16*)constScanLine(i);
|
||||
const quint16 *end = p + d->width;
|
||||
while (p < end) {
|
||||
*q = ((*p << 10) & 0x7c00) | ((*p >> 10) & 0x1f) | (*p & 0x3e0);
|
||||
p++;
|
||||
q++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Format_ARGB8555_Premultiplied:
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
for (int i = 0; i < d->height; i++) {
|
||||
const quint8 *p = constScanLine(i);
|
||||
quint8 *q = res.scanLine(i);
|
||||
const quint8 *end = p + d->width * sizeof(qargb8555);
|
||||
while (p < end) {
|
||||
q[0] = p[0];
|
||||
q[1] = (p[1] & 0xe0) | (p[2] >> 2);
|
||||
q[2] = (p[2] & 0x03) | ((p[1] << 2) & 0x7f);
|
||||
p += sizeof(qargb8555);
|
||||
q += sizeof(qargb8555);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Format_RGB888:
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
for (int i = 0; i < d->height; i++) {
|
||||
quint8 *q = res.scanLine(i);
|
||||
const quint8 *p = constScanLine(i);
|
||||
const quint8 *end = p + d->width * sizeof(qrgb888);
|
||||
while (p < end) {
|
||||
q[0] = p[2];
|
||||
q[1] = p[1];
|
||||
q[2] = p[0];
|
||||
q += sizeof(qrgb888);
|
||||
p += sizeof(qrgb888);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Format_RGB444:
|
||||
case Format_ARGB4444_Premultiplied:
|
||||
res = QImage(d->width, d->height, d->format);
|
||||
QIMAGE_SANITYCHECK_MEMORY(res);
|
||||
for (int i = 0; i < d->height; i++) {
|
||||
quint16 *q = reinterpret_cast<quint16*>(res.scanLine(i));
|
||||
const quint16 *p = reinterpret_cast<const quint16*>(constScanLine(i));
|
||||
const quint16 *end = p + d->width;
|
||||
while (p < end) {
|
||||
*q = (*p & 0xf0f0) | ((*p & 0x0f) << 8) | ((*p & 0xf00) >> 8);
|
||||
p++;
|
||||
q++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,27 +144,11 @@ void QBlittablePlatformPixmap::fill(const QColor &color)
|
|||
m_alpha = true;
|
||||
}
|
||||
|
||||
uint pixel;
|
||||
switch (blittable()->lock()->format()) {
|
||||
case QImage::Format_ARGB32_Premultiplied:
|
||||
pixel = PREMUL(color.rgba());
|
||||
break;
|
||||
case QImage::Format_ARGB8565_Premultiplied:
|
||||
pixel = qargb8565(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_ARGB8555_Premultiplied:
|
||||
pixel = qargb8555(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_ARGB6666_Premultiplied:
|
||||
pixel = qargb6666(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_ARGB4444_Premultiplied:
|
||||
pixel = qargb4444(color.rgba()).rawValue();
|
||||
break;
|
||||
default:
|
||||
pixel = color.rgba();
|
||||
break;
|
||||
}
|
||||
uint pixel = PREMUL(color.rgba());
|
||||
const QPixelLayout *layout = &qPixelLayouts[blittable()->lock()->format()];
|
||||
Q_ASSERT(layout->convertFromARGB32PM);
|
||||
layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0);
|
||||
|
||||
//so premultiplied formats are supported and ARGB32 and RGB32
|
||||
blittable()->lock()->fill(pixel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,46 +202,10 @@ void QRasterPlatformPixmap::fill(const QColor &color)
|
|||
image = QImage(image.width(), image.height(), toFormat);
|
||||
}
|
||||
}
|
||||
|
||||
switch (image.format()) {
|
||||
case QImage::Format_ARGB8565_Premultiplied:
|
||||
pixel = qargb8565(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_ARGB8555_Premultiplied:
|
||||
pixel = qargb8555(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_ARGB6666_Premultiplied:
|
||||
pixel = qargb6666(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_ARGB4444_Premultiplied:
|
||||
pixel = qargb4444(color.rgba()).rawValue();
|
||||
break;
|
||||
default:
|
||||
pixel = PREMUL(color.rgba());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (image.format()) {
|
||||
case QImage::Format_RGB16:
|
||||
pixel = qt_colorConvert<quint16, quint32>(color.rgba(), 0);
|
||||
break;
|
||||
case QImage::Format_RGB444:
|
||||
pixel = qrgb444(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_RGB555:
|
||||
pixel = qrgb555(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_RGB666:
|
||||
pixel = qrgb666(color.rgba()).rawValue();
|
||||
break;
|
||||
case QImage::Format_RGB888:
|
||||
pixel = qrgb888(color.rgba()).rawValue();
|
||||
break;
|
||||
default:
|
||||
pixel = color.rgba();
|
||||
break;
|
||||
}
|
||||
}
|
||||
pixel = PREMUL(color.rgba());
|
||||
const QPixelLayout *layout = &qPixelLayouts[image.format()];
|
||||
layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0);
|
||||
} else {
|
||||
pixel = 0;
|
||||
// ### what about 8 bits
|
||||
|
|
|
|||
|
|
@ -71,21 +71,6 @@ struct SourceAndConstAlpha
|
|||
RGB16 (565) format target format
|
||||
************************************************************************/
|
||||
|
||||
static inline quint16 convert_argb32_to_rgb16(quint32 spix)
|
||||
{
|
||||
quint32 b = spix;
|
||||
quint32 g = spix;
|
||||
b >>= 8;
|
||||
g >>= 5;
|
||||
b &= 0x0000f800;
|
||||
g &= 0x000007e0;
|
||||
spix >>= 3;
|
||||
b |= g;
|
||||
spix &= 0x0000001f;
|
||||
b |= spix;
|
||||
return b;
|
||||
}
|
||||
|
||||
struct Blend_RGB16_on_RGB16_NoAlpha {
|
||||
inline void write(quint16 *dst, quint16 src) { *dst = src; }
|
||||
|
||||
|
|
@ -108,46 +93,11 @@ struct Blend_RGB16_on_RGB16_ConstAlpha {
|
|||
quint32 m_ialpha;
|
||||
};
|
||||
|
||||
struct Blend_ARGB24_on_RGB16_SourceAlpha {
|
||||
inline void write(quint16 *dst, const qargb8565 &src) {
|
||||
const uint alpha = src.alpha();
|
||||
if (alpha) {
|
||||
quint16 s = src.rawValue16();
|
||||
if (alpha < 255)
|
||||
s += BYTE_MUL_RGB16(*dst, 255 - alpha);
|
||||
*dst = s;
|
||||
}
|
||||
}
|
||||
|
||||
inline void flush(void *) {}
|
||||
};
|
||||
|
||||
struct Blend_ARGB24_on_RGB16_SourceAndConstAlpha {
|
||||
inline Blend_ARGB24_on_RGB16_SourceAndConstAlpha(quint32 alpha) {
|
||||
m_alpha = (alpha * 255) >> 8;
|
||||
}
|
||||
|
||||
inline void write(quint16 *dst, qargb8565 src) {
|
||||
src = src.byte_mul(src.alpha(m_alpha));
|
||||
const uint alpha = src.alpha();
|
||||
if (alpha) {
|
||||
quint16 s = src.rawValue16();
|
||||
if (alpha < 255)
|
||||
s += BYTE_MUL_RGB16(*dst, 255 - alpha);
|
||||
*dst = s;
|
||||
}
|
||||
}
|
||||
|
||||
inline void flush(void *) {}
|
||||
|
||||
quint32 m_alpha;
|
||||
};
|
||||
|
||||
struct Blend_ARGB32_on_RGB16_SourceAlpha {
|
||||
inline void write(quint16 *dst, quint32 src) {
|
||||
const quint8 alpha = qAlpha(src);
|
||||
if(alpha) {
|
||||
quint16 s = convert_argb32_to_rgb16(src);
|
||||
if (alpha) {
|
||||
quint16 s = qConvertRgb32To16(src);
|
||||
if(alpha < 255)
|
||||
s += BYTE_MUL_RGB16(*dst, 255 - alpha);
|
||||
*dst = s;
|
||||
|
|
@ -166,7 +116,7 @@ struct Blend_ARGB32_on_RGB16_SourceAndConstAlpha {
|
|||
src = BYTE_MUL(src, m_alpha);
|
||||
const quint8 alpha = qAlpha(src);
|
||||
if(alpha) {
|
||||
quint16 s = convert_argb32_to_rgb16(src);
|
||||
quint16 s = qConvertRgb32To16(src);
|
||||
if(alpha < 255)
|
||||
s += BYTE_MUL_RGB16(*dst, 255 - alpha);
|
||||
*dst = s;
|
||||
|
|
@ -203,32 +153,6 @@ void qt_scale_image_rgb16_on_rgb16(uchar *destPixels, int dbpl,
|
|||
}
|
||||
}
|
||||
|
||||
void qt_scale_image_argb24_on_rgb16(uchar *destPixels, int dbpl,
|
||||
const uchar *srcPixels, int sbpl,
|
||||
const QRectF &targetRect,
|
||||
const QRectF &sourceRect,
|
||||
const QRect &clip,
|
||||
int const_alpha)
|
||||
{
|
||||
#ifdef QT_DEBUG_DRAW
|
||||
printf("qt_scale_argb24_on_rgb16: dst=(%p, %d), src=(%p, %d), target=(%d, %d), [%d x %d], src=(%d, %d) [%d x %d] alpha=%d\n",
|
||||
destPixels, dbpl, srcPixels, sbpl,
|
||||
targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(),
|
||||
sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height(),
|
||||
const_alpha);
|
||||
#endif
|
||||
if (const_alpha == 256) {
|
||||
Blend_ARGB24_on_RGB16_SourceAlpha noAlpha;
|
||||
qt_scale_image_16bit<qargb8565>(destPixels, dbpl, srcPixels, sbpl,
|
||||
targetRect, sourceRect, clip, noAlpha);
|
||||
} else {
|
||||
Blend_ARGB24_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
|
||||
qt_scale_image_16bit<qargb8565>(destPixels, dbpl, srcPixels, sbpl,
|
||||
targetRect, sourceRect, clip, constAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void qt_scale_image_argb32_on_rgb16(uchar *destPixels, int dbpl,
|
||||
const uchar *srcPixels, int sbpl,
|
||||
const QRectF &targetRect,
|
||||
|
|
@ -280,7 +204,6 @@ void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl,
|
|||
}
|
||||
}
|
||||
} else if (const_alpha != 0) {
|
||||
SourceAndConstAlpha alpha(const_alpha); // expects the 0-256 range
|
||||
quint16 *d = (quint16 *) dst;
|
||||
const quint16 *s = (const quint16 *) src;
|
||||
quint8 a = (255 * const_alpha) >> 8;
|
||||
|
|
@ -296,79 +219,6 @@ void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl,
|
|||
}
|
||||
|
||||
|
||||
template <typename T> void qt_blend_argb24_on_rgb16(uchar *destPixels, int dbpl,
|
||||
const uchar *srcPixels, int sbpl,
|
||||
int w, int h, const T &alphaFunc)
|
||||
{
|
||||
int srcOffset = w*3;
|
||||
int dstJPL = dbpl / 2;
|
||||
quint16 *dst = (quint16 *) destPixels;
|
||||
int dstExtraStride = dstJPL - w;
|
||||
|
||||
for (int y=0; y<h; ++y) {
|
||||
const uchar *src = srcPixels + y * sbpl;
|
||||
const uchar *srcEnd = src + srcOffset;
|
||||
while (src < srcEnd) {
|
||||
#if defined(QT_ARCH_ARMV5) || defined(QT_ARCH_POWERPC) || defined(QT_ARCH_SH) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_WINDOWSCE) && !defined(_X86_)) || (defined(QT_ARCH_SPARC) && defined(Q_CC_GNU)) || (defined(QT_ARCH_INTEGRITY) && !defined(_X86_))
|
||||
// non-16-bit aligned memory access is not possible on PowerPC,
|
||||
// ARM <v6 (QT_ARCH_ARMV5) & SH & AVR32 & SPARC w/GCC
|
||||
quint16 spix = (quint16(src[2])<<8) + src[1];
|
||||
#else
|
||||
quint16 spix = *(quint16 *) (src + 1);
|
||||
#endif
|
||||
uchar alpha = alphaFunc.alpha(*src);
|
||||
|
||||
if (alpha == 255) {
|
||||
*dst = spix;
|
||||
} else if (alpha != 0) {
|
||||
quint16 dpix = *dst;
|
||||
quint32 sia = 255 - alpha;
|
||||
|
||||
quint16 dr = (dpix & 0x0000f800);
|
||||
quint16 dg = (dpix & 0x000007e0);
|
||||
quint16 db = (dpix & 0x0000001f);
|
||||
|
||||
quint32 siar = dr * sia;
|
||||
quint32 siag = dg * sia;
|
||||
quint32 siab = db * sia;
|
||||
|
||||
quint32 rr = ((siar + (siar>>8) + (0x80 << 8)) >> 8) & 0xf800;
|
||||
quint32 rg = ((siag + (siag>>8) + (0x80 << 3)) >> 8) & 0x07e0;
|
||||
quint32 rb = ((siab + (siab>>8) + (0x80 >> 3)) >> 8) & 0x001f;
|
||||
|
||||
*dst = alphaFunc.bytemul(spix) + rr + rg + rb;
|
||||
}
|
||||
|
||||
++dst;
|
||||
src += 3;
|
||||
}
|
||||
dst += dstExtraStride;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void qt_blend_argb24_on_rgb16(uchar *destPixels, int dbpl,
|
||||
const uchar *srcPixels, int sbpl,
|
||||
int w, int h,
|
||||
int const_alpha)
|
||||
{
|
||||
#ifdef QT_DEBUG_DRAW
|
||||
printf("qt_blend_argb24_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
|
||||
destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
|
||||
#endif
|
||||
|
||||
if (const_alpha != 256) {
|
||||
SourceAndConstAlpha alphaFunc(const_alpha);
|
||||
qt_blend_argb24_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, alphaFunc);
|
||||
} else {
|
||||
SourceOnlyAlpha alphaFunc;
|
||||
qt_blend_argb24_on_rgb16(destPixels, dbpl, srcPixels, sbpl, w, h, alphaFunc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void qt_blend_argb32_on_rgb16_const_alpha(uchar *destPixels, int dbpl,
|
||||
const uchar *srcPixels, int sbpl,
|
||||
int w, int h,
|
||||
|
|
@ -383,7 +233,7 @@ void qt_blend_argb32_on_rgb16_const_alpha(uchar *destPixels, int dbpl,
|
|||
uint s = src[i];
|
||||
s = BYTE_MUL(s, const_alpha);
|
||||
int alpha = qAlpha(s);
|
||||
s = convert_argb32_to_rgb16(s);
|
||||
s = qConvertRgb32To16(s);
|
||||
s += BYTE_MUL_RGB16(dst[i], 255 - alpha);
|
||||
dst[i] = s;
|
||||
}
|
||||
|
|
@ -412,7 +262,7 @@ static void qt_blend_argb32_on_rgb16(uchar *destPixels, int dbpl,
|
|||
quint32 alpha = spix >> 24;
|
||||
|
||||
if (alpha == 255) {
|
||||
dst[x] = convert_argb32_to_rgb16(spix);
|
||||
dst[x] = qConvertRgb32To16(spix);
|
||||
} else if (alpha != 0) {
|
||||
quint32 dpix = dst[x];
|
||||
|
||||
|
|
@ -473,7 +323,7 @@ static void qt_blend_rgb32_on_rgb16(uchar *destPixels, int dbpl,
|
|||
while (dst < dstEnd) {
|
||||
const quint32 *srcEnd = src + w;
|
||||
while (src < srcEnd) {
|
||||
*dst = convert_argb32_to_rgb16(*src);
|
||||
*dst = qConvertRgb32To16(*src);
|
||||
++dst;
|
||||
++src;
|
||||
}
|
||||
|
|
@ -545,19 +395,11 @@ void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,
|
|||
|
||||
const uint *src = (const uint *) srcPixels;
|
||||
uint *dst = (uint *) destPixels;
|
||||
if (w <= 64) {
|
||||
for (int y=0; y<h; ++y) {
|
||||
qt_memconvert(dst, src, w);
|
||||
dst = (quint32 *)(((uchar *) dst) + dbpl);
|
||||
src = (const quint32 *)(((const uchar *) src) + sbpl);
|
||||
}
|
||||
} else {
|
||||
int len = w * 4;
|
||||
for (int y=0; y<h; ++y) {
|
||||
memcpy(dst, src, len);
|
||||
dst = (quint32 *)(((uchar *) dst) + dbpl);
|
||||
src = (const quint32 *)(((const uchar *) src) + sbpl);
|
||||
}
|
||||
int len = w * 4;
|
||||
for (int y=0; y<h; ++y) {
|
||||
memcpy(dst, src, len);
|
||||
dst = (quint32 *)(((uchar *) dst) + dbpl);
|
||||
src = (const quint32 *)(((const uchar *) src) + sbpl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -681,28 +523,6 @@ void qt_transform_image_rgb16_on_rgb16(uchar *destPixels, int dbpl,
|
|||
}
|
||||
}
|
||||
|
||||
void qt_transform_image_argb24_on_rgb16(uchar *destPixels, int dbpl,
|
||||
const uchar *srcPixels, int sbpl,
|
||||
const QRectF &targetRect,
|
||||
const QRectF &sourceRect,
|
||||
const QRect &clip,
|
||||
const QTransform &targetRectTransform,
|
||||
int const_alpha)
|
||||
{
|
||||
if (const_alpha == 256) {
|
||||
Blend_ARGB24_on_RGB16_SourceAlpha noAlpha;
|
||||
qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
|
||||
reinterpret_cast<const qargb8565 *>(srcPixels), sbpl,
|
||||
targetRect, sourceRect, clip, targetRectTransform, noAlpha);
|
||||
} else {
|
||||
Blend_ARGB24_on_RGB16_SourceAndConstAlpha constAlpha(const_alpha);
|
||||
qt_transform_image(reinterpret_cast<quint16 *>(destPixels), dbpl,
|
||||
reinterpret_cast<const qargb8565 *>(srcPixels), sbpl,
|
||||
targetRect, sourceRect, clip, targetRectTransform, constAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void qt_transform_image_argb32_on_rgb16(uchar *destPixels, int dbpl,
|
||||
const uchar *srcPixels, int sbpl,
|
||||
const QRectF &targetRect,
|
||||
|
|
@ -903,7 +723,7 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
|
|||
0, // Format_ARGB32,
|
||||
qt_scale_image_argb32_on_rgb16, // Format_ARGB32_Premultiplied,
|
||||
qt_scale_image_rgb16_on_rgb16, // Format_RGB16,
|
||||
qt_scale_image_argb24_on_rgb16, // Format_ARGB8565_Premultiplied,
|
||||
0, // Format_ARGB8565_Premultiplied,
|
||||
0, // Format_RGB666,
|
||||
0, // Format_ARGB6666_Premultiplied,
|
||||
0, // Format_RGB555,
|
||||
|
|
@ -1195,7 +1015,7 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
|
|||
0, // Format_ARGB32,
|
||||
qt_blend_argb32_on_rgb16, // Format_ARGB32_Premultiplied,
|
||||
qt_blend_rgb16_on_rgb16, // Format_RGB16,
|
||||
qt_blend_argb24_on_rgb16, // Format_ARGB8565_Premultiplied,
|
||||
0, // Format_ARGB8565_Premultiplied,
|
||||
0, // Format_RGB666,
|
||||
0, // Format_ARGB6666_Premultiplied,
|
||||
0, // Format_RGB555,
|
||||
|
|
@ -1486,7 +1306,7 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
|
|||
0, // Format_ARGB32,
|
||||
qt_transform_image_argb32_on_rgb16, // Format_ARGB32_Premultiplied,
|
||||
qt_transform_image_rgb16_on_rgb16, // Format_RGB16,
|
||||
qt_transform_image_argb24_on_rgb16, // Format_ARGB8565_Premultiplied,
|
||||
0, // Format_ARGB8565_Premultiplied,
|
||||
0, // Format_RGB666,
|
||||
0, // Format_ARGB6666_Premultiplied,
|
||||
0, // Format_RGB555,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -198,7 +198,7 @@ void qt_blend_rgb16_on_argb32_neon(uchar *destPixels, int dbpl,
|
|||
|
||||
while (h--) {
|
||||
for (int x=0; x<w; ++x)
|
||||
dst[x] = INTERPOLATE_PIXEL_255(qt_colorConvert(src[x], dst[x]), a, dst[x], ia);
|
||||
dst[x] = INTERPOLATE_PIXEL_255(qConvertRgb16To32(src[x]), a, dst[x], ia);
|
||||
dst += dbpl;
|
||||
src += sbpl;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -459,7 +459,7 @@ void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
|
|||
quint32 color,
|
||||
const uchar *src, int width, int height, int stride)
|
||||
{
|
||||
const quint16 c = qt_colorConvert<quint16, quint32>(color, 0);
|
||||
const quint16 c = qConvertRgb32To16(color);
|
||||
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;
|
||||
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ inline void qt_bitmapblit16_sse_template(QRasterBuffer *rasterBuffer,
|
|||
const uchar *src,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
const quint16 c = qt_colorConvert<quint16, quint32>(color, 0);
|
||||
const quint16 c = qConvertRgb32To16(color);
|
||||
quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;
|
||||
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);
|
||||
|
||||
|
|
|
|||
|
|
@ -53,36 +53,36 @@ static const int tileSize = 32;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_cachedRead(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate90_cachedRead(const T *src, int w, int h, int sstride, T *dest,
|
||||
int dstride)
|
||||
{
|
||||
const char *s = reinterpret_cast<const char*>(src);
|
||||
char *d = reinterpret_cast<char*>(dest);
|
||||
for (int y = 0; y < h; ++y) {
|
||||
for (int x = w - 1; x >= 0; --x) {
|
||||
DST *destline = reinterpret_cast<DST*>(d + (w - x - 1) * dstride);
|
||||
destline[y] = qt_colorConvert<DST,SRC>(src[x], 0);
|
||||
T *destline = reinterpret_cast<T *>(d + (w - x - 1) * dstride);
|
||||
destline[y] = src[x];
|
||||
}
|
||||
s += sstride;
|
||||
src = reinterpret_cast<const SRC*>(s);
|
||||
src = reinterpret_cast<const T*>(s);
|
||||
}
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_cachedRead(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate270_cachedRead(const T *src, int w, int h, int sstride, T *dest,
|
||||
int dstride)
|
||||
{
|
||||
const char *s = reinterpret_cast<const char*>(src);
|
||||
char *d = reinterpret_cast<char*>(dest);
|
||||
s += (h - 1) * sstride;
|
||||
for (int y = h - 1; y >= 0; --y) {
|
||||
src = reinterpret_cast<const SRC*>(s);
|
||||
src = reinterpret_cast<const T*>(s);
|
||||
for (int x = 0; x < w; ++x) {
|
||||
DST *destline = reinterpret_cast<DST*>(d + x * dstride);
|
||||
destline[h - y - 1] = qt_colorConvert<DST,SRC>(src[x], 0);
|
||||
T *destline = reinterpret_cast<T *>(d + x * dstride);
|
||||
destline[h - y - 1] = src[x];
|
||||
}
|
||||
s -= sstride;
|
||||
}
|
||||
|
|
@ -90,29 +90,29 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_cachedRead(const SRC *src
|
|||
|
||||
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_cachedWrite(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate90_cachedWrite(const T *src, int w, int h, int sstride, T *dest,
|
||||
int dstride)
|
||||
{
|
||||
for (int x = w - 1; x >= 0; --x) {
|
||||
DST *d = dest + (w - x - 1) * dstride;
|
||||
T *d = dest + (w - x - 1) * dstride;
|
||||
for (int y = 0; y < h; ++y) {
|
||||
*d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
*d++ = src[y * sstride + x];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_cachedWrite(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate270_cachedWrite(const T *src, int w, int h, int sstride, T *dest,
|
||||
int dstride)
|
||||
{
|
||||
for (int x = 0; x < w; ++x) {
|
||||
DST *d = dest + x * dstride;
|
||||
T *d = dest + x * dstride;
|
||||
for (int y = h - 1; y >= 0; --y) {
|
||||
*d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
*d++ = src[y * sstride + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -123,23 +123,21 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_cachedWrite(const SRC *sr
|
|||
|
||||
// TODO: packing algorithms should probably be modified on 64-bit architectures
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_packing(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate90_packing(const T *src, int w, int h, int sstride, T *dest, int dstride)
|
||||
{
|
||||
sstride /= sizeof(SRC);
|
||||
dstride /= sizeof(DST);
|
||||
sstride /= sizeof(T);
|
||||
dstride /= sizeof(T);
|
||||
|
||||
const int pack = sizeof(quint32) / sizeof(DST);
|
||||
const int unaligned = int((long(dest) & (sizeof(quint32)-1))) / sizeof(DST);
|
||||
const int pack = sizeof(quint32) / sizeof(T);
|
||||
const int unaligned = int((long(dest) & (sizeof(quint32)-1))) / sizeof(T);
|
||||
|
||||
for (int x = w - 1; x >= 0; --x) {
|
||||
int y = 0;
|
||||
|
||||
for (int i = 0; i < unaligned; ++i) {
|
||||
dest[(w - x - 1) * dstride + y]
|
||||
= qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
dest[(w - x - 1) * dstride + y] = src[y * sstride + x];
|
||||
++y;
|
||||
}
|
||||
|
||||
|
|
@ -147,40 +145,36 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_packing(const SRC *src, in
|
|||
+ unaligned);
|
||||
const int rest = (h - unaligned) % pack;
|
||||
while (y < h - rest) {
|
||||
quint32 c = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
quint32 c = src[y * sstride + x];
|
||||
for (int i = 1; i < pack; ++i) {
|
||||
c |= qt_colorConvert<DST,SRC>(src[(y + i) * sstride + x], 0)
|
||||
<< (sizeof(int) * 8 / pack * i);
|
||||
c |= src[(y + i) * sstride + x] << (sizeof(int) * 8 / pack * i);
|
||||
}
|
||||
*d++ = c;
|
||||
y += pack;
|
||||
}
|
||||
|
||||
while (y < h) {
|
||||
dest[(w - x - 1) * dstride + y]
|
||||
= qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
dest[(w - x - 1) * dstride + y] = src[y * sstride + x];
|
||||
++y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_packing(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate270_packing(const T *src, int w, int h, int sstride, T *dest, int dstride)
|
||||
{
|
||||
sstride /= sizeof(SRC);
|
||||
dstride /= sizeof(DST);
|
||||
sstride /= sizeof(T);
|
||||
dstride /= sizeof(T);
|
||||
|
||||
const int pack = sizeof(quint32) / sizeof(DST);
|
||||
const int unaligned = int((long(dest) & (sizeof(quint32)-1))) / sizeof(DST);
|
||||
const int pack = sizeof(quint32) / sizeof(T);
|
||||
const int unaligned = int((long(dest) & (sizeof(quint32)-1))) / sizeof(T);
|
||||
|
||||
for (int x = 0; x < w; ++x) {
|
||||
int y = h - 1;
|
||||
|
||||
for (int i = 0; i < unaligned; ++i) {
|
||||
dest[x * dstride + h - y - 1]
|
||||
= qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
dest[x * dstride + h - y - 1] = src[y * sstride + x];
|
||||
--y;
|
||||
}
|
||||
|
||||
|
|
@ -188,17 +182,15 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_packing(const SRC *src, i
|
|||
+ unaligned);
|
||||
const int rest = (h - unaligned) % pack;
|
||||
while (y > rest) {
|
||||
quint32 c = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
quint32 c = src[y * sstride + x];
|
||||
for (int i = 1; i < pack; ++i) {
|
||||
c |= qt_colorConvert<DST,SRC>(src[(y - i) * sstride + x], 0)
|
||||
<< (sizeof(int) * 8 / pack * i);
|
||||
c |= src[(y - i) * sstride + x] << (sizeof(int) * 8 / pack * i);
|
||||
}
|
||||
*d++ = c;
|
||||
y -= pack;
|
||||
}
|
||||
while (y >= 0) {
|
||||
dest[x * dstride + h - y - 1]
|
||||
= qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
dest[x * dstride + h - y - 1] = src[y * sstride + x];
|
||||
--y;
|
||||
}
|
||||
}
|
||||
|
|
@ -207,17 +199,16 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_packing(const SRC *src, i
|
|||
#endif // QT_ROTATION_PACKING
|
||||
|
||||
#if QT_ROTATION_ALGORITHM == QT_ROTATION_TILED
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_tiled(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate90_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride)
|
||||
{
|
||||
sstride /= sizeof(SRC);
|
||||
dstride /= sizeof(DST);
|
||||
sstride /= sizeof(T);
|
||||
dstride /= sizeof(T);
|
||||
|
||||
const int pack = sizeof(quint32) / sizeof(DST);
|
||||
const int pack = sizeof(quint32) / sizeof(T);
|
||||
const int unaligned =
|
||||
qMin(uint((quintptr(dest) & (sizeof(quint32)-1)) / sizeof(DST)), uint(h));
|
||||
qMin(uint((quintptr(dest) & (sizeof(quint32)-1)) / sizeof(T)), uint(h));
|
||||
const int restX = w % tileSize;
|
||||
const int restY = (h - unaligned) % tileSize;
|
||||
const int unoptimizedY = restY % pack;
|
||||
|
|
@ -230,9 +221,9 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_tiled(const SRC *src, int
|
|||
|
||||
if (unaligned) {
|
||||
for (int x = startx; x >= stopx; --x) {
|
||||
DST *d = dest + (w - x - 1) * dstride;
|
||||
T *d = dest + (w - x - 1) * dstride;
|
||||
for (int y = 0; y < unaligned; ++y) {
|
||||
*d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
*d++ = src[y * sstride + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -244,10 +235,10 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_tiled(const SRC *src, int
|
|||
for (int x = startx; x >= stopx; --x) {
|
||||
quint32 *d = reinterpret_cast<quint32*>(dest + (w - x - 1) * dstride + starty);
|
||||
for (int y = starty; y < stopy; y += pack) {
|
||||
quint32 c = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
quint32 c = src[y * sstride + x];
|
||||
for (int i = 1; i < pack; ++i) {
|
||||
const int shift = (sizeof(int) * 8 / pack * i);
|
||||
const DST color = qt_colorConvert<DST,SRC>(src[(y + i) * sstride + x], 0);
|
||||
const T color = src[(y + i) * sstride + x];
|
||||
c |= color << shift;
|
||||
}
|
||||
*d++ = c;
|
||||
|
|
@ -258,19 +249,19 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_tiled(const SRC *src, int
|
|||
if (unoptimizedY) {
|
||||
const int starty = h - unoptimizedY;
|
||||
for (int x = startx; x >= stopx; --x) {
|
||||
DST *d = dest + (w - x - 1) * dstride + starty;
|
||||
T *d = dest + (w - x - 1) * dstride + starty;
|
||||
for (int y = starty; y < h; ++y) {
|
||||
*d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
*d++ = src[y * sstride + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_tiled_unpacked(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate90_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest,
|
||||
int dstride)
|
||||
{
|
||||
const int numTilesX = (w + tileSize - 1) / tileSize;
|
||||
const int numTilesY = (h + tileSize - 1) / tileSize;
|
||||
|
|
@ -284,10 +275,10 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_tiled_unpacked(const SRC *
|
|||
const int stopy = qMin(starty + tileSize, h);
|
||||
|
||||
for (int x = startx; x >= stopx; --x) {
|
||||
DST *d = (DST*)((char*)dest + (w - x - 1) * dstride) + starty;
|
||||
T *d = (T *)((char*)dest + (w - x - 1) * dstride) + starty;
|
||||
const char *s = (const char*)(src + x) + starty * sstride;
|
||||
for (int y = starty; y < stopy; ++y) {
|
||||
*d++ = qt_colorConvert<DST,SRC>(*(const SRC*)(s), 0);
|
||||
*d++ = *(const T *)(s);
|
||||
s += sstride;
|
||||
}
|
||||
}
|
||||
|
|
@ -295,17 +286,16 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_tiled_unpacked(const SRC *
|
|||
}
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_tiled(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate270_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride)
|
||||
{
|
||||
sstride /= sizeof(SRC);
|
||||
dstride /= sizeof(DST);
|
||||
sstride /= sizeof(T);
|
||||
dstride /= sizeof(T);
|
||||
|
||||
const int pack = sizeof(quint32) / sizeof(DST);
|
||||
const int pack = sizeof(quint32) / sizeof(T);
|
||||
const int unaligned =
|
||||
qMin(uint((long(dest) & (sizeof(quint32)-1)) / sizeof(DST)), uint(h));
|
||||
qMin(uint((long(dest) & (sizeof(quint32)-1)) / sizeof(T)), uint(h));
|
||||
const int restX = w % tileSize;
|
||||
const int restY = (h - unaligned) % tileSize;
|
||||
const int unoptimizedY = restY % pack;
|
||||
|
|
@ -318,9 +308,9 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_tiled(const SRC *src, int
|
|||
|
||||
if (unaligned) {
|
||||
for (int x = startx; x < stopx; ++x) {
|
||||
DST *d = dest + x * dstride;
|
||||
T *d = dest + x * dstride;
|
||||
for (int y = h - 1; y >= h - unaligned; --y) {
|
||||
*d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
*d++ = src[y * sstride + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -333,10 +323,10 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_tiled(const SRC *src, int
|
|||
quint32 *d = reinterpret_cast<quint32*>(dest + x * dstride
|
||||
+ h - 1 - starty);
|
||||
for (int y = starty; y > stopy; y -= pack) {
|
||||
quint32 c = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
quint32 c = src[y * sstride + x];
|
||||
for (int i = 1; i < pack; ++i) {
|
||||
const int shift = (sizeof(int) * 8 / pack * i);
|
||||
const DST color = qt_colorConvert<DST,SRC>(src[(y - i) * sstride + x], 0);
|
||||
const T color = src[(y - i) * sstride + x];
|
||||
c |= color << shift;
|
||||
}
|
||||
*d++ = c;
|
||||
|
|
@ -346,19 +336,19 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_tiled(const SRC *src, int
|
|||
if (unoptimizedY) {
|
||||
const int starty = unoptimizedY - 1;
|
||||
for (int x = startx; x < stopx; ++x) {
|
||||
DST *d = dest + x * dstride + h - 1 - starty;
|
||||
T *d = dest + x * dstride + h - 1 - starty;
|
||||
for (int y = starty; y >= 0; --y) {
|
||||
*d++ = qt_colorConvert<DST,SRC>(src[y * sstride + x], 0);
|
||||
*d++ = src[y * sstride + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_tiled_unpacked(const SRC *src, int w, int h,
|
||||
int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate270_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest,
|
||||
int dstride)
|
||||
{
|
||||
const int numTilesX = (w + tileSize - 1) / tileSize;
|
||||
const int numTilesY = (h + tileSize - 1) / tileSize;
|
||||
|
|
@ -372,10 +362,10 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_tiled_unpacked(const SRC
|
|||
const int stopy = qMax(starty - tileSize, 0);
|
||||
|
||||
for (int x = startx; x < stopx; ++x) {
|
||||
DST *d = (DST*)((char*)dest + x * dstride) + h - 1 - starty;
|
||||
T *d = (T*)((char*)dest + x * dstride) + h - 1 - starty;
|
||||
const char *s = (const char*)(src + x) + starty * sstride;
|
||||
for (int y = starty; y >= stopy; --y) {
|
||||
*d++ = qt_colorConvert<DST,SRC>(*(const SRC*)s, 0);
|
||||
*d++ = *(const T*)s;
|
||||
s -= sstride;
|
||||
}
|
||||
}
|
||||
|
|
@ -385,214 +375,112 @@ Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_tiled_unpacked(const SRC
|
|||
|
||||
#endif // QT_ROTATION_ALGORITHM
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate90_template(const SRC *src,
|
||||
int srcWidth, int srcHeight, int srcStride,
|
||||
DST *dest, int dstStride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate90_template(const T *src, int srcWidth, int srcHeight, int srcStride,
|
||||
T *dest, int dstStride)
|
||||
{
|
||||
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
|
||||
qt_memrotate90_cachedRead<DST,SRC>(src, srcWidth, srcHeight, srcStride,
|
||||
dest, dstStride);
|
||||
qt_memrotate90_cachedRead<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
|
||||
qt_memrotate90_cachedWrite<DST,SRC>(src, srcWidth, srcHeight, srcStride,
|
||||
dest, dstStride);
|
||||
qt_memrotate90_cachedWrite<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING
|
||||
qt_memrotate90_packing<DST,SRC>(src, srcWidth, srcHeight, srcStride,
|
||||
dest, dstStride);
|
||||
qt_memrotate90_packing<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED
|
||||
qt_memrotate90_tiled<DST,SRC>(src, srcWidth, srcHeight, srcStride,
|
||||
dest, dstStride);
|
||||
qt_memrotate90_tiled<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate180_template(const SRC *src,
|
||||
int w, int h, int sstride,
|
||||
DST *dest, int dstride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate180_template(const T *src, int w, int h, int sstride, T *dest, int dstride)
|
||||
{
|
||||
const char *s = (const char*)(src) + (h - 1) * sstride;
|
||||
for (int y = h - 1; y >= 0; --y) {
|
||||
DST *d = reinterpret_cast<DST*>((char *)(dest) + (h - y - 1) * dstride);
|
||||
src = reinterpret_cast<const SRC*>(s);
|
||||
T *d = reinterpret_cast<T*>((char *)(dest) + (h - y - 1) * dstride);
|
||||
src = reinterpret_cast<const T*>(s);
|
||||
for (int x = w - 1; x >= 0; --x) {
|
||||
d[w - x - 1] = qt_colorConvert<DST,SRC>(src[x], 0);
|
||||
d[w - x - 1] = src[x];
|
||||
}
|
||||
s -= sstride;
|
||||
}
|
||||
}
|
||||
|
||||
template <class DST, class SRC>
|
||||
Q_STATIC_TEMPLATE_FUNCTION inline void qt_memrotate270_template(const SRC *src,
|
||||
int srcWidth, int srcHeight, int srcStride,
|
||||
DST *dest, int dstStride)
|
||||
template <class T>
|
||||
Q_STATIC_TEMPLATE_FUNCTION
|
||||
inline void qt_memrotate270_template(const T *src, int srcWidth, int srcHeight, int srcStride,
|
||||
T *dest, int dstStride)
|
||||
{
|
||||
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
|
||||
qt_memrotate270_cachedRead<DST,SRC>(src, srcWidth, srcHeight, srcStride,
|
||||
dest, dstStride);
|
||||
qt_memrotate270_cachedRead<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
|
||||
qt_memrotate270_cachedWrite<DST,SRC>(src, srcWidth, srcHeight, srcStride,
|
||||
dest, dstStride);
|
||||
qt_memrotate270_cachedWrite<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING
|
||||
qt_memrotate270_packing<DST,SRC>(src, srcWidth, srcHeight, srcStride,
|
||||
dest, dstStride);
|
||||
qt_memrotate270_packing<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED
|
||||
qt_memrotate270_tiled_unpacked<DST,SRC>(src, srcWidth, srcHeight,
|
||||
srcStride,
|
||||
dest, dstStride);
|
||||
qt_memrotate270_tiled_unpacked<T>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
Q_STATIC_TEMPLATE_SPECIALIZATION
|
||||
inline void qt_memrotate90_template<quint24, quint24>(const quint24 *src,
|
||||
int srcWidth, int srcHeight, int srcStride,
|
||||
quint24 *dest, int dstStride)
|
||||
inline void qt_memrotate90_template<quint24>(const quint24 *src, int srcWidth, int srcHeight,
|
||||
int srcStride, quint24 *dest, int dstStride)
|
||||
{
|
||||
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
|
||||
qt_memrotate90_cachedRead<quint24,quint24>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
qt_memrotate90_cachedRead<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
|
||||
qt_memrotate90_cachedWrite<quint24,quint24>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
qt_memrotate90_cachedWrite<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING
|
||||
// packed algorithm not implemented
|
||||
qt_memrotate90_cachedRead<quint24,quint24>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
qt_memrotate90_cachedRead<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED
|
||||
// packed algorithm not implemented
|
||||
qt_memrotate90_tiled_unpacked<quint24,quint24>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
qt_memrotate90_tiled_unpacked<quint24>(src, srcWidth, srcHeight, srcStride, dest, dstStride);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
Q_STATIC_TEMPLATE_SPECIALIZATION
|
||||
inline void qt_memrotate90_template<quint24, quint32>(const quint32 *src,
|
||||
int srcWidth, int srcHeight, int srcStride,
|
||||
quint24 *dest, int dstStride)
|
||||
{
|
||||
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
|
||||
qt_memrotate90_cachedRead<quint24,quint32>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
|
||||
qt_memrotate90_cachedWrite<quint24,quint32>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING
|
||||
// packed algorithm not implemented
|
||||
qt_memrotate90_cachedRead<quint24,quint32>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED
|
||||
// packed algorithm not implemented
|
||||
qt_memrotate90_tiled_unpacked<quint24,quint32>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
Q_STATIC_TEMPLATE_SPECIALIZATION
|
||||
inline void qt_memrotate90_template<quint18, quint32>(const quint32 *src,
|
||||
int srcWidth, int srcHeight, int srcStride,
|
||||
quint18 *dest, int dstStride)
|
||||
{
|
||||
#if QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDREAD
|
||||
qt_memrotate90_cachedRead<quint18,quint32>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_CACHEDWRITE
|
||||
qt_memrotate90_cachedWrite<quint18,quint32>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_PACKING
|
||||
// packed algorithm not implemented
|
||||
qt_memrotate90_cachedRead<quint18,quint32>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
#elif QT_ROTATION_ALGORITHM == QT_ROTATION_TILED
|
||||
// packed algorithm not implemented
|
||||
qt_memrotate90_tiled_unpacked<quint18,quint32>(src, srcWidth, srcHeight,
|
||||
srcStride, dest, dstStride);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define QT_IMPL_MEMROTATE(srctype, desttype) \
|
||||
Q_GUI_EXPORT void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
|
||||
desttype *dest, int dstride) \
|
||||
#define QT_IMPL_MEMROTATE(type) \
|
||||
Q_GUI_EXPORT void qt_memrotate90(const type *src, int w, int h, int sstride, \
|
||||
type *dest, int dstride) \
|
||||
{ \
|
||||
qt_memrotate90_template(src, w, h, sstride, dest, dstride); \
|
||||
} \
|
||||
Q_GUI_EXPORT void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
|
||||
desttype *dest, int dstride) \
|
||||
Q_GUI_EXPORT void qt_memrotate180(const type *src, int w, int h, int sstride, \
|
||||
type *dest, int dstride) \
|
||||
{ \
|
||||
qt_memrotate180_template(src, w, h, sstride, dest, dstride); \
|
||||
} \
|
||||
Q_GUI_EXPORT void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
|
||||
desttype *dest, int dstride) \
|
||||
Q_GUI_EXPORT void qt_memrotate270(const type *src, int w, int h, int sstride, \
|
||||
type *dest, int dstride) \
|
||||
{ \
|
||||
qt_memrotate270_template(src, w, h, sstride, dest, dstride); \
|
||||
}
|
||||
|
||||
#define QT_IMPL_SIMPLE_MEMROTATE(srctype, desttype) \
|
||||
Q_GUI_EXPORT void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
|
||||
desttype *dest, int dstride) \
|
||||
#define QT_IMPL_SIMPLE_MEMROTATE(type) \
|
||||
Q_GUI_EXPORT void qt_memrotate90(const type *src, int w, int h, int sstride, \
|
||||
type *dest, int dstride) \
|
||||
{ \
|
||||
qt_memrotate90_tiled_unpacked<desttype,srctype>(src, w, h, sstride, dest, dstride); \
|
||||
qt_memrotate90_tiled_unpacked<type>(src, w, h, sstride, dest, dstride); \
|
||||
} \
|
||||
Q_GUI_EXPORT void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
|
||||
desttype *dest, int dstride) \
|
||||
Q_GUI_EXPORT void qt_memrotate180(const type *src, int w, int h, int sstride, \
|
||||
type *dest, int dstride) \
|
||||
{ \
|
||||
qt_memrotate180_template(src, w, h, sstride, dest, dstride); \
|
||||
} \
|
||||
Q_GUI_EXPORT void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
|
||||
desttype *dest, int dstride) \
|
||||
Q_GUI_EXPORT void qt_memrotate270(const type *src, int w, int h, int sstride, \
|
||||
type *dest, int dstride) \
|
||||
{ \
|
||||
qt_memrotate270_tiled_unpacked<desttype,srctype>(src, w, h, sstride, dest, dstride); \
|
||||
qt_memrotate270_tiled_unpacked<type>(src, w, h, sstride, dest, dstride); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QT_IMPL_MEMROTATE(quint32, quint32)
|
||||
QT_IMPL_MEMROTATE(quint32, quint16)
|
||||
QT_IMPL_MEMROTATE(quint16, quint32)
|
||||
QT_IMPL_MEMROTATE(quint16, quint16)
|
||||
QT_IMPL_MEMROTATE(quint24, quint24)
|
||||
QT_IMPL_MEMROTATE(quint32, quint24)
|
||||
QT_IMPL_MEMROTATE(quint32, quint18)
|
||||
QT_IMPL_MEMROTATE(quint32, quint8)
|
||||
QT_IMPL_MEMROTATE(quint16, quint8)
|
||||
QT_IMPL_MEMROTATE(qrgb444, quint8)
|
||||
QT_IMPL_MEMROTATE(quint8, quint8)
|
||||
|
||||
#if defined(QT_QWS_ROTATE_BGR)
|
||||
QT_IMPL_SIMPLE_MEMROTATE(quint16, qbgr565)
|
||||
QT_IMPL_SIMPLE_MEMROTATE(quint32, qbgr565)
|
||||
QT_IMPL_SIMPLE_MEMROTATE(qrgb555, qbgr555)
|
||||
QT_IMPL_SIMPLE_MEMROTATE(quint32, qbgr555)
|
||||
#endif
|
||||
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
QT_IMPL_MEMROTATE(quint32, qrgb_generic16)
|
||||
QT_IMPL_MEMROTATE(quint16, qrgb_generic16)
|
||||
#endif
|
||||
|
||||
struct qrgb_gl_rgba
|
||||
{
|
||||
public:
|
||||
inline qrgb_gl_rgba(quint32 v) {
|
||||
if (QSysInfo::ByteOrder == QSysInfo::LittleEndian)
|
||||
data = ((v << 16) & 0xff0000) | ((v >> 16) & 0xff) | (v & 0xff00ff00);
|
||||
else
|
||||
data = (v << 8) | ((v >> 24) & 0xff);
|
||||
}
|
||||
|
||||
inline operator quint32() const { return data; }
|
||||
|
||||
private:
|
||||
quint32 data;
|
||||
} Q_PACKED;
|
||||
|
||||
void Q_GUI_EXPORT qt_memrotate90_gl(const quint32 *src, int srcWidth, int srcHeight, int srcStride,
|
||||
quint32 *dest, int dstStride)
|
||||
{
|
||||
qt_memrotate90_template(src, srcWidth, srcHeight, srcStride, reinterpret_cast<qrgb_gl_rgba *>(dest), dstStride);
|
||||
}
|
||||
QT_IMPL_MEMROTATE(quint32)
|
||||
QT_IMPL_MEMROTATE(quint16)
|
||||
QT_IMPL_MEMROTATE(quint24)
|
||||
QT_IMPL_MEMROTATE(quint8)
|
||||
|
||||
void qt_memrotate90_16(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,37 +70,15 @@ QT_BEGIN_NAMESPACE
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define QT_DECL_MEMROTATE(srctype, desttype) \
|
||||
void Q_GUI_EXPORT qt_memrotate90(const srctype*, int, int, int, desttype*, int); \
|
||||
void Q_GUI_EXPORT qt_memrotate180(const srctype*, int, int, int, desttype*, int); \
|
||||
void Q_GUI_EXPORT qt_memrotate270(const srctype*, int, int, int, desttype*, int)
|
||||
#define QT_DECL_MEMROTATE(type) \
|
||||
void Q_GUI_EXPORT qt_memrotate90(const type*, int, int, int, type*, int); \
|
||||
void Q_GUI_EXPORT qt_memrotate180(const type*, int, int, int, type*, int); \
|
||||
void Q_GUI_EXPORT qt_memrotate270(const type*, int, int, int, type*, int)
|
||||
|
||||
void Q_GUI_EXPORT qt_memrotate90(const quint32*, int, int, int, quint32*, int);
|
||||
void Q_GUI_EXPORT qt_memrotate180(const quint32*, int, int, int, quint32*, int);
|
||||
void Q_GUI_EXPORT qt_memrotate270(const quint32*, int, int, int, quint32*, int);
|
||||
|
||||
QT_DECL_MEMROTATE(quint32, quint16);
|
||||
QT_DECL_MEMROTATE(quint16, quint32);
|
||||
QT_DECL_MEMROTATE(quint16, quint16);
|
||||
QT_DECL_MEMROTATE(quint24, quint24);
|
||||
QT_DECL_MEMROTATE(quint32, quint24);
|
||||
QT_DECL_MEMROTATE(quint32, quint18);
|
||||
QT_DECL_MEMROTATE(quint32, quint8);
|
||||
QT_DECL_MEMROTATE(quint16, quint8);
|
||||
QT_DECL_MEMROTATE(qrgb444, quint8);
|
||||
QT_DECL_MEMROTATE(quint8, quint8);
|
||||
|
||||
#ifdef QT_QWS_ROTATE_BGR
|
||||
QT_DECL_MEMROTATE(quint16, qbgr565);
|
||||
QT_DECL_MEMROTATE(quint32, qbgr565);
|
||||
QT_DECL_MEMROTATE(qrgb555, qbgr555);
|
||||
QT_DECL_MEMROTATE(quint32, qbgr555);
|
||||
#endif
|
||||
|
||||
#ifdef QT_QWS_DEPTH_GENERIC
|
||||
QT_DECL_MEMROTATE(quint32, qrgb_generic16);
|
||||
QT_DECL_MEMROTATE(quint16, qrgb_generic16);
|
||||
#endif
|
||||
QT_DECL_MEMROTATE(quint32);
|
||||
QT_DECL_MEMROTATE(quint16);
|
||||
QT_DECL_MEMROTATE(quint24);
|
||||
QT_DECL_MEMROTATE(quint8);
|
||||
|
||||
#undef QT_DECL_MEMROTATE
|
||||
|
||||
|
|
|
|||
|
|
@ -1025,17 +1025,17 @@ void tst_QImage::setPixel_data()
|
|||
QTest::newRow("RGB16 blue") << int(QImage::Format_RGB16)
|
||||
<< 0xff0000ff << 0x001fu;
|
||||
QTest::newRow("ARGB8565_Premultiplied red") << int(QImage::Format_ARGB8565_Premultiplied)
|
||||
<< 0xffff0000 << 0xffff0000;
|
||||
<< 0xffff0000 << 0xf800ffu;
|
||||
QTest::newRow("ARGB8565_Premultiplied green") << int(QImage::Format_ARGB8565_Premultiplied)
|
||||
<< 0xff00ff00 << 0xff00ff00;
|
||||
<< 0xff00ff00 << 0x07e0ffu;
|
||||
QTest::newRow("ARGB8565_Premultiplied blue") << int(QImage::Format_ARGB8565_Premultiplied)
|
||||
<< 0xff0000ff << 0xff0000ff;
|
||||
<< 0xff0000ff << 0x001fffu;
|
||||
QTest::newRow("RGB666 red") << int(QImage::Format_RGB666)
|
||||
<< 0xffff0000 << 0xffff0000;
|
||||
<< 0xffff0000 << 0x03f000u;
|
||||
QTest::newRow("RGB666 green") << int(QImage::Format_RGB666)
|
||||
<< 0xff00ff00 << 0xff00ff00;;
|
||||
<< 0xff00ff00 << 0x000fc0u;
|
||||
QTest::newRow("RGB666 blue") << int(QImage::Format_RGB666)
|
||||
<< 0xff0000ff << 0xff0000ff;
|
||||
<< 0xff0000ff << 0x00003fu;
|
||||
QTest::newRow("RGB555 red") << int(QImage::Format_RGB555)
|
||||
<< 0xffff0000 << 0x7c00u;
|
||||
QTest::newRow("RGB555 green") << int(QImage::Format_RGB555)
|
||||
|
|
@ -1043,17 +1043,17 @@ void tst_QImage::setPixel_data()
|
|||
QTest::newRow("RGB555 blue") << int(QImage::Format_RGB555)
|
||||
<< 0xff0000ff << 0x001fu;
|
||||
QTest::newRow("ARGB8555_Premultiplied red") << int(QImage::Format_ARGB8555_Premultiplied)
|
||||
<< 0xffff0000 << 0xffff0000;
|
||||
<< 0xffff0000 << 0x7c00ffu;
|
||||
QTest::newRow("ARGB8555_Premultiplied green") << int(QImage::Format_ARGB8555_Premultiplied)
|
||||
<< 0xff00ff00 << 0xff00ff00;
|
||||
<< 0xff00ff00 << 0x03e0ffu;
|
||||
QTest::newRow("ARGB8555_Premultiplied blue") << int(QImage::Format_ARGB8555_Premultiplied)
|
||||
<< 0xff0000ff << 0xff0000ff;
|
||||
<< 0xff0000ff << 0x001fffu;
|
||||
QTest::newRow("RGB888 red") << int(QImage::Format_RGB888)
|
||||
<< 0xffff0000 << 0xffff0000;
|
||||
<< 0xffff0000 << 0x0000ffu;
|
||||
QTest::newRow("RGB888 green") << int(QImage::Format_RGB888)
|
||||
<< 0xff00ff00 << 0xff00ff00;
|
||||
<< 0xff00ff00 << 0x00ff00u;
|
||||
QTest::newRow("RGB888 blue") << int(QImage::Format_RGB888)
|
||||
<< 0xff0000ff << 0xff0000ff;
|
||||
<< 0xff0000ff << 0xff0000u;
|
||||
}
|
||||
|
||||
void tst_QImage::setPixel()
|
||||
|
|
@ -1106,57 +1106,18 @@ void tst_QImage::setPixel()
|
|||
break;
|
||||
}
|
||||
case int(QImage::Format_RGB666):
|
||||
{
|
||||
for (int y = 0; y < h; ++y) {
|
||||
const qrgb666 *row = (const qrgb666*)(img.scanLine(y));
|
||||
for (int x = 0; x < w; ++x) {
|
||||
quint32 result = row[x];
|
||||
if (result != expected)
|
||||
printf("[x,y]: %d,%d, expected=%04x, result=%04x\n",
|
||||
x, y, expected, result);
|
||||
QCOMPARE(result, expected);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case int(QImage::Format_ARGB8565_Premultiplied):
|
||||
{
|
||||
for (int y = 0; y < h; ++y) {
|
||||
const qargb8565 *row = (const qargb8565*)(img.scanLine(y));
|
||||
for (int x = 0; x < w; ++x) {
|
||||
quint32 result = row[x];
|
||||
if (result != expected)
|
||||
printf("[x,y]: %d,%d, expected=%04x, result=%04x\n",
|
||||
x, y, expected, result);
|
||||
QCOMPARE(result, expected);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case int(QImage::Format_ARGB8555_Premultiplied):
|
||||
{
|
||||
for (int y = 0; y < h; ++y) {
|
||||
const qargb8555 *row = (const qargb8555*)(img.scanLine(y));
|
||||
for (int x = 0; x < w; ++x) {
|
||||
quint32 result = row[x];
|
||||
if (result != expected)
|
||||
printf("[x,y]: %d,%d, expected=%04x, result=%04x\n",
|
||||
x, y, expected, result);
|
||||
QCOMPARE(result, expected);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case int(QImage::Format_RGB888):
|
||||
{
|
||||
for (int y = 0; y < h; ++y) {
|
||||
const qrgb888 *row = (const qrgb888*)(img.scanLine(y));
|
||||
const quint24 *row = (const quint24*)(img.scanLine(y));
|
||||
for (int x = 0; x < w; ++x) {
|
||||
qrgb888 result = row[x];
|
||||
quint32 result = row[x];
|
||||
if (result != expected)
|
||||
printf("[x,y]: %d,%d, expected=%04x, result=%04x\n",
|
||||
x, y, expected, quint32(result));
|
||||
QCOMPARE(uint(result), expected);
|
||||
x, y, expected, result);
|
||||
QCOMPARE(result, expected);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue