diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-12-09 01:00:42 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-12-09 01:00:43 +0100 |
commit | fc116049649a6aef06f07dec3d89cc5d44c41723 (patch) | |
tree | 9c545c77faa4385d50e016970dbf70c0c199f4c9 | |
parent | f8c5c1356465f503e1a8357ceff01bb956d51c9e (diff) | |
parent | d36a4fc19709e6047fe846b36731b59909218b6d (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I10ae61ec6867b38601d85d6fc34e1f6a6ba0cc11
20 files changed, 541 insertions, 94 deletions
diff --git a/config.tests/x11/xrender/xrender.pro b/config.tests/x11/xrender/xrender.pro index ab5c5efa77..6244ae6b47 100644 --- a/config.tests/x11/xrender/xrender.pro +++ b/config.tests/x11/xrender/xrender.pro @@ -1,3 +1,2 @@ SOURCES = xrender.cpp -CONFIG += x11 CONFIG -= qt diff --git a/mkspecs/features/qmake_use.prf b/mkspecs/features/qmake_use.prf index dba45de92a..8159e471a2 100644 --- a/mkspecs/features/qmake_use.prf +++ b/mkspecs/features/qmake_use.prf @@ -1,23 +1,31 @@ suffix = for(ever) { - QMAKE_USE$${suffix} = $$unique(QMAKE_USE$${suffix}) + CC_USES = + LD_USES = for (use, QMAKE_USE$${suffix}) { use = $$split(use, /) name = $$take_first(use) nu = $$upper($$name) + !contains(use, linkonly): CC_USES += $$nu + !contains(use, nolink): LD_USES += $$nu + } + CC_USES = $$resolve_depends(CC_USES, QMAKE_DEPENDS_, _CC) + for (nu, CC_USES) { + !defined(QMAKE_LIBS_$$nu, var): \ + error("Library '$$lower($$nu)' is not defined.") + + DEFINES += $$eval(QMAKE_DEFINES_$${nu}) + INCLUDEPATH += $$eval(QMAKE_INCDIR_$${nu}) + } + LD_USES = $$resolve_depends(LD_USES, QMAKE_DEPENDS_, _LD) + for (nu, LD_USES) { !defined(QMAKE_LIBS_$$nu, var): \ - error("Library '$$name' is not defined.") + error("Library '$$lower($$nu)' is not defined.") - !contains(use, nolink) { - debug: \ - LIBS$${suffix} += $$eval(QMAKE_LIBS_$${nu}_DEBUG) $$eval(QMAKE_LIBS_$$nu) - else: \ - LIBS$${suffix} += $$eval(QMAKE_LIBS_$${nu}_RELEASE) $$eval(QMAKE_LIBS_$$nu) - } - !contains(use, linkonly) { - DEFINES += $$eval(QMAKE_DEFINES_$${nu}) - INCLUDEPATH += $$eval(QMAKE_INCDIR_$${nu}) - } + debug: \ + LIBS$${suffix} += $$eval(QMAKE_LIBS_$${nu}_DEBUG) $$eval(QMAKE_LIBS_$$nu) + else: \ + LIBS$${suffix} += $$eval(QMAKE_LIBS_$${nu}_RELEASE) $$eval(QMAKE_LIBS_$$nu) } !isEmpty(suffix): break() suffix = "_PRIVATE" diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index d75365cd0a..d8f5af5404 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -743,6 +743,21 @@ defineTest(qtConfLibrary_pkgConfig) { !qtConfResolvePathIncs($${1}.includedir, $$includes): \ return(false) $${1}.defines = $$defines + + # now remove the content of the transitive deps we know about. + largs = $$qtConfAllLibraryArgs($$eval($${2}.dependencies)) + for (la, largs): \ + eval("$$la") + USES = $$eval($$list($$upper($$QMAKE_USE))) + # _CC == _LD for configure's library sources, so pick first arbitrarily. + DEPS = $$resolve_depends(USES, QMAKE_DEPENDS_, _CC) + for (DEP, DEPS) { + $${1}.libs -= $$eval(QMAKE_LIBS_$${DEP}) + $${1}.includedir -= $$eval(QMAKE_INCDIR_$${DEP}) + $${1}.defines -= $$eval(QMAKE_DEFINES_$${DEP}) + } + export($${1}.libs) + export($${1}.includedir) export($${1}.defines) return(true) @@ -776,20 +791,36 @@ defineReplace(qtConfLibraryArgs) { defines = $$eval($${1}.defines) !isEmpty(defines): \ qmake_args += "QMAKE_DEFINES_$${NAME} = $$val_escape(defines)" + depends = $$eval($${2}.dependencies) + !isEmpty(depends) { + dep_uses = + for (use, depends): \ + dep_uses += $$section(use, :, 1, 1) + qmake_args += \ + "QMAKE_DEPENDS_$${NAME}_CC = $$upper($$dep_uses)" \ + "QMAKE_DEPENDS_$${NAME}_LD = $$upper($$dep_uses)" + } return($$qmake_args) } defineReplace(qtConfAllLibraryArgs) { isEmpty(1): return() dep_uses = + for (use, 1): \ + dep_uses += $$section(use, :, 1, 1) dep_args = - for (use, 1) { + seen = + for(ever) { + isEmpty(1): break() + use = $$take_last(1) + contains(seen, $$use): next() + seen += $$use use_cfg = $$section(use, :, 0, 0) - use_lib = $$section(use, :, 1, 1) - dep_uses += $$use_lib !isEmpty(use_cfg) { + use_lib = $$section(use, :, 1, 1) lpfx = $${use_cfg}.libraries.$$use_lib - dep_args += $$qtConfLibraryArgs($${lpfx}.sources.$$eval($${lpfx}.source)) + dep_args += $$qtConfLibraryArgs($${lpfx}.sources.$$eval($${lpfx}.source), $$lpfx) + 1 += $$eval($${lpfx}.dependencies) } } return("QMAKE_USE += $$dep_uses" $$dep_args) @@ -818,6 +849,24 @@ defineTest(qtConfExportLibrary) { !isEmpty(defines): qtConfOutputVar(assign, $$output, QMAKE_DEFINES_$$NAME, $$defines) includes = $$eval($${spfx}.includedir) !isEmpty(includes): qtConfOutputVar(assign, $$output, QMAKE_INCDIR_$$NAME, $$includes) + uses = $$eval($${lpfx}.dependencies) + !isEmpty(uses) { + # FIXME: ideally, we would export transitive deps only for static + # libs, to not extend the link interface unduly. however, the system + # does currently not differentiate between public and private deps. + depends = + for (use, uses) { + use_cfg = $$section(use, :, 0, 0) + use_lib = $$section(use, :, 1, 1) + !isEmpty(use_cfg): \ + depends += $$upper($$eval($${use_cfg}.libraries.$${use_lib}.export)) + else: \ + depends += $$upper($$use_lib) + } + # we use suffixes instead of infixes, because $$resolve_depends() demands it. + qtConfOutputVar(assign, $$output, QMAKE_DEPENDS_$${NAME}_CC, $$depends) + qtConfOutputVar(assign, $$output, QMAKE_DEPENDS_$${NAME}_LD, $$depends) + } !isEmpty($${currentConfig}.module): \ qtConfExtendVar($$output, "QT.$${currentModule}_private.libraries", $$name) } @@ -843,7 +892,8 @@ defineTest(qtConfHandleLibrary) { export($${lpfx}.result) return() } - resolved_uses = $$eval($${lpfx}.resolved_uses) + $${lpfx}.dependencies = $$eval($${lpfx}.resolved_uses) + export($${lpfx}.dependencies) qtConfLoadResult($${lpfx}, $$1, "library") { $$eval($${lpfx}.result): \ @@ -881,7 +931,7 @@ defineTest(qtConfHandleLibrary) { # if the library defines a test, use it to verify the source. !isEmpty($${lpfx}.test)|!isEmpty($${lpfx}.test._KEYS_) { - $${lpfx}.resolved_uses = $$currentConfig:$$1 $$resolved_uses + $${lpfx}.resolved_uses = $$currentConfig:$$1 $${lpfx}.host = $$eval($${spfx}.host) !qtConfTest_compile($$lpfx) { qtLog(" => source failed verification.") diff --git a/mkspecs/features/qt_helper_lib.prf b/mkspecs/features/qt_helper_lib.prf index 1a8446acb4..05d3b941bd 100644 --- a/mkspecs/features/qt_helper_lib.prf +++ b/mkspecs/features/qt_helper_lib.prf @@ -41,7 +41,20 @@ THE_TARGET = $$qt5LibraryTarget($$TARGET) prefix = $$QMAKE_PREFIX_SHLIB suffix = $$QMAKE_EXTENSION_SHLIB } + CC_USES = + LD_USES = + for (use, QMAKE_USE) { + use = $$split(use, /) + name = $$take_first(use) + nu = $$upper($$name) + !contains(use, linkonly): CC_USES += $$nu + !contains(use, nolink): LD_USES += $$nu + } + CC_USES = $$unique(CC_USES) + LD_USES = $$unique(LD_USES) MODULE_PRI_CONT = \ + "QMAKE_DEPENDS_$${ucmodule}_CC =$$join(CC_USES, " ", " ")" \ + "QMAKE_DEPENDS_$${ucmodule}_LD =$$join(LD_USES, " ", " ")" \ "QMAKE_INCDIR_$${ucmodule} = $$val_escape(MODULE_INCLUDEPATH)" \ "QMAKE_DEFINES_$${ucmodule} = $$val_escape(MODULE_DEFINES)" debug_and_release { diff --git a/mkspecs/features/qt_module_pris.prf b/mkspecs/features/qt_module_pris.prf index 163f52f23f..e0556ce960 100644 --- a/mkspecs/features/qt_module_pris.prf +++ b/mkspecs/features/qt_module_pris.prf @@ -56,6 +56,7 @@ defineReplace(qtExportLibsForModule) { for (lib, QT.$${1}.libraries) { NAME = $$upper($$lib) vars = \ + QMAKE_DEPENDS_$${NAME}_CC QMAKE_DEPENDS_$${NAME}_LD \ QMAKE_LIBS_$$NAME QMAKE_LIBS_$${NAME}_DEBUG QMAKE_LIBS_$${NAME}_RELEASE \ QMAKE_DEFINES_$$NAME QMAKE_INCDIR_$$NAME for (var, vars) { diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 6039c52bd0..55295f271f 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -134,6 +134,8 @@ isEmpty($${target_prefix}.INCDIRS) { for (line, output) { contains(line, "^libraries: .*") { line ~= s,^libraries: ,, + # clang (7.x) on Windows uses the wrong path list separator ... + equals(QMAKE_HOST.os, Windows): line ~= s,:(?![/\\\\]),;, paths = $$split(line, $$QMAKE_DIRLIST_SEP) for (path, paths): \ QMAKE_DEFAULT_LIBDIRS += $$clean_path($$replace(path, ^=, $$[SYSROOT])) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 5ea5aeca12..137870f64f 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -415,6 +415,21 @@ static bool simdTestMask(const char *&ptr, const char *end, quint32 maskval) return true; } + +static Q_ALWAYS_INLINE __m128i mm_load8_zero_extend(const void *ptr) +{ + const __m128i *dataptr = static_cast<const __m128i *>(ptr); +#if defined(__SSE4_1__) + // use a MOVQ followed by PMOVZXBW + // if AVX2 is present, these should combine into a single VPMOVZXBW instruction + __m128i data = _mm_loadl_epi64(dataptr); + return _mm_cvtepu8_epi16(data); +# else + // use MOVQ followed by PUNPCKLBW + __m128i data = _mm_loadl_epi64(dataptr); + return _mm_unpacklo_epi8(data, _mm_setzero_si128()); +# endif +} #endif // Note: ptr on output may be off by one and point to a preceding US-ASCII @@ -585,8 +600,7 @@ void qt_from_latin1(ushort *dst, const char *str, size_t size) Q_DECL_NOTHROW // we're going to read str[offset..offset+7] (8 bytes) if (str + offset + 7 < e) { - const __m128i chunk = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(str + offset)); - const __m128i unpacked = _mm_unpacklo_epi8(chunk, _mm_setzero_si128()); + const __m128i unpacked = mm_load8_zero_extend(str + offset); _mm_storeu_si128(reinterpret_cast<__m128i *>(dst + offset), unpacked); offset += 8; } @@ -1044,8 +1058,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, size_t l) // we'll read uc[offset..offset+7] (16 bytes) and c[offset..offset+7] (8 bytes) if (uc + offset + 7 < e) { // same, but we're using an 8-byte load - __m128i chunk = _mm_loadl_epi64((const __m128i*)(c + offset)); - __m128i secondHalf = _mm_unpacklo_epi8(chunk, nullmask); + __m128i secondHalf = mm_load8_zero_extend(c + offset); __m128i ucdata = _mm_loadu_si128((const __m128i*)(uc + offset)); __m128i result = _mm_cmpeq_epi16(secondHalf, ucdata); diff --git a/src/gui/configure.json b/src/gui/configure.json index 6a2f1fe434..7585e9c8d4 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -163,7 +163,10 @@ "sources": [ { "type": "pkgConfig", "args": "freetype2" }, { "type": "freetype", "libs": "-lfreetype", "condition": "!config.wasm" }, - { "type": "freetype", "libs": "-s USE_FREETYPE=1", "condition": "config.wasm" } + { "libs": "-s USE_FREETYPE=1", "condition": "config.wasm" } + ], + "use": [ + { "lib": "zlib", "condition": "features.system-zlib" } ] }, "fontconfig": { @@ -451,6 +454,19 @@ { "type": "pkgConfig", "args": "wayland-server" } ] }, + "xlib": { + "label": "XLib", + "test": { + "include": "X11/Xlib.h", + "main": [ + "Display *d = XOpenDisplay(NULL);", + "XCloseDisplay(d);" + ] + }, + "sources": [ + { "type": "makeSpec", "spec": "X11" } + ] + }, "x11sm": { "label": "X11 session management", "sources": [ @@ -501,16 +517,14 @@ "xcb_xlib": { "label": "XCB Xlib", "test": { - "include": [ "xcb/xcb.h", "X11/Xlib.h", "X11/Xlib-xcb.h" ], - "main": [ - "Display *dpy = XOpenDisplay(\"\");", - "(void) XGetXCBConnection(dpy);" - ] + "include": "X11/Xlib-xcb.h", + "main": "(void) XGetXCBConnection((Display *)0);" }, "sources": [ - { "type": "pkgConfig", "args": "x11-xcb x11 xcb" }, - "-lxcb -lX11 -lX11-xcb" - ] + { "type": "pkgConfig", "args": "x11-xcb" }, + "-lX11-xcb" + ], + "use": "xcb xlib" }, "xcb_xkb": { "label": "XCB XKB >= 1.10", @@ -527,14 +541,15 @@ ] }, "sources": [ - { "type": "pkgConfig", "args": "xcb-xkb >= 1.10 xcb" }, - "-lxcb-xkb -lxcb" - ] + { "type": "pkgConfig", "args": "xcb-xkb >= 1.10" }, + "-lxcb-xkb" + ], + "use": "xcb" }, "xcb_render": { "label": "XCB XRender", "test": { - "include": [ "xcb/xcb.h", "xcb/render.h" ], + "include": "xcb/render.h", "tail": [ "// 'template' is used as a function argument name in xcb_renderutil.h", "#define template template_param", @@ -547,7 +562,7 @@ "main": [ "int primaryScreen = 0;", "xcb_generic_error_t *error = 0;", - "xcb_connection_t *connection = xcb_connect(\"\", &primaryScreen);", + "xcb_connection_t *connection = 0;", "xcb_render_query_pict_formats_cookie_t formatsCookie =", " xcb_render_query_pict_formats(connection);", "xcb_render_query_pict_formats_reply_t *formatsReply =", @@ -558,17 +573,18 @@ ] }, "sources": [ - { "type": "pkgConfig", "args": "xcb-renderutil xcb-render xcb" }, - "-lxcb-render-util -lxcb-render -lxcb" - ] + { "type": "pkgConfig", "args": "xcb-renderutil xcb-render" }, + "-lxcb-render-util -lxcb-render" + ], + "use": "xcb" }, "xcb_glx": { "label": "XCB GLX", "test": { - "include": [ "xcb/xcb.h", "xcb/glx.h" ], + "include": "xcb/glx.h", "main": [ "int primaryScreen = 0;", - "xcb_connection_t *connection = xcb_connect(\"\", &primaryScreen);", + "xcb_connection_t *connection = 0;", "xcb_generic_error_t *error = 0;", "xcb_glx_query_version_cookie_t xglx_query_cookie = xcb_glx_query_version(", " connection, XCB_GLX_MAJOR_VERSION, XCB_GLX_MINOR_VERSION);", @@ -576,17 +592,17 @@ ] }, "sources": [ - { "type": "pkgConfig", "args": "xcb-glx xcb" }, - "-lxcb-glx -lxcb" - ] + { "type": "pkgConfig", "args": "xcb-glx" }, + "-lxcb-glx" + ], + "use": "xcb" }, "xcb_xinput": { "label": "XCB XInput", "test": { - "include": [ "xcb/xcb.h", "xcb/xinput.h" ], + "include": "xcb/xinput.h", "main": [ - "int primaryScreen = 0;", - "xcb_connection_t *connection = xcb_connect(\"\", &primaryScreen);", + "xcb_connection_t *connection = 0;", "xcb_generic_error_t *error = 0;", "xcb_input_xi_query_version_cookie_t xinput_query_cookie = xcb_input_xi_query_version(", " connection, XCB_INPUT_MAJOR_VERSION, XCB_INPUT_MINOR_VERSION);", @@ -594,9 +610,10 @@ ] }, "sources": [ - { "type": "pkgConfig", "args": "xcb-xinput >= 1.12 xcb" }, - "-lxcb-xinput -lxcb" - ] + { "type": "pkgConfig", "args": "xcb-xinput >= 1.12" }, + "-lxcb-xinput" + ], + "use": "xcb" }, "xkbcommon": { "label": "xkbcommon >= 0.5.0", @@ -623,7 +640,8 @@ "test": "x11/xrender", "sources": [ "-lXrender" - ] + ], + "use": "xlib" } }, @@ -697,7 +715,7 @@ "// window and pixmap types will be different than what an X-based platform", "// plugin would expect." ], - "include": [ "EGL/egl.h", "xcb/xcb.h", "X11/Xlib.h", "X11/Xlib-xcb.h" ], + "include": [ "EGL/egl.h", "X11/Xlib.h" ], "main": [ "Display *dpy = EGL_DEFAULT_DISPLAY;", "EGLNativeDisplayType egldpy = XOpenDisplay(\"\");", @@ -707,7 +725,7 @@ "XCloseDisplay(dpy);" ] }, - "use": "egl xcb_xlib" + "use": "egl xlib" }, "egl-brcm": { "label": "Broadcom EGL (Raspberry Pi)", @@ -910,18 +928,6 @@ "pkg-config-variable": "prefix", "value": "/usr", "log": "value" - }, - "xlib": { - "label": "XLib", - "type": "compile", - "test": { - "include": "X11/Xlib.h", - "main": [ - "Display *d = XOpenDisplay(NULL);", - "XCloseDisplay(d);" - ], - "qmake": "CONFIG += x11" - } } }, @@ -1223,6 +1229,11 @@ "condition": "config.integrity && features.eglfs && tests.egl-openwfd", "output": [ "privateFeature" ] }, + "eglfs_x11": { + "label": "EGLFS X11", + "condition": "features.eglfs && features.xcb && features.xcb-xlib && features.egl_x11", + "output": [ "privateFeature" ] + }, "gif": { "label": "GIF", "condition": "features.imageformatplugin", @@ -1371,7 +1382,7 @@ "xlib": { "label": "XLib", "autoDetect": "!config.darwin || features.xcb", - "condition": "tests.xlib", + "condition": "libs.xlib", "output": [ "privateFeature" ] }, "texthtmlparser": { @@ -1703,7 +1714,7 @@ QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your pla "section": "EGLFS details", "condition": "features.eglfs", "entries": [ - "eglfs_openwfd", "eglfs_viv", "eglfs_viv_wl", "eglfs_rcar", "eglfs_egldevice", "eglfs_gbm", "eglfs_vsp2", "eglfs_mali", "eglfs_brcm", "egl_x11" + "eglfs_openwfd", "eglfs_viv", "eglfs_viv_wl", "eglfs_rcar", "eglfs_egldevice", "eglfs_gbm", "eglfs_vsp2", "eglfs_mali", "eglfs_brcm", "eglfs_x11" ] }, "linuxfb", "vnc", "mirclient", diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index da963adae6..0105f1decd 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -149,10 +149,7 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format) d->bytes_per_line = params.bytesPerLine; d->nbytes = params.totalSize; - if (depth == 64) - d->data = (uchar *)new (std::nothrow) quint64[d->nbytes / sizeof(quint64)]; - else // nbytes is known to already be a multipla of 4: - d->data = (uchar *)new (std::nothrow) quint32[d->nbytes / sizeof(quint32)]; + d->data = (uchar *)malloc(d->nbytes); if (!d->data) return nullptr; @@ -168,13 +165,8 @@ QImageData::~QImageData() if (is_cached) QImagePixmapCleanupHooks::executeImageHooks((((qint64) ser_no) << 32) | ((qint64) detach_no)); delete paintEngine; - if (data && own_data) { - // Casting to avoid being theoretically UB: - if (depth == 64) - delete[] (quint64 *)data; - else - delete[] (quint32 *)data; - } + if (data && own_data) + free(data); data = 0; } diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 81ce5c60c5..880423ca3b 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -1093,9 +1093,14 @@ bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTran if (fontEngine->glyphFormat == QFontEngine::Format_ARGB) return true; + static const int maxCachedGlyphSizeSquared = std::pow([]{ + if (int env = qEnvironmentVariableIntValue("QT_MAX_CACHED_GLYPH_SIZE")) + return env; + return QT_MAX_CACHED_GLYPH_SIZE; + }(), 2); + qreal pixelSize = fontEngine->fontDef.pixelSize; - return (pixelSize * pixelSize * qAbs(m.determinant())) < - QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE; + return (pixelSize * pixelSize * qAbs(m.determinant())) < maxCachedGlyphSizeSquared; } QT_END_NAMESPACE diff --git a/src/platformsupport/eglconvenience/eglconvenience.pro b/src/platformsupport/eglconvenience/eglconvenience.pro index 4301d63574..df21f14697 100644 --- a/src/platformsupport/eglconvenience/eglconvenience.pro +++ b/src/platformsupport/eglconvenience/eglconvenience.pro @@ -26,15 +26,15 @@ qtConfig(opengl) { qeglpbuffer.cpp } -# Avoid X11 header collision, use generic EGL native types -DEFINES += QT_EGL_NO_X11 - -qtConfig(xlib) { +qtConfig(egl_x11) { HEADERS += \ qxlibeglintegration_p.h SOURCES += \ qxlibeglintegration.cpp - LIBS_PRIVATE += $$QMAKE_LIBS_X11 + QMAKE_USE_PRIVATE += xlib +} else { + # Avoid X11 header collision, use generic EGL native types + DEFINES += QT_EGL_NO_X11 } CONFIG += egl diff --git a/src/platformsupport/glxconvenience/glxconvenience.pro b/src/platformsupport/glxconvenience/glxconvenience.pro index 58fa9fc479..8367dc5e31 100644 --- a/src/platformsupport/glxconvenience/glxconvenience.pro +++ b/src/platformsupport/glxconvenience/glxconvenience.pro @@ -6,7 +6,7 @@ CONFIG += static internal_module DEFINES += QT_NO_CAST_FROM_ASCII -LIBS_PRIVATE += $$QMAKE_LIBS_X11 +QMAKE_USE_PRIVATE += xlib HEADERS += qglxconvenience_p.h SOURCES += qglxconvenience.cpp diff --git a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro index 919ecd01f6..360536d22f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/deviceintegration.pro @@ -1,7 +1,7 @@ TEMPLATE = subdirs QT_FOR_CONFIG += gui-private -qtConfig(egl_x11): SUBDIRS += eglfs_x11 +qtConfig(eglfs_x11): SUBDIRS += eglfs_x11 qtConfig(eglfs_gbm): SUBDIRS *= eglfs_kms_support eglfs_kms qtConfig(eglfs_egldevice): SUBDIRS *= eglfs_kms_support eglfs_kms_egldevice qtConfig(eglfs_vsp2): SUBDIRS += eglfs_kms_vsp2 diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro index acbd1cc785..6b55918f03 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro @@ -8,7 +8,7 @@ DEFINES += QT_EGL_NO_X11 INCLUDEPATH += $$PWD/../../api CONFIG += egl -QMAKE_USE += xcb_xlib +QMAKE_USE += xcb_xlib xcb xlib SOURCES += $$PWD/qeglfsx11main.cpp \ $$PWD/qeglfsx11integration.cpp diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index ccf4252b79..9aec4f3aa4 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1657,7 +1657,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, alignment |= Qt::TextHideMnemonic; if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { - pr.setHeight(pmSize.height() + 6); + pr.setHeight(pmSize.height() + 4); //### 4 is currently hardcoded in QToolButton::sizeHint() tr.adjust(0, pr.height() - 1, 0, -1); pr.translate(shiftX, shiftY); if (!hasArrow) { @@ -1667,7 +1667,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } alignment |= Qt::AlignCenter; } else { - pr.setWidth(pmSize.width() + 8); + pr.setWidth(pmSize.width() + 4); //### 4 is currently hardcoded in QToolButton::sizeHint() tr.adjust(pr.width(), 0, 0, 0); pr.translate(shiftX, shiftY); if (!hasArrow) { diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index abb203b8cc..1e84237253 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -488,6 +488,7 @@ QScroller::QScroller(QObject *target) : d_ptr(new QScrollerPrivate(this, target)) { Q_ASSERT(target); // you can't create a scroller without a target in any normal way + setParent(target); Q_D(QScroller); d->init(); } diff --git a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp index fac13c7074..8bdd4b4783 100644 --- a/tests/auto/widgets/util/qscroller/tst_qscroller.cpp +++ b/tests/auto/widgets/util/qscroller/tst_qscroller.cpp @@ -125,6 +125,7 @@ private slots: void scrollTo(); void scroll(); void overshoot(); + void multipleWindows(); private: QTouchDevice *m_touchScreen = QTest::createTouchDevice(); @@ -373,7 +374,7 @@ void tst_QScroller::scrollTo() void tst_QScroller::scroll() { -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) && QT_CONFIG(scroller) // -- good case. normal scroll tst_QScrollerWidget *sw = new tst_QScrollerWidget(); sw->scrollArea = QRectF(0, 0, 1000, 1000); @@ -413,7 +414,7 @@ void tst_QScroller::scroll() void tst_QScroller::overshoot() { -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) && QT_CONFIG(scroller) tst_QScrollerWidget *sw = new tst_QScrollerWidget(); sw->scrollArea = QRectF(0, 0, 1000, 1000); QScroller::grabGesture(sw, QScroller::TouchGesture); @@ -504,6 +505,39 @@ void tst_QScroller::overshoot() #endif } +void tst_QScroller::multipleWindows() +{ +#if QT_CONFIG(gestures) && QT_CONFIG(scroller) + QScopedPointer<tst_QScrollerWidget> sw1(new tst_QScrollerWidget()); + sw1->scrollArea = QRectF(0, 0, 1000, 1000); + QScroller::grabGesture(sw1.data(), QScroller::TouchGesture); + sw1->setGeometry(100, 100, 400, 300); + QScroller *s1 = QScroller::scroller(sw1.data()); + kineticScroll(sw1.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); + // now we should be scrolling + QTRY_COMPARE( s1->state(), QScroller::Scrolling ); + + // That was fun! Do it again! + QScopedPointer<tst_QScrollerWidget> sw2(new tst_QScrollerWidget()); + sw2->scrollArea = QRectF(0, 0, 1000, 1000); + QScroller::grabGesture(sw2.data(), QScroller::TouchGesture); + sw2->setGeometry(100, 100, 400, 300); + QScroller *s2 = QScroller::scroller(sw2.data()); + kineticScroll(sw2.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); + // now we should be scrolling + QTRY_COMPARE( s2->state(), QScroller::Scrolling ); + + // wait for both to stop + QTRY_VERIFY(s1->state() != QScroller::Scrolling); + QTRY_VERIFY(s2->state() != QScroller::Scrolling); + + sw1.reset(); // destroy one window + sw2->reset(); // reset the other scroller's internal state + // make sure we can still scroll the remaining one without crashing (QTBUG-71232) + kineticScroll(sw2.data(), QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); +#endif +} + QTEST_MAIN(tst_QScroller) #include "tst_qscroller.moc" diff --git a/tests/manual/textrendering/nativetext/main.cpp b/tests/manual/textrendering/nativetext/main.cpp new file mode 100644 index 0000000000..5c7621e61f --- /dev/null +++ b/tests/manual/textrendering/nativetext/main.cpp @@ -0,0 +1,310 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtWidgets> + +#ifdef Q_OS_DARWIN +#include <private/qcoregraphics_p.h> +#include <private/qcore_mac_p.h> +#include <Foundation/Foundation.h> +#include <private/qfont_p.h> +#include <private/qfontengine_p.h> +#endif + +static int s_mode; +static QString s_text = QString::fromUtf8("The quick brown \xF0\x9F\xA6\x8A jumps over the lazy \xF0\x9F\x90\xB6"); + +class TextRenderer : public QWidget +{ + Q_OBJECT +public: + enum RenderingMode { QtRendering, NativeRendering }; + Q_ENUM(RenderingMode); + + TextRenderer(qreal pointSize, const QString &text, const QColor &textColor = QColor(), const QColor &bgColor = QColor()) + : m_text(text) + { + if (pointSize) { + QFont f = font(); + f.setPointSize(pointSize); + setFont(f); + } + + if (textColor.isValid()) { + QPalette p = palette(); + p.setColor(QPalette::Text, textColor); + setPalette(p); + } + + if (bgColor.isValid()) { + QPalette p = palette(); + p.setColor(QPalette::Window, bgColor); + setPalette(p); + } + } + + QString text() const + { + return !m_text.isNull() ? m_text : s_text; + } + + QSize sizeHint() const override + { + QFontMetrics fm = fontMetrics(); + return QSize(fm.boundingRect(text()).width(), fm.height()); + } + + bool event(QEvent * event) override + { + if (event->type() == QEvent::ToolTip) { + QString toolTip; + QDebug debug(&toolTip); + debug << "textColor =" << palette().color(QPalette::Text) << "bgColor =" << palette().color(QPalette::Window); + setToolTip(toolTip); + } + + return QWidget::event(event); + } + + void paintEvent(QPaintEvent *) override + { + QImage image(size() * devicePixelRatio(), QImage::Format_ARGB32_Premultiplied); + image.setDevicePixelRatio(devicePixelRatio()); + + QPainter p(&image); + p.fillRect(QRect(0, 0, image.width(), image.height()), palette().window().color()); + + const int ascent = fontMetrics().ascent(); + + p.setPen(Qt::magenta); + p.drawLine(QPoint(0, ascent), QPoint(width(), ascent)); + p.end(); + + if (s_mode == QtRendering) + renderQtText(image); + else + renderNativeText(image); + + QPainter wp(this); + wp.drawImage(QPoint(0, 0), image); + } + + void renderQtText(QImage &image) + { + QPainter p(&image); + + const int ascent = fontMetrics().ascent(); + + p.setPen(palette().text().color()); + + QFont f = font(); + f.resolve(-1); + p.setFont(f); + + p.drawText(QPoint(0, ascent), text()); + } + + void renderNativeText(QImage &image) + { +#ifdef Q_OS_DARWIN + QMacAutoReleasePool pool; + QMacCGContext ctx(&image); + + const auto *fontEngine = QFontPrivate::get(font())->engineForScript(QChar::Script_Common); + Q_ASSERT(fontEngine); + if (fontEngine->type() == QFontEngine::Multi) { + fontEngine = static_cast<const QFontEngineMulti *>(fontEngine)->engine(0); + Q_ASSERT(fontEngine); + } + Q_ASSERT(fontEngine->type() == QFontEngine::Mac); + + QColor textColor = palette().text().color(); + auto nsColor = [NSColor colorWithSRGBRed:textColor.redF() + green:textColor.greenF() + blue:textColor.blueF() + alpha:textColor.alphaF()]; + + if (font().styleStrategy() & QFont::NoAntialias) + CGContextSetShouldAntialias(ctx, false); + + // Retain count already tracked by QMacCGContext above + NSGraphicsContext.currentContext = [NSGraphicsContext graphicsContextWithCGContext:ctx flipped:YES]; + [text().toNSString() drawAtPoint:CGPointZero withAttributes:@{ + NSFontAttributeName : (NSFont *)fontEngine->handle(), + NSForegroundColorAttributeName : nsColor + }]; + NSGraphicsContext.currentContext = nil; +#endif + } + +public: + + RenderingMode m_mode = QtRendering; + QString m_text; +}; + +class TestWidget : public QWidget +{ + Q_OBJECT +public: + TestWidget() + { + auto *mainLayout = new QVBoxLayout; + + m_previews = new QWidget; + m_previews->setLayout(new QHBoxLayout); + + for (int i = 0; i < 6; ++i) { + auto *layout = new QVBoxLayout; + QString text; + if (i > 0) + text = "ABC"; + + QPair<QColor, QColor> color = [i] { + switch (i) { + case 0: return qMakePair(QColor(), QColor()); + case 1: return qMakePair(QColor(Qt::black), QColor(Qt::white)); + case 2: return qMakePair(QColor(Qt::white), QColor(Qt::black)); + case 3: return qMakePair(QColor(Qt::green), QColor(Qt::red)); + case 4: return qMakePair(QColor(0, 0, 0, 128), QColor(Qt::white)); + case 5: return qMakePair(QColor(255, 255, 255, 128), QColor(Qt::black)); + default: return qMakePair(QColor(), QColor()); + } + }(); + + layout->addWidget(new TextRenderer(12, text, color.first, color.second)); + layout->addWidget(new TextRenderer(24, text, color.first, color.second)); + layout->addWidget(new TextRenderer(36, text, color.first, color.second)); + layout->addWidget(new TextRenderer(48, text, color.first, color.second)); + static_cast<QHBoxLayout*>(m_previews->layout())->addLayout(layout); + } + + mainLayout->addWidget(m_previews); + + auto *controls = new QHBoxLayout; + auto *lineEdit = new QLineEdit(s_text); + connect(lineEdit, &QLineEdit::textChanged, [&](const QString &text) { + s_text = text; + for (TextRenderer *renderer : m_previews->findChildren<TextRenderer *>()) + renderer->updateGeometry(); + }); + controls->addWidget(lineEdit); + + auto *colorButton = new QPushButton("Color..."); + connect(colorButton, &QPushButton::clicked, [&] { + auto *colorDialog = new QColorDialog(this); + colorDialog->setOptions(QColorDialog::NoButtons | QColorDialog::ShowAlphaChannel); + colorDialog->setModal(false); + connect(colorDialog, &QColorDialog::currentColorChanged, [&](const QColor &color) { + QPalette p = palette(); + p.setColor(QPalette::Text, color); + setPalette(p); + }); + colorDialog->setCurrentColor(palette().text().color()); + colorDialog->setVisible(true); + }); + controls->addWidget(colorButton); + auto *fontButton = new QPushButton("Font..."); + connect(fontButton, &QPushButton::clicked, [&] { + auto *fontDialog = new QFontDialog(this); + fontDialog->setOptions(QFontDialog::NoButtons); + fontDialog->setModal(false); + fontDialog->setCurrentFont(m_previews->font()); + connect(fontDialog, &QFontDialog::currentFontChanged, [&](const QFont &font) { + m_previews->setFont(font); + }); + fontDialog->setVisible(true); + }); + controls->addWidget(fontButton); + + auto *aaButton = new QCheckBox("NoAntialias"); + connect(aaButton, &QCheckBox::stateChanged, [&] { + for (TextRenderer *renderer : m_previews->findChildren<TextRenderer *>()) { + QFont font = renderer->font(); + font.setStyleStrategy(QFont::StyleStrategy(font.styleStrategy() ^ QFont::NoAntialias)); + renderer->setFont(font); + } + }); + controls->addWidget(aaButton); + + auto *subpixelAAButton = new QCheckBox("NoSubpixelAntialias"); + connect(subpixelAAButton, &QCheckBox::stateChanged, [&] { + for (TextRenderer *renderer : m_previews->findChildren<TextRenderer *>()) { + QFont font = renderer->font(); + font.setStyleStrategy(QFont::StyleStrategy(font.styleStrategy() ^ QFont::NoSubpixelAntialias)); + renderer->setFont(font); + } + }); + controls->addWidget(subpixelAAButton); + controls->addStretch(); + + mainLayout->addLayout(controls); + + mainLayout->setSizeConstraint(QLayout::SetFixedSize); + setLayout(mainLayout); + + setMode(TextRenderer::QtRendering); + setFocusPolicy(Qt::StrongFocus); + setFocus(); + } + + void setMode(TextRenderer::RenderingMode mode) + { + s_mode = mode; + setWindowTitle(s_mode == TextRenderer::QtRendering ? "Qt" : "Native"); + + for (TextRenderer *renderer : m_previews->findChildren<TextRenderer *>()) + renderer->update(); + } + + void mousePressEvent(QMouseEvent *) override + { + setMode(TextRenderer::RenderingMode(!s_mode)); + } + + void keyPressEvent(QKeyEvent *e) override + { + if (e->key() == Qt::Key_Space) + setMode(TextRenderer::RenderingMode(!s_mode)); + } + + QWidget *m_previews; +}; + +int main(int argc, char **argv) +{ + qputenv("QT_MAX_CACHED_GLYPH_SIZE", "97"); + QApplication app(argc, argv); + + TestWidget widget; + widget.show(); + return app.exec(); +} + +#include "main.moc" + diff --git a/tests/manual/textrendering/nativetext/nativetext.pro b/tests/manual/textrendering/nativetext/nativetext.pro new file mode 100644 index 0000000000..fb3e3799e7 --- /dev/null +++ b/tests/manual/textrendering/nativetext/nativetext.pro @@ -0,0 +1,7 @@ +QT += widgets core-private gui-private +SOURCES += main.cpp +CONFIG -= app_bundle +darwin { + QMAKE_CXXFLAGS += -x objective-c++ + LIBS += -framework Foundation -framework CoreGraphics -framework AppKit +} diff --git a/tests/manual/textrendering/textrendering.pro b/tests/manual/textrendering/textrendering.pro index 92f0741bf3..14806e416c 100644 --- a/tests/manual/textrendering/textrendering.pro +++ b/tests/manual/textrendering/textrendering.pro @@ -1,4 +1,5 @@ TEMPLATE=subdirs SUBDIRS = glyphshaping \ - textperformance + textperformance \ + nativetext |