diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.pro | 1 | ||||
-rw-r--r-- | src/gui/image/qiconloader_p.h | 17 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qclipboard.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qplatformscreen.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qsurfaceformat.cpp | 12 | ||||
-rw-r--r-- | src/gui/opengl/qopenglframebufferobject.cpp | 1 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 53 | ||||
-rw-r--r-- | src/gui/painting/qpdf.cpp | 13 | ||||
-rw-r--r-- | src/gui/painting/qpdf_p.h | 2 | ||||
-rw-r--r-- | src/gui/text/qcssparser.cpp | 9 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 25 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 2 |
16 files changed, 99 insertions, 63 deletions
diff --git a/src/gui/gui.pro b/src/gui/gui.pro index a6eaadd6c5..5f8cbe2cbe 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -9,6 +9,7 @@ QMAKE_DOCS = $$PWD/doc/qtgui.qdocconf MODULE_PLUGIN_TYPES = \ platforms \ + platforms/darwin \ xcbglintegrations \ platformthemes \ platforminputcontexts \ diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h index 583499be76..ed7b7ff7ae 100644 --- a/src/gui/image/qiconloader_p.h +++ b/src/gui/image/qiconloader_p.h @@ -95,7 +95,6 @@ public: QIcon::State state) = 0; QString filename; QIconDirInfo dir; - static int count; }; struct ScalableEntry : public QIconLoaderEngineEntry @@ -124,18 +123,18 @@ public: QIconLoaderEngine(const QString& iconName = QString()); ~QIconLoaderEngine(); - void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state); - QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state); - QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state); - QIconEngine *clone() const; - bool read(QDataStream &in); - bool write(QDataStream &out) const; + void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE; + QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE; + QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE; + QIconEngine *clone() const Q_DECL_OVERRIDE; + bool read(QDataStream &in) Q_DECL_OVERRIDE; + bool write(QDataStream &out) const Q_DECL_OVERRIDE; private: - QString key() const; + QString key() const Q_DECL_OVERRIDE; bool hasIcon() const; void ensureLoaded(); - void virtual_hook(int id, void *data); + void virtual_hook(int id, void *data) Q_DECL_OVERRIDE; QIconLoaderEngineEntry *entryForSize(const QSize &size); QIconLoaderEngine(const QIconLoaderEngine &other); QThemeIconInfo m_info; diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 8bbcfa612d..9e911bdcea 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -5062,7 +5062,7 @@ static Q_CONSTEXPR QPixelFormat pixelformats[] = { /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha, /*ALPHA POSITION*/ QPixelFormat::AtBeginning, /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied, - /*INTERPRETATION*/ QPixelFormat::UnsignedInteger, + /*INTERPRETATION*/ QPixelFormat::UnsignedByte, /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian), //QImage::Format_RGB444: QPixelFormat(QPixelFormat::RGB, diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 9bd098b7b1..c646ee96b4 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -930,12 +930,12 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers const int dest_pad = (dst_bytes_per_line >> 1) - width; quint16 colorTableRGB16[256]; - if (data->colortable.isEmpty()) { + const int tableSize = data->colortable.size(); + if (tableSize == 0) { for (int i = 0; i < 256; ++i) colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i)); } else { // 1) convert the existing colors to RGB16 - const int tableSize = data->colortable.size(); for (int i = 0; i < tableSize; ++i) colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i)); data->colortable = QVector<QRgb>(); diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index 21127eebbd..f14355bc01 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -425,8 +425,9 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode) /*! \fn QMimeData *QClipboard::mimeData(Mode mode) const - Returns a reference to a QMimeData representation of the current - clipboard data. + Returns a pointer to a QMimeData representation of the current + clipboard data (can be NULL if the given \a mode is not + supported by the platform). The \a mode argument is used to control which part of the system clipboard is used. If \a mode is QClipboard::Clipboard, the diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index d8457bc041..7beab72ab0 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -351,6 +351,16 @@ void QWindowGeometrySpecification::applyTo(QWindow *window) const static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER; /*! + \macro qGuiApp + \relates QGuiApplication + + A global pointer referring to the unique application object. + Only valid for use when that object is a QGuiApplication. + + \sa QCoreApplication::instance(), qApp +*/ + +/*! \class QGuiApplication \brief The QGuiApplication class manages the GUI application's control flow and main settings. diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp index 3c1552c31e..1d519e84f9 100644 --- a/src/gui/kernel/qplatformscreen.cpp +++ b/src/gui/kernel/qplatformscreen.cpp @@ -342,6 +342,10 @@ void QPlatformScreen::resizeMaximizedWindows() for (int i = 0; i < windows.size(); ++i) { QWindow *w = windows.at(i); + // Skip non-platform windows, e.g., offscreen windows. + if (!w->handle()) + continue; + if (platformScreenForWindow(w) != this) continue; diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index d7dc0faceb..000d727380 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -41,6 +41,8 @@ #include <QtCore/qatomic.h> #include <QtCore/QDebug> +#include <QOpenGLContext> +#include <QtGui/qguiapplication.h> #ifdef major #undef major @@ -761,6 +763,16 @@ Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format) */ void QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &format) { +#ifndef QT_NO_OPENGL + if (qApp) { + QOpenGLContext *globalContext = QOpenGLContext::globalShareContext(); + if (globalContext && globalContext->isValid()) { + qWarning("Warning: Setting a new default format with a different version or profile " + "after the global shared context is created may cause issues with context " + "sharing."); + } + } +#endif *qt_default_surface_format() = format; } diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index e0f469cbcb..4833617377 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1492,6 +1492,7 @@ bool QOpenGLFramebufferObject::bindDefault() if (ctx) { ctx->functions()->glBindFramebuffer(GL_FRAMEBUFFER, ctx->defaultFramebufferObject()); QOpenGLContextPrivate::get(ctx)->qgl_current_fbo_invalid = true; + QOpenGLContextPrivate::get(ctx)->qgl_current_fbo = Q_NULLPTR; } #ifdef QT_DEBUG else diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 45a3174734..e537c343bb 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -335,6 +335,8 @@ struct QSpanData QGradientData gradient; QTextureData texture; }; + QExplicitlySharedDataPointer<const QSharedData> cachedGradient; + void init(QRasterBuffer *rb, const QRasterPaintEngine *pe); void setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 0edd9125a3..df96a993e3 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2283,6 +2283,8 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe = QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(), clippedTargetRect.width(), clippedTargetRect.height()).toRect(); + clippedSourceRect = clippedSourceRect.intersected(img.rect()); + uint dbpl = d->rasterBuffer->bytesPerLine(); uint sbpl = img.bytesPerLine(); @@ -4147,7 +4149,8 @@ void QRasterBuffer::flushToARGBImage(QImage *target) const class QGradientCache { - struct CacheInfo +public: + struct CacheInfo : public QSharedData { inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) : stops(qMove(s)), opacity(op), interpolationMode(mode) {} @@ -4158,12 +4161,9 @@ class QGradientCache QGradient::InterpolationMode interpolationMode; }; - typedef QMultiHash<quint64, CacheInfo> QGradientColorTableHash; - -public: - typedef QPair<const QRgb *, const QRgba64 *> ColorBufferPair; + typedef QMultiHash<quint64, QExplicitlySharedDataPointer<const CacheInfo> > QGradientColorTableHash; - inline ColorBufferPair getBuffer(const QGradient &gradient, int opacity) { + inline QExplicitlySharedDataPointer<const CacheInfo> getBuffer(const QGradient &gradient, int opacity) { quint64 hash_val = 0; const QGradientStops stops = gradient.stops(); @@ -4177,10 +4177,9 @@ public: return addCacheElement(hash_val, gradient, opacity); else { do { - const CacheInfo &cache_info = it.value(); - if (cache_info.stops == stops && cache_info.opacity == opacity && cache_info.interpolationMode == gradient.interpolationMode()) - return qMakePair(reinterpret_cast<const QRgb *>(cache_info.buffer32), - reinterpret_cast<const QRgba64 *>(cache_info.buffer64)); + const QExplicitlySharedDataPointer<const CacheInfo> &cache_info = it.value(); + if (cache_info->stops == stops && cache_info->opacity == opacity && cache_info->interpolationMode == gradient.interpolationMode()) + return cache_info; ++it; } while (it != cache.constEnd() && it.key() == hash_val); // an exact match for these stops and opacity was not found, create new cache @@ -4194,18 +4193,16 @@ protected: inline void generateGradientColorTable(const QGradient& g, QRgba64 *colorTable, int size, int opacity) const; - ColorBufferPair addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { + QExplicitlySharedDataPointer<const CacheInfo> addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) { if (cache.size() == maxCacheSize()) { // may remove more than 1, but OK cache.erase(cache.begin() + (qrand() % maxCacheSize())); } - CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode()); - generateGradientColorTable(gradient, cache_entry.buffer64, paletteSize(), opacity); + QExplicitlySharedDataPointer<CacheInfo> cache_entry(new CacheInfo (gradient.stops(), opacity, gradient.interpolationMode())); + generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity); for (int i = 0; i < GRADIENT_STOPTABLE_SIZE; ++i) - cache_entry.buffer32[i] = cache_entry.buffer64[i].toArgb32(); - CacheInfo &cache_value = cache.insert(hash_val, cache_entry).value(); - return qMakePair(reinterpret_cast<const QRgb *>(cache_value.buffer32), - reinterpret_cast<const QRgba64 *>(cache_value.buffer64)); + cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32(); + return cache.insert(hash_val, cache_entry).value(); } QGradientColorTableHash cache; @@ -4424,6 +4421,7 @@ Q_GUI_EXPORT extern QImage qt_imageForBrush(int brushStyle, bool invert); void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode) { Qt::BrushStyle brushStyle = qbrush_style(brush); + cachedGradient.reset(); switch (brushStyle) { case Qt::SolidPattern: { type = Solid; @@ -4440,9 +4438,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QLinearGradient *g = static_cast<const QLinearGradient *>(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha); - gradient.colorTable64 = colorBuffers.second; - gradient.colorTable32 = colorBuffers.first; + QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + cachedGradient = cacheInfo; + gradient.colorTable32 = cacheInfo->buffer32; + gradient.colorTable64 = cacheInfo->buffer64; gradient.spread = g->spread(); @@ -4461,9 +4460,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QRadialGradient *g = static_cast<const QRadialGradient *>(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha); - gradient.colorTable64 = colorBuffers.second; - gradient.colorTable32 = colorBuffers.first; + QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + cachedGradient = cacheInfo; + gradient.colorTable32 = cacheInfo->buffer32; + gradient.colorTable64 = cacheInfo->buffer64; gradient.spread = g->spread(); @@ -4486,9 +4486,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode const QConicalGradient *g = static_cast<const QConicalGradient *>(brush.gradient()); gradient.alphaColor = !brush.isOpaque() || alpha != 256; - QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha); - gradient.colorTable64 = colorBuffers.second; - gradient.colorTable32 = colorBuffers.first; + QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha); + cachedGradient = cacheInfo; + gradient.colorTable32 = cacheInfo->buffer32; + gradient.colorTable64 = cacheInfo->buffer64; gradient.spread = QGradient::RepeatSpread; diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index d246c96da6..84e18a64dd 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1924,7 +1924,7 @@ int QPdfEnginePrivate::writeCompressed(const char *src, int len) } int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, int depth, - int maskObject, int softMaskObject, bool dct) + int maskObject, int softMaskObject, bool dct, bool isMono) { int image = addXrefEntry(-1); xprintf("<<\n" @@ -1934,8 +1934,13 @@ int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, "/Height %d\n", width, height); if (depth == 1) { - xprintf("/ImageMask true\n" - "/Decode [1 0]\n"); + if (!isMono) { + xprintf("/ImageMask true\n" + "/Decode [1 0]\n"); + } else { + xprintf("/BitsPerComponent 1\n" + "/ColorSpace /DeviceGray\n"); + } } else { xprintf("/BitsPerComponent 8\n" "/ColorSpace %s\n", (depth == 32) ? "/DeviceRGB" : "/DeviceGray"); @@ -2453,7 +2458,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n memcpy(rawdata, image.constScanLine(y), bytesPerLine); rawdata += bytesPerLine; } - object = writeImage(data, w, h, d, 0, 0); + object = writeImage(data, w, h, d, 0, 0, false, is_monochrome(img.colorTable())); } else { QByteArray softMaskData; bool dct = false; diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index cb1a91e09f..a6aa2940c8 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -295,7 +295,7 @@ private: int streampos; int writeImage(const QByteArray &data, int width, int height, int depth, - int maskObject, int softMaskObject, bool dct = false); + int maskObject, int softMaskObject, bool dct = false, bool isMono = false); void writePage(); int addXrefEntry(int object, bool printostr = true); diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index cb19a42688..31d832a9ce 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -746,8 +746,9 @@ static ColorData parseColorValue(QCss::Value v) QVector<QCss::Value> colorDigits; if (!p.parseExpr(&colorDigits)) return ColorData(); + const int tokenCount = colorDigits.count(); - for (int i = 0; i < qMin(colorDigits.count(), 7); i += 2) { + for (int i = 0; i < qMin(tokenCount, 7); i += 2) { if (colorDigits.at(i).type == Value::Percentage) { colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (255. / 100.); colorDigits[i].type = Value::Number; @@ -756,11 +757,15 @@ static ColorData parseColorValue(QCss::Value v) } } + + if (tokenCount < 5) + return ColorData(); + int v1 = colorDigits.at(0).variant.toInt(); int v2 = colorDigits.at(2).variant.toInt(); int v3 = colorDigits.at(4).variant.toInt(); int alpha = 255; - if (colorDigits.count() >= 7) { + if (tokenCount >= 7) { int alphaValue = colorDigits.at(6).variant.toInt(); if (rgba && alphaValue <= 1) alpha = colorDigits.at(6).variant.toReal() * 255.; diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 7fcac9b9f2..d2da24ca94 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -804,7 +804,8 @@ QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFo Q_UNUSED(family); Q_UNUSED(styleHint); - QStringList retList; + QStringList preferredFallbacks; + QStringList otherFallbacks; size_t writingSystem = std::find(scriptForWritingSystem, scriptForWritingSystem + QFontDatabase::WritingSystemsCount, @@ -825,18 +826,18 @@ QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFo QtFontFoundry *foundry = f->foundries[j]; for (int k = 0; k < foundry->count; ++k) { - if (style == foundry->styles[k]->key.style) { - if (foundry->name.isEmpty()) - retList.append(f->name); - else - retList.append(f->name + QLatin1String(" [") + foundry->name + QLatin1Char(']')); - break; - } + QString name = foundry->name.isEmpty() + ? f->name + : f->name + QLatin1String(" [") + foundry->name + QLatin1Char(']'); + if (style == foundry->styles[k]->key.style) + preferredFallbacks.append(name); + else + otherFallbacks.append(name); } } } - return retList; + return preferredFallbacks + otherFallbacks; } static void initializeDb(); @@ -1659,9 +1660,6 @@ bool QFontDatabase::isFixedPitch(const QString &family, bool QFontDatabase::isBitmapScalable(const QString &family, const QString &style) const { - if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable()) - return true; - bool bitmapScalable = false; QString familyName, foundryName; parseFontName(family, foundryName, familyName); @@ -1702,9 +1700,6 @@ bool QFontDatabase::isBitmapScalable(const QString &family, */ bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &style) const { - if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable()) - return true; - bool smoothScalable = false; QString familyName, foundryName; parseFontName(family, foundryName, familyName); diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index d6af6d21a2..09b0475a84 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1910,7 +1910,7 @@ void QFontEngineFT::unlockAlphaMapForGlyph() static inline bool is2dRotation(const QTransform &t) { return qFuzzyCompare(t.m11(), t.m22()) && qFuzzyCompare(t.m12(), -t.m21()) - && qFuzzyCompare(t.m11()*t.m22() - t.m12()*t.m21(), 1.0); + && qFuzzyCompare(t.m11()*t.m22() - t.m12()*t.m21(), qreal(1.0)); } QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g, |