diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-02-02 13:17:28 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-04-03 08:13:17 +0000 |
commit | ae8e27b58a8e00ae3c2ebbbdebc0f6a9493ede2b (patch) | |
tree | 5155603352fe893b469c6725ff1deb0f7951b702 /src/gui/image/qimage.cpp | |
parent | ffb2c2ac6c3ba40acbe13a39899a72049585b427 (diff) |
Remove bit details from QPixelLayout
They were only used for rgb swap and checking for the presence of an
alpha channel.
Change-Id: I013aa9035ccf4362fa3d9ecda41723e4ec5a44cb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/image/qimage.cpp')
-rw-r--r-- | src/gui/image/qimage.cpp | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 469ae8b97e..e1cac2011d 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3209,13 +3209,15 @@ void QImage::mirrored_inplace(bool horizontal, bool vertical) inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage *dst, const QPixelLayout* layout) { - Q_ASSERT(layout->redWidth == layout->blueWidth); FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; StorePixelsFunc store = qStorePixels[layout->bpp]; - - const uint redBlueMask = (1 << layout->redWidth) - 1; - const uint alphaGreenMask = (((1 << layout->alphaWidth) - 1) << layout->alphaShift) - | (((1 << layout->greenWidth) - 1) << layout->greenShift); + RbSwapFunc func = layout->rbSwap; + if (!func) { + qWarning("Trying to rb-swap an image format where it doesn't make sense"); + if (src != dst) + *dst = *src; + return; + } uint buffer[BufferSize]; for (int i = 0; i < height; ++i) { @@ -3225,14 +3227,9 @@ inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage while (x < width) { int l = qMin(width - x, BufferSize); const uint *ptr = fetch(buffer, p, x, l); - for (int j = 0; j < l; ++j) { - uint red = (ptr[j] >> layout->redShift) & redBlueMask; - uint blue = (ptr[j] >> layout->blueShift) & redBlueMask; - buffer[j] = (ptr[j] & alphaGreenMask) - | (red << layout->blueShift) - | (blue << layout->redShift); - } - store(q, buffer, x, l); + ptr = func(buffer, ptr, l); + if (q != (const uchar *)ptr) + store(q, ptr, x, l); x += l; } } @@ -3319,23 +3316,6 @@ QImage QImage::rgbSwapped_helper() const } } break; - case Format_BGR30: - case Format_A2BGR30_Premultiplied: - case Format_RGB30: - case Format_A2RGB30_Premultiplied: - res = QImage(d->width, d->height, d->format); - QIMAGE_SANITYCHECK_MEMORY(res); - for (int i = 0; i < d->height; i++) { - uint *q = (uint*)res.scanLine(i); - const uint *p = (const uint*)constScanLine(i); - const uint *end = p + d->width; - while (p < end) { - *q = qRgbSwapRgb30(*p); - p++; - q++; - } - } - break; default: res = QImage(d->width, d->height, d->format); rgbSwapped_generic(d->width, d->height, this, &res, &qPixelLayouts[d->format]); |