summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimage.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-12-13 14:22:31 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-03-07 14:30:01 +0000
commit9fb73a01dd860a8a8e80945d5591a081256b14e0 (patch)
tree8d3ee58e24b51ad9c8cbf1a37c1c045b0f29d7b7 /src/gui/image/qimage.cpp
parent4020829ac8fc27f28e75db905aa307ef2af63bfe (diff)
Use simple scaling for downscaling less than 2x
The simple scaling that only samples every input pixel once, can be used with downscaling < 2x as well if we just handle the case where the input can't be in the intermediate buffer. At the same time the handling of the intermediate buffer has been moved out of simple scale helper functions so the code can be shared and the AVX2 optimizations also used for non-argb32pm formats. Change-Id: I98d225ef8d4f2978480d09110c959b556c563b57 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/image/qimage.cpp')
-rw-r--r--src/gui/image/qimage.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 5ef65dd0cc..469ae8b97e 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2582,15 +2582,14 @@ bool QImage::allGray() const
break;
}
- const int buffer_size = 2048;
- uint buffer[buffer_size];
+ uint buffer[BufferSize];
const QPixelLayout *layout = &qPixelLayouts[d->format];
FetchPixelsFunc fetch = qFetchPixels[layout->bpp];
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, buffer_size);
+ int l = qMin(d->width - x, BufferSize);
const uint *ptr = fetch(buffer, b, x, l);
ptr = layout->convertToARGB32PM(buffer, ptr, l, 0, 0);
for (int i = 0; i < l; ++i) {
@@ -3218,14 +3217,13 @@ inline void rgbSwapped_generic(int width, int height, const QImage *src, QImage
const uint alphaGreenMask = (((1 << layout->alphaWidth) - 1) << layout->alphaShift)
| (((1 << layout->greenWidth) - 1) << layout->greenShift);
- const int buffer_size = 2048;
- uint buffer[buffer_size];
+ 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, buffer_size);
+ 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;