diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-10-10 09:42:41 +0200 |
---|---|---|
committer | Antti Kokko <antti.kokko@qt.io> | 2017-11-28 18:41:40 +0000 |
commit | 984ad6124992c9831f57c2776aa2ed0a760149e6 (patch) | |
tree | 320236847752f32a56a1c6e18618a353172921f9 /src/gui | |
parent | 8298956eb084d8f0e478240a674c5ae131c8be97 (diff) |
Improve readability of code that uses the Qt signed size typev5.10.0-rc2
During the container BoF session at the Qt Contributor Summit 2017 the
name of the signed size type became a subject of discussion in the
context of readability of code using this type and the intention of
using it for all length, size and count properties throughout the entire
framework in future versions of Qt.
This change proposes qsizetype as new name for qssize_t to emphasize the
readability of code over POSIX compatibility, the former being
potentially more relevant than the latter to the majority of users of
Qt.
Change-Id: Idb99cb4a8782703c054fa463a9e5af23a918e7f3
Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch>
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qbmphandler.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qimage.h | 2 | ||||
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 28 | ||||
-rw-r--r-- | src/gui/image/qimage_p.h | 4 | ||||
-rw-r--r-- | src/gui/image/qpixmap_blitter.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_avx2.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 4 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 10 |
10 files changed, 32 insertions, 32 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 1ec45a7491..587f375ce7 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -49,10 +49,10 @@ QT_BEGIN_NAMESPACE static void swapPixel01(QImage *image) // 1-bpp: swap 0 and 1 pixels { - qssize_t i; + qsizetype i; if (image->depth() == 1 && image->colorCount() == 2) { uint *p = (uint *)image->bits(); - qssize_t nbytes = static_cast<qssize_t>(image->sizeInBytes()); + qsizetype nbytes = static_cast<qsizetype>(image->sizeInBytes()); for (i=0; i<nbytes/4; i++) { *p = ~*p; p++; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 097033280a..99c2271581 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -130,7 +130,7 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format) if (std::numeric_limits<int>::max()/depth < width || bytes_per_line <= 0 || height <= 0 - || std::numeric_limits<qssize_t>::max()/uint(bytes_per_line) < height + || std::numeric_limits<qsizetype>::max()/uint(bytes_per_line) < height || std::numeric_limits<int>::max()/sizeof(uchar *) < uint(height)) return 0; @@ -1470,7 +1470,7 @@ int QImage::byteCount() const \sa byteCount(), bytesPerLine(), bits(), {QImage#Image Information}{Image Information} */ -qssize_t QImage::sizeInBytes() const +qsizetype QImage::sizeInBytes() const { return d ? d->nbytes : 0; } diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index eccff480bb..cddb5fe632 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -217,7 +217,7 @@ public: #if QT_DEPRECATED_SINCE(5, 10) QT_DEPRECATED int byteCount() const; #endif - qssize_t sizeInBytes() const; + qsizetype sizeInBytes() const; uchar *scanLine(int); const uchar *scanLine(int) const; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 6abaa2887e..4eef617336 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -823,8 +823,8 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve const int depth = 32; - const qssize_t dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qssize_t nbytes = dst_bytes_per_line * data->height; + const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; + const qsizetype nbytes = dst_bytes_per_line * data->height; uchar *const newData = (uchar *)realloc(data->data, nbytes); if (!newData) return false; @@ -877,8 +877,8 @@ static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversi const int depth = 32; - const qssize_t dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qssize_t nbytes = dst_bytes_per_line * data->height; + const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; + const qsizetype nbytes = dst_bytes_per_line * data->height; uchar *const newData = (uchar *)realloc(data->data, nbytes); if (!newData) return false; @@ -945,8 +945,8 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers const int depth = 16; - const qssize_t dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qssize_t nbytes = dst_bytes_per_line * data->height; + const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; + const qsizetype nbytes = dst_bytes_per_line * data->height; uchar *const newData = (uchar *)realloc(data->data, nbytes); if (!newData) return false; @@ -1002,8 +1002,8 @@ static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFl const int depth = 16; - const qssize_t dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; - const qssize_t src_bytes_per_line = data->bytes_per_line; + const qsizetype dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; + const qsizetype src_bytes_per_line = data->bytes_per_line; quint32 *src_data = (quint32 *) data->data; quint16 *dst_data = (quint16 *) data->data; @@ -1257,9 +1257,9 @@ void dither_to_Mono(QImageData *dst, const QImageData *src, } uchar *dst_data = dst->data; - qssize_t dst_bpl = dst->bytes_per_line; + qsizetype dst_bpl = dst->bytes_per_line; const uchar *src_data = src->data; - qssize_t src_bpl = src->bytes_per_line; + qsizetype src_bpl = src->bytes_per_line; switch (dithermode) { case Diffuse: { @@ -1912,8 +1912,8 @@ static void convert_Indexed8_to_Alpha8(QImageData *dest, const QImageData *src, if (simpleCase) memcpy(dest->data, src->data, src->bytes_per_line * src->height); else { - qssize_t size = src->bytes_per_line * src->height; - for (qssize_t i = 0; i < size; ++i) { + qsizetype size = src->bytes_per_line * src->height; + for (qsizetype i = 0; i < size; ++i) { dest->data[i] = translate[src->data[i]]; } } @@ -1936,8 +1936,8 @@ static void convert_Indexed8_to_Grayscale8(QImageData *dest, const QImageData *s if (simpleCase) memcpy(dest->data, src->data, src->bytes_per_line * src->height); else { - qssize_t size = src->bytes_per_line * src->height; - for (qssize_t i = 0; i < size; ++i) { + qsizetype size = src->bytes_per_line * src->height; + for (qsizetype i = 0; i < size; ++i) { dest->data[i] = translate[src->data[i]]; } } diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 9ba4945dc5..befecbfe8b 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -71,12 +71,12 @@ struct Q_GUI_EXPORT QImageData { // internal image data int width; int height; int depth; - qssize_t nbytes; // number of bytes data + qsizetype nbytes; // number of bytes data qreal devicePixelRatio; QVector<QRgb> colortable; uchar *data; QImage::Format format; - qssize_t bytes_per_line; + qsizetype bytes_per_line; int ser_no; // serial number int detach_no; diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index d694352fc1..646e737afa 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -191,7 +191,7 @@ void QBlittablePlatformPixmap::fromImage(const QImage &image, uchar *mem = thisImg->bits(); const uchar *bits = correctFormatPic.constBits(); - qssize_t bytesCopied = 0; + qsizetype bytesCopied = 0; while (bytesCopied < correctFormatPic.sizeInBytes()) { memcpy(mem,bits,correctFormatPic.bytesPerLine()); mem += thisImg->bytesPerLine(); diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 5ec570a5db..6a24c02aaa 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -2383,7 +2383,7 @@ static void QT_FASTCALL fetchTransformedBilinearARGB32PM_fast_rotate_helper(uint __m128i v_fy = _mm_setr_epi32(fy, fy + fdy, fy + fdy + fdy, fy + fdy + fdy + fdy); const uchar *textureData = image.imageData; - const qssize_t bytesPerLine = image.bytesPerLine; + const qsizetype bytesPerLine = image.bytesPerLine; const __m128i vbpl = _mm_shufflelo_epi16(_mm_cvtsi32_si128(bytesPerLine/4), _MM_SHUFFLE(0, 0, 0, 0)); while (b < boundedEnd - 3) { @@ -4959,7 +4959,7 @@ static void blend_transformed_tiled_argb(int count, const QSpan *spans, void *us int image_width = data->texture.width; int image_height = data->texture.height; - const qssize_t scanline_offset = data->texture.bytesPerLine / 4; + const qsizetype scanline_offset = data->texture.bytesPerLine / 4; if (data->fast_matrix) { // The increment pr x in the scanline diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp index d6c3319c76..2619539788 100644 --- a/src/gui/painting/qdrawhelper_avx2.cpp +++ b/src/gui/painting/qdrawhelper_avx2.cpp @@ -685,7 +685,7 @@ void QT_FASTCALL fetchTransformedBilinearARGB32PM_fast_rotate_helper_avx2(uint * v_fy = _mm256_add_epi32(v_fy, _mm256_mullo_epi32(_mm256_set1_epi32(fdy), v_index)); const uchar *textureData = image.imageData; - const qssize_t bytesPerLine = image.bytesPerLine; + const qsizetype bytesPerLine = image.bytesPerLine; const __m256i vbpl = _mm256_set1_epi16(bytesPerLine/4); while (b < boundedEnd - 7) { diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 2be10d2cfb..df9f762314 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -293,7 +293,7 @@ struct QTextureData int y1; int x2; int y2; - qssize_t bytesPerLine; + qsizetype bytesPerLine; QImage::Format format; const QVector<QRgb> *colorTable; bool hasAlpha; @@ -847,7 +847,7 @@ inline void qt_memfill(T *dest, T value, int count) template <class T> Q_STATIC_TEMPLATE_FUNCTION inline void qt_rectfill(T *dest, T value, - int x, int y, int width, int height, qssize_t stride) + int x, int y, int width, int height, qsizetype stride) { char *d = reinterpret_cast<char*>(dest + x) + y * stride; if (uint(stride) == (width * sizeof(T))) { diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index d0d948bbb7..1637a933b1 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -994,7 +994,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt, Q_ASSERT(img.depth() >= 8); - qssize_t srcBPL = img.bytesPerLine(); + qsizetype srcBPL = img.bytesPerLine(); const uchar *srcBits = img.bits(); int srcSize = img.depth() >> 3; // This is the part that is incompatible with lower than 8-bit.. int iw = img.width(); @@ -1043,7 +1043,7 @@ void QRasterPaintEnginePrivate::drawImage(const QPointF &pt, // call the blend function... int dstSize = rasterBuffer->bytesPerPixel(); - qssize_t dstBPL = rasterBuffer->bytesPerLine(); + qsizetype dstBPL = rasterBuffer->bytesPerLine(); func(rasterBuffer->buffer() + x * dstSize + y * dstBPL, dstBPL, srcBits, srcBPL, iw, ih, @@ -2318,8 +2318,8 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe clippedSourceRect = clippedSourceRect.intersected(img.rect()); - const qssize_t dbpl = d->rasterBuffer->bytesPerLine(); - const qssize_t sbpl = img.bytesPerLine(); + const qsizetype dbpl = d->rasterBuffer->bytesPerLine(); + const qsizetype sbpl = img.bytesPerLine(); uchar *dst = d->rasterBuffer->buffer(); uint bpp = img.depth() >> 3; @@ -2828,7 +2828,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, cache->fillInPendingGlyphs(); const QImage &image = cache->image(); - qssize_t bpl = image.bytesPerLine(); + qsizetype bpl = image.bytesPerLine(); int depth = image.depth(); int rightShift = 0; |