diff options
Diffstat (limited to 'src/gui')
33 files changed, 605 insertions, 732 deletions
diff --git a/src/gui/configure.json b/src/gui/configure.json index 3f139cf02d..7efaaff505 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -7,7 +7,6 @@ "commandline": { "options": { - "android-style-assets": "boolean", "angle": "boolean", "direct2d": "boolean", "directfb": "boolean", @@ -422,11 +421,6 @@ "condition": "features.accessibility && features.xcb && features.dbus", "output": [ "privateFeature", "feature" ] }, - "android-style-assets": { - "label": "Android Style Assets", - "condition": "config.android", - "output": [ "privateFeature" ] - }, "angle": { "label": "ANGLE", "autoDetect": "features.opengles2 || features.opengl-dynamic", @@ -978,6 +972,13 @@ "section": "Utilities", "condition": "features.properties", "output": [ "publicFeature", "feature" ] + }, + "multiprocess": { + "label": "Multi process", + "description": "Provides support for detecting the desktop environment, launching external processes and opening URLs.", + "section": "Utilities", + "condition": "!config.integrity", + "output": [ "privateFeature" ] } }, diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 91aaf673d0..fd2298561e 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -381,8 +381,7 @@ inline void QImage::setPixelColor(const QPoint &pt, const QColor &c) { setPixelC #if QT_DEPRECATED_SINCE(5, 0) QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") -QT_WARNING_DISABLE_MSVC(4996) +QT_WARNING_DISABLE_DEPRECATED inline QString QImage::text(const char* key, const char* lang) const { diff --git a/src/gui/image/qimage_sse2.cpp b/src/gui/image/qimage_sse2.cpp index 0fb92e9d43..8f7195e0b5 100644 --- a/src/gui/image/qimage_sse2.cpp +++ b/src/gui/image/qimage_sse2.cpp @@ -51,51 +51,66 @@ bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionF { Q_ASSERT(data->format == QImage::Format_ARGB32 || data->format == QImage::Format_RGBA8888); - // extra pixels on each line - const int spare = data->width & 3; - // width in pixels of the pad at the end of each line - const int pad = (data->bytes_per_line >> 2) - data->width; - const int iter = data->width >> 2; - int height = data->height; + const int width = data->width; + const int height = data->height; + const int bpl = data->bytes_per_line; const __m128i alphaMask = _mm_set1_epi32(0xff000000); const __m128i nullVector = _mm_setzero_si128(); const __m128i half = _mm_set1_epi16(0x80); const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); - __m128i *d = reinterpret_cast<__m128i*>(data->data); - while (height--) { - const __m128i *end = d + iter; - - for (; d != end; ++d) { - const __m128i srcVector = _mm_loadu_si128(d); + uchar *d = data->data; + for (int y = 0; y < height; ++y) { + int i = 0; + quint32 *d32 = reinterpret_cast<quint32 *>(d); + ALIGNMENT_PROLOGUE_16BYTES(d, i, width) { + const quint32 p = d32[i]; + if (p <= 0x00ffffff) + d32[i] = 0; + else if (p < 0xff000000) + d32[i] = qPremultiply(p); + } + __m128i *d128 = reinterpret_cast<__m128i *>(d32 + i); + for (; i < (width - 3); i += 4) { + const __m128i srcVector = _mm_load_si128(d128); +#ifdef __SSE4_1__ + if (_mm_testc_si128(srcVector, alphaMask)) { + // opaque, data is unchanged + } else if (_mm_testz_si128(srcVector, alphaMask)) { + // fully transparent + _mm_store_si128(d128, nullVector); + } else { + const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); +#else const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) { // opaque, data is unchanged } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) == 0xffff) { // fully transparent - _mm_storeu_si128(d, nullVector); + _mm_store_si128(d128, nullVector); } else { +#endif __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); __m128i result; BYTE_MUL_SSE2(result, srcVector, alphaChannel, colorMask, half); result = _mm_or_si128(_mm_andnot_si128(alphaMask, result), srcVectorAlpha); - _mm_storeu_si128(d, result); + _mm_store_si128(d128, result); } + d128++; } - QRgb *p = reinterpret_cast<QRgb*>(d); - QRgb *pe = p+spare; - for (; p != pe; ++p) { - if (*p < 0x00ffffff) - *p = 0; - else if (*p < 0xff000000) - *p = qPremultiply(*p); + SIMD_EPILOGUE(i, width, 3) { + const quint32 p = d32[i]; + if (p <= 0x00ffffff) + d32[i] = 0; + else if (p < 0xff000000) + d32[i] = qPremultiply(p); } - d = reinterpret_cast<__m128i*>(p+pad); + d += bpl; } if (data->format == QImage::Format_ARGB32) diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index eda816f0f2..19015c5dcd 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -124,17 +124,18 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) qint64 readBytes = 0; + char *p; + // scan for database - for (;;) { + do { if ((readBytes = device->readLine(buf, buflen)) <= 0) { // end of file return false; } buf[readBytes] = '\0'; - if (QByteArray::fromRawData(buf, readBytes).contains("0x")) - break; - } + p = strstr(buf, "0x"); + } while (!p); if (outImage->size() != QSize(w, h) || outImage->format() != QImage::Format_MonoLSB) { *outImage = QImage(w, h, QImage::Format_MonoLSB); @@ -148,7 +149,6 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) int x = 0, y = 0; uchar *b = outImage->scanLine(0); - char *p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); w = (w+7)/8; // byte width while (y < h) { // for all encoded bytes... @@ -163,7 +163,8 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) } else { // read another line if ((readBytes = device->readLine(buf,buflen)) <= 0) // EOF ==> truncated image break; - p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); + buf[readBytes] = '\0'; + p = strstr(buf, "0x"); } } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index bf5f6b5f64..d3f3827d6e 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1918,7 +1918,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers, e->source); ev.setTimestamp(e->timestamp); - if (window->d_func()->blockedByModalWindow) { + if (window->d_func()->blockedByModalWindow && !qApp->d_func()->popupActive()) { // a modal window is blocking this window, don't allow mouse events through return; } diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 996ea748b0..3804667ef3 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -199,6 +199,7 @@ public: static void hideModalWindow(QWindow *window); static void updateBlockedStatus(QWindow *window); virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const; + virtual bool popupActive() { return false; } static Qt::MouseButtons buttons; static ulong mousePressTime; diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index d59bd63caf..a6bc7d4d9c 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1528,7 +1528,9 @@ bool QKeySequence::isDetached() const If the key sequence has no keys, an empty string is returned. On \macos, the string returned resembles the sequence that is - shown in the menu bar. + shown in the menu bar if \a format is + QKeySequence::NativeText; otherwise, the string uses the + "portable" format, suitable for writing to a file. \sa fromString() */ diff --git a/src/gui/kernel/qplatformnativeinterface.cpp b/src/gui/kernel/qplatformnativeinterface.cpp index f48e470d1b..6614d45b12 100644 --- a/src/gui/kernel/qplatformnativeinterface.cpp +++ b/src/gui/kernel/qplatformnativeinterface.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qplatformnativeinterface.h" +#include <QtGui/qcursor.h> QT_BEGIN_NAMESPACE diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 19540308a1..e143884f9d 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -867,9 +867,9 @@ inline QPointF operator*(const QPointF& point, const QMatrix4x4& matrix) yin * matrix.m[3][1] + matrix.m[3][3]; if (w == 1.0f) { - return QPointF(float(x), float(y)); + return QPointF(qreal(x), qreal(y)); } else { - return QPointF(float(x / w), float(y / w)); + return QPointF(qreal(x / w), qreal(y / w)); } } @@ -907,33 +907,35 @@ inline QPoint operator*(const QMatrix4x4& matrix, const QPoint& point) inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point) { - float xin, yin; - float x, y, w; + qreal xin, yin; + qreal x, y, w; xin = point.x(); yin = point.y(); if (matrix.flagBits == QMatrix4x4::Identity) { return point; } else if (matrix.flagBits < QMatrix4x4::Rotation2D) { // Translation | Scale - return QPointF(xin * matrix.m[0][0] + matrix.m[3][0], - yin * matrix.m[1][1] + matrix.m[3][1]); + return QPointF(xin * qreal(matrix.m[0][0]) + qreal(matrix.m[3][0]), + yin * qreal(matrix.m[1][1]) + qreal(matrix.m[3][1])); } else if (matrix.flagBits < QMatrix4x4::Perspective) { - return QPointF(xin * matrix.m[0][0] + yin * matrix.m[1][0] + matrix.m[3][0], - xin * matrix.m[0][1] + yin * matrix.m[1][1] + matrix.m[3][1]); + return QPointF(xin * qreal(matrix.m[0][0]) + yin * qreal(matrix.m[1][0]) + + qreal(matrix.m[3][0]), + xin * qreal(matrix.m[0][1]) + yin * qreal(matrix.m[1][1]) + + qreal(matrix.m[3][1])); } else { - x = xin * matrix.m[0][0] + - yin * matrix.m[1][0] + - matrix.m[3][0]; - y = xin * matrix.m[0][1] + - yin * matrix.m[1][1] + - matrix.m[3][1]; - w = xin * matrix.m[0][3] + - yin * matrix.m[1][3] + - matrix.m[3][3]; - if (w == 1.0f) { - return QPointF(float(x), float(y)); + x = xin * qreal(matrix.m[0][0]) + + yin * qreal(matrix.m[1][0]) + + qreal(matrix.m[3][0]); + y = xin * qreal(matrix.m[0][1]) + + yin * qreal(matrix.m[1][1]) + + qreal(matrix.m[3][1]); + w = xin * qreal(matrix.m[0][3]) + + yin * qreal(matrix.m[1][3]) + + qreal(matrix.m[3][3]); + if (w == 1.0) { + return QPointF(qreal(x), qreal(y)); } else { - return QPointF(float(x / w), float(y / w)); + return QPointF(qreal(x / w), qreal(y / w)); } } } diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index 21b051e08e..808e0ee6d7 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -202,7 +202,8 @@ inline QQuaternion QQuaternion::inverted() const double(yp) * double(yp) + double(zp) * double(zp); if (!qFuzzyIsNull(len)) - return QQuaternion(wp / len, -xp / len, -yp / len, -zp / len); + return QQuaternion(double(wp) / len, double(-xp) / len, + double(-yp) / len, double(-zp) / len); return QQuaternion(0.0f, 0.0f, 0.0f, 0.0f); } @@ -251,7 +252,7 @@ inline const QQuaternion operator*(const QQuaternion &q1, const QQuaternion& q2) float zz = (q1.wp + q1.yp) * (q2.wp - q2.zp); float ww = (q1.zp + q1.xp) * (q2.xp + q2.yp); float xx = ww + yy + zz; - float qq = 0.5 * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp)); + float qq = 0.5f * (xx + (q1.zp - q1.xp) * (q2.xp - q2.yp)); float w = qq - ww + (q1.zp - q1.yp) * (q2.yp - q2.zp); float x = qq - xx + (q1.xp + q1.wp) * (q2.xp + q2.wp); diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index e7eff5b7a0..4c778b184e 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -24,7 +24,6 @@ qtConfig(opengl) { opengl/qopenglcustomshaderstage_p.h \ opengl/qopengltextureglyphcache_p.h \ opengl/qopenglshadercache_p.h \ - opengl/qopenglshadercache_meego_p.h \ opengl/qopenglversionfunctions.h \ opengl/qopenglversionfunctionsfactory_p.h \ opengl/qopenglvertexarrayobject.h \ diff --git a/src/gui/opengl/qopenglshadercache_meego_p.h b/src/gui/opengl/qopenglshadercache_meego_p.h deleted file mode 100644 index 0892e1a2a1..0000000000 --- a/src/gui/opengl/qopenglshadercache_meego_p.h +++ /dev/null @@ -1,450 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QOPENGLSHADERCACHE_MEEGO_P_H -#define QOPENGLSHADERCACHE_MEEGO_P_H - -#include <QtCore/qopenglobal.h> - -#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2) - -#include <QtCore/qcryptographichash.h> -#include <QtCore/qsharedmemory.h> -#include <QtCore/qsystemsemaphore.h> - -#ifndef QT_BOOTSTRAPPED -# include <GLES2/gl2ext.h> -#endif -#if defined(QT_DEBUG) || defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE_TRACE) -# include <syslog.h> -#endif - -/* - This cache stores internal Qt shader programs in shared memory. - - This header file is ugly on purpose and can only be included once. It is only to be used - for the internal shader cache, not as a generic cache for anyone's shaders. - - The cache stores either ShaderCacheMaxEntries shader programs or ShaderCacheDataSize kilobytes - of shader programs, whatever limit is reached first. - - The layout of the cache is as outlined in the CachedShaders struct. After some - integers, an array of headers is reserved, then comes the space for the actual binaries. - - Shader Programs are identified by the md5sum of their frag and vertex shader source code. - - Shader Programs are never removed. The cache never shrinks or re-shuffles. This is done - on purpose to ensure minimum amount of locking, no alignment problems and very few write - operations. - - Note: Locking the shader cache could be expensive, because the entire system might hang. - That's why the cache is immutable to minimize the time we need to keep it locked. - - Why is it Meego specific? - - First, the size is chosen so that it fits to generic meego usage. Second, on Meego, there's - always at least one Qt application active (the launcher), so the cache will never be destroyed. - Only when the last Qt app exits, the cache dies, which should only be when someone kills the - X11 server. And last but not least it was only tested with Meego's SGX driver. - - There's a small tool in src/opengl/util/meego that dumps the contents of the cache. - */ - -// anonymous namespace, prevent exporting of the private symbols -namespace -{ - -struct CachedShaderHeader -{ - /* the index in the data[] member of CachedShaders */ - int index; - /* the size of the binary shader */ - GLsizei size; - /* the format of the binary shader */ - GLenum format; - /* the md5sum of the frag+vertex shaders */ - char md5Sum[16]; -}; - -enum -{ - /* The maximum amount of shader programs the cache can hold */ - ShaderCacheMaxEntries = 20 -}; - -typedef CachedShaderHeader CachedShaderHeaders[ShaderCacheMaxEntries]; - -enum -{ - // ShaderCacheDataSize is 20k minus the other data members of CachedShaders - ShaderCacheDataSize = 1024 * ShaderCacheMaxEntries - sizeof(CachedShaderHeaders) - 2 * sizeof(int) -}; - -struct CachedShaders -{ - /* How much space is still available in the cache */ - inline int availableSize() const { return ShaderCacheDataSize - dataSize; } - - /* The current amount of cached shaders */ - int shaderCount; - - /* The current amount (in bytes) of cached data */ - int dataSize; - - /* The headers describing the shaders */ - CachedShaderHeaders headers; - - /* The actual binary data of the shader programs */ - char data[ShaderCacheDataSize]; -}; - -//#define QT_DEBUG_SHADER_CACHE -#ifdef QT_DEBUG_SHADER_CACHE -static QDebug shaderCacheDebug() -{ - return QDebug(QtDebugMsg); -} -#else -static inline QNoDebug shaderCacheDebug() { return QNoDebug(); } -#endif - -class ShaderCacheSharedMemory -{ -public: - ShaderCacheSharedMemory() - : shm(QLatin1String("qt_gles2_shadercache_" QT_VERSION_STR)) - { - // we need a system semaphore here, since cache creation and initialization must be atomic - QSystemSemaphore attachSemaphore(QLatin1String("qt_gles2_shadercache_mutex_" QT_VERSION_STR), 1); - - if (!attachSemaphore.acquire()) { - shaderCacheDebug() << "Unable to require shader cache semaphore:" << attachSemaphore.errorString(); - return; - } - - if (shm.attach()) { - // success! - shaderCacheDebug() << "Attached to shader cache"; - } else { - - // no cache exists - create and initialize it - if (shm.create(sizeof(CachedShaders))) { - shaderCacheDebug() << "Created new shader cache"; - initializeCache(); - } else { - shaderCacheDebug() << "Unable to create shader cache:" << shm.errorString(); - } - } - - attachSemaphore.release(); - } - - inline bool isAttached() const { return shm.isAttached(); } - - inline bool lock() { return shm.lock(); } - inline bool unlock() { return shm.unlock(); } - inline void *data() { return shm.data(); } - inline QString errorString() { return shm.errorString(); } - - ~ShaderCacheSharedMemory() - { - if (!shm.detach()) - shaderCacheDebug() << "Unable to detach shader cache" << shm.errorString(); - } - -private: - void initializeCache() - { - // no need to lock the shared memory since we're already protected by the - // attach system semaphore. - - void *data = shm.data(); - Q_ASSERT(data); - - memset(data, 0, sizeof(CachedShaders)); - } - - QSharedMemory shm; -}; - -class ShaderCacheLocker -{ -public: - inline ShaderCacheLocker(ShaderCacheSharedMemory *cache) - : shm(cache->lock() ? cache : (ShaderCacheSharedMemory *)0) - { - if (!shm) - shaderCacheDebug() << "Unable to lock shader cache" << cache->errorString(); - } - - inline bool isLocked() const { return shm; } - - inline ~ShaderCacheLocker() - { - if (!shm) - return; - if (!shm->unlock()) - shaderCacheDebug() << "Unable to unlock shader cache" << shm->errorString(); - } - -private: - ShaderCacheSharedMemory *shm; -}; - -#ifdef QT_BOOTSTRAPPED -} // end namespace -#else - -static void traceCacheOverflow(const char *message) -{ -#if defined(QT_DEBUG) || defined (QT_MEEGO_EXPERIMENTAL_SHADERCACHE_TRACE) - openlog(qPrintable(QCoreApplication::applicationName()), LOG_PID | LOG_ODELAY, LOG_USER); - syslog(LOG_DEBUG, message); - closelog(); -#endif - shaderCacheDebug() << message; -} - -Q_GLOBAL_STATIC(ShaderCacheSharedMemory, shaderCacheSharedMemory) - -/* - Finds the index of the shader program identified by md5Sum in the cache. - Note: Does NOT lock the cache for reading, the cache must already be locked! - - Returns -1 when no shader was found. - */ -static int qt_cache_index_unlocked(const QByteArray &md5Sum, CachedShaders *cache) -{ - for (int i = 0; i < cache->shaderCount; ++i) { - if (qstrncmp(md5Sum.constData(), cache->headers[i].md5Sum, 16) == 0) { - return i; - } - } - return -1; -} - -/* Returns the index of the shader identified by md5Sum */ -static int qt_cache_index(const QByteArray &md5Sum) -{ - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - Q_ASSERT(md5Sum.length() == 16); - - ShaderCacheLocker locker(shm); - if (!locker.isLocked()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast<CachedShaders *>(data); - - return qt_cache_index_unlocked(md5Sum, cache); -} - -/* Loads the cached shader at index \a shaderIndex into \a program - * Note: Since the cache is immutable, this operation doesn't lock the shared memory. - */ -static bool qt_cached_shader(QOpenGLShaderProgram *program, QOpenGLContext *ctx, int shaderIndex) -{ - Q_ASSERT(shaderIndex >= 0 && shaderIndex <= ShaderCacheMaxEntries); - Q_ASSERT(program); - - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast<CachedShaders *>(data); - - shaderCacheDebug() << "fetching cached shader at index" << shaderIndex - << "dataIndex" << cache->headers[shaderIndex].index - << "size" << cache->headers[shaderIndex].size - << "format" << cache->headers[shaderIndex].format; - - // call program->programId first, since that resolves the glProgramBinaryOES symbol - GLuint programId = program->programId(); - glProgramBinaryOES(programId, cache->headers[shaderIndex].format, - cache->data + cache->headers[shaderIndex].index, - cache->headers[shaderIndex].size); - - return true; -} - -/* Stores the shader program in the cache. Returns false if there's an error with the cache, or - if the cache is too small to hold the shader. */ -static bool qt_cache_shader(const QOpenGLShaderProgram *shader, QOpenGLContext *ctx, const QByteArray &md5Sum) -{ - ShaderCacheSharedMemory *shm = shaderCacheSharedMemory(); - if (!shm || !shm->isAttached()) - return false; - - void *data = shm->data(); - Q_ASSERT(data); - - CachedShaders *cache = reinterpret_cast<CachedShaders *>(data); - - ShaderCacheLocker locker(shm); - if (!locker.isLocked()) - return false; - - int cacheIdx = cache->shaderCount; - if (cacheIdx >= ShaderCacheMaxEntries) { - traceCacheOverflow("Qt OpenGL shader cache index overflow!"); - return false; - } - - // now that we have the lock on the shared memory, make sure no one - // inserted the shader already while we were unlocked - if (qt_cache_index_unlocked(md5Sum, cache) != -1) - return true; // already cached - - shaderCacheDebug() << "Caching shader at index" << cacheIdx; - - GLint binaryLength = 0; - glGetProgramiv(shader->programId(), GL_PROGRAM_BINARY_LENGTH_OES, &binaryLength); - - if (!binaryLength) { - shaderCacheDebug() << "Unable to determine binary shader size!"; - return false; - } - - if (binaryLength > cache->availableSize()) { - traceCacheOverflow("Qt OpenGL shader cache data overflow!"); - return false; - } - - GLsizei size = 0; - GLenum format = 0; - glGetProgramBinaryOES(shader->programId(), binaryLength, &size, &format, - cache->data + cache->dataSize); - - if (!size) { - shaderCacheDebug() << "Unable to get binary shader!"; - return false; - } - - cache->headers[cacheIdx].index = cache->dataSize; - cache->dataSize += binaryLength; - ++cache->shaderCount; - cache->headers[cacheIdx].size = binaryLength; - cache->headers[cacheIdx].format = format; - - memcpy(cache->headers[cacheIdx].md5Sum, md5Sum.constData(), 16); - - shaderCacheDebug() << "cached shader size" << size - << "format" << format - << "binarySize" << binaryLength - << "cache index" << cacheIdx - << "data index" << cache->headers[cacheIdx].index; - - return true; -} - -} // namespace - -QT_BEGIN_NAMESPACE - - -class CachedShader -{ -public: - CachedShader(const QByteArray &fragSource, const QByteArray &vertexSource) - : cacheIdx(-1) - { - QCryptographicHash md5Hash(QCryptographicHash::Md5); - - md5Hash.addData(fragSource); - md5Hash.addData(vertexSource); - - md5Sum = md5Hash.result(); - } - - bool isCached() - { - return cacheIndex() != -1; - } - - int cacheIndex() - { - if (cacheIdx != -1) - return cacheIdx; - cacheIdx = qt_cache_index(md5Sum); - return cacheIdx; - } - - bool load(QOpenGLShaderProgram *program, QOpenGLContext *ctx) - { - if (cacheIndex() == -1) - return false; - return qt_cached_shader(program, ctx, cacheIdx); - } - - bool store(QOpenGLShaderProgram *program, QOpenGLContext *ctx) - { - return qt_cache_shader(program, ctx, md5Sum); - } - -private: - QByteArray md5Sum; - int cacheIdx; -}; - - -QT_END_NAMESPACE - -#endif - -#endif -#endif diff --git a/src/gui/opengl/qopenglshadercache_p.h b/src/gui/opengl/qopenglshadercache_p.h index b4d1d64721..0f730602b0 100644 --- a/src/gui/opengl/qopenglshadercache_p.h +++ b/src/gui/opengl/qopenglshadercache_p.h @@ -53,10 +53,6 @@ #include <QtGui/private/qtguiglobal_p.h> -#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2) -# include "qopenglshadercache_meego_p.h" -#else - QT_BEGIN_NAMESPACE @@ -88,4 +84,3 @@ public: QT_END_NAMESPACE #endif -#endif diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 0a46eea85d..c9b08f60b1 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -410,6 +410,34 @@ static bool isSizedTextureFormat(QOpenGLTexture::TextureFormat internalFormat) case QOpenGLTexture::SRGB8_PunchThrough_Alpha1_ETC2: case QOpenGLTexture::RGBA8_ETC2_EAC: case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: + case QOpenGLTexture::RGBA_ASTC_4x4: + case QOpenGLTexture::RGBA_ASTC_5x4: + case QOpenGLTexture::RGBA_ASTC_5x5: + case QOpenGLTexture::RGBA_ASTC_6x5: + case QOpenGLTexture::RGBA_ASTC_6x6: + case QOpenGLTexture::RGBA_ASTC_8x5: + case QOpenGLTexture::RGBA_ASTC_8x6: + case QOpenGLTexture::RGBA_ASTC_8x8: + case QOpenGLTexture::RGBA_ASTC_10x5: + case QOpenGLTexture::RGBA_ASTC_10x6: + case QOpenGLTexture::RGBA_ASTC_10x8: + case QOpenGLTexture::RGBA_ASTC_10x10: + case QOpenGLTexture::RGBA_ASTC_12x10: + case QOpenGLTexture::RGBA_ASTC_12x12: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_4x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x12: return true; case QOpenGLTexture::RGB8_ETC1: @@ -703,6 +731,36 @@ static QOpenGLTexture::PixelFormat pixelFormatCompatibleWithInternalFormat(QOpen case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: return QOpenGLTexture::RGBA; + case QOpenGLTexture::RGBA_ASTC_4x4: + case QOpenGLTexture::RGBA_ASTC_5x4: + case QOpenGLTexture::RGBA_ASTC_5x5: + case QOpenGLTexture::RGBA_ASTC_6x5: + case QOpenGLTexture::RGBA_ASTC_6x6: + case QOpenGLTexture::RGBA_ASTC_8x5: + case QOpenGLTexture::RGBA_ASTC_8x6: + case QOpenGLTexture::RGBA_ASTC_8x8: + case QOpenGLTexture::RGBA_ASTC_10x5: + case QOpenGLTexture::RGBA_ASTC_10x6: + case QOpenGLTexture::RGBA_ASTC_10x8: + case QOpenGLTexture::RGBA_ASTC_10x10: + case QOpenGLTexture::RGBA_ASTC_12x10: + case QOpenGLTexture::RGBA_ASTC_12x12: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_4x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x12: + return QOpenGLTexture::RGBA; + case QOpenGLTexture::DepthFormat: return QOpenGLTexture::Depth; @@ -859,6 +917,34 @@ static QOpenGLTexture::PixelType pixelTypeCompatibleWithInternalFormat(QOpenGLTe case QOpenGLTexture::RGBA8_ETC2_EAC: case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: case QOpenGLTexture::RGB8_ETC1: + case QOpenGLTexture::RGBA_ASTC_4x4: + case QOpenGLTexture::RGBA_ASTC_5x4: + case QOpenGLTexture::RGBA_ASTC_5x5: + case QOpenGLTexture::RGBA_ASTC_6x5: + case QOpenGLTexture::RGBA_ASTC_6x6: + case QOpenGLTexture::RGBA_ASTC_8x5: + case QOpenGLTexture::RGBA_ASTC_8x6: + case QOpenGLTexture::RGBA_ASTC_8x8: + case QOpenGLTexture::RGBA_ASTC_10x5: + case QOpenGLTexture::RGBA_ASTC_10x6: + case QOpenGLTexture::RGBA_ASTC_10x8: + case QOpenGLTexture::RGBA_ASTC_10x10: + case QOpenGLTexture::RGBA_ASTC_12x10: + case QOpenGLTexture::RGBA_ASTC_12x12: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_4x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x12: return QOpenGLTexture::UInt8; case QOpenGLTexture::DepthFormat: @@ -977,6 +1063,34 @@ static bool isCompressedFormat(QOpenGLTexture::TextureFormat internalFormat) case QOpenGLTexture::RGBA8_ETC2_EAC: case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: case QOpenGLTexture::RGB8_ETC1: + case QOpenGLTexture::RGBA_ASTC_4x4: + case QOpenGLTexture::RGBA_ASTC_5x4: + case QOpenGLTexture::RGBA_ASTC_5x5: + case QOpenGLTexture::RGBA_ASTC_6x5: + case QOpenGLTexture::RGBA_ASTC_6x6: + case QOpenGLTexture::RGBA_ASTC_8x5: + case QOpenGLTexture::RGBA_ASTC_8x6: + case QOpenGLTexture::RGBA_ASTC_8x8: + case QOpenGLTexture::RGBA_ASTC_10x5: + case QOpenGLTexture::RGBA_ASTC_10x6: + case QOpenGLTexture::RGBA_ASTC_10x8: + case QOpenGLTexture::RGBA_ASTC_10x10: + case QOpenGLTexture::RGBA_ASTC_12x10: + case QOpenGLTexture::RGBA_ASTC_12x12: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_4x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x12: return true; case QOpenGLTexture::DepthFormat: @@ -2037,6 +2151,34 @@ QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target \value RGBA8_ETC2_EAC Equivalent to GL_COMPRESSED_RGBA8_ETC2_EAC \value SRGB8_Alpha8_ETC2_EAC Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC \value RGB8_ETC1 Equivalent to GL_ETC1_RGB8_OES + \value RGBA_ASTC_4x4 Equivalent to GL_COMPRESSED_RGBA_ASTC_4x4_KHR + \value RGBA_ASTC_5x4 Equivalent to GL_COMPRESSED_RGBA_ASTC_5x4_KHR + \value RGBA_ASTC_5x5 Equivalent to GL_COMPRESSED_RGBA_ASTC_5x5_KHR + \value RGBA_ASTC_6x5 Equivalent to GL_COMPRESSED_RGBA_ASTC_6x5_KHR + \value RGBA_ASTC_6x6 Equivalent to GL_COMPRESSED_RGBA_ASTC_6x6_KHR + \value RGBA_ASTC_8x5 Equivalent to GL_COMPRESSED_RGBA_ASTC_8x5_KHR + \value RGBA_ASTC_8x6 Equivalent to GL_COMPRESSED_RGBA_ASTC_8x6_KHR + \value RGBA_ASTC_8x8 Equivalent to GL_COMPRESSED_RGBA_ASTC_8x8_KHR + \value RGBA_ASTC_10x5 Equivalent to GL_COMPRESSED_RGBA_ASTC_10x5_KHR + \value RGBA_ASTC_10x6 Equivalent to GL_COMPRESSED_RGBA_ASTC_10x6_KHR + \value RGBA_ASTC_10x8 Equivalent to GL_COMPRESSED_RGBA_ASTC_10x8_KHR + \value RGBA_ASTC_10x10 Equivalent to GL_COMPRESSED_RGBA_ASTC_10x10_KHR + \value RGBA_ASTC_12x10 Equivalent to GL_COMPRESSED_RGBA_ASTC_12x10_KHR + \value RGBA_ASTC_12x12 Equivalent to GL_COMPRESSED_RGBA_ASTC_12x12_KHR + \value SRGB8_Alpha8_ASTC_4x4 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR + \value SRGB8_Alpha8_ASTC_5x4 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR + \value SRGB8_Alpha8_ASTC_5x5 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR + \value SRGB8_Alpha8_ASTC_6x5 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR + \value SRGB8_Alpha8_ASTC_6x6 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR + \value SRGB8_Alpha8_ASTC_8x5 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR + \value SRGB8_Alpha8_ASTC_8x6 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR + \value SRGB8_Alpha8_ASTC_8x8 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR + \value SRGB8_Alpha8_ASTC_10x5 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR + \value SRGB8_Alpha8_ASTC_10x6 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR + \value SRGB8_Alpha8_ASTC_10x8 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR + \value SRGB8_Alpha8_ASTC_10x10 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR + \value SRGB8_Alpha8_ASTC_12x10 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR + \value SRGB8_Alpha8_ASTC_12x12 Equivalent to GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR \value SRGB8 Equivalent to GL_SRGB8 \value SRGB8_Alpha8 Equivalent to GL_SRGB8_ALPHA8 @@ -2592,6 +2734,34 @@ void QOpenGLTexture::setFormat(TextureFormat format) case RGBAFormat: case LuminanceFormat: case LuminanceAlphaFormat: + case QOpenGLTexture::RGBA_ASTC_4x4: + case QOpenGLTexture::RGBA_ASTC_5x4: + case QOpenGLTexture::RGBA_ASTC_5x5: + case QOpenGLTexture::RGBA_ASTC_6x5: + case QOpenGLTexture::RGBA_ASTC_6x6: + case QOpenGLTexture::RGBA_ASTC_8x5: + case QOpenGLTexture::RGBA_ASTC_8x6: + case QOpenGLTexture::RGBA_ASTC_8x8: + case QOpenGLTexture::RGBA_ASTC_10x5: + case QOpenGLTexture::RGBA_ASTC_10x6: + case QOpenGLTexture::RGBA_ASTC_10x8: + case QOpenGLTexture::RGBA_ASTC_10x10: + case QOpenGLTexture::RGBA_ASTC_12x10: + case QOpenGLTexture::RGBA_ASTC_12x12: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_4x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x4: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_5x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_6x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_8x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x5: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x6: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x8: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_10x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x10: + case QOpenGLTexture::SRGB8_Alpha8_ASTC_12x12: d->formatClass = FormatClass_Unique; break; } diff --git a/src/gui/opengl/qopengltexture.h b/src/gui/opengl/qopengltexture.h index 0a948488a6..d0a3bfec8b 100644 --- a/src/gui/opengl/qopengltexture.h +++ b/src/gui/opengl/qopengltexture.h @@ -208,6 +208,34 @@ public: RGBA8_ETC2_EAC = 0x9278, // GL_COMPRESSED_RGBA8_ETC2_EAC SRGB8_Alpha8_ETC2_EAC = 0x9279, // GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC RGB8_ETC1 = 0x8D64, // GL_ETC1_RGB8_OES + RGBA_ASTC_4x4 = 0x93B0, // GL_COMPRESSED_RGBA_ASTC_4x4_KHR + RGBA_ASTC_5x4 = 0x93B1, // GL_COMPRESSED_RGBA_ASTC_5x4_KHR + RGBA_ASTC_5x5 = 0x93B2, // GL_COMPRESSED_RGBA_ASTC_5x5_KHR + RGBA_ASTC_6x5 = 0x93B3, // GL_COMPRESSED_RGBA_ASTC_6x5_KHR + RGBA_ASTC_6x6 = 0x93B4, // GL_COMPRESSED_RGBA_ASTC_6x6_KHR + RGBA_ASTC_8x5 = 0x93B5, // GL_COMPRESSED_RGBA_ASTC_8x5_KHR + RGBA_ASTC_8x6 = 0x93B6, // GL_COMPRESSED_RGBA_ASTC_8x6_KHR + RGBA_ASTC_8x8 = 0x93B7, // GL_COMPRESSED_RGBA_ASTC_8x8_KHR + RGBA_ASTC_10x5 = 0x93B8, // GL_COMPRESSED_RGBA_ASTC_10x5_KHR + RGBA_ASTC_10x6 = 0x93B9, // GL_COMPRESSED_RGBA_ASTC_10x6_KHR + RGBA_ASTC_10x8 = 0x93BA, // GL_COMPRESSED_RGBA_ASTC_10x8_KHR + RGBA_ASTC_10x10 = 0x93BB, // GL_COMPRESSED_RGBA_ASTC_10x10_KHR + RGBA_ASTC_12x10 = 0x93BC, // GL_COMPRESSED_RGBA_ASTC_12x10_KHR + RGBA_ASTC_12x12 = 0x93BD, // GL_COMPRESSED_RGBA_ASTC_12x12_KHR + SRGB8_Alpha8_ASTC_4x4 = 0x93D0, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR + SRGB8_Alpha8_ASTC_5x4 = 0x93D1, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR + SRGB8_Alpha8_ASTC_5x5 = 0x93D2, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR + SRGB8_Alpha8_ASTC_6x5 = 0x93D3, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR + SRGB8_Alpha8_ASTC_6x6 = 0x93D4, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR + SRGB8_Alpha8_ASTC_8x5 = 0x93D5, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR + SRGB8_Alpha8_ASTC_8x6 = 0x93D6, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR + SRGB8_Alpha8_ASTC_8x8 = 0x93D7, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR + SRGB8_Alpha8_ASTC_10x5 = 0x93D8, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR + SRGB8_Alpha8_ASTC_10x6 = 0x93D9, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR + SRGB8_Alpha8_ASTC_10x8 = 0x93DA, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR + SRGB8_Alpha8_ASTC_10x10 = 0x93DB, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR + SRGB8_Alpha8_ASTC_12x10 = 0x93DC, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR + SRGB8_Alpha8_ASTC_12x12 = 0x93DD, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR // sRGB formats SRGB8 = 0x8C41, // GL_SRGB8 diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp index 0a5d458532..a4a091a29f 100644 --- a/src/gui/painting/qblendfunctions.cpp +++ b/src/gui/painting/qblendfunctions.cpp @@ -385,19 +385,25 @@ void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl, destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); fflush(stdout); #endif - - if (const_alpha != 256) { - qt_blend_argb32_on_argb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha); - return; - } - const uint *src = (const uint *) srcPixels; uint *dst = (uint *) destPixels; - int len = w * 4; - for (int y=0; y<h; ++y) { - memcpy(dst, src, len); - dst = (quint32 *)(((uchar *) dst) + dbpl); - src = (const quint32 *)(((const uchar *) src) + sbpl); + if (const_alpha == 256) { + const int len = w * 4; + for (int y = 0; y < h; ++y) { + memcpy(dst, src, len); + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } + return; + } else if (const_alpha != 0) { + const_alpha = (const_alpha * 255) >> 8; + int ialpha = 255 - const_alpha; + for (int y=0; y<h; ++y) { + for (int x=0; x<w; ++x) + dst[x] = INTERPOLATE_PIXEL_255(dst[x], ialpha, src[x], const_alpha); + dst = (quint32 *)(((uchar *) dst) + dbpl); + src = (const quint32 *)(((const uchar *) src) + sbpl); + } } } @@ -414,7 +420,7 @@ struct Blend_RGB32_on_RGB32_ConstAlpha { } inline void write(quint32 *dst, quint32 src) { - *dst = BYTE_MUL(src, m_alpha) + BYTE_MUL(*dst, m_ialpha); + *dst = INTERPOLATE_PIXEL_255(src, m_alpha, *dst, m_ialpha); } inline void flush(void *) {} diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index e3dbf663e1..6a8091bf8b 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -795,12 +795,20 @@ QColor::QColor(Spec spec) Q_DECL_NOTHROW /*! \fn QColor::QColor(const char *name) + + Constructs a named color in the same way as setNamedColor() using + the given \a name. + \overload \sa setNamedColor(), name(), isValid() */ /*! \fn QColor::QColor(QLatin1String name) + + Constructs a named color in the same way as setNamedColor() using + the given \a name. + \overload \since 5.8 \sa setNamedColor(), name(), isValid() diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index a29d60ca6e..bf0be7f3d3 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -147,13 +147,16 @@ NSImage *qt_mac_create_nsimage(const QPixmap &pm) return nsImage; } -NSImage *qt_mac_create_nsimage(const QIcon &icon) +NSImage *qt_mac_create_nsimage(const QIcon &icon, int defaultSize) { if (icon.isNull()) return nil; NSImage *nsImage = [[NSImage alloc] init]; - foreach (QSize size, icon.availableSizes()) { + QList<QSize> availableSizes = icon.availableSizes(); + if (availableSizes.isEmpty() && defaultSize > 0) + availableSizes << QSize(defaultSize, defaultSize); + foreach (QSize size, availableSizes) { QPixmap pm = icon.pixmap(size); QImage image = pm.toImage(); CGImageRef cgImage = qt_mac_toCGImage(image); diff --git a/src/gui/painting/qcoregraphics_p.h b/src/gui/painting/qcoregraphics_p.h index ab2579387e..065910222d 100644 --- a/src/gui/painting/qcoregraphics_p.h +++ b/src/gui/painting/qcoregraphics_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE #ifdef Q_OS_MACOS Q_GUI_EXPORT NSImage *qt_mac_create_nsimage(const QPixmap &pm); -Q_GUI_EXPORT NSImage *qt_mac_create_nsimage(const QIcon &icon); +Q_GUI_EXPORT NSImage *qt_mac_create_nsimage(const QIcon &icon, int defaultSize = 0); Q_GUI_EXPORT QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size); #endif Q_GUI_EXPORT CGImageRef qt_mac_toCGImage(const QImage &qImage); diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index ae62aeca5f..08f96bd654 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -218,8 +218,8 @@ static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *sr uint green = (src[i] >> greenShift<Format>()) & greenMask; uint blue = (src[i] >> blueShift<Format>()) & blueMask; - red = ((red << redLeftShift) | (red >> redRightShift)) << 16; - green = ((green << greenLeftShift) | (green >> greenRightShift)) << 8; + red = ((red << redLeftShift) | (red >> redRightShift)); + green = ((green << greenLeftShift) | (green >> greenRightShift)); blue = (blue << blueLeftShift) | (blue >> blueRightShift); buffer[i] = QRgba64::fromRgba(red, green, blue, 255); } @@ -581,6 +581,8 @@ static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint * int i = 0; for (; ((uintptr_t)buffer & 0xf) && i < count; ++i) { uint s = *src++; + if (maskAlpha) + s = s | 0xff000000; if (RGBA) s = RGBA2ARGB(s); *buffer++ = QRgba64::fromArgb32(s); @@ -606,6 +608,8 @@ static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint * SIMD_EPILOGUE(i, count, 3) { uint s = *src++; + if (maskAlpha) + s = s | 0xff000000; if (RGBA) s = RGBA2ARGB(s); *buffer++ = QRgba64::fromArgb32(s); @@ -837,7 +841,10 @@ static const uint *QT_FASTCALL convertGrayscale8FromARGB32PM(uint *buffer, const } template <QPixelLayout::BPP bpp> static -uint QT_FASTCALL fetchPixel(const uchar *src, int index); +uint QT_FASTCALL fetchPixel(const uchar *, int) +{ + Q_UNREACHABLE(); +} template <> inline uint QT_FASTCALL fetchPixel<QPixelLayout::BPP1LSB>(const uchar *src, int index) @@ -1555,102 +1562,28 @@ static const QRgba64 *QT_FASTCALL fetchUntransformed64(QRgba64 *buffer, const Op } } -// blendType is either BlendTransformed or BlendTransformedTiled -template<TextureBlendType blendType> -static const uint *QT_FASTCALL fetchTransformedARGB32PM(uint *buffer, const Operator *, const QSpanData *data, - int y, int x, int length) -{ - int image_width = data->texture.width; - int image_height = data->texture.height; - - const qreal cx = x + qreal(0.5); - const qreal cy = y + qreal(0.5); - - const uint *end = buffer + length; - uint *b = buffer; - if (data->fast_matrix) { - // The increment pr x in the scanline - int fdx = (int)(data->m11 * fixed_scale); - int fdy = (int)(data->m12 * fixed_scale); - - int fx = int((data->m21 * cy - + data->m11 * cx + data->dx) * fixed_scale); - int fy = int((data->m22 * cy - + data->m12 * cx + data->dy) * fixed_scale); - - while (b < end) { - int px = fx >> 16; - int py = fy >> 16; - - if (blendType == BlendTransformedTiled) { - px %= image_width; - py %= image_height; - if (px < 0) px += image_width; - if (py < 0) py += image_height; - } else { - px = qBound(0, px, image_width - 1); - py = qBound(0, py, image_height - 1); - } - *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; - - fx += fdx; - fy += fdy; - ++b; - } - } else { - const qreal fdx = data->m11; - const qreal fdy = data->m12; - const qreal fdw = data->m13; - - qreal fx = data->m21 * cy + data->m11 * cx + data->dx; - qreal fy = data->m22 * cy + data->m12 * cx + data->dy; - qreal fw = data->m23 * cy + data->m13 * cx + data->m33; - - while (b < end) { - const qreal iw = fw == 0 ? 1 : 1 / fw; - const qreal tx = fx * iw; - const qreal ty = fy * iw; - int px = int(tx) - (tx < 0); - int py = int(ty) - (ty < 0); - - if (blendType == BlendTransformedTiled) { - px %= image_width; - py %= image_height; - if (px < 0) px += image_width; - if (py < 0) py += image_height; - } else { - px = qBound(0, px, image_width - 1); - py = qBound(0, py, image_height - 1); - } - *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; - - fx += fdx; - fy += fdy; - fw += fdw; - //force increment to avoid /0 - if (!fw) { - fw += fdw; - } - ++b; - } - } - return buffer; -} - -template<TextureBlendType blendType> /* either BlendTransformed or BlendTransformedTiled */ +template<TextureBlendType blendType, QPixelLayout::BPP bpp> static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { - int image_width = data->texture.width; - int image_height = data->texture.height; + Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled); + const int image_width = data->texture.width; + const int image_height = data->texture.height; + const int image_x1 = data->texture.x1; + const int image_y1 = data->texture.y1; + const int image_x2 = data->texture.x2 - 1; + const int image_y2 = data->texture.y2 - 1; const qreal cx = x + qreal(0.5); const qreal cy = y + qreal(0.5); const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; - FetchPixelFunc fetch = qFetchPixel[layout->bpp]; + if (bpp != QPixelLayout::BPPNone) // Like this to not ICE on GCC 5.3.1 + Q_ASSERT(layout->bpp == bpp); + // When templated 'fetch' should be inlined at compile time: + const FetchPixelFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : fetchPixel<bpp>; - const uint *end = buffer + length; + uint *const end = buffer + length; uint *b = buffer; if (data->fast_matrix) { // The increment pr x in the scanline @@ -1672,8 +1605,8 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, if (px < 0) px += image_width; if (py < 0) py += image_height; } else { - px = qBound(0, px, image_width - 1); - py = qBound(0, py, image_height - 1); + px = qBound(image_x1, px, image_x2); + py = qBound(image_y1, py, image_y2); } *b = fetch(data->texture.scanLine(py), px); @@ -1703,8 +1636,8 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, if (px < 0) px += image_width; if (py < 0) py += image_height; } else { - px = qBound(0, px, image_width - 1); - py = qBound(0, py, image_height - 1); + px = qBound(image_x1, px, image_x2); + py = qBound(image_y1, py, image_y2); } *b = fetch(data->texture.scanLine(py), px); @@ -1725,8 +1658,12 @@ template<TextureBlendType blendType> /* either BlendTransformed or BlendTransfo static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { - int image_width = data->texture.width; - int image_height = data->texture.height; + const int image_width = data->texture.width; + const int image_height = data->texture.height; + const int image_x1 = data->texture.x1; + const int image_y1 = data->texture.y1; + const int image_x2 = data->texture.x2 - 1; + const int image_y2 = data->texture.y2 - 1; const qreal cx = x + qreal(0.5); const qreal cy = y + qreal(0.5); @@ -1763,8 +1700,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper if (px < 0) px += image_width; if (py < 0) py += image_height; } else { - px = qBound(0, px, image_width - 1); - py = qBound(0, py, image_height - 1); + px = qBound(image_x1, px, image_x2); + py = qBound(image_y1, py, image_y2); } buffer32[j] = fetch(data->texture.scanLine(py), px); @@ -1804,8 +1741,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper if (px < 0) px += image_width; if (py < 0) py += image_height; } else { - px = qBound(0, px, image_width - 1); - py = qBound(0, py, image_height - 1); + px = qBound(image_x1, px, image_x2); + py = qBound(image_y1, py, image_y2); } buffer32[j] = fetch(data->texture.scanLine(py), px); @@ -2307,7 +2244,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c } } } else { //rotation - if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) { + if (std::abs(data->m11) < (1./8.) || std::abs(data->m22) < (1./8.)) { //if we are zooming more than 8 times, we use 8bit precision for the position. while (b < end) { int x1 = (fx >> 16); @@ -2586,12 +2523,17 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c } // blendType = BlendTransformedBilinear or BlendTransformedBilinearTiled -template<TextureBlendType blendType> +template<TextureBlendType blendType, QPixelLayout::BPP bpp> static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; const QVector<QRgb> *clut = data->texture.colorTable; + if (bpp != QPixelLayout::BPPNone) // Like this to not ICE on GCC 5.3.1 + Q_ASSERT(layout->bpp == bpp); + // When templated 'fetch' should be inlined at compile time: + const FetchPixelsFunc fetch = (bpp == QPixelLayout::BPPNone) ? qFetchPixels[layout->bpp] : fetchPixels<bpp>; + const FetchPixelFunc fetch1 = (bpp == QPixelLayout::BPPNone) ? qFetchPixel[layout->bpp] : fetchPixel<bpp>; int image_width = data->texture.width; int image_height = data->texture.height; @@ -2629,7 +2571,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper // The idea is first to do the interpolation between the row s1 and the row s2 // into an intermediate buffer, then we interpolate between two pixel of this buffer. - FetchPixelsFunc fetch = qFetchPixels[layout->bpp]; // +1 for the last pixel to interpolate with, and +1 for rounding errors. uint buf1[buffer_size + 2]; uint buf2[buffer_size + 2]; @@ -2718,7 +2659,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper fx += fdx; } } else { - FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint buf1[buffer_size]; uint buf2[buffer_size]; uint *b = buffer; @@ -2729,19 +2669,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper int x1 = (fx >> 16); int x2; fetchTransformedBilinear_pixelBounds<blendType>(image_width, image_x1, image_x2, x1, x2); - - if (layout->bpp == QPixelLayout::BPP32) { - buf1[i * 2 + 0] = ((const uint*)s1)[x1]; - buf1[i * 2 + 1] = ((const uint*)s1)[x2]; - buf2[i * 2 + 0] = ((const uint*)s2)[x1]; - buf2[i * 2 + 1] = ((const uint*)s2)[x2]; - } else { - buf1[i * 2 + 0] = fetch(s1, x1); - buf1[i * 2 + 1] = fetch(s1, x2); - buf2[i * 2 + 0] = fetch(s2, x1); - buf2[i * 2 + 1] = fetch(s2, x2); - } - + buf1[i * 2 + 0] = fetch1(s1, x1); + buf1[i * 2 + 1] = fetch1(s1, x2); + buf2[i * 2 + 0] = fetch1(s2, x1); + buf2[i * 2 + 1] = fetch1(s2, x2); fx += fdx; } layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0); @@ -2771,7 +2702,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper } } } else { //rotation - FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint buf1[buffer_size]; uint buf2[buffer_size]; uint *b = buffer; @@ -2790,26 +2720,17 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); - - if (layout->bpp == QPixelLayout::BPP32) { - buf1[i * 2 + 0] = ((const uint*)s1)[x1]; - buf1[i * 2 + 1] = ((const uint*)s1)[x2]; - buf2[i * 2 + 0] = ((const uint*)s2)[x1]; - buf2[i * 2 + 1] = ((const uint*)s2)[x2]; - } else { - buf1[i * 2 + 0] = fetch(s1, x1); - buf1[i * 2 + 1] = fetch(s1, x2); - buf2[i * 2 + 0] = fetch(s2, x1); - buf2[i * 2 + 1] = fetch(s2, x2); - } - + buf1[i * 2 + 0] = fetch1(s1, x1); + buf1[i * 2 + 1] = fetch1(s1, x2); + buf2[i * 2 + 0] = fetch1(s2, x1); + buf2[i * 2 + 1] = fetch1(s2, x2); fx += fdx; fy += fdy; } 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 (std::abs(data->m11) < (1./8.) || std::abs(data->m22) < (1./8.)) { //if we are zooming more than 8 times, we use 8bit precision for the position. for (int i = 0; i < len; ++i) { int distx = (fracX & 0x0000ffff) >> 8; @@ -2849,7 +2770,6 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper qreal fy = data->m22 * cy + data->m12 * cx + data->dy; qreal fw = data->m23 * cy + data->m13 * cx + data->m33; - FetchPixelFunc fetch = qFetchPixel[layout->bpp]; uint buf1[buffer_size]; uint buf2[buffer_size]; uint *b = buffer; @@ -2877,18 +2797,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); - - if (layout->bpp == QPixelLayout::BPP32) { - buf1[i * 2 + 0] = ((const uint*)s1)[x1]; - buf1[i * 2 + 1] = ((const uint*)s1)[x2]; - buf2[i * 2 + 0] = ((const uint*)s2)[x1]; - buf2[i * 2 + 1] = ((const uint*)s2)[x2]; - } else { - buf1[i * 2 + 0] = fetch(s1, x1); - buf1[i * 2 + 1] = fetch(s1, x2); - buf2[i * 2 + 0] = fetch(s2, x1); - buf2[i * 2 + 1] = fetch(s2, x2); - } + buf1[i * 2 + 0] = fetch1(s1, x1); + buf1[i * 2 + 1] = fetch1(s1, x2); + buf2[i * 2 + 0] = fetch1(s2, x1); + buf2[i * 2 + 1] = fetch1(s2, x2); fx += fdx; fy += fdy; @@ -3294,23 +3206,32 @@ static SourceFetchProc sourceFetchUntransformed[QImage::NImageFormats] = { }; static const SourceFetchProc sourceFetchGeneric[NBlendTypes] = { - fetchUntransformed, // Untransformed - fetchUntransformed, // Tiled - fetchTransformed<BlendTransformed>, // Transformed - fetchTransformed<BlendTransformedTiled>, // TransformedTiled - fetchTransformedBilinear<BlendTransformedBilinear>, // Bilinear - fetchTransformedBilinear<BlendTransformedBilinearTiled> // BilinearTiled + fetchUntransformed, // Untransformed + fetchUntransformed, // Tiled + fetchTransformed<BlendTransformed, QPixelLayout::BPPNone>, // Transformed + fetchTransformed<BlendTransformedTiled, QPixelLayout::BPPNone>, // TransformedTiled + fetchTransformedBilinear<BlendTransformedBilinear, QPixelLayout::BPPNone>, // TransformedBilinear + fetchTransformedBilinear<BlendTransformedBilinearTiled, QPixelLayout::BPPNone> // TransformedBilinearTiled }; static SourceFetchProc sourceFetchARGB32PM[NBlendTypes] = { fetchUntransformedARGB32PM, // Untransformed fetchUntransformedARGB32PM, // Tiled - fetchTransformedARGB32PM<BlendTransformed>, // Transformed - fetchTransformedARGB32PM<BlendTransformedTiled>, // TransformedTiled + fetchTransformed<BlendTransformed, QPixelLayout::BPP32>, // Transformed + fetchTransformed<BlendTransformedTiled, QPixelLayout::BPP32>, // TransformedTiled fetchTransformedBilinearARGB32PM<BlendTransformedBilinear>, // Bilinear fetchTransformedBilinearARGB32PM<BlendTransformedBilinearTiled> // BilinearTiled }; +static SourceFetchProc sourceFetchAny32[NBlendTypes] = { + fetchUntransformed, // Untransformed + fetchUntransformed, // Tiled + fetchTransformed<BlendTransformed, QPixelLayout::BPP32>, // Transformed + fetchTransformed<BlendTransformedTiled, QPixelLayout::BPP32>, // TransformedTiled + fetchTransformedBilinear<BlendTransformedBilinear, QPixelLayout::BPP32>, // TransformedBilinear + fetchTransformedBilinear<BlendTransformedBilinearTiled, QPixelLayout::BPP32> // TransformedBilinearTiled +}; + static const SourceFetchProc64 sourceFetchGeneric64[NBlendTypes] = { fetchUntransformed64, // Untransformed fetchUntransformed64, // Tiled @@ -3326,6 +3247,8 @@ static inline SourceFetchProc getSourceFetch(TextureBlendType blendType, QImage: return sourceFetchARGB32PM[blendType]; if (blendType == BlendUntransformed || blendType == BlendTiled) return sourceFetchUntransformed[format]; + if (qPixelLayouts[format].bpp == QPixelLayout::BPP32) + return sourceFetchAny32[blendType]; return sourceFetchGeneric[blendType]; } @@ -4718,8 +4641,10 @@ static void blend_transformed_argb(int count, const QSpan *spans, void *userData CompositionFunction func = functionForMode[data->rasterBuffer->compositionMode]; uint buffer[buffer_size]; - int image_width = data->texture.width; - int image_height = data->texture.height; + const int image_x1 = data->texture.x1; + const int image_y1 = data->texture.y1; + const int image_x2 = data->texture.x2 - 1; + const int image_y2 = data->texture.y2 - 1; if (data->fast_matrix) { // The increment pr x in the scanline @@ -4746,8 +4671,8 @@ static void blend_transformed_argb(int count, const QSpan *spans, void *userData const uint *end = buffer + l; uint *b = buffer; while (b < end) { - int px = qBound(0, x >> 16, image_width - 1); - int py = qBound(0, y >> 16, image_height - 1); + int px = qBound(image_x1, x >> 16, image_x2); + int py = qBound(image_y1, y >> 16, image_y2); *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; x += fdx; @@ -4786,8 +4711,8 @@ static void blend_transformed_argb(int count, const QSpan *spans, void *userData const qreal iw = w == 0 ? 1 : 1 / w; const qreal tx = x * iw; const qreal ty = y * iw; - const int px = qBound(0, int(tx) - (tx < 0), image_width - 1); - const int py = qBound(0, int(ty) - (ty < 0), image_height - 1); + const int px = qBound(image_x1, int(tx) - (tx < 0), image_x2); + const int py = qBound(image_y1, int(ty) - (ty < 0), image_y2); *b = reinterpret_cast<const uint *>(data->texture.scanLine(py))[px]; x += fdx; @@ -4819,8 +4744,10 @@ static void blend_transformed_rgb565(int count, const QSpan *spans, void *userDa } quint16 buffer[buffer_size]; - const int image_width = data->texture.width; - const int image_height = data->texture.height; + const int image_x1 = data->texture.x1; + const int image_y1 = data->texture.y1; + const int image_x2 = data->texture.x2 - 1; + const int image_y2 = data->texture.y2 - 1; if (data->fast_matrix) { // The increment pr x in the scanline @@ -4858,8 +4785,8 @@ static void blend_transformed_rgb565(int count, const QSpan *spans, void *userDa const quint16 *end = b + l; while (b < end) { - const int px = qBound(0, x >> 16, image_width - 1); - const int py = qBound(0, y >> 16, image_height - 1); + const int px = qBound(image_x1, x >> 16, image_x2); + const int py = qBound(image_y1, y >> 16, image_y2); *b = ((const quint16 *)data->texture.scanLine(py))[px]; ++b; @@ -4917,8 +4844,8 @@ static void blend_transformed_rgb565(int count, const QSpan *spans, void *userDa const qreal tx = x * iw; const qreal ty = y * iw; - const int px = qBound(0, int(tx) - (tx < 0), image_width - 1); - const int py = qBound(0, int(ty) - (ty < 0), image_height - 1); + const int px = qBound(image_x1, int(tx) - (tx < 0), image_x2); + const int py = qBound(image_y1, int(ty) - (ty < 0), image_y2); *b = ((const quint16 *)data->texture.scanLine(py))[px]; ++b; diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp index acc9bc7ba1..9c1335298e 100644 --- a/src/gui/painting/qdrawhelper_avx2.cpp +++ b/src/gui/painting/qdrawhelper_avx2.cpp @@ -267,11 +267,9 @@ void qt_blend_rgb32_on_rgb32_avx2(uchar *destPixels, int dbpl, // 2) interpolate pixels with AVX2 for (; x < (w - 7); x += 8) { const __m256i srcVector = _mm256_lddqu_si256((const __m256i *)&src[x]); - if (!_mm256_testz_si256(srcVector, srcVector)) { - __m256i dstVector = _mm256_load_si256((__m256i *)&dst[x]); - INTERPOLATE_PIXEL_255_AVX2(srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half); - _mm256_store_si256((__m256i *)&dst[x], dstVector); - } + __m256i dstVector = _mm256_load_si256((__m256i *)&dst[x]); + INTERPOLATE_PIXEL_255_AVX2(srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half); + _mm256_store_si256((__m256i *)&dst[x], dstVector); } // 3) Epilogue diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp index d51b43961c..a833520b00 100644 --- a/src/gui/painting/qdrawhelper_neon.cpp +++ b/src/gui/painting/qdrawhelper_neon.cpp @@ -523,8 +523,6 @@ void qt_blend_rgb32_on_rgb32_neon(uchar *destPixels, int dbpl, vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high)); } for (; x<w; ++x) { - uint s = src[x]; - s = BYTE_MUL(s, const_alpha); dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha); } dst = (quint32 *)(((uchar *) dst) + dbpl); diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index 5ff08e8153..edce70d2d0 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -101,7 +101,6 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, quint32 *dst = (quint32 *) destPixels; if (const_alpha != 256) { if (const_alpha != 0) { - const __m128i nullVector = _mm_set1_epi32(0); const __m128i half = _mm_set1_epi16(0x80); const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); @@ -119,12 +118,10 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, for (; x < w-3; x += 4) { __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[x]); - if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) { - const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); - __m128i result; - INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half); - _mm_store_si128((__m128i *)&dst[x], result); - } + const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); + __m128i result; + INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half); + _mm_store_si128((__m128i *)&dst[x], result); } SIMD_EPILOGUE(x, w, 3) dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha); diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 31d832a9ce..a0438bd458 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -2211,6 +2211,7 @@ void Parser::init(const QString &css, bool isFile) bool Parser::parse(StyleSheet *styleSheet, Qt::CaseSensitivity nameCaseSensitivity) { if (testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("charset"))) { + while (test(S) || test(CDO) || test(CDC)) {} if (!next(STRING)) return false; if (!next(SEMICOLON)) return false; } diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index d2da24ca94..43648d0f7f 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -406,9 +406,14 @@ QtFontFoundry *QtFontFamily::foundry(const QString &f, bool create) return foundries[count++]; } +static inline bool equalsCaseInsensitive(const QString &a, const QString &b) +{ + return a.size() == b.size() && a.compare(b, Qt::CaseInsensitive) == 0; +} + bool QtFontFamily::matchesFamilyName(const QString &familyName) const { - return name.compare(familyName, Qt::CaseInsensitive) == 0 || aliases.contains(familyName, Qt::CaseInsensitive); + return equalsCaseInsensitive(name, familyName) || aliases.contains(familyName, Qt::CaseInsensitive); } void QtFontFamily::ensurePopulated() @@ -947,8 +952,8 @@ QFontEngine *loadSingleEngine(int script, return 0; } + engine->isSmoothlyScalable = style->smoothScalable; fontCache->insertEngine(key, engine); - return engine; } } @@ -973,6 +978,7 @@ QFontEngine *loadSingleEngine(int script, return 0; } + engine->isSmoothlyScalable = style->smoothScalable; fontCache->insertEngine(key, engine); if (Q_LIKELY(cacheForCommonScript && !engine->symbol)) { diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 74ea8d15b7..0b2972f189 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -53,7 +53,7 @@ #include <qendian.h> #include <private/qstringiterator_p.h> -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) # include "qharfbuzzng_p.h" # include <harfbuzz/hb-ot.h> #endif @@ -93,7 +93,7 @@ static inline bool qSafeFromBigEndian(const uchar *source, const uchar *end, T * // Harfbuzz helper functions -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) Q_GLOBAL_STATIC_WITH_ARGS(bool, useHarfbuzzNG,(qgetenv("QT_HARFBUZZ") != "old")) bool qt_useHarfbuzzNG() @@ -257,6 +257,7 @@ QFontEngine::QFontEngine(Type type) cache_cost = 0; fsType = 0; symbol = false; + isSmoothlyScalable = false; glyphFormat = Format_None; m_subPixelPositionCount = 0; @@ -296,7 +297,7 @@ QFixed QFontEngine::underlinePosition() const void *QFontEngine::harfbuzzFont() const { Q_ASSERT(type() != QFontEngine::Multi); -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (qt_useHarfbuzzNG()) return hb_qt_font_get_for_engine(const_cast<QFontEngine *>(this)); #endif @@ -331,7 +332,7 @@ void *QFontEngine::harfbuzzFont() const void *QFontEngine::harfbuzzFace() const { Q_ASSERT(type() != QFontEngine::Multi); -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (qt_useHarfbuzzNG()) return hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this)); #endif @@ -363,7 +364,7 @@ bool QFontEngine::supportsScript(QChar::Script script) const return true; } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (qt_useHarfbuzzNG()) { #if defined(Q_OS_DARWIN) // in AAT fonts, 'gsub' table is effectively replaced by 'mort'/'morx' table diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 42610e9b70..c0e350f755 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -325,6 +325,7 @@ public: uint cache_cost; // amount of mem used in bytes by the font uint fsType : 16; bool symbol; + bool isSmoothlyScalable; struct KernPair { uint left_right; QFixed adjust; diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h index 95a21eedb6..fabf222bae 100644 --- a/src/gui/text/qharfbuzzng_p.h +++ b/src/gui/text/qharfbuzzng_p.h @@ -53,6 +53,9 @@ // #include <QtGui/private/qtguiglobal_p.h> + +QT_REQUIRE_CONFIG(harfbuzz); + #include <QtCore/qchar.h> #include <harfbuzz/hb.h> diff --git a/src/gui/text/qinputcontrol.cpp b/src/gui/text/qinputcontrol.cpp new file mode 100644 index 0000000000..c2c198866a --- /dev/null +++ b/src/gui/text/qinputcontrol.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qinputcontrol_p.h" +#include <QtGui/qevent.h> + +QT_BEGIN_NAMESPACE + +QInputControl::QInputControl(Type type, QObject *parent) + : QObject(parent) + , m_type(type) +{ +} + +QInputControl::QInputControl(Type type, QObjectPrivate &dd, QObject *parent) + : QObject(dd, parent) + , m_type(type) +{ +} + +bool QInputControl::isAcceptableInput(const QKeyEvent *event) const +{ + const QString text = event->text(); + if (text.isEmpty()) + return false; + + const QChar c = text.at(0); + + // ZWNJ and ZWJ. This needs to go before the next test, since CTRL+SHIFT is + // used to input it on Windows. + if (c == QChar(0x200C) || c == QChar(0x200D)) + return true; + + // QTBUG-35734: ignore Ctrl/Ctrl+Shift; accept only AltGr (Alt+Ctrl) on German keyboards + if (event->modifiers() == Qt::ControlModifier + || event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) { + return false; + } + + if (c.isPrint()) + return true; + + if (c.category() == QChar::Other_PrivateUse) + return true; + + if (m_type == TextEdit && c == QLatin1Char('\t')) + return true; + + return false; +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qinputcontrol_p.h b/src/gui/text/qinputcontrol_p.h new file mode 100644 index 0000000000..3b46067ba9 --- /dev/null +++ b/src/gui/text/qinputcontrol_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QINPUTCONTROL_P_H +#define QINPUTCONTROL_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 <QtCore/qobject.h> +#include <qtguiglobal.h> + +QT_BEGIN_NAMESPACE + +class QKeyEvent; +class Q_GUI_EXPORT QInputControl : public QObject +{ + Q_OBJECT +public: + enum Type { + LineEdit, + TextEdit + }; + + explicit QInputControl(Type type, QObject *parent = nullptr); + + bool isAcceptableInput(const QKeyEvent *event) const; + +protected: + explicit QInputControl(Type type, QObjectPrivate &dd, QObject *parent = nullptr); + +private: + const Type m_type; +}; + +QT_END_NAMESPACE + +#endif // QINPUTCONTROL_P_H diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 742b01dd1f..67cafa53fe 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -37,6 +37,7 @@ ** ****************************************************************************/ +#include <QtGui/private/qtguiglobal_p.h> #include "qdebug.h" #include "qtextformat.h" #include "qtextformat_p.h" @@ -837,7 +838,7 @@ enum JustificationClass { Justification_Arabic_Kashida = 13 // User-inserted Kashida(U+0640) }; -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) /* Adds an inter character justification opportunity after the number or letter @@ -916,7 +917,7 @@ static inline void qt_getJustificationOpportunities(const ushort *string, int le qt_getDefaultJustificationOpportunities(string, length, g, log_clusters, spaceAs); } -#endif // QT_ENABLE_HARFBUZZ_NG +#endif // harfbuzz // shape all the items that intersect with the line, taking tab widths into account to find out what text actually fits in the line. @@ -950,7 +951,7 @@ void QTextEngine::shapeLine(const QScriptLine &line) } } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) extern bool qt_useHarfbuzzNG(); // defined in qfontengine.cpp #endif @@ -1063,7 +1064,7 @@ void QTextEngine::shapeText(int item) const letterSpacing *= font.d->dpi / qt_defaultDpiY(); } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (Q_LIKELY(qt_useHarfbuzzNG())) si.num_glyphs = shapeTextWithHarfbuzzNG(si, string, itemLength, fontEngine, itemBoundaries, kerningEnabled, letterSpacing != 0); else @@ -1079,7 +1080,7 @@ void QTextEngine::shapeText(int item) const QGlyphLayout glyphs = shapedGlyphs(&si); -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) if (Q_LIKELY(qt_useHarfbuzzNG())) qt_getJustificationOpportunities(string, itemLength, si, glyphs, logClusters(&si)); #endif @@ -1119,7 +1120,7 @@ void QTextEngine::shapeText(int item) const si.width += glyphs.advances[i] * !glyphs.attributes[i].dontPrint; } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) QT_BEGIN_INCLUDE_NAMESPACE @@ -1313,7 +1314,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, return glyphs_shaped; } -#endif // QT_ENABLE_HARFBUZZ_NG +#endif // harfbuzz QT_BEGIN_INCLUDE_NAMESPACE @@ -1669,7 +1670,7 @@ void QTextEngine::itemize() const analysis->flags = QScriptAnalysis::None; break; } -#ifndef QT_ENABLE_HARFBUZZ_NG +#if !QT_CONFIG(harfbuzz) analysis->script = hbscript_to_script(script_to_hbscript(analysis->script)); #endif ++uc; @@ -1678,7 +1679,7 @@ void QTextEngine::itemize() const if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) { (analysis-1)->flags = QScriptAnalysis::LineOrParagraphSeparator; // to exclude it from width } -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) analysis = scriptAnalysis.data(); if (qt_useHarfbuzzNG()) { // ### pretend HB-old behavior for now diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 160e9ce490..f49e2638f5 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -649,7 +649,7 @@ private: void setBoundary(int strPos) const; void addRequiredBoundaries() const; void shapeText(int item) const; -#ifdef QT_ENABLE_HARFBUZZ_NG +#if QT_CONFIG(harfbuzz) int shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index a15793ec2f..abe20abe02 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -39,7 +39,8 @@ HEADERS += \ text/qrawfont_p.h \ text/qglyphrun.h \ text/qglyphrun_p.h \ - text/qdistancefield_p.h + text/qdistancefield_p.h \ + text/qinputcontrol_p.h SOURCES += \ text/qfont.cpp \ @@ -69,7 +70,8 @@ SOURCES += \ text/qstatictext.cpp \ text/qrawfont.cpp \ text/qglyphrun.cpp \ - text/qdistancefield.cpp + text/qdistancefield.cpp \ + text/qinputcontrol.cpp SOURCES += \ text/qfontengine_qpf2.cpp \ @@ -78,9 +80,7 @@ SOURCES += \ HEADERS += \ text/qplatformfontdatabase.h -qtConfig(harfbuzz)|qtConfig(system-harfbuzz) { - DEFINES += QT_ENABLE_HARFBUZZ_NG - +qtConfig(harfbuzz) { QMAKE_USE_PRIVATE += harfbuzz SOURCES += text/qharfbuzzng.cpp |