summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qbrush.cpp2
-rw-r--r--src/gui/painting/qbrush.h5
-rw-r--r--src/gui/painting/qcolor.cpp8
-rw-r--r--src/gui/painting/qdrawhelper.cpp6
-rw-r--r--src/gui/painting/qdrawhelper_p.h4
-rw-r--r--src/gui/painting/qimagescale.cpp213
-rw-r--r--src/gui/painting/qimagescale_sse4.cpp42
-rw-r--r--src/gui/painting/qpaintdevice.cpp2
-rw-r--r--src/gui/painting/qpaintdevice.h2
-rw-r--r--src/gui/painting/qpaintengineex.cpp8
-rw-r--r--src/gui/painting/qpainterpath.cpp19
-rw-r--r--src/gui/painting/qpainterpath.h22
-rw-r--r--src/gui/painting/qpdf.cpp2
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp129
-rw-r--r--src/gui/painting/qplatformbackingstore.h17
-rw-r--r--src/gui/painting/qpolygon.h8
-rw-r--r--src/gui/painting/qregion.h4
-rw-r--r--src/gui/painting/qstroker_p.h2
-rw-r--r--src/gui/painting/qtransform.cpp2
19 files changed, 236 insertions, 261 deletions
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 5bf8387400..670717c5f1 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -999,7 +999,7 @@ bool QBrush::operator==(const QBrush &b) const
*/
QDebug operator<<(QDebug dbg, const QBrush &b)
{
- static const char *BRUSH_STYLES[] = {
+ static const char *const BRUSH_STYLES[] = {
"NoBrush",
"SolidPattern",
"Dense1Pattern",
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index a3b88a50ef..ceb95f5676 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -73,10 +73,11 @@ public:
~QBrush();
QBrush &operator=(const QBrush &brush);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QBrush &operator=(QBrush &&other)
+ inline QBrush &operator=(QBrush &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QBrush &other) { qSwap(d, other.d); }
+ inline void swap(QBrush &other) Q_DECL_NOEXCEPT
+ { qSwap(d, other.d); }
operator QVariant() const;
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index b33d7a74fc..f1ceb464c8 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -729,8 +729,8 @@ void QColor::setHsv(int h, int s, int v, int a)
saturation, lightness, and alpha-channel (transparency) components of the
color's HSL value.
- These components can be retrieved individually using the hueHslF(),
- saturationHslF(), lightnessF() and alphaF() functions.
+ These components can be retrieved individually using the hslHueF(),
+ hslSaturationF(), lightnessF() and alphaF() functions.
\sa setHsl()
*/
@@ -759,8 +759,8 @@ void QColor::getHslF(qreal *h, qreal *s, qreal *l, qreal *a) const
saturation, lightness, and alpha-channel (transparency) components of the
color's HSL value.
- These components can be retrieved individually using the hueHsl(),
- saturationHsl(), lightness() and alpha() functions.
+ These components can be retrieved individually using the hslHue(),
+ hslSaturation(), lightness() and alpha() functions.
\sa setHsl()
*/
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index e46e997f1d..7b03cc00ff 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -944,7 +944,7 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, false, QPixelLayout::BPP8, convertGrayscale8ToRGB32, convertGrayscale8FromARGB32PM, convertGrayscale8FromRGB32, convertGrayscale8ToRGB64 } // Format_Grayscale8
};
-FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
+const FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
0, // BPPNone
fetchPixels<QPixelLayout::BPP1MSB>, // BPP1MSB
fetchPixels<QPixelLayout::BPP1LSB>, // BPP1LSB
@@ -954,7 +954,7 @@ FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
fetchPixels<QPixelLayout::BPP32> // BPP32
};
-StorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = {
+const StorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = {
0, // BPPNone
storePixels<QPixelLayout::BPP1MSB>, // BPP1MSB
storePixels<QPixelLayout::BPP1LSB>, // BPP1LSB
@@ -966,7 +966,7 @@ StorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = {
typedef uint (QT_FASTCALL *FetchPixelFunc)(const uchar *src, int index);
-FetchPixelFunc qFetchPixel[QPixelLayout::BPPCount] = {
+static const FetchPixelFunc qFetchPixel[QPixelLayout::BPPCount] = {
0, // BPPNone
fetchPixel<QPixelLayout::BPP1MSB>, // BPP1MSB
fetchPixel<QPixelLayout::BPP1LSB>, // BPP1LSB
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index f8865a6f7e..179900ddd2 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -1142,8 +1142,8 @@ typedef const uint *(QT_FASTCALL *FetchPixelsFunc)(uint *buffer, const uchar *sr
typedef void (QT_FASTCALL *StorePixelsFunc)(uchar *dest, const uint *src, int index, int count);
extern QPixelLayout qPixelLayouts[QImage::NImageFormats];
-extern FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount];
-extern StorePixelsFunc qStorePixels[QPixelLayout::BPPCount];
+extern const FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount];
+extern const StorePixelsFunc qStorePixels[QPixelLayout::BPPCount];
diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp
index 5f1b25e189..867c64c5e0 100644
--- a/src/gui/painting/qimagescale.cpp
+++ b/src/gui/painting/qimagescale.cpp
@@ -38,22 +38,6 @@
QT_BEGIN_NAMESPACE
-typedef void (*qt_qimageScaleFunc)(QImageScale::QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
-
-static void qt_qimageScaleAARGB(QImageScale::QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
-
-static void qt_qimageScaleAARGBA(QImageScale::QImageScaleInfo *isi, unsigned int *dest,
- int dxx, int dyy, int dx, int dy, int dw,
- int dh, int dow, int sow);
-
-qt_qimageScaleFunc qt_qimageScaleArgb = qt_qimageScaleAARGBA;
-qt_qimageScaleFunc qt_qimageScaleRgb = qt_qimageScaleAARGB;
-
-
/*
* Copyright (C) 2004, 2005 Daniel M. Duley
*
@@ -93,6 +77,8 @@ qt_qimageScaleFunc qt_qimageScaleRgb = qt_qimageScaleAARGB;
*
* Changes include formatting, namespaces and other C++'ings, removal of old
* #ifdef'ed code, and removal of unneeded border calculation code.
+ * Later the code has been refactored and an SSE4.1 optimizated path have been
+ * added instead of the removed MMX assembler.
*
* Imlib2 is (C) Carsten Haitzler and various contributors. The MMX code
* is by Willem Monsuwe <willem@stack.nl>. All other modifications are
@@ -115,21 +101,14 @@ using namespace QImageScale;
// Code ported from Imlib...
//
-// FIXME: replace with qRed, etc... These work on pointers to pixels, not
-// pixel values
-#define A_VAL(p) (qAlpha(*p))
-#define R_VAL(p) (qRed(*p))
-#define G_VAL(p) (qGreen(*p))
-#define B_VAL(p) (qBlue(*p))
-
const unsigned int** QImageScale::qimageCalcYPoints(const unsigned int *src,
- int sw, int sh, int dh)
+ int sw, int sh, int dh)
{
const unsigned int **p;
int j = 0, rv = 0;
qint64 val, inc;
- if(dh < 0){
+ if (dh < 0) {
dh = -dh;
rv = 1;
}
@@ -157,7 +136,7 @@ int* QImageScale::qimageCalcXPoints(int sw, int dw)
int *p, j = 0, rv = 0;
qint64 val, inc;
- if(dw < 0){
+ if (dw < 0) {
dw = -dw;
rv = 1;
}
@@ -178,25 +157,23 @@ int* QImageScale::qimageCalcXPoints(int sw, int dw)
p[dw - i - 1] = tmp;
}
}
- return(p);
+ return p;
}
int* QImageScale::qimageCalcApoints(int s, int d, int up)
{
int *p, j = 0, rv = 0;
- if(d < 0){
+ if (d < 0) {
rv = 1;
d = -d;
}
p = new int[d];
- /* scaling up */
- if(up){
- qint64 val, inc;
-
- val = 0x8000 * s / d - 0x8000;
- inc = (((qint64)s) << 16) / d;
+ if (up) {
+ /* scaling up */
+ qint64 val = 0x8000 * s / d - 0x8000;
+ qint64 inc = (((qint64)s) << 16) / d;
for (int i = 0; i < d; i++) {
int pos = val >> 16;
if (pos < 0)
@@ -207,9 +184,8 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
p[j++] = (val >> 8) - ((val >> 8) & 0xffffff00);
val += inc;
}
- }
- /* scaling down */
- else {
+ } else {
+ /* scaling down */
qint64 val = 0;
qint64 inc = (((qint64)s) << 16) / d;
int Cp = (((d << 14) + s - 1) / s);
@@ -220,7 +196,7 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
val += inc;
}
}
- if(rv){
+ if (rv) {
int tmp;
for (int i = d / 2; --i >= 0; ) {
tmp = p[i];
@@ -233,7 +209,7 @@ int* QImageScale::qimageCalcApoints(int s, int d, int up)
QImageScaleInfo* QImageScale::qimageFreeScaleInfo(QImageScaleInfo *isi)
{
- if(isi){
+ if (isi) {
delete[] isi->xpoints;
delete[] isi->ypoints;
delete[] isi->xapoints;
@@ -254,28 +230,28 @@ QImageScaleInfo* QImageScale::qimageCalcScaleInfo(const QImage &img,
sch = dh * qlonglong(img.height()) / sh;
isi = new QImageScaleInfo;
- if(!isi)
+ if (!isi)
return 0;
memset(isi, 0, sizeof(QImageScaleInfo));
isi->xup_yup = (qAbs(dw) >= sw) + ((qAbs(dh) >= sh) << 1);
isi->xpoints = qimageCalcXPoints(img.width(), scw);
- if(!isi->xpoints)
- return(qimageFreeScaleInfo(isi));
+ if (!isi->xpoints)
+ return qimageFreeScaleInfo(isi);
isi->ypoints = qimageCalcYPoints((const unsigned int *)img.scanLine(0),
img.bytesPerLine() / 4, img.height(), sch);
if (!isi->ypoints)
- return(qimageFreeScaleInfo(isi));
- if(aa) {
+ return qimageFreeScaleInfo(isi);
+ if (aa) {
isi->xapoints = qimageCalcApoints(img.width(), scw, isi->xup_yup & 1);
- if(!isi->xapoints)
- return(qimageFreeScaleInfo(isi));
+ if (!isi->xapoints)
+ return qimageFreeScaleInfo(isi);
isi->yapoints = qimageCalcApoints(img.height(), sch, isi->xup_yup & 2);
- if(!isi->yapoints)
- return(qimageFreeScaleInfo(isi));
+ if (!isi->yapoints)
+ return qimageFreeScaleInfo(isi);
}
- return(isi);
+ return isi;
}
@@ -349,7 +325,7 @@ static void qt_qimageScaleAARGBA(QImageScaleInfo *isi, unsigned int *dest,
int dh, int dow, int sow)
{
/* scaling up both ways */
- if (isi->xup_yup == 3){
+ if (isi->xup_yup == 3) {
qt_qimageScaleAARGBA_up_xy(isi, dest, dxx, dyy, dx, dy, dw, dh, dow, sow);
}
/* if we're scaling down vertically */
@@ -381,46 +357,25 @@ static void qt_qimageScaleAARGBA(QImageScaleInfo *isi, unsigned int *dest,
}
}
-inline static void qt_qimageScaleAARGBA_helper_x(const unsigned int *pix, int xap, int Cx, int &r, int &g, int &b, int &a)
+inline static void qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step, int &r, int &g, int &b, int &a)
{
- r = R_VAL(pix) * xap;
- g = G_VAL(pix) * xap;
- b = B_VAL(pix) * xap;
- a = A_VAL(pix) * xap;
+ r = qRed(*pix) * xyap;
+ g = qGreen(*pix) * xyap;
+ b = qBlue(*pix) * xyap;
+ a = qAlpha(*pix) * xyap;
int j;
- for (j = (1 << 14) - xap; j > Cx; j -= Cx ){
- pix++;
- r += R_VAL(pix) * Cx;
- g += G_VAL(pix) * Cx;
- b += B_VAL(pix) * Cx;
- a += A_VAL(pix) * Cx;
- }
- pix++;
- r += R_VAL(pix) * j;
- g += G_VAL(pix) * j;
- b += B_VAL(pix) * j;
- a += A_VAL(pix) * j;
-}
-
-inline static void qt_qimageScaleAARGBA_helper_y(const unsigned int *pix, int yap, int Cy, int sow, int &r, int &g, int &b, int &a)
-{
- r = R_VAL(pix) * yap;
- g = G_VAL(pix) * yap;
- b = B_VAL(pix) * yap;
- a = A_VAL(pix) * yap;
- int j;
- for (j = (1 << 14) - yap; j > Cy; j -= Cy ){
- pix += sow;
- r += R_VAL(pix) * Cy;
- g += G_VAL(pix) * Cy;
- b += B_VAL(pix) * Cy;
- a += A_VAL(pix) * Cy;
- }
- pix += sow;
- r += R_VAL(pix) * j;
- g += G_VAL(pix) * j;
- b += B_VAL(pix) * j;
- a += A_VAL(pix) * j;
+ for (j = (1 << 14) - xyap; j > Cxy; j -= Cxy) {
+ pix += step;
+ r += qRed(*pix) * Cxy;
+ g += qGreen(*pix) * Cxy;
+ b += qBlue(*pix) * Cxy;
+ a += qAlpha(*pix) * Cxy;
+ }
+ pix += step;
+ r += qRed(*pix) * j;
+ g += qGreen(*pix) * j;
+ b += qBlue(*pix) * j;
+ a += qAlpha(*pix) * j;
}
static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest,
@@ -443,12 +398,12 @@ static void qt_qimageScaleAARGBA_up_x_down_y(QImageScaleInfo *isi, unsigned int
for (int x = dxx; x < end; x++) {
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int r, g, b, a;
- qt_qimageScaleAARGBA_helper_y(sptr, yap, Cy, sow, r, g, b, a);
+ qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, r, g, b, a);
int xap = xapoints[x];
if (xap > 0) {
int rr, gg, bb, aa;
- qt_qimageScaleAARGBA_helper_y(sptr + 1, yap, Cy, sow, rr, gg, bb, aa);
+ qt_qimageScaleAARGBA_helper(sptr + 1, yap, Cy, sow, rr, gg, bb, aa);
r = r * (256 - xap);
g = g * (256 - xap);
@@ -484,12 +439,12 @@ static void qt_qimageScaleAARGBA_down_x_up_y(QImageScaleInfo *isi, unsigned int
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int r, g, b, a;
- qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, r, g, b, a);
+ qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, r, g, b, a);
int yap = yapoints[dyy + y];
if (yap > 0) {
int rr, gg, bb, aa;
- qt_qimageScaleAARGBA_helper_x(sptr + sow, xap, Cx, rr, gg, bb, aa);
+ qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1, rr, gg, bb, aa);
r = r * (256 - yap);
g = g * (256 - yap);
@@ -528,7 +483,7 @@ static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *des
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int rx, gx, bx, ax;
- qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, rx, gx, bx, ax);
+ qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax);
int r = ((rx>>4) * yap);
int g = ((gx>>4) * yap);
@@ -538,14 +493,14 @@ static void qt_qimageScaleAARGBA_down_xy(QImageScaleInfo *isi, unsigned int *des
int j;
for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
sptr += sow;
- qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, rx, gx, bx, ax);
+ qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax);
r += ((rx>>4) * Cy);
g += ((gx>>4) * Cy);
b += ((bx>>4) * Cy);
a += ((ax>>4) * Cy);
}
sptr += sow;
- qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, rx, gx, bx, ax);
+ qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, rx, gx, bx, ax);
r += ((rx>>4) * j);
g += ((gx>>4) * j);
@@ -609,40 +564,22 @@ static void qt_qimageScaleAARGB(QImageScaleInfo *isi, unsigned int *dest,
}
-inline static void qt_qimageScaleAARGB_helper_x(const unsigned int *pix, int xap, int Cx, int &r, int &g, int &b)
+inline static void qt_qimageScaleAARGB_helper(const unsigned int *pix, int xyap, int Cxy, int step, int &r, int &g, int &b)
{
- r = R_VAL(pix) * xap;
- g = G_VAL(pix) * xap;
- b = B_VAL(pix) * xap;
+ r = qRed(*pix) * xyap;
+ g = qGreen(*pix) * xyap;
+ b = qBlue(*pix) * xyap;
int j;
- for (j = (1 << 14) - xap; j > Cx; j -= Cx ){
- pix++;
- r += R_VAL(pix) * Cx;
- g += G_VAL(pix) * Cx;
- b += B_VAL(pix) * Cx;
- }
- pix++;
- r += R_VAL(pix) * j;
- g += G_VAL(pix) * j;
- b += B_VAL(pix) * j;
-}
-
-inline static void qt_qimageScaleAARGB_helper_y(const unsigned int *pix, int yap, int Cy, int sow, int &r, int &g, int &b)
-{
- r = R_VAL(pix) * yap;
- g = G_VAL(pix) * yap;
- b = B_VAL(pix) * yap;
- int j;
- for (j = (1 << 14) - yap; j > Cy; j -= Cy ){
- pix += sow;
- r += R_VAL(pix) * Cy;
- g += G_VAL(pix) * Cy;
- b += B_VAL(pix) * Cy;
- }
- pix += sow;
- r += R_VAL(pix) * j;
- g += G_VAL(pix) * j;
- b += B_VAL(pix) * j;
+ for (j = (1 << 14) - xyap; j > Cxy; j -= Cxy) {
+ pix += step;
+ r += qRed(*pix) * Cxy;
+ g += qGreen(*pix) * Cxy;
+ b += qBlue(*pix) * Cxy;
+ }
+ pix += step;
+ r += qRed(*pix) * j;
+ g += qGreen(*pix) * j;
+ b += qBlue(*pix) * j;
}
static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *dest,
@@ -665,12 +602,12 @@ static void qt_qimageScaleAARGB_up_x_down_y(QImageScaleInfo *isi, unsigned int *
for (int x = dxx; x < end; x++) {
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int r, g, b;
- qt_qimageScaleAARGB_helper_y(sptr, yap, Cy, sow, r, g, b);
+ qt_qimageScaleAARGB_helper(sptr, yap, Cy, sow, r, g, b);
int xap = xapoints[x];
if (xap > 0) {
int rr, bb, gg;
- qt_qimageScaleAARGB_helper_y(sptr + 1, yap, Cy, sow, rr, gg, bb);
+ qt_qimageScaleAARGB_helper(sptr + 1, yap, Cy, sow, rr, gg, bb);
r = r * (256 - xap);
g = g * (256 - xap);
@@ -704,12 +641,12 @@ static void qt_qimageScaleAARGB_down_x_up_y(QImageScaleInfo *isi, unsigned int *
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int r, g, b;
- qt_qimageScaleAARGB_helper_x(sptr, xap, Cx, r, g, b);
+ qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, r, g, b);
int yap = yapoints[dyy + y];
if (yap > 0) {
int rr, bb, gg;
- qt_qimageScaleAARGB_helper_x(sptr + sow, xap, Cx, rr, gg, bb);
+ qt_qimageScaleAARGB_helper(sptr + sow, xap, Cx, 1, rr, gg, bb);
r = r * (256 - yap);
g = g * (256 - yap);
@@ -745,7 +682,7 @@ static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
int rx, gx, bx;
- qt_qimageScaleAARGB_helper_x(sptr, xap, Cx, rx, gx, bx);
+ qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx);
int r = (rx >> 4) * yap;
int g = (gx >> 4) * yap;
@@ -754,14 +691,14 @@ static void qt_qimageScaleAARGB_down_xy(QImageScaleInfo *isi, unsigned int *dest
int j;
for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
sptr += sow;
- qt_qimageScaleAARGB_helper_x(sptr, xap, Cx, rx, gx, bx);
+ qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx);
r += (rx >> 4) * Cy;
g += (gx >> 4) * Cy;
b += (bx >> 4) * Cy;
}
sptr += sow;
- qt_qimageScaleAARGB_helper_x(sptr, xap, Cx, rx, gx, bx);
+ qt_qimageScaleAARGB_helper(sptr, xap, Cx, 1, rx, gx, bx);
r += (rx >> 4) * j;
g += (gx >> 4) * j;
@@ -794,11 +731,11 @@ QImage qSmoothScaleImage(const QImage &src, int dw, int dh)
}
if (src.hasAlphaChannel())
- qt_qimageScaleArgb(scaleinfo, (unsigned int *)buffer.scanLine(0),
- 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
+ qt_qimageScaleAARGBA(scaleinfo, (unsigned int *)buffer.scanLine(0),
+ 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
else
- qt_qimageScaleRgb(scaleinfo, (unsigned int *)buffer.scanLine(0),
- 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
+ qt_qimageScaleAARGB(scaleinfo, (unsigned int *)buffer.scanLine(0),
+ 0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
qimageFreeScaleInfo(scaleinfo);
return buffer;
diff --git a/src/gui/painting/qimagescale_sse4.cpp b/src/gui/painting/qimagescale_sse4.cpp
index 565ea4daa1..303e0fd980 100644
--- a/src/gui/painting/qimagescale_sse4.cpp
+++ b/src/gui/painting/qimagescale_sse4.cpp
@@ -41,33 +41,17 @@ QT_BEGIN_NAMESPACE
using namespace QImageScale;
-inline static __m128i qt_qimageScaleAARGBA_helper_x(const unsigned int *pix, int xap, int Cx, const __m128i vxap, const __m128i vCx)
+inline static __m128i qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step, const __m128i vxyap, const __m128i vCxy)
{
__m128i vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- __m128i vx = _mm_mullo_epi32(vpix, vxap);
+ __m128i vx = _mm_mullo_epi32(vpix, vxyap);
int i;
- for (i = (1 << 14) - xap; i > Cx; i -= Cx) {
- pix++;
+ for (i = (1 << 14) - xyap; i > Cxy; i -= Cxy) {
+ pix += step;
vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, vCx));
+ vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, vCxy));
}
- pix++;
- vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, _mm_set1_epi32(i)));
- return vx;
-}
-
-inline static __m128i qt_qimageScaleAARGBA_helper_y(const unsigned int *pix, int yap, int Cy, int sow, const __m128i vyap, const __m128i vCy)
-{
- __m128i vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- __m128i vx = _mm_mullo_epi32(vpix, vyap);
- int i;
- for (i = (1 << 14) - yap; i > Cy; i -= Cy) {
- pix += sow;
- vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
- vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, vCy));
- }
- pix += sow;
+ pix += step;
vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));
vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, _mm_set1_epi32(i)));
return vx;
@@ -97,13 +81,13 @@ void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *d
unsigned int *dptr = dest + dx + ((y + dy) * dow);
for (int x = dxx; x < end; x++) {
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
- __m128i vx = qt_qimageScaleAARGBA_helper_y(sptr, yap, Cy, sow, vyap, vCy);
+ __m128i vx = qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, vyap, vCy);
int xap = xapoints[x];
if (xap > 0) {
const __m128i vxap = _mm_set1_epi32(xap);
const __m128i vinvxap = _mm_sub_epi32(v256, vxap);
- __m128i vr = qt_qimageScaleAARGBA_helper_y(sptr + 1, yap, Cy, sow, vyap, vCy);
+ __m128i vr = qt_qimageScaleAARGBA_helper(sptr + 1, yap, Cy, sow, vyap, vCy);
vx = _mm_mullo_epi32(vx, vinvxap);
vr = _mm_mullo_epi32(vr, vxap);
@@ -145,13 +129,13 @@ void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *d
const __m128i vxap = _mm_set1_epi32(xap);
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
- __m128i vx = qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, vxap, vCx);
+ __m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
int yap = yapoints[dyy + y];
if (yap > 0) {
const __m128i vyap = _mm_set1_epi32(yap);
const __m128i vinvyap = _mm_sub_epi32(v256, vyap);
- __m128i vr = qt_qimageScaleAARGBA_helper_x(sptr + sow, xap, Cx, vxap, vCx);
+ __m128i vr = qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1, vxap, vCx);
vx = _mm_mullo_epi32(vx, vinvyap);
vr = _mm_mullo_epi32(vr, vyap);
@@ -194,17 +178,17 @@ void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest,
const __m128i vxap = _mm_set1_epi32(xap);
const unsigned int *sptr = ypoints[dyy + y] + xpoints[x];
- __m128i vx = qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, vxap, vCx);
+ __m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
__m128i vr = _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vyap);
int j;
for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
sptr += sow;
- vx = qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, vxap, vCx);
+ vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
vr = _mm_add_epi32(vr, _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vCy));
}
sptr += sow;
- vx = qt_qimageScaleAARGBA_helper_x(sptr, xap, Cx, vxap, vCx);
+ vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);
vr = _mm_add_epi32(vr, _mm_mullo_epi32(_mm_srli_epi32(vx, 4), _mm_set1_epi32(j)));
vr = _mm_srli_epi32(vr, 24);
diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp
index 36e0bbe223..bbf8e8f170 100644
--- a/src/gui/painting/qpaintdevice.cpp
+++ b/src/gui/painting/qpaintdevice.cpp
@@ -35,7 +35,7 @@
QT_BEGIN_NAMESPACE
-QPaintDevice::QPaintDevice()
+QPaintDevice::QPaintDevice() Q_DECL_NOEXCEPT
{
reserved = 0;
painters = 0;
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index 7c756c66de..4eb972786b 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -80,7 +80,7 @@ public:
int depth() const { return metric(PdmDepth); }
protected:
- QPaintDevice();
+ QPaintDevice() Q_DECL_NOEXCEPT;
virtual int metric(PaintDeviceMetric metric) const;
virtual void initPainter(QPainter *painter) const;
virtual QPaintDevice *redirected(QPoint *offset) const;
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 0f80cd18a0..f00bc8d9df 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -238,7 +238,7 @@ bool QPaintEngineExPrivate::hasClipOperations() const
*
*/
-static QPainterPath::ElementType qpaintengineex_ellipse_types[] = {
+static const QPainterPath::ElementType qpaintengineex_ellipse_types[] = {
QPainterPath::MoveToElement,
QPainterPath::CurveToElement,
QPainterPath::CurveToDataElement,
@@ -257,7 +257,7 @@ static QPainterPath::ElementType qpaintengineex_ellipse_types[] = {
QPainterPath::CurveToDataElement
};
-static QPainterPath::ElementType qpaintengineex_line_types_16[] = {
+static const QPainterPath::ElementType qpaintengineex_line_types_16[] = {
QPainterPath::MoveToElement, QPainterPath::LineToElement,
QPainterPath::MoveToElement, QPainterPath::LineToElement,
QPainterPath::MoveToElement, QPainterPath::LineToElement,
@@ -276,7 +276,7 @@ static QPainterPath::ElementType qpaintengineex_line_types_16[] = {
QPainterPath::MoveToElement, QPainterPath::LineToElement
};
-static QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
+static const QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 1
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 2
QPainterPath::MoveToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, QPainterPath::LineToElement, // 3
@@ -312,7 +312,7 @@ static QPainterPath::ElementType qpaintengineex_rect4_types_32[] = {
};
-static QPainterPath::ElementType qpaintengineex_roundedrect_types[] = {
+static const QPainterPath::ElementType qpaintengineex_roundedrect_types[] = {
QPainterPath::MoveToElement,
QPainterPath::LineToElement,
QPainterPath::CurveToElement,
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index e3c6eabbc3..e2f267d7ee 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -521,7 +521,7 @@ void QPainterPath::setElementPositionAt(int i, qreal x, qreal y)
/*!
Constructs an empty QPainterPath object.
*/
-QPainterPath::QPainterPath()
+QPainterPath::QPainterPath() Q_DECL_NOEXCEPT
: d_ptr(0)
{
}
@@ -3057,20 +3057,19 @@ qreal QPainterPath::slopeAtPercent(qreal t) const
//tangent line
qreal slope = 0;
-#define SIGN(x) ((x < 0)?-1:1)
if (m1)
slope = m2/m1;
else {
- //windows doesn't define INFINITY :(
-#ifdef INFINITY
- slope = INFINITY*SIGN(m2);
-#else
- if (sizeof(qreal) == sizeof(double)) {
- return 1.79769313486231570e+308;
+ if (std::numeric_limits<qreal>::has_infinity) {
+ slope = (m2 < 0) ? -std::numeric_limits<qreal>::infinity()
+ : std::numeric_limits<qreal>::infinity();
} else {
- return ((qreal)3.40282346638528860e+38);
+ if (sizeof(qreal) == sizeof(double)) {
+ return 1.79769313486231570e+308;
+ } else {
+ return ((qreal)3.40282346638528860e+38);
+ }
}
-#endif
}
return slope;
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index eb32782a96..4a7bd98234 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -81,16 +81,16 @@ public:
inline bool operator!=(const Element &e) const { return !operator==(e); }
};
- QPainterPath();
+ QPainterPath() Q_DECL_NOEXCEPT;
explicit QPainterPath(const QPointF &startPoint);
QPainterPath(const QPainterPath &other);
QPainterPath &operator=(const QPainterPath &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QPainterPath &operator=(QPainterPath &&other)
+ inline QPainterPath &operator=(QPainterPath &&other) Q_DECL_NOEXCEPT
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
~QPainterPath();
- inline void swap(QPainterPath &other) { d_ptr.swap(other.d_ptr); }
+ inline void swap(QPainterPath &other) Q_DECL_NOEXCEPT { d_ptr.swap(other.d_ptr); }
void closeSubpath();
@@ -147,8 +147,8 @@ public:
void translate(qreal dx, qreal dy);
inline void translate(const QPointF &offset);
- QPainterPath translated(qreal dx, qreal dy) const;
- inline QPainterPath translated(const QPointF &offset) const;
+ QPainterPath translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT;
+ inline QPainterPath translated(const QPointF &offset) const Q_REQUIRED_RESULT;
QRectF boundingRect() const;
QRectF controlPointRect() const;
@@ -158,7 +158,7 @@ public:
bool isEmpty() const;
- QPainterPath toReversed() const;
+ QPainterPath toReversed() const Q_REQUIRED_RESULT;
QList<QPolygonF> toSubpathPolygons(const QMatrix &matrix = QMatrix()) const;
QList<QPolygonF> toFillPolygons(const QMatrix &matrix = QMatrix()) const;
QPolygonF toFillPolygon(const QMatrix &matrix = QMatrix()) const;
@@ -178,12 +178,12 @@ public:
bool intersects(const QPainterPath &p) const;
bool contains(const QPainterPath &p) const;
- QPainterPath united(const QPainterPath &r) const;
- QPainterPath intersected(const QPainterPath &r) const;
- QPainterPath subtracted(const QPainterPath &r) const;
- QPainterPath subtractedInverted(const QPainterPath &r) const;
+ QPainterPath united(const QPainterPath &r) const Q_REQUIRED_RESULT;
+ QPainterPath intersected(const QPainterPath &r) const Q_REQUIRED_RESULT;
+ QPainterPath subtracted(const QPainterPath &r) const Q_REQUIRED_RESULT;
+ QPainterPath subtractedInverted(const QPainterPath &r) const Q_REQUIRED_RESULT;
- QPainterPath simplified() const;
+ QPainterPath simplified() const Q_REQUIRED_RESULT;
bool operator==(const QPainterPath &other) const;
bool operator!=(const QPainterPath &other) const;
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 3f2ebb92a0..6ea0800538 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -384,7 +384,7 @@ QByteArray QPdf::generateDashes(const QPen &pen)
-static const char* pattern_for_brush[] = {
+static const char* const pattern_for_brush[] = {
0, // NoBrush
0, // SolidPattern
"0 J\n"
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 24ea3f4cdd..62492980de 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -83,9 +83,10 @@ public:
struct QBackingstoreTextureInfo
{
- QWidget *widget; // may be null
+ void *source; // may be null
GLuint textureId;
QRect rect;
+ QRect clipRect;
QPlatformTextureList::Flags flags;
};
@@ -124,10 +125,10 @@ GLuint QPlatformTextureList::textureId(int index) const
return d->textures.at(index).textureId;
}
-QWidget *QPlatformTextureList::widget(int index)
+void *QPlatformTextureList::source(int index)
{
Q_D(const QPlatformTextureList);
- return d->textures.at(index).widget;
+ return d->textures.at(index).source;
}
QPlatformTextureList::Flags QPlatformTextureList::flags(int index) const
@@ -142,6 +143,12 @@ QRect QPlatformTextureList::geometry(int index) const
return d->textures.at(index).rect;
}
+QRect QPlatformTextureList::clipRect(int index) const
+{
+ Q_D(const QPlatformTextureList);
+ return d->textures.at(index).clipRect;
+}
+
void QPlatformTextureList::lock(bool on)
{
Q_D(QPlatformTextureList);
@@ -157,13 +164,15 @@ bool QPlatformTextureList::isLocked() const
return d->locked;
}
-void QPlatformTextureList::appendTexture(QWidget *widget, GLuint textureId, const QRect &geometry, Flags flags)
+void QPlatformTextureList::appendTexture(void *source, GLuint textureId, const QRect &geometry,
+ const QRect &clipRect, Flags flags)
{
Q_D(QPlatformTextureList);
QBackingstoreTextureInfo bi;
- bi.widget = widget;
+ bi.source = source;
bi.textureId = textureId;
bi.rect = geometry;
+ bi.clipRect = clipRect;
bi.flags = flags;
d->textures.append(bi);
}
@@ -198,7 +207,7 @@ void QPlatformTextureList::clear()
#ifndef QT_NO_OPENGL
-static QRect deviceRect(const QRect &rect, QWindow *window)
+static inline QRect deviceRect(const QRect &rect, QWindow *window)
{
QRect deviceRect(rect.topLeft() * window->devicePixelRatio(),
rect.size() * window->devicePixelRatio());
@@ -219,6 +228,32 @@ static QRegion deviceRegion(const QRegion &region, QWindow *window)
return deviceRegion;
}
+static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
+{
+ return QRect(topLeftRect.x(), windowHeight - topLeftRect.bottomRight().y() - 1,
+ topLeftRect.width(), topLeftRect.height());
+}
+
+static void blit(const QPlatformTextureList *textures, int idx, QWindow *window, const QRect &deviceWindowRect,
+ QOpenGLTextureBlitter *blitter)
+{
+ const QRect rectInWindow = textures->geometry(idx);
+ QRect clipRect = textures->clipRect(idx);
+ if (clipRect.isEmpty())
+ clipRect = QRect(QPoint(0, 0), rectInWindow.size());
+ const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
+ const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
+
+ const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(deviceRect(clippedRectInWindow, window),
+ deviceWindowRect);
+
+ const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(deviceRect(srcRect, window),
+ deviceRect(rectInWindow, window).size(),
+ QOpenGLTextureBlitter::OriginBottomLeft);
+
+ blitter->blit(textures->textureId(idx), target, source);
+}
+
/*!
Flushes the given \a region from the specified \a window onto the
screen, and composes it with the specified \a textures.
@@ -254,15 +289,12 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
d_ptr->blitter->bind();
- QRect windowRect(QPoint(), window->size() * window->devicePixelRatio());
+ const QRect deviceWindowRect = deviceRect(QRect(QPoint(), window->size()), window);
// Textures for renderToTexture widgets.
for (int i = 0; i < textures->count(); ++i) {
- if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- QRect targetRect = deviceRect(textures->geometry(i), window);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect);
- d_ptr->blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
- }
+ if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
+ blit(textures, i, window, deviceWindowRect, d_ptr->blitter);
}
funcs->glEnable(GL_BLEND);
@@ -272,6 +304,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
// semi-transparency even when it is not wanted.
funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
+ // Backingstore texture with the normal widgets.
GLuint textureId = 0;
QOpenGLTextureBlitter::Origin origin = QOpenGLTextureBlitter::OriginTopLeft;
if (QPlatformGraphicsBuffer *graphicsBuffer = this->graphicsBuffer()) {
@@ -307,12 +340,15 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
origin = QOpenGLTextureBlitter::OriginBottomLeft;
textureId = d_ptr->textureId;
} else {
- // Backingstore texture with the normal widgets.
- textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize, &d_ptr->needsSwizzle);
+ TextureFlags flags = 0;
+ textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize, &flags);
+ d_ptr->needsSwizzle = (flags & TextureSwizzle) != 0;
+ if (flags & TextureFlip)
+ origin = QOpenGLTextureBlitter::OriginBottomLeft;
}
if (textureId) {
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), windowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), deviceWindowRect);
if (d_ptr->needsSwizzle)
d_ptr->blitter->setSwizzleRB(true);
d_ptr->blitter->blit(textureId, target, origin);
@@ -322,11 +358,8 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
// Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set.
for (int i = 0; i < textures->count(); ++i) {
- if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
- QRect targetRect = deviceRect(textures->geometry(i), window);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, windowRect);
- d_ptr->blitter->blit(textures->textureId(i), target, QOpenGLTextureBlitter::OriginBottomLeft);
- }
+ if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop))
+ blit(textures, i, window, deviceWindowRect, d_ptr->blitter);
}
funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@@ -354,43 +387,55 @@ QImage QPlatformBackingStore::toImage() const
backingstore as an OpenGL texture. \a dirtyRegion is the part of the
backingstore which may have changed since the last call to this function. The
caller of this function must ensure that there is a current context.
+
The size of the texture is returned in \a textureSize.
The ownership of the texture is not transferred. The caller must not store
the return value between calls, but instead call this function before each use.
- The default implementation returns a cached texture if \a dirtyRegion is
- empty and the window has not been resized, otherwise it retrieves the
- content using toImage() and performs a texture upload.
+ The default implementation returns a cached texture if \a dirtyRegion is empty and
+ \a textureSize matches the backingstore size, otherwise it retrieves the content using
+ toImage() and performs a texture upload. This works only if the value of \a textureSize
+ is preserved between the calls to this function.
+
+ If the red and blue components have to swapped, \a flags will be set to include \c
+ TextureSwizzle. This allows creating textures from images in formats like
+ QImage::Format_RGB32 without any further image conversion. Instead, the swizzling will
+ be done in the shaders when performing composition. Other formats, that do not need
+ such swizzling due to being already byte ordered RGBA, for example
+ QImage::Format_RGBA8888, must result in having \a needsSwizzle set to false.
- If the red and blue components have to swapped, \a needsSwizzle will be set to \c true.
- This allows creating textures from images in formats like QImage::Format_RGB32 without
- any further image conversion. Instead, the swizzling will be done in the shaders when
- performing composition. Other formats, that do not need such swizzling due to being
- already byte ordered RGBA, for example QImage::Format_RGBA8888, must result in having \a
- needsSwizzle set to false.
+ If the image has to be flipped (e.g. because the texture is attached to an FBO), \a
+ flags will be set to include \c TextureFlip.
*/
-GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, bool *needsSwizzle) const
+GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const
{
+ Q_ASSERT(textureSize);
+ Q_ASSERT(flags);
+
QImage image = toImage();
QSize imageSize = image.size();
- if (imageSize.isEmpty())
+
+ *flags = 0;
+ if (image.format() == QImage::Format_RGB32)
+ *flags |= TextureSwizzle;
+
+ if (imageSize.isEmpty()) {
+ *textureSize = imageSize;
return 0;
+ }
- bool resized = d_ptr->textureSize != imageSize;
+ // Must rely on the input only, not d_ptr.
+ // With the default composeAndFlush() textureSize is &d_ptr->textureSize.
+ bool resized = *textureSize != imageSize;
if (dirtyRegion.isEmpty() && !resized)
return d_ptr->textureId;
+ *textureSize = imageSize;
+
// Fast path for RGB32 and RGBA8888, convert everything else to RGBA8888.
- if (image.format() == QImage::Format_RGB32) {
- if (needsSwizzle)
- *needsSwizzle = true;
- } else {
- if (needsSwizzle)
- *needsSwizzle = false;
- if (image.format() != QImage::Format_RGBA8888)
- image = image.convertToFormat(QImage::Format_RGBA8888);
- }
+ if (image.format() != QImage::Format_RGB32 && image.format() != QImage::Format_RGBA8888)
+ image = image.convertToFormat(QImage::Format_RGBA8888);
QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
@@ -412,8 +457,6 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu
funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageSize.width(), imageSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
const_cast<uchar*>(image.constBits()));
- if (textureSize)
- *textureSize = imageSize;
} else {
funcs->glBindTexture(GL_TEXTURE_2D, d_ptr->textureId);
QRect imageRect = image.rect();
diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h
index df98ebf51b..eac97e9cf6 100644
--- a/src/gui/painting/qplatformbackingstore.h
+++ b/src/gui/painting/qplatformbackingstore.h
@@ -82,12 +82,14 @@ public:
bool isEmpty() const { return count() == 0; }
GLuint textureId(int index) const;
QRect geometry(int index) const;
- QWidget *widget(int index);
+ QRect clipRect(int index) const;
+ void *source(int index);
Flags flags(int index) const;
void lock(bool on);
bool isLocked() const;
- void appendTexture(QWidget *widget, GLuint textureId, const QRect &geometry, Flags flags = 0);
+ void appendTexture(void *source, GLuint textureId, const QRect &geometry,
+ const QRect &clipRect = QRect(), Flags flags = 0);
void clear();
Q_SIGNALS:
@@ -114,7 +116,12 @@ public:
QPlatformTextureList *textures, QOpenGLContext *context,
bool translucentBackground);
virtual QImage toImage() const;
- virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, bool *needsSwizzle) const;
+ enum TextureFlag {
+ TextureSwizzle = 0x01,
+ TextureFlip = 0x02
+ };
+ Q_DECLARE_FLAGS(TextureFlags, TextureFlag)
+ virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize, TextureFlags *flags) const;
#endif
virtual QPlatformGraphicsBuffer *graphicsBuffer() const;
@@ -130,6 +137,10 @@ private:
QPlatformBackingStorePrivate *d_ptr;
};
+#ifndef QT_NO_OPENGL
+Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformBackingStore::TextureFlags)
+#endif
+
QT_END_NAMESPACE
#endif // QPLATFORMBACKINGSTORE_H
diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h
index ee7d4d31ad..1549ebe2b5 100644
--- a/src/gui/painting/qpolygon.h
+++ b/src/gui/painting/qpolygon.h
@@ -138,7 +138,7 @@ public:
void translate(const QPointF &offset);
inline QPolygonF translated(qreal dx, qreal dy) const;
- QPolygonF translated(const QPointF &offset) const;
+ QPolygonF translated(const QPointF &offset) const Q_REQUIRED_RESULT;
QPolygon toPolygon() const;
@@ -148,9 +148,9 @@ public:
bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
- QPolygonF united(const QPolygonF &r) const;
- QPolygonF intersected(const QPolygonF &r) const;
- QPolygonF subtracted(const QPolygonF &r) const;
+ QPolygonF united(const QPolygonF &r) const Q_REQUIRED_RESULT;
+ QPolygonF intersected(const QPolygonF &r) const Q_REQUIRED_RESULT;
+ QPolygonF subtracted(const QPolygonF &r) const Q_REQUIRED_RESULT;
};
inline QPolygonF::QPolygonF(int asize) : QVector<QPointF>(asize) {}
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index bab07b5a5d..ab2404e887 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -66,10 +66,10 @@ public:
~QRegion();
QRegion &operator=(const QRegion &);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QRegion &operator=(QRegion &&other)
+ inline QRegion &operator=(QRegion &&other) Q_DECL_NOEXCEPT
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QRegion &other) { qSwap(d, other.d); }
+ inline void swap(QRegion &other) Q_DECL_NOEXCEPT { qSwap(d, other.d); }
bool isEmpty() const;
bool isNull() const;
diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h
index eda65b8e2f..f967c091df 100644
--- a/src/gui/painting/qstroker_p.h
+++ b/src/gui/painting/qstroker_p.h
@@ -201,7 +201,7 @@ public:
QStroker();
~QStroker();
- void setStrokeWidth(qfixed width) { m_strokeWidth = width; }
+ void setStrokeWidth(qfixed width) { m_strokeWidth = width; m_curveThreshold = width >= 1 ? 1.0/width : 0.5;}
qfixed strokeWidth() const { return m_strokeWidth; }
void setCapStyle(Qt::PenCapStyle capStyle) { m_capStyle = joinModeForCap(capStyle); }
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 4b3f0b30dc..fca2b72249 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -1102,7 +1102,7 @@ QDataStream & operator>>(QDataStream &s, QTransform &t)
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QTransform &m)
{
- static const char *typeStr[] =
+ static const char *const typeStr[] =
{
"TxNone",
"TxTranslate",