From 9f27bfb31acfba49a74a342d9249f24633a7ade2 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 13 Apr 2018 09:01:43 +0200 Subject: Make sure we can build with -no-feature-draganddrop We move QInternalMimeData to a separate file, because this class is used, even if draganddrop is disabled. From now on, include qinternalmimedata_p.h instead of qdnd_p.h for QInternalMimeData. Change-Id: I594e08e2e90d574dc445119091686b4b69e4731b Reviewed-by: Gatis Paeglis --- src/gui/itemmodels/qstandarditemmodel.cpp | 4 +- src/gui/itemmodels/qstandarditemmodel.h | 4 +- src/gui/kernel/kernel.pri | 27 ++-- src/gui/kernel/qdnd.cpp | 217 +-------------------------- src/gui/kernel/qdnd_p.h | 41 +----- src/gui/kernel/qdrag.cpp | 4 - src/gui/kernel/qdrag.h | 6 +- src/gui/kernel/qevent.cpp | 19 ++- src/gui/kernel/qevent.h | 4 +- src/gui/kernel/qguiapplication.cpp | 13 +- src/gui/kernel/qguiapplication_p.h | 10 +- src/gui/kernel/qinternalmimedata.cpp | 234 ++++++++++++++++++++++++++++++ src/gui/kernel/qinternalmimedata_p.h | 93 ++++++++++++ src/gui/kernel/qplatformdrag.cpp | 3 - src/gui/kernel/qplatformdrag.h | 6 +- src/gui/kernel/qplatformintegration.cpp | 7 +- src/gui/kernel/qplatformintegration.h | 2 +- src/gui/kernel/qshapedpixmapdndwindow_p.h | 2 + src/gui/kernel/qsimpledrag.cpp | 4 - src/gui/kernel/qsimpledrag_p.h | 6 +- src/gui/kernel/qwindow.cpp | 8 +- src/gui/kernel/qwindowsysteminterface.cpp | 9 +- src/gui/kernel/qwindowsysteminterface.h | 2 +- 23 files changed, 410 insertions(+), 315 deletions(-) create mode 100644 src/gui/kernel/qinternalmimedata.cpp create mode 100644 src/gui/kernel/qinternalmimedata_p.h (limited to 'src/gui') diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index c340bddc51..f55e90c153 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -1414,7 +1414,7 @@ void QStandardItem::setTristate(bool tristate) } #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Sets whether the item is drag enabled. If \a dragEnabled is true, the item @@ -1472,7 +1472,7 @@ void QStandardItem::setDropEnabled(bool dropEnabled) \sa setDropEnabled(), isDragEnabled(), flags() */ -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! Returns the row where the item is located in its parent's child table, or diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index d1c04d6b51..827179b31d 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -179,7 +179,7 @@ public: QT_DEPRECATED void setTristate(bool tristate); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) inline bool isDragEnabled() const { return (flags() & Qt::ItemIsDragEnabled) != 0; } @@ -189,7 +189,7 @@ public: return (flags() & Qt::ItemIsDropEnabled) != 0; } void setDropEnabled(bool dropEnabled); -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) QStandardItem *parent() const; int row() const; diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 792ca9fbaf..3b9afdfe8b 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -13,7 +13,6 @@ HEADERS += \ kernel/qwindowsysteminterface.h \ kernel/qwindowsysteminterface_p.h \ kernel/qplatformintegration.h \ - kernel/qplatformdrag.h \ kernel/qplatformscreen.h \ kernel/qplatformscreen_p.h \ kernel/qplatforminputcontext.h \ @@ -33,8 +32,6 @@ HEADERS += \ kernel/qplatformclipboard.h \ kernel/qplatformnativeinterface.h \ kernel/qplatformmenu.h \ - kernel/qshapedpixmapdndwindow_p.h \ - kernel/qsimpledrag_p.h \ kernel/qsurfaceformat.h \ kernel/qguiapplication.h \ kernel/qguiapplication_p.h \ @@ -46,12 +43,11 @@ HEADERS += \ kernel/qclipboard.h \ kernel/qcursor.h \ kernel/qcursor_p.h \ - kernel/qdrag.h \ - kernel/qdnd_p.h \ kernel/qevent.h \ kernel/qevent_p.h \ kernel/qinputmethod.h \ kernel/qinputmethod_p.h \ + kernel/qinternalmimedata_p.h \ kernel/qkeysequence.h \ kernel/qkeysequence_p.h \ kernel/qkeymapper_p.h \ @@ -89,7 +85,6 @@ SOURCES += \ kernel/qplatforminputcontextplugin.cpp \ kernel/qplatforminputcontext.cpp \ kernel/qplatformintegration.cpp \ - kernel/qplatformdrag.cpp \ kernel/qplatformscreen.cpp \ kernel/qplatformintegrationfactory.cpp \ kernel/qplatformintegrationplugin.cpp \ @@ -102,8 +97,6 @@ SOURCES += \ kernel/qplatformclipboard.cpp \ kernel/qplatformnativeinterface.cpp \ kernel/qsessionmanager.cpp \ - kernel/qshapedpixmapdndwindow.cpp \ - kernel/qsimpledrag.cpp \ kernel/qsurfaceformat.cpp \ kernel/qguiapplication.cpp \ kernel/qwindow.cpp \ @@ -112,10 +105,9 @@ SOURCES += \ kernel/qsurface.cpp \ kernel/qclipboard.cpp \ kernel/qcursor.cpp \ - kernel/qdrag.cpp \ - kernel/qdnd.cpp \ kernel/qevent.cpp \ kernel/qinputmethod.cpp \ + kernel/qinternalmimedata.cpp \ kernel/qkeysequence.cpp \ kernel/qkeymapper.cpp \ kernel/qpalette.cpp \ @@ -138,6 +130,21 @@ SOURCES += \ kernel/qinputdevicemanager.cpp \ kernel/qhighdpiscaling.cpp +qtConfig(draganddrop) { + HEADERS += \ + kernel/qdnd_p.h \ + kernel/qdrag.h \ + kernel/qplatformdrag.h \ + kernel/qshapedpixmapdndwindow_p.h \ + kernel/qsimpledrag_p.h + + SOURCES += \ + kernel/qdnd.cpp \ + kernel/qdrag.cpp \ + kernel/qplatformdrag.cpp \ + kernel/qshapedpixmapdndwindow.cpp \ + kernel/qsimpledrag.cpp +} qtConfig(opengl) { HEADERS += \ diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index 3af7f5c181..5c5f166554 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -37,39 +37,19 @@ ** ****************************************************************************/ -#include "qplatformdefs.h" +#include "qdnd_p.h" -#include "qbitmap.h" -#include "qdrag.h" -#include "qpixmap.h" -#include "qevent.h" -#include "qfile.h" -#include "qtextcodec.h" #include "qguiapplication.h" -#include "qpoint.h" -#include "qbuffer.h" -#include "qimage.h" -#include "qpainter.h" -#include "qregexp.h" -#include "qdir.h" -#include "qdnd_p.h" -#include "qimagereader.h" -#include "qimagewriter.h" -#include "qdebug.h" #include -#include #include - +#include #include -#ifndef QT_NO_DRAGANDDROP - QT_BEGIN_NAMESPACE // the universe's only drag manager QDragManager *QDragManager::m_instance = 0; - QDragManager::QDragManager() : QObject(qApp), m_currentDropTarget(0), m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()), @@ -78,7 +58,6 @@ QDragManager::QDragManager() Q_ASSERT(!m_instance); } - QDragManager::~QDragManager() { m_instance = 0; @@ -142,196 +121,4 @@ Qt::DropAction QDragManager::drag(QDrag *o) return result; } -#endif // QT_NO_DRAGANDDROP - -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - -static QStringList imageMimeFormats(const QList &imageFormats) -{ - QStringList formats; - formats.reserve(imageFormats.size()); - for (const auto &format : imageFormats) - formats.append(QLatin1String("image/") + QLatin1String(format.toLower())); - - //put png at the front because it is best - int pngIndex = formats.indexOf(QLatin1String("image/png")); - if (pngIndex != -1 && pngIndex != 0) - formats.move(pngIndex, 0); - - return formats; -} - -static inline QStringList imageReadMimeFormats() -{ - return imageMimeFormats(QImageReader::supportedImageFormats()); -} - - -static inline QStringList imageWriteMimeFormats() -{ - return imageMimeFormats(QImageWriter::supportedImageFormats()); -} - -QInternalMimeData::QInternalMimeData() - : QMimeData() -{ -} - -QInternalMimeData::~QInternalMimeData() -{ -} - -bool QInternalMimeData::hasFormat(const QString &mimeType) const -{ - bool foundFormat = hasFormat_sys(mimeType); - if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) { - QStringList imageFormats = imageReadMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - if ((foundFormat = hasFormat_sys(imageFormats.at(i)))) - break; - } - } - return foundFormat; -} - -QStringList QInternalMimeData::formats() const -{ - QStringList realFormats = formats_sys(); - if (!realFormats.contains(QLatin1String("application/x-qt-image"))) { - QStringList imageFormats = imageReadMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - if (realFormats.contains(imageFormats.at(i))) { - realFormats += QLatin1String("application/x-qt-image"); - break; - } - } - } - return realFormats; -} - -QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const -{ - QVariant data = retrieveData_sys(mimeType, type); - if (mimeType == QLatin1String("application/x-qt-image")) { - if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) { - // try to find an image - QStringList imageFormats = imageReadMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - data = retrieveData_sys(imageFormats.at(i), type); - if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) - continue; - break; - } - } - // we wanted some image type, but all we got was a byte array. Convert it to an image. - if (data.type() == QVariant::ByteArray - && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap)) - data = QImage::fromData(data.toByteArray()); - - } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) { - QColor c; - QByteArray ba = data.toByteArray(); - if (ba.size() == 8) { - ushort * colBuf = (ushort *)ba.data(); - c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF), - qreal(colBuf[1]) / qreal(0xFFFF), - qreal(colBuf[2]) / qreal(0xFFFF), - qreal(colBuf[3]) / qreal(0xFFFF)); - data = c; - } else { - qWarning("Qt: Invalid color format"); - } - } else if (data.type() != type && data.type() == QVariant::ByteArray) { - // try to use mime data's internal conversion stuf. - QInternalMimeData *that = const_cast(this); - that->setData(mimeType, data.toByteArray()); - data = QMimeData::retrieveData(mimeType, type); - that->clear(); - } - return data; -} - -bool QInternalMimeData::canReadData(const QString &mimeType) -{ - return imageReadMimeFormats().contains(mimeType); -} - -// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core. -QStringList QInternalMimeData::formatsHelper(const QMimeData *data) -{ - QStringList realFormats = data->formats(); - if (realFormats.contains(QLatin1String("application/x-qt-image"))) { - // add all supported image formats - QStringList imageFormats = imageWriteMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - if (!realFormats.contains(imageFormats.at(i))) - realFormats.append(imageFormats.at(i)); - } - } - return realFormats; -} - -bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data) -{ - - bool foundFormat = data->hasFormat(mimeType); - if (!foundFormat) { - if (mimeType == QLatin1String("application/x-qt-image")) { - // check all supported image formats - QStringList imageFormats = imageWriteMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - if ((foundFormat = data->hasFormat(imageFormats.at(i)))) - break; - } - } else if (mimeType.startsWith(QLatin1String("image/"))) { - return data->hasImage() && imageWriteMimeFormats().contains(mimeType); - } - } - return foundFormat; -} - -QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data) -{ - QByteArray ba; - if (mimeType == QLatin1String("application/x-color")) { - /* QMimeData can only provide colors as QColor or the name - of a color as a QByteArray or a QString. So we need to do - the conversion to application/x-color here. - The application/x-color format is : - type: application/x-color - format: 16 - data[0]: red - data[1]: green - data[2]: blue - data[3]: opacity - */ - ba.resize(8); - ushort * colBuf = (ushort *)ba.data(); - QColor c = qvariant_cast(data->colorData()); - colBuf[0] = ushort(c.redF() * 0xFFFF); - colBuf[1] = ushort(c.greenF() * 0xFFFF); - colBuf[2] = ushort(c.blueF() * 0xFFFF); - colBuf[3] = ushort(c.alphaF() * 0xFFFF); - } else { - ba = data->data(mimeType); - if (ba.isEmpty()) { - if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) { - QImage image = qvariant_cast(data->imageData()); - QBuffer buf(&ba); - buf.open(QBuffer::WriteOnly); - // would there not be PNG ?? - image.save(&buf, "PNG"); - } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) { - QImage image = qvariant_cast(data->imageData()); - QBuffer buf(&ba); - buf.open(QBuffer::WriteOnly); - image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper()); - } - } - } - return ba; -} - -#endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD - QT_END_NAMESPACE diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index e7d83cbbaf..cc00bc1442 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -62,41 +62,16 @@ #include "QtCore/qpoint.h" #include "private/qobject_p.h" #include "QtGui/qbackingstore.h" -QT_BEGIN_NAMESPACE - -class QEventLoop; -class QMouseEvent; -class QPlatformDrag; - -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - -class Q_GUI_EXPORT QInternalMimeData : public QMimeData -{ - Q_OBJECT -public: - QInternalMimeData(); - ~QInternalMimeData(); - - bool hasFormat(const QString &mimeType) const override; - QStringList formats() const override; - static bool canReadData(const QString &mimeType); +// ### Remove the following include, once everybody includes +// qinternalmimedata_p.h for QInternalMimeData. +#include "qinternalmimedata_p.h" - static QStringList formatsHelper(const QMimeData *data); - static bool hasFormatHelper(const QString &mimeType, const QMimeData *data); - static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data); +QT_REQUIRE_CONFIG(draganddrop); -protected: - QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override; - - virtual bool hasFormat_sys(const QString &mimeType) const = 0; - virtual QStringList formats_sys() const = 0; - virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0; -}; - -#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) +QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP +class QPlatformDrag; class QDragPrivate : public QObjectPrivate { @@ -142,10 +117,6 @@ private: Q_DISABLE_COPY(QDragManager) }; - -#endif // !QT_NO_DRAGANDDROP - - QT_END_NAMESPACE #endif // QDND_P_H diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 982c9e7659..bb0e490aa0 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -45,8 +45,6 @@ #include #include "qdnd_p.h" -#ifndef QT_NO_DRAGANDDROP - QT_BEGIN_NAMESPACE /*! @@ -420,5 +418,3 @@ void QDrag::cancel() */ QT_END_NAMESPACE - -#endif // QT_NO_DRAGANDDROP diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h index a8288e1b53..27b9c2c88f 100644 --- a/src/gui/kernel/qdrag.h +++ b/src/gui/kernel/qdrag.h @@ -43,10 +43,10 @@ #include #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); +QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP class QMimeData; class QDragPrivate; class QPixmap; @@ -95,8 +95,6 @@ private: Q_DISABLE_COPY(QDrag) }; -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE #endif // QDRAG_H diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 50d9bbb2cc..3c412903e1 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -42,16 +42,19 @@ #include "private/qguiapplication_p.h" #include "private/qtouchdevice_p.h" #include "qpa/qplatformintegration.h" -#include "qpa/qplatformdrag.h" #include "private/qevent_p.h" #include "qfile.h" #include "qhashfunctions.h" #include "qmetaobject.h" #include "qmimedata.h" -#include "private/qdnd_p.h" #include "qevent_p.h" #include "qmath.h" +#if QT_CONFIG(draganddrop) +#include +#include +#endif + #include QT_BEGIN_NAMESPACE @@ -2883,7 +2886,7 @@ const QTouchDevice *QNativeGestureEvent::device() const */ #endif // QT_NO_GESTURES -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Creates a QDragMoveEvent of the required \a type indicating that the mouse is at position \a pos given within a widget. @@ -3227,7 +3230,7 @@ QDragLeaveEvent::QDragLeaveEvent() QDragLeaveEvent::~QDragLeaveEvent() { } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \class QHelpEvent @@ -3902,7 +3905,7 @@ static const char *eventClassName(QEvent::Type t) return "QEvent"; } -# ifndef QT_NO_DRAGANDDROP +# if QT_CONFIG(draganddrop) static void formatDropEvent(QDebug d, const QDropEvent *e) { @@ -3923,7 +3926,7 @@ static void formatDropEvent(QDebug d, const QDropEvent *e) QtDebugUtils::formatQFlags(d, e->mouseButtons()); } -# endif // !QT_NO_DRAGANDDROP +# endif // QT_CONFIG(draganddrop) # if QT_CONFIG(tabletevent) @@ -4086,13 +4089,13 @@ QDebug operator<<(QDebug dbg, const QEvent *e) dbg << ')'; } break; -# ifndef QT_NO_DRAGANDDROP +# if QT_CONFIG(draganddrop) case QEvent::DragEnter: case QEvent::DragMove: case QEvent::Drop: formatDropEvent(dbg, static_cast(e)); break; -# endif // !QT_NO_DRAGANDDROP +# endif // QT_CONFIG(draganddrop) case QEvent::InputMethod: formatInputMethodEvent(dbg, static_cast(e)); break; diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index d95da40368..033d24d665 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -598,7 +598,7 @@ Q_DECLARE_TYPEINFO(QInputMethodQueryEvent::QueryPair, Q_MOVABLE_TYPE); #endif // QT_NO_INPUTMETHOD -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) class QMimeData; @@ -671,7 +671,7 @@ public: QDragLeaveEvent(); ~QDragLeaveEvent(); }; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) class Q_GUI_EXPORT QHelpEvent : public QEvent diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index caa8aaca4b..c73dac42d6 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -87,9 +86,13 @@ #include "private/qinputdevicemanager_p.h" #include "private/qtouchdevice_p.h" -#include "private/qdnd_p.h" #include +#if QT_CONFIG(draganddrop) +#include +#include +#endif + #ifndef QT_NO_CURSOR #include #endif @@ -3034,7 +3037,7 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E QCoreApplication::sendSpontaneousEvent(window, &exposeEvent); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDragQtResponse QGuiApplicationPrivate::processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) { @@ -3094,7 +3097,7 @@ QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QM return response; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) #ifndef QT_NO_CLIPBOARD /*! @@ -3910,7 +3913,7 @@ void QGuiApplicationPrivate::notifyThemeChanged() } } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) { Q_UNUSED(drag) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 75cbc7abde..2fefaf0af6 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -70,9 +70,9 @@ class QColorProfile; class QPlatformIntegration; class QPlatformTheme; class QPlatformDragQtResponse; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) class QDrag; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) class QInputDeviceManager; class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate @@ -162,7 +162,7 @@ public: static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); static QPlatformDropQtResponse processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); #endif @@ -309,9 +309,9 @@ public: protected: virtual void notifyThemeChanged(); bool tryCloseRemainingWindows(QWindowList processedWindows); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void notifyDragStarted(const QDrag *); -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) private: friend class QDragManager; diff --git a/src/gui/kernel/qinternalmimedata.cpp b/src/gui/kernel/qinternalmimedata.cpp new file mode 100644 index 0000000000..8f4da1afb5 --- /dev/null +++ b/src/gui/kernel/qinternalmimedata.cpp @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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$ +** +****************************************************************************/ + +#include "qinternalmimedata_p.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +static QStringList imageMimeFormats(const QList &imageFormats) +{ + QStringList formats; + formats.reserve(imageFormats.size()); + for (const auto &format : imageFormats) + formats.append(QLatin1String("image/") + QLatin1String(format.toLower())); + + //put png at the front because it is best + int pngIndex = formats.indexOf(QLatin1String("image/png")); + if (pngIndex != -1 && pngIndex != 0) + formats.move(pngIndex, 0); + + return formats; +} + +static inline QStringList imageReadMimeFormats() +{ + return imageMimeFormats(QImageReader::supportedImageFormats()); +} + +static inline QStringList imageWriteMimeFormats() +{ + return imageMimeFormats(QImageWriter::supportedImageFormats()); +} + +QInternalMimeData::QInternalMimeData() + : QMimeData() +{ +} + +QInternalMimeData::~QInternalMimeData() +{ +} + +bool QInternalMimeData::hasFormat(const QString &mimeType) const +{ + bool foundFormat = hasFormat_sys(mimeType); + if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) { + QStringList imageFormats = imageReadMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + if ((foundFormat = hasFormat_sys(imageFormats.at(i)))) + break; + } + } + return foundFormat; +} + +QStringList QInternalMimeData::formats() const +{ + QStringList realFormats = formats_sys(); + if (!realFormats.contains(QLatin1String("application/x-qt-image"))) { + QStringList imageFormats = imageReadMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + if (realFormats.contains(imageFormats.at(i))) { + realFormats += QLatin1String("application/x-qt-image"); + break; + } + } + } + return realFormats; +} + +QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const +{ + QVariant data = retrieveData_sys(mimeType, type); + if (mimeType == QLatin1String("application/x-qt-image")) { + if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) { + // try to find an image + QStringList imageFormats = imageReadMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + data = retrieveData_sys(imageFormats.at(i), type); + if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) + continue; + break; + } + } + // we wanted some image type, but all we got was a byte array. Convert it to an image. + if (data.type() == QVariant::ByteArray + && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap)) + data = QImage::fromData(data.toByteArray()); + + } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) { + QColor c; + QByteArray ba = data.toByteArray(); + if (ba.size() == 8) { + ushort * colBuf = (ushort *)ba.data(); + c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF), + qreal(colBuf[1]) / qreal(0xFFFF), + qreal(colBuf[2]) / qreal(0xFFFF), + qreal(colBuf[3]) / qreal(0xFFFF)); + data = c; + } else { + qWarning("Qt: Invalid color format"); + } + } else if (data.type() != type && data.type() == QVariant::ByteArray) { + // try to use mime data's internal conversion stuf. + QInternalMimeData *that = const_cast(this); + that->setData(mimeType, data.toByteArray()); + data = QMimeData::retrieveData(mimeType, type); + that->clear(); + } + return data; +} + +bool QInternalMimeData::canReadData(const QString &mimeType) +{ + return imageReadMimeFormats().contains(mimeType); +} + +// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core. +QStringList QInternalMimeData::formatsHelper(const QMimeData *data) +{ + QStringList realFormats = data->formats(); + if (realFormats.contains(QLatin1String("application/x-qt-image"))) { + // add all supported image formats + QStringList imageFormats = imageWriteMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + if (!realFormats.contains(imageFormats.at(i))) + realFormats.append(imageFormats.at(i)); + } + } + return realFormats; +} + +bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data) +{ + + bool foundFormat = data->hasFormat(mimeType); + if (!foundFormat) { + if (mimeType == QLatin1String("application/x-qt-image")) { + // check all supported image formats + QStringList imageFormats = imageWriteMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + if ((foundFormat = data->hasFormat(imageFormats.at(i)))) + break; + } + } else if (mimeType.startsWith(QLatin1String("image/"))) { + return data->hasImage() && imageWriteMimeFormats().contains(mimeType); + } + } + return foundFormat; +} + +QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data) +{ + QByteArray ba; + if (mimeType == QLatin1String("application/x-color")) { + /* QMimeData can only provide colors as QColor or the name + of a color as a QByteArray or a QString. So we need to do + the conversion to application/x-color here. + The application/x-color format is : + type: application/x-color + format: 16 + data[0]: red + data[1]: green + data[2]: blue + data[3]: opacity + */ + ba.resize(8); + ushort * colBuf = (ushort *)ba.data(); + QColor c = qvariant_cast(data->colorData()); + colBuf[0] = ushort(c.redF() * 0xFFFF); + colBuf[1] = ushort(c.greenF() * 0xFFFF); + colBuf[2] = ushort(c.blueF() * 0xFFFF); + colBuf[3] = ushort(c.alphaF() * 0xFFFF); + } else { + ba = data->data(mimeType); + if (ba.isEmpty()) { + if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) { + QImage image = qvariant_cast(data->imageData()); + QBuffer buf(&ba); + buf.open(QBuffer::WriteOnly); + // would there not be PNG ?? + image.save(&buf, "PNG"); + } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) { + QImage image = qvariant_cast(data->imageData()); + QBuffer buf(&ba); + buf.open(QBuffer::WriteOnly); + image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper()); + } + } + } + return ba; +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qinternalmimedata_p.h b/src/gui/kernel/qinternalmimedata_p.h new file mode 100644 index 0000000000..aa5e896323 --- /dev/null +++ b/src/gui/kernel/qinternalmimedata_p.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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$ +** +****************************************************************************/ + +#ifndef QINTERNALMIMEDATA_P_H +#define QINTERNALMIMEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QEventLoop; +class QMouseEvent; +class QPlatformDrag; + +class Q_GUI_EXPORT QInternalMimeData : public QMimeData +{ + Q_OBJECT +public: + QInternalMimeData(); + ~QInternalMimeData(); + + bool hasFormat(const QString &mimeType) const override; + QStringList formats() const override; + static bool canReadData(const QString &mimeType); + + + static QStringList formatsHelper(const QMimeData *data); + static bool hasFormatHelper(const QString &mimeType, const QMimeData *data); + static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data); + +protected: + QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override; + + virtual bool hasFormat_sys(const QString &mimeType) const = 0; + virtual QStringList formats_sys() const = 0; + virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0; +}; + +QT_END_NAMESPACE + +#endif // QINTERNALMIMEDATA_P_H diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp index 3c23406a6b..b40ddcbfb8 100644 --- a/src/gui/kernel/qplatformdrag.cpp +++ b/src/gui/kernel/qplatformdrag.cpp @@ -46,7 +46,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP #ifdef QDND_DEBUG # include #endif @@ -222,6 +221,4 @@ bool QPlatformDrag::ownsDragObject() const return false; } -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h index 54e6a667fe..9d4e352b4b 100644 --- a/src/gui/kernel/qplatformdrag.h +++ b/src/gui/kernel/qplatformdrag.h @@ -52,9 +52,9 @@ #include #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); -#ifndef QT_NO_DRAGANDDROP +QT_BEGIN_NAMESPACE class QMimeData; class QMouseEvent; @@ -112,8 +112,6 @@ private: Q_DISABLE_COPY(QPlatformDrag) }; -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE #endif diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 2aaa4c8510..dfb8f60915 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -45,8 +45,11 @@ #include #include #include + +#if QT_CONFIG(draganddrop) #include #include +#endif #ifndef QT_NO_SESSIONMANAGER # include @@ -92,7 +95,7 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Accessor for the platform integration's drag object. @@ -107,7 +110,7 @@ QPlatformDrag *QPlatformIntegration::drag() const } return drag; } -#endif +#endif // QT_CONFIG(draganddrop) QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const { diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index d88f818920..efb1481f6d 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -130,7 +130,7 @@ public: #ifndef QT_NO_CLIPBOARD virtual QPlatformClipboard *clipboard() const; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual QPlatformDrag *drag() const; #endif virtual QPlatformInputContext *inputContext() const; diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h index 477938867c..072e7c6aea 100644 --- a/src/gui/kernel/qshapedpixmapdndwindow_p.h +++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h @@ -55,6 +55,8 @@ #include #include +QT_REQUIRE_CONFIG(draganddrop); + QT_BEGIN_NAMESPACE class QShapedPixmapWindow : public QRasterWindow diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index c98b879a15..12e204a09f 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -68,8 +68,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP - Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd") static QWindow* topLevelAt(const QPoint &pos) @@ -434,6 +432,4 @@ void QSimpleDrag::drop(const QPoint &nativeGlobalPos) } } -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h index e56c7bf306..d980a3c49d 100644 --- a/src/gui/kernel/qsimpledrag_p.h +++ b/src/gui/kernel/qsimpledrag_p.h @@ -56,9 +56,9 @@ #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); -#ifndef QT_NO_DRAGANDDROP +QT_BEGIN_NAMESPACE class QMouseEvent; class QWindow; @@ -136,8 +136,6 @@ protected: virtual void drop(const QPoint &globalPos) override; }; -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE #endif diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 2c7e061bcf..9abe04810b 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -55,7 +55,9 @@ # include "qaccessible.h" #endif #include "qhighdpiscaling_p.h" +#if QT_CONFIG(draganddrop) #include "qshapedpixmapdndwindow_p.h" +#endif // QT_CONFIG(draganddrop) #include @@ -382,7 +384,11 @@ void QWindowPrivate::setVisible(bool visible) QGuiApplicationPrivate::hideModalWindow(q); // QShapedPixmapWindow is used on some platforms for showing a drag pixmap, so don't block // input to this window as it is performing a drag - QTBUG-63846 - } else if (visible && QGuiApplication::modalWindow() && !qobject_cast(q)) { + } else if (visible && QGuiApplication::modalWindow() +#if QT_CONFIG(draganddrop) + && !qobject_cast(q) +#endif // QT_CONFIG(draganddrop) + ) { QGuiApplicationPrivate::updateBlockedStatus(q); } diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index c310ab5213..6edcdfc255 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -43,12 +43,15 @@ #include "private/qevent_p.h" #include "private/qtouchdevice_p.h" #include -#include #include #include #include "qhighdpiscaling_p.h" #include +#if QT_CONFIG(draganddrop) +#include +#endif + QT_BEGIN_NAMESPACE @@ -791,7 +794,7 @@ void QWindowSystemInterface::handleThemeChange(QWindow *window) QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) { return QGuiApplicationPrivate::processDrag(window, dropData, QHighDpi::fromNativeLocalPosition(p, window) ,supportedActions); @@ -801,7 +804,7 @@ QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, cons { return QGuiApplicationPrivate::processDrop(window, dropData, QHighDpi::fromNativeLocalPosition(p, window),supportedActions); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \fn static QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index a7cc30be4b..bba0b05c5a 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -214,7 +214,7 @@ public: template static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) // Drag and drop. These events are sent immediately. static QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); static QPlatformDropQtResponse handleDrop(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); -- cgit v1.2.3 From 6a1460874253ad6dce25a90dd3ab5bfe95e718c0 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 22 May 2018 13:47:31 +0200 Subject: QOpenGLTexture: Enable multisample 2D textures on GLES 3.1+ Task-number: QTBUG-68510 Change-Id: Ib224189906b595bbae5aab95c888dd13e94171aa Reviewed-by: Andy Nichols --- src/gui/opengl/qopengltexturehelper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gui') diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index be88946e90..6709edc4e2 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -188,6 +188,12 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) TexBufferRange = 0; TextureView = 0; + // OpenGL ES 3.1+ has TexStorage2DMultisample + if (ctx->format().version() >= qMakePair(3, 1)) { + QOpenGLExtraFunctionsPrivate *extra = static_cast(context->extraFunctions())->d(); + TexStorage2DMultisample = extra->f.TexStorage2DMultisample; + } + #endif if (context->isOpenGLES() && context->hasExtension(QByteArrayLiteral("GL_OES_texture_3D"))) { -- cgit v1.2.3 From ffc377a5291d8c53b62de11cc4187026e0f7a6bf Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 28 May 2018 14:33:58 +0200 Subject: Reduce recent performance regression The change to fix 16-bit integer overflow used two floor operations when only one is necessary. With floor being rather expensive on x86 without SSE4.1 this caused a performance regression in ARGB32 smooth perspective transforms. This eliminates one of the floor operations which is unnecessary as the number is always positive in this case and thus truncation will yield the same result faster. Change-Id: Iaae76820d4bc2f368e49ed143130b5075fc760a2 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 17010fa3fa..34847daf55 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -3198,8 +3198,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co int y1 = qFloor(py); int y2; - distxs[i] = qFloor((px - x1) * (1<<16)); - distys[i] = qFloor((py - y1) * (1<<16)); + distxs[i] = int((px - x1) * (1<<16)); + distys[i] = int((py - y1) * (1<<16)); fetchTransformedBilinear_pixelBounds(image.width, image.x1, image.x2 - 1, x1, x2); fetchTransformedBilinear_pixelBounds(image.height, image.y1, image.y2 - 1, y1, y2); -- cgit v1.2.3 From d9d77e8680f4fcb1afacbcea3830adccf77957c4 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 5 Jun 2018 11:06:59 +0200 Subject: Fix QTransform::transposed() result having wrong transformation type The implementation of QTransform::transposed() had a wrong assumption about the type of the result. Task-number: QTBUG-68630 Change-Id: Ia5ce794efe773d74fb5fdaff3da8cae2b452e7e5 Reviewed-by: Friedemann Kleint Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qtransform.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 7a53c44bc4..c5e296b293 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -352,8 +352,6 @@ QTransform QTransform::transposed() const QTransform t(affine._m11, affine._m21, affine._dx, affine._m12, affine._m22, affine._dy, m_13, m_23, m_33, true); - t.m_type = m_type; - t.m_dirty = m_dirty; return t; } -- cgit v1.2.3 From 8c33b798237b95d37fe4d60ae36f0d8067504429 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 30 May 2018 15:51:32 +0200 Subject: Fix HDR format in QOpenGLFramebufferObject::toImage() If the fbo had samples > 0 set, it would use a temporary fbo with a default configuration losing the HDR precision. Change-Id: I7e9966165b3100f148c4ad24738f3ee71273f29a Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglframebufferobject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 469f019a1c..91c25184b6 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1424,14 +1424,17 @@ QImage QOpenGLFramebufferObject::toImage(bool flipped, int colorAttachmentIndex) // qt_gl_read_framebuffer doesn't work on a multisample FBO if (format().samples() != 0) { QRect rect(QPoint(0, 0), size()); + QOpenGLFramebufferObjectFormat fmt; if (extraFuncs->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)) { - QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, QOpenGLFramebufferObjectFormat()); + fmt.setInternalTextureFormat(d->colorAttachments[colorAttachmentIndex].internalFormat); + QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, fmt); blitFramebuffer(&temp, rect, const_cast(this), rect, GL_COLOR_BUFFER_BIT, GL_NEAREST, colorAttachmentIndex, 0); image = temp.toImage(flipped); } else { - QOpenGLFramebufferObject temp(size(), QOpenGLFramebufferObjectFormat()); + fmt.setInternalTextureFormat(d->colorAttachments[0].internalFormat); + QOpenGLFramebufferObject temp(size(), fmt); blitFramebuffer(&temp, rect, const_cast(this), rect); image = temp.toImage(flipped); } -- cgit v1.2.3 From 62abbe34b84a1c224d27f3eb2f735749f5f24b4f Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 5 Jun 2018 13:13:12 +0200 Subject: Fix build for Android with android-clang in r17 Task-number: QTBUG-67464 Change-Id: Ib971a5da82b31bce9ac1c9ac623ad7d5302cfaec Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/kernel/qplatformcursor.cpp | 2 +- src/gui/kernel/qplatformdialoghelper.cpp | 6 +++--- src/gui/painting/qpagesize.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index df78e7d896..bab26f6028 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -549,7 +549,7 @@ void QPlatformCursorImage::createSystemCursor(int id) void QPlatformCursorImage::set(Qt::CursorShape id) { QPlatformCursorImage *cursor = 0; - if (id >= 0 && id <= Qt::LastCursor) { + if (unsigned(id) <= unsigned(Qt::LastCursor)) { if (!systemCursorTable[id]) createSystemCursor(id); cursor = systemCursorTable[id]; diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index fbadb48f70..b456c1ca31 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -664,18 +664,18 @@ QStringList QFileDialogOptions::history() const void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text) { - if (label >= 0 && label < DialogLabelCount) + if (unsigned(label) < unsigned(DialogLabelCount)) d->labels[label] = text; } QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const { - return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString(); + return (unsigned(label) < unsigned(DialogLabelCount)) ? d->labels[label] : QString(); } bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label) { - return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty(); + return unsigned(label) < unsigned(DialogLabelCount) && !d->labels[label].isEmpty(); } QUrl QFileDialogOptions::initialDirectory() const diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp index 8831d60d48..9cbe6ef911 100644 --- a/src/gui/painting/qpagesize.cpp +++ b/src/gui/painting/qpagesize.cpp @@ -762,7 +762,7 @@ QPageSizePrivate::QPageSizePrivate(QPageSize::PageSizeId pageSizeId) m_windowsId(0), m_units(QPageSize::Point) { - if (pageSizeId >= QPageSize::PageSizeId(0) && pageSizeId <= QPageSize::LastPageSize) + if (unsigned(pageSizeId) <= unsigned(QPageSize::LastPageSize)) init(pageSizeId, QString()); } @@ -1478,7 +1478,7 @@ QRect QPageSize::rectPixels(int resolution) const QString QPageSize::key(PageSizeId pageSizeId) { - if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize) + if (unsigned(pageSizeId) > unsigned(LastPageSize)) return QString(); return QString::fromUtf8(qt_pageSizes[pageSizeId].mediaOption); } @@ -1497,7 +1497,7 @@ static QString msgImperialPageSizeInch(int width, int height) QString QPageSize::name(PageSizeId pageSizeId) { - if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize) + if (unsigned(pageSizeId) > unsigned(LastPageSize)) return QString(); switch (pageSizeId) { -- cgit v1.2.3