From 5ce23ae5eae63c556609d06921efb38308833261 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 21 Aug 2020 03:15:46 +0300 Subject: [PATCH] drop obscure (24-bit) QImage formats support --- src/gui/image/qbmphandler.cpp | 18 +- src/gui/image/qimage.cpp | 562 +------------ src/gui/image/qimage.h | 18 - src/gui/image/qimage_p.h | 9 - src/gui/image/qpixmap_raster.cpp | 20 +- src/gui/image/qpixmapfilter.cpp | 34 +- src/gui/image/qpnghandler.cpp | 7 +- src/gui/image/qppmhandler.cpp | 20 +- src/gui/painting/qdrawhelper.cpp | 925 +-------------------- src/gui/painting/qdrawhelper_p.h | 695 ---------------- src/gui/painting/qmemrotate_p.h | 1 - src/gui/painting/qpaintengine_raster.cpp | 12 - src/plugins/imageformats/jpeg/qjpeghandler.cpp | 3 - .../qimageconversion/tst_qimageconversion.cpp | 26 +- .../gui/painting/qpainter/tst_qpainter.cpp | 25 +- 15 files changed, 54 insertions(+), 2321 deletions(-) diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index c0c8ded5f..6197f8eae 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -760,23 +760,9 @@ bool QBmpHandler::read(QImage *image) bool QBmpHandler::write(const QImage &img) { - QImage image; - switch (img.format()) { - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB4444_Premultiplied: - image = img.convertToFormat(QImage::Format_ARGB32); - break; - case QImage::Format_RGB16: - case QImage::Format_RGB888: - case QImage::Format_RGB666: - case QImage::Format_RGB555: - case QImage::Format_RGB444: + QImage image(img); + if (image.format() == QImage::Format_RGB16) { image = img.convertToFormat(QImage::Format_RGB32); - break; - default: - image = img; } QIODevice *d = device(); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 978f250ca..a31e9d99c 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -79,31 +79,6 @@ QT_BEGIN_NAMESPACE # error No image format available for streaming #endif -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; - } -} - - #define QIMAGE_SANITYCHECK_MEMORY(image) \ if (Q_UNLIKELY((image).isNull())) { \ qWarning("QImage: out of memory, returning null image"); \ @@ -136,12 +111,6 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format) if (!size.isValid() || 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); @@ -214,49 +183,6 @@ bool QImageData::checkForAlphaPixels() const } } break; - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_ARGB8565_Premultiplied: { - uchar *bits = data; - uchar *end_bits = data + bytes_per_line; - - for (int y=0; y(reinterpret_cast(d->data), pixel, 0, 0, d->width, d->height, d->bytes_per_line); return; - } else if (d->depth == 24) { - qt_rectfill(reinterpret_cast(d->data), pixel, - 0, 0, d->width, d->height, d->bytes_per_line); - return; } if (d->format == Format_RGB32) @@ -1687,8 +1587,7 @@ void QImage::fill(const QColor &color) fill(pixel); } else if (d->depth == 16 && d->format == QImage::Format_RGB16) { - qrgb565 p(color.rgba()); - fill((uint) p.rawValue()); + fill((uint) color.rgba()); } else if (d->depth == 1) { if (color == Qt::color1) @@ -2666,24 +2565,6 @@ static void convert_Mono_to_Indexed8(QImageData *dest, const QImageData *src, Qt 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) -CONVERT_DECL(quint16, qrgb555) -CONVERT_DECL(qrgb555, quint16) -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 @@ -2696,14 +2577,6 @@ CONVERT_DECL(qargb4444, quint32) 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 */ @@ -2711,7 +2584,7 @@ CONVERT_DECL(qargb4444, quint32) static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormats] = { { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, @@ -2721,14 +2594,6 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat convert_Mono_to_X32, convert_Mono_to_X32, convert_Mono_to_X32, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, 0 }, // Format_Mono @@ -2740,14 +2605,6 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat convert_Mono_to_X32, convert_Mono_to_X32, convert_Mono_to_X32, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, 0 }, // Format_MonoLSB @@ -2759,14 +2616,6 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat convert_Indexed8_to_X32, convert_Indexed8_to_X32, convert_Indexed8_to_X32, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, 0 }, // Format_Indexed8 @@ -2779,14 +2628,6 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat 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) }, // Format_RGB32 { @@ -2797,15 +2638,7 @@ 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_PTR(quint16, quint32) }, // Format_ARGB32 { @@ -2816,14 +2649,6 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat convert_ARGB_PM_to_RGB, convert_ARGB_PM_to_ARGB, 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, 0 }, // Format_ARGB32_Premultiplied @@ -2835,168 +2660,8 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat CONVERT_PTR(quint32, quint16), CONVERT_PTR(quint32, quint16), CONVERT_PTR(quint32, quint16), - 0, - 0, - 0, - 0, - CONVERT_PTR(qrgb555, quint16), - 0, - 0, - 0, 0 }, // Format_RGB16 - - { - 0, - 0, - 0, - 0, - CONVERT_PTR(quint32, qargb8565), - CONVERT_PTR(quint32, qargb8565), - CONVERT_PTR(quint32, qargb8565), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - }, // Format_ARGB8565_Premultiplied - - { - 0, - 0, - 0, - 0, - CONVERT_PTR(quint32, qrgb666), - CONVERT_PTR(quint32, qrgb666), - CONVERT_PTR(quint32, qrgb666), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - }, // Format_RGB666 - - { - 0, - 0, - 0, - 0, - CONVERT_PTR(quint32, qargb6666), - CONVERT_PTR(quint32, qargb6666), - CONVERT_PTR(quint32, qargb6666), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - }, // Format_ARGB6666_Premultiplied - - { - 0, - 0, - 0, - 0, - CONVERT_PTR(quint32, qrgb555), - CONVERT_PTR(quint32, qrgb555), - CONVERT_PTR(quint32, qrgb555), - CONVERT_PTR(quint16, qrgb555), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - }, // Format_RGB555 - - { - 0, - 0, - 0, - 0, - CONVERT_PTR(quint32, qargb8555), - CONVERT_PTR(quint32, qargb8555), - CONVERT_PTR(quint32, qargb8555), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - }, // Format_ARGB8555_Premultiplied - - { - 0, - 0, - 0, - 0, - CONVERT_PTR(quint32, qrgb888), - CONVERT_PTR(quint32, qrgb888), - CONVERT_PTR(quint32, qrgb888), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - }, // Format_RGB888 - - { - 0, - 0, - 0, - 0, - CONVERT_PTR(quint32, qrgb444), - CONVERT_PTR(quint32, qrgb444), - CONVERT_PTR(quint32, qrgb444), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - }, // Format_RGB444 - - { - 0, - 0, - 0, - 0, - CONVERT_PTR(quint32, qargb4444), - CONVERT_PTR(quint32, qargb4444), - CONVERT_PTR(quint32, qargb4444), - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - } // Format_ARGB4444_Premultiplied }; /*! @@ -3234,22 +2899,6 @@ QRgb QImage::pixel(int x, int y) const 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(reinterpret_cast(s)[x], 0); - case Format_RGB666: - return qt_colorConvert(reinterpret_cast(s)[x], 0); - case Format_ARGB6666_Premultiplied: - return qt_colorConvert(reinterpret_cast(s)[x], 0); - case Format_RGB555: - return qt_colorConvert(reinterpret_cast(s)[x], 0); - case Format_ARGB8555_Premultiplied: - return qt_colorConvert(reinterpret_cast(s)[x], 0); - case Format_RGB888: - return qt_colorConvert(reinterpret_cast(s)[x], 0); - case Format_RGB444: - return qt_colorConvert(reinterpret_cast(s)[x], 0); - case Format_ARGB4444_Premultiplied: - return qt_colorConvert(reinterpret_cast(s)[x], 0); case Format_RGB16: return qt_colorConvert(reinterpret_cast(s)[x], 0); default: @@ -3334,30 +2983,6 @@ void QImage::setPixel(int x, int y, uint index_or_rgb) case Format_RGB16: ((quint16 *)s)[x] = qt_colorConvert(p, 0); break; - case Format_ARGB8565_Premultiplied: - ((qargb8565*)s)[x] = qt_colorConvert(p, 0); - break; - case Format_RGB666: - ((qrgb666*)s)[x] = qt_colorConvert(p, 0); - break; - case Format_ARGB6666_Premultiplied: - ((qargb6666*)s)[x] = qt_colorConvert(p, 0); - break; - case Format_RGB555: - ((qrgb555*)s)[x] = qt_colorConvert(p, 0); - break; - case Format_ARGB8555_Premultiplied: - ((qargb8555*)s)[x] = qt_colorConvert(p, 0); - break; - case Format_RGB888: - ((qrgb888*)s)[x] = qt_colorConvert(p, 0); - break; - case Format_RGB444: - ((qrgb444*)s)[x] = qt_colorConvert(p, 0); - break; - case Format_ARGB4444_Premultiplied: - ((qargb4444*)s)[x] = qt_colorConvert(p, 0); - break; case Format_Invalid: case NImageFormats: Q_ASSERT(false); @@ -3390,12 +3015,6 @@ bool QImage::allGray() const while (p--) if (!qIsGray(qt_colorConvert(*b++, 0))) return false; - } else if (d->format == QImage::Format_RGB888) { - int p = width()*height(); - const qrgb888* b = (const qrgb888 *)constBits(); - while (p--) - if (!qIsGray(qt_colorConvert(*b++, 0))) - return false; } else { if (d->colortable.isEmpty()) return true; @@ -3422,7 +3041,6 @@ bool QImage::isGrayscale() const switch (depth()) { case 32: - case 24: case 16: return allGray(); case 8: { @@ -3886,9 +3504,6 @@ QImage QImage::mirrored(bool horizontal, bool vertical) const case 32: do_mirror_data(result.d, d, dstX0, dstY0, dstXIncr, dstYIncr, w, h); break; - case 24: - do_mirror_data(result.d, d, dstX0, dstY0, dstXIncr, dstYIncr, w, h); - break; case 16: do_mirror_data(result.d, d, dstX0, dstY0, dstXIncr, dstYIncr, w, h); break; @@ -4009,112 +3624,6 @@ QImage QImage::rgbSwapped() const } } 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); - } - } - 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(res.scanLine(i)); - const qrgb666 *p = reinterpret_cast(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(res.scanLine(i)); - const quint16 *p = reinterpret_cast(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; } @@ -4708,20 +4217,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth } break; - case 24: // 24 bpp transform - while (dptr < maxp) { - if (trigx < maxws && trigy < maxhs) { - const uchar *p2 = sptr+sbpl*(trigy>>12) + ((trigx>>12)*3); - dptr[0] = p2[0]; - dptr[1] = p2[1]; - dptr[2] = p2[2]; - } - trigx += m11; - trigy += m12; - dptr += 3; - } - break; - case 32: // 32 bpp transform while (dptr < maxp) { if (trigx < maxws && trigy < maxhs) @@ -5008,10 +4503,6 @@ bool QImage::hasAlphaChannel() const { return d && (d->format == Format_ARGB32_Premultiplied || d->format == Format_ARGB32 - || d->format == Format_ARGB8565_Premultiplied - || d->format == Format_ARGB8555_Premultiplied - || d->format == Format_ARGB6666_Premultiplied - || d->format == Format_ARGB4444_Premultiplied || (d->has_alpha_clut && (d->format == Format_Indexed8 || d->format == Format_Mono || d->format == Format_MonoLSB))); @@ -5040,18 +4531,6 @@ int QImage::bitPlaneCount() const case QImage::Format_RGB32: bpc = 24; break; - case QImage::Format_RGB666: - bpc = 18; - break; - case QImage::Format_RGB555: - bpc = 15; - break; - case QImage::Format_ARGB8555_Premultiplied: - bpc = 23; - break; - case QImage::Format_RGB444: - bpc = 12; - break; default: bpc = qt_depthForFormat(d->format); break; @@ -5106,19 +4585,7 @@ static QImage rotated90(const QImage &image) { reinterpret_cast(out.bits()), out.bytesPerLine()); break; - case QImage::Format_RGB666: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_RGB888: - qt_memrotate270(reinterpret_cast(image.constBits()), - w, h, image.bytesPerLine(), - reinterpret_cast(out.bits()), - out.bytesPerLine()); - break; - case QImage::Format_RGB555: case QImage::Format_RGB16: - case QImage::Format_ARGB4444_Premultiplied: qt_memrotate270(reinterpret_cast(image.constBits()), w, h, image.bytesPerLine(), reinterpret_cast(out.bits()), @@ -5165,19 +4632,7 @@ static QImage rotated270(const QImage &image) { reinterpret_cast(out.bits()), out.bytesPerLine()); break; - case QImage::Format_RGB666: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_RGB888: - qt_memrotate90(reinterpret_cast(image.constBits()), - w, h, image.bytesPerLine(), - reinterpret_cast(out.bits()), - out.bytesPerLine()); - break; - case QImage::Format_RGB555: case QImage::Format_RGB16: - case QImage::Format_ARGB4444_Premultiplied: qt_memrotate90(reinterpret_cast(image.constBits()), w, h, image.bytesPerLine(), reinterpret_cast(out.bits()), @@ -5302,7 +4757,6 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode break; case 1: case 16: - case 24: case 32: memset(dImage.bits(), 0x00, dImage.byteCount()); break; diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index aca4de38b..4bb6256b9 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -66,24 +66,6 @@ public: 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, -#if 0 - // reserved for future use - Format_RGB15, - Format_Grayscale16, - Format_Grayscale8, - Format_Grayscale4, - Format_Grayscale4LSB, - Format_Grayscale2, - Format_Grayscale2LSB -#endif NImageFormats }; diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 028ef26ab..3c2352867 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -100,17 +100,8 @@ static inline int qt_depthForFormat(QImage::Format format) case QImage::Format_ARGB32: case QImage::Format_ARGB32_Premultiplied: return 32; - case QImage::Format_RGB555: case QImage::Format_RGB16: - case QImage::Format_RGB444: - case QImage::Format_ARGB4444_Premultiplied: return 16; - case QImage::Format_RGB666: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_RGB888: - return 24; } return 0; } diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 8ca795fda..c5bf2fff6 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -114,11 +114,6 @@ void QRasterPixmapData::fromImage(const QImage &sourceImage, QImage::Format opaqueFormat = QImage::systemFormat(); QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied; - // We don't care about the others... - if (opaqueFormat == QImage::Format_RGB16) { - alphaFormat = QImage::Format_ARGB8565_Premultiplied; - } - if (!sourceImage.hasAlphaChannel()) { format = opaqueFormat; } else if ((flags & Qt::NoOpaqueDetection) == 0 @@ -173,20 +168,7 @@ bool QRasterPixmapData::scroll(int dx, int dy, const QRect &rect) void QRasterPixmapData::fill(const QColor &color) { if (color.alpha() != 255 && !image.hasAlphaChannel()) { - switch (image.format()) { - case QImage::Format_RGB666: { - image = image.convertToFormat(QImage::Format_ARGB6666_Premultiplied); - break; - } - case QImage::Format_RGB444: { - image = image.convertToFormat(QImage::Format_ARGB4444_Premultiplied); - break; - } - default: { - image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); - break; - } - } + image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); } image.fill(color); diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index 45ce9f319..48918cd0b 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -467,40 +467,8 @@ static QImage qt_halfScaled(const QImage &source) } return dest; - } else if (source.format() == QImage::Format_ARGB8565_Premultiplied) { - QImage dest(source.width() / 2, source.height() / 2, srcImage.format()); - - const uchar *src = srcImage.constBits(); - int sx = srcImage.bytesPerLine(); - int sx2 = sx << 1; - - uchar *dst = dest.bits(); - int dx = dest.bytesPerLine(); - int ww = dest.width(); - int hh = dest.height(); - - for (int y = hh; y; --y, dst += dx, src += sx2) { - const uchar *p1 = src; - const uchar *p2 = src + sx; - uchar *q = dst; - for (int x = ww; x; --x, q += 3, p1 += 6, p2 += 6) { - // alpha - q[0] = AVG(AVG(p1[0], p1[3]), AVG(p2[0], p2[3])); - // rgb - const quint16 p16_1 = (p1[2] << 8) | p1[1]; - const quint16 p16_2 = (p1[5] << 8) | p1[4]; - const quint16 p16_3 = (p2[2] << 8) | p2[1]; - const quint16 p16_4 = (p2[5] << 8) | p2[4]; - const quint16 result = AVG16(AVG16(p16_1, p16_2), AVG16(p16_3, p16_4)); - q[1] = result & 0xff; - q[2] = result >> 8; - } - } - - return dest; } else if (source.format() != QImage::Format_ARGB32_Premultiplied - && source.format() != QImage::Format_RGB32) - { + && source.format() != QImage::Format_RGB32) { srcImage = source.convertToFormat(QImage::Format_ARGB32_Premultiplied); } diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 0c1e76d95..f3487a93b 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -595,9 +595,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in) // Qt==ARGB==Big(ARGB)==Little(BGRA). But RGB888 is RGB regardless #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN - if (image.format() != QImage::Format_RGB888) { - png_set_bgr(png_ptr); - } + png_set_bgr(png_ptr); #endif QPoint offset = image.offset(); @@ -621,7 +619,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in) if (image.depth() != 1) png_set_packing(png_ptr); - if (color_type == PNG_COLOR_TYPE_RGB && image.format() != QImage::Format_RGB888) + if (color_type == PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr, 0, QFILLER_ORDER); int height = image.height(); @@ -632,7 +630,6 @@ bool QPNGImageWriter::writeImage(const QImage& image, int quality_in) case QImage::Format_Indexed8: case QImage::Format_RGB32: case QImage::Format_ARGB32: - case QImage::Format_RGB888: { png_bytep* row_pointers = new png_bytep[height]; for (int y=0; y> 5) & 0x07e0; - t |= (((x & 0xf81f) * a + (y & 0xf81f) * b) >> 5) & 0xf81f; - dest = t; -} - /* Destination fetch. This is simple as we don't have to do bounds checks or transformations @@ -150,14 +141,6 @@ static DestFetchProc destFetchProc[QImage::NImageFormats] = destFetchARGB32, // Format_ARGB32, destFetchARGB32P, // Format_ARGB32_Premultiplied destFetchRGB16, // Format_RGB16 - destFetch, // Format_ARGB8565_Premultiplied - destFetch, // Format_RGB666 - destFetch, // Format_ARGB6666_Premultiplied - destFetch, // Format_RGB555 - destFetch, // Format_ARGB8555_Premultiplied - destFetch, // Format_RGB888 - destFetch, // Format_RGB444 - destFetch // Format_ARGB4444_Premultiplied }; /* @@ -294,14 +277,6 @@ static DestStoreProc destStoreProc[QImage::NImageFormats] = destStoreARGB32, // Format_ARGB32, 0, // Format_ARGB32_Premultiplied destStoreRGB16, // Format_RGB16 - destStore, // Format_ARGB8565_Premultiplied - destStore, // Format_RGB666 - destStore, // Format_ARGB6666_Premultiplied - destStore, // Format_RGB555 - destStore, // Format_ARGB8555_Premultiplied - destStore, // Format_RGB888 - destStore, // Format_RGB444 - destStore // Format_ARGB4444_Premultiplied }; /* @@ -369,78 +344,6 @@ uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, } template<> -uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, - const QVector *) -{ - const qargb8565 color = reinterpret_cast(scanLine)[x]; - return qt_colorConvert(color, 0); -} - -template<> -uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, - const QVector *) -{ - const qrgb666 color = reinterpret_cast(scanLine)[x]; - return qt_colorConvert(color, 0); -} - -template<> -uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, - const QVector *) -{ - const qargb6666 color = reinterpret_cast(scanLine)[x]; - return qt_colorConvert(color, 0); -} - -template<> -uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, - const QVector *) -{ - const qrgb555 color = reinterpret_cast(scanLine)[x]; - return qt_colorConvert(color, 0); -} - -template<> -uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, - const QVector *) -{ - const qargb8555 color = reinterpret_cast(scanLine)[x]; - return qt_colorConvert(color, 0); -} - -template<> -uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, - const QVector *) -{ - const qrgb888 color = reinterpret_cast(scanLine)[x]; - return qt_colorConvert(color, 0); -} - -template<> -uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, - const QVector *) -{ - const qrgb444 color = reinterpret_cast(scanLine)[x]; - return qt_colorConvert(color, 0); -} - -template<> -uint QT_FASTCALL qt_fetchPixel(const uchar *scanLine, - int x, - const QVector *) -{ - const qargb4444 color = reinterpret_cast(scanLine)[x]; - return qt_colorConvert(color, 0); -} - -template<> uint QT_FASTCALL qt_fetchPixel(const uchar *, int , const QVector *) @@ -460,15 +363,7 @@ static const FetchPixelProc fetchPixelProc[QImage::NImageFormats] = qt_fetchPixel, qt_fetchPixel, qt_fetchPixel, - qt_fetchPixel, - qt_fetchPixel, - qt_fetchPixel, - qt_fetchPixel, - qt_fetchPixel, - qt_fetchPixel, - qt_fetchPixel, - qt_fetchPixel, - qt_fetchPixel + qt_fetchPixel }; enum TextureBlendType { @@ -662,15 +557,7 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { qt_fetchUntransformed, // RGB32 qt_fetchUntransformed, // ARGB32 qt_fetchUntransformed, // ARGB32_Premultiplied - qt_fetchUntransformed, // RGB16 - qt_fetchUntransformed,// ARGB8565_Premultiplied - qt_fetchUntransformed, // RGB666 - qt_fetchUntransformed,// ARGB6666_Premultiplied - qt_fetchUntransformed, // RGB555 - qt_fetchUntransformed,// ARGB8555_Premultiplied - qt_fetchUntransformed, // RGB888 - qt_fetchUntransformed, // RGB444 - qt_fetchUntransformed // ARGB4444_Premultiplied + qt_fetchUntransformed // RGB16 }, // Tiled { @@ -681,15 +568,7 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { qt_fetchUntransformed, // RGB32 qt_fetchUntransformed, // ARGB32 qt_fetchUntransformed, // ARGB32_Premultiplied - qt_fetchUntransformed, // RGB16 - qt_fetchUntransformed,// ARGB8565_Premultiplied - qt_fetchUntransformed, // RGB666 - qt_fetchUntransformed,// ARGB6666_Premultiplied - qt_fetchUntransformed, // RGB555 - qt_fetchUntransformed,// ARGB8555_Premultiplied - qt_fetchUntransformed, // RGB888 - qt_fetchUntransformed, // RGB444 - qt_fetchUntransformed // ARGB4444_Premultiplied + qt_fetchUntransformed // RGB16 }, // Transformed { @@ -700,15 +579,7 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformed, // RGB32 fetchTransformed, // ARGB32 fetchTransformed, // ARGB32_Premultiplied - fetchTransformed, // RGB16 - fetchTransformed, // ARGB8565_Premultiplied - fetchTransformed, // RGB666 - fetchTransformed, // ARGB6666_Premultiplied - fetchTransformed, // RGB555 - fetchTransformed, // ARGB8555_Premultiplied - fetchTransformed, // RGB888 - fetchTransformed, // RGB444 - fetchTransformed, // ARGB4444_Premultiplied + fetchTransformed // RGB16 }, { 0, // TransformedTiled @@ -718,15 +589,7 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformed, // RGB32 fetchTransformed, // ARGB32 fetchTransformed, // ARGB32_Premultiplied - fetchTransformed, // RGB16 - fetchTransformed, // ARGB8565_Premultiplied - fetchTransformed, // RGB666 - fetchTransformed, // ARGB6666_Premultiplied - fetchTransformed, // RGB555 - fetchTransformed, // ARGB8555_Premultiplied - fetchTransformed, // RGB888 - fetchTransformed, // RGB444 - fetchTransformed, // ARGB4444_Premultiplied + fetchTransformed // RGB16 }, { 0, // Bilinear @@ -737,14 +600,6 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformedBilinear, // ARGB32 fetchTransformedBilinear, // ARGB32_Premultiplied fetchTransformedBilinear, // RGB16 - fetchTransformedBilinear, // ARGB8565_Premultiplied - fetchTransformedBilinear, // RGB666 - fetchTransformedBilinear, // ARGB6666_Premultiplied - fetchTransformedBilinear, // RGB555 - fetchTransformedBilinear, // ARGB8555_Premultiplied - fetchTransformedBilinear, // RGB888 - fetchTransformedBilinear, // RGB444 - fetchTransformedBilinear // ARGB4444_Premultiplied }, { 0, // BilinearTiled @@ -754,15 +609,7 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = { fetchTransformedBilinear, // RGB32 fetchTransformedBilinear, // ARGB32 fetchTransformedBilinear, // ARGB32_Premultiplied - fetchTransformedBilinear, // RGB16 - fetchTransformedBilinear, // ARGB8565_Premultiplied - fetchTransformedBilinear, // RGB666 - fetchTransformedBilinear, // ARGB6666_Premultiplied - fetchTransformedBilinear, // RGB555 - fetchTransformedBilinear, // ARGB8555_Premultiplied - fetchTransformedBilinear, // RGB888 - fetchTransformedBilinear, // RGB444 - fetchTransformedBilinear // ARGB4444_Premultiplied + fetchTransformedBilinear // RGB16 }, }; @@ -2853,19 +2700,6 @@ static void blend_color_generic(int count, const QSpan *spans, void *userData) } } -static void blend_color_argb(int count, const QSpan *spans, void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - - Operator op = getOperator(data, spans, count); - - while (count--) { - uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; - op.funcSolid(target, spans->len, data->solid.color, spans->coverage); - ++spans; - } -} - static void blend_src_generic(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -2971,104 +2805,6 @@ static void blend_untransformed_generic(int count, const QSpan *spans, void *use } } -static void blend_untransformed_argb(int count, const QSpan *spans, void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - Operator op = getOperator(data, spans, count); - - const int image_width = data->texture.width; - const int image_height = data->texture.height; - int xoff = -qRound(-data->dx); - int yoff = -qRound(-data->dy); - - while (count--) { - int x = spans->x; - int length = spans->len; - int sx = xoff + x; - int sy = yoff + spans->y; - if (sy >= 0 && sy < image_height && sx < image_width) { - if (sx < 0) { - x -= sx; - length += sx; - sx = 0; - } - if (sx + length > image_width) - length = image_width - sx; - if (length > 0) { - const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; - const uint *src = (const uint *)data->texture.scanLine(sy) + sx; - uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; - op.func(dest, src, length, coverage); - } - } - ++spans; - } -} - -static void QT_FASTCALL blendUntransformed(qrgb565 *dest, const qrgb565 *src, - quint8 coverage, int length) -{ - Q_ASSERT(coverage > 0 && coverage < 255); - - const quint8 alpha = qrgb565::alpha(coverage); - if (alpha) { - const quint8 ialpha = qrgb565::ialpha(coverage); - for (int i = 0; i < length; ++i) - interpolate_pixel(dest[i], ialpha, src[i], alpha); - } -} - -static void blend_untransformed_rgb565(int count, const QSpan *spans, - void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; - - if (mode != QPainter::CompositionMode_SourceOver && - mode != QPainter::CompositionMode_Source) - { - blend_src_generic(count, spans, userData); - return; - } - - const int image_width = data->texture.width; - const int image_height = data->texture.height; - int xoff = -qRound(-data->dx); - int yoff = -qRound(-data->dy); - - while (count--) { - const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; - if (coverage == 0) { - ++spans; - continue; - } - - int x = spans->x; - int length = spans->len; - int sx = xoff + x; - int sy = yoff + spans->y; - if (sy >= 0 && sy < image_height && sx < image_width) { - if (sx < 0) { - x -= sx; - length += sx; - sx = 0; - } - if (sx + length > image_width) - length = image_width - sx; - if (length > 0) { - qrgb565 *dest = ((qrgb565*)data->rasterBuffer->scanLine(spans->y)) + x; - const qrgb565 *src = (const qrgb565*)data->texture.scanLine(sy) + sx; - if (coverage == 255) { - qt_memconvert(dest, src, length); - } else { - blendUntransformed(dest, src, coverage, length); - } - } - } - ++spans; - } -} - static void blend_tiled_generic(int count, const QSpan *spans, void *userData) { QSpanData *data = reinterpret_cast(userData); @@ -3117,519 +2853,6 @@ static void blend_tiled_generic(int count, const QSpan *spans, void *userData) } } -static void blend_tiled_argb(int count, const QSpan *spans, void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - Operator op = getOperator(data, spans, count); - - int image_width = data->texture.width; - int image_height = data->texture.height; - int xoff = -qRound(-data->dx) % image_width; - int yoff = -qRound(-data->dy) % image_height; - - if (xoff < 0) - xoff += image_width; - if (yoff < 0) - yoff += image_height; - - while (count--) { - int x = spans->x; - int length = spans->len; - int sx = (xoff + spans->x) % image_width; - int sy = (spans->y + yoff) % image_height; - if (sx < 0) - sx += image_width; - if (sy < 0) - sy += image_height; - - const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; - while (length) { - int l = qMin(image_width - sx, length); - if (buffer_size < l) - l = buffer_size; - const uint *src = (const uint *)data->texture.scanLine(sy) + sx; - uint *dest = ((uint *)data->rasterBuffer->scanLine(spans->y)) + x; - op.func(dest, src, l, coverage); - x += l; - length -= l; - sx = 0; - } - ++spans; - } -} - -static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; - - if (mode != QPainter::CompositionMode_SourceOver && - mode != QPainter::CompositionMode_Source) - { - blend_src_generic(count, spans, userData); - return; - } - - const int image_width = data->texture.width; - const int image_height = data->texture.height; - int xoff = -qRound(-data->dx) % image_width; - int yoff = -qRound(-data->dy) % image_height; - - if (xoff < 0) - xoff += image_width; - if (yoff < 0) - yoff += image_height; - - while (count--) { - const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; - if (coverage == 0) { - ++spans; - continue; - } - - int x = spans->x; - int length = spans->len; - int sx = (xoff + spans->x) % image_width; - int sy = (spans->y + yoff) % image_height; - if (sx < 0) - sx += image_width; - if (sy < 0) - sy += image_height; - - if (coverage == 255) { - // Copy the first texture block - length = qMin(image_width,length); - int tx = x; - while (length) { - int l = qMin(image_width - sx, length); - if (buffer_size < l) - l = buffer_size; - qrgb565 *dest = ((qrgb565*)data->rasterBuffer->scanLine(spans->y)) + tx; - const qrgb565 *src = (const qrgb565*)data->texture.scanLine(sy) + sx; - - qt_memconvert(dest, src, l); - length -= l; - tx += l; - sx = 0; - } - - // Now use the rasterBuffer as the source of the texture, - // We can now progressively copy larger blocks - // - Less cpu time in code figuring out what to copy - // We are dealing with one block of data - // - More likely to fit in the cache - // - can use memcpy - int copy_image_width = qMin(image_width, int(spans->len)); - length = spans->len - copy_image_width; - qrgb565 *src = ((qrgb565*)data->rasterBuffer->scanLine(spans->y)) + x; - qrgb565 *dest = src + copy_image_width; - while (copy_image_width < length) { - qt_memconvert(dest, src, copy_image_width); - dest += copy_image_width; - length -= copy_image_width; - copy_image_width *= 2; - } - if (length > 0) - qt_memconvert(dest, src, length); - } else { - while (length) { - int l = qMin(image_width - sx, length); - if (buffer_size < l) - l = buffer_size; - qrgb565 *dest = ((qrgb565*)data->rasterBuffer->scanLine(spans->y)) + x; - const qrgb565 *src = (const qrgb565*)data->texture.scanLine(sy) + sx; - blendUntransformed(dest, src, coverage, l); - - x += l; - length -= l; - sx = 0; - } - } - ++spans; - } -} - -static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans, - void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; - - - if (mode != QPainter::CompositionMode_SourceOver) { - blend_src_generic(count, spans, userData); - return; - } - - qrgb565 buffer[buffer_size]; - - const int src_minx = data->texture.x1; - const int src_miny = data->texture.y1; - const int src_maxx = data->texture.x2 - 1; - const int src_maxy = data->texture.y2 - 1; - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - while (count--) { - const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; - if (coverage == 0) { - ++spans; - continue; - } - - qrgb565 *dest = (qrgb565*)data->rasterBuffer->scanLine(spans->y) - + spans->x; - - const qreal cx = spans->x + qreal(0.5); - const qreal cy = spans->y + qreal(0.5); - - qreal x = data->m21 * cy + data->m11 * cx + data->dx; - qreal y = data->m22 * cy + data->m12 * cx + data->dy; - qreal w = data->m23 * cy + data->m13 * cx + data->m33; - - int length = spans->len; - while (length) { - const int l = qMin(length, buffer_size); - const qrgb565 *end = buffer + l; - qrgb565 *b = buffer; - while (b < end) { - const qreal iw = w == 0 ? 1 : 1 / w; - const qreal px = x * iw - qreal(0.5); - const qreal py = y * iw - qreal(0.5); - - int x1 = int(px) - (px < 0); - int x2; - int y1 = int(py) - (py < 0); - int y2; - - const int distx = int((px - x1) * 256); - const int disty = int((py - y1) * 256); - - if (x1 < src_minx) { - x2 = x1 = src_minx; - } else if (x1 >= src_maxx) { - x2 = x1 = src_maxx; - } else { - x2 = x1 + 1; - } - if (y1 < src_miny) { - y2 = y1 = src_miny; - } else if (y1 >= src_maxy) { - y2 = y1 = src_maxy; - } else { - y2 = y1 + 1; - } - - const qrgb565 *src1 = (const qrgb565*)data->texture.scanLine(y1); - const qrgb565 *src2 = (const qrgb565*)data->texture.scanLine(y2); - qrgb565 tl = src1[x1]; - const qrgb565 tr = src1[x2]; - qrgb565 bl = src2[x1]; - const qrgb565 br = src2[x2]; - const quint8 ax = qrgb565::alpha(distx); - const quint8 iax = qrgb565::ialpha(distx); - - interpolate_pixel(tl, iax, tr, ax); - interpolate_pixel(bl, iax, br, ax); - interpolate_pixel(tl, qrgb565::ialpha(disty), - bl, qrgb565::alpha(disty)); - *b = tl; - ++b; - - x += fdx; - y += fdy; - w += fdw; - } - if (coverage == 255) { - qt_memconvert(dest, buffer, l); - } else { - blendUntransformed(dest, buffer, coverage, l); - } - - dest += l; - length -= l; - } - ++spans; - } -} - -static void blend_transformed_argb(int count, const QSpan *spans, void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; - uint buffer[buffer_size]; - - int image_width = data->texture.width; - int image_height = data->texture.height; - const int scanline_offset = data->texture.bytesPerLine / 4; - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - while (count--) { - void *t = data->rasterBuffer->scanLine(spans->y); - - uint *target = ((uint *)t) + spans->x; - uint *image_bits = (uint *)data->texture.imageData; - - const qreal cx = spans->x + qreal(0.5); - const qreal cy = spans->y + qreal(0.5); - - qreal x = data->m21 * cy + data->m11 * cx + data->dx; - qreal y = data->m22 * cy + data->m12 * cx + data->dy; - qreal w = data->m23 * cy + data->m13 * cx + data->m33; - - int length = spans->len; - const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; - while (length) { - int l = qMin(length, buffer_size); - const uint *end = buffer + l; - uint *b = buffer; - while (b < end) { - const qreal iw = w == 0 ? 1 : 1 / w; - const qreal tx = x * iw; - const qreal ty = y * iw; - const int px = int(tx) - (tx < 0); - const int py = int(ty) - (ty < 0); - - bool out = (px < 0) || (px >= image_width) - || (py < 0) || (py >= image_height); - - int y_offset = py * scanline_offset; - *b = out ? uint(0) : image_bits[y_offset + px]; - x += fdx; - y += fdy; - w += fdw; - - ++b; - } - func(target, buffer, l, coverage); - target += l; - length -= l; - } - ++spans; - } -} - -static void blend_transformed_rgb565(int count, const QSpan *spans, - void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; - - if (mode != QPainter::CompositionMode_SourceOver) { - blend_src_generic(count, spans, userData); - return; - } - - qrgb565 buffer[buffer_size]; - const int image_width = data->texture.width; - const int image_height = data->texture.height; - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - while (count--) { - const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; - if (coverage == 0) { - ++spans; - continue; - } - - qrgb565 *dest = (qrgb565*)data->rasterBuffer->scanLine(spans->y) - + spans->x; - - const qreal cx = spans->x + qreal(0.5); - const qreal cy = spans->y + qreal(0.5); - - qreal x = data->m21 * cy + data->m11 * cx + data->dx; - qreal y = data->m22 * cy + data->m12 * cx + data->dy; - qreal w = data->m23 * cy + data->m13 * cx + data->m33; - - int length = spans->len; - while (length) { - const int l = qMin(length, buffer_size); - const qrgb565 *end = buffer + l; - qrgb565 *b = buffer; - while (b < end) { - const qreal iw = w == 0 ? 1 : 1 / w; - const qreal tx = x * iw; - const qreal ty = y * iw; - - const int px = int(tx) - (tx < 0); - const int py = int(ty) - (ty < 0); - - if ((px < 0) || (px >= image_width) || - (py < 0) || (py >= image_height)) - { - *b = 0; - } else { - *b = ((const qrgb565*)data->texture.scanLine(py))[px]; - } - ++b; - - x += fdx; - y += fdy; - w += fdw; - } - if (coverage == 255) { - qt_memconvert(dest, buffer, l); - } else { - blendUntransformed(dest, buffer, coverage, l); - } - - dest += l; - length -= l; - } - ++spans; - } -} - -static void blend_transformed_tiled_argb(int count, const QSpan *spans, void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; - uint buffer[buffer_size]; - - int image_width = data->texture.width; - int image_height = data->texture.height; - const int scanline_offset = data->texture.bytesPerLine / 4; - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - while (count--) { - void *t = data->rasterBuffer->scanLine(spans->y); - - uint *target = ((uint *)t) + spans->x; - uint *image_bits = (uint *)data->texture.imageData; - - const qreal cx = spans->x + qreal(0.5); - const qreal cy = spans->y + qreal(0.5); - - qreal x = data->m21 * cy + data->m11 * cx + data->dx; - qreal y = data->m22 * cy + data->m12 * cx + data->dy; - qreal w = data->m23 * cy + data->m13 * cx + data->m33; - - const int coverage = (spans->coverage * data->texture.const_alpha) >> 8; - int length = spans->len; - while (length) { - int l = qMin(length, buffer_size); - const uint *end = buffer + l; - uint *b = buffer; - while (b < end) { - const qreal iw = w == 0 ? 1 : 1 / w; - const qreal tx = x * iw; - const qreal ty = y * iw; - int px = int(tx) - (tx < 0); - int py = int(ty) - (ty < 0); - - px %= image_width; - py %= image_height; - if (px < 0) px += image_width; - if (py < 0) py += image_height; - int y_offset = py * scanline_offset; - - Q_ASSERT(px >= 0 && px < image_width); - Q_ASSERT(py >= 0 && py < image_height); - - *b = image_bits[y_offset + px]; - x += fdx; - y += fdy; - w += fdw; - //force increment to avoid /0 - if (!w) { - w += fdw; - } - ++b; - } - func(target, buffer, l, coverage); - target += l; - length -= l; - } - ++spans; - } -} - -static void blend_transformed_tiled_rgb565(int count, const QSpan *spans, - void *userData) -{ - QSpanData *data = reinterpret_cast(userData); - QPainter::CompositionMode mode = data->rasterBuffer->compositionMode; - - if (mode != QPainter::CompositionMode_SourceOver) { - blend_src_generic(count, spans, userData); - return; - } - - qrgb565 buffer[buffer_size]; - const int image_width = data->texture.width; - const int image_height = data->texture.height; - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - while (count--) { - const quint8 coverage = (data->texture.const_alpha * spans->coverage) >> 8; - if (coverage == 0) { - ++spans; - continue; - } - - qrgb565 *dest = (qrgb565*)data->rasterBuffer->scanLine(spans->y) - + spans->x; - - const qreal cx = spans->x + qreal(0.5); - const qreal cy = spans->y + qreal(0.5); - - qreal x = data->m21 * cy + data->m11 * cx + data->dx; - qreal y = data->m22 * cy + data->m12 * cx + data->dy; - qreal w = data->m23 * cy + data->m13 * cx + data->m33; - - int length = spans->len; - while (length) { - const int l = qMin(length, buffer_size); - const qrgb565 *end = buffer + l; - qrgb565 *b = buffer; - while (b < end) { - const qreal iw = w == 0 ? 1 : 1 / w; - const qreal tx = x * iw; - const qreal ty = y * iw; - - int px = int(tx) - (tx < 0); - int py = int(ty) - (ty < 0); - - px %= image_width; - py %= image_height; - if (px < 0) - px += image_width; - if (py < 0) - py += image_height; - - *b = ((const qrgb565*)data->texture.scanLine(py))[px]; - ++b; - - x += fdx; - y += fdy; - w += fdw; - // force increment to avoid /0 - if (!w) - w += fdw; - } - if (coverage == 255) { - qt_memconvert(dest, buffer, l); - } else { - blendUntransformed(dest, buffer, coverage, l); - } - - dest += l; - length -= l; - } - ++spans; - } -} - /* Image formats here are target formats */ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats] = { // Untransformed @@ -3640,16 +2863,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_untransformed_generic, // Indexed8 blend_untransformed_generic, // RGB32 blend_untransformed_generic, // ARGB32 - blend_untransformed_argb, // ARGB32_Premultiplied - blend_untransformed_rgb565, // RGB16 - blend_untransformed_generic, // argb8565 - blend_untransformed_generic, // rgb666 - blend_untransformed_generic, // argb6666 - blend_untransformed_generic, // rgb555 - blend_untransformed_generic, // argb8555 - blend_untransformed_generic, // rgb888 - blend_untransformed_generic, // rgb444 - blend_untransformed_generic // argb4444 + blend_untransformed_generic, // ARGB32_Premultiplied + blend_untransformed_generic // RGB16 }, // Tiled { @@ -3659,16 +2874,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_tiled_generic, // Indexed8 blend_tiled_generic, // RGB32 blend_tiled_generic, // ARGB32 - blend_tiled_argb, // ARGB32_Premultiplied - blend_tiled_rgb565, // RGB16 - blend_tiled_generic, // argb8565 - blend_tiled_generic, // rgb666 - blend_tiled_generic, // argb6666 - blend_tiled_generic, // rgb555 - blend_tiled_generic, // argb8555 - blend_tiled_generic, // rgb888 - blend_tiled_generic, // rgb444 - blend_tiled_generic, // argb4444 + blend_tiled_generic, // ARGB32_Premultiplied + blend_tiled_generic // RGB16 }, // Transformed { @@ -3678,16 +2885,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // Indexed8 blend_src_generic, // RGB32 blend_src_generic, // ARGB32 - blend_transformed_argb, // ARGB32_Premultiplied - blend_transformed_rgb565, // RGB16 - blend_src_generic, // argb8565 - blend_src_generic, // rgb666 - blend_src_generic, // argb6666 - blend_src_generic, // rgb555 - blend_src_generic, // argb8555 - blend_src_generic, // rgb888 - blend_src_generic, // rgb444 - blend_src_generic // argb4444 + blend_src_generic, // ARGB32_Premultiplied + blend_src_generic // RGB16 }, // TransformedTiled { @@ -3697,16 +2896,8 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // Indexed8 blend_src_generic, // RGB32 blend_src_generic, // ARGB32 - blend_transformed_tiled_argb, // ARGB32_Premultiplied - blend_transformed_tiled_rgb565, // RGB16 - blend_src_generic, // argb8565 - blend_src_generic, // rgb666 - blend_src_generic, // argb6666 - blend_src_generic, // rgb555 - blend_src_generic, // argb8555 - blend_src_generic, // rgb888 - blend_src_generic, // rgb444 - blend_src_generic // argb4444 + blend_src_generic, // ARGB32_Premultiplied + blend_src_generic // RGB16 }, // Bilinear { @@ -3717,15 +2908,7 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // RGB32 blend_src_generic, // ARGB32 blend_src_generic, // ARGB32_Premultiplied - blend_transformed_bilinear_rgb565, // RGB16 - blend_src_generic, // argb8565 - blend_src_generic, // rgb666 - blend_src_generic, // argb6666 - blend_src_generic, // rgb555 - blend_src_generic, // argb8555 - blend_src_generic, // rgb888 - blend_src_generic, // rgb444 - blend_src_generic, // argb4444 + blend_src_generic // RGB16 }, // BilinearTiled { @@ -3736,15 +2919,7 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats blend_src_generic, // RGB32 blend_src_generic, // ARGB32 blend_src_generic, // ARGB32_Premultiplied - blend_src_generic, // RGB16 - blend_src_generic, // ARGB8565_Premultiplied - blend_src_generic, // RGB666 - blend_src_generic, // ARGB6666_Premultiplied - blend_src_generic, // RGB555 - blend_src_generic, // ARGB8555_Premultiplied - blend_src_generic, // RGB888 - blend_src_generic, // RGB444 - blend_src_generic, // ARGB4444_Premultiplied + blend_src_generic // RGB16 } }; @@ -4126,14 +3301,6 @@ static void qt_alphargbblit_quint32(QRasterBuffer *rasterBuffer, QT_RECTFILL(quint32) QT_RECTFILL(quint16) -QT_RECTFILL(qargb8565) -QT_RECTFILL(qrgb666) -QT_RECTFILL(qargb6666) -QT_RECTFILL(qrgb555) -QT_RECTFILL(qargb8555) -QT_RECTFILL(qrgb888) -QT_RECTFILL(qrgb444) -QT_RECTFILL(qargb4444) #undef QT_RECTFILL inline static void qt_rectfill_nonpremul_quint32(QRasterBuffer *rasterBuffer, @@ -4172,7 +3339,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = }, // Format_RGB32, { - blend_color_argb, + blend_color_generic, qt_gradient_quint32, qt_bitmapblit_quint32, qt_alphamapblit_quint32, @@ -4190,7 +3357,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = }, // Format_ARGB32_Premultiplied { - blend_color_argb, + blend_color_generic, qt_gradient_quint32, qt_bitmapblit_quint32, qt_alphamapblit_quint32, @@ -4205,62 +3372,6 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = qt_alphamapblit_quint16, 0, qt_rectfill_quint16 - }, - // Format_ARGB8565_Premultiplied - { - blend_color_generic, - blend_src_generic, - 0, 0, 0, - qt_rectfill_qargb8565 - }, - // Format_RGB666 - { - blend_color_generic, - blend_src_generic, - 0, 0, 0, - qt_rectfill_qrgb666 - }, - // Format_ARGB6666_Premultiplied - { - blend_color_generic, - blend_src_generic, - 0, 0, 0, - qt_rectfill_qargb6666 - }, - // Format_RGB555 - { - blend_color_generic, - blend_src_generic, - 0, 0, 0, - qt_rectfill_qrgb555 - }, - // Format_ARGB8555_Premultiplied - { - blend_color_generic, - blend_src_generic, - 0, 0, 0, - qt_rectfill_qargb8555 - }, - // Format_RGB888 - { - blend_color_generic, - blend_src_generic, - 0, 0, 0, - qt_rectfill_qrgb888 - }, - // Format_RGB444 - { - blend_color_generic, - blend_src_generic, - 0, 0, 0, - qt_rectfill_qrgb444 - }, - // Format_ARGB4444_Premultiplied - { - blend_color_generic, - blend_src_generic, - 0, 0, 0, - qt_rectfill_qargb4444 } }; diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 54ba014a4..907babb4b 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -354,683 +354,6 @@ private: quint32 data; }; -class qrgb565; - -class qargb8565 -{ -public: - static inline bool hasAlpha() { return true; } - - inline qargb8565() {} - inline qargb8565(quint32 v); - inline explicit qargb8565(quint32p v); - inline qargb8565(const qargb8565 &v); - inline qargb8565(const qrgb565 &v); - - inline operator quint32() const; - inline operator quint16() const; - - inline qargb8565 operator+(qargb8565 v) const; - inline bool operator==(const qargb8565 &v) const; - - inline quint32 rawValue() const; - -private: - friend class qrgb565; - quint8 data[3]; -}; - -class qrgb565 -{ -public: - static inline bool hasAlpha() { return false; } - - qrgb565(int v = 0) : data(v) {} - - inline explicit qrgb565(quint32p v); - inline explicit qrgb565(quint32 v); - inline explicit qrgb565(const qargb8565 &v); - - inline operator quint32() const; - inline operator quint16() const; - - inline qrgb565 operator+(qrgb565 v) const; - - static inline quint8 alpha(quint8 a) { return (a + 1) >> 3; } - static inline quint8 ialpha(quint8 a) { return 0x20 - alpha(a); } - - inline bool operator==(const qrgb565 &v) const; - inline quint16 rawValue() const { return data; } - -private: - friend class qargb8565; - quint16 data; -}; - -qargb8565::qargb8565(quint32 v) -{ - *this = qargb8565(quint32p(v)); -} - -qargb8565::qargb8565(quint32p v) -{ - data[0] = qAlpha(v); - const int r = qRed(v); - const int g = qGreen(v); - const int b = qBlue(v); - data[1] = ((g << 3) & 0xe0) | (b >> 3); - data[2] = (r & 0xf8) | (g >> 5); -} - -qargb8565::qargb8565(const qargb8565 &v) -{ - data[0] = v.data[0]; - data[1] = v.data[1]; - data[2] = v.data[2]; -} - -qargb8565::qargb8565(const qrgb565 &v) -{ - data[0] = 0xff; - data[1] = v.data & 0xff; - data[2] = v.data >> 8; -} - -qargb8565::operator quint32() const -{ - const quint16 rgb = (data[2] << 8) | data[1]; - const int a = data[0]; - const int r = (rgb & 0xf800); - const int g = (rgb & 0x07e0); - const int b = (rgb & 0x001f); - const int tr = qMin(a, (r >> 8) | (r >> 13)); - const int tg = qMin(a, (g >> 3) | (g >> 9)); - const int tb = qMin(a, (b << 3) | (b >> 2)); - return qRgba(tr, tg, tb, data[0]); -} - -qargb8565::operator quint16() const -{ - return (data[2] << 8) | data[1]; -} - -qargb8565 qargb8565::operator+(qargb8565 v) const -{ - qargb8565 t; - t.data[0] = data[0] + v.data[0]; - const quint16 rgb = ((data[2] + v.data[2]) << 8) - + (data[1] + v.data[1]); - t.data[1] = rgb & 0xff; - t.data[2] = rgb >> 8; - return t; -} - -bool qargb8565::operator==(const qargb8565 &v) const -{ - return data[0] == v.data[0] - && data[1] == v.data[1] - && data[2] == v.data[2]; -} - -quint32 qargb8565::rawValue() const -{ - return (data[2] << 16) | (data[1] << 8) | data[0]; -} - -qrgb565::qrgb565(quint32p v) -{ - *this = qrgb565(quint32(v)); -} - -qrgb565::qrgb565(quint32 v) -{ - const int r = qRed(v) << 8; - const int g = qGreen(v) << 3; - const int b = qBlue(v) >> 3; - - data = (r & 0xf800) | (g & 0x07e0)| (b & 0x001f); -} - -qrgb565::qrgb565(const qargb8565 &v) -{ - data = (v.data[2] << 8) | v.data[1]; -} - -qrgb565::operator quint32() const -{ - const int r = (data & 0xf800); - const int g = (data & 0x07e0); - const int b = (data & 0x001f); - const int tr = (r >> 8) | (r >> 13); - const int tg = (g >> 3) | (g >> 9); - const int tb = (b << 3) | (b >> 2); - return qRgb(tr, tg, tb); -} - -qrgb565::operator quint16() const -{ - return data; -} - -qrgb565 qrgb565::operator+(qrgb565 v) const -{ - qrgb565 t; - t.data = data + v.data; - return t; -} - -bool qrgb565::operator==(const qrgb565 &v) const -{ - return data == v.data; -} - -class qrgb555; - -class qargb8555 -{ -public: - static inline bool hasAlpha() { return true; } - - qargb8555() {} - inline qargb8555(quint32 v); - inline explicit qargb8555(quint32p v); - inline qargb8555(const qargb8555 &v); - inline qargb8555(const qrgb555 &v); - - inline operator quint32() const; - - inline qargb8555 operator+(qargb8555 v) const; - - inline bool operator==(const qargb8555 &v) const; - -private: - friend class qrgb555; - quint8 data[3]; -}; - -class qrgb555 -{ -public: - static inline bool hasAlpha() { return false; } - - inline qrgb555(int v = 0) : data(v) {} - - inline explicit qrgb555(quint32p v) { *this = qrgb555(quint32(v)); } - - inline explicit qrgb555(quint32 v) - { - const int r = qRed(v) << 7; - const int g = qGreen(v) << 2; - const int b = qBlue(v) >> 3; - - data = (r & 0x7c00) | (g & 0x03e0) | (b & 0x001f); - } - - inline explicit qrgb555(quint16 v) - { - data = ((v >> 1) & (0x7c00 | 0x03e0)) | - (v & 0x001f); - } - - inline explicit qrgb555(const qargb8555 &v); - - inline operator quint32() const - { - const int r = (data & 0x7c00); - const int g = (data & 0x03e0); - const int b = (data & 0x001f); - const int tr = (r >> 7) | (r >> 12); - const int tg = (g >> 2) | (g >> 7); - const int tb = (b << 3) | (b >> 2); - - return qRgb(tr, tg, tb); - } - - inline operator quint16() const - { - const int r = ((data & 0x7c00) << 1) & 0xf800; - const int g = (((data & 0x03e0) << 1) | ((data >> 4) & 0x0020)) & 0x07e0; - const int b = (data & 0x001f); - - return r | g | b; - } - - inline qrgb555 operator+(qrgb555 v) const; - - inline bool operator==(const qrgb555 &v) const { return v.data == data; } - inline bool operator!=(const qrgb555 &v) const { return v.data != data; } - -private: - friend class qargb8555; - quint16 data; -}; - -qrgb555::qrgb555(const qargb8555 &v) -{ - data = (v.data[2] << 8) | v.data[1]; -} - -qrgb555 qrgb555::operator+(qrgb555 v) const -{ - qrgb555 t; - t.data = data + v.data; - return t; -} - -qargb8555::qargb8555(quint32 v) -{ - v = quint32p(v); - data[0] = qAlpha(v); - const int r = qRed(v); - const int g = qGreen(v); - const int b = qBlue(v); - data[1] = ((g << 2) & 0xe0) | (b >> 3); - data[2] = ((r >> 1) & 0x7c) | (g >> 6); - -} - -qargb8555::qargb8555(quint32p v) -{ - data[0] = qAlpha(v); - const int r = qRed(v); - const int g = qGreen(v); - const int b = qBlue(v); - data[1] = ((g << 2) & 0xe0) | (b >> 3); - data[2] = ((r >> 1) & 0x7c) | (g >> 6); -} - -qargb8555::qargb8555(const qargb8555 &v) -{ - data[0] = v.data[0]; - data[1] = v.data[1]; - data[2] = v.data[2]; -} - -qargb8555::qargb8555(const qrgb555 &v) -{ - data[0] = 0xff; - data[1] = v.data & 0xff; - data[2] = v.data >> 8; -} - -qargb8555::operator quint32() const -{ - const quint16 rgb = (data[2] << 8) | data[1]; - const int r = (rgb & 0x7c00); - const int g = (rgb & 0x03e0); - const int b = (rgb & 0x001f); - const int tr = (r >> 7) | (r >> 12); - const int tg = (g >> 2) | (g >> 7); - const int tb = (b << 3) | (b >> 2); - - return qRgba(tr, tg, tb, data[0]); -} - -bool qargb8555::operator==(const qargb8555 &v) const -{ - return data[0] == v.data[0] - && data[1] == v.data[1] - && data[2] == v.data[2]; -} - -qargb8555 qargb8555::operator+(qargb8555 v) const -{ - qargb8555 t; - t.data[0] = data[0] + v.data[0]; - const quint16 rgb = ((data[2] + v.data[2]) << 8) - + (data[1] + v.data[1]); - t.data[1] = rgb & 0xff; - t.data[2] = rgb >> 8; - return t; -} - -class qrgb666; - -class qargb6666 -{ -public: - static inline bool hasAlpha() { return true; } - - inline qargb6666() {} - inline qargb6666(quint32 v) { *this = qargb6666(quint32p(v)); } - inline explicit qargb6666(quint32p v); - inline qargb6666(const qargb6666 &v); - inline qargb6666(const qrgb666 &v); - - inline operator quint32 () const; - - inline qargb6666 operator+(qargb6666 v) const; - inline bool operator==(const qargb6666 &v) const; - -private: - friend class qrgb666; - quint8 data[3]; -}; - -class qrgb666 -{ -public: - static inline bool hasAlpha() { return false; } - - inline qrgb666() {} - inline qrgb666(quint32 v); - inline qrgb666(const qargb6666 &v); - - inline operator quint32 () const; - - inline qrgb666 operator+(qrgb666 v) const; - - inline bool operator==(const qrgb666 &v) const; - inline bool operator!=(const qrgb666 &v) const { return !(*this == v); } - -private: - friend class qargb6666; - quint8 data[3]; -}; - -qrgb666::qrgb666(quint32 v) -{ - const uchar b = qBlue(v); - const uchar g = qGreen(v); - const uchar r = qRed(v); - const uint p = (b >> 2) | ((g >> 2) << 6) | ((r >> 2) << 12); - data[0] = qBlue(p); - data[1] = qGreen(p); - data[2] = qRed(p); -} - -qrgb666::qrgb666(const qargb6666 &v) -{ - data[0] = v.data[0]; - data[1] = v.data[1]; - data[2] = v.data[2] & 0x03; -} - -qrgb666::operator quint32 () const -{ - const uchar r = (data[2] << 6) | ((data[1] & 0xf0) >> 2) | (data[2] & 0x3); - const uchar g = (data[1] << 4) | ((data[0] & 0xc0) >> 4) | ((data[1] & 0x0f) >> 2); - const uchar b = (data[0] << 2) | ((data[0] & 0x3f) >> 4); - return qRgb(r, g, b); -} - -qrgb666 qrgb666::operator+(qrgb666 v) const -{ - const quint32 x1 = (data[2] << 16) | (data[1] << 8) | data[0]; - const quint32 x2 = (v.data[2] << 16) | (v.data[1] << 8) | v.data[0]; - const quint32 t = x1 + x2; - qrgb666 r; - r.data[0] = t & 0xff; - r.data[1] = (t >> 8) & 0xff; - r.data[2] = (t >> 16) & 0xff; - return r; -} - -bool qrgb666::operator==(const qrgb666 &v) const -{ - return (data[0] == v.data[0] && - data[1] == v.data[1] && - data[2] == v.data[2]); -} - -qargb6666::qargb6666(quint32p v) -{ - const quint8 b = qBlue(v) >> 2; - const quint8 g = qGreen(v) >> 2; - const quint8 r = qRed(v) >> 2; - const quint8 a = qAlpha(v) >> 2; - const uint p = (a << 18) | (r << 12) | (g << 6) | b; - data[0] = qBlue(p); - data[1] = qGreen(p); - data[2] = qRed(p); -} - -qargb6666::qargb6666(const qargb6666 &v) -{ - data[0] = v.data[0]; - data[1] = v.data[1]; - data[2] = v.data[2]; -} - -qargb6666::qargb6666(const qrgb666 &v) -{ - data[0] = v.data[0]; - data[1] = v.data[1]; - data[2] = (v.data[2] | 0xfc); -} - -qargb6666::operator quint32 () const -{ - const quint8 r = (data[2] << 6) | ((data[1] & 0xf0) >> 2) | (data[2] & 0x3); - const quint8 g = (data[1] << 4) | ((data[0] & 0xc0) >> 4) | ((data[1] & 0x0f) >> 2); - const quint8 b = (data[0] << 2) | ((data[0] & 0x3f) >> 4); - const quint8 a = (data[2] & 0xfc) | (data[2] >> 6); - return qRgba(r, g, b, a); -} - -qargb6666 qargb6666::operator+(qargb6666 v) const -{ - const quint32 x1 = (data[2] << 16) | (data[1] << 8) | data[0]; - const quint32 x2 = (v.data[2] << 16) | (v.data[1] << 8) | v.data[0]; - const quint32 t = x1 + x2; - qargb6666 r; - r.data[0] = t & 0xff; - r.data[1] = (t >> 8) & 0xff; - r.data[2] = (t >> 16) & 0xff; - return r; -} - -bool qargb6666::operator==(const qargb6666 &v) const -{ - return data[0] == v.data[0] - && data[1] == v.data[1] - && data[2] == v.data[2]; -} - -class qrgb888 -{ -public: - static inline bool hasAlpha() { return false; } - - inline qrgb888() {} - inline qrgb888(quint32 v); - - inline operator quint32() const; - - inline qrgb888 operator+(qrgb888 v) const; - inline bool operator==(qrgb888 v) const; - -private: - uchar data[3]; -}; - -qrgb888::qrgb888(quint32 v) -{ - data[0] = qRed(v); - data[1] = qGreen(v); - data[2] = qBlue(v); -} - -qrgb888::operator quint32() const -{ - return qRgb(data[0], data[1], data[2]); -} - -qrgb888 qrgb888::operator+(qrgb888 v) const -{ - qrgb888 t = *this; - t.data[0] += v.data[0]; - t.data[1] += v.data[1]; - t.data[2] += v.data[2]; - return t; -} - -bool qrgb888::operator==(qrgb888 v) const -{ - return (data[0] == v.data[0] && - data[1] == v.data[1] && - data[2] == v.data[2]); -} - -// hw: endianess?? -class quint24 -{ -public: - inline quint24(quint32 v) - { - data[0] = qBlue(v); - data[1] = qGreen(v); - data[2] = qRed(v); - } - - inline operator quint32 () const - { - return qRgb(data[2], data[1], data[0]); - } - - inline bool operator==(const quint24 &v) const - { - return data[0] == v.data[0] - && data[1] == v.data[1] - && data[2] == v.data[2]; - } - -private: - uchar data[3]; -}; - -class qrgb444; - -class qargb4444 -{ -public: - static inline bool hasAlpha() { return true; } - - inline qargb4444() {} - inline qargb4444(quint32 v) { *this = qargb4444(quint32p(v)); } - inline explicit qargb4444(quint32p v); - inline qargb4444(const qrgb444 &v); - - inline operator quint32() const; - inline operator quint8() const; - - inline qargb4444 operator+(qargb4444 v) const; - - inline bool operator==(const qargb4444 &v) const { return data == v.data; } - -private: - friend class qrgb444; - quint16 data; -}; - -class qrgb444 -{ -public: - static inline bool hasAlpha() { return false; } - - inline qrgb444() {} - inline qrgb444(quint32 v); - inline explicit qrgb444(qargb4444 v); - - inline operator quint32() const; - inline operator quint8() const; - - inline qrgb444 operator+(qrgb444 v) const; - - inline bool operator==(const qrgb444 &v) const { return data == v.data; } - inline bool operator!=(const qrgb444 &v) const { return data != v.data; } - -private: - friend class qargb4444; - quint16 data; -}; - - -qargb4444::qargb4444(quint32p color) -{ - quint32 v = color; - v &= 0xf0f0f0f0; - const int a = qAlpha(v) << 8; - const int r = qRed(v) << 4; - const int g = qGreen(v); - const int b = qBlue(v) >> 4; - - data = a | r | g | b; -} - -qargb4444::qargb4444(const qrgb444 &v) -{ - data = v.data | 0xf000; -} - -qargb4444::operator quint32() const -{ - const int a = (data & 0xf000); - const int r = (data & 0x0f00); - const int g = (data & 0x00f0); - const int b = (data & 0x000f); - const int ta = (a >> 8) | (a >> 12); - const int tr = (r >> 4) | (r >> 8); - const int tg = g | (g >> 4); - const int tb = (b << 4) | b; - - return qRgba(tr, tg, tb, ta); -} - -qargb4444::operator quint8() const -{ - // hw: optimize! - return operator quint32(); -} - -qargb4444 qargb4444::operator+(qargb4444 v) const -{ - qargb4444 t; - t.data = data + v.data; - return t; -} - -qrgb444::qrgb444(quint32 v) -{ - v &= 0xf0f0f0f0; - const int r = qRed(v) << 4; - const int g = qGreen(v); - const int b = qBlue(v) >> 4; - - data = r | g | b; -} - -qrgb444::qrgb444(qargb4444 v) -{ - data = v.data & 0x0fff; -} - -qrgb444::operator quint32() const -{ - const int r = (data & 0x0f00); - const int g = (data & 0x00f0); - const int b = (data & 0x000f); - const int tr = (r >> 4) | (r >> 8); - const int tg = g | (g >> 4); - const int tb = (b << 4) | b; - - return qRgb(tr, tg, tb); -} - -qrgb444::operator quint8() const -{ - // hw: optimize! - return operator quint32(); -} - -qrgb444 qrgb444::operator+(qrgb444 v) const -{ - qrgb444 t; - t.data = data + v.data; - return t; -} - - template inline DST qt_colorConvert(const SRC color, const DST dummy) { @@ -1134,16 +457,7 @@ inline void qt_memconvert(DST *dest, const SRC *src, int count) ::memcpy(dest, src, count * sizeof(T)); \ } QT_TRIVIAL_MEMCONVERT_IMPL(quint32) -QT_TRIVIAL_MEMCONVERT_IMPL(qrgb888) -QT_TRIVIAL_MEMCONVERT_IMPL(qargb6666) -QT_TRIVIAL_MEMCONVERT_IMPL(qrgb666) QT_TRIVIAL_MEMCONVERT_IMPL(quint16) -QT_TRIVIAL_MEMCONVERT_IMPL(qrgb565) -QT_TRIVIAL_MEMCONVERT_IMPL(qargb8565) -QT_TRIVIAL_MEMCONVERT_IMPL(qargb8555) -QT_TRIVIAL_MEMCONVERT_IMPL(qrgb555) -QT_TRIVIAL_MEMCONVERT_IMPL(qargb4444) -QT_TRIVIAL_MEMCONVERT_IMPL(qrgb444) #undef QT_TRIVIAL_MEMCONVERT_IMPL template @@ -1176,16 +490,7 @@ inline void qt_rectconvert(DST *dest, const SRC *src, } QT_RECTCONVERT_TRIVIAL_IMPL(quint32) -QT_RECTCONVERT_TRIVIAL_IMPL(qrgb888) -QT_RECTCONVERT_TRIVIAL_IMPL(qargb6666) -QT_RECTCONVERT_TRIVIAL_IMPL(qrgb666) -QT_RECTCONVERT_TRIVIAL_IMPL(qrgb565) -QT_RECTCONVERT_TRIVIAL_IMPL(qargb8565) QT_RECTCONVERT_TRIVIAL_IMPL(quint16) -QT_RECTCONVERT_TRIVIAL_IMPL(qargb8555) -QT_RECTCONVERT_TRIVIAL_IMPL(qrgb555) -QT_RECTCONVERT_TRIVIAL_IMPL(qargb4444) -QT_RECTCONVERT_TRIVIAL_IMPL(qrgb444) #undef QT_RECTCONVERT_TRIVIAL_IMPL static inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } diff --git a/src/gui/painting/qmemrotate_p.h b/src/gui/painting/qmemrotate_p.h index 3a862c6b6..c8fc30695 100644 --- a/src/gui/painting/qmemrotate_p.h +++ b/src/gui/painting/qmemrotate_p.h @@ -124,7 +124,6 @@ static inline void qt_memrotate270(const srctype *src, int w, int h, int sstride QT_IMPL_MEMROTATE(quint8, quint8) QT_IMPL_MEMROTATE(quint16, quint16) -QT_IMPL_MEMROTATE(quint24, quint24) QT_IMPL_MEMROTATE(quint32, quint32) #undef QT_IMPL_MEMROTATE diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9185b251c..eb17b699a 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -242,19 +242,11 @@ void QRasterPaintEngine::init() case QImage::Format_Mono: d->mono_surface = true; break; - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB4444_Premultiplied: case QImage::Format_ARGB32_Premultiplied: case QImage::Format_ARGB32: gccaps |= PorterDuff; break; case QImage::Format_RGB32: - case QImage::Format_RGB444: - case QImage::Format_RGB555: - case QImage::Format_RGB666: - case QImage::Format_RGB888: case QImage::Format_RGB16: break; default: @@ -1749,10 +1741,6 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe QRgb color = img.pixel(sr_l, sr_t); switch (img.format()) { case QImage::Format_ARGB32_Premultiplied: - case QImage::Format_ARGB8565_Premultiplied: - case QImage::Format_ARGB6666_Premultiplied: - case QImage::Format_ARGB8555_Premultiplied: - case QImage::Format_ARGB4444_Premultiplied: // Combine premultiplied color with the opacity set on the painter. d->solid_color_filler.solid.color = ((((color & 0x00ff00ff) * s->intOpacity) >> 8) & 0x00ff00ff) diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 3b184fa23..46b8aef75 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -607,9 +607,6 @@ static bool write_jpeg_image(const QImage &image, QIODevice *device, int quality } } break; - case QImage::Format_RGB888: - memcpy(row, image.constScanLine(cinfo.next_scanline), w * 3); - break; case QImage::Format_RGB32: case QImage::Format_ARGB32: case QImage::Format_ARGB32_Premultiplied: diff --git a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp index 7de4e6d7e..eb994ef50 100644 --- a/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp +++ b/tests/benchmarks/gui/image/qimageconversion/tst_qimageconversion.cpp @@ -40,35 +40,35 @@ class tst_QImageConversion : public QObject { Q_OBJECT private slots: - void convertRgb888ToRGB32_data(); - void convertRgb888ToRGB32(); + void convertRgb16ToRGB32_data(); + void convertRgb16ToRGB32(); private: - QImage generateImageRgb888(int width, int height); + QImage generateImage(int width, int height); }; -void tst_QImageConversion::convertRgb888ToRGB32_data() +void tst_QImageConversion::convertRgb16ToRGB32_data() { QTest::addColumn("inputImage"); // height = 5000 to get interesting timing. // 3 pixels wide -> smaller than regular vector of 128bits - QTest::newRow("width: 3px; height: 5000px;") << generateImageRgb888(3, 5000); + QTest::newRow("width: 3px; height: 5000px;") << generateImage(3, 5000); // 8 pixels wide -> potential for 2 vectors - QTest::newRow("width: 8px; height: 5000px;") << generateImageRgb888(3, 5000); + QTest::newRow("width: 8px; height: 5000px;") << generateImage(3, 5000); // 16 pixels, minimum for the SSSE3 implementation - QTest::newRow("width: 16px; height: 5000px;") << generateImageRgb888(16, 5000); + QTest::newRow("width: 16px; height: 5000px;") << generateImage(16, 5000); // 50 pixels, more realistic use case - QTest::newRow("width: 50px; height: 5000px;") << generateImageRgb888(50, 5000); + QTest::newRow("width: 50px; height: 5000px;") << generateImage(50, 5000); // 2000 pixels -> typical values for pictures - QTest::newRow("width: 2000px; height: 5000px;") << generateImageRgb888(2000, 5000); + QTest::newRow("width: 2000px; height: 5000px;") << generateImage(2000, 5000); } -void tst_QImageConversion::convertRgb888ToRGB32() +void tst_QImageConversion::convertRgb16ToRGB32() { QFETCH(QImage, inputImage); @@ -81,11 +81,11 @@ void tst_QImageConversion::convertRgb888ToRGB32() } /* - Fill a RGB888 image with "random" pixel values. + Fill a RGB16 image with "random" pixel values. */ -QImage tst_QImageConversion::generateImageRgb888(int width, int height) +QImage tst_QImageConversion::generateImage(int width, int height) { - QImage image(width, height, QImage::Format_RGB888); + QImage image(width, height, QImage::Format_RGB16); const int byteWidth = width * 3; for (int y = 0; y < image.height(); ++y) { diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp index f36c45ad5..780212e88 100644 --- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp @@ -653,17 +653,6 @@ void tst_QPainter::drawPixmap_data() for (int tar=4; tar("imageType"); QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; + QTest::newRow("imagetype=RGB16") << (int)QImage::Format_RGB16; } void tst_QPainter::drawScaledImageRoundedRect() @@ -1386,7 +1375,7 @@ void tst_QPainter::drawTransformedImageRoundedRect_data() QTest::addColumn("imageType"); QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; + QTest::newRow("imagetype=RGB16") << (int)QImage::Format_RGB16; } void tst_QPainter::drawTransformedImageRoundedRect() @@ -1462,7 +1451,7 @@ void tst_QPainter::drawScaledBorderPixmapRoundedRect_data() for (float i = 0; i < 3; i += .1) QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB32_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB32_Premultiplied; //for (float i = 0; i < 3; i += .1) - // QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB8565_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB8565_Premultiplied; + // QTest::newRow(QString(QLatin1String("scale=%1; imagetype=RGB16")).arg(i).toLatin1()) << i << (int)QImage::Format_RGB16; } //code from QDeclarativeRectangle for drawing rounded rects @@ -1517,7 +1506,7 @@ void tst_QPainter::drawTransformedBorderPixmapRoundedRect_data() for (float angle = 0; angle < 360; angle += 10) QTest::newRow(QString(QLatin1String("angle=%1; imagetype=ARGB32_Pre")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_ARGB32_Premultiplied; //for (float angle = 0; angle < 360; angle += 10) - // QTest::newRow(QString(QLatin1String("angle=%1; imagetype=ARGB8565_Pre")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_ARGB8565_Premultiplied; + // QTest::newRow(QString(QLatin1String("angle=%1; imagetype=RGB16")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_RGB16; } @@ -1570,7 +1559,7 @@ void tst_QPainter::drawTransformedTransparentImage_data() QTest::addColumn("imageType"); QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; + QTest::newRow("imagetype=RGB16") << (int)QImage::Format_RGB16; } void tst_QPainter::drawTransformedTransparentImage() @@ -1597,7 +1586,7 @@ void tst_QPainter::drawTransformedSemiTransparentImage_data() QTest::addColumn("imageType"); QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; + QTest::newRow("imagetype=RGB16") << (int)QImage::Format_RGB16; } void tst_QPainter::drawTransformedSemiTransparentImage() @@ -1624,7 +1613,7 @@ void tst_QPainter::drawTransformedFilledImage_data() QTest::addColumn("imageType"); QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; - QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; + QTest::newRow("imagetype=RGB16") << (int)QImage::Format_RGB16; } void tst_QPainter::drawTransformedFilledImage() -- 2.11.0