diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-04-04 17:45:28 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-02 14:20:55 +0000 |
commit | 648ee7aa020d04b160ec56187f49f761ffab93cc (patch) | |
tree | 3d68cc7feb1393c26259ea92f52f4e3fba99fb0d /src/gui/image/qimage.cpp | |
parent | 6a39e49a6cdeb28a04a3657bb6a22f848d5dfa9d (diff) |
Merge drawhelper convert-from and store
Avoids using an intermediate buffer on store and simplifies the code.
Change-Id: I2dc4e735eb770f90dc99fe0f513b4df3b35ee793
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/image/qimage.cpp')
-rw-r--r-- | src/gui/image/qimage.cpp | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index e1cac2011d..907f90f3a5 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2303,8 +2303,7 @@ QRgb QImage::pixel(int x, int y) const } const QPixelLayout *layout = &qPixelLayouts[d->format]; uint result; - const uint *ptr = qFetchPixels[layout->bpp](&result, s, x, 1); - return *layout->convertToARGB32PM(&result, ptr, 1, 0, 0); + return *layout->fetchToARGB32PM(&result, s, x, 1, nullptr, nullptr); } /*! @@ -2405,9 +2404,7 @@ void QImage::setPixel(int x, int y, uint index_or_rgb) } const QPixelLayout *layout = &qPixelLayouts[d->format]; - uint result; - const uint *ptr = layout->convertFromARGB32PM(&result, &index_or_rgb, 1, 0, 0); - qStorePixels[layout->bpp](s, ptr, x, 1); + layout->storeFromARGB32PM(s, &index_or_rgb, x, 1, nullptr, nullptr); } /*! @@ -2584,14 +2581,13 @@ bool QImage::allGray() const uint buffer[BufferSize]; const QPixelLayout *layout = &qPixelLayouts[d->format]; - FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; + const auto fetch = layout->fetchToARGB32PM; for (int j = 0; j < d->height; ++j) { const uchar *b = constScanLine(j); int x = 0; while (x < d->width) { int l = qMin(d->width - x, BufferSize); - const uint *ptr = fetch(buffer, b, x, l); - ptr = layout->convertToARGB32PM(buffer, ptr, l, 0, 0); + const uint *ptr = fetch(buffer, b, x, l, nullptr, nullptr); for (int i = 0; i < l; ++i) { if (!qIsGray(ptr[i])) return false; @@ -3209,9 +3205,7 @@ void QImage::mirrored_inplace(bool horizontal, bool vertical) inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage *dst, const QPixelLayout* layout) { - FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; - StorePixelsFunc store = qStorePixels[layout->bpp]; - RbSwapFunc func = layout->rbSwap; + const RbSwapFunc func = layout->rbSwap; if (!func) { qWarning("Trying to rb-swap an image format where it doesn't make sense"); if (src != dst) @@ -3219,19 +3213,10 @@ inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage return; } - uint buffer[BufferSize]; for (int i = 0; i < height; ++i) { uchar *q = dst->scanLine(i); const uchar *p = src->constScanLine(i); - int x = 0; - while (x < width) { - int l = qMin(width - x, BufferSize); - const uint *ptr = fetch(buffer, p, x, l); - ptr = func(buffer, ptr, l); - if (q != (const uchar *)ptr) - store(q, ptr, x, l); - x += l; - } + func(q, p, width); } } |