diff options
Diffstat (limited to 'src/gui')
382 files changed, 3626 insertions, 4872 deletions
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index 7bc124f7d9..27756d764d 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_ACCESSIBILITY #ifndef QACCESSIBLE_H diff --git a/src/gui/accessible/qaccessiblebridge.h b/src/gui/accessible/qaccessiblebridge.h index c161e01b0f..7429716e65 100644 --- a/src/gui/accessible/qaccessiblebridge.h +++ b/src/gui/accessible/qaccessiblebridge.h @@ -40,6 +40,7 @@ #ifndef QACCESSIBLEBRIDGE_H #define QACCESSIBLEBRIDGE_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h index a9208702e4..f054ee9678 100644 --- a/src/gui/accessible/qaccessiblecache_p.h +++ b/src/gui/accessible/qaccessiblecache_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qobject.h> #include <QtCore/qhash.h> diff --git a/src/gui/accessible/qaccessibleobject.h b/src/gui/accessible/qaccessibleobject.h index 5918e942bd..dd69dcb081 100644 --- a/src/gui/accessible/qaccessibleobject.h +++ b/src/gui/accessible/qaccessibleobject.h @@ -40,6 +40,7 @@ #ifndef QACCESSIBLEOBJECT_H #define QACCESSIBLEOBJECT_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qaccessible.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/accessible/qaccessibleplugin.h b/src/gui/accessible/qaccessibleplugin.h index b0c28e5bf8..09d4c542d3 100644 --- a/src/gui/accessible/qaccessibleplugin.h +++ b/src/gui/accessible/qaccessibleplugin.h @@ -40,6 +40,7 @@ #ifndef QACCESSIBLEPLUGIN_H #define QACCESSIBLEPLUGIN_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qaccessible.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/accessible/qplatformaccessibility.h b/src/gui/accessible/qplatformaccessibility.h index 5dc4781bb2..5d668c2bd6 100644 --- a/src/gui/accessible/qplatformaccessibility.h +++ b/src/gui/accessible/qplatformaccessibility.h @@ -48,9 +48,11 @@ // source and binary incompatible with future versions of Qt. // -#include <QtCore/qobject.h> +#include <QtGui/qtguiglobal.h> + #ifndef QT_NO_ACCESSIBILITY +#include <QtCore/qobject.h> #include <QtGui/qaccessible.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp index e18340d302..b72764e048 100644 --- a/src/gui/animation/qguivariantanimation.cpp +++ b/src/gui/animation/qguivariantanimation.cpp @@ -36,11 +36,12 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <QtCore/qvariantanimation.h> -#include <private/qvariantanimation_p.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_ANIMATION +#include <QtCore/qvariantanimation.h> +#include <private/qvariantanimation_p.h> #include <QtGui/qcolor.h> #include <QtGui/qvector2d.h> #include <QtGui/qvector3d.h> diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc index 9781135960..a9fe520d5e 100644 --- a/src/gui/doc/src/qtgui.qdoc +++ b/src/gui/doc/src/qtgui.qdoc @@ -187,6 +187,19 @@ More info in \l{Drag and Drop} + \section1 Licenses and Attributions + + Qt GUI is available under commercial licenses from \l{The Qt Company}. + In addition, it is available under the + \l{GNU Lesser General Public License, version 3}, or + the \l{GNU General Public License, version 2}. + See \l{Qt Licensing} for further details. + + Furthermore Qt GUI potentially contains third party + modules under following permissive licenses: + + \generatelist{groupsbymodule attributions-qtgui} + \section1 Reference \list \li \l{Qt GUI C++ Classes} diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 462f133ff8..d1d0041616 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -18,7 +18,7 @@ MODULE_PLUGIN_TYPES = \ egldeviceintegrations # This is here only because the platform plugin is no module, obviously. -win32:contains(QT_CONFIG, angle)|contains(QT_CONFIG, dynamicgl) { +contains(QT_CONFIG, angle) { MODULE_AUX_INCLUDES = \ \$\$QT_MODULE_INCLUDE_BASE/QtANGLE } diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 8db944e5e3..fe21ff4cc0 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -11,7 +11,6 @@ HEADERS += \ image/qimagereader.h \ image/qimagewriter.h \ image/qmovie.h \ - image/qnativeimage_p.h \ image/qpaintengine_pic_p.h \ image/qpicture.h \ image/qpicture_p.h \ @@ -45,7 +44,6 @@ SOURCES += \ image/qmovie.cpp \ image/qpixmap_raster.cpp \ image/qpixmap_blitter.cpp \ - image/qnativeimage.cpp \ image/qimagepixmapcleanuphooks.cpp \ image/qicon.cpp \ image/qiconloader.cpp \ @@ -55,6 +53,8 @@ SOURCES += \ win32:!winrt: SOURCES += image/qpixmap_win.cpp +darwin: OBJECTIVE_SOURCES += image/qimage_darwin.mm + NO_PCH_SOURCES += image/qimage_compat.cpp false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator @@ -71,11 +71,11 @@ SOURCES += \ image/qxbmhandler.cpp \ image/qxpmhandler.cpp -!contains(QT_CONFIG, no-png):include($$PWD/qpnghandler.pri) -else:DEFINES *= QT_NO_IMAGEFORMAT_PNG - -contains(QT_CONFIG, jpeg):include($$PWD/qjpeghandler.pri) -contains(QT_CONFIG, gif):include($$PWD/qgifhandler.pri) +contains(QT_CONFIG, png) { + HEADERS += image/qpnghandler_p.h + SOURCES += image/qpnghandler.cpp + include($$PWD/../../3rdparty/png_dependency.pri) +} # SIMD SSE2_SOURCES += image/qimage_sse2.cpp diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h index 68727e74b5..def59b3f89 100644 --- a/src/gui/image/qbitmap.h +++ b/src/gui/image/qbitmap.h @@ -40,6 +40,7 @@ #ifndef QBITMAP_H #define QBITMAP_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qpixmap.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/image/qbmphandler_p.h b/src/gui/image/qbmphandler_p.h index c4800e3f97..258ce0fce6 100644 --- a/src/gui/image/qbmphandler_p.h +++ b/src/gui/image/qbmphandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qimageiohandler.h" #ifndef QT_NO_IMAGEFORMAT_BMP diff --git a/src/gui/image/qgifhandler.cpp b/src/gui/image/qgifhandler.cpp deleted file mode 100644 index 476b456563..0000000000 --- a/src/gui/image/qgifhandler.cpp +++ /dev/null @@ -1,1218 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** WARNING: -** A separate license from Unisys may be required to use the gif -** reader. See http://www.unisys.com/about__unisys/lzw/ -** for information from Unisys -** -****************************************************************************/ - -#include "qgifhandler_p.h" - -#include <qimage.h> -#include <qiodevice.h> -#include <qvariant.h> - -QT_BEGIN_NAMESPACE - -#define Q_TRANSPARENT 0x00ffffff - -// avoid going through QImage::scanLine() which calls detach -#define FAST_SCAN_LINE(bits, bpl, y) (bits + (y) * bpl) - - -/* - Incremental image decoder for GIF image format. - - This subclass of QImageFormat decodes GIF format images, - including animated GIFs. Internally in -*/ - -class QGIFFormat { -public: - QGIFFormat(); - ~QGIFFormat(); - - int decode(QImage *image, const uchar* buffer, int length, - int *nextFrameDelay, int *loopCount); - static void scan(QIODevice *device, QVector<QSize> *imageSizes, int *loopCount); - - bool newFrame; - bool partialNewFrame; - -private: - void fillRect(QImage *image, int x, int y, int w, int h, QRgb col); - inline QRgb color(uchar index) const; - - // GIF specific stuff - QRgb* globalcmap; - QRgb* localcmap; - QImage backingstore; - unsigned char hold[16]; - bool gif89; - int count; - int ccount; - int expectcount; - enum State { - Header, - LogicalScreenDescriptor, - GlobalColorMap, - LocalColorMap, - Introducer, - ImageDescriptor, - TableImageLZWSize, - ImageDataBlockSize, - ImageDataBlock, - ExtensionLabel, - GraphicControlExtension, - ApplicationExtension, - NetscapeExtensionBlockSize, - NetscapeExtensionBlock, - SkipBlockSize, - SkipBlock, - Done, - Error - } state; - int gncols; - int lncols; - int ncols; - int lzwsize; - bool lcmap; - int swidth, sheight; - int width, height; - int left, top, right, bottom; - enum Disposal { NoDisposal, DoNotChange, RestoreBackground, RestoreImage }; - Disposal disposal; - bool disposed; - int trans_index; - bool gcmap; - int bgcol; - int interlace; - int accum; - int bitcount; - - enum { max_lzw_bits=12 }; // (poor-compiler's static const int) - - int code_size, clear_code, end_code, max_code_size, max_code; - int firstcode, oldcode, incode; - short* table[2]; - short* stack; - short *sp; - bool needfirst; - int x, y; - int frame; - bool out_of_bounds; - bool digress; - void nextY(unsigned char *bits, int bpl); - void disposePrevious(QImage *image); -}; - -/*! - Constructs a QGIFFormat. -*/ -QGIFFormat::QGIFFormat() -{ - globalcmap = 0; - localcmap = 0; - lncols = 0; - gncols = 0; - disposal = NoDisposal; - out_of_bounds = false; - disposed = true; - frame = -1; - state = Header; - count = 0; - lcmap = false; - newFrame = false; - partialNewFrame = false; - table[0] = 0; - table[1] = 0; - stack = 0; -} - -/*! - Destroys a QGIFFormat. -*/ -QGIFFormat::~QGIFFormat() -{ - if (globalcmap) delete[] globalcmap; - if (localcmap) delete[] localcmap; - delete [] stack; -} - -void QGIFFormat::disposePrevious(QImage *image) -{ - if (out_of_bounds) { - // flush anything that survived - // ### Changed: QRect(0, 0, swidth, sheight) - } - - // Handle disposal of previous image before processing next one - - if (disposed) return; - - int l = qMin(swidth-1,left); - int r = qMin(swidth-1,right); - int t = qMin(sheight-1,top); - int b = qMin(sheight-1,bottom); - - switch (disposal) { - case NoDisposal: - break; - case DoNotChange: - break; - case RestoreBackground: - if (trans_index>=0) { - // Easy: we use the transparent color - fillRect(image, l, t, r-l+1, b-t+1, Q_TRANSPARENT); - } else if (bgcol>=0) { - // Easy: we use the bgcol given - fillRect(image, l, t, r-l+1, b-t+1, color(bgcol)); - } else { - // Impossible: We don't know of a bgcol - use pixel 0 - const QRgb *bits = reinterpret_cast<const QRgb *>(image->constBits()); - fillRect(image, l, t, r-l+1, b-t+1, bits[0]); - } - // ### Changed: QRect(l, t, r-l+1, b-t+1) - break; - case RestoreImage: { - if (frame >= 0) { - for (int ln=t; ln<=b; ln++) { - memcpy(image->scanLine(ln)+l, - backingstore.constScanLine(ln-t), - (r-l+1)*sizeof(QRgb)); - } - // ### Changed: QRect(l, t, r-l+1, b-t+1) - } - } - } - disposal = NoDisposal; // Until an extension says otherwise. - - disposed = true; -} - -/*! - This function decodes some data into image changes. - - Returns the number of bytes consumed. -*/ -int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, - int *nextFrameDelay, int *loopCount) -{ - // We are required to state that - // "The Graphics Interchange Format(c) is the Copyright property of - // CompuServe Incorporated. GIF(sm) is a Service Mark property of - // CompuServe Incorporated." - - if (!stack) { - stack = new short[(1 << max_lzw_bits) * 4]; - table[0] = &stack[(1 << max_lzw_bits) * 2]; - table[1] = &stack[(1 << max_lzw_bits) * 3]; - } - - image->detach(); - int bpl = image->bytesPerLine(); - unsigned char *bits = image->bits(); - -#define LM(l, m) (((m)<<8)|l) - digress = false; - const int initial = length; - while (!digress && length) { - length--; - unsigned char ch=*buffer++; - switch (state) { - case Header: - hold[count++]=ch; - if (count==6) { - // Header - gif89=(hold[3]!='8' || hold[4]!='7'); - state=LogicalScreenDescriptor; - count=0; - } - break; - case LogicalScreenDescriptor: - hold[count++]=ch; - if (count==7) { - // Logical Screen Descriptor - swidth=LM(hold[0], hold[1]); - sheight=LM(hold[2], hold[3]); - gcmap=!!(hold[4]&0x80); - //UNUSED: bpchan=(((hold[4]&0x70)>>3)+1); - //UNUSED: gcmsortflag=!!(hold[4]&0x08); - gncols=2<<(hold[4]&0x7); - bgcol=(gcmap) ? hold[5] : -1; - //aspect=hold[6] ? double(hold[6]+15)/64.0 : 1.0; - - trans_index = -1; - count=0; - ncols=gncols; - if (gcmap) { - ccount=0; - state=GlobalColorMap; - globalcmap = new QRgb[gncols+1]; // +1 for trans_index - globalcmap[gncols] = Q_TRANSPARENT; - } else { - state=Introducer; - } - } - break; - case GlobalColorMap: case LocalColorMap: - hold[count++]=ch; - if (count==3) { - QRgb rgb = qRgb(hold[0], hold[1], hold[2]); - if (state == LocalColorMap) { - if (ccount < lncols) - localcmap[ccount] = rgb; - } else { - globalcmap[ccount] = rgb; - } - if (++ccount >= ncols) { - if (state == LocalColorMap) - state=TableImageLZWSize; - else - state=Introducer; - } - count=0; - } - break; - case Introducer: - hold[count++]=ch; - switch (ch) { - case ',': - state=ImageDescriptor; - break; - case '!': - state=ExtensionLabel; - break; - case ';': - // ### Changed: QRect(0, 0, swidth, sheight) - state=Done; - break; - default: - digress=true; - // Unexpected Introducer - ignore block - state=Error; - } - break; - case ImageDescriptor: - hold[count++]=ch; - if (count==10) { - int newleft=LM(hold[1], hold[2]); - int newtop=LM(hold[3], hold[4]); - int newwidth=LM(hold[5], hold[6]); - int newheight=LM(hold[7], hold[8]); - - // disbelieve ridiculous logical screen sizes, - // unless the image frames are also large. - if (swidth/10 > qMax(newwidth,200)) - swidth = -1; - if (sheight/10 > qMax(newheight,200)) - sheight = -1; - - if (swidth <= 0) - swidth = newleft + newwidth; - if (sheight <= 0) - sheight = newtop + newheight; - - QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32; - if (image->isNull()) { - (*image) = QImage(swidth, sheight, format); - bpl = image->bytesPerLine(); - bits = image->bits(); - memset(bits, 0, image->byteCount()); - } - - // Check if the previous attempt to create the image failed. If it - // did then the image is broken and we should give up. - if (image->isNull()) { - state = Error; - return -1; - } - - disposePrevious(image); - disposed = false; - - left = newleft; - top = newtop; - width = newwidth; - height = newheight; - - right=qMax(0, qMin(left+width, swidth)-1); - bottom=qMax(0, qMin(top+height, sheight)-1); - lcmap=!!(hold[9]&0x80); - interlace=!!(hold[9]&0x40); - //bool lcmsortflag=!!(hold[9]&0x20); - lncols=lcmap ? (2<<(hold[9]&0x7)) : 0; - if (lncols) { - if (localcmap) - delete [] localcmap; - localcmap = new QRgb[lncols+1]; - localcmap[lncols] = Q_TRANSPARENT; - ncols = lncols; - } else { - ncols = gncols; - } - frame++; - if (frame == 0) { - if (left || top || width<swidth || height<sheight) { - // Not full-size image - erase with bg or transparent - if (trans_index >= 0) { - fillRect(image, 0, 0, swidth, sheight, color(trans_index)); - // ### Changed: QRect(0, 0, swidth, sheight) - } else if (bgcol>=0) { - fillRect(image, 0, 0, swidth, sheight, color(bgcol)); - // ### Changed: QRect(0, 0, swidth, sheight) - } - } - } - - if (disposal == RestoreImage) { - int l = qMin(swidth-1,left); - int r = qMin(swidth-1,right); - int t = qMin(sheight-1,top); - int b = qMin(sheight-1,bottom); - int w = r-l+1; - int h = b-t+1; - - if (backingstore.width() < w - || backingstore.height() < h) { - // We just use the backing store as a byte array - backingstore = QImage(qMax(backingstore.width(), w), - qMax(backingstore.height(), h), - QImage::Format_RGB32); - memset(bits, 0, image->byteCount()); - } - const int dest_bpl = backingstore.bytesPerLine(); - unsigned char *dest_data = backingstore.bits(); - for (int ln=0; ln<h; ln++) { - memcpy(FAST_SCAN_LINE(dest_data, dest_bpl, ln), - FAST_SCAN_LINE(bits, bpl, t+ln) + l, w*sizeof(QRgb)); - } - } - - count=0; - if (lcmap) { - ccount=0; - state=LocalColorMap; - } else { - state=TableImageLZWSize; - } - x = left; - y = top; - accum = 0; - bitcount = 0; - sp = stack; - firstcode = oldcode = 0; - needfirst = true; - out_of_bounds = left>=swidth || y>=sheight; - } - break; - case TableImageLZWSize: { - lzwsize=ch; - if (lzwsize > max_lzw_bits) { - state=Error; - } else { - code_size=lzwsize+1; - clear_code=1<<lzwsize; - end_code=clear_code+1; - max_code_size=2*clear_code; - max_code=clear_code+2; - int i; - for (i=0; i<clear_code; i++) { - table[0][i]=0; - table[1][i]=i; - } - state=ImageDataBlockSize; - } - count=0; - break; - } case ImageDataBlockSize: - expectcount=ch; - if (expectcount) { - state=ImageDataBlock; - } else { - state=Introducer; - digress = true; - newFrame = true; - } - break; - case ImageDataBlock: - count++; - accum|=(ch<<bitcount); - bitcount+=8; - while (bitcount>=code_size && state==ImageDataBlock) { - int code=accum&((1<<code_size)-1); - bitcount-=code_size; - accum>>=code_size; - - if (code==clear_code) { - if (!needfirst) { - code_size=lzwsize+1; - max_code_size=2*clear_code; - max_code=clear_code+2; - } - needfirst=true; - } else if (code==end_code) { - bitcount = -32768; - // Left the block end arrive - } else { - if (needfirst) { - firstcode=oldcode=code; - if (!out_of_bounds && image->height() > y && ((frame == 0) || (firstcode != trans_index))) - ((QRgb*)FAST_SCAN_LINE(bits, bpl, y))[x] = color(firstcode); - x++; - if (x>=swidth) out_of_bounds = true; - needfirst=false; - if (x>=left+width) { - x=left; - out_of_bounds = left>=swidth || y>=sheight; - nextY(bits, bpl); - } - } else { - incode=code; - if (code>=max_code) { - *sp++=firstcode; - code=oldcode; - } - while (code>=clear_code+2) { - if (code >= max_code) { - state = Error; - return -1; - } - *sp++=table[1][code]; - if (code==table[0][code]) { - state=Error; - return -1; - } - if (sp-stack>=(1<<(max_lzw_bits))*2) { - state=Error; - return -1; - } - code=table[0][code]; - } - if (code < 0) { - state = Error; - return -1; - } - - *sp++=firstcode=table[1][code]; - code=max_code; - if (code<(1<<max_lzw_bits)) { - table[0][code]=oldcode; - table[1][code]=firstcode; - max_code++; - if ((max_code>=max_code_size) - && (max_code_size<(1<<max_lzw_bits))) - { - max_code_size*=2; - code_size++; - } - } - oldcode=incode; - const int h = image->height(); - QRgb *line = 0; - if (!out_of_bounds && h > y) - line = (QRgb*)FAST_SCAN_LINE(bits, bpl, y); - while (sp>stack) { - const uchar index = *(--sp); - if (!out_of_bounds && h > y && ((frame == 0) || (index != trans_index))) { - line[x] = color(index); - } - x++; - if (x>=swidth) out_of_bounds = true; - if (x>=left+width) { - x=left; - out_of_bounds = left>=swidth || y>=sheight; - nextY(bits, bpl); - if (!out_of_bounds && h > y) - line = (QRgb*)FAST_SCAN_LINE(bits, bpl, y); - } - } - } - } - } - partialNewFrame = true; - if (count==expectcount) { - count=0; - state=ImageDataBlockSize; - } - break; - case ExtensionLabel: - switch (ch) { - case 0xf9: - state=GraphicControlExtension; - break; - case 0xff: - state=ApplicationExtension; - break; -#if 0 - case 0xfe: - state=CommentExtension; - break; - case 0x01: - break; -#endif - default: - state=SkipBlockSize; - } - count=0; - break; - case ApplicationExtension: - if (count<11) hold[count]=ch; - count++; - if (count==hold[0]+1) { - if (qstrncmp((char*)(hold+1), "NETSCAPE", 8)==0) { - // Looping extension - state=NetscapeExtensionBlockSize; - } else { - state=SkipBlockSize; - } - count=0; - } - break; - case NetscapeExtensionBlockSize: - expectcount=ch; - count=0; - if (expectcount) state=NetscapeExtensionBlock; - else state=Introducer; - break; - case NetscapeExtensionBlock: - if (count<3) hold[count]=ch; - count++; - if (count==expectcount) { - *loopCount = hold[1]+hold[2]*256; - state=SkipBlockSize; // Ignore further blocks - } - break; - case GraphicControlExtension: - if (count<5) hold[count]=ch; - count++; - if (count==hold[0]+1) { - disposePrevious(image); - disposal=Disposal((hold[1]>>2)&0x7); - //UNUSED: waitforuser=!!((hold[1]>>1)&0x1); - int delay=count>3 ? LM(hold[2], hold[3]) : 1; - // IE and mozilla use a minimum delay of 10. With the minimum delay of 10 - // we are compatible to them and avoid huge loads on the app and xserver. - *nextFrameDelay = (delay < 2 ? 10 : delay) * 10; - - bool havetrans=hold[1]&0x1; - trans_index = havetrans ? hold[4] : -1; - - count=0; - state=SkipBlockSize; - } - break; - case SkipBlockSize: - expectcount=ch; - count=0; - if (expectcount) state=SkipBlock; - else state=Introducer; - break; - case SkipBlock: - count++; - if (count==expectcount) state=SkipBlockSize; - break; - case Done: - digress=true; - /* Netscape ignores the junk, so we do too. - length++; // Unget - state=Error; // More calls to this is an error - */ - break; - case Error: - return -1; // Called again after done. - } - } - return initial-length; -} - -/*! - Scans through the data stream defined by \a device and returns the image - sizes found in the stream in the \a imageSizes vector. -*/ -void QGIFFormat::scan(QIODevice *device, QVector<QSize> *imageSizes, int *loopCount) -{ - if (!device) - return; - - qint64 oldPos = device->pos(); - if (device->isSequential() || !device->seek(0)) - return; - - int colorCount = 0; - int localColorCount = 0; - int globalColorCount = 0; - int colorReadCount = 0; - bool localColormap = false; - bool globalColormap = false; - int count = 0; - int blockSize = 0; - int imageWidth = 0; - int imageHeight = 0; - bool done = false; - uchar hold[16]; - State state = Header; - - const int readBufferSize = 40960; // 40k read buffer - QByteArray readBuffer(device->read(readBufferSize)); - - if (readBuffer.isEmpty()) { - device->seek(oldPos); - return; - } - - // This is a specialized version of the state machine from decode(), - // which doesn't do any image decoding or mallocing, and has an - // optimized way of skipping SkipBlocks, ImageDataBlocks and - // Global/LocalColorMaps. - - while (!readBuffer.isEmpty()) { - int length = readBuffer.size(); - const uchar *buffer = (const uchar *) readBuffer.constData(); - while (!done && length) { - length--; - uchar ch = *buffer++; - switch (state) { - case Header: - hold[count++] = ch; - if (count == 6) { - state = LogicalScreenDescriptor; - count = 0; - } - break; - case LogicalScreenDescriptor: - hold[count++] = ch; - if (count == 7) { - imageWidth = LM(hold[0], hold[1]); - imageHeight = LM(hold[2], hold[3]); - globalColormap = !!(hold[4] & 0x80); - globalColorCount = 2 << (hold[4] & 0x7); - count = 0; - colorCount = globalColorCount; - if (globalColormap) { - int colorTableSize = 3 * globalColorCount; - if (length >= colorTableSize) { - // skip the global color table in one go - length -= colorTableSize; - buffer += colorTableSize; - state = Introducer; - } else { - colorReadCount = 0; - state = GlobalColorMap; - } - } else { - state=Introducer; - } - } - break; - case GlobalColorMap: - case LocalColorMap: - hold[count++] = ch; - if (count == 3) { - if (++colorReadCount >= colorCount) { - if (state == LocalColorMap) - state = TableImageLZWSize; - else - state = Introducer; - } - count = 0; - } - break; - case Introducer: - hold[count++] = ch; - switch (ch) { - case 0x2c: - state = ImageDescriptor; - break; - case 0x21: - state = ExtensionLabel; - break; - case 0x3b: - state = Done; - break; - default: - done = true; - state = Error; - } - break; - case ImageDescriptor: - hold[count++] = ch; - if (count == 10) { - int newLeft = LM(hold[1], hold[2]); - int newTop = LM(hold[3], hold[4]); - int newWidth = LM(hold[5], hold[6]); - int newHeight = LM(hold[7], hold[8]); - - if (imageWidth/10 > qMax(newWidth,200)) - imageWidth = -1; - if (imageHeight/10 > qMax(newHeight,200)) - imageHeight = -1; - - if (imageWidth <= 0) - imageWidth = newLeft + newWidth; - if (imageHeight <= 0) - imageHeight = newTop + newHeight; - - *imageSizes << QSize(imageWidth, imageHeight); - - localColormap = !!(hold[9] & 0x80); - localColorCount = localColormap ? (2 << (hold[9] & 0x7)) : 0; - if (localColorCount) - colorCount = localColorCount; - else - colorCount = globalColorCount; - - count = 0; - if (localColormap) { - int colorTableSize = 3 * localColorCount; - if (length >= colorTableSize) { - // skip the local color table in one go - length -= colorTableSize; - buffer += colorTableSize; - state = TableImageLZWSize; - } else { - colorReadCount = 0; - state = LocalColorMap; - } - } else { - state = TableImageLZWSize; - } - } - break; - case TableImageLZWSize: - if (ch > max_lzw_bits) - state = Error; - else - state = ImageDataBlockSize; - count = 0; - break; - case ImageDataBlockSize: - blockSize = ch; - if (blockSize) { - if (length >= blockSize) { - // we can skip the block in one go - length -= blockSize; - buffer += blockSize; - count = 0; - } else { - state = ImageDataBlock; - } - } else { - state = Introducer; - } - break; - case ImageDataBlock: - ++count; - if (count == blockSize) { - count = 0; - state = ImageDataBlockSize; - } - break; - case ExtensionLabel: - switch (ch) { - case 0xf9: - state = GraphicControlExtension; - break; - case 0xff: - state = ApplicationExtension; - break; - default: - state = SkipBlockSize; - } - count = 0; - break; - case ApplicationExtension: - if (count < 11) - hold[count] = ch; - ++count; - if (count == hold[0] + 1) { - if (qstrncmp((char*)(hold+1), "NETSCAPE", 8) == 0) - state=NetscapeExtensionBlockSize; - else - state=SkipBlockSize; - count = 0; - } - break; - case GraphicControlExtension: - if (count < 5) - hold[count] = ch; - ++count; - if (count == hold[0] + 1) { - count = 0; - state = SkipBlockSize; - } - break; - case NetscapeExtensionBlockSize: - blockSize = ch; - count = 0; - if (blockSize) - state = NetscapeExtensionBlock; - else - state = Introducer; - break; - case NetscapeExtensionBlock: - if (count < 3) - hold[count] = ch; - count++; - if (count == blockSize) { - *loopCount = LM(hold[1], hold[2]); - state = SkipBlockSize; - } - break; - case SkipBlockSize: - blockSize = ch; - count = 0; - if (blockSize) { - if (length >= blockSize) { - // we can skip the block in one go - length -= blockSize; - buffer += blockSize; - } else { - state = SkipBlock; - } - } else { - state = Introducer; - } - break; - case SkipBlock: - ++count; - if (count == blockSize) - state = SkipBlockSize; - break; - case Done: - done = true; - break; - case Error: - device->seek(oldPos); - return; - } - } - readBuffer = device->read(readBufferSize); - } - device->seek(oldPos); - return; -} - -void QGIFFormat::fillRect(QImage *image, int col, int row, int w, int h, QRgb color) -{ - if (w>0) { - for (int j=0; j<h; j++) { - QRgb *line = (QRgb*)image->scanLine(j+row); - for (int i=0; i<w; i++) - *(line+col+i) = color; - } - } -} - -void QGIFFormat::nextY(unsigned char *bits, int bpl) -{ - if (out_of_bounds) - return; - int my; - switch (interlace) { - case 0: // Non-interlaced - // if (!out_of_bounds) { - // ### Changed: QRect(left, y, right - left + 1, 1); - // } - y++; - break; - case 1: { - int i; - my = qMin(7, bottom-y); - // Don't dup with transparency - if (trans_index < 0) { - for (i=1; i<=my; i++) { - memcpy(FAST_SCAN_LINE(bits, bpl, y+i)+left*sizeof(QRgb), FAST_SCAN_LINE(bits, bpl, y)+left*sizeof(QRgb), - (right-left+1)*sizeof(QRgb)); - } - } - - // if (!out_of_bounds) { - // ### Changed: QRect(left, y, right - left + 1, my + 1); - // } -// if (!out_of_bounds) -// qDebug("consumer->changed(QRect(%d, %d, %d, %d))", left, y, right-left+1, my+1); - y+=8; - if (y>bottom) { - interlace++; y=top+4; - if (y > bottom) { // for really broken GIFs with bottom < 5 - interlace=2; - y = top + 2; - if (y > bottom) { // for really broken GIF with bottom < 3 - interlace = 0; - y = top + 1; - } - } - } - } break; - case 2: { - int i; - my = qMin(3, bottom-y); - // Don't dup with transparency - if (trans_index < 0) { - for (i=1; i<=my; i++) { - memcpy(FAST_SCAN_LINE(bits, bpl, y+i)+left*sizeof(QRgb), FAST_SCAN_LINE(bits, bpl, y)+left*sizeof(QRgb), - (right-left+1)*sizeof(QRgb)); - } - } - - // if (!out_of_bounds) { - // ### Changed: QRect(left, y, right - left + 1, my + 1); - // } - y+=8; - if (y>bottom) { - interlace++; y=top+2; - // handle broken GIF with bottom < 3 - if (y > bottom) { - interlace = 3; - y = top + 1; - } - } - } break; - case 3: { - int i; - my = qMin(1, bottom-y); - // Don't dup with transparency - if (trans_index < 0) { - for (i=1; i<=my; i++) { - memcpy(FAST_SCAN_LINE(bits, bpl, y+i)+left*sizeof(QRgb), FAST_SCAN_LINE(bits, bpl, y)+left*sizeof(QRgb), - (right-left+1)*sizeof(QRgb)); - } - } - // if (!out_of_bounds) { - // ### Changed: QRect(left, y, right - left + 1, my + 1); - // } - y+=4; - if (y>bottom) { interlace++; y=top+1; } - } break; - case 4: - // if (!out_of_bounds) { - // ### Changed: QRect(left, y, right - left + 1, 1); - // } - y+=2; - } - - // Consume bogus extra lines - if (y >= sheight) out_of_bounds=true; //y=bottom; -} - -inline QRgb QGIFFormat::color(uchar index) const -{ - if (index > ncols) - return Q_TRANSPARENT; - - QRgb *map = lcmap ? localcmap : globalcmap; - QRgb col = map ? map[index] : 0; - return index == trans_index ? col & Q_TRANSPARENT : col; -} - -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- -//------------------------------------------------------------------------- - -QGifHandler::QGifHandler() -{ - gifFormat = new QGIFFormat; - nextDelay = 100; - loopCnt = -1; - frameNumber = -1; - scanIsCached = false; -} - -QGifHandler::~QGifHandler() -{ - delete gifFormat; -} - -// Does partial decode if necessary, just to see if an image is coming - -bool QGifHandler::imageIsComing() const -{ - const int GifChunkSize = 4096; - - while (!gifFormat->partialNewFrame) { - if (buffer.isEmpty()) { - buffer += device()->read(GifChunkSize); - if (buffer.isEmpty()) - break; - } - - int decoded = gifFormat->decode(&lastImage, (const uchar *)buffer.constData(), buffer.size(), - &nextDelay, &loopCnt); - if (decoded == -1) - break; - buffer.remove(0, decoded); - } - return gifFormat->partialNewFrame; -} - -bool QGifHandler::canRead() const -{ - if (canRead(device()) || imageIsComing()) { - setFormat("gif"); - return true; - } - - return false; -} - -bool QGifHandler::canRead(QIODevice *device) -{ - if (!device) { - qWarning("QGifHandler::canRead() called with no device"); - return false; - } - - char head[6]; - if (device->peek(head, sizeof(head)) == sizeof(head)) - return qstrncmp(head, "GIF87a", 6) == 0 - || qstrncmp(head, "GIF89a", 6) == 0; - return false; -} - -bool QGifHandler::read(QImage *image) -{ - const int GifChunkSize = 4096; - - while (!gifFormat->newFrame) { - if (buffer.isEmpty()) { - buffer += device()->read(GifChunkSize); - if (buffer.isEmpty()) - break; - } - - int decoded = gifFormat->decode(&lastImage, (const uchar *)buffer.constData(), buffer.size(), - &nextDelay, &loopCnt); - if (decoded == -1) - break; - buffer.remove(0, decoded); - } - if (gifFormat->newFrame || (gifFormat->partialNewFrame && device()->atEnd())) { - *image = lastImage; - ++frameNumber; - gifFormat->newFrame = false; - gifFormat->partialNewFrame = false; - return true; - } - - return false; -} - -bool QGifHandler::write(const QImage &image) -{ - Q_UNUSED(image); - return false; -} - -bool QGifHandler::supportsOption(ImageOption option) const -{ - if (!device() || device()->isSequential()) - return option == Animation; - else - return option == Size - || option == Animation; -} - -QVariant QGifHandler::option(ImageOption option) const -{ - if (option == Size) { - if (!scanIsCached) { - QGIFFormat::scan(device(), &imageSizes, &loopCnt); - scanIsCached = true; - } - // before the first frame is read, or we have an empty data stream - if (frameNumber == -1) - return (imageSizes.count() > 0) ? QVariant(imageSizes.at(0)) : QVariant(); - // after the last frame has been read, the next size is undefined - if (frameNumber >= imageSizes.count() - 1) - return QVariant(); - // and the last case: the size of the next frame - return imageSizes.at(frameNumber + 1); - } else if (option == Animation) { - return true; - } - return QVariant(); -} - -void QGifHandler::setOption(ImageOption option, const QVariant &value) -{ - Q_UNUSED(option); - Q_UNUSED(value); -} - -int QGifHandler::nextImageDelay() const -{ - return nextDelay; -} - -int QGifHandler::imageCount() const -{ - if (!scanIsCached) { - QGIFFormat::scan(device(), &imageSizes, &loopCnt); - scanIsCached = true; - } - return imageSizes.count(); -} - -int QGifHandler::loopCount() const -{ - if (!scanIsCached) { - QGIFFormat::scan(device(), &imageSizes, &loopCnt); - scanIsCached = true; - } - - if (loopCnt == 0) - return -1; - else if (loopCnt == -1) - return 0; - else - return loopCnt; -} - -int QGifHandler::currentImageNumber() const -{ - return frameNumber; -} - -QByteArray QGifHandler::name() const -{ - return "gif"; -} - -QT_END_NAMESPACE diff --git a/src/gui/image/qgifhandler.pri b/src/gui/image/qgifhandler.pri deleted file mode 100644 index ec33101451..0000000000 --- a/src/gui/image/qgifhandler.pri +++ /dev/null @@ -1,3 +0,0 @@ -# common to plugin and built-in forms -HEADERS += $$PWD/qgifhandler_p.h -SOURCES += $$PWD/qgifhandler.cpp diff --git a/src/gui/image/qgifhandler_p.h b/src/gui/image/qgifhandler_p.h deleted file mode 100644 index bc3debe83c..0000000000 --- a/src/gui/image/qgifhandler_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** WARNING: -** A separate license from Unisys may be required to use the gif -** reader. See http://www.unisys.com/about__unisys/lzw/ -** for information from Unisys -** -****************************************************************************/ - -#ifndef QGIFHANDLER_P_H -#define QGIFHANDLER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtGui/qimageiohandler.h> -#include <QtGui/qimage.h> -#include <QtCore/qbytearray.h> - -QT_BEGIN_NAMESPACE - -class QGIFFormat; -class QGifHandler : public QImageIOHandler -{ -public: - QGifHandler(); - ~QGifHandler(); - - bool canRead() const Q_DECL_OVERRIDE; - bool read(QImage *image) Q_DECL_OVERRIDE; - bool write(const QImage &image) Q_DECL_OVERRIDE; - - QByteArray name() const Q_DECL_OVERRIDE; - - static bool canRead(QIODevice *device); - - QVariant option(ImageOption option) const Q_DECL_OVERRIDE; - void setOption(ImageOption option, const QVariant &value) Q_DECL_OVERRIDE; - bool supportsOption(ImageOption option) const Q_DECL_OVERRIDE; - - int imageCount() const Q_DECL_OVERRIDE; - int loopCount() const Q_DECL_OVERRIDE; - int nextImageDelay() const Q_DECL_OVERRIDE; - int currentImageNumber() const Q_DECL_OVERRIDE; - -private: - bool imageIsComing() const; - QGIFFormat *gifFormat; - QString fileName; - mutable QByteArray buffer; - mutable QImage lastImage; - - mutable int nextDelay; - mutable int loopCnt; - int frameNumber; - mutable QVector<QSize> imageSizes; - mutable bool scanIsCached; -}; - -QT_END_NAMESPACE - -#endif // QGIFHANDLER_P_H diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 1b0e73c21b..40d3e92af9 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -40,7 +40,7 @@ #ifndef QICON_H #define QICON_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qsize.h> #include <QtCore/qlist.h> #include <QtGui/qpixmap.h> diff --git a/src/gui/image/qicon_p.h b/src/gui/image/qicon_p.h index cfae9b3e52..a978a72192 100644 --- a/src/gui/image/qicon_p.h +++ b/src/gui/image/qicon_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qsize.h> #include <QtCore/qlist.h> #include <QtGui/qpixmap.h> diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h index c702a1e8bb..b0c92ced73 100644 --- a/src/gui/image/qiconengine.h +++ b/src/gui/image/qiconengine.h @@ -40,7 +40,7 @@ #ifndef QICONENGINE_H #define QICONENGINE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qlist.h> #include <QtGui/qicon.h> diff --git a/src/gui/image/qiconengineplugin.h b/src/gui/image/qiconengineplugin.h index aacb3a9ebb..7a01d3731c 100644 --- a/src/gui/image/qiconengineplugin.h +++ b/src/gui/image/qiconengineplugin.h @@ -40,6 +40,7 @@ #ifndef QICONENGINEPLUGIN_H #define QICONENGINEPLUGIN_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 0233ccbf87..0faf8820dd 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -316,10 +316,8 @@ QIconTheme::QIconTheme(const QString &themeName) #ifndef QT_NO_SETTINGS if (themeIndex.exists()) { const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat); - QStringListIterator keyIterator(indexReader.allKeys()); - while (keyIterator.hasNext()) { - - const QString key = keyIterator.next(); + const QStringList keys = indexReader.allKeys(); + for (const QString &key : keys) { if (key.endsWith(QLatin1String("/Size"))) { // Note the QSettings ini-format does not accept // slashes in key names, hence we have to cheat @@ -431,21 +429,23 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName, QString contentDir = contentDirs.at(i) + QLatin1Char('/'); for (int j = 0; j < subDirs.size() ; ++j) { const QIconDirInfo &dirInfo = subDirs.at(j); - QString subdir = dirInfo.path; - QDir currentDir(contentDir + subdir); - if (currentDir.exists(pngIconName)) { + const QString subDir = contentDir + dirInfo.path + QLatin1Char('/'); + const QString pngPath = subDir + pngIconName; + if (QFile::exists(pngPath)) { PixmapEntry *iconEntry = new PixmapEntry; iconEntry->dir = dirInfo; - iconEntry->filename = currentDir.filePath(pngIconName); + iconEntry->filename = pngPath; // Notice we ensure that pixmap entries always come before // scalable to preserve search order afterwards info.entries.prepend(iconEntry); - } else if (m_supportsSvg && - currentDir.exists(svgIconName)) { - ScalableEntry *iconEntry = new ScalableEntry; - iconEntry->dir = dirInfo; - iconEntry->filename = currentDir.filePath(svgIconName); - info.entries.append(iconEntry); + } else if (m_supportsSvg) { + const QString svgPath = subDir + svgIconName; + if (QFile::exists(svgPath)) { + ScalableEntry *iconEntry = new ScalableEntry; + iconEntry->dir = dirInfo; + iconEntry->filename = svgPath; + info.entries.append(iconEntry); + } } } } diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h index 0945add2fb..583499be76 100644 --- a/src/gui/image/qiconloader_p.h +++ b/src/gui/image/qiconloader_p.h @@ -40,7 +40,7 @@ #ifndef QICONLOADER_P_H #define QICONLOADER_P_H -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #ifndef QT_NO_ICON // diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index de02e9a1dd..bd32ca7bee 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -780,9 +780,8 @@ QImage::QImage() Q_DECL_NOEXCEPT drawing onto it with QPainter. */ QImage::QImage(int width, int height, Format format) - : QPaintDevice() + : QImage(QSize(width, height), format) { - d = QImageData::create(QSize(width, height), format); } /*! @@ -2286,7 +2285,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, layout, 0); + return *layout->convertToARGB32PM(&result, ptr, 1, 0, 0); } /*! @@ -2388,7 +2387,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, layout, 0); + const uint *ptr = layout->convertFromARGB32PM(&result, &index_or_rgb, 1, 0, 0); qStorePixels[layout->bpp](s, ptr, x, 1); } @@ -2574,7 +2573,7 @@ bool QImage::allGray() const while (x < d->width) { int l = qMin(d->width - x, buffer_size); const uint *ptr = fetch(buffer, b, x, l); - ptr = layout->convertToARGB32PM(buffer, ptr, l, layout, 0); + ptr = layout->convertToARGB32PM(buffer, ptr, l, 0, 0); for (int i = 0; i < l; ++i) { if (!qIsGray(ptr[i])) return false; @@ -5217,4 +5216,33 @@ Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformation } } +QMap<QString, QString> qt_getImageText(const QImage &image, const QString &description) +{ + QMap<QString, QString> text = qt_getImageTextFromDescription(description); + const auto textKeys = image.textKeys(); + for (const QString &key : textKeys) { + if (!key.isEmpty() && !text.contains(key)) + text.insert(key, image.text(key)); + } + return text; +} + +QMap<QString, QString> qt_getImageTextFromDescription(const QString &description) +{ + QMap<QString, QString> text; + const auto pairs = description.splitRef(QLatin1String("\n\n")); + for (const QStringRef &pair : pairs) { + int index = pair.indexOf(QLatin1Char(':')); + if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) { + if (!pair.trimmed().isEmpty()) + text.insert(QLatin1String("Description"), pair.toString().simplified()); + } else { + const QStringRef key = pair.left(index); + if (!key.trimmed().isEmpty()) + text.insert(key.toString(), pair.mid(index + 2).toString().simplified()); + } + } + return text; +} + QT_END_NAMESPACE diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 6f8e214b11..91aaf673d0 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -40,6 +40,7 @@ #ifndef QIMAGE_H #define QIMAGE_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qcolor.h> #include <QtGui/qrgb.h> #include <QtGui/qpaintdevice.h> @@ -53,6 +54,10 @@ #include <QtCore/qstringlist.h> #endif +#if defined(Q_OS_DARWIN) || defined(Q_QDOC) +Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGImage); +#endif + QT_BEGIN_NAMESPACE @@ -320,6 +325,11 @@ public: static QPixelFormat toPixelFormat(QImage::Format format) Q_DECL_NOTHROW; static QImage::Format toImageFormat(QPixelFormat format) Q_DECL_NOTHROW; + // Platform spesific conversion functions +#if defined(Q_OS_DARWIN) || defined(Q_QDOC) + CGImageRef toCGImage() const Q_DECL_CF_RETURNS_RETAINED; +#endif + #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED inline QString text(const char *key, const char *lang = Q_NULLPTR) const; QT_DEPRECATED inline QList<QImageTextKeyLang> textList() const; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index bb0b76d55f..442492d198 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -108,7 +108,7 @@ void qGamma_correct_back_to_linear_cs(QImage *image) // The drawhelper conversions from/to RGB32 are passthroughs which is not always correct for general image conversion. static const uint *QT_FASTCALL convertRGB32FromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = 0xff000000 | qUnpremultiply(src[i]); @@ -116,7 +116,7 @@ static const uint *QT_FASTCALL convertRGB32FromARGB32PM(uint *buffer, const uint } static const uint *QT_FASTCALL convertRGB32ToARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = 0xff000000 |src[i]; @@ -124,10 +124,11 @@ static const uint *QT_FASTCALL convertRGB32ToARGB32PM(uint *buffer, const uint * } #ifdef QT_COMPILER_SUPPORTS_SSE4_1 -extern const uint *QT_FASTCALL convertRGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); +extern const uint *QT_FASTCALL convertRGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, + const QVector<QRgb> *, QDitherInfo *); #endif -void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) +void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags flags) { // Cannot be used with indexed formats. Q_ASSERT(dest->format > QImage::Format_Indexed8); @@ -158,14 +159,20 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio convertFromARGB32PM = convertRGB32FromARGB32PM; } } + QDitherInfo dither; + QDitherInfo *ditherPtr = 0; + if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither) + ditherPtr = &dither; for (int y = 0; y < src->height; ++y) { + dither.y = y; int x = 0; while (x < src->width) { + dither.x = x; int l = qMin(src->width - x, buffer_size); const uint *ptr = fetch(buffer, srcData, x, l); - ptr = convertToARGB32PM(buffer, ptr, l, srcLayout, 0); - ptr = convertFromARGB32PM(buffer, ptr, l, destLayout, 0); + ptr = convertToARGB32PM(buffer, ptr, l, 0, ditherPtr); + ptr = convertFromARGB32PM(buffer, ptr, l, 0, ditherPtr); store(destData, ptr, x, l); x += l; } @@ -174,7 +181,7 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio } } -bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags) +bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags flags) { // Cannot be used with indexed formats or between formats with different pixel depths. Q_ASSERT(dst_format > QImage::Format_Indexed8); @@ -207,14 +214,20 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im convertFromARGB32PM = convertRGB32FromARGB32PM; } } + QDitherInfo dither; + QDitherInfo *ditherPtr = 0; + if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither) + ditherPtr = &dither; for (int y = 0; y < data->height; ++y) { + dither.y = y; int x = 0; while (x < data->width) { + dither.x = x; int l = qMin(data->width - x, buffer_size); const uint *ptr = fetch(buffer, srcData, x, l); - ptr = convertToARGB32PM(buffer, ptr, l, srcLayout, 0); - ptr = convertFromARGB32PM(buffer, ptr, l, destLayout, 0); + ptr = convertToARGB32PM(buffer, ptr, l, 0, ditherPtr); + ptr = convertFromARGB32PM(buffer, ptr, l, 0, ditherPtr); // The conversions might be passthrough and not use the buffer, in that case we are already done. if (srcData != (const uchar*)ptr) store(srcData, ptr, x, l); diff --git a/src/gui/image/qimage_darwin.mm b/src/gui/image/qimage_darwin.mm new file mode 100644 index 0000000000..d72733abd3 --- /dev/null +++ b/src/gui/image/qimage_darwin.mm @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qimage.h" + +#include <private/qcore_mac_p.h> + +#import <Foundation/Foundation.h> +#import <CoreGraphics/CoreGraphics.h> + +QT_BEGIN_NAMESPACE + +/*! + Creates a \c CGImage equivalent to the QImage \a image. Returns a + \c CGImageRef handle. + + The returned CGImageRef partakes in the QImage implicit sharing, + and holds a reference to the QImage data. CGImage is immutable + and will never detach the QImage. Writing to the QImage will detach + as usual. + + This function is fast, and does not copy or convert image data. + + The following image formats are supported, and will be mapped to + a corresponding native image type: + + \table + \header + \li Qt + \li CoreGraphics + \row + \li Format_ARGB32 + \li kCGImageAlphaFirst | kCGBitmapByteOrder32Host + \row + \li Format_RGB32 + \li kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host + \row + \li Format_RGBA8888_Premultiplied + \li kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big + \row + \li Format_RGBA8888 + \li kCGImageAlphaLast | kCGBitmapByteOrder32Big + \row + \li Format_RGBX8888 + \li kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big + \row + \li Format_ARGB32_Premultiplied + \li kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host + \endtable + + Other formats are not supported; this function returns a null + CGImageRef for those cases. Users of this function may then + convert the QImage to a supported formate first, for example + Format_ARGB32_Premultiplied. + + The CGImageRef color space is set to the sRGB color space. + + \sa toNSImage() +*/ +CGImageRef QImage::toCGImage() const +{ + if (isNull()) + return nil; + + // Determine the target native format + uint cgflags = kCGImageAlphaNone; + switch (format()) { + case QImage::Format_ARGB32: + cgflags = kCGImageAlphaFirst | kCGBitmapByteOrder32Host; + break; + case QImage::Format_RGB32: + cgflags = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host; + break; + case QImage::Format_RGBA8888_Premultiplied: + cgflags = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big; + break; + case QImage::Format_RGBA8888: + cgflags = kCGImageAlphaLast | kCGBitmapByteOrder32Big; + break; + case QImage::Format_RGBX8888: + cgflags = kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big; + break; + case QImage::Format_ARGB32_Premultiplied: + cgflags = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host; + break; + default: break; + } + + // Format not supported: return nil CGImageRef + if (cgflags == kCGImageAlphaNone) + return nil; + + // Create a data provider that owns a copy of the QImage and references the image data. + auto deleter = [](void *image, const void *, size_t) + { delete static_cast<QImage *>(image); }; + QCFType<CGDataProviderRef> dataProvider = + CGDataProviderCreateWithData(new QImage(*this), bits(), byteCount(), deleter); + + QCFType<CGColorSpaceRef> colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); + + const size_t bitsPerComponent = 8; + const size_t bitsPerPixel = 32; + const CGFloat *decode = nullptr; + const bool shouldInterpolate = false; + + return CGImageCreate(width(), height(), bitsPerComponent, bitsPerPixel, + this->bytesPerLine(), colorSpace, cgflags, dataProvider, + decode, shouldInterpolate, kCGRenderingIntentDefault); +} + +QT_END_NAMESPACE diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index 3e76f39b94..775ab6d541 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #include <QMap> #include <QVector> @@ -212,6 +212,9 @@ inline QImage::Format qt_alphaVersionForPainting(QImage::Format format) return toFormat; } +Q_GUI_EXPORT QMap<QString, QString> qt_getImageText(const QImage &image, const QString &description); +Q_GUI_EXPORT QMap<QString, QString> qt_getImageTextFromDescription(const QString &description); + QT_END_NAMESPACE #endif // QIMAGE_P_H diff --git a/src/gui/image/qimage_sse4.cpp b/src/gui/image/qimage_sse4.cpp index 1f3f8f0d3f..0e2c2f492e 100644 --- a/src/gui/image/qimage_sse4.cpp +++ b/src/gui/image/qimage_sse4.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE const uint *QT_FASTCALL convertRGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = 0xff000000 | qUnpremultiply_sse4(src[i]); diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h index 8f196ee9e0..baf9853259 100644 --- a/src/gui/image/qimageiohandler.h +++ b/src/gui/image/qimageiohandler.h @@ -40,6 +40,7 @@ #ifndef QIMAGEIOHANDLER_H #define QIMAGEIOHANDLER_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qiodevice.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h index f0ac17b0a9..29144c6656 100644 --- a/src/gui/image/qimagepixmapcleanuphooks_p.h +++ b/src/gui/image/qimagepixmapcleanuphooks_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qpixmap.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 4dada4ca82..45d57856aa 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -147,6 +147,9 @@ #include <private/qfactoryloader_p.h> #include <QMutexLocker> +// for qt_getImageText +#include <private/qimage_p.h> + // image handlers #include <private/qbmphandler_p.h> #include <private/qppmhandler_p.h> @@ -155,12 +158,6 @@ #ifndef QT_NO_IMAGEFORMAT_PNG #include <private/qpnghandler_p.h> #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG -#include <private/qjpeghandler_p.h> -#endif -#ifdef QT_BUILTIN_GIF_READER -#include <private/qgifhandler_p.h> -#endif #include <algorithm> @@ -175,13 +172,6 @@ enum _qt_BuiltInFormatType { #ifndef QT_NO_IMAGEFORMAT_PNG _qt_PngFormat, #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG - _qt_JpgFormat, - _qt_JpegFormat, -#endif -#ifdef QT_BUILTIN_GIF_READER - _qt_GifFormat, -#endif #ifndef QT_NO_IMAGEFORMAT_BMP _qt_BmpFormat, #endif @@ -210,13 +200,6 @@ static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = { #ifndef QT_NO_IMAGEFORMAT_PNG {"png", "image/png"}, #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG - {"jpg", "image/jpeg"}, - {"jpeg", "image/jpeg"}, -#endif -#ifdef QT_BUILTIN_GIF_READER - {"gif", "image/gif"}, -#endif #ifndef QT_NO_IMAGEFORMAT_BMP {"bmp", "image/bmp"}, #endif @@ -357,14 +340,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, } else if (testFormat == "png") { handler = new QPngHandler; #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG - } else if (testFormat == "jpg" || testFormat == "jpeg") { - handler = new QJpegHandler; -#endif -#ifdef QT_BUILTIN_GIF_READER - } else if (testFormat == "gif") { - handler = new QGifHandler; -#endif #ifndef QT_NO_IMAGEFORMAT_BMP } else if (testFormat == "bmp") { handler = new QBmpHandler; @@ -442,19 +417,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, handler = new QPngHandler; break; #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG - case _qt_JpgFormat: - case _qt_JpegFormat: - if (QJpegHandler::canRead(device)) - handler = new QJpegHandler; - break; -#endif -#ifdef QT_BUILTIN_GIF_READER - case _qt_GifFormat: - if (QGifHandler::canRead(device)) - handler = new QGifHandler; - break; -#endif #ifndef QT_NO_IMAGEFORMAT_BMP case _qt_BmpFormat: if (QBmpHandler::canRead(device)) @@ -491,8 +453,8 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, if (handler) { #ifdef QIMAGEREADER_DEBUG - qDebug() << "QImageReader::createReadHandler: the" << _qt_BuiltInFormats[currentFormat].extension - << "built-in handler can read this data"; + qDebug("QImageReader::createReadHandler: the %s built-in handler can read this data", + _qt_BuiltInFormats[currentFormat].extension); #endif break; } @@ -633,18 +595,8 @@ bool QImageReaderPrivate::initHandler() */ void QImageReaderPrivate::getText() { - if (!text.isEmpty() || (!handler && !initHandler()) || !handler->supportsOption(QImageIOHandler::Description)) - return; - foreach (const QString &pair, handler->option(QImageIOHandler::Description).toString().split( - QLatin1String("\n\n"))) { - int index = pair.indexOf(QLatin1Char(':')); - if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) { - text.insert(QLatin1String("Description"), pair.simplified()); - } else { - QString key = pair.left(index); - text.insert(key, pair.mid(index + 2).simplified()); - } - } + if (text.isEmpty() && (handler || initHandler()) && handler->supportsOption(QImageIOHandler::Description)) + text = qt_getImageTextFromDescription(handler->option(QImageIOHandler::Description).toString()); } /*! @@ -674,12 +626,9 @@ QImageReader::QImageReader(QIODevice *device, const QByteArray &format) \sa setFileName() */ QImageReader::QImageReader(const QString &fileName, const QByteArray &format) - : d(new QImageReaderPrivate(this)) + : QImageReader(new QFile(fileName), format) { - QFile *file = new QFile(fileName); - d->device = file; d->deleteDevice = true; - d->format = format; } /*! diff --git a/src/gui/image/qimagereader.h b/src/gui/image/qimagereader.h index ad4f56c001..9d6c1e0b1e 100644 --- a/src/gui/image/qimagereader.h +++ b/src/gui/image/qimagereader.h @@ -40,6 +40,7 @@ #ifndef QIMAGEREADER_H #define QIMAGEREADER_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qbytearray.h> #include <QtCore/qcoreapplication.h> #include <QtGui/qimage.h> diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index 35db038601..f3af2738af 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -115,12 +115,6 @@ #ifndef QT_NO_IMAGEFORMAT_PNG #include <private/qpnghandler_p.h> #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG -#include <private/qjpeghandler_p.h> -#endif -#ifdef QT_BUILTIN_GIF_READER -#include <private/qgifhandler_p.h> -#endif #include <algorithm> @@ -184,14 +178,6 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, } else if (testFormat == "png") { handler = new QPngHandler; #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG - } else if (testFormat == "jpg" || testFormat == "jpeg") { - handler = new QJpegHandler; -#endif -#ifdef QT_BUILTIN_GIF_READER - } else if (testFormat == "gif") { - handler = new QGifHandler; -#endif #ifndef QT_NO_IMAGEFORMAT_BMP } else if (testFormat == "bmp") { handler = new QBmpHandler; @@ -340,12 +326,9 @@ QImageWriter::QImageWriter(QIODevice *device, const QByteArray &format) by inspecting the extension of \a fileName. */ QImageWriter::QImageWriter(const QString &fileName, const QByteArray &format) - : d(new QImageWriterPrivate(this)) + : QImageWriter(new QFile(fileName), format) { - QFile *file = new QFile(fileName); - d->device = file; d->deleteDevice = true; - d->format = format; } /*! @@ -910,9 +893,6 @@ QList<QByteArray> QImageWriter::supportedImageFormats() #ifndef QT_NO_IMAGEFORMAT_PNG formats << "png"; #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG - formats << "jpg" << "jpeg"; -#endif #ifndef QT_NO_IMAGEFORMATPLUGIN supportedImageHandlerFormats(loader(), QImageIOPlugin::CanWrite, &formats); @@ -951,9 +931,6 @@ QList<QByteArray> QImageWriter::supportedMimeTypes() #ifndef QT_NO_IMAGEFORMAT_PNG mimeTypes << "image/png"; #endif -#ifndef QT_NO_IMAGEFORMAT_JPEG - mimeTypes << "image/jpeg"; -#endif #ifndef QT_NO_IMAGEFORMATPLUGIN supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanWrite, &mimeTypes); diff --git a/src/gui/image/qimagewriter.h b/src/gui/image/qimagewriter.h index a6208ae5dc..58f8c51472 100644 --- a/src/gui/image/qimagewriter.h +++ b/src/gui/image/qimagewriter.h @@ -40,6 +40,7 @@ #ifndef QIMAGEWRITER_H #define QIMAGEWRITER_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qbytearray.h> #include <QtCore/qcoreapplication.h> #include <QtCore/qlist.h> diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp deleted file mode 100644 index 52e8b39f11..0000000000 --- a/src/gui/image/qjpeghandler.cpp +++ /dev/null @@ -1,1144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qjpeghandler_p.h" - -#include <qimage.h> -#include <qvariant.h> -#include <qvector.h> -#include <qbuffer.h> -#include <qmath.h> -#include <private/qsimd_p.h> - -#include <stdio.h> // jpeglib needs this to be pre-included -#include <setjmp.h> - -#ifdef FAR -#undef FAR -#endif - -// including jpeglib.h seems to be a little messy -extern "C" { -// mingw includes rpcndr.h but does not define boolean -#if defined(Q_OS_WIN) && defined(Q_CC_GNU) -# if defined(__RPCNDR_H__) && !defined(boolean) - typedef unsigned char boolean; -# define HAVE_BOOLEAN -# endif -#endif - -#define XMD_H // shut JPEGlib up -#if defined(Q_OS_UNIXWARE) -# define HAVE_BOOLEAN // libjpeg under Unixware seems to need this -#endif -#include <jpeglib.h> -#ifdef const -# undef const // remove crazy C hackery in jconfig.h -#endif -} - -QT_BEGIN_NAMESPACE -QT_WARNING_DISABLE_GCC("-Wclobbered") - -Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32(quint32 *dst, const uchar *src, int len); -typedef void (QT_FASTCALL *Rgb888ToRgb32Converter)(quint32 *dst, const uchar *src, int len); - -struct my_error_mgr : public jpeg_error_mgr { - jmp_buf setjmp_buffer; -}; - -extern "C" { - -static void my_error_exit (j_common_ptr cinfo) -{ - my_error_mgr* myerr = (my_error_mgr*) cinfo->err; - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buffer); - qWarning("%s", buffer); - longjmp(myerr->setjmp_buffer, 1); -} - -static void my_output_message(j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buffer); - qWarning("%s", buffer); -} - -} - - -static const int max_buf = 4096; - -struct my_jpeg_source_mgr : public jpeg_source_mgr { - // Nothing dynamic - cannot rely on destruction over longjump - QIODevice *device; - JOCTET buffer[max_buf]; - const QBuffer *memDevice; - -public: - my_jpeg_source_mgr(QIODevice *device); -}; - -extern "C" { - -static void qt_init_source(j_decompress_ptr) -{ -} - -static boolean qt_fill_input_buffer(j_decompress_ptr cinfo) -{ - my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; - qint64 num_read = 0; - if (src->memDevice) { - src->next_input_byte = (const JOCTET *)(src->memDevice->data().constData() + src->memDevice->pos()); - num_read = src->memDevice->data().size() - src->memDevice->pos(); - src->device->seek(src->memDevice->data().size()); - } else { - src->next_input_byte = src->buffer; - num_read = src->device->read((char*)src->buffer, max_buf); - } - if (num_read <= 0) { - // Insert a fake EOI marker - as per jpeglib recommendation - src->next_input_byte = src->buffer; - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - src->bytes_in_buffer = 2; - } else { - src->bytes_in_buffer = num_read; - } - return TRUE; -} - -static void qt_skip_input_data(j_decompress_ptr cinfo, long num_bytes) -{ - my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; - - // `dumb' implementation from jpeglib - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - if (num_bytes > 0) { - while (num_bytes > (long) src->bytes_in_buffer) { // Should not happen in case of memDevice - num_bytes -= (long) src->bytes_in_buffer; - (void) qt_fill_input_buffer(cinfo); - /* note we assume that qt_fill_input_buffer will never return false, - * so suspension need not be handled. - */ - } - src->next_input_byte += (size_t) num_bytes; - src->bytes_in_buffer -= (size_t) num_bytes; - } -} - -static void qt_term_source(j_decompress_ptr cinfo) -{ - my_jpeg_source_mgr* src = (my_jpeg_source_mgr*)cinfo->src; - if (!src->device->isSequential()) - src->device->seek(src->device->pos() - src->bytes_in_buffer); -} - -} - -inline my_jpeg_source_mgr::my_jpeg_source_mgr(QIODevice *device) -{ - jpeg_source_mgr::init_source = qt_init_source; - jpeg_source_mgr::fill_input_buffer = qt_fill_input_buffer; - jpeg_source_mgr::skip_input_data = qt_skip_input_data; - jpeg_source_mgr::resync_to_restart = jpeg_resync_to_restart; - jpeg_source_mgr::term_source = qt_term_source; - this->device = device; - memDevice = qobject_cast<QBuffer *>(device); - bytes_in_buffer = 0; - next_input_byte = buffer; -} - - -inline static bool read_jpeg_size(int &w, int &h, j_decompress_ptr cinfo) -{ - (void) jpeg_calc_output_dimensions(cinfo); - - w = cinfo->output_width; - h = cinfo->output_height; - return true; -} - -#define HIGH_QUALITY_THRESHOLD 50 - -inline static bool read_jpeg_format(QImage::Format &format, j_decompress_ptr cinfo) -{ - - bool result = true; - switch (cinfo->output_components) { - case 1: - format = QImage::Format_Grayscale8; - break; - case 3: - case 4: - format = QImage::Format_RGB32; - break; - default: - result = false; - break; - } - cinfo->output_scanline = cinfo->output_height; - return result; -} - -static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info, - const QSize& size) -{ - QImage::Format format; - switch (info->output_components) { - case 1: - format = QImage::Format_Grayscale8; - break; - case 3: - case 4: - format = QImage::Format_RGB32; - break; - default: - return false; // unsupported format - } - - if (dest->size() != size || dest->format() != format) - *dest = QImage(size, format); - - return !dest->isNull(); -} - -static bool read_jpeg_image(QImage *outImage, - QSize scaledSize, QRect scaledClipRect, - QRect clipRect, volatile int inQuality, - Rgb888ToRgb32Converter converter, - j_decompress_ptr info, struct my_error_mgr* err ) -{ - if (!setjmp(err->setjmp_buffer)) { - // -1 means default quality. - int quality = inQuality; - if (quality < 0) - quality = 75; - - // If possible, merge the scaledClipRect into either scaledSize - // or clipRect to avoid doing a separate scaled clipping pass. - // Best results are achieved by clipping before scaling, not after. - if (!scaledClipRect.isEmpty()) { - if (scaledSize.isEmpty() && clipRect.isEmpty()) { - // No clipping or scaling before final clip. - clipRect = scaledClipRect; - scaledClipRect = QRect(); - } else if (scaledSize.isEmpty()) { - // Clipping, but no scaling: combine the clip regions. - scaledClipRect.translate(clipRect.topLeft()); - clipRect = scaledClipRect.intersected(clipRect); - scaledClipRect = QRect(); - } else if (clipRect.isEmpty()) { - // No clipping, but scaling: if we can map back to an - // integer pixel boundary, then clip before scaling. - if ((info->image_width % scaledSize.width()) == 0 && - (info->image_height % scaledSize.height()) == 0) { - int x = scaledClipRect.x() * info->image_width / - scaledSize.width(); - int y = scaledClipRect.y() * info->image_height / - scaledSize.height(); - int width = (scaledClipRect.right() + 1) * - info->image_width / scaledSize.width() - x; - int height = (scaledClipRect.bottom() + 1) * - info->image_height / scaledSize.height() - y; - clipRect = QRect(x, y, width, height); - scaledSize = scaledClipRect.size(); - scaledClipRect = QRect(); - } - } else { - // Clipping and scaling: too difficult to figure out, - // and not a likely use case, so do it the long way. - } - } - - // Determine the scale factor to pass to libjpeg for quick downscaling. - if (!scaledSize.isEmpty() && info->image_width && info->image_height) { - if (clipRect.isEmpty()) { - double f = qMin(double(info->image_width) / scaledSize.width(), - double(info->image_height) / scaledSize.height()); - - // libjpeg supports M/8 scaling with M=[1,16]. All downscaling factors - // are a speed improvement, but upscaling during decode is slower. - info->scale_num = qBound(1, qCeil(8/f), 8); - info->scale_denom = 8; - } else { - info->scale_denom = qMin(clipRect.width() / scaledSize.width(), - clipRect.height() / scaledSize.height()); - - // Only scale by powers of two when clipping so we can - // keep the exact pixel boundaries - if (info->scale_denom < 2) - info->scale_denom = 1; - else if (info->scale_denom < 4) - info->scale_denom = 2; - else if (info->scale_denom < 8) - info->scale_denom = 4; - else - info->scale_denom = 8; - info->scale_num = 1; - - // Correct the scale factor so that we clip accurately. - // It is recommended that the clip rectangle be aligned - // on an 8-pixel boundary for best performance. - while (info->scale_denom > 1 && - ((clipRect.x() % info->scale_denom) != 0 || - (clipRect.y() % info->scale_denom) != 0 || - (clipRect.width() % info->scale_denom) != 0 || - (clipRect.height() % info->scale_denom) != 0)) { - info->scale_denom /= 2; - } - } - } - - // If high quality not required, use fast decompression - if( quality < HIGH_QUALITY_THRESHOLD ) { - info->dct_method = JDCT_IFAST; - info->do_fancy_upsampling = FALSE; - } - - (void) jpeg_calc_output_dimensions(info); - - // Determine the clip region to extract. - QRect imageRect(0, 0, info->output_width, info->output_height); - QRect clip; - if (clipRect.isEmpty()) { - clip = imageRect; - } else if (info->scale_denom == info->scale_num) { - clip = clipRect.intersected(imageRect); - } else { - // The scale factor was corrected above to ensure that - // we don't miss pixels when we scale the clip rectangle. - clip = QRect(clipRect.x() / int(info->scale_denom), - clipRect.y() / int(info->scale_denom), - clipRect.width() / int(info->scale_denom), - clipRect.height() / int(info->scale_denom)); - clip = clip.intersected(imageRect); - } - - // Allocate memory for the clipped QImage. - if (!ensureValidImage(outImage, info, clip.size())) - longjmp(err->setjmp_buffer, 1); - - // Avoid memcpy() overhead if grayscale with no clipping. - bool quickGray = (info->output_components == 1 && - clip == imageRect); - if (!quickGray) { - // Ask the jpeg library to allocate a temporary row. - // The library will automatically delete it for us later. - // The libjpeg docs say we should do this before calling - // jpeg_start_decompress(). We can't use "new" here - // because we are inside the setjmp() block and an error - // in the jpeg input stream would cause a memory leak. - JSAMPARRAY rows = (info->mem->alloc_sarray) - ((j_common_ptr)info, JPOOL_IMAGE, - info->output_width * info->output_components, 1); - - (void) jpeg_start_decompress(info); - - while (info->output_scanline < info->output_height) { - int y = int(info->output_scanline) - clip.y(); - if (y >= clip.height()) - break; // We've read the entire clip region, so abort. - - (void) jpeg_read_scanlines(info, rows, 1); - - if (y < 0) - continue; // Haven't reached the starting line yet. - - if (info->output_components == 3) { - uchar *in = rows[0] + clip.x() * 3; - QRgb *out = (QRgb*)outImage->scanLine(y); - converter(out, in, clip.width()); - } else if (info->out_color_space == JCS_CMYK) { - // Convert CMYK->RGB. - uchar *in = rows[0] + clip.x() * 4; - QRgb *out = (QRgb*)outImage->scanLine(y); - for (int i = 0; i < clip.width(); ++i) { - int k = in[3]; - *out++ = qRgb(k * in[0] / 255, k * in[1] / 255, - k * in[2] / 255); - in += 4; - } - } else if (info->output_components == 1) { - // Grayscale. - memcpy(outImage->scanLine(y), - rows[0] + clip.x(), clip.width()); - } - } - } else { - // Load unclipped grayscale data directly into the QImage. - (void) jpeg_start_decompress(info); - while (info->output_scanline < info->output_height) { - uchar *row = outImage->scanLine(info->output_scanline); - (void) jpeg_read_scanlines(info, &row, 1); - } - } - - if (info->output_scanline == info->output_height) - (void) jpeg_finish_decompress(info); - - if (info->density_unit == 1) { - outImage->setDotsPerMeterX(int(100. * info->X_density / 2.54)); - outImage->setDotsPerMeterY(int(100. * info->Y_density / 2.54)); - } else if (info->density_unit == 2) { - outImage->setDotsPerMeterX(int(100. * info->X_density)); - outImage->setDotsPerMeterY(int(100. * info->Y_density)); - } - - if (scaledSize.isValid() && scaledSize != clip.size()) { - *outImage = outImage->scaled(scaledSize, Qt::IgnoreAspectRatio, quality >= HIGH_QUALITY_THRESHOLD ? Qt::SmoothTransformation : Qt::FastTransformation); - } - - if (!scaledClipRect.isEmpty()) - *outImage = outImage->copy(scaledClipRect); - return !outImage->isNull(); - } - else - return false; -} - -struct my_jpeg_destination_mgr : public jpeg_destination_mgr { - // Nothing dynamic - cannot rely on destruction over longjump - QIODevice *device; - JOCTET buffer[max_buf]; - -public: - my_jpeg_destination_mgr(QIODevice *); -}; - - -extern "C" { - -static void qt_init_destination(j_compress_ptr) -{ -} - -static boolean qt_empty_output_buffer(j_compress_ptr cinfo) -{ - my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest; - - int written = dest->device->write((char*)dest->buffer, max_buf); - if (written == -1) - (*cinfo->err->error_exit)((j_common_ptr)cinfo); - - dest->next_output_byte = dest->buffer; - dest->free_in_buffer = max_buf; - - return TRUE; -} - -static void qt_term_destination(j_compress_ptr cinfo) -{ - my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest; - qint64 n = max_buf - dest->free_in_buffer; - - qint64 written = dest->device->write((char*)dest->buffer, n); - if (written == -1) - (*cinfo->err->error_exit)((j_common_ptr)cinfo); -} - -} - -inline my_jpeg_destination_mgr::my_jpeg_destination_mgr(QIODevice *device) -{ - jpeg_destination_mgr::init_destination = qt_init_destination; - jpeg_destination_mgr::empty_output_buffer = qt_empty_output_buffer; - jpeg_destination_mgr::term_destination = qt_term_destination; - this->device = device; - next_output_byte = buffer; - free_in_buffer = max_buf; -} - - -static inline void set_text(const QImage &image, j_compress_ptr cinfo, const QString &description) -{ - QMap<QString, QString> text; - foreach (const QString &key, image.textKeys()) { - if (!key.isEmpty()) - text.insert(key, image.text(key)); - } - foreach (const QString &pair, description.split(QLatin1String("\n\n"))) { - int index = pair.indexOf(QLatin1Char(':')); - if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) { - QString s = pair.simplified(); - if (!s.isEmpty()) - text.insert(QLatin1String("Description"), s); - } else { - QString key = pair.left(index); - if (!key.simplified().isEmpty()) - text.insert(key, pair.mid(index + 2).simplified()); - } - } - if (text.isEmpty()) - return; - - for (QMap<QString, QString>::ConstIterator it = text.constBegin(); it != text.constEnd(); ++it) { - QByteArray comment = it.key().toLatin1(); - if (!comment.isEmpty()) - comment += ": "; - comment += it.value().toLatin1(); - if (comment.length() > 65530) - comment.truncate(65530); - jpeg_write_marker(cinfo, JPEG_COM, (const JOCTET *)comment.constData(), comment.size()); - } -} - -static bool write_jpeg_image(const QImage &image, QIODevice *device, volatile int sourceQuality, const QString &description, bool optimize, bool progressive) -{ - bool success = false; - const QVector<QRgb> cmap = image.colorTable(); - - if (image.format() == QImage::Format_Invalid || image.format() == QImage::Format_Alpha8) - return false; - - struct jpeg_compress_struct cinfo; - JSAMPROW row_pointer[1]; - row_pointer[0] = 0; - - struct my_jpeg_destination_mgr *iod_dest = new my_jpeg_destination_mgr(device); - struct my_error_mgr jerr; - - cinfo.err = jpeg_std_error(&jerr); - jerr.error_exit = my_error_exit; - jerr.output_message = my_output_message; - - if (!setjmp(jerr.setjmp_buffer)) { - // WARNING: - // this if loop is inside a setjmp/longjmp branch - // do not create C++ temporaries here because the destructor may never be called - // if you allocate memory, make sure that you can free it (row_pointer[0]) - jpeg_create_compress(&cinfo); - - cinfo.dest = iod_dest; - - cinfo.image_width = image.width(); - cinfo.image_height = image.height(); - - bool gray = false; - switch (image.format()) { - case QImage::Format_Mono: - case QImage::Format_MonoLSB: - case QImage::Format_Indexed8: - gray = true; - for (int i = image.colorCount(); gray && i; i--) { - gray = gray & qIsGray(cmap[i-1]); - } - cinfo.input_components = gray ? 1 : 3; - cinfo.in_color_space = gray ? JCS_GRAYSCALE : JCS_RGB; - break; - case QImage::Format_Grayscale8: - gray = true; - cinfo.input_components = 1; - cinfo.in_color_space = JCS_GRAYSCALE; - break; - default: - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - } - - jpeg_set_defaults(&cinfo); - - qreal diffInch = qAbs(image.dotsPerMeterX()*2.54/100. - qRound(image.dotsPerMeterX()*2.54/100.)) - + qAbs(image.dotsPerMeterY()*2.54/100. - qRound(image.dotsPerMeterY()*2.54/100.)); - qreal diffCm = (qAbs(image.dotsPerMeterX()/100. - qRound(image.dotsPerMeterX()/100.)) - + qAbs(image.dotsPerMeterY()/100. - qRound(image.dotsPerMeterY()/100.)))*2.54; - if (diffInch < diffCm) { - cinfo.density_unit = 1; // dots/inch - cinfo.X_density = qRound(image.dotsPerMeterX()*2.54/100.); - cinfo.Y_density = qRound(image.dotsPerMeterY()*2.54/100.); - } else { - cinfo.density_unit = 2; // dots/cm - cinfo.X_density = (image.dotsPerMeterX()+50) / 100; - cinfo.Y_density = (image.dotsPerMeterY()+50) / 100; - } - - if (optimize) - cinfo.optimize_coding = true; - - if (progressive) - jpeg_simple_progression(&cinfo); - - int quality = sourceQuality >= 0 ? qMin(int(sourceQuality),100) : 75; - jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); - jpeg_start_compress(&cinfo, TRUE); - - set_text(image, &cinfo, description); - - row_pointer[0] = new uchar[cinfo.image_width*cinfo.input_components]; - int w = cinfo.image_width; - while (cinfo.next_scanline < cinfo.image_height) { - uchar *row = row_pointer[0]; - switch (image.format()) { - case QImage::Format_Mono: - case QImage::Format_MonoLSB: - if (gray) { - const uchar* data = image.constScanLine(cinfo.next_scanline); - if (image.format() == QImage::Format_MonoLSB) { - for (int i=0; i<w; i++) { - bool bit = !!(*(data + (i >> 3)) & (1 << (i & 7))); - row[i] = qRed(cmap[bit]); - } - } else { - for (int i=0; i<w; i++) { - bool bit = !!(*(data + (i >> 3)) & (1 << (7 -(i & 7)))); - row[i] = qRed(cmap[bit]); - } - } - } else { - const uchar* data = image.constScanLine(cinfo.next_scanline); - if (image.format() == QImage::Format_MonoLSB) { - for (int i=0; i<w; i++) { - bool bit = !!(*(data + (i >> 3)) & (1 << (i & 7))); - *row++ = qRed(cmap[bit]); - *row++ = qGreen(cmap[bit]); - *row++ = qBlue(cmap[bit]); - } - } else { - for (int i=0; i<w; i++) { - bool bit = !!(*(data + (i >> 3)) & (1 << (7 -(i & 7)))); - *row++ = qRed(cmap[bit]); - *row++ = qGreen(cmap[bit]); - *row++ = qBlue(cmap[bit]); - } - } - } - break; - case QImage::Format_Indexed8: - if (gray) { - const uchar* pix = image.constScanLine(cinfo.next_scanline); - for (int i=0; i<w; i++) { - *row = qRed(cmap[*pix]); - ++row; ++pix; - } - } else { - const uchar* pix = image.constScanLine(cinfo.next_scanline); - for (int i=0; i<w; i++) { - *row++ = qRed(cmap[*pix]); - *row++ = qGreen(cmap[*pix]); - *row++ = qBlue(cmap[*pix]); - ++pix; - } - } - break; - case QImage::Format_Grayscale8: - memcpy(row, image.constScanLine(cinfo.next_scanline), w); - break; - case QImage::Format_RGB888: - memcpy(row, image.constScanLine(cinfo.next_scanline), w * 3); - break; - case QImage::Format_RGB32: - case QImage::Format_ARGB32: - case QImage::Format_ARGB32_Premultiplied: - { - const QRgb* rgb = (const QRgb*)image.constScanLine(cinfo.next_scanline); - for (int i=0; i<w; i++) { - *row++ = qRed(*rgb); - *row++ = qGreen(*rgb); - *row++ = qBlue(*rgb); - ++rgb; - } - } - break; - default: - { - // (Testing shows that this way is actually faster than converting to RGB888 + memcpy) - QImage rowImg = image.copy(0, cinfo.next_scanline, w, 1).convertToFormat(QImage::Format_RGB32); - const QRgb* rgb = (const QRgb*)rowImg.constScanLine(0); - for (int i=0; i<w; i++) { - *row++ = qRed(*rgb); - *row++ = qGreen(*rgb); - *row++ = qBlue(*rgb); - ++rgb; - } - } - break; - } - jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - jpeg_finish_compress(&cinfo); - jpeg_destroy_compress(&cinfo); - success = true; - } else { - jpeg_destroy_compress(&cinfo); - success = false; - } - - delete iod_dest; - delete [] row_pointer[0]; - return success; -} - -class QJpegHandlerPrivate -{ -public: - enum State { - Ready, - ReadHeader, - ReadingEnd, - Error - }; - - QJpegHandlerPrivate(QJpegHandler *qq) - : quality(75), transformation(QImageIOHandler::TransformationNone), iod_src(0), - rgb888ToRgb32ConverterPtr(qt_convert_rgb888_to_rgb32), state(Ready), optimize(false), progressive(false), q(qq) - {} - - ~QJpegHandlerPrivate() - { - if(iod_src) - { - jpeg_destroy_decompress(&info); - delete iod_src; - iod_src = 0; - } - } - - bool readJpegHeader(QIODevice*); - bool read(QImage *image); - - int quality; - QImageIOHandler::Transformations transformation; - QVariant size; - QImage::Format format; - QSize scaledSize; - QRect scaledClipRect; - QRect clipRect; - QString description; - QStringList readTexts; - - struct jpeg_decompress_struct info; - struct my_jpeg_source_mgr * iod_src; - struct my_error_mgr err; - - Rgb888ToRgb32Converter rgb888ToRgb32ConverterPtr; - - State state; - - bool optimize; - bool progressive; - - QJpegHandler *q; -}; - -static bool readExifHeader(QDataStream &stream) -{ - char prefix[6]; - if (stream.readRawData(prefix, sizeof(prefix)) != sizeof(prefix)) - return false; - static const char exifMagic[6] = {'E', 'x', 'i', 'f', 0, 0}; - return memcmp(prefix, exifMagic, 6) == 0; -} - -/* - * Returns -1 on error - * Returns 0 if no Exif orientation was found - * Returns 1 orientation is horizontal (normal) - * Returns 2 mirror horizontal - * Returns 3 rotate 180 - * Returns 4 mirror vertical - * Returns 5 mirror horizontal and rotate 270 CCW - * Returns 6 rotate 90 CW - * Returns 7 mirror horizontal and rotate 90 CW - * Returns 8 rotate 270 CW - */ -static int getExifOrientation(QByteArray &exifData) -{ - QDataStream stream(&exifData, QIODevice::ReadOnly); - - if (!readExifHeader(stream)) - return -1; - - quint16 val; - quint32 offset; - const qint64 headerStart = stream.device()->pos(); - - // read byte order marker - stream >> val; - if (val == 0x4949) // 'II' == Intel - stream.setByteOrder(QDataStream::LittleEndian); - else if (val == 0x4d4d) // 'MM' == Motorola - stream.setByteOrder(QDataStream::BigEndian); - else - return -1; // unknown byte order - - // read size - stream >> val; - if (val != 0x2a) - return -1; - - stream >> offset; - - // read IFD - while (!stream.atEnd()) { - quint16 numEntries; - - // skip offset bytes to get the next IFD - const qint64 bytesToSkip = offset - (stream.device()->pos() - headerStart); - - if (stream.skipRawData(bytesToSkip) != bytesToSkip) - return -1; - - stream >> numEntries; - - for (; numEntries > 0; --numEntries) { - quint16 tag; - quint16 type; - quint32 components; - quint16 value; - quint16 dummy; - - stream >> tag >> type >> components >> value >> dummy; - if (tag == 0x0112) { // Tag Exif.Image.Orientation - if (components != 1) - return -1; - if (type != 3) // we are expecting it to be an unsigned short - return -1; - if (value < 1 || value > 8) // check for valid range - return -1; - - // It is possible to include the orientation multiple times. - // Right now the first value is returned. - return value; - } - } - - // read offset to next IFD - stream >> offset; - if (offset == 0) // this is the last IFD - break; - } - - // No Exif orientation was found - return 0; -} - -static QImageIOHandler::Transformations exif2Qt(int exifOrientation) -{ - switch (exifOrientation) { - case 1: // normal - return QImageIOHandler::TransformationNone; - case 2: // mirror horizontal - return QImageIOHandler::TransformationMirror; - case 3: // rotate 180 - return QImageIOHandler::TransformationRotate180; - case 4: // mirror vertical - return QImageIOHandler::TransformationFlip; - case 5: // mirror horizontal and rotate 270 CW - return QImageIOHandler::TransformationFlipAndRotate90; - case 6: // rotate 90 CW - return QImageIOHandler::TransformationRotate90; - case 7: // mirror horizontal and rotate 90 CW - return QImageIOHandler::TransformationMirrorAndRotate90; - case 8: // rotate 270 CW - return QImageIOHandler::TransformationRotate270; - } - qWarning("Invalid EXIF orientation"); - return QImageIOHandler::TransformationNone; -} - -/*! - \internal -*/ -bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device) -{ - if(state == Ready) - { - state = Error; - iod_src = new my_jpeg_source_mgr(device); - - info.err = jpeg_std_error(&err); - err.error_exit = my_error_exit; - err.output_message = my_output_message; - - jpeg_create_decompress(&info); - info.src = iod_src; - - if (!setjmp(err.setjmp_buffer)) { - jpeg_save_markers(&info, JPEG_COM, 0xFFFF); - jpeg_save_markers(&info, JPEG_APP0 + 1, 0xFFFF); // Exif uses APP1 marker - - (void) jpeg_read_header(&info, TRUE); - - int width = 0; - int height = 0; - read_jpeg_size(width, height, &info); - size = QSize(width, height); - - format = QImage::Format_Invalid; - read_jpeg_format(format, &info); - - QByteArray exifData; - - for (jpeg_saved_marker_ptr marker = info.marker_list; marker != NULL; marker = marker->next) { - if (marker->marker == JPEG_COM) { - QString key, value; - QString s = QString::fromLatin1((const char *)marker->data, marker->data_length); - int index = s.indexOf(QLatin1String(": ")); - if (index == -1 || s.indexOf(QLatin1Char(' ')) < index) { - key = QLatin1String("Description"); - value = s; - } else { - key = s.left(index); - value = s.mid(index + 2); - } - if (!description.isEmpty()) - description += QLatin1String("\n\n"); - description += key + QLatin1String(": ") + value.simplified(); - readTexts.append(key); - readTexts.append(value); - } else if (marker->marker == JPEG_APP0 + 1) { - exifData.append((const char*)marker->data, marker->data_length); - } - } - - if (!exifData.isEmpty()) { - // Exif data present - int exifOrientation = getExifOrientation(exifData); - if (exifOrientation > 0) - transformation = exif2Qt(exifOrientation); - } - - state = ReadHeader; - return true; - } - else - { - return false; - } - } - else if(state == Error) - return false; - return true; -} - -bool QJpegHandlerPrivate::read(QImage *image) -{ - if(state == Ready) - readJpegHeader(q->device()); - - if(state == ReadHeader) - { - bool success = read_jpeg_image(image, scaledSize, scaledClipRect, clipRect, quality, rgb888ToRgb32ConverterPtr, &info, &err); - if (success) { - for (int i = 0; i < readTexts.size()-1; i+=2) - image->setText(readTexts.at(i), readTexts.at(i+1)); - - state = ReadingEnd; - return true; - } - - state = Error; - } - - return false; - -} - -Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len); -Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, const uchar *src, int len); -extern "C" void qt_convert_rgb888_to_rgb32_mips_dspr2_asm(quint32 *dst, const uchar *src, int len); - -QJpegHandler::QJpegHandler() - : d(new QJpegHandlerPrivate(this)) -{ -#if defined(__ARM_NEON__) - // from qimage_neon.cpp - if (qCpuHasFeature(NEON)) - d->rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_neon; -#endif - -#if defined(QT_COMPILER_SUPPORTS_SSSE3) - // from qimage_ssse3.cpps - if (qCpuHasFeature(SSSE3)) { - d->rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_ssse3; - } -#endif // QT_COMPILER_SUPPORTS_SSSE3 -#if defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) - if (qCpuHasFeature(DSPR2)) { - d->rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_mips_dspr2_asm; - } -#endif // QT_COMPILER_SUPPORTS_DSPR2 -} - -QJpegHandler::~QJpegHandler() -{ - delete d; -} - -bool QJpegHandler::canRead() const -{ - if(d->state == QJpegHandlerPrivate::Ready && !canRead(device())) - return false; - - if (d->state != QJpegHandlerPrivate::Error && d->state != QJpegHandlerPrivate::ReadingEnd) { - setFormat("jpeg"); - return true; - } - - return false; -} - -bool QJpegHandler::canRead(QIODevice *device) -{ - if (!device) { - qWarning("QJpegHandler::canRead() called with no device"); - return false; - } - - char buffer[2]; - if (device->peek(buffer, 2) != 2) - return false; - return uchar(buffer[0]) == 0xff && uchar(buffer[1]) == 0xd8; -} - -bool QJpegHandler::read(QImage *image) -{ - if (!canRead()) - return false; - return d->read(image); -} - -extern void qt_imageTransform(QImage &src, QImageIOHandler::Transformations orient); - -bool QJpegHandler::write(const QImage &image) -{ - if (d->transformation != QImageIOHandler::TransformationNone) { - // We don't support writing EXIF headers so apply the transform to the data. - QImage img = image; - qt_imageTransform(img, d->transformation); - return write_jpeg_image(img, device(), d->quality, d->description, d->optimize, d->progressive); - } - return write_jpeg_image(image, device(), d->quality, d->description, d->optimize, d->progressive); -} - -bool QJpegHandler::supportsOption(ImageOption option) const -{ - return option == Quality - || option == ScaledSize - || option == ScaledClipRect - || option == ClipRect - || option == Description - || option == Size - || option == ImageFormat - || option == OptimizedWrite - || option == ProgressiveScanWrite - || option == ImageTransformation; -} - -QVariant QJpegHandler::option(ImageOption option) const -{ - switch(option) { - case Quality: - return d->quality; - case ScaledSize: - return d->scaledSize; - case ScaledClipRect: - return d->scaledClipRect; - case ClipRect: - return d->clipRect; - case Description: - d->readJpegHeader(device()); - return d->description; - case Size: - d->readJpegHeader(device()); - return d->size; - case ImageFormat: - d->readJpegHeader(device()); - return d->format; - case OptimizedWrite: - return d->optimize; - case ProgressiveScanWrite: - return d->progressive; - case ImageTransformation: - d->readJpegHeader(device()); - return int(d->transformation); - default: - break; - } - - return QVariant(); -} - -void QJpegHandler::setOption(ImageOption option, const QVariant &value) -{ - switch(option) { - case Quality: - d->quality = value.toInt(); - break; - case ScaledSize: - d->scaledSize = value.toSize(); - break; - case ScaledClipRect: - d->scaledClipRect = value.toRect(); - break; - case ClipRect: - d->clipRect = value.toRect(); - break; - case Description: - d->description = value.toString(); - break; - case OptimizedWrite: - d->optimize = value.toBool(); - break; - case ProgressiveScanWrite: - d->progressive = value.toBool(); - break; - case ImageTransformation: { - int transformation = value.toInt(); - if (transformation > 0 && transformation < 8) - d->transformation = QImageIOHandler::Transformations(transformation); - } - default: - break; - } -} - -QByteArray QJpegHandler::name() const -{ - return "jpeg"; -} - -QT_END_NAMESPACE diff --git a/src/gui/image/qjpeghandler.pri b/src/gui/image/qjpeghandler.pri deleted file mode 100644 index de40c6742e..0000000000 --- a/src/gui/image/qjpeghandler.pri +++ /dev/null @@ -1,11 +0,0 @@ -# common to plugin and built-in forms -HEADERS += $$PWD/qjpeghandler_p.h -SOURCES += $$PWD/qjpeghandler.cpp -contains(QT_CONFIG, system-jpeg) { - msvc: \ - LIBS += libjpeg.lib - else: \ - LIBS += -ljpeg -} else { - include($$PWD/../../3rdparty/libjpeg.pri) -} diff --git a/src/gui/image/qjpeghandler_p.h b/src/gui/image/qjpeghandler_p.h deleted file mode 100644 index 534ce12115..0000000000 --- a/src/gui/image/qjpeghandler_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QJPEGHANDLER_P_H -#define QJPEGHANDLER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtGui/qimageiohandler.h> -#include <QtCore/QSize> -#include <QtCore/QRect> - -QT_BEGIN_NAMESPACE - -class QJpegHandlerPrivate; -class QJpegHandler : public QImageIOHandler -{ -public: - QJpegHandler(); - ~QJpegHandler(); - - bool canRead() const Q_DECL_OVERRIDE; - bool read(QImage *image) Q_DECL_OVERRIDE; - bool write(const QImage &image) Q_DECL_OVERRIDE; - - QByteArray name() const Q_DECL_OVERRIDE; - - static bool canRead(QIODevice *device); - - QVariant option(ImageOption option) const Q_DECL_OVERRIDE; - void setOption(ImageOption option, const QVariant &value) Q_DECL_OVERRIDE; - bool supportsOption(ImageOption option) const Q_DECL_OVERRIDE; - -private: - QJpegHandlerPrivate *d; -}; - -QT_END_NAMESPACE - -#endif // QJPEGHANDLER_P_H diff --git a/src/gui/image/qmovie.h b/src/gui/image/qmovie.h index cf644d3347..2b41e07dba 100644 --- a/src/gui/image/qmovie.h +++ b/src/gui/image/qmovie.h @@ -40,10 +40,11 @@ #ifndef QMOVIE_H #define QMOVIE_H -#include <QtCore/qobject.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_MOVIE +#include <QtCore/qobject.h> #include <QtCore/qbytearray.h> #include <QtCore/qlist.h> #include <QtGui/qimagereader.h> diff --git a/src/gui/image/qpaintengine_pic_p.h b/src/gui/image/qpaintengine_pic_p.h index 6894593092..277004d055 100644 --- a/src/gui/image/qpaintengine_pic_p.h +++ b/src/gui/image/qpaintengine_pic_p.h @@ -52,7 +52,8 @@ // // -#include "QtGui/qpaintengine.h" +#include <QtGui/private/qtguiglobal_p.h> +#include <QtGui/qpaintengine.h> #ifndef QT_NO_PICTURE diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h index f375157317..8da11caee4 100644 --- a/src/gui/image/qpicture.h +++ b/src/gui/image/qpicture.h @@ -40,6 +40,7 @@ #ifndef QPICTURE_H #define QPICTURE_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qiodevice.h> #include <QtCore/qstringlist.h> #include <QtCore/qsharedpointer.h> diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h index df1235469c..67db9aa354 100644 --- a/src/gui/image/qpicture_p.h +++ b/src/gui/image/qpicture_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qatomic.h" #include "QtCore/qbuffer.h" #include "QtCore/qobjectdefs.h" diff --git a/src/gui/image/qpictureformatplugin.h b/src/gui/image/qpictureformatplugin.h index 003ccac116..32195687c7 100644 --- a/src/gui/image/qpictureformatplugin.h +++ b/src/gui/image/qpictureformatplugin.h @@ -40,6 +40,7 @@ #ifndef QPICTUREFORMATPLUGIN_H #define QPICTUREFORMATPLUGIN_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 59d6dc12c6..a360debf5b 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -125,12 +125,8 @@ QPixmap::QPixmap() */ QPixmap::QPixmap(int w, int h) - : QPaintDevice() + : QPixmap(QSize(w, h)) { - if (!qt_pixmap_thread_test()) - doInit(0, 0, QPlatformPixmap::PixmapType); - else - doInit(w, h, QPlatformPixmap::PixmapType); } /*! @@ -144,12 +140,8 @@ QPixmap::QPixmap(int w, int h) */ QPixmap::QPixmap(const QSize &size) - : QPaintDevice() + : QPixmap(size, QPlatformPixmap::PixmapType) { - if (!qt_pixmap_thread_test()) - doInit(0, 0, QPlatformPixmap::PixmapType); - else - doInit(size.width(), size.height(), QPlatformPixmap::PixmapType); } /*! @@ -778,7 +770,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers QFileInfo info(fileName); QString key = QLatin1String("qt_pixmap") % info.absoluteFilePath() - % HexString<uint>(info.lastModified().toTime_t()) + % HexString<uint>(info.lastModified().toSecsSinceEpoch()) % HexString<quint64>(info.size()) % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 165ec4a6b8..d651b57fd5 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -40,6 +40,7 @@ #ifndef QPIXMAP_H #define QPIXMAP_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qpaintdevice.h> #include <QtGui/qcolor.h> #include <QtCore/qnamespace.h> diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 0906b65d96..4032176efc 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -152,7 +152,7 @@ void QBlittablePlatformPixmap::fill(const QColor &color) uint pixel = qPremultiply(color.rgba()); const QPixelLayout *layout = &qPixelLayouts[blittable()->lock()->format()]; Q_ASSERT(layout->convertFromARGB32PM); - layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0); + layout->convertFromARGB32PM(&pixel, &pixel, 1, 0, 0); //so premultiplied formats are supported and ARGB32 and RGB32 blittable()->lock()->fill(pixel); @@ -298,10 +298,8 @@ QRectF QBlittablePlatformPixmap::clipAndTransformRect(const QRectF &rect) const if (clipData->hasRectClip) { transformationRect &= clipData->clipRect; } else if (clipData->hasRegionClip) { - const QVector<QRect> rects = clipData->clipRegion.rects(); - for (int i = 0; i < rects.size(); i++) { - transformationRect &= rects.at(i); - } + for (const QRect &rect : clipData->clipRegion) + transformationRect &= rect; } } } diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h index bc97bbc1df..9889cfb8ec 100644 --- a/src/gui/image/qpixmap_blitter_p.h +++ b/src/gui/image/qpixmap_blitter_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qpa/qplatformpixmap.h> #include <private/qpaintengine_blitter_p.h> diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 13104ce17f..741f7713da 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -42,7 +42,6 @@ #include <private/qfont_p.h> #include "qpixmap_raster_p.h" -#include "qnativeimage_p.h" #include "qimage_p.h" #include "qpaintengine.h" @@ -50,9 +49,12 @@ #include "qimage.h" #include <QBuffer> #include <QImageReader> +#include <QGuiApplication> +#include <QScreen> #include <private/qimage_p.h> #include <private/qsimd_p.h> #include <private/qdrawhelper_p.h> +#include <qpa/qplatformscreen.h> QT_BEGIN_NAMESPACE @@ -88,6 +90,13 @@ QRasterPlatformPixmap::~QRasterPlatformPixmap() { } +QImage::Format QRasterPlatformPixmap::systemOpaqueFormat() +{ + if (!QGuiApplication::primaryScreen()) + return QImage::Format_RGB32; + return QGuiApplication::primaryScreen()->handle()->format(); +} + QPlatformPixmap *QRasterPlatformPixmap::createCompatiblePlatformPixmap() const { return new QRasterPlatformPixmap(pixelType()); @@ -99,7 +108,7 @@ void QRasterPlatformPixmap::resize(int width, int height) if (pixelType() == BitmapType) format = QImage::Format_MonoLSB; else - format = QNativeImage::systemFormat(); + format = systemOpaqueFormat(); image = QImage(width, height, format); w = width; @@ -195,7 +204,7 @@ void QRasterPlatformPixmap::fill(const QColor &color) } pixel = qPremultiply(color.rgba()); const QPixelLayout *layout = &qPixelLayouts[image.format()]; - layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0); + layout->convertFromARGB32PM(&pixel, &pixel, 1, 0, 0); } else if (image.format() == QImage::Format_Alpha8) { pixel = qAlpha(color.rgba()); } else if (image.format() == QImage::Format_Grayscale8) { @@ -306,13 +315,13 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; } else { - QImage::Format opaqueFormat = QNativeImage::systemFormat(); + QImage::Format opaqueFormat = systemOpaqueFormat(); QImage::Format alphaFormat = qt_alphaVersionForPainting(opaqueFormat); if (!sourceImage.hasAlphaChannel()) { format = opaqueFormat; } else if ((flags & Qt::NoOpaqueDetection) == 0 - && !const_cast<QImage &>(sourceImage).data_ptr()->checkForAlphaPixels()) + && !sourceImage.data_ptr()->checkForAlphaPixels()) { format = opaqueFormat; } else { @@ -335,7 +344,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC } else if (inPlace && sourceImage.d->convertInPlace(format, flags)) { image = sourceImage; } else { - image = sourceImage.convertToFormat(format); + image = sourceImage.convertToFormat(format, flags); } if (image.d) { diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h index 1a42757669..95e018eb35 100644 --- a/src/gui/image/qpixmap_raster_p.h +++ b/src/gui/image/qpixmap_raster_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qpa/qplatformpixmap.h> @@ -87,6 +88,7 @@ protected: void createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace); void setImage(const QImage &image); QImage image; + static QImage::Format systemOpaqueFormat(); private: friend class QPixmap; diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index 7f20586156..92f6964783 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -48,84 +48,6 @@ QT_BEGIN_NAMESPACE -#ifdef Q_OS_WINCE -#define GetDIBits(a,b,c,d,e,f,g) qt_wince_GetDIBits(a,b,c,d,e,f,g) -int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID lpvBits, LPBITMAPINFO, uint) -{ - if (!lpvBits) { - qWarning("::GetDIBits(), lpvBits NULL"); - return 0; - } - BITMAP bm; - GetObject(hSourceBitmap, sizeof(BITMAP), &bm); - bm.bmHeight = qAbs(bm.bmHeight); - - HBITMAP hTargetBitmap; - void *pixels; - - BITMAPINFO dibInfo; - memset(&dibInfo, 0, sizeof(dibInfo)); - dibInfo.bmiHeader.biBitCount = 32; - dibInfo.bmiHeader.biClrImportant = 0; - dibInfo.bmiHeader.biClrUsed = 0; - dibInfo.bmiHeader.biCompression = BI_RGB;; - dibInfo.bmiHeader.biHeight = -bm.bmHeight; - dibInfo.bmiHeader.biWidth = bm.bmWidth; - dibInfo.bmiHeader.biPlanes = 1; - dibInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - dibInfo.bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4; - - HDC displayDC = GetDC(NULL); - if (!displayDC) { - qWarning("::GetDIBits(), failed to GetDC"); - return 0; - } - - int ret = bm.bmHeight; - - hTargetBitmap = CreateDIBSection(displayDC, (const BITMAPINFO*) &dibInfo, DIB_RGB_COLORS, - (void**)&pixels, NULL, 0); - if (!hTargetBitmap) { - qWarning("::GetDIBits(), failed to CreateDIBSection"); - return 0; - } - - HDC hdcSrc = CreateCompatibleDC(displayDC); - HDC hdcDst = CreateCompatibleDC(displayDC); - - if (!(hdcDst && hdcSrc)) { - qWarning("::GetDIBits(), failed to CreateCompatibleDC"); - ret = 0; - } - - HBITMAP hOldBitmap1 = (HBITMAP) SelectObject(hdcSrc, hSourceBitmap); - HBITMAP hOldBitmap2 = (HBITMAP) SelectObject(hdcDst, hTargetBitmap); - - if (!(hOldBitmap1 && hOldBitmap2)) { - qWarning("::GetDIBits(), failed to SelectObject for bitmaps"); - ret = 0; - } - - if (!BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY)) { - qWarning("::GetDIBits(), BitBlt failed"); - ret = 0; - } - - SelectObject(hdcSrc, hOldBitmap1); - SelectObject(hdcDst, hOldBitmap2); - - DeleteDC(hdcSrc); - DeleteDC(hdcDst); - - ReleaseDC(NULL, displayDC); - - memcpy(lpvBits, pixels, dibInfo.bmiHeader.biSizeImage); - - DeleteObject(hTargetBitmap); - return ret; -} -#endif - static inline void initBitMapInfoHeader(int width, int height, bool topToBottom, BITMAPINFOHEADER *bih) { memset(bih, 0, sizeof(BITMAPINFOHEADER)); @@ -325,8 +247,6 @@ Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p) return hIcon; } -#ifndef Q_OS_WINCE - Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h) { QImage image(w, h, QImage::Format_ARGB32_Premultiplied); @@ -415,95 +335,5 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon) DeleteDC(hdc); return QPixmap::fromImage(image); } -#else //ifndef Q_OS_WINCE -Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon) -{ - HDC screenDevice = GetDC(0); - HDC hdc = CreateCompatibleDC(screenDevice); - ReleaseDC(0, screenDevice); - - ICONINFO iconinfo; - bool result = GetIconInfo(icon, &iconinfo); - if (!result) - qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()"); - - int w = 0; - int h = 0; - if (!iconinfo.xHotspot || !iconinfo.yHotspot) { - // We could not retrieve the icon size via GetIconInfo, - // so we try again using the icon bitmap. - BITMAP bm; - int result = GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bm); - if (!result) result = GetObject(iconinfo.hbmMask, sizeof(BITMAP), &bm); - if (!result) { - qWarning("QPixmap::fromWinHICON(), failed to retrieve icon size"); - return QPixmap(); - } - w = bm.bmWidth; - h = bm.bmHeight; - } else { - // x and y Hotspot describes the icon center - w = iconinfo.xHotspot * 2; - h = iconinfo.yHotspot * 2; - } - const DWORD dwImageSize = w * h * 4; - - BITMAPINFO bmi; - memset(&bmi, 0, sizeof(bmi)); - bmi.bmiHeader.biSize = sizeof(BITMAPINFO); - bmi.bmiHeader.biWidth = w; - bmi.bmiHeader.biHeight = -h; - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = 32; - bmi.bmiHeader.biCompression = BI_RGB; - bmi.bmiHeader.biSizeImage = dwImageSize; - - uchar* bits; - - HBITMAP winBitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &bits, 0, 0); - if (winBitmap ) - memset(bits, 0xff, dwImageSize); - if (!winBitmap) { - qWarning("QPixmap::fromWinHICON(), failed to CreateDIBSection()"); - return QPixmap(); - } - - HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap); - if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_NORMAL)) - qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()"); - - uint mask = 0xff000000; - // Create image and copy data into image. - QImage image(w, h, QImage::Format_ARGB32); - - if (!image.isNull()) { // failed to alloc? - int bytes_per_line = w * sizeof(QRgb); - for (int y=0; y < h; ++y) { - QRgb *dest = (QRgb *) image.scanLine(y); - const QRgb *src = (const QRgb *) (bits + y * bytes_per_line); - for (int x=0; x < w; ++x) { - dest[x] = src[x]; - } - } - } - if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK)) - qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()"); - if (!image.isNull()) { // failed to alloc? - int bytes_per_line = w * sizeof(QRgb); - for (int y=0; y < h; ++y) { - QRgb *dest = (QRgb *) image.scanLine(y); - const QRgb *src = (const QRgb *) (bits + y * bytes_per_line); - for (int x=0; x < w; ++x) { - if (!src[x]) - dest[x] = dest[x] | mask; - } - } - } - SelectObject(hdc, oldhdc); //restore state - DeleteObject(winBitmap); - DeleteDC(hdc); - return QPixmap::fromImage(image); -} -#endif //ifndef Q_OS_WINCE QT_END_NAMESPACE diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h index cc35fd0fd2..856b82f559 100644 --- a/src/gui/image/qpixmapcache.h +++ b/src/gui/image/qpixmapcache.h @@ -40,6 +40,7 @@ #ifndef QPIXMAPCACHE_H #define QPIXMAPCACHE_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qpixmap.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 951c4ea9b1..3c57367514 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -50,6 +50,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qpixmapcache.h" #include "qpaintengine.h" #include <private/qimage_p.h> diff --git a/src/gui/image/qplatformpixmap.h b/src/gui/image/qplatformpixmap.h index c83278a4c3..8513755cca 100644 --- a/src/gui/image/qplatformpixmap.h +++ b/src/gui/image/qplatformpixmap.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtGui/qpixmap.h> #include <QtCore/qatomic.h> diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index d021e6f09f..fdf77e162c 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -49,6 +49,8 @@ #include <qvariant.h> #include <qvector.h> +#include <private/qimage_p.h> // for qt_getImageText + #include <png.h> #include <pngconf.h> @@ -75,20 +77,8 @@ # endif #endif -#ifdef Q_OS_WINCE -#define CALLBACK_CALL_TYPE __cdecl -#else -#define CALLBACK_CALL_TYPE -#endif - QT_BEGIN_NAMESPACE -#if defined(Q_OS_WINCE) && defined(STANDARDSHELL_UI_MODEL) -# define Q_INTERNAL_WIN_NO_THROW __declspec(nothrow) -#else -# define Q_INTERNAL_WIN_NO_THROW -#endif - // avoid going through QImage::scanLine() which calls detach #define FAST_SCAN_LINE(data, bpl, y) (data + (y) * bpl) @@ -190,7 +180,7 @@ private: extern "C" { static -void CALLBACK_CALL_TYPE iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) +void iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) { QPngHandlerPrivate *d = (QPngHandlerPrivate *)png_get_io_ptr(png_ptr); QIODevice *in = d->q->device(); @@ -215,7 +205,7 @@ void CALLBACK_CALL_TYPE iod_read_fn(png_structp png_ptr, png_bytep data, png_siz static -void CALLBACK_CALL_TYPE qpiw_write_fn(png_structp png_ptr, png_bytep data, png_size_t length) +void qpiw_write_fn(png_structp png_ptr, png_bytep data, png_size_t length) { QPNGImageWriter* qpiw = (QPNGImageWriter*)png_get_io_ptr(png_ptr); QIODevice* out = qpiw->device(); @@ -229,7 +219,7 @@ void CALLBACK_CALL_TYPE qpiw_write_fn(png_structp png_ptr, png_bytep data, png_s static -void CALLBACK_CALL_TYPE qpiw_flush_fn(png_structp /* png_ptr */) +void qpiw_flush_fn(png_structp /* png_ptr */) { } @@ -487,7 +477,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i } extern "C" { -static void CALLBACK_CALL_TYPE qt_png_warning(png_structp /*png_ptr*/, png_const_charp message) +static void qt_png_warning(png_structp /*png_ptr*/, png_const_charp message) { qWarning("libpng warning: %s", message); } @@ -495,7 +485,7 @@ static void CALLBACK_CALL_TYPE qt_png_warning(png_structp /*png_ptr*/, png_const } -void Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngTexts(png_info *info) +void QPngHandlerPrivate::readPngTexts(png_info *info) { png_textp text_ptr; int num_text=0; @@ -522,7 +512,7 @@ void Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngTexts(png_info *info) } -bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngHeader() +bool QPngHandlerPrivate::readPngHeader() { state = Error; png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0); @@ -566,7 +556,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngHeader() return true; } -bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage) +bool QPngHandlerPrivate::readPngImage(QImage *outImage) { if (state == Error) return false; @@ -730,27 +720,10 @@ void QPNGImageWriter::setGamma(float g) gamma = g; } - static void set_text(const QImage &image, png_structp png_ptr, png_infop info_ptr, const QString &description) { - QMap<QString, QString> text; - foreach (const QString &key, image.textKeys()) { - if (!key.isEmpty()) - text.insert(key, image.text(key)); - } - foreach (const QString &pair, description.split(QLatin1String("\n\n"))) { - int index = pair.indexOf(QLatin1Char(':')); - if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) { - QString s = pair.simplified(); - if (!s.isEmpty()) - text.insert(QLatin1String("Description"), s); - } else { - QString key = pair.left(index); - if (!key.simplified().isEmpty()) - text.insert(key, pair.mid(index + 2).simplified()); - } - } + const QMap<QString, QString> text = qt_getImageText(image, description); if (text.isEmpty()) return; @@ -810,7 +783,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int off_x, int off_y) return writeImage(image, -1, QString(), off_x, off_y); } -bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, volatile int quality_in, const QString &description, +bool QPNGImageWriter::writeImage(const QImage& image, volatile int quality_in, const QString &description, int off_x_in, int off_y_in) { QPoint offset = image.offset(); diff --git a/src/gui/image/qpnghandler.pri b/src/gui/image/qpnghandler.pri index 505d214130..e69de29bb2 100644 --- a/src/gui/image/qpnghandler.pri +++ b/src/gui/image/qpnghandler.pri @@ -1,4 +0,0 @@ -HEADERS += $$PWD/qpnghandler_p.h -SOURCES += $$PWD/qpnghandler.cpp - -include($$PWD/../../3rdparty/png_dependency.pri) diff --git a/src/gui/image/qpnghandler_p.h b/src/gui/image/qpnghandler_p.h index fb5a830baa..0232df7c3f 100644 --- a/src/gui/image/qpnghandler_p.h +++ b/src/gui/image/qpnghandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qimageiohandler.h" #ifndef QT_NO_IMAGEFORMAT_PNG diff --git a/src/gui/image/qppmhandler_p.h b/src/gui/image/qppmhandler_p.h index 1e8ca2b81e..3106d74651 100644 --- a/src/gui/image/qppmhandler_p.h +++ b/src/gui/image/qppmhandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qimageiohandler.h" #ifndef QT_NO_IMAGEFORMAT_PPM diff --git a/src/gui/image/qxbmhandler_p.h b/src/gui/image/qxbmhandler_p.h index 5094a43ef6..c59872f4be 100644 --- a/src/gui/image/qxbmhandler_p.h +++ b/src/gui/image/qxbmhandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qimageiohandler.h" #ifndef QT_NO_IMAGEFORMAT_XBM diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index c8dd589673..756e31318f 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -845,7 +845,7 @@ static bool read_xpm_header( if (!read_xpm_string(buf, device, source, index, state)) return false; -#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE) +#ifdef Q_CC_MSVC if (sscanf_s(buf, "%d %d %d %d", w, h, ncols, cpp) < 4) #else if (sscanf(buf, "%d %d %d %d", w, h, ncols, cpp) < 4) diff --git a/src/gui/image/qxpmhandler_p.h b/src/gui/image/qxpmhandler_p.h index 9a2041be94..51e5d6dc6c 100644 --- a/src/gui/image/qxpmhandler_p.h +++ b/src/gui/image/qxpmhandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qimageiohandler.h" #ifndef QT_NO_IMAGEFORMAT_XPM diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 5c04510af1..e965045524 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -705,20 +705,16 @@ void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent, Constructs an item. */ QStandardItem::QStandardItem() - : d_ptr(new QStandardItemPrivate) + : QStandardItem(*new QStandardItemPrivate) { - Q_D(QStandardItem); - d->q_ptr = this; } /*! Constructs an item with the given \a text. */ QStandardItem::QStandardItem(const QString &text) - : d_ptr(new QStandardItemPrivate) + : QStandardItem(*new QStandardItemPrivate) { - Q_D(QStandardItem); - d->q_ptr = this; setText(text); } @@ -726,22 +722,17 @@ QStandardItem::QStandardItem(const QString &text) Constructs an item with the given \a icon and \a text. */ QStandardItem::QStandardItem(const QIcon &icon, const QString &text) - : d_ptr(new QStandardItemPrivate) + : QStandardItem(text) { - Q_D(QStandardItem); - d->q_ptr = this; setIcon(icon); - setText(text); } /*! Constructs an item with \a rows rows and \a columns columns of child items. */ QStandardItem::QStandardItem(int rows, int columns) - : d_ptr(new QStandardItemPrivate) + : QStandardItem(*new QStandardItemPrivate) { - Q_D(QStandardItem); - d->q_ptr = this; setRowCount(rows); setColumnCount(columns); } @@ -1877,36 +1868,7 @@ bool QStandardItem::operator<(const QStandardItem &other) const { const int role = model() ? model()->sortRole() : Qt::DisplayRole; const QVariant l = data(role), r = other.data(role); - // this code is copied from QSortFilterProxyModel::lessThan() - if (l.userType() == QVariant::Invalid) - return false; - if (r.userType() == QVariant::Invalid) - return true; - switch (l.userType()) { - case QVariant::Int: - return l.toInt() < r.toInt(); - case QVariant::UInt: - return l.toUInt() < r.toUInt(); - case QVariant::LongLong: - return l.toLongLong() < r.toLongLong(); - case QVariant::ULongLong: - return l.toULongLong() < r.toULongLong(); - case QMetaType::Float: - return l.toFloat() < r.toFloat(); - case QVariant::Double: - return l.toDouble() < r.toDouble(); - case QVariant::Char: - return l.toChar() < r.toChar(); - case QVariant::Date: - return l.toDate() < r.toDate(); - case QVariant::Time: - return l.toTime() < r.toTime(); - case QVariant::DateTime: - return l.toDateTime() < r.toDateTime(); - case QVariant::String: - default: - return l.toString().compare(r.toString()) < 0; - } + return QAbstractItemModelPrivate::isVariantLessThan(l, r); } /*! diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index 476b936a25..a9cde106c1 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -40,6 +40,7 @@ #ifndef QSTANDARDITEMMODEL_H #define QSTANDARDITEMMODEL_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qabstractitemmodel.h> #include <QtGui/qbrush.h> #include <QtGui/qfont.h> diff --git a/src/gui/itemmodels/qstandarditemmodel_p.h b/src/gui/itemmodels/qstandarditemmodel_p.h index 1849e1a850..fbba93b93a 100644 --- a/src/gui/itemmodels/qstandarditemmodel_p.h +++ b/src/gui/itemmodels/qstandarditemmodel_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qabstractitemmodel_p.h" #ifndef QT_NO_STANDARDITEMMODEL diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 73a5a7b6ab..0e224df1ff 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -6,6 +6,8 @@ PRECOMPILED_HEADER = kernel/qt_gui_pch.h KERNEL_P= kernel HEADERS += \ + kernel/qtguiglobal.h \ + kernel/qtguiglobal_p.h \ kernel/qgenericpluginfactory.h \ kernel/qgenericplugin.h \ kernel/qwindowsysteminterface.h \ diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index bb3895c2f5..ec6c0bcc36 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -553,7 +553,7 @@ bool QClipboard::ownsFindBuffer() const bool QClipboard::supportsMode(Mode mode) const { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); - return clipboard->supportsMode(mode); + return clipboard && clipboard->supportsMode(mode); } /*! @@ -565,7 +565,7 @@ bool QClipboard::supportsMode(Mode mode) const bool QClipboard::ownsMode(Mode mode) const { QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); - return clipboard->ownsMode(mode); + return clipboard && clipboard->ownsMode(mode); } /*! diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h index 2588288880..e91444d3dc 100644 --- a/src/gui/kernel/qclipboard.h +++ b/src/gui/kernel/qclipboard.h @@ -40,6 +40,7 @@ #ifndef QCLIPBOARD_H #define QCLIPBOARD_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index 814e8ab7bd..c7e9188e5b 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -40,6 +40,7 @@ #ifndef QCURSOR_H #define QCURSOR_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qpoint.h> #include <QtGui/qwindowdefs.h> diff --git a/src/gui/kernel/qcursor_p.h b/src/gui/kernel/qcursor_p.h index 8dcea7fdcc..37245a793f 100644 --- a/src/gui/kernel/qcursor_p.h +++ b/src/gui/kernel/qcursor_p.h @@ -51,8 +51,8 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qatomic.h" -#include "QtCore/qglobal.h" #include "QtCore/qnamespace.h" #include "QtGui/qpixmap.h" diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index af7aaf771a..6f2ec46252 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qobject.h" #include "QtCore/qmap.h" #include "QtCore/qmimedata.h" diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h index 6332899c39..a8288e1b53 100644 --- a/src/gui/kernel/qdrag.h +++ b/src/gui/kernel/qdrag.h @@ -40,6 +40,7 @@ #ifndef QDRAG_H #define QDRAG_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 19220b5492..63876479bd 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -289,7 +289,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0) + : QMouseEvent(type, localPos, localPos, screenPos, button, buttons, modifiers) {} /*! @@ -342,7 +342,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &wind QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source) - : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0) + : QMouseEvent(type, localPos, windowPos, screenPos, button, buttons, modifiers) { QGuiApplicationPrivate::setMouseEventSource(this, source); } @@ -405,6 +405,18 @@ Qt::MouseEventFlags QMouseEvent::flags() const */ /*! + \fn void QMouseEvent::setLocalPos(const QPointF &localPosition) + + \since 5.8 + + \internal + + Sets the local position in the mouse event to \a localPosition. This allows to re-use one event + when sending it to a series of receivers that expect the local pos in their + respective local coordinates. +*/ + +/*! \fn QPointF QMouseEvent::windowPos() const \since 5.0 @@ -829,9 +841,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers) - : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::NoScrollPhase), - src(Qt::MouseEventNotSynthesized), invertedScrolling(false) + : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, + buttons, modifiers, Qt::NoScrollPhase) {} /*! @@ -860,9 +871,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase) - : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase), - src(Qt::MouseEventNotSynthesized), invertedScrolling(false) + : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, + buttons, modifiers, phase, Qt::MouseEventNotSynthesized) {} /*! @@ -896,9 +906,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source) - : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), - angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase), src(source), - invertedScrolling(false) + : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation, + buttons, modifiers, phase, source, false) {} /*! @@ -1767,7 +1776,7 @@ QIconDragEvent::~QIconDragEvent() coordinates. */ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos) - : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason) + : QContextMenuEvent(reason, pos, globalPos, Qt::NoModifier) {} /*! @@ -2065,6 +2074,16 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos) */ /*! + \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length) + \overload + \since 5.7 + + Constructs an input method attribute with no value. \a type + specifies the type of attribute, and \a start and \a length + the position of the attribute. +*/ + +/*! Constructs an event of type QEvent::InputMethod. The attributes(), preeditString(), commitString(), replacementStart(), and replacementLength() are initialized to default values. @@ -2440,19 +2459,8 @@ QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalP int device, int pointerType, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID) - : QInputEvent(type, keyState), - mPos(pos), - mGPos(globalPos), - mDev(device), - mPointerType(pointerType), - mXT(xTilt), - mYT(yTilt), - mZ(z), - mPress(pressure), - mTangential(tangentialPressure), - mRot(rotation), - mUnique(uniqueID), - mExtra(new QTabletEventPrivate(Qt::NoButton, Qt::NoButton)) + : QTabletEvent(type, pos, globalPos, device, pointerType, pressure, xTilt, yTilt, + tangentialPressure, rotation, z, keyState, uniqueID, Qt::NoButton, Qt::NoButton) { } @@ -4414,6 +4422,7 @@ QTouchEvent::~QTouchEvent() The values of this enum describe additional information about a touch point. \value Pen Indicates that the contact has been made by a designated pointing device (e.g. a pen) instead of a finger. + \value Token Indicates that the contact has been made by a fiducial object (e.g. a knob or other token) instead of a finger. */ /*! @@ -4460,6 +4469,22 @@ int QTouchEvent::TouchPoint::id() const } /*! + \since 5.8 + Returns the unique ID of this touch point or token, if any. + + It is normally invalid (with a \l {QPointerUniqueId::numeric()} {numeric()} value of -1), + because touchscreens cannot uniquely identify fingers. But when the + \l {TouchPoint::InfoFlag} {Token} flag is set, it is expected to uniquely + identify a specific token (fiducial object). + + \sa flags +*/ +QPointerUniqueId QTouchEvent::TouchPoint::uniqueId() const +{ + return d->uniqueId; +} + +/*! Returns the current state of this touch point. */ Qt::TouchPointState QTouchEvent::TouchPoint::state() const @@ -4663,6 +4688,19 @@ qreal QTouchEvent::TouchPoint::pressure() const } /*! + \since 5.8 + Returns the angular orientation of this touch point. The return value is in degrees, + where zero (the default) indicates the finger or token is pointing upwards, + a negative angle means it's rotated to the left, and a positive angle means + it's rotated to the right. Most touchscreens do not detect rotation, so + zero is the most common value. +*/ +qreal QTouchEvent::TouchPoint::rotation() const +{ + return d->rotation; +} + +/*! Returns a velocity vector for this touch point. The vector is in the screen's coordinate system, using pixels per seconds for the magnitude. @@ -4713,6 +4751,14 @@ void QTouchEvent::TouchPoint::setId(int id) } /*! \internal */ +void QTouchEvent::TouchPoint::setUniqueId(qint64 uid) +{ + if (d->ref.load() != 1) + d = d->detach(); + d->uniqueId = QPointerUniqueId(uid); +} + +/*! \internal */ void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state) { if (d->ref.load() != 1) @@ -4849,6 +4895,14 @@ void QTouchEvent::TouchPoint::setPressure(qreal pressure) } /*! \internal */ +void QTouchEvent::TouchPoint::setRotation(qreal angle) +{ + if (d->ref.load() != 1) + d = d->detach(); + d->rotation = angle; +} + +/*! \internal */ void QTouchEvent::TouchPoint::setVelocity(const QVector2D &v) { if (d->ref.load() != 1) @@ -5119,4 +5173,37 @@ Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const return m_applicationState; } +/*! + \class QPointerUniqueId + \since 5.8 + \ingroup events + \inmodule QtGui + + \brief QPointerUniqueId identifies a unique object, such as a tagged token + or stylus, which is used with a pointing device. + + \sa QTouchEvent::TouchPoint +*/ + +/*! + Constructs a unique pointer ID with a numeric \a id provided by the hardware. + The default is -1, which means an invalid pointer ID. +*/ +QPointerUniqueId::QPointerUniqueId(qint64 id) + : m_numericId(id) +{ +} + +/*! + \property QPointerUniqueId::numeric + \brief the numeric unique ID of the token represented by a touchpoint + + This is the numeric unique ID if the device provides that type of ID; + otherwise it is -1. +*/ +qint64 QPointerUniqueId::numeric() const +{ + return m_numericId; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 570212966f..93374b2299 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -40,6 +40,7 @@ #ifndef QEVENT_H #define QEVENT_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <QtGui/qregion.h> #include <QtCore/qnamespace.h> @@ -131,6 +132,8 @@ public: inline Qt::MouseButton button() const { return b; } inline Qt::MouseButtons buttons() const { return mouseState; } + inline void setLocalPos(const QPointF &localPosition) { l = localPosition; } + #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED inline QPointF posF() const { return l; } #endif @@ -535,8 +538,9 @@ public: class Attribute { public: Attribute(AttributeType typ, int s, int l, QVariant val) : type(typ), start(s), length(l), value(qMove(val)) {} - AttributeType type; + Attribute(AttributeType typ, int s, int l) : type(typ), start(s), length(l), value() {} + AttributeType type; int start; int length; QVariant value; @@ -789,6 +793,22 @@ inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);} #endif // QT_NO_SHORTCUT +class QPointerUniqueIdPrivate; +class Q_GUI_EXPORT QPointerUniqueId +{ + Q_GADGET + Q_PROPERTY(qint64 numeric READ numeric CONSTANT) +public: + explicit QPointerUniqueId(qint64 id = -1); + + qint64 numeric() const; + +private: + // TODO for TUIO 2, or any other type of complex token ID, a d-pointer can replace + // m_numericId without changing the size of this class. + qint64 m_numericId; +}; + class QTouchEventTouchPointPrivate; class Q_GUI_EXPORT QTouchEvent : public QInputEvent { @@ -797,7 +817,8 @@ public: { public: enum InfoFlag { - Pen = 0x0001 + Pen = 0x0001, + Token = 0x0002 }; #ifndef Q_MOC_RUN // otherwise moc gives @@ -823,6 +844,7 @@ public: { qSwap(d, other.d); } int id() const; + QPointerUniqueId uniqueId() const; Qt::TouchPointState state() const; @@ -847,12 +869,14 @@ public: QRectF screenRect() const; qreal pressure() const; + qreal rotation() const; QVector2D velocity() const; InfoFlags flags() const; QVector<QPointF> rawScreenPositions() const; // internal void setId(int id); + void setUniqueId(qint64 uid); void setState(Qt::TouchPointStates state); void setPos(const QPointF &pos); void setScenePos(const QPointF &scenePos); @@ -870,6 +894,7 @@ public: void setSceneRect(const QRectF &sceneRect); void setScreenRect(const QRectF &screenRect); void setPressure(qreal pressure); + void setRotation(qreal angle); void setVelocity(const QVector2D &v); void setFlags(InfoFlags flags); void setRawScreenPositions(const QVector<QPointF> &positions); diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index 726aa05d36..7e82b9c654 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -40,7 +40,7 @@ #ifndef QEVENT_P_H #define QEVENT_P_H -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qurl.h> #include <QtGui/qevent.h> @@ -65,7 +65,8 @@ public: : ref(1), id(id), state(Qt::TouchPointReleased), - pressure(qreal(-1.)) + pressure(qreal(-1.)), + rotation(qreal(0.)) { } inline QTouchEventTouchPointPrivate *detach() @@ -79,12 +80,14 @@ public: QAtomicInt ref; int id; + QPointerUniqueId uniqueId; Qt::TouchPointStates state; QRectF rect, sceneRect, screenRect; QPointF normalizedPos, startPos, startScenePos, startScreenPos, startNormalizedPos, lastPos, lastScenePos, lastScreenPos, lastNormalizedPos; qreal pressure; + qreal rotation; QVector2D velocity; QTouchEvent::TouchPoint::InfoFlags flags; QVector<QPointF> rawScreenPositions; diff --git a/src/gui/kernel/qgenericplugin.h b/src/gui/kernel/qgenericplugin.h index 7f1a493861..e8aa2e6f32 100644 --- a/src/gui/kernel/qgenericplugin.h +++ b/src/gui/kernel/qgenericplugin.h @@ -40,6 +40,7 @@ #ifndef QGENERICPLUGIN_H #define QGENERICPLUGIN_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/kernel/qgenericpluginfactory.h b/src/gui/kernel/qgenericpluginfactory.h index 282f3fed6d..9cc77a0590 100644 --- a/src/gui/kernel/qgenericpluginfactory.h +++ b/src/gui/kernel/qgenericpluginfactory.h @@ -40,6 +40,7 @@ #ifndef QGENERICPLUGINFACTORY_H #define QGENERICPLUGINFACTORY_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstringlist.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index f60cfd8af3..2ed7eb2cfb 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -104,13 +104,13 @@ #if defined(Q_OS_MAC) # include "private/qcore_mac_p.h" -#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#elif defined(Q_OS_WIN) # include <QtCore/qt_windows.h> # include <QtCore/QLibraryInfo> # if defined(Q_OS_WINPHONE) # include <Objbase.h> # endif -#endif // Q_OS_WIN && !Q_OS_WINCE +#endif // Q_OS_WIN #include <ctype.h> @@ -656,9 +656,20 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags */ void QGuiApplication::setApplicationDisplayName(const QString &name) { - if (!QGuiApplicationPrivate::displayName) - QGuiApplicationPrivate::displayName = new QString; - *QGuiApplicationPrivate::displayName = name; + if (!QGuiApplicationPrivate::displayName) { + QGuiApplicationPrivate::displayName = new QString(name); + if (qGuiApp) { + disconnect(qGuiApp, &QGuiApplication::applicationNameChanged, + qGuiApp, &QGuiApplication::applicationDisplayNameChanged); + + if (QGuiApplicationPrivate::displayName != applicationName()) + emit qGuiApp->applicationDisplayNameChanged(); + } + } else if (name != *QGuiApplicationPrivate::displayName) { + *QGuiApplicationPrivate::displayName = name; + if (qGuiApp) + emit qGuiApp->applicationDisplayNameChanged(); + } } QString QGuiApplication::applicationDisplayName() @@ -1054,7 +1065,7 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos) \li \c eglfs is a platform plugin for running Qt5 applications on top of EGL and OpenGL ES 2.0 without an actual windowing system (like X11 or Wayland). For more information, see \l{EGLFS}. - \li \c ios + \li \c ios (also used for tvOS) \li \c kms is an experimental platform plugin using kernel modesetting and \l{http://dri.freedesktop.org/wiki/DRM}{DRM} (Direct Rendering Manager). @@ -1102,12 +1113,12 @@ static void init_platform(const QString &pluginArgument, const QString &platform keys.join(QStringLiteral(", "))); } fatalMessage += QStringLiteral("Reinstalling the application may fix this problem."); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) // Windows: Display message box unless it is a console application // or debug build showing an assert box. if (!QLibraryInfo::isDebugBuild() && !GetConsoleWindow()) MessageBox(0, (LPCTSTR)fatalMessage.utf16(), (LPCTSTR)(QCoreApplication::applicationName().utf16()), MB_OK | MB_ICONERROR); -#endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT +#endif // Q_OS_WIN && !Q_OS_WINRT qFatal("%s", qPrintable(fatalMessage)); return; } @@ -1186,7 +1197,7 @@ static void init_plugins(const QList<QByteArray> &pluginList) if (plugin) QGuiApplicationPrivate::generic_plugin_list.append(plugin); else - qWarning() << "No such plugin for spec " << pluginSpec; + qWarning("No such plugin for spec \"%s\"", pluginSpec.constData()); } } @@ -1310,7 +1321,7 @@ void QGuiApplicationPrivate::init() #ifndef QT_NO_SESSIONMANAGER QString session_id; QString session_key; -# if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +# if defined(Q_OS_WIN) wchar_t guidstr[40]; GUID guid; CoCreateGuid(&guid); @@ -1424,9 +1435,8 @@ void QGuiApplicationPrivate::init() init_plugins(pluginList); QWindowSystemInterface::flushWindowSystemEvents(); -#ifndef QT_NO_SESSIONMANAGER Q_Q(QGuiApplication); - +#ifndef QT_NO_SESSIONMANAGER // connect to the session manager session_manager = new QSessionManager(q, session_id, session_key); #endif @@ -1455,6 +1465,10 @@ void QGuiApplicationPrivate::init() if (layout_direction == Qt::LayoutDirectionAuto || force_reverse) QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight); + + if (!QGuiApplicationPrivate::displayName) + QObject::connect(q, &QGuiApplication::applicationNameChanged, + q, &QGuiApplication::applicationDisplayNameChanged); } extern void qt_cleanupFontDatabase(); @@ -2450,6 +2464,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To QWindow *window = e->window.data(); typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents; + bool velocityOnly = false; for (int i = 0; i < e->points.count(); ++i) { QTouchEvent::TouchPoint touchPoint = e->points.at(i); @@ -2526,8 +2541,14 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To // Stationary points might not be delivered down to the receiving item // and get their position transformed, keep the old values instead. - if (touchPoint.state() != Qt::TouchPointStationary) + if (touchPoint.state() == Qt::TouchPointStationary) { + if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) { + touchInfo.touchPoint.setVelocity(touchPoint.velocity()); + velocityOnly = true; + } + } else { touchInfo.touchPoint = touchPoint; + } break; } @@ -2561,7 +2582,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To break; case Qt::TouchPointStationary: // don't send the event if nothing changed - continue; + if (velocityOnly) + eventType = QEvent::TouchUpdate; + else + continue; default: eventType = QEvent::TouchUpdate; break; diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h index 10057c5b7f..6721970222 100644 --- a/src/gui/kernel/qguiapplication.h +++ b/src/gui/kernel/qguiapplication.h @@ -40,6 +40,7 @@ #ifndef QGUIAPPLICATION_H #define QGUIAPPLICATION_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qcoreapplication.h> #include <QtGui/qwindowdefs.h> #include <QtGui/qinputmethod.h> @@ -72,7 +73,7 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication { Q_OBJECT Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon) - Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName) + Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName NOTIFY applicationDisplayNameChanged) Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName) Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged) Q_PROPERTY(QString platformName READ platformName STORED false) @@ -183,6 +184,7 @@ Q_SIGNALS: void saveStateRequest(QSessionManager &sessionManager); #endif void paletteChanged(const QPalette &pal); + void applicationDisplayNameChanged(); protected: bool event(QEvent *) Q_DECL_OVERRIDE; diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index a028441a2f..e1a35e048c 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qguiapplication.h> #include <QtCore/QPointF> diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index d5bc51a7e3..76663cdc01 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -68,10 +68,11 @@ static inline qreal initialGlobalScaleFactor() } } else { if (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar)) { - qWarning() << "Warning:" << legacyDevicePixelEnvVar << "is deprecated. Instead use:" << endl - << " " << autoScreenEnvVar << "to enable platform plugin controlled per-screen factors." << endl - << " " << screenFactorsEnvVar << "to set per-screen factors." << endl - << " " << scaleFactorEnvVar << "to set the application global scale factor."; + qWarning("Warning: %s is deprecated. Instead use:\n" + " %s to enable platform plugin controlled per-screen factors.\n" + " %s to set per-screen factors.\n" + " %s to set the application global scale factor.", + legacyDevicePixelEnvVar, autoScreenEnvVar, screenFactorsEnvVar, scaleFactorEnvVar); int dpr = qEnvironmentVariableIntValue(legacyDevicePixelEnvVar); if (dpr > 0) diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index eb3a9d5545..32c8f07dc0 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qmargins.h> #include <QtCore/qmath.h> #include <QtCore/qrect.h> @@ -382,8 +382,7 @@ inline QRegion fromNativeLocalRegion(const QRegion &pixelRegion, const QWindow * qreal scaleFactor = QHighDpiScaling::factor(window); QRegion pointRegion; - const auto rects = pixelRegion.rects(); - for (const QRect &rect : rects) { + for (const QRect &rect : pixelRegion) { pointRegion += QRect(fromNative(rect.topLeft(), scaleFactor), fromNative(rect.size(), scaleFactor)); } @@ -399,7 +398,7 @@ inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QW const qreal scaleFactor = QHighDpiScaling::factor(window); QRegion pointRegion; - foreach (const QRect &rect, pixelRegion.rects()) { + for (const QRect &rect : pixelRegion) { const QPointF topLeftP = QPointF(rect.topLeft()) / scaleFactor; const QPointF bottomRightP = QPointF(rect.bottomRight()) / scaleFactor; pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())), @@ -415,8 +414,7 @@ inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *wi qreal scaleFactor = QHighDpiScaling::factor(window); QRegion pixelRegon; - const auto rects = pointRegion.rects(); - for (const QRect &rect : rects) { + for (const QRect &rect : pointRegion) { pixelRegon += QRect(toNative(rect.topLeft(), scaleFactor), toNative(rect.size(), scaleFactor)); } diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h index 1cf0443834..11bbaae592 100644 --- a/src/gui/kernel/qinputdevicemanager_p.h +++ b/src/gui/kernel/qinputdevicemanager_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h index 45d8b64172..ae91f3a2ab 100644 --- a/src/gui/kernel/qinputdevicemanager_p_p.h +++ b/src/gui/kernel/qinputdevicemanager_p_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qmap.h> #include <private/qobject_p.h> #include "qinputdevicemanager_p.h" diff --git a/src/gui/kernel/qinputmethod.h b/src/gui/kernel/qinputmethod.h index 1a63d1314e..efdefb6e5a 100644 --- a/src/gui/kernel/qinputmethod.h +++ b/src/gui/kernel/qinputmethod.h @@ -40,6 +40,7 @@ #ifndef QINPUTMETHOD_H #define QINPUTMETHOD_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h index 3f7cd195ea..81723bbe30 100644 --- a/src/gui/kernel/qinputmethod_p.h +++ b/src/gui/kernel/qinputmethod_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qinputmethod.h> #include <private/qobject_p.h> #include <QtCore/QWeakPointer> diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h index 59977688e4..aeec7b7414 100644 --- a/src/gui/kernel/qkeymapper_p.h +++ b/src/gui/kernel/qkeymapper_p.h @@ -50,6 +50,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qobject.h> #include <private/qobject_p.h> #include <qkeysequence.h> diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h index 3a660b063e..6bdfd84ca3 100644 --- a/src/gui/kernel/qkeysequence.h +++ b/src/gui/kernel/qkeysequence.h @@ -40,7 +40,7 @@ #ifndef QKEYSEQUENCE_H #define QKEYSEQUENCE_H -#include <QtCore/qnamespace.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> #include <QtCore/qobjectdefs.h> diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h index 116e91c0cd..8ba86c31b8 100644 --- a/src/gui/kernel/qkeysequence_p.h +++ b/src/gui/kernel/qkeysequence_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qkeysequence.h" #include <algorithm> diff --git a/src/gui/kernel/qoffscreensurface.h b/src/gui/kernel/qoffscreensurface.h index d639407e1a..bacc9c851a 100644 --- a/src/gui/kernel/qoffscreensurface.h +++ b/src/gui/kernel/qoffscreensurface.h @@ -40,6 +40,7 @@ #ifndef QOFFSCREENSURFACE_H #define QOFFSCREENSURFACE_H +#include <QtGui/qtguiglobal.h> #include <QtCore/QObject> #include <QtGui/qsurface.h> diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 0f7bbfd2e1..7e5697e5d8 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -940,13 +940,20 @@ GLuint QOpenGLContext::defaultFramebufferObject() const If \a surface is 0 this is equivalent to calling doneCurrent(). - Do not call this function from a different thread than the one the + Avoid calling this function from a different thread than the one the QOpenGLContext instance lives in. If you wish to use QOpenGLContext from a different thread you should first call make sure it's not current in the current thread, by calling doneCurrent() if necessary. Then call moveToThread(otherThread) before using it in the other thread. - \sa functions(), doneCurrent() + By default Qt employs a check that enforces the above condition on the + thread affinity. It is still possible to disable this check by setting the + \c{Qt::AA_DontCheckOpenGLContextThreadAffinity} application attribute. Be + sure to understand the consequences of using QObjects from outside + the thread they live in, as explained in the + \l{QObject#Thread Affinity}{QObject thread affinity} documentation. + + \sa functions(), doneCurrent(), Qt::AA_DontCheckOpenGLContextThreadAffinity */ bool QOpenGLContext::makeCurrent(QSurface *surface) { @@ -954,8 +961,10 @@ bool QOpenGLContext::makeCurrent(QSurface *surface) if (!isValid()) return false; - if (Q_UNLIKELY(thread() != QThread::currentThread())) + if (Q_UNLIKELY(!qApp->testAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity) + && thread() != QThread::currentThread())) { qFatal("Cannot make QOpenGLContext current in a different thread"); + } if (!surface) { doneCurrent(); diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h index 33e3f1c3f6..3ec9ce3188 100644 --- a/src/gui/kernel/qopenglcontext.h +++ b/src/gui/kernel/qopenglcontext.h @@ -40,7 +40,7 @@ #ifndef QOPENGLCONTEXT_H #define QOPENGLCONTEXT_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 2fe8446c65..57f70356b8 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -51,6 +51,8 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> + #ifndef QT_NO_OPENGL #include "qopengl.h" diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index 8ab5c08442..e1bd3d11b2 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -42,7 +42,7 @@ #include <QtGui/QOpenGLFramebufferObject> #include <QtGui/QOpenGLPaintDevice> #include <QtGui/QOpenGLFunctions> -#include <QtGui/private/qopengltextureblitter_p.h> +#include <QtGui/QOpenGLTextureBlitter> #include <QtGui/private/qopenglextensions_p.h> #include <QtGui/private/qopenglcontext_p.h> #include <QtGui/QMatrix4x4> diff --git a/src/gui/kernel/qopenglwindow.h b/src/gui/kernel/qopenglwindow.h index 6e2a8ab904..fe236f9538 100644 --- a/src/gui/kernel/qopenglwindow.h +++ b/src/gui/kernel/qopenglwindow.h @@ -40,7 +40,7 @@ #ifndef QOPENGLWINDOW_H #define QOPENGLWINDOW_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/kernel/qpaintdevicewindow.h b/src/gui/kernel/qpaintdevicewindow.h index 1b66ed7c41..81b41dcdd5 100644 --- a/src/gui/kernel/qpaintdevicewindow.h +++ b/src/gui/kernel/qpaintdevicewindow.h @@ -40,6 +40,7 @@ #ifndef QPAINTDEVICEWINDOW_H #define QPAINTDEVICEWINDOW_H +#include <QtGui/qtguiglobal.h> #include <QtGui/QWindow> #include <QtGui/QPaintDevice> diff --git a/src/gui/kernel/qpaintdevicewindow_p.h b/src/gui/kernel/qpaintdevicewindow_p.h index 39cd1b3615..a16b83689e 100644 --- a/src/gui/kernel/qpaintdevicewindow_p.h +++ b/src/gui/kernel/qpaintdevicewindow_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/QPaintDeviceWindow> #include <QtCore/QCoreApplication> #include <QtGui/private/qwindow_p.h> diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index c130a1844b..d04fb1f0c5 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -40,6 +40,7 @@ #ifndef QPALETTE_H #define QPALETTE_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <QtGui/qcolor.h> #include <QtGui/qbrush.h> diff --git a/src/gui/kernel/qpixelformat.h b/src/gui/kernel/qpixelformat.h index a78a3b5ad3..6b2d6a6ac7 100644 --- a/src/gui/kernel/qpixelformat.h +++ b/src/gui/kernel/qpixelformat.h @@ -40,7 +40,7 @@ #ifndef QPIXELFORMAT_H #define QPIXELFORMAT_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatformclipboard.h b/src/gui/kernel/qplatformclipboard.h index c30e085d00..60733b0a9f 100644 --- a/src/gui/kernel/qplatformclipboard.h +++ b/src/gui/kernel/qplatformclipboard.h @@ -49,7 +49,7 @@ // source and binary incompatible with future versions of Qt. // -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_CLIPBOARD diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h index 52c93c87e3..f9c1607663 100644 --- a/src/gui/kernel/qplatformcursor.h +++ b/src/gui/kernel/qplatformcursor.h @@ -48,6 +48,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/QList> #include <QtGui/QImage> #include <QtGui/QMouseEvent> diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index fe4d167078..c36186b815 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -156,23 +156,33 @@ public: QString windowTitle; }; -QFontDialogOptions::QFontDialogOptions() : d(new QFontDialogOptionsPrivate) +QFontDialogOptions::QFontDialogOptions(QFontDialogOptionsPrivate *dd) + : d(dd) { } -QFontDialogOptions::QFontDialogOptions(const QFontDialogOptions &rhs) : d(rhs.d) +QFontDialogOptions::~QFontDialogOptions() { } -QFontDialogOptions &QFontDialogOptions::operator=(const QFontDialogOptions &rhs) +namespace { + struct FontDialogCombined : QFontDialogOptionsPrivate, QFontDialogOptions + { + FontDialogCombined() : QFontDialogOptionsPrivate(), QFontDialogOptions(this) {} + FontDialogCombined(const FontDialogCombined &other) + : QFontDialogOptionsPrivate(other), QFontDialogOptions(this) {} + }; +} + +// static +QSharedPointer<QFontDialogOptions> QFontDialogOptions::create() { - if (this != &rhs) - d = rhs.d; - return *this; + return QSharedPointer<FontDialogCombined>::create(); } -QFontDialogOptions::~QFontDialogOptions() +QSharedPointer<QFontDialogOptions> QFontDialogOptions::clone() const { + return QSharedPointer<FontDialogCombined>::create(*static_cast<const FontDialogCombined*>(this)); } QString QFontDialogOptions::windowTitle() const @@ -289,23 +299,33 @@ public: QString windowTitle; }; -QColorDialogOptions::QColorDialogOptions() : d(new QColorDialogOptionsPrivate) +QColorDialogOptions::QColorDialogOptions(QColorDialogOptionsPrivate *dd) + : d(dd) { } -QColorDialogOptions::QColorDialogOptions(const QColorDialogOptions &rhs) : d(rhs.d) +QColorDialogOptions::~QColorDialogOptions() { } -QColorDialogOptions &QColorDialogOptions::operator=(const QColorDialogOptions &rhs) +namespace { + struct ColorDialogCombined : QColorDialogOptionsPrivate, QColorDialogOptions + { + ColorDialogCombined() : QColorDialogOptionsPrivate(), QColorDialogOptions(this) {} + ColorDialogCombined(const ColorDialogCombined &other) + : QColorDialogOptionsPrivate(other), QColorDialogOptions(this) {} + }; +} + +// static +QSharedPointer<QColorDialogOptions> QColorDialogOptions::create() { - if (this != &rhs) - d = rhs.d; - return *this; + return QSharedPointer<ColorDialogCombined>::create(); } -QColorDialogOptions::~QColorDialogOptions() +QSharedPointer<QColorDialogOptions> QColorDialogOptions::clone() const { + return QSharedPointer<ColorDialogCombined>::create(*static_cast<const ColorDialogCombined*>(this)); } QString QColorDialogOptions::windowTitle() const @@ -436,23 +456,32 @@ public: QStringList supportedSchemes; }; -QFileDialogOptions::QFileDialogOptions() : d(new QFileDialogOptionsPrivate) +QFileDialogOptions::QFileDialogOptions(QFileDialogOptionsPrivate *dd) + : d(dd) { } -QFileDialogOptions::QFileDialogOptions(const QFileDialogOptions &rhs) : d(rhs.d) +QFileDialogOptions::~QFileDialogOptions() { } -QFileDialogOptions &QFileDialogOptions::operator=(const QFileDialogOptions &rhs) +namespace { + struct FileDialogCombined : QFileDialogOptionsPrivate, QFileDialogOptions + { + FileDialogCombined() : QFileDialogOptionsPrivate(), QFileDialogOptions(this) {} + FileDialogCombined(const FileDialogCombined &other) : QFileDialogOptionsPrivate(other), QFileDialogOptions(this) {} + }; +} + +// static +QSharedPointer<QFileDialogOptions> QFileDialogOptions::create() { - if (this != &rhs) - d = rhs.d; - return *this; + return QSharedPointer<FileDialogCombined>::create(); } -QFileDialogOptions::~QFileDialogOptions() +QSharedPointer<QFileDialogOptions> QFileDialogOptions::clone() const { + return QSharedPointer<FileDialogCombined>::create(*static_cast<const FileDialogCombined*>(this)); } QString QFileDialogOptions::windowTitle() const @@ -728,23 +757,33 @@ public: QPlatformDialogHelper::StandardButtons buttons; }; -QMessageDialogOptions::QMessageDialogOptions() : d(new QMessageDialogOptionsPrivate) +QMessageDialogOptions::QMessageDialogOptions(QMessageDialogOptionsPrivate *dd) + : d(dd) { } -QMessageDialogOptions::QMessageDialogOptions(const QMessageDialogOptions &rhs) : d(rhs.d) +QMessageDialogOptions::~QMessageDialogOptions() { } -QMessageDialogOptions &QMessageDialogOptions::operator=(const QMessageDialogOptions &rhs) +namespace { + struct MessageDialogCombined : QMessageDialogOptionsPrivate, QMessageDialogOptions + { + MessageDialogCombined() : QMessageDialogOptionsPrivate(), QMessageDialogOptions(this) {} + MessageDialogCombined(const MessageDialogCombined &other) + : QMessageDialogOptionsPrivate(other), QMessageDialogOptions(this) {} + }; +} + +// static +QSharedPointer<QMessageDialogOptions> QMessageDialogOptions::create() { - if (this != &rhs) - d = rhs.d; - return *this; + return QSharedPointer<MessageDialogCombined>::create(); } -QMessageDialogOptions::~QMessageDialogOptions() +QSharedPointer<QMessageDialogOptions> QMessageDialogOptions::clone() const { + return QSharedPointer<MessageDialogCombined>::create(*static_cast<const MessageDialogCombined*>(this)); } QString QMessageDialogOptions::windowTitle() const diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h index 825dcf293d..6caef070e2 100644 --- a/src/gui/kernel/qplatformdialoghelper.h +++ b/src/gui/kernel/qplatformdialoghelper.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/QtGlobal> #include <QtCore/QObject> #include <QtCore/QList> @@ -72,6 +73,8 @@ class QFontDialogOptionsPrivate; class QFileDialogOptionsPrivate; class QMessageDialogOptionsPrivate; +#define QPLATFORMDIALOGHELPERS_HAS_CREATE + class Q_GUI_EXPORT QPlatformDialogHelper : public QObject { Q_OBJECT @@ -176,6 +179,10 @@ QT_BEGIN_NAMESPACE class Q_GUI_EXPORT QColorDialogOptions { Q_GADGET + Q_DISABLE_COPY(QColorDialogOptions) +protected: + explicit QColorDialogOptions(QColorDialogOptionsPrivate *dd); + ~QColorDialogOptions(); public: enum ColorDialogOption { ShowAlphaChannel = 0x00000001, @@ -186,12 +193,8 @@ public: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) Q_FLAG(ColorDialogOptions) - QColorDialogOptions(); - QColorDialogOptions(const QColorDialogOptions &rhs); - QColorDialogOptions &operator=(const QColorDialogOptions &rhs); - ~QColorDialogOptions(); - - void swap(QColorDialogOptions &other) { qSwap(d, other.d); } + static QSharedPointer<QColorDialogOptions> create(); + QSharedPointer<QColorDialogOptions> clone() const; QString windowTitle() const; void setWindowTitle(const QString &); @@ -211,11 +214,9 @@ public: static void setStandardColor(int index, QRgb color); private: - QSharedDataPointer<QColorDialogOptionsPrivate> d; + QColorDialogOptionsPrivate *d; }; -Q_DECLARE_SHARED(QColorDialogOptions) - class Q_GUI_EXPORT QPlatformColorDialogHelper : public QPlatformDialogHelper { Q_OBJECT @@ -237,6 +238,11 @@ private: class Q_GUI_EXPORT QFontDialogOptions { Q_GADGET + Q_DISABLE_COPY(QFontDialogOptions) +protected: + explicit QFontDialogOptions(QFontDialogOptionsPrivate *dd); + ~QFontDialogOptions(); + public: enum FontDialogOption { NoButtons = 0x00000001, @@ -250,12 +256,8 @@ public: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) Q_FLAG(FontDialogOptions) - QFontDialogOptions(); - QFontDialogOptions(const QFontDialogOptions &rhs); - QFontDialogOptions &operator=(const QFontDialogOptions &rhs); - ~QFontDialogOptions(); - - void swap(QFontDialogOptions &other) { qSwap(d, other.d); } + static QSharedPointer<QFontDialogOptions> create(); + QSharedPointer<QFontDialogOptions> clone() const; QString windowTitle() const; void setWindowTitle(const QString &); @@ -266,11 +268,9 @@ public: FontDialogOptions options() const; private: - QSharedDataPointer<QFontDialogOptionsPrivate> d; + QFontDialogOptionsPrivate *d; }; -Q_DECLARE_SHARED(QFontDialogOptions) - class Q_GUI_EXPORT QPlatformFontDialogHelper : public QPlatformDialogHelper { Q_OBJECT @@ -292,6 +292,11 @@ private: class Q_GUI_EXPORT QFileDialogOptions { Q_GADGET + Q_DISABLE_COPY(QFileDialogOptions) +protected: + QFileDialogOptions(QFileDialogOptionsPrivate *dd); + ~QFileDialogOptions(); + public: enum ViewMode { Detail, List }; Q_ENUM(ViewMode) @@ -319,12 +324,8 @@ public: Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption) Q_FLAG(FileDialogOptions) - QFileDialogOptions(); - QFileDialogOptions(const QFileDialogOptions &rhs); - QFileDialogOptions &operator=(const QFileDialogOptions &rhs); - ~QFileDialogOptions(); - - void swap(QFileDialogOptions &other) { qSwap(d, other.d); } + static QSharedPointer<QFileDialogOptions> create(); + QSharedPointer<QFileDialogOptions> clone() const; QString windowTitle() const; void setWindowTitle(const QString &); @@ -383,11 +384,9 @@ public: static QString defaultNameFilterString(); private: - QSharedDataPointer<QFileDialogOptionsPrivate> d; + QFileDialogOptionsPrivate *d; }; -Q_DECLARE_SHARED(QFileDialogOptions) - class Q_GUI_EXPORT QPlatformFileDialogHelper : public QPlatformDialogHelper { Q_OBJECT @@ -423,17 +422,18 @@ private: class Q_GUI_EXPORT QMessageDialogOptions { Q_GADGET + Q_DISABLE_COPY(QMessageDialogOptions) +protected: + QMessageDialogOptions(QMessageDialogOptionsPrivate *dd); + ~QMessageDialogOptions(); + public: // Keep in sync with QMessageBox::Icon enum Icon { NoIcon, Information, Warning, Critical, Question }; Q_ENUM(Icon) - QMessageDialogOptions(); - QMessageDialogOptions(const QMessageDialogOptions &rhs); - QMessageDialogOptions &operator=(const QMessageDialogOptions &rhs); - ~QMessageDialogOptions(); - - void swap(QMessageDialogOptions &other) { qSwap(d, other.d); } + static QSharedPointer<QMessageDialogOptions> create(); + QSharedPointer<QMessageDialogOptions> clone() const; QString windowTitle() const; void setWindowTitle(const QString &); @@ -454,11 +454,9 @@ public: QPlatformDialogHelper::StandardButtons standardButtons() const; private: - QSharedDataPointer<QMessageDialogOptionsPrivate> d; + QMessageDialogOptionsPrivate *d; }; -Q_DECLARE_SHARED(QMessageDialogOptions) - class Q_GUI_EXPORT QPlatformMessageDialogHelper : public QPlatformDialogHelper { Q_OBJECT diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h index a9744a17ac..560f984a5b 100644 --- a/src/gui/kernel/qplatformdrag.h +++ b/src/gui/kernel/qplatformdrag.h @@ -49,7 +49,7 @@ // source and binary incompatible with future versions of Qt. // -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtGui/QPixmap> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatformgraphicsbuffer.h b/src/gui/kernel/qplatformgraphicsbuffer.h index 53fc551ad2..0aeef946e6 100644 --- a/src/gui/kernel/qplatformgraphicsbuffer.h +++ b/src/gui/kernel/qplatformgraphicsbuffer.h @@ -50,6 +50,7 @@ // +#include <QtGui/qtguiglobal.h> #include <QtCore/QSize> #include <QtCore/QRect> #include <QtGui/QPixelFormat> diff --git a/src/gui/kernel/qplatformgraphicsbufferhelper.h b/src/gui/kernel/qplatformgraphicsbufferhelper.h index 59fcd12fd0..5b7daff65a 100644 --- a/src/gui/kernel/qplatformgraphicsbufferhelper.h +++ b/src/gui/kernel/qplatformgraphicsbufferhelper.h @@ -40,6 +40,7 @@ #ifndef QPLATFORMGRAPHICSBUFFERHELPER_H #define QPLATFORMGRAPHICSBUFFERHELPER_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qpa/qplatformgraphicsbuffer.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatforminputcontext.h b/src/gui/kernel/qplatforminputcontext.h index 7afa6b82f2..26d40cd2c6 100644 --- a/src/gui/kernel/qplatforminputcontext.h +++ b/src/gui/kernel/qplatforminputcontext.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtGui/qinputmethod.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatforminputcontext_p.h b/src/gui/kernel/qplatforminputcontext_p.h index 14e9dda072..c4f4b97d03 100644 --- a/src/gui/kernel/qplatforminputcontext_p.h +++ b/src/gui/kernel/qplatforminputcontext_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <private/qobject_p.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatforminputcontextfactory_p.h b/src/gui/kernel/qplatforminputcontextfactory_p.h index 4106b2fedc..881421ce49 100644 --- a/src/gui/kernel/qplatforminputcontextfactory_p.h +++ b/src/gui/kernel/qplatforminputcontextfactory_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qstringlist.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatforminputcontextplugin_p.h b/src/gui/kernel/qplatforminputcontextplugin_p.h index 1bb0332ac7..3f45df922e 100644 --- a/src/gui/kernel/qplatforminputcontextplugin_p.h +++ b/src/gui/kernel/qplatforminputcontextplugin_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 3490e786a8..5bf0df67db 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -402,6 +402,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return true; case ItemViewActivateItemOnSingleClick: return QPlatformTheme::defaultThemeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick); + case UiEffects: + return QPlatformTheme::defaultThemeHint(QPlatformTheme::UiEffects); } return 0; diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 6ac98c20ce..22a834f0e1 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <qpa/qplatformscreen.h> #include <QtGui/qsurfaceformat.h> @@ -155,7 +156,8 @@ public: MousePressAndHoldInterval, TabFocusBehavior, ReplayMousePressOutsidePopup, - ItemViewActivateItemOnSingleClick + ItemViewActivateItemOnSingleClick, + UiEffects }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qplatformintegrationfactory_p.h b/src/gui/kernel/qplatformintegrationfactory_p.h index ea8c846557..22c77ce8bd 100644 --- a/src/gui/kernel/qplatformintegrationfactory_p.h +++ b/src/gui/kernel/qplatformintegrationfactory_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qstringlist.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatformintegrationplugin.h b/src/gui/kernel/qplatformintegrationplugin.h index 7d2a9b2a5f..f1136965b7 100644 --- a/src/gui/kernel/qplatformintegrationplugin.h +++ b/src/gui/kernel/qplatformintegrationplugin.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h index bd4f4d9beb..6eaabd3e08 100644 --- a/src/gui/kernel/qplatformmenu.h +++ b/src/gui/kernel/qplatformmenu.h @@ -49,7 +49,7 @@ // source and binary incompatible with future versions of Qt. // -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qpointer.h> #include <QtGui/QFont> #include <QtGui/QKeySequence> diff --git a/src/gui/kernel/qplatformnativeinterface.h b/src/gui/kernel/qplatformnativeinterface.h index f830221c70..95d6a03dbb 100644 --- a/src/gui/kernel/qplatformnativeinterface.h +++ b/src/gui/kernel/qplatformnativeinterface.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <QtCore/QObject> #include <QtCore/QVariant> diff --git a/src/gui/kernel/qplatformoffscreensurface.h b/src/gui/kernel/qplatformoffscreensurface.h index 77a8f63316..7f2e0d475b 100644 --- a/src/gui/kernel/qplatformoffscreensurface.h +++ b/src/gui/kernel/qplatformoffscreensurface.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include "qplatformsurface.h" #include <QtCore/qscopedpointer.h> diff --git a/src/gui/kernel/qplatformopenglcontext.h b/src/gui/kernel/qplatformopenglcontext.h index 1a38a5fed3..f307cc14f9 100644 --- a/src/gui/kernel/qplatformopenglcontext.h +++ b/src/gui/kernel/qplatformopenglcontext.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qnamespace.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h index cd300c34c8..030edea880 100644 --- a/src/gui/kernel/qplatformscreen.h +++ b/src/gui/kernel/qplatformscreen.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qmetatype.h> #include <QtCore/qnamespace.h> #include <QtCore/qcoreevent.h> diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h index aa31c4db25..d5dc7b471a 100644 --- a/src/gui/kernel/qplatformscreen_p.h +++ b/src/gui/kernel/qplatformscreen_p.h @@ -51,6 +51,8 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> + QT_BEGIN_NAMESPACE class QScreen; diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h index 52b8ce7854..339bbfde3f 100644 --- a/src/gui/kernel/qplatformservices.h +++ b/src/gui/kernel/qplatformservices.h @@ -49,7 +49,7 @@ // source and binary incompatible with future versions of Qt. // -#include <QtCore/QtGlobal> +#include <QtGui/qtguiglobal.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatformsessionmanager.h b/src/gui/kernel/qplatformsessionmanager.h index 98c364f7fe..ca7cab389b 100644 --- a/src/gui/kernel/qplatformsessionmanager.h +++ b/src/gui/kernel/qplatformsessionmanager.h @@ -51,6 +51,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qmetatype.h> #include <QtCore/qnamespace.h> diff --git a/src/gui/kernel/qplatformsharedgraphicscache.h b/src/gui/kernel/qplatformsharedgraphicscache.h index 6e0ba9151f..e11d2f41a9 100644 --- a/src/gui/kernel/qplatformsharedgraphicscache.h +++ b/src/gui/kernel/qplatformsharedgraphicscache.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtGui/qimage.h> diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h index 0bbe811803..5a1e4fe82d 100644 --- a/src/gui/kernel/qplatformsurface.h +++ b/src/gui/kernel/qplatformsurface.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qnamespace.h> #include <QtGui/qsurface.h> #include <QtGui/qsurfaceformat.h> diff --git a/src/gui/kernel/qplatformsystemtrayicon.h b/src/gui/kernel/qplatformsystemtrayicon.h index dcd7225180..c52dbfbd78 100644 --- a/src/gui/kernel/qplatformsystemtrayicon.h +++ b/src/gui/kernel/qplatformsystemtrayicon.h @@ -41,6 +41,7 @@ #ifndef QPLATFORMSYSTEMTRAYICON_H #define QPLATFORMSYSTEMTRAYICON_H +#include <QtGui/qtguiglobal.h> #include "QtCore/qobject.h" #ifndef QT_NO_SYSTEMTRAYICON diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 7f74959a60..d80ab8b597 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -44,6 +44,7 @@ #include <QtCore/QVariant> #include <QtCore/QStringList> #include <QtCore/qfileinfo.h> +#include <qicon.h> #include <qpalette.h> #include <qtextformat.h> #include <private/qiconloader_p.h> @@ -405,14 +406,22 @@ QPixmap QPlatformTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) co return QPixmap(); } -QPixmap QPlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, - QPlatformTheme::IconOptions iconOptions) const +/*! + \brief Return an icon for \a fileInfo, observing \a iconOptions. + + This function is queried by QFileIconProvider and similar classes to obtain + an icon for a file. If it does not return a non-null icon, fileIconPixmap() + is queried for a specific size. + + \since 5.8 +*/ + +QIcon QPlatformTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const { Q_UNUSED(fileInfo); - Q_UNUSED(size); Q_UNUSED(iconOptions); // TODO Should return QCommonStyle pixmaps? - return QPixmap(); + return QIcon(); } QVariant QPlatformTheme::themeHint(ThemeHint hint) const @@ -444,6 +453,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MousePressAndHoldInterval); case QPlatformTheme::ItemViewActivateItemOnSingleClick: return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ItemViewActivateItemOnSingleClick); + case QPlatformTheme::UiEffects: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects); default: return QPlatformTheme::defaultThemeHint(hint); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index c4c7482995..a8baca1967 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -49,12 +49,13 @@ // source and binary incompatible with future versions of Qt. // -#include <QtCore/QtGlobal> +#include <QtGui/qtguiglobal.h> #include <QtCore/QScopedPointer> #include <QtGui/QKeySequence> QT_BEGIN_NAMESPACE +class QIcon; class QIconEngine; class QMenu; class QMenuBar; @@ -270,7 +271,8 @@ public: AnimateComboUiEffect = 0x8, AnimateTooltipUiEffect = 0x10, FadeTooltipUiEffect = 0x20, - AnimateToolBoxUiEffect = 0x40 + AnimateToolBoxUiEffect = 0x40, + HoverEffect = 0x80 }; enum IconOption { @@ -300,9 +302,8 @@ public: virtual QVariant themeHint(ThemeHint hint) const; virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const; - virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, - QPlatformTheme::IconOptions iconOptions = 0) const; - + virtual QIcon fileIcon(const QFileInfo &fileInfo, + QPlatformTheme::IconOptions iconOptions = 0) const; virtual QIconEngine *createIconEngine(const QString &iconName) const; virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const; diff --git a/src/gui/kernel/qplatformtheme_p.h b/src/gui/kernel/qplatformtheme_p.h index 11f9e261ef..f2777c57b3 100644 --- a/src/gui/kernel/qplatformtheme_p.h +++ b/src/gui/kernel/qplatformtheme_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/QtGlobal> +#include <QtGui/private/qtguiglobal_p.h> #include "private/qkeysequence_p.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatformthemefactory_p.h b/src/gui/kernel/qplatformthemefactory_p.h index abd78d544d..3f77f03485 100644 --- a/src/gui/kernel/qplatformthemefactory_p.h +++ b/src/gui/kernel/qplatformthemefactory_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qstringlist.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qplatformthemeplugin.h b/src/gui/kernel/qplatformthemeplugin.h index 52aa09d1d5..7b56879940 100644 --- a/src/gui/kernel/qplatformthemeplugin.h +++ b/src/gui/kernel/qplatformthemeplugin.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index b2a19dd3d9..dcee4d2d84 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -48,6 +48,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qscopedpointer.h> #include <QtCore/qrect.h> #include <QtCore/qmargins.h> diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h index dc76adca86..62ecd61d9e 100644 --- a/src/gui/kernel/qplatformwindow_p.h +++ b/src/gui/kernel/qplatformwindow_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qrect.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qrasterwindow.h b/src/gui/kernel/qrasterwindow.h index 915aea598f..76312bcda2 100644 --- a/src/gui/kernel/qrasterwindow.h +++ b/src/gui/kernel/qrasterwindow.h @@ -40,6 +40,7 @@ #ifndef QRASTERWINDOW_H #define QRASTERWINDOW_H +#include <QtGui/qtguiglobal.h> #include <QtGui/QPaintDeviceWindow> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index af4e8f4760..98e35aff43 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -40,6 +40,7 @@ #ifndef QSCREEN_H #define QSCREEN_H +#include <QtGui/qtguiglobal.h> #include <QtCore/QList> #include <QtCore/QObject> #include <QtCore/QRect> diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h index 544c29a18f..f31658355b 100644 --- a/src/gui/kernel/qscreen_p.h +++ b/src/gui/kernel/qscreen_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qscreen.h> #include <qpa/qplatformscreen.h> #include "qhighdpiscaling_p.h" diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h index 54c278afbf..21100b25d9 100644 --- a/src/gui/kernel/qsessionmanager.h +++ b/src/gui/kernel/qsessionmanager.h @@ -40,6 +40,7 @@ #ifndef QSESSIONMANAGER_H #define QSESSIONMANAGER_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtGui/qwindowdefs.h> #include <QtCore/qstring.h> diff --git a/src/gui/kernel/qsessionmanager_p.h b/src/gui/kernel/qsessionmanager_p.h index 982fc801ff..954443430e 100644 --- a/src/gui/kernel/qsessionmanager_p.h +++ b/src/gui/kernel/qsessionmanager_p.h @@ -52,6 +52,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <private/qobject_p.h> #include <QtCore/qstring.h> #include <QtCore/qstringlist.h> diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h index 21cecba9e8..2c25ca7c76 100644 --- a/src/gui/kernel/qshapedpixmapdndwindow_p.h +++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/QRasterWindow> #include <QtGui/QPixmap> diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/gui/kernel/qshortcutmap_p.h index f513863e5b..8fc68229fb 100644 --- a/src/gui/kernel/qshortcutmap_p.h +++ b/src/gui/kernel/qshortcutmap_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qkeysequence.h" #include "QtCore/qvector.h" #include "QtCore/qscopedpointer.h" diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h index 8924b4d08f..0b8a0bc703 100644 --- a/src/gui/kernel/qsimpledrag_p.h +++ b/src/gui/kernel/qsimpledrag_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qpa/qplatformdrag.h> #include <QtCore/QObject> diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index ecc2886a04..7ccf1d86b0 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -77,6 +77,7 @@ public: , m_keyboardInputInterval(-1) , m_cursorFlashTime(-1) , m_tabFocusBehavior(-1) + , m_uiEffects(-1) {} int m_mouseDoubleClickInterval; @@ -86,6 +87,7 @@ public: int m_keyboardInputInterval; int m_cursorFlashTime; int m_tabFocusBehavior; + int m_uiEffects; }; /*! @@ -451,4 +453,34 @@ bool QStyleHints::singleClickActivation() const return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool(); } +/*! + \property QStyleHints::useHoverEffects + \brief \c true if UI elements should use hover effects. This is the + standard behavior on desktop platforms with a mouse pointer, whereas + on touch platforms the overhead of hover event delivery can be avoided. + + \since 5.8 +*/ +bool QStyleHints::useHoverEffects() const +{ + Q_D(const QStyleHints); + return (d->m_uiEffects >= 0 ? + d->m_uiEffects : + themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect; +} + +void QStyleHints::setUseHoverEffects(bool useHoverEffects) +{ + Q_D(QStyleHints); + if (d->m_uiEffects >= 0 && useHoverEffects == bool(d->m_uiEffects & QPlatformTheme::HoverEffect)) + return; + if (d->m_uiEffects == -1) + d->m_uiEffects = 0; + if (useHoverEffects) + d->m_uiEffects |= QPlatformTheme::HoverEffect; + else + d->m_uiEffects &= ~QPlatformTheme::HoverEffect; + emit useHoverEffectsChanged(useHoverEffects); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index 0b07e60579..fb55cc7ed6 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -40,6 +40,7 @@ #ifndef QSTYLEHINTS_H #define QSTYLEHINTS_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE @@ -69,6 +70,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject Q_PROPERTY(bool useRtlExtensions READ useRtlExtensions STORED false CONSTANT FINAL) Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL) Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL) + Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL) public: void setMouseDoubleClickInterval(int mouseDoubleClickInterval); @@ -95,6 +97,8 @@ public: Qt::TabFocusBehavior tabFocusBehavior() const; void setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior); bool singleClickActivation() const; + bool useHoverEffects() const; + void setUseHoverEffects(bool useHoverEffects); Q_SIGNALS: void cursorFlashTimeChanged(int cursorFlashTime); @@ -104,6 +108,7 @@ Q_SIGNALS: void startDragDistanceChanged(int startDragDistance); void startDragTimeChanged(int startDragTime); void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior); + void useHoverEffectsChanged(bool useHoverEffects); private: friend class QGuiApplication; diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h index 86b800a6db..d9ccdc096d 100644 --- a/src/gui/kernel/qsurface.h +++ b/src/gui/kernel/qsurface.h @@ -40,6 +40,7 @@ #ifndef QSURFACE_H #define QSURFACE_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qnamespace.h> #include <QtGui/qsurfaceformat.h> #include <QtCore/qmetatype.h> diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h index 9e8bcc91a7..b4e3f68b97 100644 --- a/src/gui/kernel/qsurfaceformat.h +++ b/src/gui/kernel/qsurfaceformat.h @@ -39,7 +39,7 @@ #ifndef QSURFACEFORMAT_H #define QSURFACEFORMAT_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qpair.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qt_gui_pch.h b/src/gui/kernel/qt_gui_pch.h index 8d1455f6c8..db12ba1078 100644 --- a/src/gui/kernel/qt_gui_pch.h +++ b/src/gui/kernel/qt_gui_pch.h @@ -47,7 +47,7 @@ // from corelib/global/qt_pch.h #if defined __cplusplus -#include <qglobal.h> +#include <qtguiglobal.h> #ifdef Q_OS_WIN diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/kernel/qtguiglobal.h index 38e67761b1..f0e64fbc53 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/kernel/qtguiglobal.h @@ -37,36 +37,23 @@ ** ****************************************************************************/ -#include <qdebug.h> -#include "qnativeimage_p.h" -#include <qpa/qplatformscreen.h> -#include "private/qguiapplication_p.h" -#include "qscreen.h" - -#include "private/qpaintengine_raster_p.h" +#ifndef QTGUIGLOBAL_H +#define QTGUIGLOBAL_H +#include <QtCore/qglobal.h> QT_BEGIN_NAMESPACE - -QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWindow *) - : image(width, height, format) -{ - -} - - -QNativeImage::~QNativeImage() -{ -} - -QImage::Format QNativeImage::systemFormat() -{ - if (!QGuiApplication::primaryScreen()) - return QImage::Format_Invalid; - return QGuiApplication::primaryScreen()->handle()->format(); -} - +#ifndef QT_STATIC +# if defined(QT_BUILD_GUI_LIB) +# define Q_GUI_EXPORT Q_DECL_EXPORT +# else +# define Q_GUI_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_GUI_EXPORT +#endif QT_END_NAMESPACE +#endif // QTGUIGLOBAL_H diff --git a/src/gui/image/qnativeimage_p.h b/src/gui/kernel/qtguiglobal_p.h index 2398a6e2ce..fd04b8ff95 100644 --- a/src/gui/image/qnativeimage_p.h +++ b/src/gui/kernel/qtguiglobal_p.h @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#ifndef QNATIVEIMAGE_P_H -#define QNATIVEIMAGE_P_H +#ifndef QTGUIGLOBAL_P_H +#define QTGUIGLOBAL_P_H // // W A R N I N G @@ -51,34 +51,7 @@ // We mean it. // -#include "qimage.h" +#include <QtGui/qtguiglobal.h> +#include <QtCore/private/qglobal_p.h> - -QT_BEGIN_NAMESPACE - -class QWindow; - -class QNativeImage -{ -public: - QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer = false, QWindow *window = 0); - ~QNativeImage(); - - inline int width() const; - inline int height() const; - - QImage image; - - static QImage::Format systemFormat(); - - -private: - Q_DISABLE_COPY(QNativeImage) -}; - -inline int QNativeImage::width() const { return image.width(); } -inline int QNativeImage::height() const { return image.height(); } - -QT_END_NAMESPACE - -#endif // QNATIVEIMAGE_P_H +#endif // QTGUIGLOBAL_P_H diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h index 243f53d4ca..0fb24e47bf 100644 --- a/src/gui/kernel/qtouchdevice.h +++ b/src/gui/kernel/qtouchdevice.h @@ -40,6 +40,7 @@ #ifndef QTOUCHDEVICE_H #define QTOUCHDEVICE_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h index b42b0507d9..203d9fca74 100644 --- a/src/gui/kernel/qtouchdevice_p.h +++ b/src/gui/kernel/qtouchdevice_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qtouchdevice.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 06bd788262..bf25cf64c9 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -40,6 +40,7 @@ #ifndef QWINDOW_H #define QWINDOW_H +#include <QtGui/qtguiglobal.h> #include <QtCore/QObject> #include <QtCore/QEvent> #include <QtCore/QMargins> diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index ccd14f66ae..6d6d5a22ee 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qscreen.h> #include <QtGui/qwindow.h> #include <qpa/qplatformwindow.h> diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h index fb6b1831af..b4f3ed4712 100644 --- a/src/gui/kernel/qwindowdefs.h +++ b/src/gui/kernel/qwindowdefs.h @@ -40,7 +40,7 @@ #ifndef QWINDOWDEFS_H #define QWINDOWDEFS_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qobjectdefs.h> #include <QtCore/qnamespace.h> diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h index d1000856bb..b546fe305e 100644 --- a/src/gui/kernel/qwindowdefs_win.h +++ b/src/gui/kernel/qwindowdefs_win.h @@ -40,7 +40,7 @@ #ifndef QWINDOWDEFS_WIN_H #define QWINDOWDEFS_WIN_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> QT_BEGIN_NAMESPACE @@ -111,13 +111,4 @@ typedef long HRESULT; typedef struct tagMSG MSG; -QT_BEGIN_NAMESPACE - -Q_CORE_EXPORT HINSTANCE qWinAppInst(); -Q_CORE_EXPORT HINSTANCE qWinAppPrevInst(); -Q_CORE_EXPORT int qWinAppCmdShow(); -Q_WIDGETS_EXPORT HDC qt_win_display_dc(); - -QT_END_NAMESPACE - #endif // QWINDOWDEFS_WIN_H diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 1b7edb1278..73140b4f6f 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -474,7 +474,10 @@ QList<QTouchEvent::TouchPoint> QList<QWindowSystemInterface::TouchPoint>::const_iterator end = points.constEnd(); while (point != end) { p.setId(point->id); + if (point->uniqueId >= 0) + p.setUniqueId(point->uniqueId); p.setPressure(point->pressure); + p.setRotation(point->rotation); states |= point->state; p.setState(point->state); @@ -922,6 +925,17 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int #endif } +namespace QTest +{ + Q_GUI_EXPORT QTouchDevice * createTouchDevice(QTouchDevice::DeviceType devType = QTouchDevice::TouchScreen) + { + QTouchDevice *ret = new QTouchDevice(); + ret->setType(devType); + QWindowSystemInterface::registerTouchDevice(ret); + return ret; + } +} + Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device, const QList<QTouchEvent::TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 6bf87439b9..e7e47ac6d9 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -48,6 +48,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/QTime> #include <QtGui/qwindowdefs.h> #include <QtCore/QEvent> @@ -117,11 +118,14 @@ public: static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier); struct TouchPoint { - TouchPoint() : id(0), pressure(0), state(Qt::TouchPointStationary) { } + TouchPoint() : id(0), uniqueId(-1), pressure(0), rotation(0), state(Qt::TouchPointStationary) { } int id; // for application use + qint64 uniqueId; // for TUIO: object/token ID; otherwise empty + // TODO for TUIO 2.0: add registerPointerUniqueID(QPointerUniqueId) QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1) QRectF area; // the touched area, centered at position in screen coordinates qreal pressure; // 0 to 1 + qreal rotation; // 0 means pointing straight up; 0 if unknown (like QTabletEvent::rotation) Qt::TouchPointState state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released} QVector2D velocity; // in screen coordinate system, pixels / seconds QTouchEvent::TouchPoint::InfoFlags flags; diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index b218c1c68c..bdbf191cbd 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -50,6 +50,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qwindowsysteminterface.h" #include <QElapsedTimer> diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h index 5e22fa6730..9a1ab54124 100644 --- a/src/gui/math3d/qgenericmatrix.h +++ b/src/gui/math3d/qgenericmatrix.h @@ -40,6 +40,7 @@ #ifndef QGENERICMATRIX_H #define QGENERICMATRIX_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qmetatype.h> #include <QtCore/qdebug.h> #include <QtCore/qdatastream.h> diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index bdcf4555d7..19540308a1 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -40,6 +40,7 @@ #ifndef QMATRIX4X4_H #define QMATRIX4X4_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qvector3d.h> #include <QtGui/qvector4d.h> #include <QtGui/qquaternion.h> diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index d4c91c430a..21b051e08e 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -40,6 +40,7 @@ #ifndef QQUATERNION_H #define QQUATERNION_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qgenericmatrix.h> #include <QtGui/qvector3d.h> #include <QtGui/qvector4d.h> diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h index 697360bd5b..d2724c9498 100644 --- a/src/gui/math3d/qvector2d.h +++ b/src/gui/math3d/qvector2d.h @@ -40,6 +40,7 @@ #ifndef QVECTOR2D_H #define QVECTOR2D_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qpoint.h> #include <QtCore/qmetatype.h> diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h index c3b335cf7c..c1d881a735 100644 --- a/src/gui/math3d/qvector3d.h +++ b/src/gui/math3d/qvector3d.h @@ -40,6 +40,7 @@ #ifndef QVECTOR3D_H #define QVECTOR3D_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qpoint.h> #include <QtCore/qmetatype.h> diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h index 28a438f3ac..9387e8d187 100644 --- a/src/gui/math3d/qvector4d.h +++ b/src/gui/math3d/qvector4d.h @@ -40,6 +40,7 @@ #ifndef QVECTOR4D_H #define QVECTOR4D_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qpoint.h> #include <QtCore/qmetatype.h> diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index b13f258fda..dfaf3042bc 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -32,7 +32,7 @@ contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) { opengl/qopenglversionfunctionsfactory_p.h \ opengl/qopenglvertexarrayobject.h \ opengl/qopengldebug.h \ - opengl/qopengltextureblitter_p.h \ + opengl/qopengltextureblitter.h \ opengl/qopengltexture.h \ opengl/qopengltexture_p.h \ opengl/qopengltexturehelper_p.h \ diff --git a/src/gui/opengl/qopengl.h b/src/gui/opengl/qopengl.h index 5f9d78b780..e2408d0047 100644 --- a/src/gui/opengl/qopengl.h +++ b/src/gui/opengl/qopengl.h @@ -40,7 +40,7 @@ #ifndef QOPENGL_H #define QOPENGL_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL @@ -119,10 +119,8 @@ typedef char GLchar; #else // non-ES2 platforms # if defined(Q_OS_MAC) # include <OpenGL/gl.h> -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 -# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED -# include <OpenGL/gl3.h> -# endif +# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED +# include <OpenGL/gl3.h> # include <OpenGL/glext.h> # else # define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h @@ -131,16 +129,11 @@ typedef char GLchar; # endif // Q_OS_MAC #endif // QT_OPENGL_ES_2 -// Desktops, apart from Mac OS X prior to 10.7 can support OpenGL 3. -// Desktops, apart from Mac OS X prior to 10.9 can support OpenGL 4. +// Desktops can support OpenGL 4. #if !defined(QT_OPENGL_ES_2) -# if !defined(Q_OS_MAC) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) -# define QT_OPENGL_3 -# define QT_OPENGL_3_2 -# endif -# if !defined(Q_OS_MAC) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9) -# define QT_OPENGL_4 -# endif +#define QT_OPENGL_3 +#define QT_OPENGL_3_2 +#define QT_OPENGL_4 # if !defined(Q_OS_MAC) # define QT_OPENGL_4_3 # endif diff --git a/src/gui/opengl/qopengl2pexvertexarray_p.h b/src/gui/opengl/qopengl2pexvertexarray_p.h index 22397391dd..5dc060ff3d 100644 --- a/src/gui/opengl/qopengl2pexvertexarray_p.h +++ b/src/gui/opengl/qopengl2pexvertexarray_p.h @@ -51,6 +51,7 @@ #ifndef QOPENGL2PEXVERTEXARRAY_P_H #define QOPENGL2PEXVERTEXARRAY_P_H +#include <QtGui/private/qtguiglobal_p.h> #include <QRectF> #include <private/qdatabuffer_p.h> diff --git a/src/gui/opengl/qopengl_p.h b/src/gui/opengl/qopengl_p.h index 042b903625..cda062eacf 100644 --- a/src/gui/opengl/qopengl_p.h +++ b/src/gui/opengl/qopengl_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qopengl.h> #include <private/qopenglcontext_p.h> #include <QtCore/qset.h> diff --git a/src/gui/opengl/qopenglbuffer.h b/src/gui/opengl/qopenglbuffer.h index bd947bc1d8..f2dfec3bb4 100644 --- a/src/gui/opengl/qopenglbuffer.h +++ b/src/gui/opengl/qopenglbuffer.h @@ -40,7 +40,7 @@ #ifndef QOPENGLBUFFER_H #define QOPENGLBUFFER_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopenglcustomshaderstage_p.h b/src/gui/opengl/qopenglcustomshaderstage_p.h index 2342991e5e..f4a71af88e 100644 --- a/src/gui/opengl/qopenglcustomshaderstage_p.h +++ b/src/gui/opengl/qopenglcustomshaderstage_p.h @@ -51,8 +51,8 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QOpenGLShaderProgram> -#include <QtGlobal> QT_BEGIN_NAMESPACE diff --git a/src/gui/opengl/qopengldebug.h b/src/gui/opengl/qopengldebug.h index 90e12fb8b1..74b2731f7e 100644 --- a/src/gui/opengl/qopengldebug.h +++ b/src/gui/opengl/qopengldebug.h @@ -40,7 +40,7 @@ #ifndef QOPENGLDEBUG_H #define QOPENGLDEBUG_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopenglengineshadermanager.cpp b/src/gui/opengl/qopenglengineshadermanager.cpp index 4e3d14ba37..1d3e47f93b 100644 --- a/src/gui/opengl/qopenglengineshadermanager.cpp +++ b/src/gui/opengl/qopenglengineshadermanager.cpp @@ -390,7 +390,7 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO fragShader->setObjectName(QString::fromLatin1(description)); #endif if (!fragShader->compileSourceCode(fragSource)) { - qWarning() << "Warning:" << description << "failed to compile!"; + qWarning("Warning: \"%s\" failed to compile!", description.constData()); break; } @@ -405,7 +405,7 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO vertexShader->setObjectName(QString::fromLatin1(description)); #endif if (!vertexShader->compileSourceCode(vertexSource)) { - qWarning() << "Warning:" << description << "failed to compile!"; + qWarning("Warning: \"%s\" failed to compile!", description.constData()); break; } diff --git a/src/gui/opengl/qopenglengineshadermanager_p.h b/src/gui/opengl/qopenglengineshadermanager_p.h index a5e190a48d..23b2ccf486 100644 --- a/src/gui/opengl/qopenglengineshadermanager_p.h +++ b/src/gui/opengl/qopenglengineshadermanager_p.h @@ -220,6 +220,7 @@ #ifndef QOPENGLENGINE_SHADER_MANAGER_H #define QOPENGLENGINE_SHADER_MANAGER_H +#include <QtGui/private/qtguiglobal_p.h> #include <QOpenGLShader> #include <QOpenGLShaderProgram> #include <QPainter> diff --git a/src/gui/opengl/qopenglengineshadersource_p.h b/src/gui/opengl/qopenglengineshadersource_p.h index 876d2775d3..1e88ac63b5 100644 --- a/src/gui/opengl/qopenglengineshadersource_p.h +++ b/src/gui/opengl/qopenglengineshadersource_p.h @@ -52,6 +52,7 @@ #ifndef QOPENGL_ENGINE_SHADER_SOURCE_H #define QOPENGL_ENGINE_SHADER_SOURCE_H +#include <QtGui/private/qtguiglobal_p.h> #include "qopenglengineshadermanager_p.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h index 894b6f2dc6..a5f1a2cc88 100644 --- a/src/gui/opengl/qopenglextensions_p.h +++ b/src/gui/opengl/qopenglextensions_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qopenglextrafunctions.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/opengl/qopenglextrafunctions.h b/src/gui/opengl/qopenglextrafunctions.h index aa29d685bc..1b36068588 100644 --- a/src/gui/opengl/qopenglextrafunctions.h +++ b/src/gui/opengl/qopenglextrafunctions.h @@ -40,7 +40,7 @@ #ifndef QOPENGLEXTRAFUNCTIONS_H #define QOPENGLEXTRAFUNCTIONS_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index b6e8855d46..1ccd78d2ed 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -856,10 +856,8 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, GLenum tar \sa size(), texture() */ QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, GLenum target) - : d_ptr(new QOpenGLFramebufferObjectPrivate) + : QOpenGLFramebufferObject(QSize(width, height), target) { - Q_D(QOpenGLFramebufferObject); - d->init(this, QSize(width, height), NoAttachment, target, effectiveInternalFormat(0)); } /*! \overload @@ -883,11 +881,8 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, const QOpe */ QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, const QOpenGLFramebufferObjectFormat &format) - : d_ptr(new QOpenGLFramebufferObjectPrivate) + : QOpenGLFramebufferObject(QSize(width, height), format) { - Q_D(QOpenGLFramebufferObject); - d->init(this, QSize(width, height), format.attachment(), format.textureTarget(), - format.internalTextureFormat(), format.samples(), format.mipmap()); } /*! \overload diff --git a/src/gui/opengl/qopenglframebufferobject.h b/src/gui/opengl/qopenglframebufferobject.h index b22726cafb..b9e61e9ee4 100644 --- a/src/gui/opengl/qopenglframebufferobject.h +++ b/src/gui/opengl/qopenglframebufferobject.h @@ -40,7 +40,7 @@ #ifndef QOPENGLFRAMEBUFFEROBJECT_H #define QOPENGLFRAMEBUFFEROBJECT_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopenglframebufferobject_p.h b/src/gui/opengl/qopenglframebufferobject_p.h index c677b5e344..b6e332fef1 100644 --- a/src/gui/opengl/qopenglframebufferobject_p.h +++ b/src/gui/opengl/qopenglframebufferobject_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qopenglframebufferobject.h> #include <private/qopenglcontext_p.h> #include <private/qopenglextensions_p.h> diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h index f6cd0e553e..aad48571b3 100644 --- a/src/gui/opengl/qopenglfunctions.h +++ b/src/gui/opengl/qopenglfunctions.h @@ -40,7 +40,7 @@ #ifndef QOPENGLFUNCTIONS_H #define QOPENGLFUNCTIONS_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopenglfunctions_1_0.cpp b/src/gui/opengl/qopenglfunctions_1_0.cpp index 9d5a76380a..4235c9a339 100644 --- a/src/gui/opengl/qopenglfunctions_1_0.cpp +++ b/src/gui/opengl/qopenglfunctions_1_0.cpp @@ -74,12 +74,14 @@ QOpenGLFunctions_1_0::QOpenGLFunctions_1_0() QOpenGLFunctions_1_0::~QOpenGLFunctions_1_0() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } } bool QOpenGLFunctions_1_0::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_1_0.h b/src/gui/opengl/qopenglfunctions_1_0.h index 825a6255a3..8284604086 100644 --- a/src/gui/opengl/qopenglfunctions_1_0.h +++ b/src/gui/opengl/qopenglfunctions_1_0.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_1_0_H #define QOPENGLVERSIONFUNCTIONS_1_0_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_1_1.cpp b/src/gui/opengl/qopenglfunctions_1_1.cpp index 57385f1927..7d09bb40c1 100644 --- a/src/gui/opengl/qopenglfunctions_1_1.cpp +++ b/src/gui/opengl/qopenglfunctions_1_1.cpp @@ -76,18 +76,22 @@ QOpenGLFunctions_1_1::QOpenGLFunctions_1_1() QOpenGLFunctions_1_1::~QOpenGLFunctions_1_1() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } } bool QOpenGLFunctions_1_1::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_1_1.h b/src/gui/opengl/qopenglfunctions_1_1.h index f312258f00..052d3e93bd 100644 --- a/src/gui/opengl/qopenglfunctions_1_1.h +++ b/src/gui/opengl/qopenglfunctions_1_1.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_1_1_H #define QOPENGLVERSIONFUNCTIONS_1_1_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_1_2.cpp b/src/gui/opengl/qopenglfunctions_1_2.cpp index 9eaa13862d..94a9d64660 100644 --- a/src/gui/opengl/qopenglfunctions_1_2.cpp +++ b/src/gui/opengl/qopenglfunctions_1_2.cpp @@ -78,24 +78,30 @@ QOpenGLFunctions_1_2::QOpenGLFunctions_1_2() QOpenGLFunctions_1_2::~QOpenGLFunctions_1_2() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } } bool QOpenGLFunctions_1_2::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_1_2.h b/src/gui/opengl/qopenglfunctions_1_2.h index fd4e7f74f9..6b36500a79 100644 --- a/src/gui/opengl/qopenglfunctions_1_2.h +++ b/src/gui/opengl/qopenglfunctions_1_2.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_1_2_H #define QOPENGLVERSIONFUNCTIONS_1_2_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_1_3.cpp b/src/gui/opengl/qopenglfunctions_1_3.cpp index 6211997302..972ef9ff70 100644 --- a/src/gui/opengl/qopenglfunctions_1_3.cpp +++ b/src/gui/opengl/qopenglfunctions_1_3.cpp @@ -80,30 +80,38 @@ QOpenGLFunctions_1_3::QOpenGLFunctions_1_3() QOpenGLFunctions_1_3::~QOpenGLFunctions_1_3() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } } bool QOpenGLFunctions_1_3::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_1_3.h b/src/gui/opengl/qopenglfunctions_1_3.h index a8509c46c5..3ed5851d5d 100644 --- a/src/gui/opengl/qopenglfunctions_1_3.h +++ b/src/gui/opengl/qopenglfunctions_1_3.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_1_3_H #define QOPENGLVERSIONFUNCTIONS_1_3_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_1_4.cpp b/src/gui/opengl/qopenglfunctions_1_4.cpp index 5ff2c24014..4b78253301 100644 --- a/src/gui/opengl/qopenglfunctions_1_4.cpp +++ b/src/gui/opengl/qopenglfunctions_1_4.cpp @@ -82,36 +82,46 @@ QOpenGLFunctions_1_4::QOpenGLFunctions_1_4() QOpenGLFunctions_1_4::~QOpenGLFunctions_1_4() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } } bool QOpenGLFunctions_1_4::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_1_4.h b/src/gui/opengl/qopenglfunctions_1_4.h index eeb99dbb1b..849fad6744 100644 --- a/src/gui/opengl/qopenglfunctions_1_4.h +++ b/src/gui/opengl/qopenglfunctions_1_4.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_1_4_H #define QOPENGLVERSIONFUNCTIONS_1_4_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_1_5.cpp b/src/gui/opengl/qopenglfunctions_1_5.cpp index d07f1decec..2a0820d0cb 100644 --- a/src/gui/opengl/qopenglfunctions_1_5.cpp +++ b/src/gui/opengl/qopenglfunctions_1_5.cpp @@ -83,39 +83,50 @@ QOpenGLFunctions_1_5::QOpenGLFunctions_1_5() QOpenGLFunctions_1_5::~QOpenGLFunctions_1_5() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } } bool QOpenGLFunctions_1_5::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_1_5.h b/src/gui/opengl/qopenglfunctions_1_5.h index d5f23c146b..18914a8957 100644 --- a/src/gui/opengl/qopenglfunctions_1_5.h +++ b/src/gui/opengl/qopenglfunctions_1_5.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_1_5_H #define QOPENGLVERSIONFUNCTIONS_1_5_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_2_0.cpp b/src/gui/opengl/qopenglfunctions_2_0.cpp index b7dc8ef458..c175b13c5b 100644 --- a/src/gui/opengl/qopenglfunctions_2_0.cpp +++ b/src/gui/opengl/qopenglfunctions_2_0.cpp @@ -85,42 +85,54 @@ QOpenGLFunctions_2_0::QOpenGLFunctions_2_0() QOpenGLFunctions_2_0::~QOpenGLFunctions_2_0() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } } bool QOpenGLFunctions_2_0::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_2_0.h b/src/gui/opengl/qopenglfunctions_2_0.h index 81b7274a93..74a91e0ff0 100644 --- a/src/gui/opengl/qopenglfunctions_2_0.h +++ b/src/gui/opengl/qopenglfunctions_2_0.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_2_0_H #define QOPENGLVERSIONFUNCTIONS_2_0_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_2_1.cpp b/src/gui/opengl/qopenglfunctions_2_1.cpp index e756685d10..4e77efd121 100644 --- a/src/gui/opengl/qopenglfunctions_2_1.cpp +++ b/src/gui/opengl/qopenglfunctions_2_1.cpp @@ -86,45 +86,58 @@ QOpenGLFunctions_2_1::QOpenGLFunctions_2_1() QOpenGLFunctions_2_1::~QOpenGLFunctions_2_1() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } } bool QOpenGLFunctions_2_1::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_2_1.h b/src/gui/opengl/qopenglfunctions_2_1.h index 7bac5af9da..e9212640f7 100644 --- a/src/gui/opengl/qopenglfunctions_2_1.h +++ b/src/gui/opengl/qopenglfunctions_2_1.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_2_1_H #define QOPENGLVERSIONFUNCTIONS_2_1_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_3_0.cpp b/src/gui/opengl/qopenglfunctions_3_0.cpp index ee7f92855d..09e3ad09ef 100644 --- a/src/gui/opengl/qopenglfunctions_3_0.cpp +++ b/src/gui/opengl/qopenglfunctions_3_0.cpp @@ -88,48 +88,62 @@ QOpenGLFunctions_3_0::QOpenGLFunctions_3_0() QOpenGLFunctions_3_0::~QOpenGLFunctions_3_0() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } } bool QOpenGLFunctions_3_0::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_3_0.h b/src/gui/opengl/qopenglfunctions_3_0.h index da8d5ec5ff..1082d869d1 100644 --- a/src/gui/opengl/qopenglfunctions_3_0.h +++ b/src/gui/opengl/qopenglfunctions_3_0.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_3_0_H #define QOPENGLVERSIONFUNCTIONS_3_0_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_3_1.cpp b/src/gui/opengl/qopenglfunctions_3_1.cpp index a459ddf244..9328f5ca89 100644 --- a/src/gui/opengl/qopenglfunctions_3_1.cpp +++ b/src/gui/opengl/qopenglfunctions_3_1.cpp @@ -82,36 +82,46 @@ QOpenGLFunctions_3_1::QOpenGLFunctions_3_1() QOpenGLFunctions_3_1::~QOpenGLFunctions_3_1() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); + Q_ASSERT(d_3_1_Core->refs.load()); + } } bool QOpenGLFunctions_3_1::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_3_1.h b/src/gui/opengl/qopenglfunctions_3_1.h index d5957381e9..2691dd29e7 100644 --- a/src/gui/opengl/qopenglfunctions_3_1.h +++ b/src/gui/opengl/qopenglfunctions_3_1.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_3_1_H #define QOPENGLVERSIONFUNCTIONS_3_1_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp b/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp index 09402db09a..b90a123bfe 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp @@ -90,54 +90,70 @@ QOpenGLFunctions_3_2_Compatibility::QOpenGLFunctions_3_2_Compatibility() QOpenGLFunctions_3_2_Compatibility::~QOpenGLFunctions_3_2_Compatibility() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } } bool QOpenGLFunctions_3_2_Compatibility::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_3_2_compatibility.h b/src/gui/opengl/qopenglfunctions_3_2_compatibility.h index 44fa6759e5..9f34190721 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_compatibility.h +++ b/src/gui/opengl/qopenglfunctions_3_2_compatibility.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_3_2_COMPATIBILITY_H #define QOPENGLVERSIONFUNCTIONS_3_2_COMPATIBILITY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_3_2_core.cpp b/src/gui/opengl/qopenglfunctions_3_2_core.cpp index 177dc9e25d..02c0c78b01 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_core.cpp +++ b/src/gui/opengl/qopenglfunctions_3_2_core.cpp @@ -83,39 +83,50 @@ QOpenGLFunctions_3_2_Core::QOpenGLFunctions_3_2_Core() QOpenGLFunctions_3_2_Core::~QOpenGLFunctions_3_2_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); + Q_ASSERT(d_3_2_Core->refs.load()); + } } bool QOpenGLFunctions_3_2_Core::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_3_2_core.h b/src/gui/opengl/qopenglfunctions_3_2_core.h index 36f959c04b..2d5ee14bee 100644 --- a/src/gui/opengl/qopenglfunctions_3_2_core.h +++ b/src/gui/opengl/qopenglfunctions_3_2_core.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_3_2_CORE_H #define QOPENGLVERSIONFUNCTIONS_3_2_CORE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp b/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp index 110a49ea53..c585f0fc7c 100644 --- a/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp @@ -91,60 +91,78 @@ QOpenGLFunctions_3_3_Compatibility::QOpenGLFunctions_3_3_Compatibility() QOpenGLFunctions_3_3_Compatibility::~QOpenGLFunctions_3_3_Compatibility() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); - if (d_3_3_Deprecated) + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } + if (d_3_3_Deprecated) { d_3_3_Deprecated->refs.deref(); - Q_ASSERT(d_3_3_Deprecated->refs.load()); + Q_ASSERT(d_3_3_Deprecated->refs.load()); + } } bool QOpenGLFunctions_3_3_Compatibility::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_3_3_compatibility.h b/src/gui/opengl/qopenglfunctions_3_3_compatibility.h index 126cc16858..a5c0cab63c 100644 --- a/src/gui/opengl/qopenglfunctions_3_3_compatibility.h +++ b/src/gui/opengl/qopenglfunctions_3_3_compatibility.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_3_3_COMPATIBILITY_H #define QOPENGLVERSIONFUNCTIONS_3_3_COMPATIBILITY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_3_3_core.cpp b/src/gui/opengl/qopenglfunctions_3_3_core.cpp index 2e706724d9..7779d92b6a 100644 --- a/src/gui/opengl/qopenglfunctions_3_3_core.cpp +++ b/src/gui/opengl/qopenglfunctions_3_3_core.cpp @@ -84,42 +84,54 @@ QOpenGLFunctions_3_3_Core::QOpenGLFunctions_3_3_Core() QOpenGLFunctions_3_3_Core::~QOpenGLFunctions_3_3_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); + Q_ASSERT(d_3_3_Core->refs.load()); + } } bool QOpenGLFunctions_3_3_Core::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_3_3_core.h b/src/gui/opengl/qopenglfunctions_3_3_core.h index 15a62802ab..4f0132d959 100644 --- a/src/gui/opengl/qopenglfunctions_3_3_core.h +++ b/src/gui/opengl/qopenglfunctions_3_3_core.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_3_3_CORE_H #define QOPENGLVERSIONFUNCTIONS_3_3_CORE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp index 14fb168c94..b5c423ef0c 100644 --- a/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp @@ -92,63 +92,82 @@ QOpenGLFunctions_4_0_Compatibility::QOpenGLFunctions_4_0_Compatibility() QOpenGLFunctions_4_0_Compatibility::~QOpenGLFunctions_4_0_Compatibility() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); - if (d_3_3_Deprecated) + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } + if (d_3_3_Deprecated) { d_3_3_Deprecated->refs.deref(); - Q_ASSERT(d_3_3_Deprecated->refs.load()); + Q_ASSERT(d_3_3_Deprecated->refs.load()); + } } bool QOpenGLFunctions_4_0_Compatibility::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_0_compatibility.h b/src/gui/opengl/qopenglfunctions_4_0_compatibility.h index 9ca6eb8a36..1fa5e8a361 100644 --- a/src/gui/opengl/qopenglfunctions_4_0_compatibility.h +++ b/src/gui/opengl/qopenglfunctions_4_0_compatibility.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_0_COMPATIBILITY_H #define QOPENGLVERSIONFUNCTIONS_4_0_COMPATIBILITY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_0_core.cpp b/src/gui/opengl/qopenglfunctions_4_0_core.cpp index 6dc94153c8..4e4e8cc547 100644 --- a/src/gui/opengl/qopenglfunctions_4_0_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_0_core.cpp @@ -85,45 +85,58 @@ QOpenGLFunctions_4_0_Core::QOpenGLFunctions_4_0_Core() QOpenGLFunctions_4_0_Core::~QOpenGLFunctions_4_0_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); + Q_ASSERT(d_4_0_Core->refs.load()); + } } bool QOpenGLFunctions_4_0_Core::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_0_core.h b/src/gui/opengl/qopenglfunctions_4_0_core.h index c3e1e9ce5a..8fd2af2d04 100644 --- a/src/gui/opengl/qopenglfunctions_4_0_core.h +++ b/src/gui/opengl/qopenglfunctions_4_0_core.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_0_CORE_H #define QOPENGLVERSIONFUNCTIONS_4_0_CORE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp index 293409ddef..72c60c74b7 100644 --- a/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp @@ -93,66 +93,86 @@ QOpenGLFunctions_4_1_Compatibility::QOpenGLFunctions_4_1_Compatibility() QOpenGLFunctions_4_1_Compatibility::~QOpenGLFunctions_4_1_Compatibility() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); - if (d_3_3_Deprecated) + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } + if (d_3_3_Deprecated) { d_3_3_Deprecated->refs.deref(); - Q_ASSERT(d_3_3_Deprecated->refs.load()); + Q_ASSERT(d_3_3_Deprecated->refs.load()); + } } bool QOpenGLFunctions_4_1_Compatibility::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_1_compatibility.h b/src/gui/opengl/qopenglfunctions_4_1_compatibility.h index e06803f0aa..a284f8e6d3 100644 --- a/src/gui/opengl/qopenglfunctions_4_1_compatibility.h +++ b/src/gui/opengl/qopenglfunctions_4_1_compatibility.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_1_COMPATIBILITY_H #define QOPENGLVERSIONFUNCTIONS_4_1_COMPATIBILITY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_1_core.cpp b/src/gui/opengl/qopenglfunctions_4_1_core.cpp index ff3d191781..5a1e1eb42f 100644 --- a/src/gui/opengl/qopenglfunctions_4_1_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_1_core.cpp @@ -86,48 +86,62 @@ QOpenGLFunctions_4_1_Core::QOpenGLFunctions_4_1_Core() QOpenGLFunctions_4_1_Core::~QOpenGLFunctions_4_1_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); + Q_ASSERT(d_4_1_Core->refs.load()); + } } bool QOpenGLFunctions_4_1_Core::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_1_core.h b/src/gui/opengl/qopenglfunctions_4_1_core.h index 17d922e261..d35db3c839 100644 --- a/src/gui/opengl/qopenglfunctions_4_1_core.h +++ b/src/gui/opengl/qopenglfunctions_4_1_core.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_1_CORE_H #define QOPENGLVERSIONFUNCTIONS_4_1_CORE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp index 58527e92b5..8398ef0948 100644 --- a/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp @@ -94,69 +94,90 @@ QOpenGLFunctions_4_2_Compatibility::QOpenGLFunctions_4_2_Compatibility() QOpenGLFunctions_4_2_Compatibility::~QOpenGLFunctions_4_2_Compatibility() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_4_2_Core) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_4_2_Core) { d_4_2_Core->refs.deref(); - Q_ASSERT(d_4_2_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_4_2_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); - if (d_3_3_Deprecated) + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } + if (d_3_3_Deprecated) { d_3_3_Deprecated->refs.deref(); - Q_ASSERT(d_3_3_Deprecated->refs.load()); + Q_ASSERT(d_3_3_Deprecated->refs.load()); + } } bool QOpenGLFunctions_4_2_Compatibility::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_2_compatibility.h b/src/gui/opengl/qopenglfunctions_4_2_compatibility.h index cb95c39936..7b45859984 100644 --- a/src/gui/opengl/qopenglfunctions_4_2_compatibility.h +++ b/src/gui/opengl/qopenglfunctions_4_2_compatibility.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_2_COMPATIBILITY_H #define QOPENGLVERSIONFUNCTIONS_4_2_COMPATIBILITY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_2_core.cpp b/src/gui/opengl/qopenglfunctions_4_2_core.cpp index b929abcf6a..fdfb4db455 100644 --- a/src/gui/opengl/qopenglfunctions_4_2_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_2_core.cpp @@ -87,51 +87,66 @@ QOpenGLFunctions_4_2_Core::QOpenGLFunctions_4_2_Core() QOpenGLFunctions_4_2_Core::~QOpenGLFunctions_4_2_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_4_2_Core) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_4_2_Core) { d_4_2_Core->refs.deref(); - Q_ASSERT(d_4_2_Core->refs.load()); + Q_ASSERT(d_4_2_Core->refs.load()); + } } bool QOpenGLFunctions_4_2_Core::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_2_core.h b/src/gui/opengl/qopenglfunctions_4_2_core.h index 14b748b3f5..80bb33e7d8 100644 --- a/src/gui/opengl/qopenglfunctions_4_2_core.h +++ b/src/gui/opengl/qopenglfunctions_4_2_core.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_2_CORE_H #define QOPENGLVERSIONFUNCTIONS_4_2_CORE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp index a9f15083ad..19e67c6331 100644 --- a/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp @@ -95,72 +95,94 @@ QOpenGLFunctions_4_3_Compatibility::QOpenGLFunctions_4_3_Compatibility() QOpenGLFunctions_4_3_Compatibility::~QOpenGLFunctions_4_3_Compatibility() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_4_2_Core) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_4_2_Core) { d_4_2_Core->refs.deref(); - Q_ASSERT(d_4_2_Core->refs.load()); - if (d_4_3_Core) + Q_ASSERT(d_4_2_Core->refs.load()); + } + if (d_4_3_Core) { d_4_3_Core->refs.deref(); - Q_ASSERT(d_4_3_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_4_3_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); - if (d_3_3_Deprecated) + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } + if (d_3_3_Deprecated) { d_3_3_Deprecated->refs.deref(); - Q_ASSERT(d_3_3_Deprecated->refs.load()); + Q_ASSERT(d_3_3_Deprecated->refs.load()); + } } bool QOpenGLFunctions_4_3_Compatibility::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_3_compatibility.h b/src/gui/opengl/qopenglfunctions_4_3_compatibility.h index 33d3065500..515467a38d 100644 --- a/src/gui/opengl/qopenglfunctions_4_3_compatibility.h +++ b/src/gui/opengl/qopenglfunctions_4_3_compatibility.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_3_COMPATIBILITY_H #define QOPENGLVERSIONFUNCTIONS_4_3_COMPATIBILITY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_3_core.cpp b/src/gui/opengl/qopenglfunctions_4_3_core.cpp index d3f988ba0d..95e2d7bc43 100644 --- a/src/gui/opengl/qopenglfunctions_4_3_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_3_core.cpp @@ -88,54 +88,70 @@ QOpenGLFunctions_4_3_Core::QOpenGLFunctions_4_3_Core() QOpenGLFunctions_4_3_Core::~QOpenGLFunctions_4_3_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_4_2_Core) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_4_2_Core) { d_4_2_Core->refs.deref(); - Q_ASSERT(d_4_2_Core->refs.load()); - if (d_4_3_Core) + Q_ASSERT(d_4_2_Core->refs.load()); + } + if (d_4_3_Core) { d_4_3_Core->refs.deref(); - Q_ASSERT(d_4_3_Core->refs.load()); + Q_ASSERT(d_4_3_Core->refs.load()); + } } bool QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_3_core.h b/src/gui/opengl/qopenglfunctions_4_3_core.h index 7e18292bb0..4a700c36d7 100644 --- a/src/gui/opengl/qopenglfunctions_4_3_core.h +++ b/src/gui/opengl/qopenglfunctions_4_3_core.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_3_CORE_H #define QOPENGLVERSIONFUNCTIONS_4_3_CORE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp index 8cbb94c1a1..a33efd0b95 100644 --- a/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp @@ -95,75 +95,98 @@ QOpenGLFunctions_4_4_Compatibility::QOpenGLFunctions_4_4_Compatibility() QOpenGLFunctions_4_4_Compatibility::~QOpenGLFunctions_4_4_Compatibility() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_4_2_Core) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_4_2_Core) { d_4_2_Core->refs.deref(); - Q_ASSERT(d_4_2_Core->refs.load()); - if (d_4_3_Core) + Q_ASSERT(d_4_2_Core->refs.load()); + } + if (d_4_3_Core) { d_4_3_Core->refs.deref(); - Q_ASSERT(d_4_3_Core->refs.load()); - if (d_4_4_Core) + Q_ASSERT(d_4_3_Core->refs.load()); + } + if (d_4_4_Core) { d_4_4_Core->refs.deref(); - Q_ASSERT(d_4_4_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_4_4_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); - if (d_3_3_Deprecated) + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } + if (d_3_3_Deprecated) { d_3_3_Deprecated->refs.deref(); - Q_ASSERT(d_3_3_Deprecated->refs.load()); + Q_ASSERT(d_3_3_Deprecated->refs.load()); + } } bool QOpenGLFunctions_4_4_Compatibility::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_4_compatibility.h b/src/gui/opengl/qopenglfunctions_4_4_compatibility.h index d369ff27ff..f2d640cdaf 100644 --- a/src/gui/opengl/qopenglfunctions_4_4_compatibility.h +++ b/src/gui/opengl/qopenglfunctions_4_4_compatibility.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_4_COMPATIBILITY_H #define QOPENGLVERSIONFUNCTIONS_4_4_COMPATIBILITY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_4_core.cpp b/src/gui/opengl/qopenglfunctions_4_4_core.cpp index 95bfc3a438..019a70087a 100644 --- a/src/gui/opengl/qopenglfunctions_4_4_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_4_core.cpp @@ -89,57 +89,74 @@ QOpenGLFunctions_4_4_Core::QOpenGLFunctions_4_4_Core() QOpenGLFunctions_4_4_Core::~QOpenGLFunctions_4_4_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_4_2_Core) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_4_2_Core) { d_4_2_Core->refs.deref(); - Q_ASSERT(d_4_2_Core->refs.load()); - if (d_4_3_Core) + Q_ASSERT(d_4_2_Core->refs.load()); + } + if (d_4_3_Core) { d_4_3_Core->refs.deref(); - Q_ASSERT(d_4_3_Core->refs.load()); - if (d_4_4_Core) + Q_ASSERT(d_4_3_Core->refs.load()); + } + if (d_4_4_Core) { d_4_4_Core->refs.deref(); - Q_ASSERT(d_4_4_Core->refs.load()); + Q_ASSERT(d_4_4_Core->refs.load()); + } } bool QOpenGLFunctions_4_4_Core::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_4_core.h b/src/gui/opengl/qopenglfunctions_4_4_core.h index e508478c50..bcb7383a9e 100644 --- a/src/gui/opengl/qopenglfunctions_4_4_core.h +++ b/src/gui/opengl/qopenglfunctions_4_4_core.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_4_CORE_H #define QOPENGLVERSIONFUNCTIONS_4_4_CORE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp index 81ee8559a5..f9d2bb9ceb 100644 --- a/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp +++ b/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp @@ -97,81 +97,106 @@ QOpenGLFunctions_4_5_Compatibility::QOpenGLFunctions_4_5_Compatibility() QOpenGLFunctions_4_5_Compatibility::~QOpenGLFunctions_4_5_Compatibility() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_4_2_Core) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_4_2_Core) { d_4_2_Core->refs.deref(); - Q_ASSERT(d_4_2_Core->refs.load()); - if (d_4_3_Core) + Q_ASSERT(d_4_2_Core->refs.load()); + } + if (d_4_3_Core) { d_4_3_Core->refs.deref(); - Q_ASSERT(d_4_3_Core->refs.load()); - if (d_4_4_Core) + Q_ASSERT(d_4_3_Core->refs.load()); + } + if (d_4_4_Core) { d_4_4_Core->refs.deref(); - Q_ASSERT(d_4_4_Core->refs.load()); - if (d_4_5_Core) + Q_ASSERT(d_4_4_Core->refs.load()); + } + if (d_4_5_Core) { d_4_5_Core->refs.deref(); - Q_ASSERT(d_4_5_Core->refs.load()); - if (d_1_0_Deprecated) + Q_ASSERT(d_4_5_Core->refs.load()); + } + if (d_1_0_Deprecated) { d_1_0_Deprecated->refs.deref(); - Q_ASSERT(d_1_0_Deprecated->refs.load()); - if (d_1_1_Deprecated) + Q_ASSERT(d_1_0_Deprecated->refs.load()); + } + if (d_1_1_Deprecated) { d_1_1_Deprecated->refs.deref(); - Q_ASSERT(d_1_1_Deprecated->refs.load()); - if (d_1_2_Deprecated) + Q_ASSERT(d_1_1_Deprecated->refs.load()); + } + if (d_1_2_Deprecated) { d_1_2_Deprecated->refs.deref(); - Q_ASSERT(d_1_2_Deprecated->refs.load()); - if (d_1_3_Deprecated) + Q_ASSERT(d_1_2_Deprecated->refs.load()); + } + if (d_1_3_Deprecated) { d_1_3_Deprecated->refs.deref(); - Q_ASSERT(d_1_3_Deprecated->refs.load()); - if (d_1_4_Deprecated) + Q_ASSERT(d_1_3_Deprecated->refs.load()); + } + if (d_1_4_Deprecated) { d_1_4_Deprecated->refs.deref(); - Q_ASSERT(d_1_4_Deprecated->refs.load()); - if (d_3_3_Deprecated) + Q_ASSERT(d_1_4_Deprecated->refs.load()); + } + if (d_3_3_Deprecated) { d_3_3_Deprecated->refs.deref(); - Q_ASSERT(d_3_3_Deprecated->refs.load()); - if (d_4_5_Deprecated) + Q_ASSERT(d_3_3_Deprecated->refs.load()); + } + if (d_4_5_Deprecated) { d_4_5_Deprecated->refs.deref(); - Q_ASSERT(d_4_5_Deprecated->refs.load()); + Q_ASSERT(d_4_5_Deprecated->refs.load()); + } } bool QOpenGLFunctions_4_5_Compatibility::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_5_compatibility.h b/src/gui/opengl/qopenglfunctions_4_5_compatibility.h index 1c50dafd65..b164538686 100644 --- a/src/gui/opengl/qopenglfunctions_4_5_compatibility.h +++ b/src/gui/opengl/qopenglfunctions_4_5_compatibility.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_5_COMPATIBILITY_H #define QOPENGLVERSIONFUNCTIONS_4_5_COMPATIBILITY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_4_5_core.cpp b/src/gui/opengl/qopenglfunctions_4_5_core.cpp index 2fdb9ef855..27c0223cf9 100644 --- a/src/gui/opengl/qopenglfunctions_4_5_core.cpp +++ b/src/gui/opengl/qopenglfunctions_4_5_core.cpp @@ -90,60 +90,78 @@ QOpenGLFunctions_4_5_Core::QOpenGLFunctions_4_5_Core() QOpenGLFunctions_4_5_Core::~QOpenGLFunctions_4_5_Core() { - if (d_1_0_Core) + if (d_1_0_Core) { d_1_0_Core->refs.deref(); - Q_ASSERT(d_1_0_Core->refs.load()); - if (d_1_1_Core) + Q_ASSERT(d_1_0_Core->refs.load()); + } + if (d_1_1_Core) { d_1_1_Core->refs.deref(); - Q_ASSERT(d_1_1_Core->refs.load()); - if (d_1_2_Core) + Q_ASSERT(d_1_1_Core->refs.load()); + } + if (d_1_2_Core) { d_1_2_Core->refs.deref(); - Q_ASSERT(d_1_2_Core->refs.load()); - if (d_1_3_Core) + Q_ASSERT(d_1_2_Core->refs.load()); + } + if (d_1_3_Core) { d_1_3_Core->refs.deref(); - Q_ASSERT(d_1_3_Core->refs.load()); - if (d_1_4_Core) + Q_ASSERT(d_1_3_Core->refs.load()); + } + if (d_1_4_Core) { d_1_4_Core->refs.deref(); - Q_ASSERT(d_1_4_Core->refs.load()); - if (d_1_5_Core) + Q_ASSERT(d_1_4_Core->refs.load()); + } + if (d_1_5_Core) { d_1_5_Core->refs.deref(); - Q_ASSERT(d_1_5_Core->refs.load()); - if (d_2_0_Core) + Q_ASSERT(d_1_5_Core->refs.load()); + } + if (d_2_0_Core) { d_2_0_Core->refs.deref(); - Q_ASSERT(d_2_0_Core->refs.load()); - if (d_2_1_Core) + Q_ASSERT(d_2_0_Core->refs.load()); + } + if (d_2_1_Core) { d_2_1_Core->refs.deref(); - Q_ASSERT(d_2_1_Core->refs.load()); - if (d_3_0_Core) + Q_ASSERT(d_2_1_Core->refs.load()); + } + if (d_3_0_Core) { d_3_0_Core->refs.deref(); - Q_ASSERT(d_3_0_Core->refs.load()); - if (d_3_1_Core) + Q_ASSERT(d_3_0_Core->refs.load()); + } + if (d_3_1_Core) { d_3_1_Core->refs.deref(); - Q_ASSERT(d_3_1_Core->refs.load()); - if (d_3_2_Core) + Q_ASSERT(d_3_1_Core->refs.load()); + } + if (d_3_2_Core) { d_3_2_Core->refs.deref(); - Q_ASSERT(d_3_2_Core->refs.load()); - if (d_3_3_Core) + Q_ASSERT(d_3_2_Core->refs.load()); + } + if (d_3_3_Core) { d_3_3_Core->refs.deref(); - Q_ASSERT(d_3_3_Core->refs.load()); - if (d_4_0_Core) + Q_ASSERT(d_3_3_Core->refs.load()); + } + if (d_4_0_Core) { d_4_0_Core->refs.deref(); - Q_ASSERT(d_4_0_Core->refs.load()); - if (d_4_1_Core) + Q_ASSERT(d_4_0_Core->refs.load()); + } + if (d_4_1_Core) { d_4_1_Core->refs.deref(); - Q_ASSERT(d_4_1_Core->refs.load()); - if (d_4_2_Core) + Q_ASSERT(d_4_1_Core->refs.load()); + } + if (d_4_2_Core) { d_4_2_Core->refs.deref(); - Q_ASSERT(d_4_2_Core->refs.load()); - if (d_4_3_Core) + Q_ASSERT(d_4_2_Core->refs.load()); + } + if (d_4_3_Core) { d_4_3_Core->refs.deref(); - Q_ASSERT(d_4_3_Core->refs.load()); - if (d_4_4_Core) + Q_ASSERT(d_4_3_Core->refs.load()); + } + if (d_4_4_Core) { d_4_4_Core->refs.deref(); - Q_ASSERT(d_4_4_Core->refs.load()); - if (d_4_5_Core) + Q_ASSERT(d_4_4_Core->refs.load()); + } + if (d_4_5_Core) { d_4_5_Core->refs.deref(); - Q_ASSERT(d_4_5_Core->refs.load()); + Q_ASSERT(d_4_5_Core->refs.load()); + } } bool QOpenGLFunctions_4_5_Core::initializeOpenGLFunctions() diff --git a/src/gui/opengl/qopenglfunctions_4_5_core.h b/src/gui/opengl/qopenglfunctions_4_5_core.h index b086e63917..0940d8cf61 100644 --- a/src/gui/opengl/qopenglfunctions_4_5_core.h +++ b/src/gui/opengl/qopenglfunctions_4_5_core.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_4_5_CORE_H #define QOPENGLVERSIONFUNCTIONS_4_5_CORE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglfunctions_es2.h b/src/gui/opengl/qopenglfunctions_es2.h index 45cb329a87..3b7d2806ea 100644 --- a/src/gui/opengl/qopenglfunctions_es2.h +++ b/src/gui/opengl/qopenglfunctions_es2.h @@ -40,7 +40,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_ES2_H #define QOPENGLVERSIONFUNCTIONS_ES2_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if defined(QT_OPENGL_ES_2) || defined(Q_QDOC) diff --git a/src/gui/opengl/qopenglgradientcache_p.h b/src/gui/opengl/qopenglgradientcache_p.h index 12423452f2..a2ed85c061 100644 --- a/src/gui/opengl/qopenglgradientcache_p.h +++ b/src/gui/opengl/qopenglgradientcache_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QMultiHash> #include <QObject> #include <private/qopenglcontext_p.h> diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp index 75f09d6031..e539ee0e31 100644 --- a/src/gui/opengl/qopenglpaintdevice.cpp +++ b/src/gui/opengl/qopenglpaintdevice.cpp @@ -137,7 +137,7 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(const QSize &size) \sa QOpenGLContext::currentContext() */ QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height) - : d_ptr(new QOpenGLPaintDevicePrivate(QSize(width, height))) + : QOpenGLPaintDevice(QSize(width, height)) { } diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h index dffa68c29e..27b7fba84f 100644 --- a/src/gui/opengl/qopenglpaintdevice.h +++ b/src/gui/opengl/qopenglpaintdevice.h @@ -40,7 +40,7 @@ #ifndef QOPENGLPAINTDEVICE_H #define QOPENGLPAINTDEVICE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopenglpaintdevice_p.h b/src/gui/opengl/qopenglpaintdevice_p.h index 78e6b7a464..3683ebebac 100644 --- a/src/gui/opengl/qopenglpaintdevice_p.h +++ b/src/gui/opengl/qopenglpaintdevice_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qopenglpaintdevice.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index d93871c99b..5c05a05d80 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1012,11 +1012,11 @@ void QOpenGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, funcs.glStencilMask(0xff); // Enable stencil writes if (dirtyStencilRegion.intersects(currentScissorBounds)) { - QVector<QRect> clearRegion = dirtyStencilRegion.intersected(currentScissorBounds).rects(); + const QRegion clearRegion = dirtyStencilRegion.intersected(currentScissorBounds); funcs.glClearStencil(0); // Clear to zero - for (int i = 0; i < clearRegion.size(); ++i) { + for (const QRect &rect : clearRegion) { #ifndef QT_GL_NO_SCISSOR_TEST - setScissor(clearRegion.at(i)); + setScissor(rect); #endif funcs.glClear(GL_STENCIL_BUFFER_BIT); } diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h index c9f328203c..807efb1ec2 100644 --- a/src/gui/opengl/qopenglpaintengine_p.h +++ b/src/gui/opengl/qopenglpaintengine_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QDebug> #include <qopenglpaintdevice.h> diff --git a/src/gui/opengl/qopenglpixeltransferoptions.h b/src/gui/opengl/qopenglpixeltransferoptions.h index 81aa588ae4..2fc52b82d8 100644 --- a/src/gui/opengl/qopenglpixeltransferoptions.h +++ b/src/gui/opengl/qopenglpixeltransferoptions.h @@ -40,7 +40,7 @@ #ifndef QOPENGLPIXELUPLOADOPTIONS_H #define QOPENGLPIXELUPLOADOPTIONS_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) diff --git a/src/gui/opengl/qopenglqueryhelper_p.h b/src/gui/opengl/qopenglqueryhelper_p.h index be36c32217..60dbf9c743 100644 --- a/src/gui/opengl/qopenglqueryhelper_p.h +++ b/src/gui/opengl/qopenglqueryhelper_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #if !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglshadercache_p.h b/src/gui/opengl/qopenglshadercache_p.h index 5070874d83..b4d1d64721 100644 --- a/src/gui/opengl/qopenglshadercache_p.h +++ b/src/gui/opengl/qopenglshadercache_p.h @@ -51,7 +51,7 @@ #ifndef QOPENGLSHADERCACHE_P_H #define QOPENGLSHADERCACHE_P_H -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2) # include "qopenglshadercache_meego_p.h" diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp index 4134513210..f076e10e20 100644 --- a/src/gui/opengl/qopenglshaderprogram.cpp +++ b/src/gui/opengl/qopenglshaderprogram.cpp @@ -337,9 +337,10 @@ bool QOpenGLShaderPrivate::compile(QOpenGLShader *q) // Dump the source code if we got it if (sourceCodeBuffer) { - qWarning("*** Problematic %s shader source code ***", type); - qWarning() << qPrintable(QString::fromLatin1(sourceCodeBuffer)); - qWarning("***"); + qWarning("*** Problematic %s shader source code ***\n" + "%ls\n" + "***", + type, qUtf16Printable(QString::fromLatin1(sourceCodeBuffer))); } // Cleanup @@ -1215,8 +1216,7 @@ int QOpenGLShaderProgram::attributeLocation(const char *name) const if (d->linked && d->programGuard && d->programGuard->id()) { return d->glfuncs->glGetAttribLocation(d->programGuard->id(), name); } else { - qWarning() << "QOpenGLShaderProgram::attributeLocation(" << name - << "): shader program is not linked"; + qWarning("QOpenGLShaderProgram::attributeLocation(%s): shader program is not linked", name); return -1; } } @@ -1479,7 +1479,7 @@ void QOpenGLShaderProgram::setAttributeValue Q_D(QOpenGLShaderProgram); Q_UNUSED(d); if (rows < 1 || rows > 4) { - qWarning() << "QOpenGLShaderProgram::setAttributeValue: rows" << rows << "not supported"; + qWarning("QOpenGLShaderProgram::setAttributeValue: rows %d not supported", rows); return; } if (location != -1) { @@ -1891,8 +1891,7 @@ int QOpenGLShaderProgram::uniformLocation(const char *name) const if (d->linked && d->programGuard && d->programGuard->id()) { return d->glfuncs->glGetUniformLocation(d->programGuard->id(), name); } else { - qWarning() << "QOpenGLShaderProgram::uniformLocation(" << name - << "): shader program is not linked"; + qWarning("QOpenGLShaderProgram::uniformLocation(%s): shader program is not linked", name); return -1; } } @@ -2819,7 +2818,7 @@ void QOpenGLShaderProgram::setUniformValueArray(int location, const GLfloat *val else if (tupleSize == 4) d->glfuncs->glUniform4fv(location, count, values); else - qWarning() << "QOpenGLShaderProgram::setUniformValue: size" << tupleSize << "not supported"; + qWarning("QOpenGLShaderProgram::setUniformValue: size %d not supported", tupleSize); } } diff --git a/src/gui/opengl/qopenglshaderprogram.h b/src/gui/opengl/qopenglshaderprogram.h index da20228e51..2da359c535 100644 --- a/src/gui/opengl/qopenglshaderprogram.h +++ b/src/gui/opengl/qopenglshaderprogram.h @@ -40,7 +40,7 @@ #ifndef QOPENGLSHADERPROGRAM_H #define QOPENGLSHADERPROGRAM_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 1db61b7ca1..0a46eea85d 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -2216,7 +2216,7 @@ QOpenGLTexture::QOpenGLTexture(Target target) OpenGL context. */ QOpenGLTexture::QOpenGLTexture(const QImage& image, MipMapGeneration genMipMaps) - : d_ptr(new QOpenGLTexturePrivate(QOpenGLTexture::Target2D, this)) + : QOpenGLTexture(QOpenGLTexture::Target2D) { setData(image, genMipMaps); } diff --git a/src/gui/opengl/qopengltexture.h b/src/gui/opengl/qopengltexture.h index 8c32fcef26..0a948488a6 100644 --- a/src/gui/opengl/qopengltexture.h +++ b/src/gui/opengl/qopengltexture.h @@ -40,7 +40,7 @@ #ifndef QOPENGLABSTRACTTEXTURE_H #define QOPENGLABSTRACTTEXTURE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopengltexture_p.h b/src/gui/opengl/qopengltexture_p.h index e9ada026ed..9914316bb4 100644 --- a/src/gui/opengl/qopengltexture_p.h +++ b/src/gui/opengl/qopengltexture_p.h @@ -53,6 +53,7 @@ #ifndef QT_NO_OPENGL +#include <QtGui/private/qtguiglobal_p.h> #include "private/qobject_p.h" #include "qopengltexture.h" #include "qopengl.h" diff --git a/src/gui/opengl/qopengltextureblitter.cpp b/src/gui/opengl/qopengltextureblitter.cpp index 18ff0c4acf..2e74afcbc2 100644 --- a/src/gui/opengl/qopengltextureblitter.cpp +++ b/src/gui/opengl/qopengltextureblitter.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "qopengltextureblitter_p.h" +#include "qopengltextureblitter.h" #include <QtGui/QOpenGLBuffer> #include <QtGui/QOpenGLShaderProgram> @@ -51,6 +51,49 @@ QT_BEGIN_NAMESPACE +/*! + \class QOpenGLTextureBlitter + \brief The QOpenGLTextureBlitter class provides a convenient way to draw textured quads via OpenGL. + \since 5.8 + \ingroup painting-3D + \inmodule QtGui + + Drawing textured quads, in order to get the contents of a texture + onto the screen, is a common operation when developing 2D user + interfaces. QOpenGLTextureBlitter provides a convenience class to + avoid repeating vertex data, shader sources, buffer and program + management and matrix calculations. + + For example, a QOpenGLWidget subclass can do the following to draw + the contents rendered into a framebuffer at the pixel position \c{(x, y)}: + + \code + void OpenGLWidget::initializeGL() + { + m_blitter.create(); + m_fbo = new QOpenGLFramebufferObject(size); + } + + void OpenGLWidget::paintGL() + { + m_fbo->bind(); + // update offscreen content + m_fbo->release(); + + m_blitter.bind(); + const QRect targetRect(QPoint(x, y), m_fbo->size()); + const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(0, 0), m_fbo->size())); + m_blitter.blit(m_fbo->texture(), target, QOpenGLTextureBlitter::OriginBottomLeft); + m_blitter.release(); + } + \endcode + + The blitter implements GLSL shaders both for GLSL 1.00 (suitable + for OpenGL (ES) 2.x and compatibility profiles of newer OpenGL + versions) and version 150 (suitable for core profile contexts with + OpenGL 3.2 and newer). + */ + static const char vertex_shader150[] = "#version 150 core\n" "in vec3 vertexCoord;" @@ -309,16 +352,44 @@ bool QOpenGLTextureBlitterPrivate::buildProgram(ProgramIndex idx, const char *vs return true; } +/*! + Constructs a new QOpenGLTextureBlitter instance. + + \note no graphics resources are initialized in the + constructor. This makes it safe to place plain + QOpenGLTextureBlitter members into classes because the actual + initialization that depends on the OpenGL context happens only in + create(). + */ QOpenGLTextureBlitter::QOpenGLTextureBlitter() : d_ptr(new QOpenGLTextureBlitterPrivate) { } +/*! + Destructs the instance. + + \note When the OpenGL context - or a context sharing resources + with it - that was current when calling create() is not current, + graphics resources will not be released. Therefore, it is + recommended to call destroy() manually instead of relying on the + destructor to perform OpenGL resource cleanup. + */ QOpenGLTextureBlitter::~QOpenGLTextureBlitter() { destroy(); } +/*! + Initializes the graphics resources used by the blitter. + + \return \c true if successful, \c false if there was a + failure. Failures can occur when there is no OpenGL context + current on the current thread, or when shader compilation fails + for some reason. + + \sa isCreated(), destroy() + */ bool QOpenGLTextureBlitter::create() { QOpenGLContext *currentContext = QOpenGLContext::currentContext(); @@ -358,12 +429,26 @@ bool QOpenGLTextureBlitter::create() return true; } +/*! + \return \c true if create() was called and succeeded. \c false otherwise. + + \sa create(), destroy() + */ bool QOpenGLTextureBlitter::isCreated() const { Q_D(const QOpenGLTextureBlitter); return d->programs[QOpenGLTextureBlitterPrivate::TEXTURE_2D].glProgram; } +/*! + Frees all graphics resources held by the blitter. Assumes that + the OpenGL context, or another context sharing resources with it, + that was current on the thread when invoking create() is current. + + The function has no effect when the blitter is not in created state. + + \sa create() + */ void QOpenGLTextureBlitter::destroy() { if (!isCreated()) @@ -376,12 +461,29 @@ void QOpenGLTextureBlitter::destroy() d->vao.reset(); } +/*! + \return \c true when bind() accepts \c GL_TEXTURE_EXTERNAL_OES as + its target argument. + + \sa bind(), blit() + */ bool QOpenGLTextureBlitter::supportsExternalOESTarget() const { QOpenGLContext *ctx = QOpenGLContext::currentContext(); return ctx && ctx->isOpenGLES() && ctx->hasExtension("GL_OES_EGL_image_external"); } +/*! + Binds the graphics resources used by the blitter. This must be + called before calling blit(). Code modifying the OpenGL state + should be avoided between the call to bind() and blit() because + otherwise conflicts may arise. + + \a target is the texture target for the source texture and must be + either \c GL_TEXTURE_2D or \c GL_OES_EGL_image_external. + + \sa release(), blit() + */ void QOpenGLTextureBlitter::bind(GLenum target) { Q_D(QOpenGLTextureBlitter); @@ -404,6 +506,11 @@ void QOpenGLTextureBlitter::bind(GLenum target) d->textureBuffer.release(); } +/*! + Unbinds the graphics resources used by the blitter. + + \sa bind() + */ void QOpenGLTextureBlitter::release() { Q_D(QOpenGLTextureBlitter); @@ -412,18 +519,64 @@ void QOpenGLTextureBlitter::release() d->vao->release(); } -void QOpenGLTextureBlitter::setSwizzleRB(bool swizzle) +/*! + Enables or disables swizzling for the red and blue color + channels. An BGRA to RGBA conversion (occurring in the shader on + the GPU, instead of a slow CPU-side transformation) can be useful + when the source texture contains data from a QImage with a format + like QImage::Format_ARGB32 which maps to BGRA on little endian + systems. + + By default the red-blue swizzle is disabled since this is what a + texture attached to an framebuffer object or a texture based on a + byte ordered QImage format (like QImage::Format_RGBA8888) needs. + */ +void QOpenGLTextureBlitter::setRedBlueSwizzle(bool swizzle) { Q_D(QOpenGLTextureBlitter); d->swizzle = swizzle; } +/*! + Changes the opacity. The default opacity is 1.0. + + \note the blitter does not alter the blend state. It is up to the + caller of blit() to ensure the correct blend settings are active. + */ void QOpenGLTextureBlitter::setOpacity(float opacity) { Q_D(QOpenGLTextureBlitter); d->opacity = opacity; } +/*! + \enum QOpenGLTextureBlitter::Origin + + \value OriginBottomLeft Indicates that the data in the texture + follows the OpenGL convention of coordinate systems, meaning Y is + running from bottom to top. + + \value OriginTopLeft Indicates that the data in the texture has Y + running from top to bottom, which is typical with regular, + unflipped image data. + + \sa blit() + */ + +/*! + Performs the blit with the source texture \a texture. + + \a targetTransform specifies the transformation applied. This is + usually generated by the targetTransform() helper function. + + \a sourceOrigin specifies if the image data needs flipping. When + \a texture corresponds to a texture attached to an FBO pass + OriginBottomLeft. On the other hand, when \a texture is based on + unflipped image data, pass OriginTopLeft. This is more efficient + than using QImage::mirrored(). + + \sa targetTransform(), Origin, bind() + */ void QOpenGLTextureBlitter::blit(GLuint texture, const QMatrix4x4 &targetTransform, Origin sourceOrigin) @@ -432,6 +585,19 @@ void QOpenGLTextureBlitter::blit(GLuint texture, d->blit(texture,targetTransform, sourceOrigin); } +/*! + Performs the blit with the source texture \a texture. + + \a targetTransform specifies the transformation applied. This is + usually generated by the targetTransform() helper function. + + \a sourceTransform specifies the transformation applied to the + source. This allows using only a sub-rect of the source + texture. This is usually generated by the sourceTransform() helper + function. + + \sa sourceTransform(), targetTransform(), Origin, bind() + */ void QOpenGLTextureBlitter::blit(GLuint texture, const QMatrix4x4 &targetTransform, const QMatrix3x3 &sourceTransform) @@ -440,6 +606,18 @@ void QOpenGLTextureBlitter::blit(GLuint texture, d->blit(texture, targetTransform, sourceTransform); } +/*! + Calculates a target transform suitable for blit(). + + \a target is the target rectangle in pixels. \a viewport describes + the source dimensions and will in most cases be set to (0, 0, + image width, image height). + + For unscaled output the size of \a target and \viewport should + match. + + \sa blit() + */ QMatrix4x4 QOpenGLTextureBlitter::targetTransform(const QRectF &target, const QRect &viewport) { @@ -460,6 +638,17 @@ QMatrix4x4 QOpenGLTextureBlitter::targetTransform(const QRectF &target, return matrix; } +/*! + Calculates a 3x3 matrix suitable as the input to blit(). This is + used when only a part of the texture is to be used in the blit. + + \a subTexture is the desired source rectangle in pixels, \a + textureSize is the full width and height of the texture data. \a + origin specifies the orientation of the image data when it comes + to the Y axis. + + \sa blit(), Origin + */ QMatrix3x3 QOpenGLTextureBlitter::sourceTransform(const QRectF &subTexture, const QSize &textureSize, Origin origin) diff --git a/src/gui/opengl/qopengltextureblitter_p.h b/src/gui/opengl/qopengltextureblitter.h index 5d39a3e8fa..2f7c6b1a0a 100644 --- a/src/gui/opengl/qopengltextureblitter_p.h +++ b/src/gui/opengl/qopengltextureblitter.h @@ -37,28 +37,21 @@ ** ****************************************************************************/ -#ifndef QOPENGLTEXTUREBLITTER_P_H -#define QOPENGLTEXTUREBLITTER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#ifndef QOPENGLTEXTUREBLITTER_H +#define QOPENGLTEXTUREBLITTER_H + +#include <QtGui/qtguiglobal.h> + +#ifndef QT_NO_OPENGL #include <QtGui/qopengl.h> #include <QtGui/QMatrix3x3> +#include <QtGui/QMatrix4x4> QT_BEGIN_NAMESPACE class QOpenGLTextureBlitterPrivate; - class Q_GUI_EXPORT QOpenGLTextureBlitter { public: @@ -79,7 +72,7 @@ public: void bind(GLenum target = GL_TEXTURE_2D); void release(); - void setSwizzleRB(bool swizzle); + void setRedBlueSwizzle(bool swizzle); void setOpacity(float opacity); void blit(GLuint texture, const QMatrix4x4 &targetTransform, Origin sourceOrigin); @@ -96,4 +89,6 @@ private: QT_END_NAMESPACE -#endif //QOPENGLTEXTUREBLITTER_P_H +#endif + +#endif //QOPENGLTEXTUREBLITTER_H diff --git a/src/gui/opengl/qopengltexturecache_p.h b/src/gui/opengl/qopengltexturecache_p.h index aedc8e7e47..c68b068739 100644 --- a/src/gui/opengl/qopengltexturecache_p.h +++ b/src/gui/opengl/qopengltexturecache_p.h @@ -51,6 +51,7 @@ #ifndef QOPENGLTEXTURECACHE_P_H #define QOPENGLTEXTURECACHE_P_H +#include <QtGui/private/qtguiglobal_p.h> #include <QHash> #include <QObject> #include <QCache> diff --git a/src/gui/opengl/qopengltextureglyphcache_p.h b/src/gui/opengl/qopengltextureglyphcache_p.h index 6cd7667d78..da6ba36643 100644 --- a/src/gui/opengl/qopengltextureglyphcache_p.h +++ b/src/gui/opengl/qopengltextureglyphcache_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <private/qtextureglyphcache_p.h> #include <private/qopenglcontext_p.h> #include <qopenglshaderprogram.h> diff --git a/src/gui/opengl/qopengltexturehelper_p.h b/src/gui/opengl/qopengltexturehelper_p.h index 6b26527269..00f6f9e5aa 100644 --- a/src/gui/opengl/qopengltexturehelper_p.h +++ b/src/gui/opengl/qopengltexturehelper_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopengltimerquery.h b/src/gui/opengl/qopengltimerquery.h index 80e52a4c99..7b9ab850e2 100644 --- a/src/gui/opengl/qopengltimerquery.h +++ b/src/gui/opengl/qopengltimerquery.h @@ -40,7 +40,7 @@ #ifndef QOPENGLTIMERQUERY_H #define QOPENGLTIMERQUERY_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2) diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h index 7f991b1955..63209cf392 100644 --- a/src/gui/opengl/qopenglversionfunctions.h +++ b/src/gui/opengl/qopenglversionfunctions.h @@ -50,7 +50,7 @@ #ifndef QOPENGLVERSIONFUNCTIONS_H #define QOPENGLVERSIONFUNCTIONS_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qopenglversionfunctionsfactory_p.h b/src/gui/opengl/qopenglversionfunctionsfactory_p.h index 0af2e4d572..469a9cc624 100644 --- a/src/gui/opengl/qopenglversionfunctionsfactory_p.h +++ b/src/gui/opengl/qopenglversionfunctionsfactory_p.h @@ -60,9 +60,10 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> + #ifndef QT_NO_OPENGL -#include <QtCore/QtGlobal> #include <QtGui/qopenglcontext.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/opengl/qopenglvertexarrayobject.h b/src/gui/opengl/qopenglvertexarrayobject.h index 228c29fce7..a8153ea40b 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.h +++ b/src/gui/opengl/qopenglvertexarrayobject.h @@ -40,7 +40,7 @@ #ifndef QOPENGLVERTEXARRAYOBJECT_H #define QOPENGLVERTEXARRAYOBJECT_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_OPENGL diff --git a/src/gui/opengl/qrbtree_p.h b/src/gui/opengl/qrbtree_p.h index 4c9dfe1af4..d3ee23a91c 100644 --- a/src/gui/opengl/qrbtree_p.h +++ b/src/gui/opengl/qrbtree_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/opengl/qtriangulatingstroker_p.h b/src/gui/opengl/qtriangulatingstroker_p.h index 5c037cb05d..2b0f08972b 100644 --- a/src/gui/opengl/qtriangulatingstroker_p.h +++ b/src/gui/opengl/qtriangulatingstroker_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <private/qdatabuffer_p.h> #include <qvarlengtharray.h> #include <private/qvectorpath_p.h> diff --git a/src/gui/opengl/qtriangulator_p.h b/src/gui/opengl/qtriangulator_p.h index 2ef635ff84..4d1aba099c 100644 --- a/src/gui/opengl/qtriangulator_p.h +++ b/src/gui/opengl/qtriangulator_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qvector.h> #include <QtGui/private/qvectorpath_p.h> diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 283b6643b9..2f927aeddb 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -104,8 +104,8 @@ AVX2_SOURCES += painting/qdrawhelper_avx2.cpp NEON_SOURCES += painting/qdrawhelper_neon.cpp painting/qimagescale_neon.cpp NEON_HEADERS += painting/qdrawhelper_neon_p.h NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S -!ios:contains(QT_ARCH, "arm"): CONFIG+=no_clang_integrated_as -!ios:!contains(QT_ARCH, "arm64"): DEFINES += ENABLE_PIXMAN_DRAWHELPERS +!uikit:contains(QT_ARCH, "arm"): CONFIG += no_clang_integrated_as +!uikit:!contains(QT_ARCH, "arm64"): DEFINES += ENABLE_PIXMAN_DRAWHELPERS MIPS_DSP_SOURCES += painting/qdrawhelper_mips_dsp.cpp MIPS_DSP_HEADERS += painting/qdrawhelper_mips_dsp_p.h painting/qt_mips_asm_dsp_p.h diff --git a/src/gui/painting/qbackingstore.h b/src/gui/painting/qbackingstore.h index 886cf29f0e..2ba6e1c906 100644 --- a/src/gui/painting/qbackingstore.h +++ b/src/gui/painting/qbackingstore.h @@ -40,6 +40,7 @@ #ifndef QBACKINGSTORE_H #define QBACKINGSTORE_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qrect.h> #include <QtGui/qwindow.h> diff --git a/src/gui/painting/qbezier_p.h b/src/gui/painting/qbezier_p.h index c4e14a18cb..f8a91e9ef3 100644 --- a/src/gui/painting/qbezier_p.h +++ b/src/gui/painting/qbezier_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qpoint.h" #include "QtCore/qline.h" #include "QtCore/qrect.h" diff --git a/src/gui/painting/qblendfunctions_p.h b/src/gui/painting/qblendfunctions_p.h index d21765bcde..7ee04987fe 100644 --- a/src/gui/painting/qblendfunctions_p.h +++ b/src/gui/painting/qblendfunctions_p.h @@ -40,6 +40,7 @@ #ifndef QBLENDFUNCTIONS_P_H #define QBLENDFUNCTIONS_P_H +#include <QtGui/private/qtguiglobal_p.h> #include <qmath.h> #include "qdrawhelper_p.h" diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h index 8df56f6d0c..24440c3c61 100644 --- a/src/gui/painting/qblittable_p.h +++ b/src/gui/painting/qblittable_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qsize.h> #include <QtGui/private/qpixmap_blitter_p.h> diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 3a296ac40c..acea5682d1 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -458,13 +458,8 @@ QBrush::QBrush(const QImage &image) */ QBrush::QBrush(Qt::BrushStyle style) + : QBrush(QColor(Qt::black), style) { - if (qbrush_check_type(style)) - init(Qt::black, style); - else { - d.reset(nullBrushInstance()); - d->ref.ref(); - } } /*! @@ -491,13 +486,8 @@ QBrush::QBrush(const QColor &color, Qt::BrushStyle style) \sa setColor(), setStyle() */ QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style) + : QBrush(QColor(color), style) { - if (qbrush_check_type(style)) - init(color, style); - else { - d.reset(nullBrushInstance()); - d->ref.ref(); - } } /*! @@ -579,11 +569,20 @@ void QBrush::cleanUp(QBrushData *x) QBrushDataPointerDeleter::deleteData(x); } +static Q_DECL_CONSTEXPR inline bool use_same_brushdata(Qt::BrushStyle lhs, Qt::BrushStyle rhs) +{ + return lhs == rhs // includes Qt::TexturePattern + || (lhs >= Qt::NoBrush && lhs <= Qt::DiagCrossPattern && rhs >= Qt::NoBrush && rhs <= Qt::DiagCrossPattern) + || (lhs >= Qt::LinearGradientPattern && lhs <= Qt::ConicalGradientPattern && rhs >= Qt::LinearGradientPattern && rhs <= Qt::ConicalGradientPattern) + ; +} void QBrush::detach(Qt::BrushStyle newStyle) { - if (newStyle == d->style && d->ref.load() == 1) + if (use_same_brushdata(newStyle, d->style) && d->ref.load() == 1) { + d->style = newStyle; return; + } QScopedPointer<QBrushData> x; switch(newStyle) { @@ -1673,13 +1672,8 @@ QLinearGradient::QLinearGradient(const QPointF &start, const QPointF &finalStop) \sa QGradient::setColorAt(), QGradient::setStops() */ QLinearGradient::QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop) + : QLinearGradient(QPointF(xStart, yStart), QPointF(xFinalStop, yFinalStop)) { - m_type = LinearGradient; - m_spread = PadSpread; - m_data.linear.x1 = xStart; - m_data.linear.y1 = yStart; - m_data.linear.x2 = xFinalStop; - m_data.linear.y2 = yFinalStop; } @@ -1882,19 +1876,8 @@ QRadialGradient::QRadialGradient(const QPointF ¢er, qreal radius) */ QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy) + : QRadialGradient(QPointF(cx, cy), radius, QPointF(fx, fy)) { - m_type = RadialGradient; - m_spread = PadSpread; - m_data.radial.cx = cx; - m_data.radial.cy = cy; - m_data.radial.cradius = radius; - - QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(QPointF(cx, cy), - radius, - QPointF(fx, fy)); - - m_data.radial.fx = adapted_focal.x(); - m_data.radial.fy = adapted_focal.y(); } /*! @@ -1904,14 +1887,8 @@ QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qre \sa QGradient::setColorAt(), QGradient::setStops() */ QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius) + : QRadialGradient(QPointF(cx, cy), radius) { - m_type = RadialGradient; - m_spread = PadSpread; - m_data.radial.cx = cx; - m_data.radial.cy = cy; - m_data.radial.cradius = radius; - m_data.radial.fx = cx; - m_data.radial.fy = cy; } @@ -2211,12 +2188,8 @@ QConicalGradient::QConicalGradient(const QPointF ¢er, qreal angle) */ QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle) + : QConicalGradient(QPointF(cx, cy), angle) { - m_type = ConicalGradient; - m_spread = PadSpread; - m_data.conical.cx = cx; - m_data.conical.cy = cy; - m_data.conical.angle = angle; } diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index 568c06ef84..e5cff9cc9b 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -40,6 +40,7 @@ #ifndef QBRUSH_H #define QBRUSH_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qpair.h> #include <QtCore/qpoint.h> #include <QtCore/qvector.h> diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 0d24fd94f5..56180af693 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -261,7 +261,7 @@ QT_BEGIN_NAMESPACE alpha-channel to feature \l {QColor#Alpha-Blended Drawing}{alpha-blended drawing}. - \sa QPalette, QBrush, QApplication::setColorSpec() + \sa QPalette, QBrush */ #define QCOLOR_INT_RANGE_CHECK(fn, var) \ diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 6338eedd22..6cf3a8e262 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -40,6 +40,7 @@ #ifndef QCOLOR_H #define QCOLOR_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qrgb.h> #include <QtCore/qnamespace.h> #include <QtCore/qstringlist.h> @@ -263,6 +264,7 @@ private: friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColor &); #endif }; +Q_DECLARE_TYPEINFO(QColor, QT_VERSION >= QT_VERSION_CHECK(6,0,0) ? Q_MOVABLE_TYPE : Q_RELOCATABLE_TYPE); inline QColor::QColor() Q_DECL_NOTHROW { invalidate(); } diff --git a/src/gui/painting/qcolor_p.h b/src/gui/painting/qcolor_p.h index 75bc888952..a8d52672f0 100644 --- a/src/gui/painting/qcolor_p.h +++ b/src/gui/painting/qcolor_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qrgb.h" #include "QtCore/qstringlist.h" diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp index 9312ee9540..6d2cb9aadb 100644 --- a/src/gui/painting/qcompositionfunctions.cpp +++ b/src/gui/painting/qcompositionfunctions.cpp @@ -87,6 +87,36 @@ QT_BEGIN_NAMESPACE }\ } +#if defined __SSE2__ +# define LOAD(ptr) _mm_loadl_epi64(reinterpret_cast<const __m128i *>(ptr)) +#ifdef Q_PROCESSOR_X86_64 +# define CONVERT(value) _mm_cvtsi64_si128(value) +#else +# define CONVERT(value) LOAD(&value) +#endif +# define STORE(ptr, value) _mm_storel_epi64(reinterpret_cast<__m128i *>(ptr), value) +# define ADD(p, q) _mm_add_epi32(p, q) +# define ALPHA(c) _mm_shufflelo_epi16(c, _MM_SHUFFLE(3, 3, 3, 3)) +# define CONST(n) _mm_shufflelo_epi16(_mm_cvtsi32_si128(n), _MM_SHUFFLE(0, 0, 0, 0)) +# define INVALPHA(c) _mm_sub_epi32(CONST(65535), ALPHA(c)) +#elif defined __ARM_NEON__ +# define LOAD(ptr) vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(ptr))) +# define CONVERT(value) vreinterpret_u16_u64(vmov_n_u64(value)) +# define STORE(ptr, value) vst1_u64(reinterpret_cast<uint64_t *>(ptr), vreinterpret_u64_u16(value)) +# define ADD(p, q) vadd_u16(p, q) +# define ALPHA(c) vdup_lane_u16(c, 3) +# define CONST(n) vdup_n_u16(n) +# define INVALPHA(c) vmvn_u16(ALPHA(c)) +#else +# define LOAD(ptr) *ptr +# define CONVERT(value) value +# define STORE(ptr, value) *ptr = value +# define ADD(p, q) (p + q) +# define ALPHA(c) (c).alpha() +# define CONST(n) n +# define INVALPHA(c) (65535 - ALPHA(c)) +#endif + void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha) { comp_func_Clear_impl(dest, length, const_alpha); @@ -99,7 +129,7 @@ void QT_FASTCALL comp_func_solid_Clear_rgb64(QRgba64 *dest, int length, QRgba64, else { int ialpha = 255 - const_alpha; for (int i = 0; i < length; ++i) { - dest[i] = multiplyAlpha255(dest[i], ialpha); + STORE(&dest[i], multiplyAlpha255(LOAD(&dest[i]), ialpha)); } } } @@ -116,7 +146,7 @@ void QT_FASTCALL comp_func_Clear_rgb64(QRgba64 *dest, const QRgba64 *, int lengt else { int ialpha = 255 - const_alpha; for (int i = 0; i < length; ++i) { - dest[i] = multiplyAlpha255(dest[i], ialpha); + STORE(&dest[i], multiplyAlpha255(LOAD(&dest[i]), ialpha)); } } } @@ -146,9 +176,9 @@ void QT_FASTCALL comp_func_solid_Source_rgb64(QRgba64 *dest, int length, QRgba64 qt_memfill64((quint64*)dest, color, length); else { int ialpha = 255 - const_alpha; - color = multiplyAlpha255(color, const_alpha); + auto c = multiplyAlpha255(CONVERT(color), const_alpha); for (int i = 0; i < length; ++i) { - dest[i] = color + multiplyAlpha255(dest[i], ialpha); + STORE(&dest[i], ADD(c, multiplyAlpha255(LOAD(&dest[i]), ialpha))); } } } @@ -174,7 +204,7 @@ void QT_FASTCALL comp_func_Source_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRg else { int ialpha = 255 - const_alpha; for (int i = 0; i < length; ++i) { - dest[i] = interpolate255(src[i], const_alpha, dest[i], ialpha); + STORE(&dest[i], interpolate255(LOAD(&src[i]), const_alpha, LOAD(&dest[i]), ialpha)); } } } @@ -221,10 +251,12 @@ void QT_FASTCALL comp_func_solid_SourceOver_rgb64(QRgba64 *dest, int length, QRg if (const_alpha == 255 && color.isOpaque()) { qt_memfill64((quint64*)dest, color, length); } else { + auto c = CONVERT(color); if (const_alpha != 255) - color = multiplyAlpha255(color, const_alpha); + c = multiplyAlpha255(c, const_alpha); + auto cAlpha = INVALPHA(c); for (int i = 0; i < length; ++i) { - dest[i] = color + multiplyAlpha65535(dest[i], 65535 - color.alpha()); + STORE(&dest[i], ADD(c, multiplyAlpha65535(LOAD(&dest[i]), cAlpha))); } } } @@ -258,12 +290,12 @@ void QT_FASTCALL comp_func_SourceOver_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const if (s.isOpaque()) dest[i] = s; else if (!s.isTransparent()) - dest[i] = s + multiplyAlpha65535(dest[i], 65535 - s.alpha()); + STORE(&dest[i], ADD(CONVERT(s), multiplyAlpha65535(LOAD(&dest[i]), 65535 - s.alpha()))); } } else { for (int i = 0; i < length; ++i) { - QRgba64 s = multiplyAlpha255(src[i], const_alpha); - dest[i] = s + multiplyAlpha65535(dest[i], 65535 - s.alpha()); + auto s = multiplyAlpha255(LOAD(&src[i]), const_alpha); + STORE(&dest[i], ADD(s, multiplyAlpha65535(LOAD(&dest[i]), INVALPHA(s)))); } } } @@ -287,11 +319,12 @@ void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint co void QT_FASTCALL comp_func_solid_DestinationOver_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { + auto c = CONVERT(color); if (const_alpha != 255) - color = multiplyAlpha255(color, const_alpha); + c = multiplyAlpha255(c, const_alpha); for (int i = 0; i < length; ++i) { - QRgba64 d = dest[i]; - dest[i] = d + multiplyAlpha65535(color, 65535 - d.alpha()); + auto d = LOAD(&dest[i]); + STORE(&dest[i], ADD(d, multiplyAlpha65535(c, INVALPHA(d)))); } } @@ -318,14 +351,14 @@ void QT_FASTCALL comp_func_DestinationOver_rgb64(QRgba64 *Q_DECL_RESTRICT dest, { if (const_alpha == 255) { for (int i = 0; i < length; ++i) { - QRgba64 d = dest[i]; - dest[i] = d + multiplyAlpha65535(src[i], 65535 - d.alpha()); + auto d = LOAD(&dest[i]); + STORE(&dest[i], ADD(d, multiplyAlpha65535(LOAD(&src[i]), INVALPHA(d)))); } } else { for (int i = 0; i < length; ++i) { - QRgba64 d = dest[i]; - QRgba64 s = multiplyAlpha255(src[i], const_alpha); - dest[i] = d + multiplyAlpha65535(s, 65535 - d.alpha()); + auto d = LOAD(&dest[i]); + auto s = multiplyAlpha255(LOAD(&src[i]), const_alpha); + STORE(&dest[i], ADD(d, multiplyAlpha65535(s, INVALPHA(d)))); } } } @@ -393,15 +426,15 @@ void QT_FASTCALL comp_func_SourceIn_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const Q { if (const_alpha == 255) { for (int i = 0; i < length; ++i) { - dest[i] = multiplyAlpha65535(src[i], dest[i].alpha()); + STORE(&dest[i], multiplyAlpha65535(LOAD(&src[i]), dest[i].alpha())); } } else { uint ca = const_alpha * 257; - uint cia = 65535 - ca; + auto cia = CONST(65535 - ca); for (int i = 0; i < length; ++i) { - QRgba64 d = dest[i]; - QRgba64 s = multiplyAlpha65535(src[i], ca); - dest[i] = interpolate65535(s, d.alpha(), d, cia); + auto d = LOAD(&dest[i]); + auto s = multiplyAlpha65535(LOAD(&src[i]), ca); + STORE(&dest[i], interpolate65535(s, ALPHA(d), d, cia)); } } } @@ -431,7 +464,7 @@ void QT_FASTCALL comp_func_solid_DestinationIn_rgb64(QRgba64 *dest, int length, if (const_alpha != 255) a = qt_div_65535(a * ca64k) + 65535 - ca64k; for (int i = 0; i < length; ++i) { - dest[i] = multiplyAlpha65535(dest[i], a); + STORE(&dest[i], multiplyAlpha65535(LOAD(&dest[i]), a)); } } @@ -885,14 +918,19 @@ void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint c void QT_FASTCALL comp_func_solid_Plus_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha) { + auto b = CONVERT(color); if (const_alpha == 255) { for (int i = 0; i < length; ++i) { - dest[i] = addWithSaturation(dest[i], color); + auto a = LOAD(&dest[i]); + a = addWithSaturation(a, b); + STORE(&dest[i], a); } } else { for (int i = 0; i < length; ++i) { - QRgba64 d = addWithSaturation(dest[i], color); - dest[i] = interpolate255(d, const_alpha, dest[i], 255 - const_alpha); + auto a = LOAD(&dest[i]); + auto d = addWithSaturation(a, b); + a = interpolate255(d, const_alpha, a, 255 - const_alpha); + STORE(&dest[i], a); } } } @@ -924,12 +962,18 @@ void QT_FASTCALL comp_func_Plus_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba { if (const_alpha == 255) { for (int i = 0; i < length; ++i) { - dest[i] = addWithSaturation(dest[i], src[i]); + auto a = LOAD(&dest[i]); + auto b = LOAD(&src[i]); + a = addWithSaturation(a, b); + STORE(&dest[i], a); } } else { for (int i = 0; i < length; ++i) { - QRgba64 d = addWithSaturation(dest[i], src[i]); - dest[i] = interpolate255(d, const_alpha, dest[i], 255 - const_alpha); + auto a = LOAD(&dest[i]); + auto b = LOAD(&src[i]); + auto d = addWithSaturation(a, b); + a = interpolate255(d, const_alpha, a, 255 - const_alpha); + STORE(&dest[i], a); } } } diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h index b22e2c2cf5..68f4e00cdc 100644 --- a/src/gui/painting/qcosmeticstroker_p.h +++ b/src/gui/painting/qcosmeticstroker_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <private/qdrawhelper_p.h> #include <private/qvectorpath_p.h> #include <private/qpaintengine_raster_p.h> diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index f5a3fa1432..77b5be0c4c 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qbytearray.h" #include <stdlib.h> diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 8729640a80..affbc43afe 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -168,7 +168,7 @@ template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_ARGB66 template<QImage::Format Format> static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); @@ -198,7 +198,7 @@ static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int template<QImage::Format Format> static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); @@ -228,7 +228,7 @@ static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *sr template<QImage::Format Format> static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1); Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); @@ -282,7 +282,7 @@ static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint template<QImage::Format Format> static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1); Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); @@ -336,48 +336,110 @@ static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const template<QImage::Format Format, bool fromRGB> static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *dither) { - Q_CONSTEXPR uint rMask = ((1 << redWidth<Format>()) - 1); - Q_CONSTEXPR uint gMask = ((1 << greenWidth<Format>()) - 1); - Q_CONSTEXPR uint bMask = ((1 << blueWidth<Format>()) - 1); + Q_CONSTEXPR uchar rWidth = redWidth<Format>(); + Q_CONSTEXPR uchar gWidth = greenWidth<Format>(); + Q_CONSTEXPR uchar bWidth = blueWidth<Format>(); - Q_CONSTEXPR uchar rRightShift = 24 - redWidth<Format>(); - Q_CONSTEXPR uchar gRightShift = 16 - greenWidth<Format>(); - Q_CONSTEXPR uchar bRightShift = 8 - blueWidth<Format>(); + // RGB32 -> RGB888 is not a precision loss. + if (!dither || (rWidth == 8 && gWidth == 8 && bWidth == 8)) { + Q_CONSTEXPR uint rMask = (1 << rWidth) - 1; + Q_CONSTEXPR uint gMask = (1 << gWidth) - 1; + Q_CONSTEXPR uint bMask = (1 << bWidth) - 1; - for (int i = 0; i < count; ++i) { - const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]); - const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); - const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); - const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); - buffer[i] = r | g | b; + Q_CONSTEXPR uchar rRightShift = 24 - rWidth; + Q_CONSTEXPR uchar gRightShift = 16 - gWidth; + Q_CONSTEXPR uchar bRightShift = 8 - bWidth; + + for (int i = 0; i < count; ++i) { + const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]); + const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); + const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); + const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); + buffer[i] = r | g | b; + } + } else { + // We do ordered dither by using a rounding conversion, but instead of + // adding half of input precision, we add the adjusted result from the + // bayer matrix before narrowing. + // Note: Rounding conversion in itself is different from the naive + // conversion we do above for non-dithering. + const uint *bayer_line = qt_bayer_matrix[dither->y & 15]; + for (int i = 0; i < count; ++i) { + const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]); + const int d = bayer_line[(dither->x + i) & 15]; + const int dr = d - ((d + 1) >> rWidth); + const int dg = d - ((d + 1) >> gWidth); + const int db = d - ((d + 1) >> bWidth); + int r = qRed(c); + int g = qGreen(c); + int b = qBlue(c); + r = (r + ((dr - r) >> rWidth) + 1) >> (8 - rWidth); + g = (g + ((dg - g) >> gWidth) + 1) >> (8 - gWidth); + b = (b + ((db - b) >> bWidth) + 1) >> (8 - bWidth); + buffer[i] = (r << redShift<Format>()) + | (g << greenShift<Format>()) + | (b << blueShift<Format>()); + } } return buffer; } template<QImage::Format Format, bool fromRGB> static const uint *QT_FASTCALL convertARGBPMFromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *dither) { - Q_CONSTEXPR uint aMask = ((1 << alphaWidth<Format>()) - 1); - Q_CONSTEXPR uint rMask = ((1 << redWidth<Format>()) - 1); - Q_CONSTEXPR uint gMask = ((1 << greenWidth<Format>()) - 1); - Q_CONSTEXPR uint bMask = ((1 << blueWidth<Format>()) - 1); + Q_CONSTEXPR uchar aWidth = alphaWidth<Format>(); + Q_CONSTEXPR uchar rWidth = redWidth<Format>(); + Q_CONSTEXPR uchar gWidth = greenWidth<Format>(); + Q_CONSTEXPR uchar bWidth = blueWidth<Format>(); - Q_CONSTEXPR uchar aRightShift = 32 - alphaWidth<Format>(); - Q_CONSTEXPR uchar rRightShift = 24 - redWidth<Format>(); - Q_CONSTEXPR uchar gRightShift = 16 - greenWidth<Format>(); - Q_CONSTEXPR uchar bRightShift = 8 - blueWidth<Format>(); + if (!dither) { + Q_CONSTEXPR uint aMask = (1 << aWidth) - 1; + Q_CONSTEXPR uint rMask = (1 << rWidth) - 1; + Q_CONSTEXPR uint gMask = (1 << gWidth) - 1; + Q_CONSTEXPR uint bMask = (1 << bWidth) - 1; - Q_CONSTEXPR uint aOpaque = (0xff & aMask) << alphaShift<Format>(); - for (int i = 0; i < count; ++i) { - const uint c = src[i]; - const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift<Format>()); - const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); - const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); - const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); - buffer[i] = a | r | g | b; + Q_CONSTEXPR uchar aRightShift = 32 - aWidth; + Q_CONSTEXPR uchar rRightShift = 24 - rWidth; + Q_CONSTEXPR uchar gRightShift = 16 - gWidth; + Q_CONSTEXPR uchar bRightShift = 8 - bWidth; + + Q_CONSTEXPR uint aOpaque = aMask << alphaShift<Format>(); + for (int i = 0; i < count; ++i) { + const uint c = src[i]; + const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift<Format>()); + const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); + const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); + const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); + buffer[i] = a | r | g | b; + } + } else { + const uint *bayer_line = qt_bayer_matrix[dither->y & 15]; + for (int i = 0; i < count; ++i) { + const uint c = src[i]; + const int d = bayer_line[(dither->x + i) & 15]; + const int da = d - ((d + 1) >> aWidth); + const int dr = d - ((d + 1) >> rWidth); + const int dg = d - ((d + 1) >> gWidth); + const int db = d - ((d + 1) >> bWidth); + int a = qAlpha(c); + int r = qRed(c); + int g = qGreen(c); + int b = qBlue(c); + if (fromRGB) + a = (1 << aWidth) - 1; + else + a = (a + ((da - a) >> aWidth) + 1) >> (8 - aWidth); + r = (r + ((dr - r) >> rWidth) + 1) >> (8 - rWidth); + g = (g + ((dg - g) >> gWidth) + 1) >> (8 - gWidth); + b = (b + ((db - b) >> bWidth) + 1) >> (8 - bWidth); + buffer[i] = (a << alphaShift<Format>()) + | (r << redShift<Format>()) + | (g << greenShift<Format>()) + | (b << blueShift<Format>()); + } } return buffer; } @@ -418,35 +480,35 @@ template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixe // To convert in place, let 'dest' and 'src' be the same. static const uint *QT_FASTCALL convertIndexedToARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *clut) + const QVector<QRgb> *clut, QDitherInfo *) { for (int i = 0; i < count; ++i) - buffer[i] = qPremultiply(clut[src[i]]); + buffer[i] = qPremultiply(clut->at(src[i])); return buffer; } static const QRgba64 *QT_FASTCALL convertIndexedToARGB64PM(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *clut) + const QVector<QRgb> *clut, QDitherInfo *) { for (int i = 0; i < count; ++i) - buffer[i] = QRgba64::fromArgb32(clut[src[i]]).premultiplied(); + buffer[i] = QRgba64::fromArgb32(clut->at(src[i])).premultiplied(); return buffer; } static const uint *QT_FASTCALL convertPassThrough(uint *, const uint *src, int, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { return src; } static const uint *QT_FASTCALL convertARGB32ToARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { return qt_convertARGB32ToARGB32PM(buffer, src, count); } static const uint *QT_FASTCALL convertRGBA8888PMToARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = RGBA2ARGB(src[i]); @@ -454,13 +516,13 @@ static const uint *QT_FASTCALL convertRGBA8888PMToARGB32PM(uint *buffer, const u } static const uint *QT_FASTCALL convertRGBA8888ToARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { return qt_convertRGBA8888ToARGB32PM(buffer, src, count); } static const uint *QT_FASTCALL convertAlpha8ToRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qRgba(0, 0, 0, src[i]); @@ -468,7 +530,7 @@ static const uint *QT_FASTCALL convertAlpha8ToRGB32(uint *buffer, const uint *sr } static const uint *QT_FASTCALL convertGrayscale8ToRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qRgb(src[i], src[i], src[i]); @@ -476,7 +538,7 @@ static const uint *QT_FASTCALL convertGrayscale8ToRGB32(uint *buffer, const uint } static const QRgba64 *QT_FASTCALL convertAlpha8ToRGB64(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = QRgba64::fromRgba(0, 0, 0, src[i]); @@ -484,7 +546,7 @@ static const QRgba64 *QT_FASTCALL convertAlpha8ToRGB64(QRgba64 *buffer, const ui } static const QRgba64 *QT_FASTCALL convertGrayscale8ToRGB64(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = QRgba64::fromRgba(src[i], src[i], src[i], 255); @@ -492,7 +554,7 @@ static const QRgba64 *QT_FASTCALL convertGrayscale8ToRGB64(QRgba64 *buffer, cons } static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qUnpremultiply(src[i]); @@ -500,7 +562,7 @@ static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uin } static const uint *QT_FASTCALL convertRGBA8888PMFromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = ARGB2RGBA(src[i]); @@ -551,7 +613,7 @@ static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint * #endif static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { #ifdef __SSE2__ qConvertARGB32PMToARGB64PM_sse2<false, true>(buffer, src, count); @@ -563,7 +625,7 @@ static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uin } static const QRgba64 *QT_FASTCALL convertARGB32ToARGB64PM(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { #ifdef __SSE2__ qConvertARGB32PMToARGB64PM_sse2<false, false>(buffer, src, count); @@ -577,7 +639,7 @@ static const QRgba64 *QT_FASTCALL convertARGB32ToARGB64PM(QRgba64 *buffer, const } static const QRgba64 *QT_FASTCALL convertARGB32PMToARGB64PM(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { #ifdef __SSE2__ qConvertARGB32PMToARGB64PM_sse2<false, false>(buffer, src, count); @@ -589,7 +651,7 @@ static const QRgba64 *QT_FASTCALL convertARGB32PMToARGB64PM(QRgba64 *buffer, con } static const QRgba64 *QT_FASTCALL convertRGBA8888ToARGB64PM(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { #ifdef __SSE2__ qConvertARGB32PMToARGB64PM_sse2<true, false>(buffer, src, count); @@ -603,7 +665,7 @@ static const QRgba64 *QT_FASTCALL convertRGBA8888ToARGB64PM(QRgba64 *buffer, con } static const QRgba64 *QT_FASTCALL convertRGBA8888PMToARGB64PM(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { #ifdef __SSE2__ qConvertARGB32PMToARGB64PM_sse2<true, false>(buffer, src, count); @@ -615,7 +677,7 @@ static const QRgba64 *QT_FASTCALL convertRGBA8888PMToARGB64PM(QRgba64 *buffer, c } static const uint *QT_FASTCALL convertRGBA8888FromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = ARGB2RGBA(qUnpremultiply(src[i])); @@ -623,7 +685,7 @@ static const uint *QT_FASTCALL convertRGBA8888FromARGB32PM(uint *buffer, const u } static const uint *QT_FASTCALL convertRGBXFromRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = ARGB2RGBA(0xff000000 | src[i]); @@ -631,7 +693,7 @@ static const uint *QT_FASTCALL convertRGBXFromRGB32(uint *buffer, const uint *sr } static const uint *QT_FASTCALL convertRGBXFromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = ARGB2RGBA(0xff000000 | qUnpremultiply(src[i])); @@ -640,10 +702,28 @@ static const uint *QT_FASTCALL convertRGBXFromARGB32PM(uint *buffer, const uint template<QtPixelOrder PixelOrder> static const uint *QT_FASTCALL convertA2RGB30PMToARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *dither) { - for (int i = 0; i < count; ++i) - buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]); + if (!dither) { + for (int i = 0; i < count; ++i) + buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]); + } else { + for (int i = 0; i < count; ++i) { + const uint c = src[i]; + short d10 = (qt_bayer_matrix[dither->y & 15][(dither->x + i) & 15] << 2); + short a10 = (c >> 30) * 0x155; + short r10 = ((c >> 20) & 0x3ff); + short g10 = ((c >> 10) & 0x3ff); + short b10 = (c & 0x3ff); + if (PixelOrder == PixelOrderBGR) + std::swap(r10, b10); + short a8 = (a10 + ((d10 - a10) >> 8)) >> 2; + short r8 = (r10 + ((d10 - r10) >> 8)) >> 2; + short g8 = (g10 + ((d10 - g10) >> 8)) >> 2; + short b8 = (b10 + ((d10 - b10) >> 8)) >> 2; + buffer[i] = qRgba(r8, g8, b8, a8); + } + } return buffer; } @@ -693,7 +773,7 @@ static inline void qConvertA2RGB30PMToARGB64PM_sse2(QRgba64 *buffer, const uint template<QtPixelOrder PixelOrder> static const QRgba64 *QT_FASTCALL convertA2RGB30PMToARGB64PM(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { #ifdef __SSE2__ qConvertA2RGB30PMToARGB64PM_sse2<PixelOrder>(buffer, src, count); @@ -706,7 +786,7 @@ static const QRgba64 *QT_FASTCALL convertA2RGB30PMToARGB64PM(QRgba64 *buffer, co template<QtPixelOrder PixelOrder> static const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qConvertArgb32ToA2rgb30<PixelOrder>(src[i]); @@ -715,7 +795,7 @@ static const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM(uint *buffer, const template<QtPixelOrder PixelOrder> static const uint *QT_FASTCALL convertRGB30FromRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(src[i]); @@ -724,7 +804,7 @@ static const uint *QT_FASTCALL convertRGB30FromRGB32(uint *buffer, const uint *s template<QtPixelOrder PixelOrder> static const uint *QT_FASTCALL convertRGB30FromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(qUnpremultiply(src[i])); @@ -732,7 +812,7 @@ static const uint *QT_FASTCALL convertRGB30FromARGB32PM(uint *buffer, const uint } static const uint *QT_FASTCALL convertAlpha8FromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qAlpha(src[i]); @@ -740,7 +820,7 @@ static const uint *QT_FASTCALL convertAlpha8FromARGB32PM(uint *buffer, const uin } static const uint *QT_FASTCALL convertGrayscale8FromRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qGray(src[i]); @@ -748,7 +828,7 @@ static const uint *QT_FASTCALL convertGrayscale8FromRGB32(uint *buffer, const ui } static const uint *QT_FASTCALL convertGrayscale8FromARGB32PM(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qGray(qUnpremultiply(src[i])); @@ -1037,7 +1117,7 @@ static uint *QT_FASTCALL destFetch(uint *buffer, QRasterBuffer *rasterBuffer, in { const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; const uint *ptr = qFetchPixels[layout->bpp](buffer, rasterBuffer->scanLine(y), x, length); - return const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, layout, 0)); + return const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, 0, 0)); } static QRgba64 *QT_FASTCALL destFetch64(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) @@ -1045,14 +1125,14 @@ static QRgba64 *QT_FASTCALL destFetch64(QRgba64 *buffer, QRasterBuffer *rasterBu const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; uint buffer32[buffer_size]; const uint *ptr = qFetchPixels[layout->bpp](buffer32, rasterBuffer->scanLine(y), x, length); - return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, layout, 0)); + return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, 0, 0)); } static QRgba64 *QT_FASTCALL destFetch64uint32(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length) { const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format]; const uint *src = ((const uint *)rasterBuffer->scanLine(y)) + x; - return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, layout, 0)); + return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, 0, 0)); } static DestFetchProc destFetchProc[QImage::NImageFormats] = @@ -1219,9 +1299,9 @@ static void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, int x, int y, con int l = qMin(length, buffer_size); const uint *ptr = 0; if (!layout->premultiplied && !layout->alphaWidth) - ptr = layout->convertFromRGB32(buf, buffer, l, layout, 0); + ptr = layout->convertFromRGB32(buf, buffer, l, 0, 0); else - ptr = layout->convertFromARGB32PM(buf, buffer, l, layout, 0); + ptr = layout->convertFromARGB32PM(buf, buffer, l, 0, 0); store(dest, ptr, x, l); length -= l; buffer += l; @@ -1247,9 +1327,9 @@ static void QT_FASTCALL destStore64(QRasterBuffer *rasterBuffer, int x, int y, c const uint *ptr = 0; convertFromRgb64(buf, buffer, l); if (!layout->premultiplied && !layout->alphaWidth) - ptr = layout->convertFromRGB32(buf, buf, l, layout, 0); + ptr = layout->convertFromRGB32(buf, buf, l, 0, 0); else - ptr = layout->convertFromARGB32PM(buf, buf, l, layout, 0); + ptr = layout->convertFromARGB32PM(buf, buf, l, 0, 0); store(dest, ptr, x, l); length -= l; buffer += l; @@ -1436,8 +1516,7 @@ static const uint *QT_FASTCALL fetchUntransformed(uint *buffer, const Operator * { const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; const uint *ptr = qFetchPixels[layout->bpp](buffer, data->texture.scanLine(y), x, length); - const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; - return layout->convertToARGB32PM(buffer, ptr, length, layout, clut); + return layout->convertToARGB32PM(buffer, ptr, length, data->texture.colorTable, 0); } static const uint *QT_FASTCALL fetchUntransformedARGB32PM(uint *, const Operator *, @@ -1465,14 +1544,13 @@ static const QRgba64 *QT_FASTCALL fetchUntransformed64(QRgba64 *buffer, const Op const QSpanData *data, int y, int x, int length) { const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; - const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; if (layout->bpp != QPixelLayout::BPP32) { uint buffer32[buffer_size]; const uint *ptr = qFetchPixels[layout->bpp](buffer32, data->texture.scanLine(y), x, length); - return layout->convertToARGB64PM(buffer, ptr, length, layout, clut); + return layout->convertToARGB64PM(buffer, ptr, length, data->texture.colorTable, 0); } else { const uint *src = (const uint *)data->texture.scanLine(y) + x; - return layout->convertToARGB64PM(buffer, src, length, layout, clut); + return layout->convertToARGB64PM(buffer, src, length, data->texture.colorTable, 0); } } @@ -1639,8 +1717,7 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, ++b; } } - const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; - return layout->convertToARGB32PM(buffer, buffer, length, layout, clut); + return layout->convertToARGB32PM(buffer, buffer, length, data->texture.colorTable, 0); } template<TextureBlendType blendType> /* either BlendTransformed or BlendTransformedTiled */ @@ -1655,7 +1732,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; FetchPixelFunc fetch = qFetchPixel[layout->bpp]; - const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; + const QVector<QRgb> *clut = data->texture.colorTable; uint buffer32[buffer_size]; QRgba64 *b = buffer; @@ -1672,7 +1749,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper int i = 0, j = 0; while (i < length) { if (j == buffer_size) { - layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut); + layout->convertToARGB64PM(b, buffer32, buffer_size, clut, 0); b += buffer_size; j = 0; } @@ -1695,7 +1772,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper ++i; ++j; } if (j > 0) { - layout->convertToARGB64PM(b, buffer32, j, layout, clut); + layout->convertToARGB64PM(b, buffer32, j, clut, 0); b += j; } } else { @@ -1710,7 +1787,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper int i = 0, j = 0; while (i < length) { if (j == buffer_size) { - layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut); + layout->convertToARGB64PM(b, buffer32, buffer_size, clut, 0); b += buffer_size; j = 0; } @@ -1741,7 +1818,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper ++i; ++j; } if (j > 0) { - layout->convertToARGB64PM(b, buffer32, j, layout, clut); + layout->convertToARGB64PM(b, buffer32, j, clut, 0); b += j; } } @@ -1750,9 +1827,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper /** \internal interpolate 4 argb pixels with the distx and disty factor. - distx and disty bust be between 0 and 16 + distx and disty must be between 0 and 16 */ -static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, int distx, int disty) +static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, uint distx, uint disty) { uint distxy = distx * disty; //idistx * disty = (16-distx) * disty = 16*disty - distxy @@ -2099,10 +2176,12 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2); const uint *s1 = (const uint *)data->texture.scanLine(y1); const uint *s2 = (const uint *)data->texture.scanLine(y2); - int disty = (fy & 0x0000ffff) >> 12; + int disty = ((fy & 0x0000ffff) + 0x0800) >> 12; if (blendType != BlendTransformedBilinearTiled) { #define BILINEAR_DOWNSCALE_BOUNDS_PROLOG \ + const qint64 min_fx = qint64(image_x1) * fixed_scale; \ + const qint64 max_fx = qint64(image_x2) * fixed_scale; \ while (b < end) { \ int x1 = (fx >> 16); \ int x2; \ @@ -2113,16 +2192,16 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c uint tr = s1[x2]; \ uint bl = s2[x1]; \ uint br = s2[x2]; \ - int distx = (fx & 0x0000ffff) >> 12; \ + int distx = ((fx & 0x0000ffff) + 0x0800) >> 12; \ *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); \ fx += fdx; \ ++b; \ } \ - uint *boundedEnd; \ + uint *boundedEnd = end; \ if (fdx > 0) \ - boundedEnd = qMin(end, buffer + uint((image_x2 - (fx >> 16)) / data->m11)); \ - else \ - boundedEnd = qMin(end, buffer + uint((image_x1 - (fx >> 16)) / data->m11)); \ + boundedEnd = qMin(boundedEnd, b + (max_fx - fx) / fdx); \ + else if (fdx < 0) \ + boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx); \ boundedEnd -= 3; #if defined(__SSE2__) @@ -2132,6 +2211,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c const __m128i v_256 = _mm_set1_epi16(256); const __m128i v_disty = _mm_set1_epi16(disty); const __m128i v_fdx = _mm_set1_epi32(fdx*4); + const __m128i v_fx_r = _mm_set1_epi32(0x8); __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx); while (b < boundedEnd) { @@ -2145,7 +2225,8 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c const __m128i bl = _mm_setr_epi32(s2[offset0], s2[offset1], s2[offset2], s2[offset3]); const __m128i br = _mm_setr_epi32(s2[offset0 + 1], s2[offset1 + 1], s2[offset2 + 1], s2[offset3 + 1]); - __m128i v_distx = _mm_srli_epi16(v_fx, 12); + __m128i v_distx = _mm_srli_epi16(v_fx, 8); + v_distx = _mm_srli_epi16(_mm_add_epi32(v_distx, v_fx_r), 4); v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); @@ -2175,6 +2256,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c } const int32x4_t v_ffff_mask = vdupq_n_s32(0x0000ffff); + const int32x4_t v_fx_r = vdupq_n_s32(0x0800); while (b < boundedEnd) { @@ -2183,7 +2265,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c Vect_buffer v_fx_shifted; v_fx_shifted.vect = vshrq_n_s32(v_fx.vect, 16); - int32x4_t v_distx = vshrq_n_s32(vandq_s32(v_fx.vect, v_ffff_mask), 12); + int32x4_t v_distx = vshrq_n_s32(vaddq_s32(vandq_s32(v_fx.vect, v_ffff_mask), v_fx_r), 12); for (int i = 0; i < 4; i++) { int x1 = v_fx_shifted.i[i]; @@ -2213,7 +2295,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c uint tr = s1[x2]; uint bl = s2[x1]; uint br = s2[x2]; - int distx = (fx & 0x0000ffff) >> 12; + int distx = ((fx & 0x0000ffff) + 0x0800) >> 12; *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); fx += fdx; ++b; @@ -2253,6 +2335,10 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c if (blendType != BlendTransformedBilinearTiled) { #define BILINEAR_ROTATE_BOUNDS_PROLOG \ + const qint64 min_fx = qint64(image_x1) * fixed_scale; \ + const qint64 max_fx = qint64(image_x2) * fixed_scale; \ + const qint64 min_fy = qint64(image_y1) * fixed_scale; \ + const qint64 max_fy = qint64(image_y2) * fixed_scale; \ while (b < end) { \ int x1 = (fx >> 16); \ int x2; \ @@ -2275,7 +2361,15 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c fy += fdy; \ ++b; \ } \ - uint *boundedEnd = end - 3; \ + uint *boundedEnd = end; \ + if (fdx > 0) \ + boundedEnd = qMin(boundedEnd, b + (max_fx - fx) / fdx); \ + else if (fdx < 0) \ + boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx); \ + if (fdy > 0) \ + boundedEnd = qMin(boundedEnd, b + (max_fy - fy) / fdy); \ + else if (fdy < 0) \ + boundedEnd = qMin(boundedEnd, b + (min_fy - fy) / fdy); \ boundedEnd -= 3; #if defined(__SSE2__) @@ -2285,6 +2379,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c const __m128i v_256 = _mm_set1_epi16(256); const __m128i v_fdx = _mm_set1_epi32(fdx*4); const __m128i v_fdy = _mm_set1_epi32(fdy*4); + const __m128i v_fxy_r = _mm_set1_epi32(0x8); __m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx); __m128i v_fy = _mm_setr_epi32(fy, fy + fdy, fy + fdy + fdy, fy + fdy + fdy + fdy); @@ -2293,15 +2388,6 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c const __m128i vbpl = _mm_shufflelo_epi16(_mm_cvtsi32_si128(bytesPerLine/4), _MM_SHUFFLE(0, 0, 0, 0)); while (b < boundedEnd) { - if (fdx > 0 && (short)_mm_extract_epi16(v_fx, 7) >= image_x2) - break; - if (fdx < 0 && (short)_mm_extract_epi16(v_fx, 7) < image_x1) - break; - if (fdy > 0 && (short)_mm_extract_epi16(v_fy, 7) >= image_y2) - break; - if (fdy < 0 && (short)_mm_extract_epi16(v_fy, 7) < image_y1) - break; - const __m128i vy = _mm_packs_epi32(_mm_srli_epi32(v_fy, 16), _mm_setzero_si128()); // 4x16bit * 4x16bit -> 4x32bit __m128i offset = _mm_unpacklo_epi16(_mm_mullo_epi16(vy, vbpl), _mm_mulhi_epi16(vy, vbpl)); @@ -2317,8 +2403,10 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c const __m128i bl = _mm_setr_epi32(bottomData[offset0], bottomData[offset1], bottomData[offset2], bottomData[offset3]); const __m128i br = _mm_setr_epi32(bottomData[offset0 + 1], bottomData[offset1 + 1], bottomData[offset2 + 1], bottomData[offset3 + 1]); - __m128i v_distx = _mm_srli_epi16(v_fx, 12); - __m128i v_disty = _mm_srli_epi16(v_fy, 12); + __m128i v_distx = _mm_srli_epi16(v_fx, 8); + __m128i v_disty = _mm_srli_epi16(v_fy, 8); + v_distx = _mm_srli_epi16(_mm_add_epi32(v_distx, v_fxy_r), 4); + v_disty = _mm_srli_epi16(_mm_add_epi32(v_disty, v_fxy_r), 4); v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); v_disty = _mm_shufflehi_epi16(v_disty, _MM_SHUFFLE(2,2,0,0)); @@ -2357,8 +2445,8 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c int disty = (fy & 0x0000ffff) >> 8; *b = interpolate_4_pixels(tl, tr, bl, br, distx, disty); #else - int distx = (fx & 0x0000ffff) >> 12; - int disty = (fy & 0x0000ffff) >> 12; + int distx = ((fx & 0x0000ffff) + 0x0800) >> 12; + int disty = ((fy & 0x0000ffff) + 0x0800) >> 12; *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); #endif @@ -2423,7 +2511,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper const QSpanData *data, int y, int x, int length) { const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; - const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; + const QVector<QRgb> *clut = data->texture.colorTable; int image_width = data->texture.width; int image_height = data->texture.height; @@ -2479,9 +2567,9 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper int len2 = qMin(x, count - len1); ptr1 = fetch(buf1, s1, x, len1); - ptr1 = layout->convertToARGB32PM(buf1, ptr1, len1, layout, clut); + ptr1 = layout->convertToARGB32PM(buf1, ptr1, len1, clut, 0); ptr2 = fetch(buf2, s2, x, len1); - ptr2 = layout->convertToARGB32PM(buf2, ptr2, len1, layout, clut); + ptr2 = layout->convertToARGB32PM(buf2, ptr2, len1, clut, 0); for (int i = 0; i < len1; ++i) { uint t = ptr1[i]; uint b = ptr2[i]; @@ -2491,9 +2579,9 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper if (len2) { ptr1 = fetch(buf1 + len1, s1, 0, len2); - ptr1 = layout->convertToARGB32PM(buf1 + len1, ptr1, len2, layout, clut); + ptr1 = layout->convertToARGB32PM(buf1 + len1, ptr1, len2, clut, 0); ptr2 = fetch(buf2 + len1, s2, 0, len2); - ptr2 = layout->convertToARGB32PM(buf2 + len1, ptr2, len2, layout, clut); + ptr2 = layout->convertToARGB32PM(buf2 + len1, ptr2, len2, clut, 0); for (int i = 0; i < len2; ++i) { uint t = ptr1[i]; uint b = ptr2[i]; @@ -2512,9 +2600,9 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper int leading = start - x; ptr1 = fetch(buf1 + leading, s1, start, len); - ptr1 = layout->convertToARGB32PM(buf1 + leading, ptr1, len, layout, clut); + ptr1 = layout->convertToARGB32PM(buf1 + leading, ptr1, len, clut, 0); ptr2 = fetch(buf2 + leading, s2, start, len); - ptr2 = layout->convertToARGB32PM(buf2 + leading, ptr2, len, layout, clut); + ptr2 = layout->convertToARGB32PM(buf2 + leading, ptr2, len, clut, 0); for (int i = 0; i < len; ++i) { uint t = ptr1[i]; @@ -2576,8 +2664,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper fx += fdx; } - layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut); - layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut); + layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0); + layout->convertToARGB32PM(buf2, buf2, len * 2, clut, 0); if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { // scale up more than 8x int disty = (fy & 0x0000ffff) >> 8; @@ -2587,13 +2675,13 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper fracX += fdx; } } else { //scale down - int disty = (fy & 0x0000ffff) >> 12; + int disty = ((fy & 0x0000ffff) + 0x0800) >> 12; for (int i = 0; i < len; ++i) { uint tl = buf1[i * 2 + 0]; uint tr = buf1[i * 2 + 1]; uint bl = buf2[i * 2 + 0]; uint br = buf2[i * 2 + 1]; - int distx = (fracX & 0x0000ffff) >> 12; + int distx = ((fracX & 0x0000ffff) + 0x0800) >> 12; b[i] = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); fracX += fdx; } @@ -2638,8 +2726,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper fx += fdx; fy += fdy; } - layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut); - layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut); + layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0); + layout->convertToARGB32PM(buf2, buf2, len * 2, clut, 0); if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) { //if we are zooming more than 8 times, we use 8bit precision for the position. @@ -2659,8 +2747,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper uint bl = buf2[i * 2 + 0]; uint br = buf2[i * 2 + 1]; - int distx = (fracX & 0x0000ffff) >> 12; - int disty = (fracY & 0x0000ffff) >> 12; + int distx = ((fracX & 0x0000ffff) + 0x0800) >> 12; + int disty = ((fracY & 0x0000ffff) + 0x0800) >> 12; b[i] = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); fracX += fdx; @@ -2730,8 +2818,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper fw += fdw; } - layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut); - layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut); + layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0); + layout->convertToARGB32PM(buf2, buf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = distxs[i]; @@ -2752,7 +2840,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co const QSpanData *data, int y, int x, int length) { const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; - const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0; + const QVector<QRgb> *clut = data->texture.colorTable; int image_width = data->texture.width; int image_height = data->texture.height; @@ -2869,9 +2957,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fx += fdx; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut); + layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); if (disty) - layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut); + layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff); @@ -3007,8 +3095,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fx += fdx; fy += fdy; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut); - layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut); + layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff); @@ -3079,8 +3167,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co fw += fdw; } - layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut); - layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut); + layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0); + layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0); for (int i = 0; i < len; ++i) { int distx = distxs[i]; @@ -4038,7 +4126,7 @@ template<typename T> struct QBlendBase { typedef T BlendType; - QBlendBase(QSpanData *d, Operator o) + QBlendBase(QSpanData *d, const Operator &o) : data(d) , op(o) , dest(0) @@ -4057,7 +4145,7 @@ struct QBlendBase class BlendSrcGeneric : public QBlendBase<uint> { public: - BlendSrcGeneric(QSpanData *d, Operator o) + BlendSrcGeneric(QSpanData *d, const Operator &o) : QBlendBase<uint>(d, o) { } @@ -4083,7 +4171,7 @@ public: class BlendSrcGenericRGB64 : public QBlendBase<QRgba64> { public: - BlendSrcGenericRGB64(QSpanData *d, Operator o) + BlendSrcGenericRGB64(QSpanData *d, const Operator &o) : QBlendBase<QRgba64>(d, o) { } @@ -5764,7 +5852,7 @@ static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int *dst = qRgb(nr, ng, nb); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) Q_GUI_EXPORT bool qt_needs_a8_gamma_correction = false; static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb, const uint *gamma, const uchar *invgamma) @@ -5801,7 +5889,7 @@ static void qt_alphamapblit_uint32(QRasterBuffer *rasterBuffer, const quint32 c = color; const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables(); if (!tables) return; @@ -5828,7 +5916,7 @@ static void qt_alphamapblit_uint32(QRasterBuffer *rasterBuffer, } else if (coverage == 255) { dest[i] = c; } else { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && doGrayBlendPixel && qAlpha(dest[i]) == 255) { grayBlendPixel(dest+i, coverage, sr, sg, sb, gamma, invgamma); @@ -5869,7 +5957,7 @@ static void qt_alphamapblit_uint32(QRasterBuffer *rasterBuffer, } else if (coverage == 255) { dest[xp] = c; } else { -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && doGrayBlendPixel && qAlpha(dest[xp]) == 255) { grayBlendPixel(dest+xp, coverage, sr, sg, sb, gamma, invgamma); @@ -6327,7 +6415,7 @@ void qt_memfill32(quint32 *dest, quint32 color, int count) #endif #ifdef QT_COMPILER_SUPPORTS_SSE4_1 -template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); +template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *); #endif extern void qInitBlendFunctions(); @@ -6403,14 +6491,19 @@ static void qInitDrawhelperFunctions() #if defined(QT_COMPILER_SUPPORTS_SSE4_1) if (qCpuHasFeature(SSE4_1)) { #if !defined(__SSE4_1__) - extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); - extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); + extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count, + const QVector<QRgb> *, QDitherInfo *); + extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count, + const QVector<QRgb> *, QDitherInfo *); qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_sse4; qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_sse4; #endif - extern const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); - extern const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); - extern const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); + extern const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, + const QVector<QRgb> *, QDitherInfo *); + extern const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uint *src, int count, + const QVector<QRgb> *, QDitherInfo *); + extern const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *src, int count, + const QVector<QRgb> *, QDitherInfo *); qPixelLayouts[QImage::Format_ARGB32].convertFromARGB32PM = convertARGB32FromARGB32PM_sse4; qPixelLayouts[QImage::Format_RGBA8888].convertFromARGB32PM = convertRGBA8888FromARGB32PM_sse4; qPixelLayouts[QImage::Format_RGBX8888].convertFromARGB32PM = convertRGBXFromARGB32PM_sse4; @@ -6421,8 +6514,10 @@ static void qInitDrawhelperFunctions() #if defined(QT_COMPILER_SUPPORTS_AVX2) && !defined(__AVX2__) if (qCpuHasFeature(AVX2)) { - extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); - extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *); + extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count, + const QVector<QRgb> *, QDitherInfo *); + extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count, + const QVector<QRgb> *, QDitherInfo *); qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_avx2; qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_avx2; } diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp index e11536ebd0..35a975c972 100644 --- a/src/gui/painting/qdrawhelper_avx2.cpp +++ b/src/gui/painting/qdrawhelper_avx2.cpp @@ -44,13 +44,13 @@ QT_BEGIN_NAMESPACE const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { return qt_convertARGB32ToARGB32PM(buffer, src, count); } const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { return qt_convertRGBA8888ToARGB32PM(buffer, src, count); } diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 21af6039f8..922ff157e2 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qmath.h" #include "QtGui/qcolor.h" #include "QtGui/qpainter.h" @@ -1171,11 +1171,15 @@ inline int comp_func_Plus_one_pixel(uint d, const uint s) #undef MIX #undef AMIX -struct QPixelLayout; +struct QDitherInfo { + int x; + int y; +}; + typedef const uint *(QT_FASTCALL *ConvertFunc)(uint *buffer, const uint *src, int count, - const QPixelLayout *layout, const QRgb *clut); + const QVector<QRgb> *clut, QDitherInfo *dither); typedef const QRgba64 *(QT_FASTCALL *ConvertFunc64)(QRgba64 *buffer, const uint *src, int count, - const QPixelLayout *layout, const QRgb *clut); + const QVector<QRgb> *clut, QDitherInfo *dither); struct QPixelLayout { diff --git a/src/gui/painting/qdrawhelper_sse4.cpp b/src/gui/painting/qdrawhelper_sse4.cpp index a39cdb3127..257bad9eca 100644 --- a/src/gui/painting/qdrawhelper_sse4.cpp +++ b/src/gui/painting/qdrawhelper_sse4.cpp @@ -45,19 +45,19 @@ QT_BEGIN_NAMESPACE const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { return qt_convertARGB32ToARGB32PM(buffer, src, count); } const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { return qt_convertRGBA8888ToARGB32PM(buffer, src, count); } const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qUnpremultiply_sse4(src[i]); @@ -65,7 +65,7 @@ const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint } const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = ARGB2RGBA(qUnpremultiply_sse4(src[i])); @@ -73,7 +73,7 @@ const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uin } const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = ARGB2RGBA(0xff000000 | qUnpremultiply_sse4(src[i])); @@ -82,7 +82,7 @@ const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *s template<QtPixelOrder PixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) + const QVector<QRgb> *, QDitherInfo *) { for (int i = 0; i < count; ++i) buffer[i] = qConvertArgb32ToA2rgb30_sse4<PixelOrder>(src[i]); @@ -91,10 +91,10 @@ const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const ui template const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4<PixelOrderBGR>(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *); + const QVector<QRgb> *, QDitherInfo *); template const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4<PixelOrderRGB>(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *); + const QVector<QRgb> *, QDitherInfo *); QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h index 37be8b89a9..cefc213999 100644 --- a/src/gui/painting/qdrawhelper_x86_p.h +++ b/src/gui/painting/qdrawhelper_x86_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <private/qdrawhelper_p.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h index e16529e2d0..8799dff92a 100644 --- a/src/gui/painting/qdrawingprimitive_sse2_p.h +++ b/src/gui/painting/qdrawingprimitive_sse2_p.h @@ -40,6 +40,7 @@ #ifndef QDRAWINGPRIMITIVE_SSE2_P_H #define QDRAWINGPRIMITIVE_SSE2_P_H +#include <QtGui/private/qtguiglobal_p.h> #include <private/qsimd_p.h> #include "qdrawhelper_p.h" diff --git a/src/gui/painting/qemulationpaintengine_p.h b/src/gui/painting/qemulationpaintengine_p.h index f3cf88af17..457cc06d63 100644 --- a/src/gui/painting/qemulationpaintengine_p.h +++ b/src/gui/painting/qemulationpaintengine_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <private/qpaintengineex_p.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h index d2b6e51ab1..846592881c 100644 --- a/src/gui/painting/qfixed_p.h +++ b/src/gui/painting/qfixed_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qdebug.h" #include "QtCore/qpoint.h" #include "QtCore/qsize.h" diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index b28c8433cd..76bf61671c 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -40,6 +40,7 @@ #ifndef QMATRIX_H #define QMATRIX_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qpolygon.h> #include <QtGui/qregion.h> #include <QtGui/qwindowdefs.h> diff --git a/src/gui/painting/qmemrotate_p.h b/src/gui/painting/qmemrotate_p.h index 64cfb22517..62613d301a 100644 --- a/src/gui/painting/qmemrotate_p.h +++ b/src/gui/painting/qmemrotate_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qdrawhelper_p.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h index 47413d920c..71999fbdee 100644 --- a/src/gui/painting/qoutlinemapper_p.h +++ b/src/gui/painting/qoutlinemapper_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qrect.h> #include <QtGui/qtransform.h> diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h index 3aebbb7551..c516f6a963 100644 --- a/src/gui/painting/qpagedpaintdevice.h +++ b/src/gui/painting/qpagedpaintdevice.h @@ -40,6 +40,7 @@ #ifndef QPAGEDPAINTDEVICE_H #define QPAGEDPAINTDEVICE_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qpaintdevice.h> #include <QtGui/qpagelayout.h> diff --git a/src/gui/painting/qpagedpaintdevice_p.h b/src/gui/painting/qpagedpaintdevice_p.h index 028ab3b5af..a993ea4cac 100644 --- a/src/gui/painting/qpagedpaintdevice_p.h +++ b/src/gui/painting/qpagedpaintdevice_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qpagedpaintdevice.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qpagelayout.h b/src/gui/painting/qpagelayout.h index bd29165777..b41689d33b 100644 --- a/src/gui/painting/qpagelayout.h +++ b/src/gui/painting/qpagelayout.h @@ -40,6 +40,7 @@ #ifndef QPAGELAYOUT_H #define QPAGELAYOUT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qsharedpointer.h> #include <QtCore/qstring.h> #include <QtCore/qmargins.h> diff --git a/src/gui/painting/qpagesize.h b/src/gui/painting/qpagesize.h index 4916ddd4b5..82054824b4 100644 --- a/src/gui/painting/qpagesize.h +++ b/src/gui/painting/qpagesize.h @@ -40,6 +40,7 @@ #ifndef QPAGESIZE_H #define QPAGESIZE_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qsharedpointer.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index 5c9b966029..9458b4ba9a 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -40,6 +40,7 @@ #ifndef QPAINTDEVICE_H #define QPAINTDEVICE_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <QtCore/qrect.h> diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index a9da37b354..9fb67e253e 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -40,6 +40,7 @@ #ifndef QPAINTENGINE_H #define QPAINTENGINE_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qnamespace.h> #include <QtCore/qobjectdefs.h> #include <QtCore/qscopedpointer.h> diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index 81191d07b8..a50d1dfd73 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -312,7 +312,7 @@ void QBlitterPaintEnginePrivate::updateBrushState(QPainterState *s) { Qt::BrushStyle style = qbrush_style(s->brush); - caps.updateState(STATE_BRUSH_PATTERN, style > Qt::SolidPattern); + caps.updateState(STATE_BRUSH_PATTERN, style != Qt::SolidPattern); caps.updateState(STATE_BRUSH_ALPHA, qbrush_color(s->brush).alpha() < 255); } @@ -374,9 +374,8 @@ void QBlitterPaintEnginePrivate::fillRect(const QRectF &rect, const QColor &colo else pmData->blittable()->fillRect(targetRect & clipData->clipRect, color); } else if (clipData->hasRegionClip) { - QVector<QRect> rects = clipData->clipRegion.rects(); - for (int i = 0; i < rects.size(); ++i) { - QRect intersectRect = rects.at(i).intersected(targetRect.toRect()); + for (const QRect &rect : clipData->clipRegion) { + QRect intersectRect = rect.intersected(targetRect.toRect()); if (!intersectRect.isEmpty()) { unlock(); if (alpha) @@ -609,10 +608,8 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) } } else if (clipData->hasRegionClip) { QRect unclippedTargetRect(x, y, blitWidth, blitHeight); - const QVector<QRect> intersectedRects = clipData->clipRegion.intersected(unclippedTargetRect).rects(); - const int intersectedSize = intersectedRects.size(); - for (int i = 0; i < intersectedSize; ++i) { - const QRect &targetRect = intersectedRects.at(i); + const QRegion targetRegion = clipData->clipRegion.intersected(unclippedTargetRect); + for (const QRect &targetRect : targetRegion) { if (!targetRect.isValid() || targetRect.isEmpty()) continue; int tmpSrcX = srcX + (targetRect.x() - x); @@ -686,9 +683,8 @@ void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const Q if (clipData->hasRectClip) { d->clipAndDrawPixmap(clipData->clipRect, targetRect, pm, sr, canDrawOpacity); } else if (clipData->hasRegionClip) { - QVector<QRect>rects = clipData->clipRegion.rects(); - for (int i = 0; i<rects.size(); ++i) - d->clipAndDrawPixmap(rects.at(i), targetRect, pm, sr, canDrawOpacity); + for (const QRect &rect : clipData->clipRegion) + d->clipAndDrawPixmap(rect, targetRect, pm, sr, canDrawOpacity); } } else { QRectF deviceRect(0, 0, paintDevice()->width(), paintDevice()->height()); diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h index 3feabcf6fc..40f5347b26 100644 --- a/src/gui/painting/qpaintengine_blitter_p.h +++ b/src/gui/painting/qpaintengine_blitter_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qpaintengine_raster_p.h" #ifndef QT_NO_BLITTABLE diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h index c14f085721..1a1df547bb 100644 --- a/src/gui/painting/qpaintengine_p.h +++ b/src/gui/painting/qpaintengine_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qpainter.h" #include "QtGui/qpaintengine.h" #include "QtGui/qregion.h" diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 1afb119535..8cde88fa82 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qpaintengineex_p.h" #include "QtGui/qpainterpath.h" #include "private/qdatabuffer_p.h" diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index 643c39c80f..7c2c98140f 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qpaintengine.h> #include <private/qpaintengine_p.h> diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 2c5e0672b1..6472481e7a 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2834,7 +2834,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) QRect rect = r.boundingRect(); if (qt_show_painter_debug_output) printf("QPainter::setClipRegion(), size=%d, [%d,%d,%d,%d]\n", - r.rects().size(), rect.x(), rect.y(), rect.width(), rect.height()); + r.rectCount(), rect.x(), rect.y(), rect.width(), rect.height()); #endif if (!d->engine) { qWarning("QPainter::setClipRegion: Painter not active"); @@ -6477,6 +6477,8 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText extended->drawTextItem(QPointF(x, y), ti2); else engine->drawTextItem(QPointF(x, y), ti2); + drawTextItemDecoration(q, p, ti2.fontEngine, textEngine, ti2.underlineStyle, + ti2.flags, ti2.width.toReal(), ti2.charFormat); if (!rtl) x += ti2.width.toReal(); @@ -6508,6 +6510,8 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText extended->drawTextItem(QPointF(x, y), ti2); else engine->drawTextItem(QPointF(x,y), ti2); + drawTextItemDecoration(q, p, ti2.fontEngine, textEngine, ti2.underlineStyle, + ti2.flags, ti2.width.toReal(), ti2.charFormat); // reset the high byte for all glyphs const int hi = which << 24; @@ -6519,9 +6523,9 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText extended->drawTextItem(p, ti); else engine->drawTextItem(p, ti); + drawTextItemDecoration(q, p, ti.fontEngine, textEngine, ti.underlineStyle, + ti.flags, ti.width.toReal(), ti.charFormat); } - drawTextItemDecoration(q, p, ti.fontEngine, textEngine, ti.underlineStyle, - ti.flags, ti.width.toReal(), ti.charFormat); if (state->renderHints != oldRenderHints) { state->renderHints = oldRenderHints; diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 5743d97405..46817b9c73 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -40,6 +40,7 @@ #ifndef QPAINTER_H #define QPAINTER_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qnamespace.h> #include <QtCore/qrect.h> #include <QtCore/qpoint.h> diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 23ab5db7b4..2d44577310 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qbrush.h" #include "QtGui/qfont.h" #include "QtGui/qpen.h" diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 5b91266b64..7dbc83b338 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1294,10 +1294,9 @@ void QPainterPath::addRegion(const QRegion ®ion) ensureData(); detach(); - QVector<QRect> rects = region.rects(); - d_func()->elements.reserve(rects.size() * 5); - for (int i=0; i<rects.size(); ++i) - addRect(rects.at(i)); + d_func()->elements.reserve(region.rectCount() * 5); + for (const QRect &rect : region) + addRect(rect); } diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 882918fc87..131fcde8cc 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -40,6 +40,7 @@ #ifndef QPAINTERPATH_H #define QPAINTERPATH_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qmatrix.h> #include <QtCore/qglobal.h> #include <QtCore/qrect.h> diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h index e90cdb0f43..92d9a4ea66 100644 --- a/src/gui/painting/qpainterpath_p.h +++ b/src/gui/painting/qpainterpath_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qpainterpath.h" #include "QtGui/qregion.h" #include "QtCore/qlist.h" diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h index fe3ce84e4a..64e684e1ad 100644 --- a/src/gui/painting/qpathclipper_p.h +++ b/src/gui/painting/qpathclipper_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qpainterpath.h> #include <QtCore/qlist.h> diff --git a/src/gui/painting/qpathsimplifier_p.h b/src/gui/painting/qpathsimplifier_p.h index 47b1c3c623..6ef298f6bf 100644 --- a/src/gui/painting/qpathsimplifier_p.h +++ b/src/gui/painting/qpathsimplifier_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qpainterpath.h> #include <QtGui/private/qdatabuffer_p.h> #include <QtGui/private/qvectorpath_p.h> diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index d568dca6b9..34f1c51f6d 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1078,9 +1078,8 @@ void QPdfEngine::updateState(const QPaintEngineState &state) } else if (flags & DirtyClipRegion) { d->clipEnabled = true; QPainterPath path; - QVector<QRect> rects = state.clipRegion().rects(); - for (int i = 0; i < rects.size(); ++i) - path.addRect(rects.at(i)); + for (const QRect &rect : state.clipRegion()) + path.addRect(rect); updateClipPath(path, state.clipOperation()); flags |= DirtyClipPath; } else if (flags & DirtyClipEnabled) { diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index ef41f1efc1..cb1a91e09f 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #ifndef QT_NO_PDF diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index cf1da95bf1..baad274818 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -40,7 +40,7 @@ #ifndef QPDFWRITER_H #define QPDFWRITER_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_PDF diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h index 7469931a48..d8d99ba800 100644 --- a/src/gui/painting/qpen.h +++ b/src/gui/painting/qpen.h @@ -40,6 +40,7 @@ #ifndef QPEN_H #define QPEN_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qcolor.h> #include <QtGui/qbrush.h> diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 35cf1dae86..e2c5a82ffc 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -49,7 +49,7 @@ #include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLFunctions> #ifndef QT_NO_OPENGL -#include <QtGui/private/qopengltextureblitter_p.h> +#include <QtGui/qopengltextureblitter.h> #endif #include <qpa/qplatformgraphicsbuffer.h> #include <qpa/qplatformgraphicsbufferhelper.h> @@ -251,9 +251,8 @@ static QRegion deviceRegion(const QRegion ®ion, QWindow *window, const QPoint return region; QVector<QRect> rects; - const QVector<QRect> regionRects = region.rects(); - rects.reserve(regionRects.count()); - for (const QRect &rect : regionRects) + rects.reserve(region.rectCount()); + for (const QRect &rect : region) rects.append(deviceRect(rect.translated(offset), window)); QRegion deviceRegion; @@ -390,7 +389,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i if (textureId) { if (d_ptr->needsSwizzle) - d_ptr->blitter->setSwizzleRB(true); + d_ptr->blitter->setRedBlueSwizzle(true); // The backingstore is for the entire tlw. // In case of native children offset tells the position relative to the tlw. const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(offset), d_ptr->textureSize.height()); @@ -399,7 +398,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i origin); d_ptr->blitter->blit(textureId, QMatrix4x4(), source); if (d_ptr->needsSwizzle) - d_ptr->blitter->setSwizzleRB(false); + d_ptr->blitter->setRedBlueSwizzle(false); } // Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set. @@ -413,7 +412,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i context->swapBuffers(window); } - +#endif /*! Implemented in subclasses to return the content of the backingstore as a QImage. @@ -426,7 +425,7 @@ QImage QPlatformBackingStore::toImage() const { return QImage(); } - +#ifndef QT_NO_OPENGL /*! May be reimplemented in subclasses to return the content of the backingstore as an OpenGL texture. \a dirtyRegion is the part of the diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h index 9b09620cce..8d0e29ad8d 100644 --- a/src/gui/painting/qplatformbackingstore.h +++ b/src/gui/painting/qplatformbackingstore.h @@ -49,6 +49,7 @@ // source and binary incompatible with future versions of Qt. // +#include <QtGui/qtguiglobal.h> #include <QtCore/qrect.h> #include <QtCore/qobject.h> @@ -121,7 +122,9 @@ public: virtual void composeAndFlush(QWindow *window, const QRegion ®ion, const QPoint &offset, QPlatformTextureList *textures, QOpenGLContext *context, bool translucentBackground); +#endif virtual QImage toImage() const; +#ifndef QT_NO_OPENGL enum TextureFlag { TextureSwizzle = 0x01, TextureFlip = 0x02, diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp index d2203595c8..126b752811 100644 --- a/src/gui/painting/qpolygon.cpp +++ b/src/gui/painting/qpolygon.cpp @@ -443,14 +443,15 @@ void QPolygon::putPoints(int index, int nPoints, const QPolygon & from, int from QRect QPolygon::boundingRect() const { - if (isEmpty()) - return QRect(0, 0, 0, 0); const QPoint *pd = constData(); + const QPoint *pe = pd + size(); + if (pd == pe) + return QRect(0, 0, 0, 0); int minx, maxx, miny, maxy; minx = maxx = pd->x(); miny = maxy = pd->y(); ++pd; - for (int i = 1; i < size(); ++i) { + for (; pd != pe; ++pd) { if (pd->x() < minx) minx = pd->x(); else if (pd->x() > maxx) @@ -459,7 +460,6 @@ QRect QPolygon::boundingRect() const miny = pd->y(); else if (pd->y() > maxy) maxy = pd->y(); - ++pd; } return QRect(QPoint(minx,miny), QPoint(maxx,maxy)); } @@ -657,14 +657,15 @@ QPolygonF QPolygonF::translated(const QPointF &offset) const QRectF QPolygonF::boundingRect() const { - if (isEmpty()) - return QRectF(0, 0, 0, 0); const QPointF *pd = constData(); + const QPointF *pe = pd + size(); + if (pd == pe) + return QRectF(0, 0, 0, 0); qreal minx, maxx, miny, maxy; minx = maxx = pd->x(); miny = maxy = pd->y(); ++pd; - for (int i = 1; i < size(); ++i) { + while (pd != pe) { if (pd->x() < minx) minx = pd->x(); else if (pd->x() > maxx) diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h index 23bdd1933f..c57802e84e 100644 --- a/src/gui/painting/qpolygon.h +++ b/src/gui/painting/qpolygon.h @@ -40,6 +40,7 @@ #ifndef QPOLYGON_H #define QPOLYGON_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qvector.h> #include <QtCore/qpoint.h> #include <QtCore/qrect.h> diff --git a/src/gui/painting/qpolygonclipper_p.h b/src/gui/painting/qpolygonclipper_p.h index c67a692b52..04a31111c9 100644 --- a/src/gui/painting/qpolygonclipper_p.h +++ b/src/gui/painting/qpolygonclipper_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qdatabuffer_p.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qrasterizer_p.h b/src/gui/painting/qrasterizer_p.h index a3e12c076d..955577f4a3 100644 --- a/src/gui/painting/qrasterizer_p.h +++ b/src/gui/painting/qrasterizer_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qpainter.h" #include <private/qdrawhelper_p.h> diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 611e40e9aa..1ba6345bf9 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -81,8 +81,8 @@ QT_BEGIN_NAMESPACE contains() a QPoint or QRect. The bounding rectangle can be found with boundingRect(). - The function rects() gives a decomposition of the region into - rectangles. + Iteration over the region (with begin(), end()) gives a decomposition of + the region into rectangles. The same sequence of rectangles is returned by rects(). Example of using complex regions: \snippet code/src_gui_painting_qregion.cpp 0 @@ -395,23 +395,24 @@ void QRegion::exec(const QByteArray &buffer, int ver, QDataStream::ByteOrder byt QDataStream &operator<<(QDataStream &s, const QRegion &r) { - QVector<QRect> a = r.rects(); - if (a.isEmpty()) { + auto b = r.begin(), e = r.end(); + if (b == e) { s << (quint32)0; } else { + const auto size = e - b; if (s.version() == 1) { - int i; - for (i = a.size() - 1; i > 0; --i) { + for (auto i = size - 1; i > 0; --i) { s << (quint32)(12 + i * 24); s << (int)QRGN_OR; } - for (i = 0; i < a.size(); ++i) { - s << (quint32)(4+8) << (int)QRGN_SETRECT << a[i]; - } + for (auto it = b; it != e; ++it) + s << (quint32)(4+8) << (int)QRGN_SETRECT << *it; } else { - s << (quint32)(4 + 4 + 16 * a.size()); // 16: storage size of QRect + s << quint32(4 + 4 + 16 * size); // 16: storage size of QRect s << (qint32)QRGN_RECTS; - s << a; + s << quint32(size); + for (auto it = b; it != e; ++it) + s << *it; } } return s; @@ -722,12 +723,9 @@ bool QRegion::intersects(const QRegion ®ion) const if (rectCount() == 1 && region.rectCount() == 1) return true; - const QVector<QRect> myRects = rects(); - const QVector<QRect> otherRects = region.rects(); - - for (QVector<QRect>::const_iterator i1 = myRects.constBegin(); i1 < myRects.constEnd(); ++i1) - for (QVector<QRect>::const_iterator i2 = otherRects.constBegin(); i2 < otherRects.constEnd(); ++i2) - if (rect_intersects(*i1, *i2)) + for (const QRect &myRect : *this) + for (const QRect &otherRect : region) + if (rect_intersects(myRect, otherRect)) return true; return false; } @@ -928,6 +926,100 @@ QRegion QRegion::intersect(const QRect &r) const */ /*! + \typedef QRegion::const_iterator + \since 5.8 + + An iterator over the QRects that make up the region. + + QRegion does not offer mutable iterators. + + \sa begin(), end() +*/ + +/*! + \typedef QRegion::const_reverse_iterator + \since 5.8 + + A reverse iterator over the QRects that make up the region. + + QRegion does not offer mutable iterators. + + \sa rbegin(), rend() +*/ + +/*! + \fn QRegion::begin() const + \since 5.8 + + Returns a const_iterator pointing to the beginning of the range of + rectangles that make up this range, in the order in which rects() + returns them. + + \sa rbegin(), cbegin(), end() +*/ + +/*! + \fn QRegion::cbegin() const + \since 5.8 + + Same as begin(). +*/ + +/*! + \fn QRegion::end() const + \since 5.8 + + Returns a const_iterator pointing to one past the end of the range of + rectangles that make up this range, in the order in which rects() + returns them. + + \sa rend(), cend(), begin() +*/ + +/*! + \fn QRegion::cend() const + \since 5.8 + + Same as end(). +*/ + +/*! + \fn QRegion::rbegin() const + \since 5.8 + + Returns a const_reverse_iterator pointing to the beginning of the range of + rectangles that make up this range, in the reverse order in which rects() + returns them. + + \sa begin(), crbegin(), rend() +*/ + +/*! + \fn QRegion::crbegin() const + \since 5.8 + + Same as rbegin(). +*/ + +/*! + \fn QRegion::rend() const + \since 5.8 + + Returns a const_reverse_iterator pointing to one past the end of the range of + rectangles that make up this range, in the reverse order in which rects() + returns them. + + \sa end(), crend(), rbegin() +*/ + +/*! + \fn QRegion::crend() const + \since 5.8 + + Same as rend(). +*/ + +/*! \fn void QRegion::setRects(const QRect *rects, int number) Sets the region using the array of rectangles specified by \a rects and @@ -1065,13 +1157,11 @@ Q_GUI_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) return result; } - const QVector<QRect> rects = region.rects(); + auto rect = region.begin(); + const auto end = region.end(); QVarLengthArray<Segment> segments; - segments.resize(4 * rects.size()); - - const QRect *rect = rects.constData(); - const QRect *end = rect + rects.size(); + segments.resize(4 * (end - rect)); int lastRowSegmentCount = 0; Segment *lastRowSegments = 0; @@ -1179,6 +1269,12 @@ struct QRegionPrivate { } } + const QRect *begin() const Q_DECL_NOTHROW + { return numRects == 1 ? &extents : rects.data(); } // avoid vectorize() + + const QRect *end() const Q_DECL_NOTHROW + { return begin() + numRects; } + inline void append(const QRect *r); void append(const QRegionPrivate *r); void prepend(const QRect *r); @@ -4200,7 +4296,7 @@ QRegion QRegion::xored(const QRegion &r) const } } -QRect QRegion::boundingRect() const +QRect QRegion::boundingRect() const Q_DECL_NOTHROW { if (isEmpty()) return QRect(); @@ -4256,6 +4352,16 @@ QVector<QRect> QRegion::rects() const } } +QRegion::const_iterator QRegion::begin() const Q_DECL_NOTHROW +{ + return d->qt_rgn ? d->qt_rgn->begin() : nullptr; +} + +QRegion::const_iterator QRegion::end() const Q_DECL_NOTHROW +{ + return d->qt_rgn ? d->qt_rgn->end() : nullptr; +} + void QRegion::setRects(const QRect *rects, int num) { *this = QRegion(); @@ -4288,7 +4394,7 @@ void QRegion::setRects(const QRect *rects, int num) } } -int QRegion::rectCount() const +int QRegion::rectCount() const Q_DECL_NOTHROW { return (d->qt_rgn ? d->qt_rgn->numRects : 0); } @@ -4318,10 +4424,10 @@ bool QRegion::intersects(const QRect &rect) const if (d->qt_rgn->numRects == 1) return true; - const QVector<QRect> myRects = rects(); - for (QVector<QRect>::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it) - if (rect_intersects(r, *it)) + for (const QRect &rect : *this) { + if (rect_intersects(r, rect)) return true; + } return false; } diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index d66f80fcde..4f0a071da8 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -40,6 +40,7 @@ #ifndef QREGION_H #define QREGION_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qatomic.h> #include <QtCore/qrect.h> #include <QtGui/qwindowdefs.h> @@ -81,6 +82,18 @@ public: bool isEmpty() const; bool isNull() const; + typedef const QRect *const_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + + const_iterator begin() const Q_DECL_NOTHROW; + const_iterator cbegin() const Q_DECL_NOTHROW { return begin(); } + const_iterator end() const Q_DECL_NOTHROW; + const_iterator cend() const Q_DECL_NOTHROW { return end(); } + const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return rbegin(); } + const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const Q_DECL_NOTHROW { return rend(); } + bool contains(const QPoint &p) const; bool contains(const QRect &r) const; @@ -108,10 +121,10 @@ public: bool intersects(const QRegion &r) const; bool intersects(const QRect &r) const; - QRect boundingRect() const; + QRect boundingRect() const Q_DECL_NOTHROW; QVector<QRect> rects() const; void setRects(const QRect *rect, int num); - int rectCount() const; + int rectCount() const Q_DECL_NOTHROW; #ifdef Q_COMPILER_MANGLES_RETURN_TYPE // ### Qt 6: remove these, they're kept for MSVC compat const QRegion operator|(const QRegion &r) const; @@ -165,6 +178,7 @@ Q_GUI_EXPORT static const struct QRegionData shared_empty; static void cleanUp(QRegionData *x); }; +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QRegion) /***************************************************************************** QRegion stream functions diff --git a/src/gui/painting/qrgb.h b/src/gui/painting/qrgb.h index 6e666025ac..fe8306109b 100644 --- a/src/gui/painting/qrgb.h +++ b/src/gui/painting/qrgb.h @@ -40,7 +40,7 @@ #ifndef QRGB_H #define QRGB_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qprocessordetection.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h index 27e1e6e06d..a3ae0c9b14 100644 --- a/src/gui/painting/qrgba64.h +++ b/src/gui/painting/qrgba64.h @@ -40,7 +40,7 @@ #ifndef QRGBA64_H #define QRGBA64_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qprocessordetection.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/painting/qrgba64_p.h b/src/gui/painting/qrgba64_p.h index cf3dad5f90..0dadc038fa 100644 --- a/src/gui/painting/qrgba64_p.h +++ b/src/gui/painting/qrgba64_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qrgba64.h> #include <QtGui/private/qdrawhelper_p.h> #include <private/qsimd_p.h> @@ -72,27 +73,49 @@ inline QRgba64 multiplyAlpha256(QRgba64 rgba64, uint alpha256) inline QRgba64 multiplyAlpha65535(QRgba64 rgba64, uint alpha65535) { + return QRgba64::fromRgba64(qt_div_65535(rgba64.red() * alpha65535), + qt_div_65535(rgba64.green() * alpha65535), + qt_div_65535(rgba64.blue() * alpha65535), + qt_div_65535(rgba64.alpha() * alpha65535)); +} + #ifdef __SSE2__ - const __m128i va = _mm_shufflelo_epi16(_mm_cvtsi32_si128(alpha65535), _MM_SHUFFLE(0, 0, 0, 0)); - __m128i vs = _mm_loadl_epi64((__m128i*)&rgba64); +Q_ALWAYS_INLINE __m128i multiplyAlpha65535(__m128i rgba64, __m128i va) +{ + __m128i vs = rgba64; vs = _mm_unpacklo_epi16(_mm_mullo_epi16(vs, va), _mm_mulhi_epu16(vs, va)); vs = _mm_add_epi32(vs, _mm_srli_epi32(vs, 16)); vs = _mm_add_epi32(vs, _mm_set1_epi32(0x8000)); vs = _mm_srai_epi32(vs, 16); vs = _mm_packs_epi32(vs, _mm_setzero_si128()); - _mm_storel_epi64((__m128i*)&rgba64, vs); - return rgba64; -#else - return QRgba64::fromRgba64(qt_div_65535(rgba64.red() * alpha65535), - qt_div_65535(rgba64.green() * alpha65535), - qt_div_65535(rgba64.blue() * alpha65535), - qt_div_65535(rgba64.alpha() * alpha65535)); + return vs; +} +Q_ALWAYS_INLINE __m128i multiplyAlpha65535(__m128i rgba64, uint alpha65535) +{ + const __m128i va = _mm_shufflelo_epi16(_mm_cvtsi32_si128(alpha65535), _MM_SHUFFLE(0, 0, 0, 0)); + return multiplyAlpha65535(rgba64, va); +} #endif + +#if defined(__ARM_NEON__) +Q_ALWAYS_INLINE uint16x4_t multiplyAlpha65535(uint16x4_t rgba64, uint16x4_t alpha65535) +{ + uint32x4_t vs32 = vmull_u16(rgba64, alpha65535); // vs = vs * alpha + vs32 = vsraq_n_u32(vs32, vs32, 16); // vs = vs + (vs >> 16) + return vrshrn_n_u32(vs32, 16); // vs = (vs + 0x8000) >> 16 } +Q_ALWAYS_INLINE uint16x4_t multiplyAlpha65535(uint16x4_t rgba64, uint alpha65535) +{ + uint32x4_t vs32 = vmull_n_u16(rgba64, alpha65535); // vs = vs * alpha + vs32 = vsraq_n_u32(vs32, vs32, 16); // vs = vs + (vs >> 16) + return vrshrn_n_u32(vs32, 16); // vs = (vs + 0x8000) >> 16 +} +#endif -inline QRgba64 multiplyAlpha255(QRgba64 rgba64, uint alpha255) +template<typename T> +inline T multiplyAlpha255(T rgba64, uint alpha255) { -#ifdef __SSE2__ +#if defined(__SSE2__) || defined(__ARM_NEON__) return multiplyAlpha65535(rgba64, alpha255 * 257); #else return QRgba64::fromRgba64(qt_div_255(rgba64.red() * alpha255), @@ -112,25 +135,69 @@ inline QRgba64 interpolate255(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2) return QRgba64::fromRgba64(multiplyAlpha255(x, alpha1) + multiplyAlpha255(y, alpha2)); } +#if defined __SSE2__ +Q_ALWAYS_INLINE __m128i interpolate255(__m128i x, uint alpha1, __m128i y, uint alpha2) +{ + return _mm_add_epi32(multiplyAlpha255(x, alpha1), multiplyAlpha255(y, alpha2)); +} +#endif + +#if defined __ARM_NEON__ +Q_ALWAYS_INLINE uint16x4_t interpolate255(uint16x4_t x, uint alpha1, uint16x4_t y, uint alpha2) +{ + return vadd_u16(multiplyAlpha255(x, alpha1), multiplyAlpha255(y, alpha2)); +} +#endif + inline QRgba64 interpolate65535(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2) { return QRgba64::fromRgba64(multiplyAlpha65535(x, alpha1) + multiplyAlpha65535(y, alpha2)); } +#if defined __SSE2__ +Q_ALWAYS_INLINE __m128i interpolate65535(__m128i x, uint alpha1, __m128i y, uint alpha2) +{ + return _mm_add_epi32(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2)); +} +// alpha2 below is const-ref because otherwise MSVC2013 complains that it can't 16-byte align the argument. +Q_ALWAYS_INLINE __m128i interpolate65535(__m128i x, __m128i alpha1, __m128i y, const __m128i &alpha2) +{ + return _mm_add_epi32(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2)); +} +#endif + +#if defined __ARM_NEON__ +Q_ALWAYS_INLINE uint16x4_t interpolate65535(uint16x4_t x, uint alpha1, uint16x4_t y, uint alpha2) +{ + return vadd_u16(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2)); +} +Q_ALWAYS_INLINE uint16x4_t interpolate65535(uint16x4_t x, uint16x4_t alpha1, uint16x4_t y, uint16x4_t alpha2) +{ + return vadd_u16(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2)); +} +#endif + inline QRgba64 addWithSaturation(QRgba64 a, QRgba64 b) { -#if defined(__SSE2__) && defined(Q_PROCESSOR_X86_64) - __m128i va = _mm_cvtsi64_si128((quint64)a); - __m128i vb = _mm_cvtsi64_si128((quint64)b); - va = _mm_adds_epu16(va, vb); - return QRgba64::fromRgba64(_mm_cvtsi128_si64(va)); -#else return QRgba64::fromRgba64(qMin(a.red() + b.red(), 65535), qMin(a.green() + b.green(), 65535), qMin(a.blue() + b.blue(), 65535), qMin(a.alpha() + b.alpha(), 65535)); +} + +#if defined(__SSE2__) +Q_ALWAYS_INLINE __m128i addWithSaturation(__m128i a, __m128i b) +{ + return _mm_adds_epu16(a, b); +} #endif + +#if defined(__ARM_NEON__) +Q_ALWAYS_INLINE uint16x4_t addWithSaturation(uint16x4_t a, uint16x4_t b) +{ + return vqmovn_u32(vaddl_u16(a, b)); } +#endif QT_END_NAMESPACE diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h index e17e68b237..ededb5d80b 100644 --- a/src/gui/painting/qstroker_p.h +++ b/src/gui/painting/qstroker_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qpainterpath.h" #include "private/qdatabuffer_p.h" #include "private/qnumeric_p.h" diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index d2c3eceeef..86a53c21a3 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -42,7 +42,6 @@ #include "qtextureglyphcache_p.h" #include "private/qfontengine_p.h" #include "private/qnumeric_p.h" -#include "private/qnativeimage_p.h" QT_BEGIN_NAMESPACE @@ -247,6 +246,7 @@ void QTextureGlyphCache::fillInPendingGlyphs() resizeCache(qNextPowerOfTwo(requiredWidth - 1), qNextPowerOfTwo(requiredHeight - 1)); } + beginFillTexture(); { QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin(); while (iter != m_pendingGlyphs.end()) { @@ -256,6 +256,7 @@ void QTextureGlyphCache::fillInPendingGlyphs() ++iter; } } + endFillTexture(); m_pendingGlyphs.clear(); } diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index 14271ccc65..25253b496a 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qhash.h> #include <qimage.h> #include <qobject.h> @@ -117,7 +118,9 @@ public: virtual void resizeTextureData(int width, int height) = 0; virtual int glyphPadding() const { return 0; } + virtual void beginFillTexture() { } virtual void fillTexture(const Coord &coord, glyph_t glyph, QFixed subPixelPosition) = 0; + virtual void endFillTexture() { } inline void createCache(int width, int height) { m_w = width; diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 470a5565e1..2aea19eca0 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -39,6 +39,7 @@ #ifndef QTRANSFORM_H #define QTRANSFORM_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qmatrix.h> #include <QtGui/qpainterpath.h> #include <QtGui/qpolygon.h> diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h index 01f7418930..d1b08ed423 100644 --- a/src/gui/painting/qvectorpath_p.h +++ b/src/gui/painting/qvectorpath_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qpaintengine.h> #include <private/qpaintengine_p.h> diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp index ff2497817e..2278378613 100644 --- a/src/gui/text/qabstracttextdocumentlayout.cpp +++ b/src/gui/text/qabstracttextdocumentlayout.cpp @@ -602,9 +602,32 @@ QTextDocument *QAbstractTextDocumentLayout::document() const */ QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const { + QTextCharFormat fmt = formatAt(pos).toCharFormat(); + return fmt.anchorHref(); +} + +/*! + \since 5.8 + + Returns the source of the image at the given position \a pos, or an empty + string if no image exists at that point. +*/ +QString QAbstractTextDocumentLayout::imageAt(const QPointF &pos) const +{ + QTextImageFormat fmt = formatAt(pos).toImageFormat(); + return fmt.name(); +} + +/*! + \since 5.8 + + Returns the text format at the given position \a pos. +*/ +QTextFormat QAbstractTextDocumentLayout::formatAt(const QPointF &pos) const +{ int cursorPos = hitTest(pos, Qt::ExactHit); if (cursorPos == -1) - return QString(); + return QTextFormat(); // compensate for preedit in the hit text block QTextBlock block = document()->firstBlock(); @@ -623,8 +646,7 @@ QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle(); QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); - QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); - return fmt.anchorHref(); + return pieceTable->formatCollection()->format(it->format); } /*! diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h index 01704fe37b..438ad6e70b 100644 --- a/src/gui/text/qabstracttextdocumentlayout.h +++ b/src/gui/text/qabstracttextdocumentlayout.h @@ -40,6 +40,7 @@ #ifndef QABSTRACTTEXTDOCUMENTLAYOUT_H #define QABSTRACTTEXTDOCUMENTLAYOUT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtGui/qtextlayout.h> #include <QtGui/qtextdocument.h> @@ -82,7 +83,10 @@ public: virtual void draw(QPainter *painter, const PaintContext &context) = 0; virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const = 0; + QString anchorAt(const QPointF& pos) const; + QString imageAt(const QPointF &pos) const; + QTextFormat formatAt(const QPointF &pos) const; virtual int pageCount() const = 0; virtual QSizeF documentSize() const = 0; diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h index fc39d8ec5c..191c463dc6 100644 --- a/src/gui/text/qabstracttextdocumentlayout_p.h +++ b/src/gui/text/qabstracttextdocumentlayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qobject_p.h" #include "QtCore/qhash.h" diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index c237d80d34..72c5d5ff33 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -900,7 +900,7 @@ static QBrush brushFromData(const BrushData& c, const QPalette &pal) } } -static BorderStyle parseStyleValue(QCss::Value v) +static BorderStyle parseStyleValue(const QCss::Value &v) { if (v.type == Value::KnownIdentifier) { switch (v.variant.toInt()) { @@ -1867,12 +1867,15 @@ bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node) do { match = basicSelectorMatches(sel, node); if (!match) { - if (sel.relationToNext == BasicSelector::MatchNextSelectorIfParent - || i == selector.basicSelectors.count() - 1) // first element must always match! + if (i == selector.basicSelectors.count() - 1) // first element must always match! + break; + if (sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor && + sel.relationToNext != BasicSelector::MatchNextSelectorIfIndirectAdjecent) break; } - if (match || sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor) + if (match || (sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor && + sel.relationToNext != BasicSelector::MatchNextSelectorIfIndirectAdjecent)) --i; if (i < 0) @@ -1885,16 +1888,18 @@ bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node) NodePtr nextParent = parentNode(node); freeNode(node); node = nextParent; - } else if (sel.relationToNext == BasicSelector::MatchNextSelectorIfPreceeds) { + } else if (sel.relationToNext == BasicSelector::MatchNextSelectorIfDirectAdjecent + || sel.relationToNext == BasicSelector::MatchNextSelectorIfIndirectAdjecent) { NodePtr previousSibling = previousSiblingNode(node); freeNode(node); node = previousSibling; - } + } if (isNullNode(node)) { match = false; break; } - } while (i >= 0 && (match || sel.relationToNext == BasicSelector::MatchNextSelectorIfAncestor)); + } while (i >= 0 && (match || sel.relationToNext == BasicSelector::MatchNextSelectorIfAncestor + || sel.relationToNext == BasicSelector::MatchNextSelectorIfIndirectAdjecent)); freeNode(node); @@ -1914,18 +1919,38 @@ bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node) if (attrValue.isNull()) return false; - if (a.valueMatchCriterium == QCss::AttributeSelector::MatchContains) { + switch (a.valueMatchCriterium) { + case QCss::AttributeSelector::NoMatch: + break; + case QCss::AttributeSelector::MatchEqual: + if (attrValue != a.value) + return false; + break; + case QCss::AttributeSelector::MatchIncludes: { const auto lst = attrValue.splitRef(QLatin1Char(' ')); if (!lst.contains(QStringRef(&a.value))) return false; - } else if ( - (a.valueMatchCriterium == QCss::AttributeSelector::MatchEqual - && attrValue != a.value) - || - (a.valueMatchCriterium == QCss::AttributeSelector::MatchBeginsWith - && !attrValue.startsWith(a.value)) - ) - return false; + break; + } + case QCss::AttributeSelector::MatchDashMatch: { + const QString dashPrefix = a.value + QLatin1Char('-'); + if (attrValue != a.value && !attrValue.startsWith(dashPrefix)) + return false; + break; + } + case QCss::AttributeSelector::MatchBeginsWith: + if (!attrValue.startsWith(a.value)) + return false; + break; + case QCss::AttributeSelector::MatchEndsWith: + if (!attrValue.endsWith(a.value)) + return false; + break; + case QCss::AttributeSelector::MatchContains: + if (!attrValue.contains(a.value)) + return false; + break; + } } } @@ -2336,9 +2361,11 @@ bool Parser::parseCombinator(BasicSelector::Relation *relation) prev(); } if (test(PLUS)) { - *relation = BasicSelector::MatchNextSelectorIfPreceeds; + *relation = BasicSelector::MatchNextSelectorIfDirectAdjecent; } else if (test(GREATER)) { *relation = BasicSelector::MatchNextSelectorIfParent; + } else if (test(TILDE)) { + *relation = BasicSelector::MatchNextSelectorIfIndirectAdjecent; } skipSpace(); return true; @@ -2439,7 +2466,7 @@ bool Parser::parseSimpleSelector(BasicSelector *basicSel) onceMore = true; AttributeSelector a; a.name = QLatin1String("class"); - a.valueMatchCriterium = AttributeSelector::MatchContains; + a.valueMatchCriterium = AttributeSelector::MatchIncludes; if (!parseClass(&a.value)) return false; basicSel->attributeSelectors.append(a); } else if (testAttrib()) { @@ -2485,9 +2512,15 @@ bool Parser::parseAttrib(AttributeSelector *attr) if (test(EQUAL)) { attr->valueMatchCriterium = AttributeSelector::MatchEqual; } else if (test(INCLUDES)) { - attr->valueMatchCriterium = AttributeSelector::MatchContains; + attr->valueMatchCriterium = AttributeSelector::MatchIncludes; } else if (test(DASHMATCH)) { + attr->valueMatchCriterium = AttributeSelector::MatchDashMatch; + } else if (test(BEGINSWITH)) { attr->valueMatchCriterium = AttributeSelector::MatchBeginsWith; + } else if (test(ENDSWITH)) { + attr->valueMatchCriterium = AttributeSelector::MatchEndsWith; + } else if (test(CONTAINS)) { + attr->valueMatchCriterium = AttributeSelector::MatchContains; } else { return next(RBRACKET); } diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h index 4da7b62dba..f5cd5395b2 100644 --- a/src/gui/text/qcssparser_p.h +++ b/src/gui/text/qcssparser_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/QStringList> #include <QtCore/QVector> #include <QtCore/QVariant> @@ -538,8 +539,11 @@ struct AttributeSelector enum ValueMatchType { NoMatch, MatchEqual, - MatchContains, - MatchBeginsWith + MatchIncludes, + MatchDashMatch, + MatchBeginsWith, + MatchEndsWith, + MatchContains }; inline AttributeSelector() : valueMatchCriterium(NoMatch) {} @@ -557,7 +561,8 @@ struct BasicSelector NoRelation, MatchNextSelectorIfAncestor, MatchNextSelectorIfParent, - MatchNextSelectorIfPreceeds + MatchNextSelectorIfDirectAdjecent, + MatchNextSelectorIfIndirectAdjecent, }; QString elementName; @@ -678,11 +683,15 @@ enum TokenType { CDC, INCLUDES, DASHMATCH, + BEGINSWITH, + ENDSWITH, + CONTAINS, LBRACE, PLUS, GREATER, COMMA, + TILDE, STRING, INVALID, @@ -782,7 +791,7 @@ public: inline bool testImport() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("import")); } inline bool testMedia() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("media")); } inline bool testPage() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("page")); } - inline bool testCombinator() { return test(PLUS) || test(GREATER) || test(S); } + inline bool testCombinator() { return test(PLUS) || test(GREATER) || test(TILDE) || test(S); } inline bool testProperty() { return test(IDENT); } bool testTerm(); inline bool testExpr() { return testTerm(); } diff --git a/src/gui/text/qcssscanner.cpp b/src/gui/text/qcssscanner.cpp index f6b25d50ba..33dc01c8bc 100644 --- a/src/gui/text/qcssscanner.cpp +++ b/src/gui/text/qcssscanner.cpp @@ -88,8 +88,10 @@ int QCssScanner_Generated::lex() goto state_3; if (ch.unicode() == 35) goto state_4; - if (ch.unicode() == 39) + if (ch.unicode() == 36) goto state_5; + if (ch.unicode() == 39) + goto state_6; if (ch.unicode() == 40) { token = QCss::LPAREN; goto found; @@ -98,22 +100,20 @@ int QCssScanner_Generated::lex() token = QCss::RPAREN; goto found; } - if (ch.unicode() == 42) { - token = QCss::STAR; - goto found; - } - if (ch.unicode() == 43) + if (ch.unicode() == 42) goto state_9; - if (ch.unicode() == 44) + if (ch.unicode() == 43) goto state_10; - if (ch.unicode() == 45) + if (ch.unicode() == 44) goto state_11; - if (ch.unicode() == 46) + if (ch.unicode() == 45) goto state_12; - if (ch.unicode() == 47) + if (ch.unicode() == 46) goto state_13; - if (ch.unicode() >= 48 && ch.unicode() <= 57) + if (ch.unicode() == 47) goto state_14; + if (ch.unicode() >= 48 && ch.unicode() <= 57) + goto state_15; if (ch.unicode() == 58) { token = QCss::COLON; goto found; @@ -123,147 +123,167 @@ int QCssScanner_Generated::lex() goto found; } if (ch.unicode() == 60) - goto state_17; + goto state_18; if (ch.unicode() == 61) { token = QCss::EQUAL; goto found; } if (ch.unicode() == 62) - goto state_19; - if (ch.unicode() == 64) goto state_20; + if (ch.unicode() == 64) + goto state_21; if (ch.unicode() == 91) { token = QCss::LBRACKET; goto found; } if (ch.unicode() == 92) - goto state_22; + goto state_23; if (ch.unicode() == 93) { token = QCss::RBRACKET; goto found; } + if (ch.unicode() == 94) + goto state_25; if (ch.unicode() == 95) - goto state_24; + goto state_26; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_24; + goto state_26; if (ch.unicode() == 123) - goto state_25; + goto state_27; if (ch.unicode() == 124) - goto state_26; + goto state_28; if (ch.unicode() == 125) { token = QCss::RBRACE; goto found; } if (ch.unicode() == 126) - goto state_28; + goto state_30; goto out; state_1: lastAcceptingPos = pos; token = QCss::S; ch = next(); if (ch.unicode() >= 9 && ch.unicode() <= 10) - goto state_29; + goto state_31; if (ch.unicode() >= 12 && ch.unicode() <= 13) - goto state_29; + goto state_31; if (ch.unicode() == 32) - goto state_29; + goto state_31; if (ch.unicode() == 43) - goto state_9; - if (ch.unicode() == 44) goto state_10; + if (ch.unicode() == 44) + goto state_11; if (ch.unicode() == 62) - goto state_19; + goto state_20; if (ch.unicode() == 123) - goto state_25; + goto state_27; + if (ch.unicode() == 126) + goto state_32; goto out; state_3: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; state_4: ch = next(); if (ch.unicode() == 45) - goto state_33; + goto state_36; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_33; + goto state_36; if (ch.unicode() == 92) - goto state_34; + goto state_37; if (ch.unicode() == 95) - goto state_33; + goto state_36; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_33; + goto state_36; goto out; state_5: + ch = next(); + if (ch.unicode() == 61) { + token = QCss::ENDSWITH; + goto found; + } + goto out; + state_6: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; state_9: lastAcceptingPos = pos; - token = QCss::PLUS; + token = QCss::STAR; + ch = next(); + if (ch.unicode() == 61) { + token = QCss::CONTAINS; + goto found; + } goto out; state_10: lastAcceptingPos = pos; - token = QCss::COMMA; + token = QCss::PLUS; goto out; state_11: lastAcceptingPos = pos; + token = QCss::COMMA; + goto out; + state_12: + lastAcceptingPos = pos; token = QCss::MINUS; ch = next(); if (ch.unicode() == 45) - goto state_38; + goto state_43; if (ch.unicode() == 92) - goto state_22; + goto state_23; if (ch.unicode() == 95) - goto state_24; + goto state_26; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_24; + goto state_26; goto out; - state_12: + state_13: lastAcceptingPos = pos; token = QCss::DOT; ch = next(); if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_39; + goto state_44; goto out; - state_13: + state_14: lastAcceptingPos = pos; token = QCss::SLASH; ch = next(); @@ -272,80 +292,87 @@ int QCssScanner_Generated::lex() goto found; } goto out; - state_14: + state_15: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) - goto state_41; + goto state_46; if (ch.unicode() == 45) - goto state_42; + goto state_47; if (ch.unicode() == 46) - goto state_43; + goto state_48; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_44; + goto state_49; if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_17: + state_18: ch = next(); if (ch.unicode() == 33) - goto state_47; + goto state_52; goto out; - state_19: + state_20: lastAcceptingPos = pos; token = QCss::GREATER; goto out; - state_20: + state_21: ch = next(); if (ch.unicode() == 45) - goto state_48; + goto state_53; if (ch.unicode() == 92) - goto state_49; + goto state_54; if (ch.unicode() == 95) - goto state_50; + goto state_55; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_50; + goto state_55; goto out; - state_22: + state_23: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_51; + goto state_56; if (ch.unicode() == 11) - goto state_51; + goto state_56; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_51; + goto state_56; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_51; + goto state_56; if (ch.unicode() >= 103) - goto state_51; + goto state_56; + goto out; + state_25: + ch = next(); + if (ch.unicode() == 61) { + token = QCss::BEGINSWITH; + goto found; + } goto out; - state_24: + state_26: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_52; + goto state_58; if (ch.unicode() == 45) - goto state_53; + goto state_59; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_53; + goto state_59; if (ch.unicode() == 92) - goto state_54; + goto state_60; if (ch.unicode() == 95) - goto state_53; + goto state_59; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_53; + goto state_59; goto out; - state_25: + state_27: lastAcceptingPos = pos; token = QCss::LBRACE; goto out; - state_26: + state_28: lastAcceptingPos = pos; token = QCss::OR; ch = next(); @@ -354,782 +381,790 @@ int QCssScanner_Generated::lex() goto found; } goto out; - state_28: + state_30: + lastAcceptingPos = pos; + token = QCss::TILDE; ch = next(); if (ch.unicode() == 61) { token = QCss::INCLUDES; goto found; } goto out; - state_29: + state_31: lastAcceptingPos = pos; token = QCss::S; ch = next(); if (ch.unicode() >= 9 && ch.unicode() <= 10) - goto state_29; + goto state_31; if (ch.unicode() >= 12 && ch.unicode() <= 13) - goto state_29; + goto state_31; if (ch.unicode() == 32) - goto state_29; + goto state_31; if (ch.unicode() == 43) - goto state_9; - if (ch.unicode() == 44) goto state_10; + if (ch.unicode() == 44) + goto state_11; if (ch.unicode() == 62) - goto state_19; + goto state_20; if (ch.unicode() == 123) - goto state_25; + goto state_27; + if (ch.unicode() == 126) + goto state_32; goto out; - state_30: + state_32: + lastAcceptingPos = pos; + token = QCss::TILDE; + goto out; + state_33: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_31: + state_34: lastAcceptingPos = pos; token = QCss::STRING; goto out; - state_32: + state_35: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_57; + goto state_63; if (ch.unicode() == 10) - goto state_58; + goto state_64; if (ch.unicode() == 11) - goto state_57; + goto state_63; if (ch.unicode() == 12) - goto state_59; + goto state_65; if (ch.unicode() == 13) - goto state_60; + goto state_66; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_57; + goto state_63; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_57; + goto state_63; if (ch.unicode() >= 103) - goto state_57; + goto state_63; goto out; - state_33: + state_36: lastAcceptingPos = pos; token = QCss::HASH; ch = next(); if (ch.unicode() == 45) - goto state_61; + goto state_67; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_61; + goto state_67; if (ch.unicode() == 92) - goto state_62; + goto state_68; if (ch.unicode() == 95) - goto state_61; + goto state_67; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_61; + goto state_67; goto out; - state_34: + state_37: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_63; + goto state_69; if (ch.unicode() == 11) - goto state_63; + goto state_69; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_63; + goto state_69; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_63; + goto state_69; if (ch.unicode() >= 103) - goto state_63; + goto state_69; goto out; - state_35: + state_39: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_36: + state_40: lastAcceptingPos = pos; token = QCss::STRING; goto out; - state_37: + state_41: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_64; + goto state_70; if (ch.unicode() == 10) - goto state_65; + goto state_71; if (ch.unicode() == 11) - goto state_64; + goto state_70; if (ch.unicode() == 12) - goto state_66; + goto state_72; if (ch.unicode() == 13) - goto state_67; + goto state_73; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_64; + goto state_70; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_64; + goto state_70; if (ch.unicode() >= 103) - goto state_64; + goto state_70; goto out; - state_38: + state_43: ch = next(); if (ch.unicode() == 62) { token = QCss::CDC; goto found; } goto out; - state_39: + state_44: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) - goto state_41; + goto state_46; if (ch.unicode() == 45) - goto state_42; + goto state_47; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_69; + goto state_75; if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_41: + state_46: lastAcceptingPos = pos; token = QCss::PERCENTAGE; goto out; - state_42: + state_47: ch = next(); if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_43: + state_48: ch = next(); if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_39; + goto state_44; goto out; - state_44: + state_49: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) - goto state_41; + goto state_46; if (ch.unicode() == 45) - goto state_42; + goto state_47; if (ch.unicode() == 46) - goto state_43; + goto state_48; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_44; + goto state_49; if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_45: + state_50: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_70; + goto state_76; if (ch.unicode() == 11) - goto state_70; + goto state_76; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_70; + goto state_76; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_70; + goto state_76; if (ch.unicode() >= 103) - goto state_70; + goto state_76; goto out; - state_46: + state_51: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_71; + goto state_77; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_71; + goto state_77; if (ch.unicode() == 92) - goto state_72; + goto state_78; if (ch.unicode() == 95) - goto state_71; + goto state_77; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_71; + goto state_77; goto out; - state_47: + state_52: ch = next(); if (ch.unicode() == 45) - goto state_73; + goto state_79; goto out; - state_48: + state_53: ch = next(); if (ch.unicode() == 92) - goto state_49; + goto state_54; if (ch.unicode() == 95) - goto state_50; + goto state_55; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_50; + goto state_55; goto out; - state_49: + state_54: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_74; + goto state_80; if (ch.unicode() == 11) - goto state_74; + goto state_80; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_74; + goto state_80; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_74; + goto state_80; if (ch.unicode() >= 103) - goto state_74; + goto state_80; goto out; - state_50: + state_55: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); if (ch.unicode() == 45) - goto state_75; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_81; if (ch.unicode() == 92) - goto state_76; + goto state_82; if (ch.unicode() == 95) - goto state_75; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_75; + goto state_81; goto out; - state_51: + state_56: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_52; + goto state_58; if (ch.unicode() == 45) - goto state_53; + goto state_59; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_53; + goto state_59; if (ch.unicode() == 92) - goto state_54; + goto state_60; if (ch.unicode() == 95) - goto state_53; + goto state_59; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_53; + goto state_59; goto out; - state_52: + state_58: lastAcceptingPos = pos; token = QCss::FUNCTION; goto out; - state_53: + state_59: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_52; + goto state_58; if (ch.unicode() == 45) - goto state_53; + goto state_59; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_53; + goto state_59; if (ch.unicode() == 92) - goto state_54; + goto state_60; if (ch.unicode() == 95) - goto state_53; + goto state_59; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_53; + goto state_59; goto out; - state_54: + state_60: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_77; + goto state_83; if (ch.unicode() == 11) - goto state_77; + goto state_83; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_77; + goto state_83; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_77; + goto state_83; if (ch.unicode() >= 103) - goto state_77; + goto state_83; goto out; - state_57: + state_63: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_58: + state_64: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_59: + state_65: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_60: + state_66: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 10) - goto state_78; + goto state_84; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_61: + state_67: lastAcceptingPos = pos; token = QCss::HASH; ch = next(); if (ch.unicode() == 45) - goto state_61; + goto state_67; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_61; + goto state_67; if (ch.unicode() == 92) - goto state_62; + goto state_68; if (ch.unicode() == 95) - goto state_61; + goto state_67; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_61; + goto state_67; goto out; - state_62: + state_68: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_79; + goto state_85; if (ch.unicode() == 11) - goto state_79; + goto state_85; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_79; + goto state_85; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_79; + goto state_85; if (ch.unicode() >= 103) - goto state_79; + goto state_85; goto out; - state_63: + state_69: lastAcceptingPos = pos; token = QCss::HASH; ch = next(); if (ch.unicode() == 45) - goto state_61; + goto state_67; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_61; + goto state_67; if (ch.unicode() == 92) - goto state_62; + goto state_68; if (ch.unicode() == 95) - goto state_61; + goto state_67; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_61; + goto state_67; goto out; - state_64: + state_70: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_65: + state_71: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_66: + state_72: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_67: + state_73: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 10) - goto state_80; + goto state_86; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_69: + state_75: lastAcceptingPos = pos; token = QCss::NUMBER; ch = next(); if (ch.unicode() == 37) - goto state_41; + goto state_46; if (ch.unicode() == 45) - goto state_42; + goto state_47; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_69; + goto state_75; if (ch.unicode() == 92) - goto state_45; + goto state_50; if (ch.unicode() == 95) - goto state_46; + goto state_51; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_46; + goto state_51; goto out; - state_70: + state_76: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_71; + goto state_77; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_71; + goto state_77; if (ch.unicode() == 92) - goto state_72; + goto state_78; if (ch.unicode() == 95) - goto state_71; + goto state_77; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_71; + goto state_77; goto out; - state_71: + state_77: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_71; + goto state_77; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_71; + goto state_77; if (ch.unicode() == 92) - goto state_72; + goto state_78; if (ch.unicode() == 95) - goto state_71; + goto state_77; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_71; + goto state_77; goto out; - state_72: + state_78: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_81; + goto state_87; if (ch.unicode() == 11) - goto state_81; + goto state_87; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_81; + goto state_87; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_81; + goto state_87; if (ch.unicode() >= 103) - goto state_81; + goto state_87; goto out; - state_73: + state_79: ch = next(); if (ch.unicode() == 45) { token = QCss::CDO; goto found; } goto out; - state_74: + state_80: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); if (ch.unicode() == 45) - goto state_75; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_81; if (ch.unicode() == 92) - goto state_76; + goto state_82; if (ch.unicode() == 95) - goto state_75; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_75; + goto state_81; goto out; - state_75: + state_81: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); if (ch.unicode() == 45) - goto state_75; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_81; if (ch.unicode() == 92) - goto state_76; + goto state_82; if (ch.unicode() == 95) - goto state_75; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_75; + goto state_81; goto out; - state_76: + state_82: ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_83; + goto state_89; if (ch.unicode() == 11) - goto state_83; + goto state_89; if (ch.unicode() >= 14 && ch.unicode() <= 47) - goto state_83; + goto state_89; if (ch.unicode() >= 58 && ch.unicode() <= 96) - goto state_83; + goto state_89; if (ch.unicode() >= 103) - goto state_83; + goto state_89; goto out; - state_77: + state_83: lastAcceptingPos = pos; token = QCss::IDENT; ch = next(); if (ch.unicode() == 40) - goto state_52; + goto state_58; if (ch.unicode() == 45) - goto state_53; + goto state_59; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_53; + goto state_59; if (ch.unicode() == 92) - goto state_54; + goto state_60; if (ch.unicode() == 95) - goto state_53; + goto state_59; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_53; + goto state_59; goto out; - state_78: + state_84: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_30; + goto state_33; if (ch.unicode() == 11) - goto state_30; + goto state_33; if (ch.unicode() >= 14 && ch.unicode() <= 33) - goto state_30; + goto state_33; if (ch.unicode() == 34) - goto state_31; + goto state_34; if (ch.unicode() >= 35 && ch.unicode() <= 91) - goto state_30; + goto state_33; if (ch.unicode() == 92) - goto state_32; + goto state_35; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_30; + goto state_33; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_30; + goto state_33; if (ch.unicode() >= 123) - goto state_30; + goto state_33; goto out; - state_79: + state_85: lastAcceptingPos = pos; token = QCss::HASH; ch = next(); if (ch.unicode() == 45) - goto state_61; + goto state_67; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_61; + goto state_67; if (ch.unicode() == 92) - goto state_62; + goto state_68; if (ch.unicode() == 95) - goto state_61; + goto state_67; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_61; + goto state_67; goto out; - state_80: + state_86: lastAcceptingPos = pos; token = QCss::INVALID; ch = next(); if (ch.unicode() >= 1 && ch.unicode() <= 9) - goto state_35; + goto state_39; if (ch.unicode() == 11) - goto state_35; + goto state_39; if (ch.unicode() >= 14 && ch.unicode() <= 38) - goto state_35; + goto state_39; if (ch.unicode() == 39) - goto state_36; + goto state_40; if (ch.unicode() >= 40 && ch.unicode() <= 91) - goto state_35; + goto state_39; if (ch.unicode() == 92) - goto state_37; + goto state_41; if (ch.unicode() >= 93 && ch.unicode() <= 96) - goto state_35; + goto state_39; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_35; + goto state_39; if (ch.unicode() >= 123) - goto state_35; + goto state_39; goto out; - state_81: + state_87: lastAcceptingPos = pos; token = QCss::LENGTH; ch = next(); if (ch.unicode() == 45) - goto state_71; + goto state_77; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_71; + goto state_77; if (ch.unicode() == 92) - goto state_72; + goto state_78; if (ch.unicode() == 95) - goto state_71; + goto state_77; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_71; + goto state_77; goto out; - state_83: + state_89: lastAcceptingPos = pos; token = QCss::ATKEYWORD_SYM; ch = next(); if (ch.unicode() == 45) - goto state_75; + goto state_81; if (ch.unicode() >= 48 && ch.unicode() <= 57) - goto state_75; + goto state_81; if (ch.unicode() == 92) - goto state_76; + goto state_82; if (ch.unicode() == 95) - goto state_75; + goto state_81; if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256) - goto state_75; + goto state_81; goto out; found: lastAcceptingPos = pos; diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index 5a696807b4..933dd1bf54 100644 --- a/src/gui/text/qdistancefield.cpp +++ b/src/gui/text/qdistancefield.cpp @@ -45,6 +45,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcDistanceField, "qt.distanceField"); + namespace { enum FillHDir @@ -736,8 +738,40 @@ static bool imageHasNarrowOutlines(const QImage &im) return minHThick == 1 || minVThick == 1; } +static int QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE = 54; +static int QT_DISTANCEFIELD_DEFAULT_SCALE = 16; +static int QT_DISTANCEFIELD_DEFAULT_RADIUS = 80; +static int QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT = 2000; + +static void initialDistanceFieldFactor() +{ + static bool initialized = false; + if (initialized) + return; + initialized = true; + + if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE")) { + QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE"); + qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE:" << QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE; + } + + if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_SCALE")) { + QT_DISTANCEFIELD_DEFAULT_SCALE = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_SCALE"); + qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_SCALE:" << QT_DISTANCEFIELD_DEFAULT_SCALE; + } + if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_RADIUS")) { + QT_DISTANCEFIELD_DEFAULT_RADIUS = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_RADIUS"); + qDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_RADIUS:" << QT_DISTANCEFIELD_DEFAULT_RADIUS; + } + if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT")) { + QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT"); + qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT:" << QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT; + } +} + bool qt_fontHasNarrowOutlines(QFontEngine *fontEngine) { + initialDistanceFieldFactor(); QFontEngine *fe = fontEngine->cloneWithSize(QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE); if (!fe) return false; @@ -757,6 +791,7 @@ bool qt_fontHasNarrowOutlines(QFontEngine *fontEngine) bool qt_fontHasNarrowOutlines(const QRawFont &f) { QRawFont font = f; + initialDistanceFieldFactor(); font.setPixelSize(QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE); if (!font.isValid()) return false; @@ -769,6 +804,41 @@ bool qt_fontHasNarrowOutlines(const QRawFont &f) QRawFont::PixelAntialiasing)); } +int QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont) +{ + initialDistanceFieldFactor(); + + if (Q_UNLIKELY(narrowOutlineFont)) + return QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2; + else + return QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE; +} + +int QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont) +{ + initialDistanceFieldFactor(); + + if (Q_UNLIKELY(narrowOutlineFont)) + return QT_DISTANCEFIELD_DEFAULT_SCALE / 2; + else + return QT_DISTANCEFIELD_DEFAULT_SCALE; +} + +int QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont) +{ + initialDistanceFieldFactor(); + + if (Q_UNLIKELY(narrowOutlineFont)) + return QT_DISTANCEFIELD_DEFAULT_RADIUS / 2; + else + return QT_DISTANCEFIELD_DEFAULT_RADIUS; +} + +int QT_DISTANCEFIELD_HIGHGLYPHCOUNT() +{ + initialDistanceFieldFactor(); + return QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT; +} QDistanceFieldData::QDistanceFieldData(const QDistanceFieldData &other) : QSharedData(other) diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h index c6c5e6b650..27ab84332c 100644 --- a/src/gui/text/qdistancefield_p.h +++ b/src/gui/text/qdistancefield_p.h @@ -51,30 +51,24 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <qrawfont.h> #include <private/qfontengine_p.h> #include <QtCore/qshareddata.h> +#include <QtCore/qglobal.h> +#include <QLoggingCategory> QT_BEGIN_NAMESPACE -#define QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE 54 -#define QT_DISTANCEFIELD_DEFAULT_SCALE 16 -#define QT_DISTANCEFIELD_DEFAULT_RADIUS 80 -#define QT_DISTANCEFIELD_HIGHGLYPHCOUNT 2000 - -#define QT_DISTANCEFIELD_BASEFONTSIZE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2 : \ - QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE) -#define QT_DISTANCEFIELD_SCALE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_SCALE / 2 : \ - QT_DISTANCEFIELD_DEFAULT_SCALE) -#define QT_DISTANCEFIELD_RADIUS(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_RADIUS / 2 : \ - QT_DISTANCEFIELD_DEFAULT_RADIUS) - bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(const QRawFont &f); bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(QFontEngine *fontEngine); +int Q_GUI_EXPORT QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_TILESIZE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont); +int Q_GUI_EXPORT QT_DISTANCEFIELD_HIGHGLYPHCOUNT(); + class Q_GUI_EXPORT QDistanceFieldData : public QSharedData { public: diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 9e4f61ebee..5e72e6969c 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2001,7 +2001,7 @@ QString QFont::key() const QString QFont::toString() const { const QChar comma(QLatin1Char(',')); - return family() + comma + + QString fontDescription = family() + comma + QString::number( pointSizeF()) + comma + QString::number( pixelSize()) + comma + QString::number((int) styleHint()) + comma + @@ -2011,6 +2011,12 @@ QString QFont::toString() const QString::number((int) strikeOut()) + comma + QString::number((int)fixedPitch()) + comma + QString::number((int) false); + + QString fontStyle = styleName(); + if (!fontStyle.isEmpty()) + fontDescription += comma + fontStyle; + + return fontDescription; } /*! @@ -2054,7 +2060,7 @@ bool QFont::fromString(const QString &descrip) setUnderline(l[5].toInt()); setStrikeOut(l[6].toInt()); setFixedPitch(l[7].toInt()); - } else if (count == 10) { + } else if (count >= 10) { if (l[2].toInt() > 0) setPixelSize(l[2].toInt()); setStyleHint((StyleHint) l[3].toInt()); @@ -2063,7 +2069,10 @@ bool QFont::fromString(const QString &descrip) setUnderline(l[6].toInt()); setStrikeOut(l[7].toInt()); setFixedPitch(l[8].toInt()); + if (count == 11) + d->request.styleName = l[10].toString(); } + if (count >= 9 && !d->request.fixedPitch) // assume 'false' fixedPitch equals default d->request.ignorePitch = true; diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 85a237643c..b295e13f61 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -40,6 +40,7 @@ #ifndef QFONT_H #define QFONT_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <QtCore/qstring.h> #include <QtCore/qsharedpointer.h> diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 3979bb27ac..21823dc12f 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qfont.h" #include "QtCore/qmap.h" #include "QtCore/qhash.h" diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index c4a130e04c..ef09a0cacd 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -2221,10 +2221,18 @@ QString QFontDatabase::writingSystemSample(WritingSystem writingSystem) sample += QChar(0x05D3); break; case Arabic: + sample += QChar(0x0623); sample += QChar(0x0628); + sample += QChar(0x062C); + sample += QChar(0x062F); + sample += QChar(0x064A); + sample += QChar(0x0629); + sample += QChar(0x0020); + sample += QChar(0x0639); + sample += QChar(0x0631); + sample += QChar(0x0628); + sample += QChar(0x064A); sample += QChar(0x0629); - sample += QChar(0x062A); - sample += QChar(0x063A); break; case Syriac: sample += QChar(0x0715); diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h index 67cf671304..e6aef493bd 100644 --- a/src/gui/text/qfontdatabase.h +++ b/src/gui/text/qfontdatabase.h @@ -40,6 +40,7 @@ #ifndef QFONTDATABASE_H #define QFONTDATABASE_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qwindowdefs.h> #include <QtCore/qstring.h> #include <QtGui/qfont.h> diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index fe5d544dba..adc8f634dc 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1845,7 +1845,11 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const { glyph_t glyph = engine(0)->glyphIndex(ucs4); - if (glyph == 0 && ucs4 != QChar::LineSeparator) { + if (glyph == 0 + && ucs4 != QChar::LineSeparator + && ucs4 != QChar::LineFeed + && ucs4 != QChar::CarriageReturn + && ucs4 != QChar::ParagraphSeparator) { if (!m_fallbackFamiliesQueried) const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried(); for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) { @@ -1883,7 +1887,11 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, QStringIterator it(str, str + len); while (it.hasNext()) { const uint ucs4 = it.peekNext(); - if (glyphs->glyphs[glyph_pos] == 0 && ucs4 != QChar::LineSeparator) { + if (glyphs->glyphs[glyph_pos] == 0 + && ucs4 != QChar::LineSeparator + && ucs4 != QChar::LineFeed + && ucs4 != QChar::CarriageReturn + && ucs4 != QChar::ParagraphSeparator) { if (!m_fallbackFamiliesQueried) const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried(); for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 1430444c7e..f3eeddab41 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qatomic.h" #include <QtCore/qvarlengtharray.h> #include <QtCore/QLinkedList> diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h index 54b9af71df..fd5db1ecf5 100644 --- a/src/gui/text/qfontengineglyphcache_p.h +++ b/src/gui/text/qfontengineglyphcache_p.h @@ -52,7 +52,7 @@ // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qatomic.h" #include <QtCore/qvarlengtharray.h> #include "private/qfont_p.h" diff --git a/src/gui/text/qfontinfo.h b/src/gui/text/qfontinfo.h index ee368e26bd..f5e05775b4 100644 --- a/src/gui/text/qfontinfo.h +++ b/src/gui/text/qfontinfo.h @@ -40,6 +40,7 @@ #ifndef QFONTINFO_H #define QFONTINFO_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qfont.h> #include <QtCore/qsharedpointer.h> diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 1d7241c9f2..22e51f29f7 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -40,6 +40,7 @@ #ifndef QFONTMETRICS_H #define QFONTMETRICS_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qfont.h> #include <QtCore/qsharedpointer.h> #ifndef QT_INCLUDE_COMPAT diff --git a/src/gui/text/qfontsubset_p.h b/src/gui/text/qfontsubset_p.h index a7328df4ed..e7c6053beb 100644 --- a/src/gui/text/qfontsubset_p.h +++ b/src/gui/text/qfontsubset_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qfontengine_p.h" QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h index b54d7261d0..35f60ac961 100644 --- a/src/gui/text/qfragmentmap_p.h +++ b/src/gui/text/qfragmentmap_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include <stdlib.h> #include <private/qtools_p.h> diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h index 6016925d27..6182c4f749 100644 --- a/src/gui/text/qglyphrun.h +++ b/src/gui/text/qglyphrun.h @@ -40,6 +40,7 @@ #ifndef QGLYPHRUN_H #define QGLYPHRUN_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qsharedpointer.h> #include <QtCore/qvector.h> #include <QtCore/qpoint.h> diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h index 52fa03f150..5b6bdad648 100644 --- a/src/gui/text/qglyphrun_p.h +++ b/src/gui/text/qglyphrun_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qglyphrun.h" #include "qrawfont.h" diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h index 28f20338dd..95a21eedb6 100644 --- a/src/gui/text/qharfbuzzng_p.h +++ b/src/gui/text/qharfbuzzng_p.h @@ -52,6 +52,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qchar.h> #include <harfbuzz/hb.h> diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index 61c892ad8b..13d8cbde60 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -49,7 +49,7 @@ // source and binary incompatible with future versions of Qt. // -#include <QtCore/qconfig.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QList> diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index aa98363229..5791c6af16 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -40,6 +40,7 @@ #ifndef QRAWFONT_H #define QRAWFONT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> #include <QtCore/qiodevice.h> #include <QtCore/qglobal.h> diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h index ee54578cf9..0fc8739bfb 100644 --- a/src/gui/text/qrawfont_p.h +++ b/src/gui/text/qrawfont_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qrawfont.h" #include "qfontengine_p.h" diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h index 2da74825a2..00dfccc144 100644 --- a/src/gui/text/qstatictext.h +++ b/src/gui/text/qstatictext.h @@ -40,6 +40,7 @@ #ifndef QSTATICTEXT_H #define QSTATICTEXT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qsize.h> #include <QtCore/qstring.h> #include <QtCore/qmetatype.h> diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index 7fdf46c101..dda566a22b 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qstatictext.h" #include <private/qtextureglyphcache_p.h> diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h index 2ccb3a68b9..d87f89f0fd 100644 --- a/src/gui/text/qsyntaxhighlighter.h +++ b/src/gui/text/qsyntaxhighlighter.h @@ -40,7 +40,7 @@ #ifndef QSYNTAXHIGHLIGHTER_H #define QSYNTAXHIGHLIGHTER_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #ifndef QT_NO_SYNTAXHIGHLIGHTER diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 9610e61b39..1a00b753ad 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -40,6 +40,7 @@ #ifndef QTEXTCURSOR_H #define QTEXTCURSOR_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> #include <QtCore/qshareddata.h> #include <QtGui/qtextformat.h> diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h index 84f912a3fa..3569317b6d 100644 --- a/src/gui/text/qtextcursor_p.h +++ b/src/gui/text/qtextcursor_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qtextcursor.h" #include "qtextdocument.h" #include "qtextdocument_p.h" diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 723918ae69..75899dec80 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -94,7 +94,7 @@ bool Qt::mightBeRichText(const QString& text) ++start; // skip a leading <?xml ... ?> as for example with xhtml - if (text.mid(start, 5) == QLatin1String("<?xml")) { + if (text.midRef(start, 5).compare(QLatin1String("<?xml")) == 0) { while (start < text.length()) { if (text.at(start) == QLatin1Char('?') && start + 2 < text.length() @@ -109,12 +109,12 @@ bool Qt::mightBeRichText(const QString& text) ++start; } - if (text.mid(start, 5).toLower() == QLatin1String("<!doc")) + if (text.midRef(start, 5).compare(QLatin1String("<!doc"), Qt::CaseInsensitive) == 0) return true; int open = start; while (open < text.length() && text.at(open) != QLatin1Char('<') && text.at(open) != QLatin1Char('\n')) { - if (text.at(open) == QLatin1Char('&') && text.mid(open+1,3) == QLatin1String("lt;")) + if (text.at(open) == QLatin1Char('&') && text.midRef(open + 1, 3) == QLatin1String("lt;")) return true; // support desperate attempt of user to see <...> ++open; } @@ -3135,7 +3135,7 @@ void QTextHtmlExporter::emitTable(const QTextTable *table) html += QLatin1String("</table>"); } -void QTextHtmlExporter::emitFrame(QTextFrame::Iterator frameIt) +void QTextHtmlExporter::emitFrame(const QTextFrame::Iterator &frameIt) { if (!frameIt.atEnd()) { QTextFrame::Iterator next = frameIt; diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index 02cfa97bce..1888088f0d 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -40,6 +40,7 @@ #ifndef QTEXTDOCUMENT_H #define QTEXTDOCUMENT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtCore/qsize.h> #include <QtCore/qrect.h> diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index ffc5d7418b..3537adba9e 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -1078,8 +1078,9 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) const QTextUndoCommand &last = undoStack.at(lastIdx); if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge - || (!c.block_part && !last.block_part)) { // two single undo items => can merge - + || (!c.block_part && !last.block_part) // two single undo items => can merge + || (c.command == QTextUndoCommand::Inserted && last.command == c.command && (last.block_part && !c.block_part))) { + // two sequential inserts that are not part of the same block => can merge if (undoStack[lastIdx].tryMerge(c)) return; } diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index 34849df0bb..cad9131fbf 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qstring.h" #include "QtCore/qvector.h" #include "QtCore/qlist.h" @@ -158,7 +158,7 @@ public: }; Q_DECLARE_TYPEINFO(QTextUndoCommand, Q_PRIMITIVE_TYPE); -class Q_AUTOTEST_EXPORT QTextDocumentPrivate : public QObjectPrivate +class Q_GUI_EXPORT QTextDocumentPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QTextDocument) public: @@ -378,7 +378,7 @@ private: enum StyleMode { EmitStyleTag, OmitStyleTag }; enum FrameType { TextFrame, TableFrame, RootFrame }; - void emitFrame(QTextFrame::Iterator frameIt); + void emitFrame(const QTextFrame::Iterator &frameIt); void emitTextFrame(const QTextFrame *frame); void emitBlock(const QTextBlock &block); void emitTable(const QTextTable *table); diff --git a/src/gui/text/qtextdocumentfragment.h b/src/gui/text/qtextdocumentfragment.h index d1c1adfd0a..a56f6d06d6 100644 --- a/src/gui/text/qtextdocumentfragment.h +++ b/src/gui/text/qtextdocumentfragment.h @@ -40,6 +40,7 @@ #ifndef QTEXTDOCUMENTFRAGMENT_H #define QTEXTDOCUMENTFRAGMENT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qtextdocumentfragment_p.h b/src/gui/text/qtextdocumentfragment_p.h index 56dff01149..e8699545f7 100644 --- a/src/gui/text/qtextdocumentfragment_p.h +++ b/src/gui/text/qtextdocumentfragment_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qtextdocument.h" #include "private/qtexthtmlparser_p.h" #include "private/qtextdocument_p.h" diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index b6cbd9617f..8ad2d85e7c 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -295,7 +295,7 @@ static inline bool isEmptyBlockBeforeTable(const QTextBlock &block, const QTextB ; } -static inline bool isEmptyBlockBeforeTable(QTextFrame::Iterator it) +static inline bool isEmptyBlockBeforeTable(const QTextFrame::Iterator &it) { QTextFrame::Iterator next = it; ++next; if (it.currentFrame()) @@ -419,7 +419,7 @@ static bool operator<(int pos, const QCheckPoint &checkPoint) #endif -static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, QRectF gradientRect = QRectF()) +static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, const QRectF &gradientRect = QRectF()) { p->save(); if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) { @@ -1504,7 +1504,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p painter->restore(); } -static QFixed flowPosition(const QTextFrame::iterator it) +static QFixed flowPosition(const QTextFrame::iterator &it) { if (it.atEnd()) return 0; @@ -2921,11 +2921,11 @@ void QTextDocumentLayout::documentChanged(int from, int oldLength, int length) { Q_D(QTextDocumentLayout); - QTextBlock startIt = document()->findBlock(from); + QTextBlock blockIt = document()->findBlock(from); QTextBlock endIt = document()->findBlock(qMax(0, from + length - 1)); if (endIt.isValid()) endIt = endIt.next(); - for (QTextBlock blockIt = startIt; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next()) + for (; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next()) blockIt.clearLayout(); if (d->docPrivate->pageSize.isNull()) @@ -2967,9 +2967,6 @@ void QTextDocumentLayout::documentChanged(int from, int oldLength, int length) d->insideDocumentChange = false; - for (QTextBlock blockIt = startIt; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next()) - emit updateBlock(blockIt); - if (d->showLayoutProgress) { const QSizeF newSize = dynamicDocumentSize(); if (newSize != d->lastReportedSize) { diff --git a/src/gui/text/qtextdocumentlayout_p.h b/src/gui/text/qtextdocumentlayout_p.h index a9cd6cf289..710c49628e 100644 --- a/src/gui/text/qtextdocumentlayout_p.h +++ b/src/gui/text/qtextdocumentlayout_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qabstracttextdocumentlayout.h" #include "QtGui/qtextoption.h" #include "QtGui/qtextobject.h" diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp index a7c58ac2a6..731aaf1fcf 100644 --- a/src/gui/text/qtextdocumentwriter.cpp +++ b/src/gui/text/qtextdocumentwriter.cpp @@ -139,12 +139,9 @@ QTextDocumentWriter::QTextDocumentWriter(QIODevice *device, const QByteArray &fo format by inspecting the extension of \a fileName. */ QTextDocumentWriter::QTextDocumentWriter(const QString &fileName, const QByteArray &format) - : d(new QTextDocumentWriterPrivate(this)) + : QTextDocumentWriter(new QFile(fileName), format) { - QFile *file = new QFile(fileName); - d->device = file; d->deleteDevice = true; - d->format = format; } /*! diff --git a/src/gui/text/qtextdocumentwriter.h b/src/gui/text/qtextdocumentwriter.h index b7917e55a4..0502bf1a96 100644 --- a/src/gui/text/qtextdocumentwriter.h +++ b/src/gui/text/qtextdocumentwriter.h @@ -39,6 +39,7 @@ #ifndef QTEXTDOCUMENTWRITER_H #define QTEXTDOCUMENTWRITER_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 7378b129a9..cad30b0c77 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -843,7 +843,7 @@ enum JustificationClass { Adds an inter character justification opportunity after the number or letter character and a space justification opportunity after the space character. */ -static inline void qt_getDefaultJustificationOpportunities(const ushort *string, int length, QGlyphLayout g, ushort *log_clusters, int spaceAs) +static inline void qt_getDefaultJustificationOpportunities(const ushort *string, int length, const QGlyphLayout &g, ushort *log_clusters, int spaceAs) { int str_pos = 0; while (str_pos < length) { @@ -877,7 +877,7 @@ static inline void qt_getDefaultJustificationOpportunities(const ushort *string, } } -static inline void qt_getJustificationOpportunities(const ushort *string, int length, const QScriptItem &si, QGlyphLayout g, ushort *log_clusters) +static inline void qt_getJustificationOpportunities(const ushort *string, int length, const QScriptItem &si, const QGlyphLayout &g, ushort *log_clusters) { Q_ASSERT(length > 0 && g.numGlyphs > 0); @@ -1292,9 +1292,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, #ifdef Q_OS_DARWIN if (actualFontEngine->type() == QFontEngine::Mac) { - // CTRunGetPosition has a bug which applies matrix on 10.6, so we disable - // scaling the advances for this particular version - if (QSysInfo::MacintoshVersion != QSysInfo::MV_10_6 && actualFontEngine->fontDef.stretch != 100) { + if (actualFontEngine->fontDef.stretch != 100) { QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100); for (uint i = 0; i < num_glyphs; ++i) g.advances[i] *= stretch; @@ -3519,7 +3517,7 @@ QTextItemInt QTextItemInt::midItem(QFontEngine *fontEngine, int firstGlyphIndex, } -QTransform qt_true_matrix(qreal w, qreal h, QTransform x) +QTransform qt_true_matrix(qreal w, qreal h, const QTransform &x) { QRectF rect = x.mapRect(QRectF(0, 0, w, h)); return x * QTransform::fromTranslate(-rect.x(), -rect.y()); diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 56c9825cc1..160e9ce490 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -51,7 +51,7 @@ // We mean it. // -#include "QtCore/qglobal.h" +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qstring.h" #include "QtCore/qvarlengtharray.h" #include "QtCore/qnamespace.h" diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index 805affd87c..28c3035537 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -40,6 +40,7 @@ #ifndef QTEXTFORMAT_H #define QTEXTFORMAT_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qcolor.h> #include <QtGui/qfont.h> #include <QtCore/qshareddata.h> diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h index 45a432d2f5..f05bfaff71 100644 --- a/src/gui/text/qtextformat_p.h +++ b/src/gui/text/qtextformat_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qtextformat.h" #include "QtCore/qvector.h" diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h index 4c0dd967f9..4ea6e44138 100644 --- a/src/gui/text/qtexthtmlparser_p.h +++ b/src/gui/text/qtexthtmlparser_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qvector.h" #include "QtGui/qbrush.h" #include "QtGui/qcolor.h" diff --git a/src/gui/text/qtextimagehandler_p.h b/src/gui/text/qtextimagehandler_p.h index 4bc19d49c3..a22c91ecbf 100644 --- a/src/gui/text/qtextimagehandler_p.h +++ b/src/gui/text/qtextimagehandler_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtCore/qobject.h" #include "QtGui/qabstracttextdocumentlayout.h" diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 3b1ee8ec03..f5827bb683 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -975,7 +975,7 @@ void QTextLayout::setFlags(int flags) } static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPointF &pos, QTextLayout::FormatRange *selection, - QPainterPath *region, QRectF boundingRect) + QPainterPath *region, const QRectF &boundingRect) { const QScriptLine &line = eng->lines[lineNumber]; @@ -1326,7 +1326,11 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition && (p->transform().type() > QTransform::TxTranslate); if (toggleAntialiasing) p->setRenderHint(QPainter::Antialiasing); + QPainter::CompositionMode origCompositionMode = p->compositionMode(); + if (p->paintEngine()->hasFeature(QPaintEngine::RasterOpModes)) + p->setCompositionMode(QPainter::RasterOp_NotDestination); p->fillRect(QRectF(x, y, qreal(width), (base + descent).toReal()), p->pen().brush()); + p->setCompositionMode(origCompositionMode); if (toggleAntialiasing) p->setRenderHint(QPainter::Antialiasing, false); if (d->layoutData->hasBidi) { diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index 1cbb5ac8d8..980a099b05 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -39,6 +39,7 @@ #ifndef QTEXTLAYOUT_H #define QTEXTLAYOUT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> #include <QtCore/qnamespace.h> #include <QtCore/qrect.h> diff --git a/src/gui/text/qtextlist.h b/src/gui/text/qtextlist.h index 71da175a14..3967787f03 100644 --- a/src/gui/text/qtextlist.h +++ b/src/gui/text/qtextlist.h @@ -40,6 +40,7 @@ #ifndef QTEXTLIST_H #define QTEXTLIST_H +#include <QtGui/qtguiglobal.h> #include <QtGui/qtextobject.h> #include <QtCore/qobject.h> diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index d3f6b3d0ac..a5030de112 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -40,6 +40,7 @@ #ifndef QTEXTOBJECT_H #define QTEXTOBJECT_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtGui/qtextformat.h> #include <QtGui/qtextlayout.h> diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h index ffc331e99d..81ab023cc3 100644 --- a/src/gui/text/qtextobject_p.h +++ b/src/gui/text/qtextobject_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "QtGui/qtextobject.h" #include "private/qobject_p.h" #include "QtGui/qtextdocument.h" diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index ad537b7126..73d2e545ba 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -295,7 +295,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc writer.writeStartElement(textNS, QString::fromLatin1("span")); QString fragmentText = frag.fragment().text(); - if (fragmentText.length() == 1 && fragmentText[0] == 0xFFFC) { // its an inline character. + if (fragmentText.length() == 1 && fragmentText[0] == QChar(0xFFFC)) { // its an inline character. writeInlineCharacter(writer, frag.fragment()); writer.writeEndElement(); // span continue; @@ -510,7 +510,7 @@ void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat case QTextOption::CenterTab: type = QString::fromLatin1("center"); break; } writer.writeAttribute(styleNS, QString::fromLatin1("type"), type); - if (iterator->delimiter != 0) + if (!iterator->delimiter.isNull()) writer.writeAttribute(styleNS, QString::fromLatin1("char"), iterator->delimiter); ++iterator; } diff --git a/src/gui/text/qtextodfwriter_p.h b/src/gui/text/qtextodfwriter_p.h index d4cd91f8a3..c1a5652760 100644 --- a/src/gui/text/qtextodfwriter_p.h +++ b/src/gui/text/qtextodfwriter_p.h @@ -40,7 +40,7 @@ #ifndef QTEXTODFWRITER_H #define QTEXTODFWRITER_H -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #ifndef QT_NO_TEXTODFWRITER diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h index f9c24ffeaf..9ef9cee9bb 100644 --- a/src/gui/text/qtextoption.h +++ b/src/gui/text/qtextoption.h @@ -40,6 +40,7 @@ #ifndef QTEXTOPTION_H #define QTEXTOPTION_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qnamespace.h> #include <QtCore/qchar.h> #include <QtCore/qmetatype.h> diff --git a/src/gui/text/qtexttable.h b/src/gui/text/qtexttable.h index 14525aae25..ee8e974396 100644 --- a/src/gui/text/qtexttable.h +++ b/src/gui/text/qtexttable.h @@ -40,7 +40,7 @@ #ifndef QTEXTTABLE_H #define QTEXTTABLE_H -#include <QtCore/qglobal.h> +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtGui/qtextobject.h> diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h index 72d9d8c639..848537272d 100644 --- a/src/gui/text/qtexttable_p.h +++ b/src/gui/text/qtexttable_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "private/qtextobject_p.h" #include "private/qtextdocument_p.h" diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h index 5603f0f0d6..eed6ee6a62 100644 --- a/src/gui/text/qzipreader_p.h +++ b/src/gui/text/qzipreader_p.h @@ -40,6 +40,7 @@ #ifndef QZIPREADER_H #define QZIPREADER_H +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qglobal.h> #ifndef QT_NO_TEXTODFWRITER diff --git a/src/gui/text/qzipwriter_p.h b/src/gui/text/qzipwriter_p.h index 0a4763855e..433bbab31e 100644 --- a/src/gui/text/qzipwriter_p.h +++ b/src/gui/text/qzipwriter_p.h @@ -39,7 +39,7 @@ #ifndef QZIPWRITER_H #define QZIPWRITER_H -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #ifndef QT_NO_TEXTODFWRITER diff --git a/src/gui/util/qabstractlayoutstyleinfo_p.h b/src/gui/util/qabstractlayoutstyleinfo_p.h index b8f3825ada..bf1e1fc852 100644 --- a/src/gui/util/qabstractlayoutstyleinfo_p.h +++ b/src/gui/util/qabstractlayoutstyleinfo_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qnamespace.h> #include "qlayoutpolicy_p.h" diff --git a/src/gui/util/qdesktopservices.h b/src/gui/util/qdesktopservices.h index 3d44ab4a1e..21705e2757 100644 --- a/src/gui/util/qdesktopservices.h +++ b/src/gui/util/qdesktopservices.h @@ -40,6 +40,7 @@ #ifndef QDESKTOPSERVICES_H #define QDESKTOPSERVICES_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qstring.h> #include <QtCore/qstandardpaths.h> diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h index d79d4cc9c9..5f0cc5da73 100644 --- a/src/gui/util/qgridlayoutengine_p.h +++ b/src/gui/util/qgridlayoutengine_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include "qalgorithms.h" #include "qbitarray.h" #include "qlist.h" diff --git a/src/gui/util/qhexstring_p.h b/src/gui/util/qhexstring_p.h index ac11c8ad14..511eec0f1b 100644 --- a/src/gui/util/qhexstring_p.h +++ b/src/gui/util/qhexstring_p.h @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include <QtCore/qglobal.h> +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qpoint.h> #include <QtCore/qstring.h> #include <QtGui/qpolygon.h> diff --git a/src/gui/util/qlayoutpolicy_p.h b/src/gui/util/qlayoutpolicy_p.h index 979b808563..a729a57e8b 100644 --- a/src/gui/util/qlayoutpolicy_p.h +++ b/src/gui/util/qlayoutpolicy_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <QtGui/private/qtguiglobal_p.h> #include <QtCore/qobject.h> #include <QtCore/qnamespace.h> diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 90c6e7a7b8..fb9dfc9f69 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -216,7 +216,7 @@ public: */ QValidator::QValidator(QObject * parent) - : QObject(*new QValidatorPrivate, parent) + : QValidator(*new QValidatorPrivate, parent) { } @@ -337,10 +337,8 @@ void QValidator::fixup(QString &) const */ QIntValidator::QIntValidator(QObject * parent) - : QValidator(parent) + : QIntValidator(INT_MIN, INT_MAX, parent) { - b = INT_MIN; - t = INT_MAX; } @@ -589,11 +587,8 @@ public: */ QDoubleValidator::QDoubleValidator(QObject * parent) - : QValidator(*new QDoubleValidatorPrivate , parent) + : QDoubleValidator(-HUGE_VAL, HUGE_VAL, 1000, parent) { - b = -HUGE_VAL; - t = HUGE_VAL; - dec = 1000; } @@ -845,7 +840,7 @@ QDoubleValidator::Notation QDoubleValidator::notation() const */ QRegExpValidator::QRegExpValidator(QObject *parent) - : QValidator(parent), r(QString::fromLatin1(".*")) + : QRegExpValidator(QRegExp(QString::fromLatin1(".*")), parent) { } @@ -982,7 +977,7 @@ QRegularExpressionValidator::QRegularExpressionValidator(QObject *parent) */ QRegularExpressionValidator::QRegularExpressionValidator(const QRegularExpression &re, QObject *parent) - : QValidator(*new QRegularExpressionValidatorPrivate, parent) + : QRegularExpressionValidator(parent) { Q_D(QRegularExpressionValidator); d->setRegularExpression(re); diff --git a/src/gui/util/qvalidator.h b/src/gui/util/qvalidator.h index 85787a66c6..eba4b54672 100644 --- a/src/gui/util/qvalidator.h +++ b/src/gui/util/qvalidator.h @@ -41,6 +41,7 @@ #ifndef QVALIDATOR_H #define QVALIDATOR_H +#include <QtGui/qtguiglobal.h> #include <QtCore/qobject.h> #include <QtCore/qstring.h> #include <QtCore/qregexp.h> |