diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/accessible/qaccessible.cpp | 22 | ||||
-rw-r--r-- | src/gui/accessible/qaccessiblecache.cpp | 4 | ||||
-rw-r--r-- | src/gui/accessible/qaccessiblecache_p.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 26 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_p.h | 20 | ||||
-rw-r--r-- | src/gui/opengl/qopenglvertexarrayobject.cpp | 5 | ||||
-rw-r--r-- | src/gui/painting/painting.pri | 1 | ||||
-rw-r--r-- | src/gui/painting/qbrush.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qcolor.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpdf.cpp | 13 | ||||
-rw-r--r-- | src/gui/painting/qrgb.h | 14 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 9 | ||||
-rw-r--r-- | src/gui/text/qtextformat.cpp | 20 |
13 files changed, 78 insertions, 64 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 50f023ec78..b3d7843506 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -462,14 +462,13 @@ QT_BEGIN_NAMESPACE Synonym for unsigned, used by the QAccessibleInterface cache. */ +#ifndef QT_NO_ACCESSIBILITY /* accessible widgets plugin discovery stuff */ -#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_LIBRARY Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QAccessibleFactoryInterface_iid, QLatin1String("/accessible"))) #endif -#endif // FIXME turn this into one global static struct Q_GLOBAL_STATIC(QList<QAccessible::InterfaceFactory>, qAccessibleFactories) @@ -482,13 +481,11 @@ QAccessible::RootObjectHandler QAccessible::rootObjectHandler = 0; static bool cleanupAdded = false; -#ifndef QT_NO_ACCESSIBILITY static QPlatformAccessibility *platformAccessibility() { QPlatformIntegration *pfIntegration = QGuiApplicationPrivate::platformIntegration(); return pfIntegration ? pfIntegration->accessibility() : 0; } -#endif /*! \fn QAccessible::QAccessible() @@ -504,10 +501,8 @@ static QPlatformAccessibility *platformAccessibility() */ void QAccessible::cleanup() { -#ifndef QT_NO_ACCESSIBILITY if (QPlatformAccessibility *pfAccessibility = platformAccessibility()) pfAccessibility->cleanup(); -#endif } static void qAccessibleCleanup() @@ -691,7 +686,6 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) return iface; } } -#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_LIBRARY // Find a QAccessiblePlugin (factory) for the class name. If there's // no entry in the cache try to create it using the plugin loader. @@ -715,18 +709,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) return result; } #endif -#endif mo = mo->superClass(); } -#ifndef QT_NO_ACCESSIBILITY if (object == qApp) { QAccessibleInterface *appInterface = new QAccessibleApplication; QAccessibleCache::instance()->insert(object, appInterface); Q_ASSERT(QAccessibleCache::instance()->objectToId.contains(qApp)); return appInterface; } -#endif return 0; } @@ -796,10 +787,8 @@ QAccessibleInterface *QAccessible::accessibleInterface(Id id) */ bool QAccessible::isActive() { -#ifndef QT_NO_ACCESSIBILITY if (QPlatformAccessibility *pfAccessibility = platformAccessibility()) return pfAccessibility->isActive(); -#endif return false; } @@ -834,10 +823,8 @@ void QAccessible::setRootObject(QObject *object) return; } -#ifndef QT_NO_ACCESSIBILITY if (QPlatformAccessibility *pfAccessibility = platformAccessibility()) pfAccessibility->setRootObject(object); -#endif } /*! @@ -864,7 +851,6 @@ void QAccessible::updateAccessibility(QAccessibleEvent *event) if (!isActive()) return; -#ifndef QT_NO_ACCESSIBILITY if (event->type() == QAccessible::TableModelChanged) { if (QAccessibleInterface *iface = event->accessibleInterface()) { if (iface->tableInterface()) @@ -879,7 +865,6 @@ void QAccessible::updateAccessibility(QAccessibleEvent *event) if (QPlatformAccessibility *pfAccessibility = platformAccessibility()) pfAccessibility->notifyAccessibilityUpdate(event); -#endif } #if QT_DEPRECATED_SINCE(5, 0) @@ -1826,7 +1811,7 @@ QDebug operator<<(QDebug d, const QAccessibleEvent &ev) d.nospace() << ")"; return d.space(); } - +#endif // QT_NO_DEBUGSTREAM /*! \class QAccessibleTextInterface @@ -2718,8 +2703,7 @@ QString qAccessibleLocalizedActionDescription(const QString &actionName) return accessibleActionStrings()->localizedDescription(actionName); } - -#endif +#endif // QT_NO_ACCESSIBILITY QT_END_NAMESPACE diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp index 96dde1ea3f..6a27210aeb 100644 --- a/src/gui/accessible/qaccessiblecache.cpp +++ b/src/gui/accessible/qaccessiblecache.cpp @@ -41,6 +41,8 @@ #include "qaccessiblecache_p.h" +#ifndef QT_NO_ACCESSIBILITY + QT_BEGIN_NAMESPACE /*! @@ -127,3 +129,5 @@ void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj) } QT_END_NAMESPACE + +#endif diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h index 643cbe5667..cd55747fcc 100644 --- a/src/gui/accessible/qaccessiblecache_p.h +++ b/src/gui/accessible/qaccessiblecache_p.h @@ -59,6 +59,8 @@ #include "qaccessible.h" +#ifndef QT_NO_ACCESSIBILITY + Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QMacAccessibilityElement)); QT_BEGIN_NAMESPACE @@ -98,4 +100,6 @@ private: QT_END_NAMESPACE +#endif // QT_NO_ACCESSIBILITY + #endif diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 2d7900b5d9..a327a43557 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1708,7 +1708,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo QPointF localPoint = e->localPos; QPointF globalPoint = e->globalPos; - if (e->nullWindow) { + if (e->nullWindow()) { window = QGuiApplication::topLevelAt(globalPoint.toPoint()); if (window) { QPointF delta = globalPoint - globalPoint.toPoint(); @@ -1761,7 +1761,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo ev.setTimestamp(e->timestamp); setMouseEventSource(&ev, e->source); #ifndef QT_NO_CURSOR - if (!e->synthetic) { + if (!e->synthetic()) { if (const QScreen *screen = window->screen()) if (QPlatformCursor *cursor = screen->handle()->cursor()) cursor->pointerEvent(ev); @@ -1779,7 +1779,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo } QGuiApplication::sendSpontaneousEvent(window, &ev); - if (!e->synthetic && !ev.isAccepted() + if (!e->synthetic() && !ev.isAccepted() && !frameStrut && qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) { if (!m_fakeTouchDevice) { @@ -1810,12 +1810,12 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::convertTouchPoints(points, &type); QWindowSystemInterfacePrivate::TouchEvent fake(window, e->timestamp, type, m_fakeTouchDevice, touchPoints, e->modifiers); - fake.synthetic = true; + fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; processTouchEvent(&fake); } if (doubleClick) { mousePressButton = Qt::NoButton; - if (!e->window.isNull() || e->nullWindow) { // QTBUG-36364, check if window closed in response to press + if (!e->window.isNull() || e->nullWindow()) { // QTBUG-36364, check if window closed in response to press const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick; QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint, button, buttons, e->modifiers); @@ -1833,7 +1833,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh QPointF globalPoint = e->globalPos; QPointF localPoint = e->localPos; - if (e->nullWindow) { + if (e->nullWindow()) { window = QGuiApplication::topLevelAt(globalPoint.toPoint()); if (window) { QPointF delta = globalPoint - globalPoint.toPoint(); @@ -1864,7 +1864,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE { QWindow *window = e->window.data(); modifier_buttons = e->modifiers; - if (e->nullWindow + if (e->nullWindow() #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) || e->key == Qt::Key_Back || e->key == Qt::Key_Menu #endif @@ -2105,7 +2105,7 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T // subsequent events up to the release are delivered to that same window. // If window is given, just send to that. if (type == QEvent::TabletPress) { - if (e->nullWindow) { + if (e->nullWindow()) { window = QGuiApplication::topLevelAt(e->global.toPoint()); localValid = false; } @@ -2113,7 +2113,7 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T return; tabletPressTarget = window; } else { - if (e->nullWindow) { + if (e->nullWindow()) { window = tabletPressTarget; localValid = false; } @@ -2247,7 +2247,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To touchEvent.setWindow(*winIt); QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent); } - if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic) { + if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic()) { for (QHash<QWindow *, SynthesizedMouseData>::const_iterator synthIt = self->synthesizedMousePoints.constBegin(), synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) { if (!synthIt->window) @@ -2259,7 +2259,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To Qt::NoButton, e->modifiers, Qt::MouseEventSynthesizedByQt); - fake.synthetic = true; + fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; processMouseEvent(&fake); } self->synthesizedMousePoints.clear(); @@ -2438,7 +2438,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To } QGuiApplication::sendSpontaneousEvent(w, &touchEvent); - if (!e->synthetic && !touchEvent.isAccepted() && synthesizeMouseFromTouchEventsEnabled()) { + if (!e->synthetic() && !touchEvent.isAccepted() && synthesizeMouseFromTouchEventsEnabled()) { // exclude touchpads as those generate their own mouse events if (touchEvent.device()->type() != QTouchDevice::TouchPad) { Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton; @@ -2459,7 +2459,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To touchPoint.pos(), touchPoint.screenPos(), b, e->modifiers); - fake.synthetic = true; + fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; processMouseEvent(&fake); break; } diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 89ca4064b2..c608061d04 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -101,11 +101,20 @@ public: class WindowSystemEvent { public: + enum { + Synthetic = 0x1, + NullWindow = 0x2 + }; + explicit WindowSystemEvent(EventType t) - : type(t), synthetic(false) { } + : type(t), flags(0) { } virtual ~WindowSystemEvent() { } + + bool synthetic() const { return flags & Synthetic; } + bool nullWindow() const { return flags & NullWindow; } + EventType type; - bool synthetic; + int flags; }; class CloseEvent : public WindowSystemEvent { @@ -194,9 +203,12 @@ public: class UserEvent : public WindowSystemEvent { public: UserEvent(QWindow * w, ulong time, EventType t) - : WindowSystemEvent(t), window(w), nullWindow(w == 0), timestamp(time) { } + : WindowSystemEvent(t), window(w), timestamp(time) + { + if (!w) + flags |= NullWindow; + } QPointer<QWindow> window; - bool nullWindow; unsigned long timestamp; }; diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index c24254756b..15f08ddfce 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -150,6 +150,11 @@ bool QOpenGLVertexArrayObjectPrivate::create() qWarning("QOpenGLVertexArrayObject::create() requires a valid current OpenGL context"); return false; } + + //Fail early, if context is the same as ctx, it means we have tried to initialize for this context and failed + if (ctx == context) + return false; + context = ctx; QObject::connect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index a5a395cce2..588a2f0a88 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -41,6 +41,7 @@ HEADERS += \ painting/qrasterdefs_p.h \ painting/qrasterizer_p.h \ painting/qregion.h \ + painting/qrgb.h \ painting/qstroker_p.h \ painting/qtextureglyphcache_p.h \ painting/qtransform.h \ diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index 4d8c97e255..e09ad3e1af 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -243,7 +243,7 @@ private: qreal cx, cy, angle; } conical; } m_data; - void *dummy; + void *dummy; // ### Qt 6: replace with actual content (CoordinateMode, InterpolationMode, ...) }; inline void QGradient::setSpread(Spread aspread) diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index e5de2678a4..d5ea51c970 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -73,7 +73,7 @@ public: QColor(QRgb rgb); QColor(const QString& name); QColor(const char *name); - QColor(const QColor &color); + QColor(const QColor &color); // ### Qt 6: remove, the trivial one is fine. QColor(Spec spec); bool isValid() const; diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 0c888d645d..c7f3c0fd5b 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -2323,6 +2323,14 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor, return patternObj; } +static inline bool is_monochrome(const QVector<QRgb> &colorTable) +{ + return colorTable.size() == 2 + && colorTable.at(0) == QColor(Qt::black).rgba() + && colorTable.at(1) == QColor(Qt::white).rgba() + ; +} + /*! * Adds an image to the pdf and return the pdf-object id. Returns -1 if adding the image failed. */ @@ -2337,10 +2345,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n QImage image = img; QImage::Format format = image.format(); - if (image.depth() == 1 && *bitmap && img.colorTable().size() == 2 - && img.colorTable().at(0) == QColor(Qt::black).rgba() - && img.colorTable().at(1) == QColor(Qt::white).rgba()) - { + if (image.depth() == 1 && *bitmap && is_monochrome(img.colorTable())) { if (format == QImage::Format_MonoLSB) image = image.convertToFormat(QImage::Format_Mono); format = QImage::Format_Mono; diff --git a/src/gui/painting/qrgb.h b/src/gui/painting/qrgb.h index d8e19302d1..646aded954 100644 --- a/src/gui/painting/qrgb.h +++ b/src/gui/painting/qrgb.h @@ -80,9 +80,11 @@ inline Q_DECL_CONSTEXPR int qGray(QRgb rgb) // convert RGB to gra inline Q_DECL_CONSTEXPR bool qIsGray(QRgb rgb) { return qRed(rgb) == qGreen(rgb) && qRed(rgb) == qBlue(rgb); } +template <int ProcessorWordSize> +inline QRgb qPremultiply_impl(QRgb x); -#if Q_PROCESSOR_WORDSIZE == 8 // 64-bit version -inline QRgb qPremultiply(QRgb x) +template <> // 64-bit version +inline QRgb qPremultiply_impl<8>(QRgb x) { const uint a = qAlpha(x); quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a; @@ -90,8 +92,9 @@ inline QRgb qPremultiply(QRgb x) t &= 0x000000ff00ff00ff; return (uint(t)) | (uint(t >> 24)) | (a << 24); } -#else // 32-bit version -inline QRgb qPremultiply(QRgb x) + +template <> // 32-bit version +inline QRgb qPremultiply_impl<4>(QRgb x) { const uint a = qAlpha(x); uint t = (x & 0xff00ff) * a; @@ -104,7 +107,8 @@ inline QRgb qPremultiply(QRgb x) x |= t | (a << 24); return x; } -#endif + +inline QRgb qPremultiply(QRgb x) { return qPremultiply_impl<Q_PROCESSOR_WORDSIZE>(x); } Q_GUI_EXPORT extern const uint qt_inv_premul_factor[]; diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 86a0bf1066..fe1f915e8f 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -1558,6 +1558,15 @@ bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &sty QtFontStyle::Key styleKey(style); QtFontFamily *f = d->family(familyName); + if (!f) { + for (int i = 0; i < d->count; i++) { + if (d->families[i]->matchesFamilyName(familyName)) { + f = d->families[i]; + f->ensurePopulated(); + break; + } + } + } if (!f) return smoothScalable; for (int j = 0; j < f->count; j++) { diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index 4854af0d01..0bb60516b5 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -266,20 +266,6 @@ private: friend QDataStream &operator>>(QDataStream &, QTextFormat &); }; -// this is only safe because sizeof(int) == sizeof(float) -static inline uint hash(float d) -{ -#ifdef Q_CC_GNU - // this is a GCC extension and isn't guaranteed to work in other compilers - // the reinterpret_cast below generates a strict-aliasing warning with GCC - union { float f; uint u; } cvt; - cvt.f = d; - return cvt.u; -#else - return reinterpret_cast<uint&>(d); -#endif -} - static inline uint hash(const QColor &color) { return (color.isValid()) ? color.rgba() : 0x234109; @@ -287,7 +273,7 @@ static inline uint hash(const QColor &color) static inline uint hash(const QPen &pen) { - return hash(pen.color()) + hash(pen.widthF()); + return hash(pen.color()) + qHash(pen.widthF()); } static inline uint hash(const QBrush &brush) @@ -300,7 +286,7 @@ static inline uint variantHash(const QVariant &variant) // simple and fast hash functions to differentiate between type and value switch (variant.userType()) { // sorted by occurrence frequency case QVariant::String: return qHash(variant.toString()); - case QVariant::Double: return hash(variant.toDouble()); + case QVariant::Double: return qHash(variant.toDouble()); case QVariant::Int: return 0x811890 + variant.toInt(); case QVariant::Brush: return 0x01010101 + hash(qvariant_cast<QBrush>(variant)); @@ -311,7 +297,7 @@ static inline uint variantHash(const QVariant &variant) case QVariant::Color: return hash(qvariant_cast<QColor>(variant)); case QVariant::TextLength: return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue()); - case QMetaType::Float: return hash(variant.toFloat()); + case QMetaType::Float: return qHash(variant.toFloat()); case QVariant::Invalid: return 0; default: break; } |