From 8ddf76989c80896d4cd1e759bbd2594609eebf6d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 24 Apr 2014 17:13:40 +0200 Subject: Remove old symbols from QOpenGLContext Task-number: QTBUG-38564 Change-Id: I39a0482e4411cdc644ed34813626c39dacb5b6af Reviewed-by: Sean Harmer --- src/gui/kernel/qopenglcontext.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h index c422d008c1..19aecee75a 100644 --- a/src/gui/kernel/qopenglcontext.h +++ b/src/gui/kernel/qopenglcontext.h @@ -196,19 +196,13 @@ public: enum OpenGLModuleType { LibGL, - LibGLES, - - // ### - DesktopGL = LibGL, - GLES2 = LibGLES + LibGLES }; static OpenGLModuleType openGLModuleType(); bool isOpenGLES() const; - bool isES() const { return isOpenGLES(); } // ### - Q_SIGNALS: void aboutToBeDestroyed(); -- cgit v1.2.3 From 1d372eddbe9e4eb75a0fcde4bdcdebcf75222075 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 18 Apr 2014 16:10:00 +0300 Subject: Fix identical sub-expressions in comparison Found by static analyzer (see http://www.viva64.com/en/b/0251/). Change-Id: I611def790a98abf7574e96e6039f10714316d81e Reviewed-by: Friedemann Kleint Reviewed-by: Jason McDonald --- src/testlib/qtest_gui.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h index a9ac7777c3..7c68b0fd77 100644 --- a/src/testlib/qtest_gui.h +++ b/src/testlib/qtest_gui.h @@ -98,7 +98,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2, } if (t1Null && t2Null) return compare_helper(true, 0, 0, 0, actual, expected, file, line); - if (t1.width() != t2.width() || t2.height() != t2.height()) { + if (t1.width() != t2.width() || t1.height() != t2.height()) { qsnprintf(msg, 1024, "Compared QImages differ in size.\n" " Actual (%s): %dx%d\n" " Expected (%s): %dx%d", @@ -132,7 +132,7 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c } if (t1Null && t2Null) return compare_helper(true, 0, 0, 0, actual, expected, file, line); - if (t1.width() != t2.width() || t2.height() != t2.height()) { + if (t1.width() != t2.width() || t1.height() != t2.height()) { qsnprintf(msg, 1024, "Compared QPixmaps differ in size.\n" " Actual (%s): %dx%d\n" " Expected (%s): %dx%d", -- cgit v1.2.3 From 373d858812a84b48be482dd64ad9d248ab2d5b3c Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Fri, 25 Apr 2014 17:55:04 +0200 Subject: [QtSql][QSqlTableModel] fix failure to refresh in selectRow() Caused by missing braces, leaving the break outside the scope of the if clause. Task-number: QTBUG-38509 Change-Id: I6b0a7f34512a3a9b0fbd790116f81f54f4a91cf0 Reviewed-by: Tobias Koenig Reviewed-by: Mark Brand Reviewed-by: Andy Shaw --- src/sql/models/qsqltablemodel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 5c73705d4c..0eed6ea4d3 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -448,9 +448,10 @@ bool QSqlTableModel::selectRow(int row) // Look for changed values. Primary key fields are customarily first // and probably change less often than other fields, so start at the end. for (int f = curValues.count() - 1; f >= 0; --f) { - if (curValues.value(f) != newValues.value(f)) + if (curValues.value(f) != newValues.value(f)) { needsAddingToCache = true; break; + } } } } -- cgit v1.2.3 From 143eab87111f4ac0dd659b0a0cc217274603a2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 25 Apr 2014 16:21:55 +0200 Subject: iOS: Send application state changes synchronously The user might have a limited time to react when the application is suspended, so we need to send the event as soon as possible. Change-Id: Ib6c342f5426cf15e36ba4ef57edf30878f86d1c9 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosapplicationstate.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosapplicationstate.mm b/src/plugins/platforms/ios/qiosapplicationstate.mm index 8d77e608e5..afa3ecb21f 100644 --- a/src/plugins/platforms/ios/qiosapplicationstate.mm +++ b/src/plugins/platforms/ios/qiosapplicationstate.mm @@ -150,6 +150,7 @@ break; } QWindowSystemInterface::handleApplicationStateChanged(state); + QWindowSystemInterface::flushWindowSystemEvents(); } @end -- cgit v1.2.3 From 2222fdf3304e921b7441932827da72a46418b649 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 28 Apr 2014 13:04:56 +0200 Subject: Doc: Remove Qt Core documentation dependency to Qt QML When generating documentation, the Qt namespace declared in Qt Core collides with the Qt global object declared in Qt QML. This caused the C++ Qt namespace documentation to go missing. This change works around the issue by removing the dependency between Qt Core and Qt QML. Task-number: QTBUG-38630 Change-Id: Ifd250a19c476bc30e2a2ed561573c8b6b3b2dba5 Reviewed-by: Martin Smith --- src/corelib/doc/qtcore.qdocconf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index c8eb15a7f7..c9c8f1da54 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -26,7 +26,8 @@ qhp.QtCore.subprojects.classes.sortPages = true tagfile = ../../../doc/qtcore/qtcore.tags -depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtqml qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake +depends += activeqt qtdbus qtgui qtwidgets qtnetwork qtdoc qtmacextras qtquick qtlinguist qtdesigner qtconcurrent qtxml qmake +# depends += qtqml # Qt namespace collides with QtQml::Qt, see QTBUG-38630 headerdirs += .. -- cgit v1.2.3 From 485b7424df5cb3474cc802bced77770d85bdcb37 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 28 Apr 2014 12:19:28 +0200 Subject: Avoid reentering processMouseEvents on embedded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-38597 Change-Id: I168c9401863bace711d0d8409bf3da30a34185bd Reviewed-by: Friedemann Kleint Reviewed-by: Jørgen Lind --- .../eglconvenience/qeglplatformcursor.cpp | 27 +++++++++++++++++++--- .../eglconvenience/qeglplatformcursor_p.h | 19 +++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp index 70e7c4e4db..e99581183e 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp @@ -69,7 +69,8 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen) m_vertexCoordEntry(0), m_textureCoordEntry(0), m_textureEntry(0), - m_deviceListener(0) + m_deviceListener(0), + m_updater(screen) { QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR"); if (!hideCursorVal.isEmpty()) @@ -270,12 +271,32 @@ bool QEGLPlatformCursor::setCurrentCursor(QCursor *cursor) } #endif -void QEGLPlatformCursor::update(const QRegion &rgn) +void QEGLPlatformCursorUpdater::update(const QPoint &pos, const QRegion &rgn) { - QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(m_cursor.pos), rgn); + m_active = false; + QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(pos), rgn); QWindowSystemInterface::flushWindowSystemEvents(); } +void QEGLPlatformCursorUpdater::scheduleUpdate(const QPoint &pos, const QRegion &rgn) +{ + if (m_active) + return; + + m_active = true; + + // Must not flush the window system events directly from here since we are likely to + // be a called directly from QGuiApplication's processMouseEvents. Flushing events + // could cause reentering by dispatching more queued mouse events. + QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection, + Q_ARG(QPoint, pos), Q_ARG(QRegion, rgn)); +} + +void QEGLPlatformCursor::update(const QRegion &rgn) +{ + m_updater.scheduleUpdate(m_cursor.pos, rgn); +} + QRect QEGLPlatformCursor::cursorRect() const { return QRect(m_cursor.pos - m_cursor.hotSpot, m_cursor.size); diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h index c9ff9a1198..6f4216874a 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h @@ -68,6 +68,24 @@ private: int m_mouseCount; }; +class QEGLPlatformCursorUpdater : public QObject +{ + Q_OBJECT + +public: + QEGLPlatformCursorUpdater(QPlatformScreen *screen) + : m_screen(screen), m_active(false) { } + + void scheduleUpdate(const QPoint &pos, const QRegion &rgn); + +private slots: + void update(const QPoint &pos, const QRegion &rgn); + +private: + QPlatformScreen *m_screen; + bool m_active; +}; + class QEGLPlatformCursor : public QPlatformCursor { public: @@ -130,6 +148,7 @@ private: int m_textureCoordEntry; int m_textureEntry; QEGLPlatformCursorDeviceListener *m_deviceListener; + QEGLPlatformCursorUpdater m_updater; }; QT_END_NAMESPACE -- cgit v1.2.3 From 9ab41425519510b5bfbe93ac916e3f40aa0e4510 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 25 Apr 2014 14:11:49 +0200 Subject: centralize auxiliary lib creation this covers convenience libraries which are linked into dlls (if we are not building statically) and "proper" (installed) builds of 3rdparty code. Change-Id: I2f00248c0baa0e73346e477724bf49bbc62ba925 Reviewed-by: Konstantin Ritt Reviewed-by: Laszlo Agocs Reviewed-by: Friedemann Kleint Reviewed-by: Joerg Bornemann --- src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro | 9 +-------- src/angle/src/common/common.pri | 1 + src/angle/src/compiler/preprocessor/preprocessor.pro | 3 --- src/angle/src/compiler/translator.pro | 3 --- src/angle/src/config.pri | 9 ++------- src/angle/src/d3dcompiler/d3dcompiler.pro | 9 +++------ src/angle/src/libEGL/libEGL.pro | 6 +----- src/angle/src/libGLESv2/libGLESv2.pro | 11 ++--------- src/plugins/platforms/xcb/xcb-static/xcb-static.pro | 5 ++--- 9 files changed, 12 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro index d505c30aa6..bd0475fc05 100644 --- a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro +++ b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro @@ -1,16 +1,11 @@ TARGET = qtharfbuzzng -TEMPLATE = lib CONFIG += \ static \ hide_symbols \ exceptions_off rtti_off -CONFIG -= qt -contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release -contains(QT_CONFIG, build_all):CONFIG += build_all - -DESTDIR = $$QT_BUILD_TREE/lib +load(qt_helper_lib) DEFINES += HAVE_CONFIG_H HEADERS += $$PWD/src/config.h @@ -133,5 +128,3 @@ mac { # even in 10.8 where they were also made available stand-alone. LIBS_PRIVATE += -framework ApplicationServices } - -TARGET = $$TARGET$$qtPlatformTargetSuffix() diff --git a/src/angle/src/common/common.pri b/src/angle/src/common/common.pri index 58ad88673a..0943b3f299 100644 --- a/src/angle/src/common/common.pri +++ b/src/angle/src/common/common.pri @@ -1,3 +1,4 @@ +CONFIG += installed include (../config.pri) INCLUDEPATH += \ diff --git a/src/angle/src/compiler/preprocessor/preprocessor.pro b/src/angle/src/compiler/preprocessor/preprocessor.pro index 74cd97c5a4..420cb90b36 100644 --- a/src/angle/src/compiler/preprocessor/preprocessor.pro +++ b/src/angle/src/compiler/preprocessor/preprocessor.pro @@ -1,7 +1,4 @@ -TEMPLATE = lib CONFIG += static -TARGET = $$qtLibraryTarget(preprocessor) - include(../../config.pri) INCLUDEPATH = $$ANGLE_DIR/src/compiler/preprocessor diff --git a/src/angle/src/compiler/translator.pro b/src/angle/src/compiler/translator.pro index 0051486f82..18c3978e0f 100644 --- a/src/angle/src/compiler/translator.pro +++ b/src/angle/src/compiler/translator.pro @@ -1,7 +1,4 @@ -TEMPLATE = lib CONFIG += static -TARGET = $$qtLibraryTarget(translator) - include(../config.pri) # Mingw 4.7 chokes on implicit move semantics, so disable C++11 here diff --git a/src/angle/src/config.pri b/src/angle/src/config.pri index 8e0f6b7f42..aa777c356f 100644 --- a/src/angle/src/config.pri +++ b/src/angle/src/config.pri @@ -59,17 +59,10 @@ CONFIG(debug, debug|release) { } # c++11 is needed by MinGW to get support for unordered_map. -CONFIG -= qt CONFIG += stl exceptions c++11 -contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release -contains(QT_CONFIG, build_all):CONFIG += build_all - INCLUDEPATH += . .. $$PWD/../include -DESTDIR = $$QT_BUILD_TREE/lib -DLLDESTDIR = $$QT_BUILD_TREE/bin - msvc { # Disabled Warnings: # 4100: 'identifier' : unreferenced formal parameter @@ -107,3 +100,5 @@ gcc { QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE + +load(qt_helper_lib) diff --git a/src/angle/src/d3dcompiler/d3dcompiler.pro b/src/angle/src/d3dcompiler/d3dcompiler.pro index 4d22080185..04b1de895d 100644 --- a/src/angle/src/d3dcompiler/d3dcompiler.pro +++ b/src/angle/src/d3dcompiler/d3dcompiler.pro @@ -1,9 +1,8 @@ -TEMPLATE = lib -TARGET = $$qtLibraryTarget(d3dcompiler_qt) - +TARGET = d3dcompiler_qt +CONFIG += installed include(../config.pri) -CONFIG += qt +CONFIG += qt QT = core DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII SOURCES += main.cpp @@ -16,5 +15,3 @@ winrt:equals(WINSDK_VER, 8.1) { # __stdcall exports get mangled, so use a def file DEF_FILE += $${TARGET}.def - -load(qt_installs) diff --git a/src/angle/src/libEGL/libEGL.pro b/src/angle/src/libEGL/libEGL.pro index 4f10583fc0..dc286ca11d 100644 --- a/src/angle/src/libEGL/libEGL.pro +++ b/src/angle/src/libEGL/libEGL.pro @@ -1,6 +1,4 @@ -TEMPLATE = lib -TARGET = $$qtLibraryTarget(libEGL) - +CONFIG += installed include(../common/common.pri) angle_d3d11: \ @@ -30,8 +28,6 @@ SOURCES += \ mingw:equals(QT_ARCH, i386): DEF_FILE = $$ANGLE_DIR/src/libEGL/$${TARGET}_mingw32.def } -load(qt_installs) - egl_headers.files = \ $$ANGLE_DIR/include/EGL/egl.h \ $$ANGLE_DIR/include/EGL/eglext.h \ diff --git a/src/angle/src/libGLESv2/libGLESv2.pro b/src/angle/src/libGLESv2/libGLESv2.pro index 6176016f13..70c58dc5a4 100644 --- a/src/angle/src/libGLESv2/libGLESv2.pro +++ b/src/angle/src/libGLESv2/libGLESv2.pro @@ -1,7 +1,4 @@ -TEMPLATE = lib -TARGET = $$qtLibraryTarget(libGLESv2) -CONFIG += simd - +CONFIG += simd installed include(../common/common.pri) INCLUDEPATH += $$OUT_PWD/.. $$ANGLE_DIR/src/libGLESv2 @@ -13,8 +10,8 @@ angle_d3d11: \ LIBS_PRIVATE += -ld3d9 LIBS_PRIVATE += -ldxguid -STATICLIBS = translator preprocessor +STATICLIBS = translator preprocessor for(libname, STATICLIBS) { # Appends 'd' to the library for debug builds and builds up the fully # qualified path to pass to the linker. @@ -238,8 +235,6 @@ for (vs, VERTEX_SHADERS_CLEAR) { angle_d3d11: QMAKE_EXTRA_COMPILERS += fxc_vs_$${vs} } -load(qt_installs) - khr_headers.files = $$ANGLE_DIR/include/KHR/khrplatform.h khr_headers.path = $$[QT_INSTALL_HEADERS]/QtANGLE/KHR gles2_headers.files = \ @@ -248,5 +243,3 @@ gles2_headers.files = \ $$ANGLE_DIR/include/GLES2/gl2platform.h gles2_headers.path = $$[QT_INSTALL_HEADERS]/QtANGLE/GLES2 INSTALLS += khr_headers gles2_headers - - diff --git a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro index 19852b74b1..dfdcb2e83a 100644 --- a/src/plugins/platforms/xcb/xcb-static/xcb-static.pro +++ b/src/plugins/platforms/xcb/xcb-static/xcb-static.pro @@ -3,9 +3,8 @@ # libxcb-fixes, libxcb-randr, libxcb-shm, libxcb-sync, libxcb-image, # libxcb-keysyms, libxcb-icccm, libxcb-renderutil, libxcb-xkb # -TEMPLATE = lib -TARGET = xcb-static -CONFIG += staticlib +CONFIG += static +load(qt_helper_lib) XCB_DIR = ../../../../3rdparty/xcb -- cgit v1.2.3 From 40b195d0f9ee7ef1b917a635bb073fa108b2ed40 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 25 Apr 2014 13:12:20 +0200 Subject: Fix font fallback handling with Harfbuzz and CoreText Comparing CGFontRefs is not reliable it seems, CFEqual on them appears to compare pointers and there's no guarantee that CTFontCopyGraphicsFont returns the same pointer all the time. So instead let's compare CTFontRefs, which we keep around and also provide as input to CoreText shaping. Task-number: 38363 Change-Id: I6073ea88f0c9f5ebf49d17cba0d76041ade32570 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Konstantin Ritt --- src/3rdparty/harfbuzz-ng/src/hb-coretext.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc index 4a905ee189..4fef861acc 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc +++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc @@ -690,13 +690,10 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, */ CFDictionaryRef attributes = CTRunGetAttributes (run); CTFontRef run_ct_font = static_cast(CFDictionaryGetValue (attributes, kCTFontAttributeName)); - CGFontRef run_cg_font = CTFontCopyGraphicsFont (run_ct_font, 0); CFRange range = CTRunGetStringRange (run); - if (!CFEqual (run_cg_font, face_data->cg_font)) + if (!CFEqual (run_ct_font, font_data->ct_font)) { - CFRelease (run_cg_font); - buffer->ensure (buffer->len + range.length); if (buffer->in_error) FAIL ("Buffer resize failed"); @@ -731,7 +728,6 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan, } continue; } - CFRelease (run_cg_font); /* CoreText throws away the PDF token, while the OpenType backend will add a zero-advance * glyph for this. We need to make sure the two produce the same output. */ -- cgit v1.2.3 From 55e430a3b3f4f225da6b7192773f082b5411741b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Proulx Date: Mon, 28 Apr 2014 11:11:11 -0400 Subject: Fix double release in QTimeZone on Mac m_nstz is released in the destructor but not retained when using the QTimeZone(QByteArray) constructor. Task-number: QTBUG-35890 Task-number: QTBUG-37582 Change-Id: Ia569830bcd3c2f2cea04ad6696e681c4f2a3c137 Reviewed-by: Shawn Rutledge Reviewed-by: Jake Petroules Reviewed-by: Gabriel de Dietrich --- src/corelib/tools/qtimezoneprivate_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index 49930490ff..3484ec79ef 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -89,7 +89,7 @@ QTimeZonePrivate *QMacTimeZonePrivate::clone() void QMacTimeZonePrivate::init(const QByteArray &ianaId) { if (availableTimeZoneIds().contains(ianaId)) { - m_nstz = [NSTimeZone timeZoneWithName:QCFString::toNSString(QString::fromUtf8(ianaId))]; + m_nstz = [[NSTimeZone timeZoneWithName:QCFString::toNSString(QString::fromUtf8(ianaId))] retain]; if (m_nstz) m_id = ianaId; } -- cgit v1.2.3 From b619c35d8507eee3ad9b456128f811b561513727 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 28 Apr 2014 11:45:44 +0200 Subject: Revert "Mac: fix bugs for font selection in QFontDialog" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3c09f6bc9aee0c97427fe8da6efdc73b4ac473aa. After fbaa6d3ca6fc2693c5c8a1cd8e565803adc97730, OS X/iOS no longer uses localized font names. Task-number: QTBUG-38548 Conflicts: src/gui/text/qfontdatabase.cpp Change-Id: Id7f7e1976e4ffc30c5c18cf57e2acb3aebafc301 Reviewed-by: Tor Arne Vestbø Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index dc22da0983..a18f721e04 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -92,16 +92,20 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) QFont newFont; if (cocoaFont) { int pSize = qRound([cocoaFont pointSize]); - CTFontDescriptorRef font = CTFontCopyFontDescriptor((CTFontRef)cocoaFont); - // QCoreTextFontDatabase::populateFontDatabase() is using localized names - QString family = QCFString::toQString((CFStringRef) CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL)); - QString style = QCFString::toQString((CFStringRef) CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL)); + QString family(QCFString::toQString([cocoaFont familyName])); + QString typeface(QCFString::toQString([cocoaFont fontName])); + + int hyphenPos = typeface.indexOf(QLatin1Char('-')); + if (hyphenPos != -1) { + typeface.remove(0, hyphenPos + 1); + } else { + typeface = QLatin1String("Normal"); + } - newFont = QFontDatabase().font(family, style, pSize); + newFont = QFontDatabase().font(family, typeface, pSize); newFont.setUnderline(resolveFont.underline()); newFont.setStrikeOut(resolveFont.strikeOut()); - CFRelease(font); } return newFont; } -- cgit v1.2.3 From a3634e4b2b39fb7895a3c5795498d1a176e528b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 24 Apr 2014 15:33:20 +0200 Subject: iOS: Send updated expose events on application background/foregrounding When an application has background processing enabled, for example for communicating with an external accessory or getting location updates, it might trigger code that does UI updates, which will kill the app as doing UI in the background is not allowed on iOS. We guard against this by propagating the backgrounding as updated expose events with a non-exposed region and isExposed() returning false. This means clients who correctly use QWindow::isExposed() to guard their drawing code (including the scene-graph), will live to see another day. Task-number: QTBUG-36956 Change-Id: Ib708394d33093affe68c9f2c7abde7e54be5ec74 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qioswindow.h | 1 + src/plugins/platforms/ios/qioswindow.mm | 32 +++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index fc99543aa6..6b6892e6e4 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -88,6 +88,7 @@ public: WId winId() const { return WId(m_view); }; private: + void applicationStateChanged(Qt::ApplicationState state); void applyGeometry(const QRect &rect); QUIView *m_view; diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 7d5c507972..ebff2c25a1 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -192,12 +192,25 @@ - (void)displayLayer:(CALayer *)layer { - QSize bounds = fromCGRect(layer.bounds).toRect().size(); + Q_UNUSED(layer); + Q_ASSERT(layer == self.layer); - Q_ASSERT(m_qioswindow->geometry().size() == bounds); - Q_ASSERT(self.hidden == !m_qioswindow->window()->isVisible()); + [self sendUpdatedExposeEvent]; +} + +- (void)sendUpdatedExposeEvent +{ + QRegion region; + + if (m_qioswindow->isExposed()) { + QSize bounds = fromCGRect(self.layer.bounds).toRect().size(); + + Q_ASSERT(m_qioswindow->geometry().size() == bounds); + Q_ASSERT(self.hidden == !m_qioswindow->window()->isVisible()); + + region = QRect(QPoint(), bounds); + } - QRegion region = self.hidden ? QRegion() : QRect(QPoint(), bounds); QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), region); QWindowSystemInterface::flushWindowSystemEvents(); } @@ -334,6 +347,8 @@ QIOSWindow::QIOSWindow(QWindow *window) , m_view([[QUIView alloc] initWithQIOSWindow:this]) , m_windowLevel(0) { + connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QIOSWindow::applicationStateChanged); + setParent(QPlatformWindow::parent()); // Resolve default window geometry in case it was not set before creating the @@ -471,7 +486,8 @@ void QIOSWindow::applyGeometry(const QRect &rect) bool QIOSWindow::isExposed() const { - return window()->isVisible() && !window()->geometry().isEmpty(); + return qApp->applicationState() > Qt::ApplicationHidden + && window()->isVisible() && !window()->geometry().isEmpty(); } void QIOSWindow::setWindowState(Qt::WindowState state) @@ -593,6 +609,12 @@ void QIOSWindow::handleContentOrientationChange(Qt::ScreenOrientation orientatio [[UIApplication sharedApplication] setStatusBarOrientation:uiOrientation animated:NO]; } +void QIOSWindow::applicationStateChanged(Qt::ApplicationState) +{ + if (window()->isExposed() != isExposed()) + [m_view sendUpdatedExposeEvent]; +} + qreal QIOSWindow::devicePixelRatio() const { return m_view.contentScaleFactor; -- cgit v1.2.3 From 27ea8fa99f84d96618d75a8245364457585bc5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 23 Apr 2014 14:55:38 +0200 Subject: QCocoaPrintDevice: Compile on Mac OS 10.6 MAXPATHLEN is not defined, use PATH_MAX. Change-Id: I5a8febce66584c15bdfe81df64fe3f1954972a47 Reviewed-by: Andy Shaw --- src/plugins/platforms/cocoa/qcocoaprintdevice.mm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm index 57d5c800e0..7322025df6 100644 --- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm +++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm @@ -463,7 +463,11 @@ bool QCocoaPrintDevice::openPpdFile() ppdClose(m_ppd); m_ppd = 0; CFURLRef ppdURL = NULL; +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 + char ppdPath[PATH_MAX]; +#else char ppdPath[MAXPATHLEN]; +#endif if (PMPrinterCopyDescriptionURL(m_printer, kPMPPDDescriptionType, &ppdURL) == noErr && ppdURL != NULL && CFURLGetFileSystemRepresentation(ppdURL, true, (UInt8*)ppdPath, sizeof(ppdPath))) { -- cgit v1.2.3 From ee85cdee67d164315e52a05462b03fe7091cc26d Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 23 Apr 2014 10:32:07 +0200 Subject: Logging: Mention 'best practices' for using QLoggingCategory QLoggingCategory objects are meant to be mere 'handles' for the registry. It's therefore not recommended to - manipulate them directly (via setEnabled()), except in a filter - export them across module boundaries - subclass them Subclassing QLoggingCategory also breaks compilations in a certain circumstances (no variadic macros). Task-number: QTBUG-37283 Change-Id: Ib12fb43d955902c7fa4583296d64afc5eca01200 Reviewed-by: Thiago Macieira --- src/corelib/io/qloggingcategory.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 08ecd67dc8..518052e537 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -62,6 +62,12 @@ Q_GLOBAL_STATIC_WITH_ARGS(QLoggingCategory, qtDefaultCategory, by a string - at runtime. Whether a category should be actually logged or not can be checked with the \l isEnabled() methods. + All objects are meant to be configured by a common registry (see also + \l{Configuring Categories}). Different objects can also represent the same + category. It's therefore not recommended to export objects across module + boundaries, nor to manipulate the objects directly, nor to inherit from + QLoggingCategory. + \section1 Creating category objects The Q_LOGGING_CATEGORY() and the Q_DECLARE_LOGGING_CATEGORY() macros -- cgit v1.2.3 From 88756dc46f019dd7d12c7b687233f707661b1ecc Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 29 Apr 2014 14:13:28 +0200 Subject: printsupport: only build cocoa backend for OS X Cocoa is not available on iOS, so the plugin should not be built. But recent build system changes exposed that we did. Change-Id: I000d54b330a075abb8f4a8b28a970bb5b5edfeb5 Reviewed-by: Oswald Buddenhagen --- src/plugins/printsupport/printsupport.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/printsupport/printsupport.pro b/src/plugins/printsupport/printsupport.pro index 93f3d65bc5..ed201f0744 100644 --- a/src/plugins/printsupport/printsupport.pro +++ b/src/plugins/printsupport/printsupport.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -mac: SUBDIRS += cocoa +osx: SUBDIRS += cocoa win32: SUBDIRS += windows unix:!mac:contains(QT_CONFIG, cups): SUBDIRS += cups -- cgit v1.2.3 From 12eb3b51c4c8c7ce90302d2c356fea09f2c42a5c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 29 Apr 2014 13:39:23 +0200 Subject: Fix incorrect repaints with plain text edit The plain text edit's smart repaint logic in QPlainTextDocumentLayout::documentChanged assumes that during a change inside just one block, the block is in the state before the edit and a call to layoutBlock() is going to bring it up-to-date. Then only a comparison of the bounding rect - before and after - is going to allow for smart repaints. The assumption of the layout being in the same state as before the edit got broken by commit cc57a2e90f18a39ce3c74b6ad0db9a64aa135ddf, which introduced code to use a QTextCursor within a slot connected to QTextDocument's contentsChange signal. The usage of the QTextCursor there ends up updating the layout of the block ahead of time, breaking the assumption and therefore the optimization, in the sense that during changes in the preedit that cause a change of height / line count, the old bounding rect in QPlainTextDocumentLayout::documentChanged and the new bounding rect will be the same. This causes a repaint of only the edited block, missing repaints of the following blocks, even though the line count effectively changed. So what's causing QTextCursor to mess with the layout is the attempt of updating the vertical movement x property. This patch inhibits the update, marking it as dirty for initialization later. This means that slots connected to this low-level signal cannot rely on the cursor's visual x position, but that doesn't seem useful anyway and isn't required for commit cc57a2e90f18a39ce3c74b6ad0db9a64aa135ddf. Task-number: QTBUG-38536 Change-Id: I5fae12d646a4b2d2cc22b9f2d021e5dc8cfdda94 Reviewed-by: Paul Olav Tvete Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Konstantin Ritt --- src/gui/text/qtextcursor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index ac9762b183..731b6adde8 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -132,7 +132,7 @@ QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int position void QTextCursorPrivate::setX() { - if (priv->isInEditBlock()) { + if (priv->isInEditBlock() || priv->inContentsChange) { x = -1; // mark dirty return; } -- cgit v1.2.3 From 7eae50a52d63b7f0434fdb75fc09b0901a0140cc Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 29 Apr 2014 09:06:08 +0200 Subject: Fix assert on justification of QTextLine with only spaces In the justification code, we unconditionally subtracted one from the line_length, but then compared the result to 0 afterwards, so we did not support when the line_length is 0 initially, which can happen if it only consists of spaces (in which case trailingSpaces will be non-zero and line_length will be zero.) The fix is to bail out for both strings of length 1 and length 0. [ChangeLog][Text] Fixed an assert when justifying a QTextLine which only contains spaces. Task-number: QTBUG-38520 Change-Id: Ib04993f47eb2f9f7fc49c4a5400f18f9682a72f2 Reviewed-by: Simon Hausmann Reviewed-by: Konstantin Ritt Reviewed-by: Lars Knoll --- src/gui/text/qtextengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 34788dc4dc..67dedca760 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2057,7 +2057,7 @@ void QTextEngine::justify(const QScriptLine &line) // subtract one char more, as we can't justfy after the last character --line_length; - if (!line_length) + if (line_length <= 0) return; int firstItem = findItem(line.from); -- cgit v1.2.3 From 8605f44097a986e10c2ddaf4b4eae0b2331d98d1 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 30 Apr 2014 16:46:22 +0200 Subject: Cocoa QPA Menu: Clear menu items' Cocoa ancestor on destruction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Valid for both the item and the menu destructions. Task-number: QTBUG-38685 Change-Id: I024b93c8bb8facefeaad5e8b6c7be6bf049898ea Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenu.mm | 4 ++++ src/plugins/platforms/cocoa/qcocoamenuitem.mm | 2 ++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 6acc062eb9..9b5753035a 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -234,6 +234,10 @@ QCocoaMenu::QCocoaMenu() : QCocoaMenu::~QCocoaMenu() { + foreach (QCocoaMenuItem *item, m_menuItems) { + if (COCOA_MENU_ANCESTOR(item) == this) + SET_COCOA_MENU_ANCESTOR(item, 0); + } QCocoaAutoReleasePool pool; [m_nativeItem setSubmenu:nil]; [m_nativeMenu release]; diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 58fe07bc62..da5475496a 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -105,6 +105,8 @@ QCocoaMenuItem::QCocoaMenuItem() : QCocoaMenuItem::~QCocoaMenuItem() { + if (m_menu && COCOA_MENU_ANCESTOR(m_menu) == this) + SET_COCOA_MENU_ANCESTOR(m_menu, 0); if (m_merged) { [m_native setHidden:YES]; } else { -- cgit v1.2.3 From d17e48108df864c446892c0a4318b41b30685de6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Proulx Date: Wed, 30 Apr 2014 13:01:36 -0400 Subject: Fix more double release in QTimeZone on Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Several objects are released without being retained. This causes double free crash. Task-number: QTBUG-37582 Task-number: QTBUG-35890 Change-Id: Ic64419c22ab555ba77ada1864feaff247798d3ad Reviewed-by: Jake Petroules Reviewed-by: Morten Johan Sørvig --- src/corelib/tools/qtimezoneprivate_mac.mm | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index 3484ec79ef..7985b78712 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -142,7 +142,6 @@ QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType, NSString *macLocaleCode = QCFString::toNSString(locale.name()); NSLocale *macLocale = [[NSLocale alloc] initWithLocaleIdentifier:macLocaleCode]; const QString result = QCFString::toQString([m_nstz localizedName:style locale:macLocale]); - [macLocaleCode release]; [macLocale release]; return result; } @@ -192,7 +191,6 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons data.daylightTimeOffset = [m_nstz daylightSavingTimeOffsetForDate:date]; data.standardTimeOffset = data.offsetFromUtc - data.daylightTimeOffset; data.abbreviation = QCFString::toQString([m_nstz abbreviationForDate:date]); - [date release]; return data; } @@ -203,8 +201,6 @@ bool QMacTimeZonePrivate::hasTransitions() const NSDate *epoch = [NSDate dateWithTimeIntervalSince1970:0]; const NSDate *date = [m_nstz nextDaylightSavingTimeTransitionAfterDate:epoch]; const bool result = ([date timeIntervalSince1970] > [epoch timeIntervalSince1970]); - [epoch release]; - [date release]; return result; } @@ -224,7 +220,6 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::nextTransition(qint64 afterMSecsSinc tran.daylightTimeOffset = [m_nstz daylightSavingTimeOffsetForDate:nextDate]; tran.standardTimeOffset = tran.offsetFromUtc - tran.daylightTimeOffset; tran.abbreviation = QCFString::toQString([m_nstz abbreviationForDate:nextDate]); - [nextDate release]; return tran; } @@ -246,7 +241,6 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate]; nextSecs = [nextDate timeIntervalSince1970]; } - [nextDate release]; } if (secsList.size() >= 1) return data(qint64(secsList.last()) * 1000); -- cgit v1.2.3 From 3db5e58dd39fd14a2b9cf16f5396d1ffa1c9280e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 1 May 2014 14:01:41 -0700 Subject: Revision new signal As it's meant for QML anyways, this allows it to coexist peacefully with existing code. Task-number: QTBUG-29806 Change-Id: Ib04993f47eb2f9f7fc49c4a5400f18f9682a7aaa Reviewed-by: Simon Hausmann --- src/gui/kernel/qwindow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 3278b7233c..0d13cfa648 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -297,7 +297,7 @@ Q_SIGNALS: void screenChanged(QScreen *screen); void modalityChanged(Qt::WindowModality modality); void windowStateChanged(Qt::WindowState windowState); - void windowTitleChanged(const QString &title); + Q_REVISION(2) void windowTitleChanged(const QString &title); void xChanged(int arg); void yChanged(int arg); -- cgit v1.2.3 From 9ae89313e43689483282ac330ad189db89bfcbba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Wed, 23 Apr 2014 19:10:35 +0000 Subject: Add a comment about not obvious code in VariantData. Change-Id: I943af28c47b396aa35173da2a1294b86c8a522fa Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 80567d6a71..3b35a51e2c 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -777,6 +777,7 @@ struct VariantData const void *data; const uint flags; private: + // copy constructor allowed to be implicit to silence level 4 warning from MSVC VariantData &operator=(const VariantData &) Q_DECL_EQ_DELETE; }; -- cgit v1.2.3 From 926d7f46f5acee39e96aed2c27da50a96f0e2c5f Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sat, 26 Apr 2014 14:34:25 +0400 Subject: Fixed wrong condition in QMacStyle. Change-Id: I003e59bd50754dbbda23de5c55096ca2d25b7a7a Reviewed-by: Jake Petroules Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 42262e66a9..174e1dabfa 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5319,7 +5319,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex if (const QStyleOptionComboBox *combo = qstyleoption_cast(opt)){ HIThemeButtonDrawInfo bdi; d->initComboboxBdi(combo, &bdi, widget, d->getDrawState(opt->state)); - if (!tds == kThemeStateInactive) + if (tds != kThemeStateInactive) QMacStylePrivate::drawCombobox(qt_hirectForQRect(combo->rect), bdi, p); else d->drawColorlessButton(qt_hirectForQRect(combo->rect), &bdi, p, opt); -- cgit v1.2.3 From 8e48707cea01f5c456cd554d2628d2b4f59ca1fc Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Fri, 2 May 2014 14:26:42 +0300 Subject: Add winrt and winphone to the list of platform file selector names Change-Id: Ifdab4184f048572c6f0e0496f6d6be2c5f92d1cc Reviewed-by: Oswald Buddenhagen Reviewed-by: Alan Alpert --- src/corelib/io/qfileselector.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp index b4021c060f..0fa1f02f5c 100644 --- a/src/corelib/io/qfileselector.cpp +++ b/src/corelib/io/qfileselector.cpp @@ -365,6 +365,11 @@ QStringList QFileSelectorPrivate::platformSelectors() ret << QStringLiteral("windows"); # if defined(Q_OS_WINCE) ret << QStringLiteral("wince"); +# elif defined(Q_OS_WINRT) + ret << QStringLiteral("winrt"); +# if defined(Q_OS_WINPHONE) + ret << QStringLiteral("winphone"); +# endif # endif #elif defined(Q_OS_UNIX) ret << QStringLiteral("unix"); -- cgit v1.2.3 From a5bba1f9da376840d92f2008d8ba8433753b1847 Mon Sep 17 00:00:00 2001 From: Lucile Quirion Date: Thu, 1 May 2014 13:50:15 -0400 Subject: [blitter] Initialize m_devicePixelRatio to fix crash When using directfb platform the drawing of some widgets (e.g. Toolbar) would crash the application. Pixmap device pixel ratio can be used in QCommonStyle::drawControl() as a denominator to calculate pixmap width or size. The drawing of some widgets (e.g. Toolbar) would fail the assertion of a non-zero denominator. This commit initializes the device pixel ratio when generating BlitterClass pixmaps and makes QBlittablePlatformPixmap::metric( PdmDevicePixelRatio) return devicePixelRatio() instead of 1. Task-number: QTBUG-38709 Change-Id: Ia8b96c5341b5ac1297c483deed1c695846398b88 Reviewed-by: Gunnar Sletta Reviewed-by: Laszlo Agocs --- src/gui/image/qpixmap_blitter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 839a7a709f..2915cdda2d 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -59,6 +59,7 @@ static int global_ser_no = 0; QBlittablePlatformPixmap::QBlittablePlatformPixmap() : QPlatformPixmap(QPlatformPixmap::PixmapType,BlitterClass) , m_alpha(false) + , m_devicePixelRatio(1.0) #ifdef QT_BLITTER_RASTEROVERLAY ,m_rasterOverlay(0), m_unmergedCopy(0) #endif //QT_BLITTER_RASTEROVERLAY @@ -121,7 +122,7 @@ int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) con case QPaintDevice::PdmPhysicalDpiY: return qt_defaultDpiY(); case QPaintDevice::PdmDevicePixelRatio: - return 1; + return devicePixelRatio(); default: qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric); break; @@ -178,6 +179,7 @@ void QBlittablePlatformPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) { m_alpha = image.hasAlphaChannel(); + m_devicePixelRatio = image.devicePixelRatio(); resize(image.width(),image.height()); markRasterOverlay(QRect(0,0,w,h)); QImage *thisImg = buffer(); -- cgit v1.2.3 From 89b70f3910dfec7108d6e95cc96f904fce01da29 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 7 Mar 2014 14:30:13 +0100 Subject: Vectorize bilinear rotating transforms This patch reuses the code and pattern used to vectorize scaling, to also vectorize rotating transforms in fetchTransformedBilinearARGB32PM. This provides significant improvements in QtWebKit on benchmarks using rotating transforms. Change-Id: If250e0f5dae1ff0f954301f96cc8970a99ae3e9d Reviewed-by: Thiago Macieira Reviewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper.cpp | 157 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 7a5c5dc660..b5ccafdf9a 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1709,6 +1709,163 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c } } else { //we are zooming less than 8x, use 4bit precision + + if (blendType != BlendTransformedBilinearTiled) { +#define BILINEAR_ROTATE_BOUNDS_PROLOG \ + while (b < end) { \ + int x1 = (fx >> 16); \ + int x2; \ + int y1 = (fy >> 16); \ + int y2; \ + fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); \ + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); \ + if (x1 != x2 && y1 != y2) \ + break; \ + const uint *s1 = (const uint *)data->texture.scanLine(y1); \ + const uint *s2 = (const uint *)data->texture.scanLine(y2); \ + uint tl = s1[x1]; \ + uint tr = s1[x2]; \ + uint bl = s2[x1]; \ + uint br = s2[x2]; \ + int distx = (fx & 0x0000ffff) >> 12; \ + int disty = (fy & 0x0000ffff) >> 12; \ + *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); \ + fx += fdx; \ + fy += fdy; \ + ++b; \ + } \ + uint *boundedEnd = end - 3; \ + boundedEnd -= 3; + +#if defined(__SSE2__) + BILINEAR_ROTATE_BOUNDS_PROLOG + + const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); + const __m128i v_256 = _mm_set1_epi16(256); + __m128i v_fdx = _mm_set1_epi32(fdx*4); + __m128i v_fdy = _mm_set1_epi32(fdy*4); + + const uchar *textureData = data->texture.imageData; + const int bytesPerLine = data->texture.bytesPerLine; + + union Vect_buffer { __m128i vect; qint32 i[4]; }; + Vect_buffer v_fx, v_fy; + + for (int i = 0; i < 4; i++) { + v_fx.i[i] = fx; + v_fy.i[i] = fy; + fx += fdx; + fy += fdy; + } + + while (b < boundedEnd) { + if (fdx > 0 && (v_fx.i[3] >> 16) >= image_x2) + break; + if (fdx < 0 && (v_fx.i[3] >> 16) < image_x1) + break; + if (fdy > 0 && (v_fy.i[3] >> 16) >= image_y2) + break; + if (fdy < 0 && (v_fy.i[3] >> 16) < image_y1) + break; + + Vect_buffer tl, tr, bl, br; + Vect_buffer v_fx_shifted, v_fy_shifted; + v_fx_shifted.vect = _mm_srli_epi32(v_fx.vect, 16); + v_fy_shifted.vect = _mm_srli_epi32(v_fy.vect, 16); + + for (int i = 0; i < 4; i++) { + const int x1 = v_fx_shifted.i[i]; + const int y1 = v_fy_shifted.i[i]; + const uchar *sl = textureData + bytesPerLine * y1; + const uint *s1 = (const uint *)sl; + const uint *s2 = (const uint *)(sl + bytesPerLine); + tl.i[i] = s1[x1]; + tr.i[i] = s1[x1+1]; + bl.i[i] = s2[x1]; + br.i[i] = s2[x1+1]; + } + __m128i v_distx = _mm_srli_epi16(v_fx.vect, 12); + __m128i v_disty = _mm_srli_epi16(v_fy.vect, 12); + v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); + v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0)); + v_disty = _mm_shufflehi_epi16(v_disty, _MM_SHUFFLE(2,2,0,0)); + v_disty = _mm_shufflelo_epi16(v_disty, _MM_SHUFFLE(2,2,0,0)); + + interpolate_4_pixels_16_sse2(tl.vect, tr.vect, bl.vect, br.vect, v_distx, v_disty, colorMask, v_256, b); + b+=4; + v_fx.vect = _mm_add_epi32(v_fx.vect, v_fdx); + v_fy.vect = _mm_add_epi32(v_fy.vect, v_fdy); + } + fx = v_fx.i[0]; + fy = v_fy.i[0]; +#elif defined(__ARM_NEON__) + BILINEAR_ROTATE_BOUNDS_PROLOG + + const int16x8_t colorMask = vdupq_n_s16(0x00ff); + const int16x8_t invColorMask = vmvnq_s16(colorMask); + const int16x8_t v_256 = vdupq_n_s16(256); + int32x4_t v_fdx = vdupq_n_s32(fdx*4); + int32x4_t v_fdy = vdupq_n_s32(fdy*4); + + const uchar *textureData = data->texture.imageData; + const int bytesPerLine = data->texture.bytesPerLine; + + union Vect_buffer { int32x4_t vect; quint32 i[4]; }; + Vect_buffer v_fx, v_fy; + + for (int i = 0; i < 4; i++) { + v_fx.i[i] = fx; + v_fy.i[i] = fy; + fx += fdx; + fy += fdy; + } + + const int32x4_t v_ffff_mask = vdupq_n_s32(0x0000ffff); + + while (b < boundedEnd) { + if (fdx > 0 && (v_fx.i[3] >> 16) >= image_x2) + break; + if (fdx < 0 && (v_fx.i[3] >> 16) < image_x1) + break; + if (fdy > 0 && (v_fy.i[3] >> 16) >= image_y2) + break; + if (fdy < 0 && (v_fy.i[3] >> 16) < image_y1) + break; + + Vect_buffer tl, tr, bl, br; + + Vect_buffer v_fx_shifted, v_fy_shifted; + v_fx_shifted.vect = vshrq_n_s32(v_fx.vect, 16); + v_fy_shifted.vect = vshrq_n_s32(v_fy.vect, 16); + + for (int i = 0; i < 4; i++) { + const int x1 = v_fx_shifted.i[i]; + const int y1 = v_fy_shifted.i[i]; + const uchar *sl = textureData + bytesPerLine * y1; + const uint *s1 = (const uint *)sl; + const uint *s2 = (const uint *)(sl + bytesPerLine); + tl.i[i] = s1[x1]; + tr.i[i] = s1[x1+1]; + bl.i[i] = s2[x1]; + br.i[i] = s2[x1+1]; + } + + int32x4_t v_distx = vshrq_n_s32(vandq_s32(v_fx.vect, v_ffff_mask), 12); + int32x4_t v_disty = vshrq_n_s32(vandq_s32(v_fy.vect, v_ffff_mask), 12); + v_distx = vorrq_s32(v_distx, vshlq_n_s32(v_distx, 16)); + v_disty = vorrq_s32(v_disty, vshlq_n_s32(v_disty, 16)); + int16x8_t v_disty_ = vshlq_n_s16(v_disty, 4); + + interpolate_4_pixels_16_neon(vreinterpretq_s16_s32(tl.vect), vreinterpretq_s16_s32(tr.vect), vreinterpretq_s16_s32(bl.vect), vreinterpretq_s16_s32(br.vect), vreinterpretq_s16_s32(v_distx), v_disty, v_disty_, colorMask, invColorMask, v_256, b); + b+=4; + v_fx.vect = vaddq_s32(v_fx.vect, v_fdx); + v_fy.vect = vaddq_s32(v_fy.vect, v_fdy); + } + fx = v_fx.i[0]; + fy = v_fy.i[0]; +#endif + } + while (b < end) { int x1 = (fx >> 16); int x2; -- cgit v1.2.3 From ac448335f177eff59465300a7141db559c9eadad Mon Sep 17 00:00:00 2001 From: Louai Al-Khanji Date: Wed, 30 Apr 2014 10:27:57 +0300 Subject: Direct2D QPA: Draw directly to swap chain Remove the intermediate pixmap in the backing store and draw directly to the window swap chain. This is faster and reduces memory pressure on the graphics card. In case of native child widgets we need to read back the back buffer, which incurs an extra copy in this case. In an artificial benchmark drawing animated full screen gradients as fast as possible this patch increases performance by 42% on my current machine from 480fps to around 680fps, i.e. the time for actually getting the pixels to the screen is now lower. Change-Id: Ifbeda0e199afec03cecfe76337679a9e9d082bdd Reviewed-by: Risto Avila Reviewed-by: Friedemann Kleint Reviewed-by: Andrew Knight --- .../direct2d/qwindowsdirect2dbackingstore.cpp | 42 ++++++---- .../direct2d/qwindowsdirect2dbackingstore.h | 9 +-- .../direct2d/qwindowsdirect2dplatformpixmap.cpp | 38 +++++++-- .../direct2d/qwindowsdirect2dplatformpixmap.h | 5 +- .../platforms/direct2d/qwindowsdirect2dwindow.cpp | 92 +++++++++++++++++----- .../platforms/direct2d/qwindowsdirect2dwindow.h | 7 +- 6 files changed, 149 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp index e4ce81bd24..be013f027b 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -66,6 +66,16 @@ static inline QWindowsDirect2DPlatformPixmap *platformPixmap(QPixmap *p) return static_cast(p->handle()); } +static inline QWindowsDirect2DBitmap *bitmap(QPixmap *p) +{ + return platformPixmap(p)->bitmap(); +} + +static inline QWindowsDirect2DWindow *nativeWindow(QWindow *window) +{ + return static_cast(window->handle()); +} + QWindowsDirect2DBackingStore::QWindowsDirect2DBackingStore(QWindow *window) : QPlatformBackingStore(window) { @@ -77,36 +87,40 @@ QWindowsDirect2DBackingStore::~QWindowsDirect2DBackingStore() void QWindowsDirect2DBackingStore::beginPaint(const QRegion &) { - platformPixmap(m_pixmap.data())->bitmap()->deviceContext()->begin(); + bitmap(nativeWindow(window())->pixmap())->deviceContext()->begin(); } void QWindowsDirect2DBackingStore::endPaint() { - platformPixmap(m_pixmap.data())->bitmap()->deviceContext()->end(); + bitmap(nativeWindow(window())->pixmap())->deviceContext()->end(); } QPaintDevice *QWindowsDirect2DBackingStore::paintDevice() { - return m_pixmap.data(); + return nativeWindow(window())->pixmap(); } -void QWindowsDirect2DBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) +void QWindowsDirect2DBackingStore::flush(QWindow *targetWindow, const QRegion ®ion, const QPoint &offset) { - QPlatformWindow *pw = window->handle(); - if (pw && m_pixmap) - static_cast(pw)->flush(platformPixmap(m_pixmap.data())->bitmap(), region, offset); + if (targetWindow != window()) { + QSharedPointer copy(nativeWindow(window())->copyBackBuffer()); + nativeWindow(targetWindow)->flush(copy.data(), region, offset); + } + + nativeWindow(targetWindow)->present(); } void QWindowsDirect2DBackingStore::resize(const QSize &size, const QRegion ®ion) { - Q_UNUSED(region); + QPixmap old = nativeWindow(window())->pixmap()->copy(); - QScopedPointer oldPixmap(m_pixmap.take()); - m_pixmap.reset(new QPixmap(size.width(), size.height())); + nativeWindow(window())->resizeSwapChain(size); + QPixmap *newPixmap = nativeWindow(window())->pixmap(); - if (oldPixmap) { - foreach (const QRect &rect, region.rects()) - platformPixmap(m_pixmap.data())->copy(oldPixmap->handle(), rect); + if (!old.isNull()) { + foreach (const QRect &rect, region.rects()) { + platformPixmap(newPixmap)->copy(old.handle(), rect); + } } } diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h index fc6802aaa2..71e9437274 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +class QWindowsDirect2DWindow; + class QWindowsDirect2DBackingStore : public QPlatformBackingStore { Q_DISABLE_COPY(QWindowsDirect2DBackingStore) @@ -62,11 +64,8 @@ public: void endPaint(); QPaintDevice *paintDevice() Q_DECL_OVERRIDE; - void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE; + void flush(QWindow *targetWindow, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE; void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE; - -private: - QScopedPointer m_pixmap; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp index 072c4b3c0e..d9f7c595ca 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -56,12 +56,27 @@ class QWindowsDirect2DPlatformPixmapPrivate { public: QWindowsDirect2DPlatformPixmapPrivate() - : bitmap(new QWindowsDirect2DBitmap) - , device(new QWindowsDirect2DPaintDevice(bitmap.data(), QInternal::Pixmap)) + : owns_bitmap(true) + , bitmap(new QWindowsDirect2DBitmap) + , device(new QWindowsDirect2DPaintDevice(bitmap, QInternal::Pixmap)) , devicePixelRatio(1.0) {} - QScopedPointer bitmap; + QWindowsDirect2DPlatformPixmapPrivate(QWindowsDirect2DBitmap *bitmap) + : owns_bitmap(false) + , bitmap(bitmap) + , device(new QWindowsDirect2DPaintDevice(bitmap, QInternal::Pixmap)) + , devicePixelRatio(1.0) + {} + + ~QWindowsDirect2DPlatformPixmapPrivate() + { + if (owns_bitmap) + delete bitmap; + } + + bool owns_bitmap; + QWindowsDirect2DBitmap *bitmap; QScopedPointer device; qreal devicePixelRatio; }; @@ -75,6 +90,19 @@ QWindowsDirect2DPlatformPixmap::QWindowsDirect2DPlatformPixmap(PixelType pixelTy setSerialNumber(qt_d2dpixmap_serno++); } +QWindowsDirect2DPlatformPixmap::QWindowsDirect2DPlatformPixmap(QPlatformPixmap::PixelType pixelType, + QWindowsDirect2DBitmap *bitmap) + : QPlatformPixmap(pixelType, Direct2DClass) + , d_ptr(new QWindowsDirect2DPlatformPixmapPrivate(bitmap)) +{ + setSerialNumber(qt_d2dpixmap_serno++); + + is_null = false; + w = bitmap->size().width(); + h = bitmap->size().height(); + this->d = 32; +} + QWindowsDirect2DPlatformPixmap::~QWindowsDirect2DPlatformPixmap() { @@ -173,7 +201,7 @@ void QWindowsDirect2DPlatformPixmap::setDevicePixelRatio(qreal scaleFactor) QWindowsDirect2DBitmap *QWindowsDirect2DPlatformPixmap::bitmap() const { Q_D(const QWindowsDirect2DPlatformPixmap); - return d->bitmap.data(); + return d->bitmap; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.h b/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.h index e6684ea423..1936ef0622 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.h +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dplatformpixmap.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -55,6 +55,9 @@ class QWindowsDirect2DPlatformPixmap : public QPlatformPixmap Q_DECLARE_PRIVATE(QWindowsDirect2DPlatformPixmap) public: QWindowsDirect2DPlatformPixmap(PixelType pixelType); + + // We do NOT take ownership of the bitmap through this constructor! + QWindowsDirect2DPlatformPixmap(PixelType pixelType, QWindowsDirect2DBitmap *bitmap); ~QWindowsDirect2DPlatformPixmap(); virtual void resize(int width, int height); diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp index 50d0cb81f5..15ec0c3526 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp @@ -43,6 +43,7 @@ #include "qwindowsdirect2dwindow.h" #include "qwindowsdirect2ddevicecontext.h" #include "qwindowsdirect2dhelpers.h" +#include "qwindowsdirect2dplatformpixmap.h" #include #include @@ -87,6 +88,13 @@ QWindowsDirect2DWindow::~QWindowsDirect2DWindow() { } +QPixmap *QWindowsDirect2DWindow::pixmap() +{ + setupBitmap(); + + return m_pixmap.data(); +} + void QWindowsDirect2DWindow::flush(QWindowsDirect2DBitmap *bitmap, const QRegion ®ion, const QPoint &offset) { DXGI_SWAP_CHAIN_DESC1 desc; @@ -102,32 +110,38 @@ void QWindowsDirect2DWindow::flush(QWindowsDirect2DBitmap *bitmap, const QRegion if (!m_bitmap) return; - m_bitmap->deviceContext()->begin(); - - ID2D1DeviceContext *dc = m_bitmap->deviceContext()->get(); - if (!m_needsFullFlush) { - QRegion clipped = region; - clipped &= QRect(0, 0, desc.Width, desc.Height); - - foreach (const QRect &rect, clipped.rects()) { - QRectF rectF(rect); + if (bitmap != m_bitmap.data()) { + m_bitmap->deviceContext()->begin(); + + ID2D1DeviceContext *dc = m_bitmap->deviceContext()->get(); + if (!m_needsFullFlush) { + QRegion clipped = region; + clipped &= QRect(0, 0, desc.Width, desc.Height); + + foreach (const QRect &rect, clipped.rects()) { + QRectF rectF(rect); + dc->DrawBitmap(bitmap->bitmap(), + to_d2d_rect_f(rectF), + 1.0, + D2D1_INTERPOLATION_MODE_LINEAR, + to_d2d_rect_f(rectF.translated(offset.x(), offset.y()))); + } + } else { + QRectF rectF(0, 0, desc.Width, desc.Height); dc->DrawBitmap(bitmap->bitmap(), to_d2d_rect_f(rectF), 1.0, D2D1_INTERPOLATION_MODE_LINEAR, to_d2d_rect_f(rectF.translated(offset.x(), offset.y()))); + m_needsFullFlush = false; } - } else { - QRectF rectF(0, 0, desc.Width, desc.Height); - dc->DrawBitmap(bitmap->bitmap(), - to_d2d_rect_f(rectF), - 1.0, - D2D1_INTERPOLATION_MODE_LINEAR, - to_d2d_rect_f(rectF.translated(offset.x(), offset.y()))); - m_needsFullFlush = false; + + m_bitmap->deviceContext()->end(); } +} - m_bitmap->deviceContext()->end(); +void QWindowsDirect2DWindow::present() +{ m_swapChain->Present(0, 0); } @@ -136,6 +150,7 @@ void QWindowsDirect2DWindow::resizeSwapChain(const QSize &size) if (!m_swapChain) return; + m_pixmap.reset(); m_bitmap.reset(); m_deviceContext->SetTarget(Q_NULLPTR); @@ -149,6 +164,43 @@ void QWindowsDirect2DWindow::resizeSwapChain(const QSize &size) m_needsFullFlush = true; } +QSharedPointer QWindowsDirect2DWindow::copyBackBuffer() const +{ + const QSharedPointer null_result; + + if (!m_bitmap) + return null_result; + + D2D1_PIXEL_FORMAT format = m_bitmap->bitmap()->GetPixelFormat(); + D2D1_SIZE_U size = m_bitmap->bitmap()->GetPixelSize(); + + FLOAT dpiX, dpiY; + m_bitmap->bitmap()->GetDpi(&dpiX, &dpiY); + + D2D1_BITMAP_PROPERTIES1 properties = { + format, // D2D1_PIXEL_FORMAT pixelFormat; + dpiX, // FLOAT dpiX; + dpiY, // FLOAT dpiY; + D2D1_BITMAP_OPTIONS_TARGET, // D2D1_BITMAP_OPTIONS bitmapOptions; + Q_NULLPTR // _Field_size_opt_(1) ID2D1ColorContext *colorContext; + }; + ComPtr copy; + HRESULT hr = m_deviceContext.Get()->CreateBitmap(size, NULL, 0, properties, ©); + + if (FAILED(hr)) { + qWarning("%s: Could not create staging bitmap: %#x", __FUNCTION__, hr); + return null_result; + } + + hr = copy.Get()->CopyFromBitmap(NULL, m_bitmap->bitmap(), NULL); + if (FAILED(hr)) { + qWarning("%s: Could not copy from bitmap! %#x", __FUNCTION__, hr); + return null_result; + } + + return QSharedPointer(new QWindowsDirect2DBitmap(copy.Get(), Q_NULLPTR)); +} + void QWindowsDirect2DWindow::setupBitmap() { if (m_bitmap) @@ -175,6 +227,10 @@ void QWindowsDirect2DWindow::setupBitmap() } m_bitmap.reset(new QWindowsDirect2DBitmap(backBufferBitmap.Get(), m_deviceContext.Get())); + + QWindowsDirect2DPlatformPixmap *pp = new QWindowsDirect2DPlatformPixmap(QPlatformPixmap::PixmapType, + m_bitmap.data()); + m_pixmap.reset(new QPixmap(pp)); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h index 7996904639..47c790da5d 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.h @@ -56,16 +56,21 @@ public: QWindowsDirect2DWindow(QWindow *window, const QWindowsWindowData &data); ~QWindowsDirect2DWindow(); + QPixmap *pixmap(); void flush(QWindowsDirect2DBitmap *bitmap, const QRegion ®ion, const QPoint &offset); + void present(); + void resizeSwapChain(const QSize &size); + + QSharedPointer copyBackBuffer() const; private: - void resizeSwapChain(const QSize &size); void setupBitmap(); private: Microsoft::WRL::ComPtr m_swapChain; Microsoft::WRL::ComPtr m_deviceContext; QScopedPointer m_bitmap; + QScopedPointer m_pixmap; bool m_needsFullFlush; }; -- cgit v1.2.3 From 14cb737ff709edd506a687f7277b4962c094ec1e Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Sat, 3 May 2014 20:04:03 +0200 Subject: Fix typo in QListWidget documentation. Change-Id: Ieefb664a49bb578efc70ea1ab1a09fb4c8507568 Reviewed-by: Gunnar Sletta --- src/widgets/itemviews/qlistwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 5040192f31..1f954d67dd 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -1631,7 +1631,7 @@ QWidget *QListWidget::itemWidget(QListWidgetItem *item) const /*! \since 4.1 - Sets the \a widget to be displayed in the give \a item. + Sets the \a widget to be displayed in the given \a item. This function should only be used to display static content in the place of a list widget item. If you want to display custom dynamic content or -- cgit v1.2.3 From ad8efdbc0c22146a30faf7181a2988a4c00dfbda Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Wed, 30 Apr 2014 13:44:09 +0300 Subject: WinRT: set orientation update mask to native orientation by default This aligns with the other mobile platforms. Task-number: QTBUG-38691 Change-Id: I7b9b70a1182c0e53f997cae111ec46b5161b0b48 Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 583441f396..773220660a 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -496,6 +496,7 @@ QWinRTScreen::QWinRTScreen(ICoreWindow *window) // Set initial orientation onOrientationChanged(0); + setOrientationUpdateMask(m_nativeOrientation); m_displayProperties->add_OrientationChanged(Callback(this, &QWinRTScreen::onOrientationChanged).Get(), &m_tokens[QEvent::OrientationChange]); -- cgit v1.2.3 From 1fdd765ae8a3d7ce4859c6f29d780f3dc177f7e4 Mon Sep 17 00:00:00 2001 From: Louai Al-Khanji Date: Mon, 5 May 2014 09:26:31 +0300 Subject: Direct2D QPA: Fix DXGI Factory discovery magic On some Intel configurations the current DXGI discovery breaks. Fix this by adhering to Microsoft's guidelines for discovery of the DXGI factory: http://msdn.microsoft.com/en-us/library/windows/desktop/hh780339(v=vs.85).aspx Not querying the adapter directly as in the code snippet on the site above seems to have been a typo originally. Change-Id: Ibd7546462cdab7e5ad03db9abc16fe1615b631f4 Reviewed-by: Friedemann Kleint Reviewed-by: Andrew Knight --- src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp index 58002fb0dd..80688a1da7 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dcontext.cpp @@ -99,7 +99,7 @@ public: return false; } - hr = dxgiDevice->GetParent(IID_PPV_ARGS(&dxgiAdapter)); + hr = dxgiDevice->GetAdapter(&dxgiAdapter); if (FAILED(hr)) { qWarning("%s: Failed to probe DXGI Device for parent DXGI Adapter: %#x", __FUNCTION__, hr); return false; -- cgit v1.2.3 From 5bca5d0a51366ec4b4a87afeda2013b42290a588 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 29 Apr 2014 16:45:33 +0200 Subject: Fix crash on startup when running screenreader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For exaple Qt Creator would crash when started and a screen reader (eg NVDA) is running. This is due to updateAccessibility being called during the ctor of the TextEdit and on Windows the AT can access properties in the same call resulting in accessing the text control before it's fully constructed. Also make sure to not send accessibility updates for non-widget type edits since we don't support any accessibility in Qt Quick 1. Task-number: QTBUG-38659 Change-Id: I1635fa3b2c4d3509f44daf760e4d7b4171d67e1d Reviewed-by: Jan Arve Sæther --- src/widgets/widgets/qwidgettextcontrol.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 9cc62fd10a..54b20e36f5 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -438,7 +438,6 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString QObject::connect(doc, SIGNAL(contentsChanged()), q, SLOT(_q_updateCurrentCharFormatAndSelection())); QObject::connect(doc, SIGNAL(cursorPositionChanged(QTextCursor)), q, SLOT(_q_emitCursorPosChanged(QTextCursor))); - QObject::connect(doc, SIGNAL(contentsChange(int,int,int)), q, SLOT(_q_contentsChanged(int,int,int))); QObject::connect(doc, SIGNAL(documentLayoutChanged()), q, SLOT(_q_documentLayoutChanged())); // convenience signal forwards @@ -501,6 +500,8 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString q->ensureCursorVisible(); emit q->cursorPositionChanged(); + + QObject::connect(doc, SIGNAL(contentsChange(int,int,int)), q, SLOT(_q_contentsChanged(int,int,int)), Qt::UniqueConnection); } void QWidgetTextControlPrivate::startDrag() @@ -646,7 +647,8 @@ void QWidgetTextControlPrivate::_q_contentsChanged(int from, int charsRemoved, i { Q_Q(QWidgetTextControl); #ifndef QT_NO_ACCESSIBILITY - if (QAccessible::isActive()) { + + if (QAccessible::isActive() && q->parent() && q->parent()->isWidgetType()) { QTextCursor tmp(doc); tmp.setPosition(from); tmp.setPosition(from + charsAdded, QTextCursor::KeepAnchor); -- cgit v1.2.3 From 9e2c4bc67f30eb1e8d776afe3a092d5994aaab38 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 5 May 2014 14:11:30 +0200 Subject: QMdiArea: Ignore events of other instances in the event filter. This caused for example the variable QMdiAreaPrivate::isSubWindowsTiled being cleared from another instance, which resulted in odd resizing behavior. Task-number: QTBUG-31448 Change-Id: I880f7e415d6654e52499df1bfaf99f2c55d86320 Reviewed-by: J-P Nurmi Reviewed-by: Andy Shaw --- src/widgets/widgets/qmdiarea.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 600d9b536f..17f73b2809 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -2591,6 +2591,9 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event) return QAbstractScrollArea::eventFilter(object, event); } + if (subWindow->mdiArea() != this) + return QAbstractScrollArea::eventFilter(object, event); + // QMdiSubWindow events: switch (event->type()) { case QEvent::Move: -- cgit v1.2.3 From 31091808814de383aeec453933d2b29ce4eefb6f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 5 May 2014 15:54:10 +0200 Subject: Avoid showing warnings from drawPixmap when using a QGLWidget QGLWidget has a paint device type of Widget, yet drawing on it from outside the gui thread is fine as long as ThreadedOpenGL is supported. It has probably been overlooked that the device type OpenGL applies to QGLFramebufferObject and such but not QGLWidget. This will fix the problem of flooding the output with warnings in the tst_qglthreads autotest and potentially elsewhere too. Task-number: QTBUG-38771 Change-Id: Ie014a2610a0db41b31c30c404e286d4997aecdc3 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Gunnar Sletta --- src/gui/painting/qpainter.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index fe5fc051df..3f387d575b 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -147,8 +147,9 @@ static inline uint line_emulation(uint emulation) } #ifndef QT_NO_DEBUG -static bool qt_painter_thread_test(int devType, const char *what) +static bool qt_painter_thread_test(int devType, int engineType, const char *what) { + const QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); switch (devType) { case QInternal::Image: case QInternal::Printer: @@ -157,8 +158,13 @@ static bool qt_painter_thread_test(int devType, const char *what) break; default: if (QThread::currentThread() != qApp->thread() - && (devType!=QInternal::Pixmap || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) - && (devType!=QInternal::OpenGL || !QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL))) { + // pixmaps cannot be targets unless threaded pixmaps are supported + && (devType != QInternal::Pixmap || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedPixmaps)) + // framebuffer objects and such cannot be targets unless threaded GL is supported + && (devType != QInternal::OpenGL || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedOpenGL)) + // widgets cannot be targets except for QGLWidget + && (devType != QInternal::Widget || !platformIntegration->hasCapability(QPlatformIntegration::ThreadedOpenGL) + || (engineType != QPaintEngine::OpenGL && engineType != QPaintEngine::OpenGL2))) { qWarning("QPainter: It is not safe to use %s outside the GUI thread", what); return false; } @@ -5054,7 +5060,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawPixmap()"); #endif if (d->extended) { @@ -5125,7 +5131,7 @@ void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) if (!d->engine || pm.isNull()) return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawPixmap()"); #endif qreal x = r.x(); @@ -6610,7 +6616,7 @@ void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPo return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()"); + qt_painter_thread_test(d->device->devType(), d->engine->type(), "drawTiledPixmap()"); #endif qreal sw = pixmap.width(); -- cgit v1.2.3 From bf9970d40bf0c99a75b59674fa55bc859291d9ba Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 5 May 2014 12:22:22 +0200 Subject: Use QCoreApplication::postEvent() for replaying popup mouse events. When replaying the mouse events synchronously, nested calls of QEventLoop::exec() may happen in conjunction with menus. Task-number: QTBUG-38550 Change-Id: I2b1dafdac59d1a080775af5f165d1e594ea58804 Reviewed-by: Gabriel de Dietrich --- src/corelib/kernel/qcoreevent.h | 1 + src/widgets/kernel/qwidgetwindow.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 3ee0eaaa61..8b58fdf55f 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -323,6 +323,7 @@ private: friend class QGraphicsViewPrivate; friend class QGraphicsScene; friend class QGraphicsScenePrivate; + friend class QWidgetWindow; #ifndef QT_NO_GESTURES friend class QGestureManager; #endif diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 0031d8e965..fc328e7af0 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -440,11 +440,13 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) if (!win) win = w->nativeParentWidget()->windowHandle(); if (win && win->geometry().contains(event->globalPos())) { + // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec() const QPoint localPos = win->mapFromGlobal(event->globalPos()); - QMouseEvent e(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers()); - QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event)); - e.setTimestamp(event->timestamp()); - QApplication::sendSpontaneousEvent(win, &e); + QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers()); + e->spont = 1; + QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event)); + e->setTimestamp(event->timestamp()); + QCoreApplication::postEvent(win, e); } } } -- cgit v1.2.3 From d36002d04665dc0db6985fae02fae31d712663cb Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 7 Apr 2014 19:13:59 +0200 Subject: Prevent interaction with a disabled menu in the menubar When moving the mouse over a disabled menu it could appear to be usable but it should not show any interaction at all. Task-number: QTBUG-31688 Task-number: QTBUG-37488 Change-Id: I9e6594b40e8b209146d8c3705750dfd75f1258c5 Reviewed-by: Frederik Gladhorn --- src/widgets/widgets/qmenubar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 729e08c7a5..f523ac2777 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -384,7 +384,7 @@ void QMenuBarPrivate::setCurrentAction(QAction *action, bool popup, bool activat QAction *previousAction = currentAction; #endif currentAction = action; - if (action) { + if (action && action->isEnabled()) { activateAction(action, QAction::Hover); if(popup) popupAction(action, activateFirst); @@ -1038,7 +1038,7 @@ void QMenuBar::mousePressEvent(QMouseEvent *e) d->mouseDown = true; QAction *action = d->actionAt(e->pos()); - if (!action || !d->isVisible(action)) { + if (!action || !d->isVisible(action) || !action->isEnabled()) { d->setCurrentAction(0); #ifndef QT_NO_WHATSTHIS if (QWhatsThis::inWhatsThisMode()) -- cgit v1.2.3 From 3b8d14055838610af0f284403d8b44bc37715062 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 23 Apr 2014 14:56:35 +0200 Subject: Accessibility: Do not report popup for QLineEdit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nothing else seems to report this state and on windows for example it results in NVDA reading subMenu which makes little sense. Task-number: QTBUG-38500 Change-Id: I64820d9f2ea9174034f01da42cb2266a19c19465 Reviewed-by: Jan Arve Sæther --- src/plugins/accessible/widgets/simplewidgets.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 646eeb06a1..a5365b2598 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -647,10 +647,6 @@ QAccessible::State QAccessibleLineEdit::state() const if (l->hasSelectedText()) state.selected = true; - if (l->contextMenuPolicy() != Qt::NoContextMenu - && l->contextMenuPolicy() != Qt::PreventContextMenu) - state.hasPopup = true; - return state; } -- cgit v1.2.3 From cfacdaeb95014458952f43aa605d60e8fb15031c Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 16 Apr 2014 23:17:55 +0200 Subject: Fix typo in QGraphicsView's interactive property doc. Change-Id: Iccc58490b330657d5d23c333fc408cde33231d95 Reviewed-by: Gunnar Sletta --- src/widgets/graphicsview/qgraphicsview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 86648c4f26..5bcf52b6a3 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -1655,7 +1655,7 @@ void QGraphicsView::invalidateScene(const QRectF &rect, QGraphicsScene::SceneLay /*! \property QGraphicsView::interactive - \brief whether the view allowed scene interaction. + \brief whether the view allows scene interaction. If enabled, this view is set to allow scene interaction. Otherwise, this view will not allow interaction, and any mouse or key events are ignored -- cgit v1.2.3 From f0579fa68e620ced2bc32c6549d2e45cdf8c7c97 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 29 Apr 2014 11:48:06 +0200 Subject: Document returned format of QOpenGLFramebufferObject::toImage() The image format returned by QOpenGLFramebufferObject::toImage() on OpenGL ES/2 builds changed in 5.2.0 but was not documented. Change-Id: I2379c62c7f715803192ffa9bb8ae1171ef4b2314 Reviewed-by: Gunnar Sletta --- src/gui/opengl/qopenglframebufferobject.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index cc829df950..7fb6815120 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1112,6 +1112,9 @@ Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, \fn QImage QOpenGLFramebufferObject::toImage() const Returns the contents of this framebuffer object as a QImage. + + Will try to return a premultiplied ARBG32 or RGB32 image. Since 5.2 it will fall back to + a premultiplied RGBA8888 or RGBx8888 image when reading to ARGB32 is not supported. */ QImage QOpenGLFramebufferObject::toImage() const { -- cgit v1.2.3 From a17aaed1cd99d4a00912e4a1c631d49f2c7c3cc4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 6 May 2014 12:27:56 +0200 Subject: Remove warnings about sleep times from QTest::qSleep() The collected data doesn't reveal any obvious correlation between sleep times and test failures but the many warnings are a hassle for anyone reading the test results. Change-Id: I71bd0c90c20c730573693f23f4435e538b635d44 Reviewed-by: Friedemann Kleint --- src/testlib/qtestcase.cpp | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'src') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index cbf479f1d2..cc58b51743 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2863,8 +2863,6 @@ bool QTest::currentTestFailed() void QTest::qSleep(int ms) { QTEST_ASSERT(ms > 0); - QElapsedTimer timer; - timer.start(); #if defined(Q_OS_WINRT) WaitForSingleObjectEx(GetCurrentThread(), ms, true); @@ -2874,20 +2872,6 @@ void QTest::qSleep(int ms) struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 }; nanosleep(&ts, NULL); #endif - // Warn if the elapsed time was more than 50% longer or more than 10% shorter than the - // requested time. - qint64 requested = 1000000 * (qint64)ms; - qint64 diff = timer.nsecsElapsed() - requested; -#ifndef Q_OS_WIN - const qint64 factor = 2; // more than 50% longer -#else - const qint64 factor = 1; // Windows: 50% is quite common, warn about 100% -#endif - if (diff * factor > requested || diff * 10 < -requested) { - QTestLog::warn(qPrintable( - QString::fromLatin1("QTest::qSleep() should have taken %1ns, but actually took %2ns!") - .arg(requested).arg(diff + requested)), __FILE__, __LINE__); - } } /*! \internal -- cgit v1.2.3 From d915432c23177a5d7f9ffd0d6899aab13ddc4c2b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 May 2014 12:03:33 +0200 Subject: QFileDialog: Return empty QUrl from the static get..FileUrl() functions. Task-number: QTBUG-38672 Change-Id: Idf554cd93d1a79db7c82f3165bd128fb31ead3e5 Reviewed-by: David Faure --- src/widgets/dialogs/qfiledialog.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index bb8cdec896..6349bdc301 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -2128,6 +2128,11 @@ QString QFileDialog::getOpenFileName(QWidget *parent, return QString(); } +static inline QUrl dialogResultToUrl(const QString &file) +{ + return file.isEmpty() ? QUrl() : QUrl::fromLocalFile(file); +} + /*! This is a convenience static function that returns an existing file selected by the user. If the user presses Cancel, it returns an @@ -2166,7 +2171,7 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent, Q_UNUSED(supportedSchemes); // Falls back to local file - return QUrl::fromLocalFile(getOpenFileName(parent, caption, dir.toLocalFile(), filter, selectedFilter, options)); + return dialogResultToUrl(getOpenFileName(parent, caption, dir.toLocalFile(), filter, selectedFilter, options)); } /*! @@ -2424,7 +2429,7 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent, Q_UNUSED(supportedSchemes); // Falls back to local file - return QUrl::fromLocalFile(getSaveFileName(parent, caption, dir.toLocalFile(), filter, selectedFilter, options)); + return dialogResultToUrl(getSaveFileName(parent, caption, dir.toLocalFile(), filter, selectedFilter, options)); } /*! @@ -2532,7 +2537,7 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent, Q_UNUSED(supportedSchemes); // Falls back to local file - return QUrl::fromLocalFile(getExistingDirectory(parent, caption, dir.toLocalFile(), options)); + return dialogResultToUrl(getExistingDirectory(parent, caption, dir.toLocalFile(), options)); } inline static QString _qt_get_directory(const QString &path) -- cgit v1.2.3 From 344562aff7b86376cd6e09033e44400782ca327e Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 3 May 2014 00:35:12 +0200 Subject: Fix debug output when enabling QABSTRACTSOCKET_DEBUG. Some calls pass len=32, so garbage was shown when maxlen (readBytes) is smaller. Change-Id: I97e61dcdf5a0db032317c57afb4bfb406437d8d5 Reviewed-by: Markus Goetz Reviewed-by: Peter Hartmann --- src/network/socket/qabstractsocket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index b8f76f8d4f..bead45ab83 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -509,7 +509,7 @@ static QByteArray qt_prettyDebug(const char *data, int len, int maxLength) { if (!data) return "(null)"; QByteArray out; - for (int i = 0; i < len; ++i) { + for (int i = 0; i < qMin(len, maxLength); ++i) { char c = data[i]; if (isprint(int(uchar(c)))) { out += c; -- cgit v1.2.3 From 85aef2dd4b059d2ba9cba4605d9fef87f3e2c4fc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 5 May 2014 10:59:56 +0200 Subject: Fix visual index lookup in QTreeViewPrivate::adjustViewOptionsForIndex(). Determine the visual index by looking up the column of the QModelIndex in the logicalIndices array instead of looping. Task-number: QTBUG-37813 Change-Id: I5c3c73c67537877b03cdc2c36a52041d99f7f49d Reviewed-by: David Faure --- src/widgets/itemviews/qtreeview.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 781dd345bd..3f952ff768 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1421,15 +1421,8 @@ void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItem *option, c const int right = (spanning ? header->visualIndex(0) : header->count() - 1 ); calcLogicalIndices(&logicalIndices, &viewItemPosList, left, right); - int columnIndex = 0; - for (int visualIndex = 0; visualIndex < current.column(); ++visualIndex) { - int logicalIndex = header->logicalIndex(visualIndex); - if (!header->isSectionHidden(logicalIndex)) { - ++columnIndex; - } - } - - option->viewItemPosition = viewItemPosList.at(columnIndex); + const int visualIndex = logicalIndices.indexOf(current.column()); + option->viewItemPosition = viewItemPosList.at(visualIndex); } -- cgit v1.2.3 From c76d8c42b2fd87f620a4ea47a5c4134a084e4142 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 6 May 2014 14:10:29 +0200 Subject: Doc: removed references to QtSharedMemory. Task-number: QTBUG-38772 Change-Id: Ibc71acfafcb93d0c7e6c8ae84d412c34aacd2967 Reviewed-by: Martin Smith --- src/corelib/kernel/qsharedmemory.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index 407a6a4e02..cde42c4f6e 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -125,11 +125,9 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, or writing to the shared memory, and remember to release the lock with unlock() after you are done. - Unlike QtSharedMemory, QSharedMemory automatically destroys the - shared memory segment when the last instance of QSharedMemory is - detached from the segment, and no references to the segment - remain. Do not mix using QtSharedMemory and QSharedMemory. Port - everything to QSharedMemory. + QSharedMemory automatically destroys the shared memory segment when + the last instance of QSharedMemory is detached from the segment, and + no references to the segment remain. \warning QSharedMemory changes the key in a Qt-specific way, unless otherwise specified. Interoperation with non-Qt applications is achieved by first creating -- cgit v1.2.3 From 2bc619c30ef08c9b5e2aaa3370d184670acd73ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Tue, 6 May 2014 10:17:51 +0200 Subject: Add virtual function to QFontEngine report if outlines are reliable GetGlyphOutline fails for ttf fonts with embedded bitmaps. This results in distancefield rendering not rendering glyphs (for the failed paths). We need to fall back to texture rendering if this is the case. Change-Id: Ibdf7dc5c1d34f513c436f88fabbdcc4089bb6fef Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine.cpp | 9 +++++++++ src/gui/text/qfontengine_p.h | 2 ++ .../platforms/windows/qwindowsfontengine.cpp | 21 +++++++++++++++++++++ src/plugins/platforms/windows/qwindowsfontengine.h | 5 +++++ 4 files changed, 37 insertions(+) (limited to 'src') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index b2254c4826..078e16574f 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1335,6 +1335,15 @@ QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &fami return f; } +/** + * Some font engines like the windows font engine + * can not reliable create outline paths + */ +bool QFontEngine::hasUnreliableGlyphOutline() const +{ + return false; +} + QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round) { if (glyphs.numGlyphs >= 1) { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 5e40abbda6..fc849d788f 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -251,6 +251,8 @@ public: static QByteArray convertToPostscriptFontFamilyName(const QByteArray &fontFamily); + virtual bool hasUnreliableGlyphOutline() const; + enum HintStyle { HintNone, HintLight, diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 29c43fc7a5..6f97c8584b 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -169,6 +169,20 @@ bool QWindowsFontEngine::hasCMapTable() const return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR; } +bool QWindowsFontEngine::hasGlyfTable() const +{ + HDC hdc = m_fontEngineData->hdc; + SelectObject(hdc, hfont); + return GetFontData(hdc, MAKE_TAG('g', 'l', 'y', 'f'), 0, 0, 0) != GDI_ERROR; +} + +bool QWindowsFontEngine::hasEbdtTable() const +{ + HDC hdc = m_fontEngineData->hdc; + SelectObject(hdc, hfont); + return GetFontData(hdc, MAKE_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR; +} + void QWindowsFontEngine::getCMap() { ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable(); @@ -308,6 +322,8 @@ QWindowsFontEngine::QWindowsFontEngine(const QString &name, userData.insert(QStringLiteral("hFont"), QVariant::fromValue(hfont)); userData.insert(QStringLiteral("trueType"), QVariant(bool(ttf))); setUserData(userData); + + hasUnreliableOutline = hasGlyfTable() && hasEbdtTable(); } QWindowsFontEngine::~QWindowsFontEngine() @@ -662,6 +678,11 @@ void QWindowsFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qre } #endif // Q_CC_MINGW +bool QWindowsFontEngine::hasUnreliableGlyphOutline() const +{ + return hasUnreliableOutline; +} + qreal QWindowsFontEngine::minLeftBearing() const { if (lbearing == SHRT_MIN) diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h index 7a0803830c..0ddf778fa0 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.h +++ b/src/plugins/platforms/windows/qwindowsfontengine.h @@ -122,6 +122,8 @@ public: virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0); #endif + bool hasUnreliableGlyphOutline() const Q_DECL_OVERRIDE; + int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs) const; void getCMap(); @@ -136,6 +138,8 @@ private: QImage::Format mask_format); bool hasCFFTable() const; bool hasCMapTable() const; + bool hasGlyfTable() const; + bool hasEbdtTable() const; const QSharedPointer m_fontEngineData; @@ -146,6 +150,7 @@ private: uint stockFont : 1; uint ttf : 1; uint hasOutline : 1; + uint hasUnreliableOutline : 1; uint cffTable : 1; TEXTMETRIC tm; int lw; -- cgit v1.2.3 From 319e90dcdde7e0867a528105193b0b26d2044f92 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 6 May 2014 09:12:40 +0200 Subject: Windows: Use Format_ARGB32_Premultiplied for backing store with alpha. Following the logic in Qt 4's QRasterWindowSurface::setGeometry(). Task-number: QTBUG-30302 Change-Id: Ica571cfd5098e3d9faedefaff0880acfb2209958 Reviewed-by: Shawn Rutledge Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/qwindowsbackingstore.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index 1abf447709..34a9c1df5f 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -145,9 +145,8 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion ®ion) << " from: " << (m_image.isNull() ? QSize() : m_image->image().size()); } #endif - QImage::Format format = QWindowsNativeImage::systemFormat(); - if (format == QImage::Format_RGB32 && window()->format().hasAlpha()) - format = QImage::Format_ARGB32_Premultiplied; + const QImage::Format format = window()->format().hasAlpha() ? + QImage::Format_ARGB32_Premultiplied : QWindowsNativeImage::systemFormat(); QWindowsNativeImage *oldwni = m_image.data(); QWindowsNativeImage *newwni = new QWindowsNativeImage(size.width(), size.height(), format); -- cgit v1.2.3 From 2989b65afd497744ac08b3c55cc4f75908c46ecf Mon Sep 17 00:00:00 2001 From: Stanislav Ionascu Date: Fri, 28 Feb 2014 21:44:22 +0100 Subject: Testlib: Fix minor leak and crash when comparing lists 1) toString does not track the string it returns, thus it has to be deleted by the caller 2) on some platforms vsnprintf crashes if a null string is in the va_list Change-Id: Iecf94e93d3a2ddf4186ee20de1f495f2f92dcc60 Reviewed-by: Olivier Goffart --- src/testlib/qtest.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 7c9a7b2b3f..7d2f3cea72 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -201,11 +201,17 @@ inline bool qCompare(QList const &t1, QList const &t2, const char *actual, } for (int i = 0; isOk && i < actualSize; ++i) { if (!(t1.at(i) == t2.at(i))) { + char *val1 = toString(t1.at(i)); + char *val2 = toString(t2.at(i)); + qsnprintf(msg, sizeof(msg), "Compared lists differ at index %d.\n" " Actual (%s): %s\n" - " Expected (%s): %s", i, actual, toString(t1.at(i)), - expected, toString(t2.at(i))); + " Expected (%s): %s", i, actual, val1 ? val1 : "", + expected, val2 ? val2 : ""); isOk = false; + + delete [] val1; + delete [] val2; } } return compare_helper(isOk, msg, 0, 0, actual, expected, file, line); -- cgit v1.2.3 From c8db5397422783648fc687c337f42e9055873572 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Wed, 30 Apr 2014 18:38:19 +0200 Subject: Fix FT glyph outline to path conversion When the start point is not on the curve, the end point will be used as starting point for the QPainterPath, if it is on the curve - if it is not on the curve, the mid point between start and end point will be used. The origianl start point will still be used as a control point for the first bezier curve. Task-number: QTBUG-38601 Change-Id: I90e07f1141288873263f1f12fa51e6a248d0804f Reviewed-by: Fabian Bumberger Reviewed-by: Lars Knoll --- src/gui/text/qfontengine_ft.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index fe38755ffd..f5ca559d62 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -450,6 +450,7 @@ static void scaleOutline(FT_Face face, FT_GlyphSlot g, FT_Fixed x_scale, FT_Fixe } } +#define GLYPH2PATH_DEBUG QT_NO_QDEBUG_MACRO // qDebug void QFreetypeFace::addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoint &point, QPainterPath *path, FT_Fixed x_scale, FT_Fixed y_scale) { const qreal factor = 1/64.; @@ -461,22 +462,32 @@ void QFreetypeFace::addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoi int i = 0; for (int j = 0; j < g->outline.n_contours; ++j) { int last_point = g->outline.contours[j]; - QPointF start = cp + QPointF(g->outline.points[i].x*factor, -g->outline.points[i].y*factor); - if(!(g->outline.tags[i] & 1)) { - start += cp + QPointF(g->outline.points[last_point].x*factor, -g->outline.points[last_point].y*factor); - start /= 2; + GLYPH2PATH_DEBUG() << "contour:" << i << "to" << last_point; + QPointF start = QPointF(g->outline.points[i].x*factor, -g->outline.points[i].y*factor); + if (!(g->outline.tags[i] & 1)) { // start point is not on curve: + if (!(g->outline.tags[last_point] & 1)) { // end point is not on curve: + GLYPH2PATH_DEBUG() << " start and end point are not on curve"; + start = (QPointF(g->outline.points[last_point].x*factor, + -g->outline.points[last_point].y*factor) + start) / 2.0; + } else { + GLYPH2PATH_DEBUG() << " end point is on curve, start is not"; + start = QPointF(g->outline.points[last_point].x*factor, + -g->outline.points[last_point].y*factor); + } + --i; // to use original start point as control point below } -// qDebug("contour: %d -- %d", i, g->outline.contours[j]); -// qDebug("first point at %f %f", start.x(), start.y()); - path->moveTo(start); + start += cp; + GLYPH2PATH_DEBUG() << " start at" << start; + path->moveTo(start); QPointF c[4]; c[0] = start; int n = 1; while (i < last_point) { ++i; c[n] = cp + QPointF(g->outline.points[i].x*factor, -g->outline.points[i].y*factor); -// qDebug() << " i=" << i << " flag=" << (int)g->outline.tags[i] << "point=" << c[n]; + GLYPH2PATH_DEBUG() << " " << i << c[n] << "tag =" << (int)g->outline.tags[i] + << ": on curve =" << (bool)(g->outline.tags[i] & 1); ++n; switch (g->outline.tags[i] & 3) { case 2: @@ -498,7 +509,7 @@ void QFreetypeFace::addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoi case 1: case 3: if (n == 2) { -// qDebug() << "lineTo" << c[1]; + GLYPH2PATH_DEBUG() << " lineTo" << c[1]; path->lineTo(c[1]); c[0] = c[1]; n = 1; @@ -510,13 +521,14 @@ void QFreetypeFace::addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoi } break; } -// qDebug() << "cubicTo" << c[1] << c[2] << c[3]; + GLYPH2PATH_DEBUG() << " cubicTo" << c[1] << c[2] << c[3]; path->cubicTo(c[1], c[2], c[3]); c[0] = c[3]; n = 1; } + if (n == 1) { -// qDebug() << "closeSubpath"; + GLYPH2PATH_DEBUG() << " closeSubpath"; path->closeSubpath(); } else { c[3] = start; @@ -524,7 +536,7 @@ void QFreetypeFace::addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoi c[2] = (2*c[1] + c[3])/3; c[1] = (2*c[1] + c[0])/3; } -// qDebug() << "cubicTo" << c[1] << c[2] << c[3]; + GLYPH2PATH_DEBUG() << " close cubicTo" << c[1] << c[2] << c[3]; path->cubicTo(c[1], c[2], c[3]); } ++i; -- cgit v1.2.3 From fdcf66f10fd4f50f99c3a124626f6f4e6033a575 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 7 May 2014 10:14:50 +0200 Subject: Accessibility Android: Do not always append role MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-36584 Change-Id: Id14962a9eb7a6c3ea78cefcfcc053fac886ba8f7 Reviewed-by: Jan Arve Sæther --- src/plugins/platforms/android/androidjniaccessibility.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp index b987c49c9c..2891152c3d 100644 --- a/src/plugins/platforms/android/androidjniaccessibility.cpp +++ b/src/plugins/platforms/android/androidjniaccessibility.cpp @@ -184,8 +184,6 @@ if (!clazz) { \ desc = iface->text(QAccessible::Name); if (desc.isEmpty()) desc = iface->text(QAccessible::Description); - - desc += QChar(' ') + QString::fromUtf8(qAccessibleRoleString(iface->role())); } jstring jdesc = env->NewString((jchar*) desc.constData(), (jsize) desc.size()); @@ -216,12 +214,6 @@ if (!clazz) { \ } } - if ((iface->role() != QAccessible::NoRole) && - (iface->role() != QAccessible::Client) && - (iface->role() != QAccessible::Pane)) { - desc += QChar(' ') + QString::fromUtf8(qAccessibleRoleString(iface->role())); - } - CALL_METHOD(node, "setEnabled", "(Z)V", !state.disabled) //CALL_METHOD(node, "setFocusable", "(Z)V", state.focusable) CALL_METHOD(node, "setFocusable", "(Z)V", true) -- cgit v1.2.3 From bfa0d149f68eadf5cb1cd6eab8327850dc0bbbf9 Mon Sep 17 00:00:00 2001 From: Louai Al-Khanji Date: Mon, 5 May 2014 16:36:37 +0300 Subject: Direct2D QPA: Speed up text rendering After analysing text drawing performance two things seem to take up most of the time. The first is font lookup, the second is QVector initialization. To address the first point a per paint engine instance font cache is introduced. At the moment no mechanism exists to clear this cache and it is unbounded. To address the second point, we simply switch to using QVarLengthArray instead of QVector. In an artificial benchmark that draws text in a tight loop, the first change raised fps from ~70 to ~100. The second change further raised this number to ~115 fps. Change-Id: Iafa25c3e35bc42bd7c1582b0636e721c5193b494 Reviewed-by: Friedemann Kleint --- .../direct2d/qwindowsdirect2dpaintengine.cpp | 110 +++++++++++---------- .../direct2d/qwindowsdirect2dpaintengine.h | 3 + 2 files changed, 60 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp index 58c30b6eeb..6e8d9b0baf 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp @@ -58,7 +58,6 @@ #include #include -#include using Microsoft::WRL::ComPtr; QT_BEGIN_NAMESPACE @@ -346,6 +345,8 @@ public: QPointF currentBrushOrigin; + QHash< QFont, ComPtr > fontCache; + struct { bool emulate; QPen qpen; @@ -1291,44 +1292,6 @@ void QWindowsDirect2DPaintEngine::drawPixmap(const QRectF &r, } } -static ComPtr fontFaceFromFontEngine(QFontEngine *fe) -{ - ComPtr fontFace; - - switch (fe->type()) { - case QFontEngine::Win: - { - QWindowsFontEngine *wfe = static_cast(fe); - QSharedPointer wfed = wfe->fontEngineData(); - - HGDIOBJ oldfont = wfe->selectDesignFont(); - HRESULT hr = QWindowsDirect2DContext::instance()->dwriteGdiInterop()->CreateFontFaceFromHdc(wfed->hdc, &fontFace); - DeleteObject(SelectObject(wfed->hdc, oldfont)); - if (FAILED(hr)) - qWarning("%s: Could not create DirectWrite fontface from HDC: %#x", __FUNCTION__, hr); - - } - break; - -#ifndef QT_NO_DIRECTWRITE - - case QFontEngine::DirectWrite: - { - QWindowsFontEngineDirectWrite *wfedw = static_cast(fe); - fontFace = wfedw->directWriteFontFace(); - } - break; - -#endif // QT_NO_DIRECTWRITE - - default: - qWarning("%s: Unknown font engine!", __FUNCTION__); - break; - } - - return fontFace; -} - void QWindowsDirect2DPaintEngine::drawStaticTextItem(QStaticTextItem *staticTextItem) { Q_D(QWindowsDirect2DPaintEngine); @@ -1340,24 +1303,22 @@ void QWindowsDirect2DPaintEngine::drawStaticTextItem(QStaticTextItem *staticText ensurePen(); // If we can't support the current configuration with Direct2D, fall back to slow path - // Most common cases are perspective transform and gradient brush as pen - if ((state()->transform().isAffine() == false) || d->pen.emulate) { + if (emulationRequired(PenEmulation)) { QPaintEngineEx::drawStaticTextItem(staticTextItem); return; } - ComPtr fontFace = fontFaceFromFontEngine(staticTextItem->fontEngine()); + ComPtr fontFace = fontFaceFromFontEngine(staticTextItem->font, staticTextItem->fontEngine()); if (!fontFace) { qWarning("%s: Could not find font - falling back to slow text rendering path.", __FUNCTION__); QPaintEngineEx::drawStaticTextItem(staticTextItem); return; } - QVector glyphIndices(staticTextItem->numGlyphs); - QVector glyphAdvances(staticTextItem->numGlyphs); - QVector glyphOffsets(staticTextItem->numGlyphs); + QVarLengthArray glyphIndices(staticTextItem->numGlyphs); + QVarLengthArray glyphAdvances(staticTextItem->numGlyphs); + QVarLengthArray glyphOffsets(staticTextItem->numGlyphs); - // XXX Are we generating a lot of cache misses here? for (int i = 0; i < staticTextItem->numGlyphs; i++) { glyphIndices[i] = UINT16(staticTextItem->glyphs[i]); // Imperfect conversion here @@ -1390,24 +1351,22 @@ void QWindowsDirect2DPaintEngine::drawTextItem(const QPointF &p, const QTextItem ensurePen(); // If we can't support the current configuration with Direct2D, fall back to slow path - // Most common cases are perspective transform and gradient brush as pen - if ((state()->transform().isAffine() == false) || d->pen.emulate) { + if (emulationRequired(PenEmulation)) { QPaintEngine::drawTextItem(p, textItem); return; } - ComPtr fontFace = fontFaceFromFontEngine(ti.fontEngine); + ComPtr fontFace = fontFaceFromFontEngine(*ti.f, ti.fontEngine); if (!fontFace) { qWarning("%s: Could not find font - falling back to slow text rendering path.", __FUNCTION__); QPaintEngine::drawTextItem(p, textItem); return; } - QVector glyphIndices(ti.glyphs.numGlyphs); - QVector glyphAdvances(ti.glyphs.numGlyphs); - QVector glyphOffsets(ti.glyphs.numGlyphs); + QVarLengthArray glyphIndices(ti.glyphs.numGlyphs); + QVarLengthArray glyphAdvances(ti.glyphs.numGlyphs); + QVarLengthArray glyphOffsets(ti.glyphs.numGlyphs); - // XXX Are we generating a lot of cache misses here? for (int i = 0; i < ti.glyphs.numGlyphs; i++) { glyphIndices[i] = UINT16(ti.glyphs.glyphs[i]); // Imperfect conversion here glyphAdvances[i] = ti.glyphs.effectiveAdvance(i).toReal(); @@ -1618,4 +1577,49 @@ void QWindowsDirect2DPaintEngine::adjustForAliasing(QPointF *point) (*point) += adjustment; } +Microsoft::WRL::ComPtr QWindowsDirect2DPaintEngine::fontFaceFromFontEngine(const QFont &font, QFontEngine *fe) +{ + Q_D(QWindowsDirect2DPaintEngine); + + ComPtr fontFace = d->fontCache.value(font); + if (fontFace) + return fontFace; + + switch (fe->type()) { + case QFontEngine::Win: + { + QWindowsFontEngine *wfe = static_cast(fe); + QSharedPointer wfed = wfe->fontEngineData(); + + HGDIOBJ oldfont = wfe->selectDesignFont(); + HRESULT hr = QWindowsDirect2DContext::instance()->dwriteGdiInterop()->CreateFontFaceFromHdc(wfed->hdc, &fontFace); + DeleteObject(SelectObject(wfed->hdc, oldfont)); + if (FAILED(hr)) + qWarning("%s: Could not create DirectWrite fontface from HDC: %#x", __FUNCTION__, hr); + + } + break; + +#ifndef QT_NO_DIRECTWRITE + + case QFontEngine::DirectWrite: + { + QWindowsFontEngineDirectWrite *wfedw = static_cast(fe); + fontFace = wfedw->directWriteFontFace(); + } + break; + +#endif // QT_NO_DIRECTWRITE + + default: + qWarning("%s: Unknown font engine!", __FUNCTION__); + break; + } + + if (fontFace) + d->fontCache.insert(font, fontFace); + + return fontFace; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h index badd7a7688..fb9b7acec3 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h @@ -47,6 +47,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -114,6 +115,8 @@ private: bool antiAliasingEnabled() const; void adjustForAliasing(QRectF *rect); void adjustForAliasing(QPointF *point); + + Microsoft::WRL::ComPtr fontFaceFromFontEngine(const QFont &font, QFontEngine *fe); }; QT_END_NAMESPACE -- cgit v1.2.3 From 70accc289a077b2d05250676ed33369eeaa7df49 Mon Sep 17 00:00:00 2001 From: Louai Al-Khanji Date: Mon, 5 May 2014 14:49:04 +0300 Subject: Direct2D QPA: Check Direct2D version Since we require a relatively recent system, check the version of the direct2d dll on disk and report an error to the user if it is too old. Previously only a cryptic runtime error resulted from a direct2d version that was too old. Change-Id: I6c3955e1a98326fca6bcdc871b0a25291391ba88 Reviewed-by: Risto Avila Reviewed-by: Friedemann Kleint --- src/plugins/platforms/direct2d/direct2d.pro | 2 +- .../direct2d/qwindowsdirect2dintegration.cpp | 135 ++++++++++++++++++++- 2 files changed, 135 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/direct2d/direct2d.pro b/src/plugins/platforms/direct2d/direct2d.pro index 439d31fb56..03997f2737 100644 --- a/src/plugins/platforms/direct2d/direct2d.pro +++ b/src/plugins/platforms/direct2d/direct2d.pro @@ -9,7 +9,7 @@ QT *= core-private QT *= gui-private QT *= platformsupport-private -LIBS *= -ld2d1 -ld3d11 -ldwrite +LIBS *= -ld2d1 -ld3d11 -ldwrite -lVersion include(../windows/windows.pri) diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp index 1a26d7029e..44fc7aa927 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp @@ -48,7 +48,8 @@ #include "qwindowscontext.h" -#include +#include +#include #include #include @@ -61,8 +62,140 @@ public: QWindowsDirect2DContext m_d2dContext; }; +class Direct2DVersion +{ +private: + Direct2DVersion() + : partOne(0) + , partTwo(0) + , partThree(0) + , partFour(0) + {} + + Direct2DVersion(int one, int two, int three, int four) + : partOne(one) + , partTwo(two) + , partThree(three) + , partFour(four) + {} + +public: + // 6.2.9200.16765 corresponds to Direct2D 1.1 on Windows 7 SP1 with Platform Update + enum { + D2DMinVersionPart1 = 6, + D2DMinVersionPart2 = 2, + D2DMinVersionPart3 = 9200, + D2DMinVersionPart4 = 16765 + }; + + static Direct2DVersion systemVersion() { + static const int bufSize = 512; + TCHAR filename[bufSize]; + + UINT i = GetSystemDirectory(filename, bufSize); + if (i > 0 && i < MAX_PATH) { + if (_tcscat_s(filename, MAX_PATH, __TEXT("\\d2d1.dll")) == 0) { + DWORD versionInfoSize = GetFileVersionInfoSize(filename, NULL); + if (versionInfoSize) { + QVector info(versionInfoSize); + if (GetFileVersionInfo(filename, NULL, versionInfoSize, info.data())) { + UINT size; + DWORD *fi; + + if (VerQueryValue(info.constData(), __TEXT("\\"), (LPVOID *) &fi, &size) && size) { + VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *) fi; + return Direct2DVersion(HIWORD(verInfo->dwFileVersionMS), + LOWORD(verInfo->dwFileVersionMS), + HIWORD(verInfo->dwFileVersionLS), + LOWORD(verInfo->dwFileVersionLS)); + } + } + } + } + } + + return Direct2DVersion(); + } + + static Direct2DVersion minimumVersion() { + return Direct2DVersion(D2DMinVersionPart1, + D2DMinVersionPart2, + D2DMinVersionPart3, + D2DMinVersionPart4); + } + + bool isValid() const { + return partOne || partTwo || partThree || partFour; + } + + bool operator<(const Direct2DVersion &other) { + int c = cmp(partOne, other.partOne); + if (c > 0) + return false; + if (c < 0) + return true; + + c = cmp(partTwo, other.partTwo); + if (c > 0) + return false; + if (c < 0) + return true; + + c = cmp(partThree, other.partThree); + if (c > 0) + return false; + if (c < 0) + return true; + + c = cmp(partFour, other.partFour); + if (c > 0) + return false; + if (c < 0) + return true; + + return false; + } + + static Q_DECL_CONSTEXPR int cmp(int a, int b) { + return a - b; + } + + int partOne, partTwo, partThree, partFour; +}; + QWindowsDirect2DIntegration *QWindowsDirect2DIntegration::create(const QStringList ¶mList) { + Direct2DVersion systemVersion = Direct2DVersion::systemVersion(); + + if (systemVersion.isValid() && systemVersion < Direct2DVersion::minimumVersion()) { + QString msg = QCoreApplication::translate("QWindowsDirect2DIntegration", + "Qt cannot load the direct2d platform plugin because " \ + "the Direct2D version on this system is too old. The " \ + "minimum system requirement for this platform plugin " \ + "is Windows 7 SP1 with Platform Update.\n\n" \ + "The minimum Direct2D version required is %1.%2.%3.%4. " \ + "The Direct2D version on this system is %5.%6.%7.%8."); + + msg = msg.arg(Direct2DVersion::D2DMinVersionPart1) + .arg(Direct2DVersion::D2DMinVersionPart2) + .arg(Direct2DVersion::D2DMinVersionPart3) + .arg(Direct2DVersion::D2DMinVersionPart4) + .arg(systemVersion.partOne) + .arg(systemVersion.partTwo) + .arg(systemVersion.partThree) + .arg(systemVersion.partFour); + + QString caption = QCoreApplication::translate("QWindowsDirect2DIntegration", + "Cannot load direct2d platform plugin"); + + MessageBoxW(NULL, + msg.toStdWString().c_str(), + caption.toStdWString().c_str(), + MB_OK | MB_ICONERROR); + + return Q_NULLPTR; + } + QWindowsDirect2DIntegration *integration = new QWindowsDirect2DIntegration(paramList); if (!integration->init()) { -- cgit v1.2.3 From f230223aef8990ec172f825de8444f67f6d1aa6f Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 8 May 2014 00:54:21 -0400 Subject: Remove trailing whitespace. Change-Id: Id487c8951d7f258c57fa71fd35a60ddb8c5a3fb2 Reviewed-by: Thiago Macieira --- src/widgets/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 174e1dabfa..e165b8aa68 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1696,7 +1696,7 @@ QMacStylePrivate::QMacStylePrivate() if (ptrHIShapeGetBounds == 0) { QLibrary library(QLatin1String("/System/Library/Frameworks/Carbon.framework/Carbon")); library.setLoadHints(QLibrary::ExportExternalSymbolsHint); - ptrHIShapeGetBounds = reinterpret_cast(library.resolve("HIShapeGetBounds")); + ptrHIShapeGetBounds = reinterpret_cast(library.resolve("HIShapeGetBounds")); } } -- cgit v1.2.3 From d7e0c926b5183f94abda4b2ebfd505d9ae68e541 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 5 May 2014 12:27:17 +0200 Subject: Android: remove the duplicate registration for qt accessibility Change-Id: I3241138e39b93657aee0564442f22ad0c40328d4 Reviewed-by: Frederik Gladhorn Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjnimain.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index ff1a40bfc5..2998762cc3 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -769,7 +769,6 @@ Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void */*reserved*/) || !QtAndroidInput::registerNatives(env) || !QtAndroidClipboard::registerNatives(env) || !QtAndroidMenu::registerNatives(env) - || !QtAndroidAccessibility::registerNatives(env) || !QtAndroidDialogHelpers::registerNatives(env)) { __android_log_print(ANDROID_LOG_FATAL, "Qt", "registerNatives failed"); return -1; -- cgit v1.2.3 From 36caeadb4db9fab1cf581f9a3bb3c4a2e14de49a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 6 May 2014 16:37:54 +0200 Subject: iOS: Gracefully handle cancelling of subset of active touches When applying the five-finger pinch gesture, we get a touchesCancelled callback with all five touch points, but the pinch gesture ends when the second to last finger is released from the screen. The last finger will not emit any more touch events, _but_, will contribute to starting another pinch gesture. That second pinch gesture will _not_ trigger a touchesCancelled event when starting, but as each finger is released, and we may get touchesMoved events for the remaining fingers. The event property 'allTouches' contains one less touch point than it should, so this behavior is likely a bug in the iOS system gesture recognizer, but have to take it into account when maintaining the Qt touch state. We do this by assuming that there are no cases where a sub-set of the active touch events are intentionally cancelled, and always clear the list of active touches. Task-number: QTBUG-37304 Change-Id: Icee79978508ecbc6854c0fb55d2da48b99d92f96 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qioswindow.mm | 36 +++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index ebff2c25a1..6f5c96cfc1 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -292,19 +292,33 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - if (!touches && m_activeTouches.isEmpty()) + if (m_activeTouches.isEmpty()) return; - if (!touches) { - m_activeTouches.clear(); - } else { - for (UITouch *touch in touches) - m_activeTouches.remove(touch); - - Q_ASSERT_X(m_activeTouches.isEmpty(), Q_FUNC_INFO, - "Subset of active touches cancelled by UIKit"); - } - + // When four-finger swiping, we get a touchesCancelled callback + // which includes all four touch points. The swipe gesture is + // then active until all four touches have been released, and + // we start getting touchesBegan events again. + + // When five-finger pinching, we also get a touchesCancelled + // callback with all five touch points, but the pinch gesture + // ends when the second to last finger is released from the + // screen. The last finger will not emit any more touch + // events, _but_, will contribute to starting another pinch + // gesture. That second pinch gesture will _not_ trigger a + // touchesCancelled event when starting, but as each finger + // is released, and we may get touchesMoved events for the + // remaining fingers. [event allTouches] also contains one + // less touch point than it should, so this behavior is + // likely a bug in the iOS system gesture recognizer, but we + // have to take it into account when maintaining the Qt state. + // We do this by assuming that there are no cases where a + // sub-set of the active touch events are intentionally cancelled. + + if (touches && (static_cast([touches count]) != m_activeTouches.count())) + qWarning("Subset of active touches cancelled by UIKit"); + + m_activeTouches.clear(); m_nextTouchId = 0; NSTimeInterval timestamp = event ? event.timestamp : [[NSProcessInfo processInfo] systemUptime]; -- cgit v1.2.3 From eed30131e168d12ed44e9ed469bef70cd4a80f4e Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 6 May 2014 18:13:45 +0200 Subject: Android: text cursor position fixes The Android input method protocol specifies that finishComposingText() should not move the cursor. Since Qt likes to move the cursor to the end of the newly committed text, we have to explicitly move the cursor to where the preedit cursor used to be. Fortunately we already keep track of that. Also implement support for the newCursorPosition argument to commitText() since the function needed to be rewritten anyway. (It was calling finishComposingText().) Task-number: QTBUG-38794 Change-Id: Iff2c43bdbd3dda812ccdc71da63f3fa730474eef Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../platforms/android/qandroidinputcontext.cpp | 55 +++++++++++++++++----- 1 file changed, 44 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index e255a49ac7..c2e5f83639 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -591,19 +591,37 @@ jboolean QAndroidInputContext::endBatchEdit() return JNI_TRUE; } -jboolean QAndroidInputContext::commitText(const QString &text, jint /*newCursorPosition*/) +/* + Android docs say: If composing, replace compose text with \a text. + Otherwise insert \a text at current cursor position. + + The cursor should then be moved to newCursorPosition. If > 0, this is + relative to the end of the text - 1; if <= 0, this is relative to the start + of the text. updateSelection() needs to be called. +*/ +jboolean QAndroidInputContext::commitText(const QString &text, jint newCursorPosition) { - QSharedPointer query = focusObjectInputMethodQuery(); - if (query.isNull()) - return JNI_FALSE; + QInputMethodEvent event; + event.setCommitString(text); + sendInputMethodEvent(&event); + clear(); + // Qt has now put the cursor at the end of the text, corresponding to newCursorPosition == 1 + if (newCursorPosition != 1) { + QSharedPointer query = focusObjectInputMethodQuery(); + if (!query.isNull()) { + QList attributes; + const int localPos = query->value(Qt::ImCursorPosition).toInt(); + const int newLocalPos = newCursorPosition > 0 + ? localPos + newCursorPosition - 1 + : localPos - text.length() + newCursorPosition; + //move the cursor + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, + newLocalPos, 0, QVariant())); + } + } - const int cursorPos = getAbsoluteCursorPosition(query); - m_composingText = text; - m_composingTextStart = cursorPos; - m_composingCursor = cursorPos + text.length(); - finishComposingText(); - //### move cursor to newCursorPosition and call updateCursorPosition() + updateCursorPosition(); return JNI_TRUE; } @@ -624,9 +642,24 @@ jboolean QAndroidInputContext::deleteSurroundingText(jint leftLength, jint right return JNI_TRUE; } +// Android docs say the cursor must not move jboolean QAndroidInputContext::finishComposingText() { - QInputMethodEvent event; + QSharedPointer query = focusObjectInputMethodQuery(); + if (query.isNull()) + return JNI_FALSE; + + if (m_composingText.isEmpty()) + return JNI_TRUE; // not composing + + const int blockPos = getBlockPosition(query); + const int localCursorPos = m_composingCursor - blockPos; + + // Moving Qt's cursor to where the preedit cursor used to be + QList attributes; + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, localCursorPos, 0, QVariant())); + + QInputMethodEvent event(QString(), attributes); event.setCommitString(m_composingText); sendInputMethodEvent(&event); clear(); -- cgit v1.2.3 From 9deafdad5b6bee4efc579823ca8f2208c656a340 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Wed, 7 May 2014 11:52:25 +0200 Subject: Avoid drawing when the QOpenGLWidget isn't mapped Do as QGLWidget::updateGL does and avoid calling paintGL in updateGL when we we don't have a valid QSurface to draw on. We currently end up calling makeCurrent on the context with a null QSurface in that case, which is the equivalend of doneCurrent, and causes QOpenGLContext::currentContext to return null later when paintGL is called on the subclass. Change-Id: I712ee59274855457b0e4de3757754f56b3528955 Reviewed-by: Laszlo Agocs Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qopenglwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 10be5aef16..cbefb8a6bf 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -147,7 +147,7 @@ void QOpenGLWidget::paintGL() void QOpenGLWidget::updateGL() { Q_D(QOpenGLWidget); - if (d->uninitialized) + if (d->uninitialized || !d->surface()) return; makeCurrent(); -- cgit v1.2.3 From 730697d1b9d3d690b4224f670d1fb01e89254bf3 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 7 May 2014 12:55:58 +0200 Subject: Accessibility Android: Make debug tags consistent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I712e64002234d546365b44ca15ae93e8decac882 Reviewed-by: Jan Arve Sæther --- src/plugins/platforms/android/androidjniaccessibility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp index 2891152c3d..a38741cc91 100644 --- a/src/plugins/platforms/android/androidjniaccessibility.cpp +++ b/src/plugins/platforms/android/androidjniaccessibility.cpp @@ -50,7 +50,7 @@ #include "qdebug.h" -static const char m_qtTag[] = "QtA11y"; +static const char m_qtTag[] = "Qt A11Y"; static const char m_classErrorMsg[] = "Can't find class \"%s\""; static const char m_methodErrorMsg[] = "Can't find method \"%s%s\""; -- cgit v1.2.3 From 9c4996b709ee5cebb1513bb7fe4703caee90f304 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Wed, 7 May 2014 11:02:23 +0200 Subject: kms plugin: do not needlessly query drm information twice QKmsDevice already requested the drmModeRes and drmModeConnector information. Simply pass them to the QKmsScreen constructor instead of requesting and freeing them there again. Change-Id: I4897d76d7b13d83297c928b6e10e17ccdfdbd242 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/kms/qkmsdevice.cpp | 5 ++--- src/plugins/platforms/kms/qkmsscreen.cpp | 15 ++++----------- src/plugins/platforms/kms/qkmsscreen.h | 4 ++-- 3 files changed, 8 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/kms/qkmsdevice.cpp b/src/plugins/platforms/kms/qkmsdevice.cpp index 1e08c6f301..8e669fe7d5 100644 --- a/src/plugins/platforms/kms/qkmsdevice.cpp +++ b/src/plugins/platforms/kms/qkmsdevice.cpp @@ -85,8 +85,7 @@ QKmsDevice::~QKmsDevice() void QKmsDevice::createScreens() { - drmModeRes *resources = 0; - resources = drmModeGetResources(m_fd); + drmModeRes *resources = drmModeGetResources(m_fd); if (!resources) qFatal("drmModeGetResources failed"); @@ -95,7 +94,7 @@ void QKmsDevice::createScreens() drmModeConnector *connector = 0; connector = drmModeGetConnector(m_fd, resources->connectors[i]); if (connector && connector->connection == DRM_MODE_CONNECTED) { - m_integration->addScreen(new QKmsScreen(this, connector->connector_id)); + m_integration->addScreen(new QKmsScreen(this, resources, connector)); } drmModeFreeConnector(connector); } diff --git a/src/plugins/platforms/kms/qkmsscreen.cpp b/src/plugins/platforms/kms/qkmsscreen.cpp index ad1a45b459..2749139330 100644 --- a/src/plugins/platforms/kms/qkmsscreen.cpp +++ b/src/plugins/platforms/kms/qkmsscreen.cpp @@ -63,18 +63,18 @@ static drmModeModeInfo builtin_1024x768 = { "1024x768" }; -QKmsScreen::QKmsScreen(QKmsDevice *device, int connectorId) +QKmsScreen::QKmsScreen(QKmsDevice *device, const drmModeRes *resources, const drmModeConnector *connector) : m_device(device), m_current_bo(0), m_next_bo(0), - m_connectorId(connectorId), + m_connectorId(connector->connector_id), m_depth(32), m_format(QImage::Format_Invalid), m_eglWindowSurface(EGL_NO_SURFACE), m_modeSet(false) { m_cursor = new QKmsCursor(this); - initializeScreenMode(); + initializeScreenMode(resources, connector); } QKmsScreen::~QKmsScreen() @@ -114,14 +114,9 @@ QPlatformCursor *QKmsScreen::cursor() const return m_cursor; } -void QKmsScreen::initializeScreenMode() +void QKmsScreen::initializeScreenMode(const drmModeRes *resources, const drmModeConnector *connector) { //Determine optimal mode for screen - drmModeRes *resources = drmModeGetResources(m_device->fd()); - if (!resources) - qFatal("drmModeGetResources failed"); - - drmModeConnector *connector = drmModeGetConnector(m_device->fd(), m_connectorId); drmModeModeInfo *mode = 0; for (int i = 0; i < connector->count_modes; ++i) { if (connector->modes[i].type & DRM_MODE_TYPE_PREFERRED) { @@ -162,8 +157,6 @@ void QKmsScreen::initializeScreenMode() qDebug() << "created gbm surface" << m_gbmSurface << m_mode.hdisplay << m_mode.vdisplay; //Cleanup drmModeFreeEncoder(encoder); - drmModeFreeConnector(connector); - drmModeFreeResources(resources); } QSurfaceFormat QKmsScreen::tweakFormat(const QSurfaceFormat &format) diff --git a/src/plugins/platforms/kms/qkmsscreen.h b/src/plugins/platforms/kms/qkmsscreen.h index 5ae5a1062b..1fa8dbb763 100644 --- a/src/plugins/platforms/kms/qkmsscreen.h +++ b/src/plugins/platforms/kms/qkmsscreen.h @@ -68,7 +68,7 @@ class QKmsContext; class QKmsScreen : public QPlatformScreen { public: - QKmsScreen(QKmsDevice *device, int connectorId); + QKmsScreen(QKmsDevice *device, const drmModeRes *resources, const drmModeConnector *connector); ~QKmsScreen(); QRect geometry() const; @@ -94,7 +94,7 @@ public: private: void performPageFlip(); - void initializeScreenMode(); + void initializeScreenMode(const drmModeRes *resources, const drmModeConnector *connector); QKmsDevice *m_device; gbm_bo *m_current_bo; -- cgit v1.2.3 From 6f6cfda8c459ab9c0a311e8643ef2534c5e194c2 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Wed, 7 May 2014 11:04:36 +0200 Subject: kms plugin: use first returned mode if no preferred one is present The list of returned modes is scanned for the first one marked as preferred, and that is used. If no preferred mode was found then the builtin default mode of 1024x768 is used. Use that builtin mode only if no modes were returned at all, pick the first one if any were returned. Change-Id: Ib355cc92219ced093c605f49dae4e34ff244b639 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/kms/qkmsscreen.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/kms/qkmsscreen.cpp b/src/plugins/platforms/kms/qkmsscreen.cpp index 2749139330..a930aa6545 100644 --- a/src/plugins/platforms/kms/qkmsscreen.cpp +++ b/src/plugins/platforms/kms/qkmsscreen.cpp @@ -124,8 +124,12 @@ void QKmsScreen::initializeScreenMode(const drmModeRes *resources, const drmMode break; } } - if (!mode) - mode = &builtin_1024x768; + if (!mode) { + if (connector->count_modes > 0) + mode = &connector->modes[0]; + else + mode = &builtin_1024x768; + } drmModeEncoder *encoder = drmModeGetEncoder(m_device->fd(), connector->encoders[0]); if (encoder == 0) -- cgit v1.2.3