diff options
Diffstat (limited to 'src/gui')
91 files changed, 1934 insertions, 3991 deletions
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index 8db944e5e3..657b57c0cd 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -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/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/qimage.cpp b/src/gui/image/qimage.cpp index 2911477d28..3238d83729 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -767,9 +767,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); } /*! @@ -2275,7 +2274,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); } /*! @@ -2377,7 +2376,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); } @@ -2563,7 +2562,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; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 3c80b070e3..16789c802e 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_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/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 4dada4ca82..0102ff5981 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -155,12 +155,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 +169,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 +197,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 +337,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 +414,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 +450,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; } @@ -674,12 +633,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/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/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/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 09d23c0084..18df8c35a6 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); } /*! 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_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 13104ce17f..45047f556c 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -195,7 +195,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) { @@ -335,7 +335,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_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/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index c84f429e46..7fbb498bbb 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -75,20 +75,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 +178,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 +203,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 +217,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 +475,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 +483,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 +510,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 +554,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; @@ -810,7 +798,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/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 5ae8e893cb..5c8ff84929 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/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 6f30f0ea25..ff54602a5d 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); } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 78a4dc4f35..305ce5c82e 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); } @@ -829,9 +829,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 +859,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 +894,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 +1764,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 +2062,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 +2447,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) { } @@ -4411,6 +4407,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. */ /*! @@ -4457,6 +4454,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 @@ -4660,6 +4673,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. @@ -4710,6 +4736,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) @@ -4846,6 +4880,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) @@ -5116,4 +5158,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() +{ + return m_numericId; +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 0a207667ad..785884681f 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -535,8 +535,9 @@ public: class Attribute { public: Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(qMove(val)) {} - AttributeType type; + Attribute(AttributeType t, int s, int l) : type(t), start(s), length(l), value() {} + AttributeType type; int start; int length; QVariant value; @@ -789,6 +790,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(); + +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 +814,8 @@ public: { public: enum InfoFlag { - Pen = 0x0001 + Pen = 0x0001, + Token = 0x0002 }; #ifndef Q_MOC_RUN // otherwise moc gives @@ -823,6 +841,7 @@ public: { qSwap(d, other.d); } int id() const; + QPointerUniqueId uniqueId() const; Qt::TouchPointState state() const; @@ -847,12 +866,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 +891,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..b37045c5d8 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.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/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a9f0ab04a1..239c5e135b 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> @@ -1102,12 +1102,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 +1186,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 +1310,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); @@ -2450,6 +2450,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 +2527,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 +2568,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/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 4cc9e95e81..d6e467db59 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..e790e3094f 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.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/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 59bf2bb065..19464eeca3 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/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..78667643fe 100644 --- a/src/gui/kernel/qplatformdialoghelper.h +++ b/src/gui/kernel/qplatformdialoghelper.h @@ -72,6 +72,8 @@ class QFontDialogOptionsPrivate; class QFileDialogOptionsPrivate; class QMessageDialogOptionsPrivate; +#define QPLATFORMDIALOGHELPERS_HAS_CREATE + class Q_GUI_EXPORT QPlatformDialogHelper : public QObject { Q_OBJECT @@ -176,6 +178,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 +192,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 +213,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 +237,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 +255,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 +267,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 +291,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 +323,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 +383,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 +421,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 +453,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/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 00b8e05f30..60b2706d35 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -469,7 +469,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); diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index eff3986788..cde70a1102 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -117,11 +117,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), flags(0) { } + TouchPoint() : id(0), uniqueId(-1), pressure(0), rotation(0), state(Qt::TouchPointStationary), flags(0) { } 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/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/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 597d347915..b932ee60c9 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/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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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/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/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/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/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/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 3a296ac40c..ee1f01e850 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(); - } } /*! @@ -1673,13 +1663,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 +1867,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 +1878,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 +2179,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/qcolor.cpp b/src/gui/painting/qcolor.cpp index 20dd8d7f82..269e6f2d97 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/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a325ee923e..b452019251 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; } } @@ -2423,7 +2500,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 +2556,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 +2568,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 +2589,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 +2653,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; @@ -2638,8 +2715,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. @@ -2730,8 +2807,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 +2829,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; @@ -2863,9 +2940,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); @@ -3001,8 +3078,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); @@ -3073,8 +3150,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]; @@ -4032,7 +4109,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) @@ -4051,7 +4128,7 @@ struct QBlendBase class BlendSrcGeneric : public QBlendBase<uint> { public: - BlendSrcGeneric(QSpanData *d, Operator o) + BlendSrcGeneric(QSpanData *d, const Operator &o) : QBlendBase<uint>(d, o) { } @@ -4077,7 +4154,7 @@ public: class BlendSrcGenericRGB64 : public QBlendBase<QRgba64> { public: - BlendSrcGenericRGB64(QSpanData *d, Operator o) + BlendSrcGenericRGB64(QSpanData *d, const Operator &o) : QBlendBase<QRgba64>(d, o) { } @@ -5758,7 +5835,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) @@ -5795,7 +5872,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; @@ -5822,7 +5899,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); @@ -5863,7 +5940,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); @@ -6321,7 +6398,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(); @@ -6397,14 +6474,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; @@ -6415,8 +6497,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..fa550541d3 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.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/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/qpainter.cpp b/src/gui/painting/qpainter.cpp index 1b947154ef..aeb76589e0 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2835,7 +2835,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"); @@ -6478,6 +6478,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(); @@ -6509,6 +6511,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; @@ -6520,9 +6524,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/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index ba14a45d4a..7072a2d79c 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/qpdf.cpp b/src/gui/painting/qpdf.cpp index 9e38c5272f..b014305796 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/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 6cec4a0a8d..7381f381fe 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -250,9 +250,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; @@ -412,7 +411,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. @@ -425,7 +424,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..52e6f40f44 100644 --- a/src/gui/painting/qplatformbackingstore.h +++ b/src/gui/painting/qplatformbackingstore.h @@ -121,7 +121,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/qregion.cpp b/src/gui/painting/qregion.cpp index d38479c4b1..b39a23e7f2 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..3bf1a5268c 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -81,6 +81,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 +120,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; diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index d2c3eceeef..bfc8551a9b 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -247,6 +247,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 +257,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..a8efb4abb1 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -117,7 +117,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/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..e2fad12ad3 100644 --- a/src/gui/text/qabstracttextdocumentlayout.h +++ b/src/gui/text/qabstracttextdocumentlayout.h @@ -82,7 +82,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/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 53d4e3fa36..bb92e6bfba 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()) { diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp index d90134482d..d4bd975eca 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 @@ -734,8 +736,45 @@ static bool imageHasNarrowOutlines(const QImage &im) return minHThick == 1 || minVThick == 1; } +static int QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE = 54; +static int QT_DISTANCEFIELD_DEFAULT_TILESIZE = 64; +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_TILESIZE")) { + QT_DISTANCEFIELD_DEFAULT_TILESIZE = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_TILESIZE"); + qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_TILESIZE:" << QT_DISTANCEFIELD_DEFAULT_TILESIZE; + } + 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; @@ -755,6 +794,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; @@ -767,6 +807,51 @@ 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_TILESIZE(bool narrowOutlineFont) +{ + initialDistanceFieldFactor(); + + if (Q_UNLIKELY(narrowOutlineFont)) + return QT_DISTANCEFIELD_DEFAULT_TILESIZE * 2; + else + return QT_DISTANCEFIELD_DEFAULT_TILESIZE; +} + +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 7cd385587b..3076a90b9d 100644 --- a/src/gui/text/qdistancefield_p.h +++ b/src/gui/text/qdistancefield_p.h @@ -54,31 +54,20 @@ #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_TILESIZE 64 -#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_TILESIZE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_TILESIZE * 2 : \ - QT_DISTANCEFIELD_DEFAULT_TILESIZE) -#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/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index febd5da488..8e4fa8a730 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -3140,7 +3140,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_p.cpp b/src/gui/text/qtextdocument_p.cpp index 93071aaf59..df0d52d8e9 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -1077,8 +1077,9 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) QTextUndoCommand &last = undoStack[undoState - 1]; 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 (last.tryMerge(c)) return; } diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index 34849df0bb..caa63e15d2 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -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/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 9863955a55..1b2113d281 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; 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/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 7864975091..e65ec15caa 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); @@ -3512,7 +3512,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/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/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index bd2a9d5183..f7741bad2c 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/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); |