diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-07-06 11:55:39 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-07-07 20:35:05 +0200 |
commit | 471e4fcb226c4523efe93b1bdaf0db026495da94 (patch) | |
tree | bb963937b2446eb32d7632568433083a386f2c68 /src/gui/image | |
parent | 7f400522c39f6a1abf083dc1af49ea3109635cc8 (diff) |
Use QList instead of QVector in gui implementation
Task-number: QTBUG-84469
Change-Id: I366e845249203d80d640355a7780ac2f91a762f1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qbmphandler.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qicon.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qiconloader.cpp | 10 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 22 | ||||
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 32 | ||||
-rw-r--r-- | src/gui/image/qpixmap_win.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qpnghandler.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qppmhandler.cpp | 4 |
8 files changed, 40 insertions, 42 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 87f6ac2822..715bbd11ec 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -42,8 +42,8 @@ #ifndef QT_NO_IMAGEFORMAT_BMP #include <qimage.h> +#include <qlist.h> #include <qvariant.h> -#include <qvector.h> QT_BEGIN_NAMESPACE @@ -588,8 +588,8 @@ bool qt_write_dib(QDataStream &s, const QImage &image, int bpl, int bpl_bmp, int if (image.depth() != 32) { // write color table uchar *color_table = new uchar[4*image.colorCount()]; uchar *rgb = color_table; - QVector<QRgb> c = image.colorTable(); - for (int i=0; i<image.colorCount(); i++) { + QList<QRgb> c = image.colorTable(); + for (int i = 0; i < image.colorCount(); i++) { *rgb++ = qBlue (c[i]); *rgb++ = qGreen(c[i]); *rgb++ = qRed (c[i]); diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 91da21c477..0ad24f04b8 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -385,7 +385,7 @@ static inline int origIcoDepth(const QImage &image) return s.isEmpty() ? 32 : s.toInt(); } -static inline int findBySize(const QVector<QImage> &images, const QSize &size) +static inline int findBySize(const QList<QImage> &images, const QSize &size) { for (int i = 0; i < images.size(); ++i) { if (images.at(i).size() == size) @@ -449,7 +449,7 @@ void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIco // these files may contain low-resolution images. As this information is lost, // ICOReader sets the original format as an image text key value. Read all matching // images into a list trying to find the highest quality per size. - QVector<QImage> icoImages; + QList<QImage> icoImages; while (imageReader.read(&image)) { if (ignoreSize || image.size() == size) { const int position = findBySize(icoImages, image.size()); diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 00982ca331..9b91becf97 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -217,7 +217,7 @@ class QIconCacheGtkReader { public: explicit QIconCacheGtkReader(const QString &themeDir); - QVector<const char *> lookup(QStringView); + QList<const char *> lookup(QStringView); bool isValid() const { return m_isValid; } private: QFile m_file; @@ -290,9 +290,9 @@ static quint32 icon_name_hash(const char *p) with this name is present. The char* are pointers to the mapped data. For example, this would return { "32x32/apps", "24x24/apps" , ... } */ -QVector<const char *> QIconCacheGtkReader::lookup(QStringView name) +QList<const char *> QIconCacheGtkReader::lookup(QStringView name) { - QVector<const char *> ret; + QList<const char *> ret; if (!isValid() || name.isEmpty()) return ret; @@ -452,7 +452,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName, // Add all relevant files for (int i = 0; i < contentDirs.size(); ++i) { - QVector<QIconDirInfo> subDirs = theme.keyList(); + QList<QIconDirInfo> subDirs = theme.keyList(); // Try to reduce the amount of subDirs by looking in the GTK+ cache in order to save // a massive amount of file stat (especially if the icon is not there) @@ -460,7 +460,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName, if (cache->isValid()) { const auto result = cache->lookup(iconNameFallback); if (cache->isValid()) { - const QVector<QIconDirInfo> subDirsCopy = subDirs; + const QList<QIconDirInfo> subDirsCopy = subDirs; subDirs.clear(); subDirs.reserve(result.count()); for (const char *s : result) { diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index bcb4288631..84d8c5a705 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -541,7 +541,7 @@ bool QImageData::checkForAlphaPixels() const 8-bit images are stored using 8-bit indexes into a color table, i.e. they have a single byte per pixel. The color table is a - QVector<QRgb>, and the QRgb typedef is equivalent to an unsigned + QList<QRgb>, and the QRgb typedef is equivalent to an unsigned int containing an ARGB quadruplet on the format 0xAARRGGBB. 32-bit images have no color table; instead, each pixel contains an @@ -1398,7 +1398,7 @@ int QImage::colorCount() const \sa colorTable(), setColor(), {QImage#Image Transformations}{Image Transformations} */ -void QImage::setColorTable(const QVector<QRgb> &colors) +void QImage::setColorTable(const QList<QRgb> &colors) { if (!d) return; @@ -1424,9 +1424,9 @@ void QImage::setColorTable(const QVector<QRgb> &colors) \sa setColorTable(), colorCount(), color() */ -QVector<QRgb> QImage::colorTable() const +QList<QRgb> QImage::colorTable() const { - return d ? d->colortable : QVector<QRgb>(); + return d ? d->colortable : QList<QRgb>(); } /*! @@ -2014,7 +2014,7 @@ void QImage::setColorCount(int colorCount) if (colorCount == d->colortable.size()) return; if (colorCount <= 0) { // use no color table - d->colortable = QVector<QRgb>(); + d->colortable.clear(); return; } int nc = d->colortable.size(); @@ -2109,7 +2109,7 @@ static inline int pixel_distance(QRgb p1, QRgb p2) { return abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2) + abs(a1 - a2); } -static inline int closestMatch(QRgb pixel, const QVector<QRgb> &clut) { +static inline int closestMatch(QRgb pixel, const QList<QRgb> &clut) { int idx = 0; int current_distance = INT_MAX; for (int i=0; i<clut.size(); ++i) { @@ -2123,7 +2123,7 @@ static inline int closestMatch(QRgb pixel, const QVector<QRgb> &clut) { } static QImage convertWithPalette(const QImage &src, QImage::Format format, - const QVector<QRgb> &clut) { + const QList<QRgb> &clut) { QImage dest(src.size(), format); dest.setColorTable(clut); @@ -2149,7 +2149,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format, } } } else { - QVector<QRgb> table = clut; + QList<QRgb> table = clut; table.resize(2); for (int y=0; y<h; ++y) { const QRgb *src_pixels = (const QRgb *) src.scanLine(y); @@ -2178,7 +2178,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format, and will use a straightforward nearest color approach, with no dithering. */ -QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags) const +QImage QImage::convertToFormat(Format format, const QList<QRgb> &colorTable, Qt::ImageConversionFlags flags) const { if (!d || d->format == format) return *this; @@ -3776,8 +3776,8 @@ bool QImage::operator==(const QImage & i) const } else { const int w = width(); const int h = height(); - const QVector<QRgb> &colortable = d->colortable; - const QVector<QRgb> &icolortable = i.d->colortable; + const QList<QRgb> &colortable = d->colortable; + const QList<QRgb> &icolortable = i.d->colortable; for (int y=0; y<h; ++y) { for (int x=0; x<w; ++x) { if (colortable[pixelIndex(x, y)] != icolortable[i.pixelIndex(x, y)]) diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 134f17a9d1..773face2d4 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -69,7 +69,7 @@ struct QDefaultColorTables } } - QVector<QRgb> gray, alpha; + QList<QRgb> gray, alpha; }; Q_GLOBAL_STATIC(QDefaultColorTables, defaultColorTables); @@ -132,7 +132,7 @@ void qGamma_correct_back_to_linear_cs(QImage *image) // The drawhelper conversions from/to RGB32 are passthroughs which is not always correct for general image conversion #if !defined(__ARM_NEON__) || !(Q_BYTE_ORDER == Q_LITTLE_ENDIAN) static void QT_FASTCALL storeRGB32FromARGB32PM(uchar *dest, const uint *src, int index, int count, - const QVector<QRgb> *, QDitherInfo *) + const QList<QRgb> *, QDitherInfo *) { uint *d = reinterpret_cast<uint *>(dest) + index; for (int i = 0; i < count; ++i) @@ -141,7 +141,7 @@ static void QT_FASTCALL storeRGB32FromARGB32PM(uchar *dest, const uint *src, int #endif static void QT_FASTCALL storeRGB32FromARGB32(uchar *dest, const uint *src, int index, int count, - const QVector<QRgb> *, QDitherInfo *) + const QList<QRgb> *, QDitherInfo *) { uint *d = reinterpret_cast<uint *>(dest) + index; for (int i = 0; i < count; ++i) @@ -149,7 +149,7 @@ static void QT_FASTCALL storeRGB32FromARGB32(uchar *dest, const uint *src, int i } static const uint *QT_FASTCALL fetchRGB32ToARGB32PM(uint *buffer, const uchar *src, int index, int count, - const QVector<QRgb> *, QDitherInfo *) + const QList<QRgb> *, QDitherInfo *) { const uint *s = reinterpret_cast<const uint *>(src) + index; for (int i = 0; i < count; ++i) @@ -159,10 +159,10 @@ static const uint *QT_FASTCALL fetchRGB32ToARGB32PM(uint *buffer, const uchar *s #ifdef QT_COMPILER_SUPPORTS_SSE4_1 extern void QT_FASTCALL storeRGB32FromARGB32PM_sse4(uchar *dest, const uint *src, int index, int count, - const QVector<QRgb> *, QDitherInfo *); + const QList<QRgb> *, QDitherInfo *); #elif defined(__ARM_NEON__) && (Q_BYTE_ORDER == Q_LITTLE_ENDIAN) extern void QT_FASTCALL storeRGB32FromARGB32PM_neon(uchar *dest, const uint *src, int index, int count, - const QVector<QRgb> *, QDitherInfo *); + const QList<QRgb> *, QDitherInfo *); #endif void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags flags) @@ -1308,9 +1308,9 @@ static void convert_RGBA64_to_gray16(QImageData *dest, const QImageData *src, Qt } } -static QVector<QRgb> fix_color_table(const QVector<QRgb> &ctbl, QImage::Format format) +static QList<QRgb> fix_color_table(const QList<QRgb> &ctbl, QImage::Format format) { - QVector<QRgb> colorTable = ctbl; + QList<QRgb> colorTable = ctbl; if (format == QImage::Format_RGB32) { // check if the color table has alpha for (int i = 0; i < colorTable.size(); ++i) @@ -1644,7 +1644,7 @@ static void convert_RGB_to_Indexed8(QImageData *dst, const QImageData *src, Qt:: int pix=0; if (!dst->colortable.isEmpty()) { - QVector<QRgb> ctbl = dst->colortable; + QList<QRgb> ctbl = dst->colortable; dst->colortable.resize(256); // Preload palette into table. // Almost same code as pixel insertion below @@ -1907,7 +1907,7 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt: Q_ASSERT(src->width == dest->width); Q_ASSERT(src->height == dest->height); - QVector<QRgb> colorTable = src->has_alpha_clut ? fix_color_table(src->colortable, dest->format) : src->colortable; + QList<QRgb> colorTable = src->has_alpha_clut ? fix_color_table(src->colortable, dest->format) : src->colortable; if (colorTable.size() == 0) { colorTable.resize(256); for (int i=0; i<256; ++i) @@ -1947,7 +1947,7 @@ static void convert_Mono_to_X32(QImageData *dest, const QImageData *src, Qt::Ima Q_ASSERT(src->width == dest->width); Q_ASSERT(src->height == dest->height); - QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format); + QList<QRgb> colorTable = fix_color_table(src->colortable, dest->format); // Default to black / white colors if (colorTable.size() < 2) { @@ -1987,7 +1987,7 @@ static void convert_Mono_to_Indexed8(QImageData *dest, const QImageData *src, Qt Q_ASSERT(src->width == dest->width); Q_ASSERT(src->height == dest->height); - QVector<QRgb> ctbl = src->colortable; + QList<QRgb> ctbl = src->colortable; if (ctbl.size() > 2) { ctbl.resize(2); } else if (ctbl.size() < 2) { @@ -2041,7 +2041,7 @@ static void convert_Indexed8_to_Alpha8(QImageData *dest, const QImageData *src, Q_ASSERT(dest->format == QImage::Format_Alpha8); uchar translate[256]; - const QVector<QRgb> &colors = src->colortable; + const QList<QRgb> &colors = src->colortable; bool simpleCase = (colors.size() == 256); for (int i = 0; i < colors.size(); ++i) { uchar alpha = qAlpha(colors[i]); @@ -2069,7 +2069,7 @@ static void convert_Indexed8_to_Grayscale8(QImageData *dest, const QImageData *s Q_ASSERT(dest->format == QImage::Format_Grayscale8); uchar translate[256]; - const QVector<QRgb> &colors = src->colortable; + const QList<QRgb> &colors = src->colortable; bool simpleCase = (colors.size() == 256); for (int i = 0; i < colors.size(); ++i) { uchar gray = qGray(colors[i]); @@ -2096,7 +2096,7 @@ static bool convert_Indexed8_to_Alpha8_inplace(QImageData *data, Qt::ImageConver Q_ASSERT(data->format == QImage::Format_Indexed8); // Just check if this is an Alpha8 in Indexed8 disguise. - const QVector<QRgb> &colors = data->colortable; + const QList<QRgb> &colors = data->colortable; if (colors.size() != 256) return false; for (int i = 0; i < colors.size(); ++i) { @@ -2115,7 +2115,7 @@ static bool convert_Indexed8_to_Grayscale8_inplace(QImageData *data, Qt::ImageCo Q_ASSERT(data->format == QImage::Format_Indexed8); // Just check if this is a Grayscale8 in Indexed8 disguise. - const QVector<QRgb> &colors = data->colortable; + const QList<QRgb> &colors = data->colortable; if (colors.size() != 256) return false; for (int i = 0; i < colors.size(); ++i) { diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index be6cd0c5fc..a5565479e3 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -181,7 +181,7 @@ static QImage copyImageData(const BITMAPINFOHEADER &header, const RGBQUAD *color } if (colorTableSize) { Q_ASSERT(colorTableIn); - QVector<QRgb> colorTable; + QList<QRgb> colorTable; colorTable.reserve(colorTableSize); std::transform(colorTableIn, colorTableIn + colorTableSize, std::back_inserter(colorTable), rgbQuadToQRgb); diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 7cca0788fe..c3c987fa01 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -45,9 +45,7 @@ #include <qdebug.h> #include <qiodevice.h> #include <qimage.h> -#include <qlist.h> #include <qvariant.h> -#include <qvector.h> #include <private/qimage_p.h> // for qt_getImageText diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index afeb403abb..eccd750f1d 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -42,8 +42,8 @@ #ifndef QT_NO_IMAGEFORMAT_PPM #include <qimage.h> +#include <qlist.h> #include <qvariant.h> -#include <qvector.h> #include <ctype.h> #include <qrgba64.h> @@ -367,7 +367,7 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy qsizetype bpl = qsizetype(w) * (gray ? 1 : 3); uchar *buf = new uchar[bpl]; if (image.format() == QImage::Format_Indexed8) { - QVector<QRgb> color = image.colorTable(); + QList<QRgb> color = image.colorTable(); for (uint y=0; y<h; y++) { const uchar *b = image.constScanLine(y); uchar *p = buf; |