diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-13 09:49:38 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-10-13 09:49:38 +0200 |
commit | dfc177e3a99dd593db4b1e9445d6243ce75ebf07 (patch) | |
tree | 4e33c7be90a44642e672fff22ea163b500ff3aef /src/gui | |
parent | 72efb2e6f4af2fd909daaf9104f09fd1425acfb0 (diff) | |
parent | 1d6eb70dcec105af28d6a5e9b59d56c895c70389 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
qmake/library/qmakeevaluator.cpp
(cherry picked from commit 1af6dc2c8fb4d91400fddc5050166f972ae57c9a in qttools)
src/corelib/kernel/qcore_mac_objc.mm
src/gui/painting/qcolor.h
src/plugins/platforms/cocoa/qcocoawindow.mm
Change-Id: I5b3ec468a5a9a73911b528d3d24ff8e19f339f31
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/configure.json | 41 | ||||
-rw-r--r-- | src/gui/configure.pri | 19 | ||||
-rw-r--r-- | src/gui/image/qimage_ssse3.cpp | 22 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 50 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.cpp | 185 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface.h | 14 | ||||
-rw-r--r-- | src/gui/kernel/qwindowsysteminterface_p.h | 7 | ||||
-rw-r--r-- | src/gui/painting/qbackingstore.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 1 | ||||
-rw-r--r-- | src/gui/painting/qcolor.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 6 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_avx2.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_neon.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_sse2.cpp | 13 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_ssse3.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawingprimitive_sse2_p.h | 4 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 6 | ||||
-rw-r--r-- | src/gui/text/qstatictext.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 9 |
20 files changed, 244 insertions, 157 deletions
diff --git a/src/gui/configure.json b/src/gui/configure.json index 376359ba37..318efe5401 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -54,6 +54,14 @@ "-lbcm_host" ] }, + "direct2d": { + "label": "Direct 2D", + "export": "", + "test": "qpa/direct2d", + "sources": [ + "-ld2d1 -ldwrite -ld3d11" + ] + }, "directfb": { "label": "DirectFB", "test": "qpa/directfb", @@ -87,10 +95,10 @@ }, "freetype": { "label": "FreeType", - "export": "", "test": "unix/freetype", "sources": [ - "-lfreetype" + { "type": "pkgConfig", "args": "freetype2" }, + { "type": "freetype", "libs": "-lfreetype" } ] }, "fontconfig": { @@ -98,7 +106,7 @@ "test": "unix/fontconfig", "sources": [ { "type": "pkgConfig", "args": "fontconfig freetype2" }, - "-lfontconfig -lfreetype" + { "type": "freetype", "libs": "-lfontconfig -lfreetype" } ] }, "gbm": { @@ -294,12 +302,6 @@ }, "tests": { - "direct2d": { - "label": "Direct 2D", - "type": "compile", - "test": "qpa/direct2d", - "use": "direct2d" - }, "directwrite2": { "label": "DirectWrite 2", "type": "compile", @@ -356,6 +358,12 @@ "type": "compile", "test": "unix/evdev" }, + "libinput_axis_api": { + "label": "axis API in libinput", + "type": "compile", + "test": "unix/libinput_axis_api", + "use": "libinput" + }, "linuxfb": { "label": "LinuxFB", "type": "compile", @@ -436,7 +444,7 @@ "direct2d": { "label": "Direct 2D", "autoDetect": false, - "condition": "tests.direct2d", + "condition": "config.win32 && libs.direct2d", "output": [ "privateFeature" ] }, "evdev": { @@ -446,6 +454,8 @@ }, "freetype": { "label": "FreeType", + "purpose": "Supports the FreeType 2 font engine (and its supported font formats).", + "section": "Fonts", "output": [ "privateFeature", "feature" ] }, "system-freetype": { @@ -499,6 +509,11 @@ "condition": "features.libudev && libs.libinput", "output": [ "privateFeature" ] }, + "libinput-axis-api": { + "label": "axis API in libinput", + "condition": "tests.libinput_axis_api", + "output": [ "privateFeature" ] + }, "lgmon": { "label": "lgmon", "emitIf": "config.qnx", @@ -922,12 +937,6 @@ "condition": "features.temporaryfile", "output": [ "publicFeature", "feature" ] }, - "freetype": { - "label": "Freetype Font Engine", - "purpose": "Supports the FreeType 2 font engine (and its supported font formats).", - "section": "Fonts", - "output": [ "publicFeature", "feature" ] - }, "desktopservices": { "label": "QDesktopServices", "purpose": "Provides methods for accessing common desktop services.", diff --git a/src/gui/configure.pri b/src/gui/configure.pri index d79c5a6bba..ee5c7730df 100644 --- a/src/gui/configure.pri +++ b/src/gui/configure.pri @@ -1,5 +1,20 @@ # custom tests +defineTest(qtConfLibrary_freetype) { + TRY_INCLUDEPATHS = $$EXTRA_INCLUDEPATH $$QMAKE_INCDIR_X11 + haiku: TRY_INCLUDEPATHS += /system/develop/headers + TRY_INCLUDEPATHS += $$QMAKE_DEFAULT_INCDIR + for (p, TRY_INCLUDEPATHS) { + includedir = $$p/freetype2 + exists($$includedir) { + $${1}.includedir = "$$val_escape(includedir)" + export($${1}.includedir) + return(true) + } + } + return(false) +} + # Check for Direct X SDK (include, lib, and direct shader compiler 'fxc'). # Up to Direct X SDK June 2010 and for MinGW, this is pointed to by the # DXSDK_DIR variable. Starting with Windows Kit 8, it is included in @@ -50,9 +65,11 @@ defineTest(qtConfTest_qpaDefaultPlatform) { else: win32: name = windows else: android: name = android else: macos: name = cocoa - else: ios: name = ios + else: if(ios|tvos): name = ios + else: watchos: name = minimal else: qnx: name = qnx else: integrity: name = integrityfb + else: haiku: name = haiku else: name = xcb $${1}.value = $$name diff --git a/src/gui/image/qimage_ssse3.cpp b/src/gui/image/qimage_ssse3.cpp index 0fa0eecd80..9cdfba20e3 100644 --- a/src/gui/image/qimage_ssse3.cpp +++ b/src/gui/image/qimage_ssse3.cpp @@ -50,15 +50,11 @@ QT_BEGIN_NAMESPACE // dst must be at least len * 4 bytes Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, const uchar *src, int len) { - quint32 *const end = dst + len; + int i = 0; - // Prologue, align dst to 16 bytes. The alignment is done on dst because it has 4 store() - // for each 3 load() of src. - const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast<quintptr>(dst) >> 2) & 0x3)) & 0x3; - const int prologLength = qMin(len, offsetToAlignOn16Bytes); - - for (int i = 0; i < prologLength; ++i) { - *dst++ = qRgb(src[0], src[1], src[2]); + // Prologue, align dst to 16 bytes. + ALIGNMENT_PROLOGUE_16BYTES(dst, i, len) { + dst[i] = qRgb(src[0], src[1], src[2]); src += 3; } @@ -72,10 +68,9 @@ Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, con const __m128i alphaMask = _mm_set1_epi32(0xff000000); const __m128i *inVectorPtr = (const __m128i *)src; - __m128i *dstVectorPtr = (__m128i *)dst; + __m128i *dstVectorPtr = (__m128i *)(dst + i); - const int simdRoundCount = (len - prologLength) / 16; // one iteration in the loop converts 16 pixels - for (int i = 0; i < simdRoundCount; ++i) { + for (; i < (len - 15); i += 16) { // one iteration in the loop converts 16 pixels /* RGB888 has 5 pixels per vector, + 1 byte from the next pixel. The idea here is to load vectors of RGB888 and use palignr to select a vector out of two vectors. @@ -117,10 +112,9 @@ Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, con ++dstVectorPtr; } src = (const uchar *)inVectorPtr; - dst = (quint32 *)dstVectorPtr; - while (dst != end) { - *dst++ = qRgb(src[0], src[1], src[2]); + SIMD_EPILOGUE(i, len, 15) { + dst[i] = qRgb(src[0], src[1], src[2]); src += 3; } } diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index a360debf5b..0aa05a04e2 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -760,39 +760,37 @@ QBitmap QPixmap::createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConversionFlags flags) { - if (fileName.isEmpty()) { - data.reset(); - return false; - } - - detach(); + if (!fileName.isEmpty()) { - QFileInfo info(fileName); - QString key = QLatin1String("qt_pixmap") - % info.absoluteFilePath() - % HexString<uint>(info.lastModified().toSecsSinceEpoch()) - % HexString<quint64>(info.size()) - % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); + QFileInfo info(fileName); + // Note: If no extension is provided, we try to match the + // file against known plugin extensions + if (info.completeSuffix().isEmpty() || info.exists()) { - // Note: If no extension is provided, we try to match the - // file against known plugin extensions - if (!info.completeSuffix().isEmpty() && !info.exists()) { - data.reset(); - return false; - } + QString key = QLatin1String("qt_pixmap") + % info.absoluteFilePath() + % HexString<uint>(info.lastModified().toSecsSinceEpoch()) + % HexString<quint64>(info.size()) + % HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType); - if (QPixmapCache::find(key, this)) - return true; + if (QPixmapCache::find(key, this)) + return true; - if (!data) - data = QPlatformPixmap::create(0, 0, QPlatformPixmap::PixmapType); + data = QPlatformPixmap::create(0, 0, data ? data->pixelType() : QPlatformPixmap::PixmapType); - if (data->fromFile(fileName, format, flags)) { - QPixmapCache::insert(key, *this); - return true; + if (data->fromFile(fileName, format, flags)) { + QPixmapCache::insert(key, *this); + return true; + } + } } - data.reset(); + if (!isNull()) { + if (isQBitmap()) + *this = QBitmap(); + else + data.reset(); + } return false; } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index cd67e9a875..fcb9c14406 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -1667,7 +1667,7 @@ QResizeEvent::~QResizeEvent() The event handler QWidget::closeEvent() receives close events. The default implementation of this event handler accepts the close event. If you do not want your widget to be hidden, or want some - special handing, you should reimplement the event handler and + special handling, you should reimplement the event handler and ignore() the event. The \l{mainwindows/application#close event handler}{closeEvent() in the diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index bb778bc5fc..b799f75090 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -70,6 +70,63 @@ QWindowSystemInterfacePrivate::WindowSystemEventList QWindowSystemInterfacePriva extern QPointer<QWindow> qt_last_mouse_receiver; /*! + Handles a window system event asynchronously by posting the event to Qt Gui. + + \sa postWindowSystemEvent() +*/ +template<> +bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::AsynchronousDelivery>(WindowSystemEvent *ev) +{ + QWindowSystemInterfacePrivate::postWindowSystemEvent(ev); + return true; +} + +/*! + Handles a window system event synchronously. + + If the event is delivered from another thread than the Qt main thread the + window system event queue is flushed, which may deliver other events as + well. + + \sa processWindowSystemEvent() +*/ +template<> +bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::SynchronousDelivery>(WindowSystemEvent *ev) +{ + return QWindowSystemInterfacePrivate::processWindowSystemEvent(ev); +} + +/*! + Handles a window system event. + + By default this function posts the event on the window system event queue and + wakes the Gui event dispatcher. Qt Gui will then handle the event asynchonously + at a later point. The return value is not used in asynchronous mode and will + always be true. + + In synchronous mode Qt Gui will process the event immediately. The return value + indicates if Qt accepted the event. If the event is delivered from another thread + than the Qt main thread the window system event queue is flushed, which may deliver + other events as well. + + \sa flushWindowSystemEvents(), processWindowSystemEvent(), setSynchronousWindowSystemEvents() +*/ +template<> +bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::DefaultDelivery>(QWindowSystemInterfacePrivate::WindowSystemEvent *ev) +{ + if (synchronousWindowSystemEvents) + return handleWindowSystemEvent<QWindowSystemInterface::SynchronousDelivery>(ev); + else + return handleWindowSystemEvent<QWindowSystemInterface::AsynchronousDelivery>(ev); +} + +#define QT_DEFINE_QPA_EVENT_HANDLER(ReturnType, HandlerName, ...) \ + template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::DefaultDelivery>(__VA_ARGS__); \ + template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::SynchronousDelivery>(__VA_ARGS__); \ + template Q_GUI_EXPORT ReturnType QWindowSystemInterface::HandlerName<QWindowSystemInterface::AsynchronousDelivery>(__VA_ARGS__); \ + template<typename Delivery> ReturnType QWindowSystemInterface::HandlerName(__VA_ARGS__) + +/*! \class QWindowSystemInterface \since 5.0 \internal @@ -81,18 +138,18 @@ extern QPointer<QWindow> qt_last_mouse_receiver; until sendWindowSystemEvents() is called by the event dispatcher. */ -void QWindowSystemInterface::handleEnterEvent(QWindow *tlw, const QPointF &local, const QPointF &global) +QT_DEFINE_QPA_EVENT_HANDLER(void, handleEnterEvent, QWindow *tlw, const QPointF &local, const QPointF &global) { if (tlw) { QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw, local, global); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } } -void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw) +QT_DEFINE_QPA_EVENT_HANDLER(void, handleLeaveEvent, QWindow *tlw) { QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } /*! @@ -104,15 +161,8 @@ void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw) */ void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local, const QPointF& global) { - bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents; - if (wasSynchronous) - setSynchronousWindowSystemEvents(false); - handleLeaveEvent(leave); + handleLeaveEvent<AsynchronousDelivery>(leave); handleEnterEvent(enter, local, global); - if (wasSynchronous) { - flushWindowSystemEvents(); - setSynchronousWindowSystemEvents(true); - } } void QWindowSystemInterface::handleWindowActivated(QWindow *tlw, Qt::FocusReason r) @@ -167,19 +217,19 @@ void QWindowSystemInterface::handleCloseEvent(QWindow *tlw, bool *accepted) \a w == 0 means that the event is in global coords only, \a local will be ignored in this case */ -void QWindowSystemInterface::handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, +QT_DEFINE_QPA_EVENT_HANDLER(void, handleMouseEvent, QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, Qt::MouseEventSource source) { unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); - handleMouseEvent(w, time, local, global, b, mods, source); + handleMouseEvent<Delivery>(w, time, local, global, b, mods, source); } -void QWindowSystemInterface::handleMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, +QT_DEFINE_QPA_EVENT_HANDLER(void, handleMouseEvent, QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, Qt::MouseEventSource source) { QWindowSystemInterfacePrivate::MouseEvent * e = new QWindowSystemInterfacePrivate::MouseEvent(w, timestamp, QHighDpi::fromNativeLocalPosition(local, w), QHighDpi::fromNativePixels(global, w), b, mods, source); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } void QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, @@ -217,11 +267,7 @@ bool QWindowSystemInterface::handleShortcutEvent(QWindow *window, ulong timestam QEvent::ShortcutOverride, keyCode, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorepeat, count); { - // FIXME: Template handleWindowSystemEvent to support both sync and async delivery - QScopedValueRollback<bool> syncRollback(QWindowSystemInterfacePrivate::synchronousWindowSystemEvents); - QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = true; - - if (QWindowSystemInterfacePrivate::handleWindowSystemEvent(shortcutOverrideEvent)) + if (QWindowSystemInterfacePrivate::handleWindowSystemEvent<SynchronousDelivery>(shortcutOverrideEvent)) return false; } } @@ -248,13 +294,12 @@ bool QWindowSystemInterface::handleShortcutEvent(QWindow *window, ulong timestam #endif } - -bool QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) { +QT_DEFINE_QPA_EVENT_HANDLER(bool, handleKeyEvent, QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) { unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); - return handleKeyEvent(w, time, t, k, mods, text, autorep, count); + return handleKeyEvent<Delivery>(w, time, t, k, mods, text, autorep, count); } -bool QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) +QT_DEFINE_QPA_EVENT_HANDLER(bool, handleKeyEvent, QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) { #if defined(Q_OS_OSX) if (t == QEvent::KeyPress && QWindowSystemInterface::handleShortcutEvent(tlw, timestamp, k, mods, 0, 0, 0, text, autorep, count)) @@ -263,7 +308,7 @@ bool QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEven QWindowSystemInterfacePrivate::KeyEvent * e = new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count); - return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, @@ -394,6 +439,15 @@ void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *e windowSystemEventQueue.remove(event); } +/*! + Posts a window system event to be handled asynchronously by Qt Gui. + + This function posts the event on the window system event queue and wakes the + Gui event dispatcher. Qt Gui will then handle the event asynchonously at a + later point. + + \sa flushWindowSystemEvents(), processWindowSystemEvent(), handleWindowSystemEvent() +*/ void QWindowSystemInterfacePrivate::postWindowSystemEvent(WindowSystemEvent *ev) { windowSystemEventQueue.append(ev); @@ -403,37 +457,32 @@ void QWindowSystemInterfacePrivate::postWindowSystemEvent(WindowSystemEvent *ev) } /*! - Handles a window system event. + Processes a window system event synchronously. - By default this function posts the event on the window system event queue and - wakes the Gui event dispatcher. Qt Gui will then handle the event asynchonously - at a later point. The return value is not used in asynchronous mode and will - always be true. + Qt Gui will process the event immediately. The return value indicates if Qt + accepted the event. - In synchronous mode Qt Gui will process the event immediately. The return value - indicates if Qt accepted the event. + If the event is delivered from another thread than the Qt main thread the + window system event queue is flushed, which may deliver other events as + well. - \sa flushWindowSystemEvents(), setSynchronousWindowSystemEvents() + \sa flushWindowSystemEvents(), postWindowSystemEvent(), handleWindowSystemEvent() */ -bool QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev) +bool QWindowSystemInterfacePrivate::processWindowSystemEvent(WindowSystemEvent *ev) { bool accepted = true; - if (synchronousWindowSystemEvents) { - if (QThread::currentThread() == QGuiApplication::instance()->thread()) { - // Process the event immediately on the current thread and return the accepted state. - QGuiApplicationPrivate::processWindowSystemEvent(ev); - accepted = ev->eventAccepted; - delete ev; - } else { - // Post the event on the Qt main thread queue and flush the queue. - // This will wake up the Gui thread which will process the event. - // Return the accepted state for the last event on the queue, - // which is the event posted by this function. - postWindowSystemEvent(ev); - accepted = QWindowSystemInterface::flushWindowSystemEvents(); - } + if (QThread::currentThread() == QGuiApplication::instance()->thread()) { + // Process the event immediately on the current thread and return the accepted state. + QGuiApplicationPrivate::processWindowSystemEvent(ev); + accepted = ev->eventAccepted; + delete ev; } else { + // Post the event on the Qt main thread queue and flush the queue. + // This will wake up the Gui thread which will process the event. + // Return the accepted state for the last event on the queue, + // which is the event posted by this function. postWindowSystemEvent(ev); + accepted = QWindowSystemInterface::flushWindowSystemEvents(); } return accepted; } @@ -453,13 +502,6 @@ bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device) return QTouchDevicePrivate::isRegistered(device); } -void QWindowSystemInterface::handleTouchEvent(QWindow *w, QTouchDevice *device, - const QList<TouchPoint> &points, Qt::KeyboardModifiers mods) -{ - unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); - handleTouchEvent(w, time, device, points, mods); -} - QList<QTouchEvent::TouchPoint> QWindowSystemInterfacePrivate::fromNativeTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points, const QWindow *window, @@ -530,7 +572,14 @@ QList<QWindowSystemInterface::TouchPoint> return newList; } -void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTouchDevice *device, +QT_DEFINE_QPA_EVENT_HANDLER(void, handleTouchEvent, QWindow *w, QTouchDevice *device, + const QList<TouchPoint> &points, Qt::KeyboardModifiers mods) +{ + unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); + handleTouchEvent<Delivery>(w, time, device, points, mods); +} + +QT_DEFINE_QPA_EVENT_HANDLER(void, handleTouchEvent, QWindow *tlw, ulong timestamp, QTouchDevice *device, const QList<TouchPoint> &points, Qt::KeyboardModifiers mods) { if (!points.size()) // Touch events must have at least one point @@ -544,7 +593,7 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTo QWindowSystemInterfacePrivate::TouchEvent *e = new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, device, touchPoints, mods); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *device, @@ -634,7 +683,7 @@ bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFl // deferredFlushWindowSystemEvents from the Gui thread. QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex); QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags); - QWindowSystemInterfacePrivate::postWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent<SynchronousDelivery>(e); QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex); } else { sendWindowSystemEvents(flags); @@ -872,20 +921,13 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPo Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *w, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods, int timestamp) { - bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents; - QWindowSystemInterface::setSynchronousWindowSystemEvents(true); const qreal factor = QHighDpiScaling::factor(w); - QWindowSystemInterface::handleMouseEvent(w, timestamp, local * factor, - global * factor, b, mods); - QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous); + QWindowSystemInterface::handleMouseEvent<QWindowSystemInterface::SynchronousDelivery>(w, timestamp, local * factor, global * factor, b, mods); } Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1) { - bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents; - QWindowSystemInterface::setSynchronousWindowSystemEvents(true); - QWindowSystemInterface::handleKeyEvent(w, t, k, mods, text, autorep, count); - QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous); + QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(w, t, k, mods, text, autorep, count); } Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1) @@ -940,11 +982,8 @@ Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device, const QList<QTouchEvent::TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier) { - bool wasSynchronous = QWindowSystemInterfacePrivate::synchronousWindowSystemEvents; - QWindowSystemInterface::setSynchronousWindowSystemEvents(true); - QWindowSystemInterface::handleTouchEvent(w, device, - QWindowSystemInterfacePrivate::toNativeTouchPoints(points, w), mods); - QWindowSystemInterface::setSynchronousWindowSystemEvents(wasSynchronous); + QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(w, device, + QWindowSystemInterfacePrivate::toNativeTouchPoints(points, w), mods); } QWindowSystemEventHandler::~QWindowSystemEventHandler() diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index e7e47ac6d9..6fade3cc4c 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -72,9 +72,15 @@ class QPlatformDropQtResponse; class Q_GUI_EXPORT QWindowSystemInterface { public: + struct SynchronousDelivery {}; + struct AsynchronousDelivery {}; + struct DefaultDelivery {}; + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized); @@ -88,7 +94,9 @@ public: static bool handleShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString & text = QString(), bool autorep = false, ushort count = 1); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static bool handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static bool handleKeyEvent(QWindow *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1); static bool handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, @@ -135,8 +143,11 @@ public: static void registerTouchDevice(const QTouchDevice *device); static void unregisterTouchDevice(const QTouchDevice *device); static bool isTouchDeviceRegistered(const QTouchDevice *device); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleTouchEvent(QWindow *w, QTouchDevice *device, const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleTouchEvent(QWindow *w, ulong timestamp, QTouchDevice *device, const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier); static void handleTouchCancelEvent(QWindow *w, QTouchDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier); @@ -145,7 +156,10 @@ public: // rect is relative to parent static void handleGeometryChange(QWindow *w, const QRect &newRect, const QRect &oldRect = QRect()); static void handleCloseEvent(QWindow *w, bool *accepted = Q_NULLPTR); + + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleEnterEvent(QWindow *w, const QPointF &local = QPointF(), const QPointF& global = QPointF()); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static void handleLeaveEvent(QWindow *w); static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF()); static void handleWindowActivated(QWindow *w, Qt::FocusReason r = Qt::OtherFocusReason); diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index f471e1f550..7c9b1f2852 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -491,9 +491,14 @@ public: static WindowSystemEvent *getNonUserInputWindowSystemEvent(); static WindowSystemEvent *peekWindowSystemEvent(EventType t); static void removeWindowSystemEvent(WindowSystemEvent *event); - static void postWindowSystemEvent(WindowSystemEvent *ev); + template<typename Delivery = QWindowSystemInterface::DefaultDelivery> static bool handleWindowSystemEvent(WindowSystemEvent *ev); +private: + static void postWindowSystemEvent(WindowSystemEvent *ev); + static bool processWindowSystemEvent(WindowSystemEvent *ev); + +public: static QElapsedTimer eventTime; static bool synchronousWindowSystemEvents; diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index ceaad61e13..53349dcef4 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -112,6 +112,8 @@ void QBackingStore::flush(const QRegion ®ion, QWindow *win, const QPoint &off } #endif + Q_ASSERT(win == this->window() || this->window()->isAncestorOf(win, QWindow::ExcludeTransients)); + d_ptr->platformBackingStore->flush(win, QHighDpi::toNativeLocalRegion(region, win), QHighDpi::toNativeLocalPosition(offset, win)); } diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 05790c4504..e3dbf663e1 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -131,6 +131,7 @@ static bool get_hex_rgb(const QChar *str, int len, QRgb *rgb) char tmp[16]; for (int i = 0; i < len; ++i) tmp[i] = str[i].toLatin1(); + tmp[len] = 0; return get_hex_rgb(tmp, len, rgb); } diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index eda1ac89c7..22fcbcb2a8 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -73,7 +73,7 @@ public: QColor(QRgb rgb) Q_DECL_NOTHROW; QColor(QRgba64 rgba64) Q_DECL_NOTHROW; inline QColor(const QString& name); - QColor(const char *aname) : QColor(QLatin1String(aname)) {} + inline QColor(const char *aname) : QColor(QLatin1String(aname)) {} inline QColor(QLatin1String name); QColor(Spec spec) Q_DECL_NOTHROW; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 3e01d34cb2..928a56fd2f 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -603,7 +603,7 @@ static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint * buffer += 2; } - for (; i < count; ++i) { + SIMD_EPILOGUE(i, count, 3) { uint s = *src++; if (RGBA) s = RGBA2ARGB(s); @@ -766,7 +766,7 @@ static inline void qConvertA2RGB30PMToARGB64PM_sse2(QRgba64 *buffer, const uint buffer += 2; } - for (; i < count; ++i) + SIMD_EPILOGUE(i, count, 3) *buffer++ = qConvertA2rgb30ToRgb64<PixelOrder>(*src++); } #endif @@ -1397,7 +1397,7 @@ static inline void qConvertARGB64PMToA2RGB30PM_sse2(uint *dest, const QRgba64 *b } } - for (; i < count; ++i) + SIMD_EPILOGUE(i, count, 15) *dest++ = qConvertRgb64ToRgb30<PixelOrder>(*buffer++); } #endif diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp index 01ffd54918..acc9bc7ba1 100644 --- a/src/gui/painting/qdrawhelper_avx2.cpp +++ b/src/gui/painting/qdrawhelper_avx2.cpp @@ -201,7 +201,7 @@ inline static void BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_AVX2(quint32 *dst, _mm256_store_si256((__m256i *)&dst[x], dstVector); } } - for (; x < length; ++x) + SIMD_EPILOGUE(x, length, 7) blend_pixel(dst[x], src[x], const_alpha); } @@ -267,7 +267,7 @@ 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_testc_si256(srcVector, _mm256_setzero_si256())) { + 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); @@ -275,7 +275,7 @@ void qt_blend_rgb32_on_rgb32_avx2(uchar *destPixels, int dbpl, } // 3) Epilogue - for (; x < w; ++x) + SIMD_EPILOGUE(x, w, 7) dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha); srcPixels += sbpl; @@ -322,7 +322,7 @@ void QT_FASTCALL comp_func_Source_avx2(uint *dst, const uint *src, int length, u } // 3) Epilogue - for (; x < length; ++x) + SIMD_EPILOGUE(x, length, 7) dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha); } } @@ -353,7 +353,7 @@ void QT_FASTCALL comp_func_solid_SourceOver_avx2(uint *destPixels, int length, u dstVector = _mm256_add_epi8(colorVector, dstVector); _mm256_store_si256((__m256i *)&dst[x], dstVector); } - for (; x < length; ++x) + SIMD_EPILOGUE(x, length, 7) destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor); } } diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp index f5b794ace6..d51b43961c 100644 --- a/src/gui/painting/qdrawhelper_neon.cpp +++ b/src/gui/painting/qdrawhelper_neon.cpp @@ -817,7 +817,7 @@ void QT_FASTCALL comp_func_solid_SourceOver_neon(uint *destPixels, int length, u vst1q_u32(&dst[x], colorPlusBlendedPixels); } - for (;x < length; ++x) + SIMD_EPILOGUE(x, length, 3) destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor); } } @@ -869,7 +869,7 @@ void QT_FASTCALL comp_func_Plus_neon(uint *dst, const uint *src, int length, uin vst1q_u32((uint32_t *)&dst[x], vcombine_u32(result32_low, result32_high)); } - for (; x < length; ++x) + SIMD_EPILOGUE(x, length, 3) dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x], const_alpha, one_minus_const_alpha); } } diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index 03abeed440..5ff08e8153 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -126,9 +126,8 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, _mm_store_si128((__m128i *)&dst[x], result); } } - for (; x<w; ++x) { + SIMD_EPILOGUE(x, w, 3) dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha); - } dst = (quint32 *)(((uchar *) dst) + dbpl); src = (const quint32 *)(((const uchar *) src) + sbpl); } @@ -177,7 +176,7 @@ void QT_FASTCALL comp_func_Plus_sse2(uint *dst, const uint *src, int length, uin } // 3) Epilogue: - for (; x < length; ++x) + SIMD_EPILOGUE(x, length, 3) dst[x] = comp_func_Plus_one_pixel(dst[x], src[x]); } else { const int one_minus_const_alpha = 255 - const_alpha; @@ -201,7 +200,7 @@ void QT_FASTCALL comp_func_Plus_sse2(uint *dst, const uint *src, int length, uin } // 3) Epilogue: - for (; x < length; ++x) + SIMD_EPILOGUE(x, length, 3) dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x], const_alpha, one_minus_const_alpha); } } @@ -232,7 +231,7 @@ void QT_FASTCALL comp_func_Source_sse2(uint *dst, const uint *src, int length, u } // 3) Epilogue - for (; x < length; ++x) + SIMD_EPILOGUE(x, length, 3) dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha); } } @@ -313,7 +312,7 @@ void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, u dstVector = _mm_add_epi8(colorVector, dstVector); _mm_store_si128((__m128i *)&dst[x], dstVector); } - for (;x < length; ++x) + SIMD_EPILOGUE(x, length, 3) destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor); } } @@ -592,7 +591,7 @@ void qt_scale_image_argb32_on_argb32_sse2(uchar *destPixels, int dbpl, BLEND_SOURCE_OVER_ARGB32_SSE2_helper(dst, srcVector, nullVector, half, one, colorMask, alphaMask); } - for (; x<w; x++) { + SIMD_EPILOGUE(x, w, 3) { uint s = src[(basex + x*ix) >> 16]; dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); } diff --git a/src/gui/painting/qdrawhelper_ssse3.cpp b/src/gui/painting/qdrawhelper_ssse3.cpp index 2026a4e656..45ecc8b422 100644 --- a/src/gui/painting/qdrawhelper_ssse3.cpp +++ b/src/gui/painting/qdrawhelper_ssse3.cpp @@ -215,7 +215,7 @@ static inline void store_uint24_ssse3(uchar *dst, const uint *src, int len) dst24 = reinterpret_cast<quint24*>(dstVectorPtr); src = reinterpret_cast<const uint*>(inVectorPtr); - for (; i < len; ++i) + SIMD_EPILOGUE(i, len, 15) *dst24++ = quint24(*src++); } diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h index 7affc63b32..93e4b9f572 100644 --- a/src/gui/painting/qdrawingprimitive_sse2_p.h +++ b/src/gui/painting/qdrawingprimitive_sse2_p.h @@ -178,7 +178,7 @@ QT_BEGIN_NAMESPACE const __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[x]); \ BLEND_SOURCE_OVER_ARGB32_SSE2_helper(dst, srcVector, nullVector, half, one, colorMask, alphaMask) \ } \ - for (; x < length; ++x) { \ + SIMD_EPILOGUE(x, length, 3) { \ blend_pixel(dst[x], src[x]); \ } \ } @@ -219,7 +219,7 @@ QT_BEGIN_NAMESPACE _mm_store_si128((__m128i *)&dst[x], result); \ } \ } \ - for (; x < length; ++x) { \ + SIMD_EPILOGUE(x, length, 3) { \ blend_pixel(dst[x], src[x], const_alpha); \ } \ } diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 62941b6cac..d6af6d21a2 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -781,8 +781,14 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, FT_Select_Size(face, i); if (face->size->metrics.ascender + face->size->metrics.descender > 0) { + FT_Pos leading = metrics.height - metrics.ascender + metrics.descender; metrics.ascender = face->size->metrics.ascender; metrics.descender = face->size->metrics.descender; + if (metrics.descender > 0 + && QString::fromUtf8(face->family_name) == QLatin1String("Courier New")) { + metrics.descender *= -1; + } + metrics.height = metrics.ascender - metrics.descender + leading; } FT_Set_Char_Size(face, xsize, ysize, 0, 0); diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index a10071490e..dbc2e6e558 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -622,6 +622,8 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p) if (textWidth >= 0.0) line.setLineWidth(textWidth); + else + line.setLineWidth(QFIXED_MAX); height += leading; line.setPosition(QPointF(0.0, height)); height += line.height(); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 5dbeccff7f..742b01dd1f 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2067,6 +2067,9 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix font = font.resolve(fnt); } engine = font.d->engineForScript(script); + if (engine) + engine->ref.ref(); + QTextCharFormat::VerticalAlignment valign = f.verticalAlignment(); if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) { if (font.pointSize() != -1) @@ -2074,16 +2077,14 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix else font.setPixelSize((font.pixelSize() * 2) / 3); scaledEngine = font.d->engineForScript(script); + if (scaledEngine) + scaledEngine->ref.ref(); } - if (engine) - engine->ref.ref(); if (feCache.prevFontEngine) releaseCachedFontEngine(feCache.prevFontEngine); feCache.prevFontEngine = engine; - if (scaledEngine) - scaledEngine->ref.ref(); if (feCache.prevScaledFontEngine) releaseCachedFontEngine(feCache.prevScaledFontEngine); feCache.prevScaledFontEngine = scaledEngine; |