Browse Source

qt5 : update patch and README

Lionel CHAZALLON 6 years ago
parent
commit
a8d4578ce6
2 changed files with 321 additions and 2 deletions
  1. 2 2
      README.md
  2. 319 0
      qt-patches/qt5-5.9.5.patch

+ 2 - 2
README.md

@@ -2,7 +2,7 @@
 
 You need:
 
-* Qt 5.7.1
+* Qt 5.9.5
 * cmake 3.1 or newer
 * ninja is recommended for building
 * FFmpeg 3.x and mpv from github
@@ -50,7 +50,7 @@ Systems not based on Debian/Ubuntu will have similar packages, but you'll need t
 
 ### Downloading and installing Qt
 
-If your distro provides Qt 5.7.1 or later packages, try to use them. Otherwise, find a Qt download at qt.io.
+If your distro provides Qt 5.9.5 or later packages, try to use them. Otherwise, find a Qt download at qt.io.
 
 On Windows and OSX, you can omit the ``-DQTROOT`` argument to use the Qt built by Plex. (Untested whether this works reliably.)
 

+ 319 - 0
qt-patches/qt5-5.9.5.patch

@@ -0,0 +1,319 @@
+--- qtwebengine/src/core/web_engine_context.cpp
++++ qtwebengine/src/core/web_engine_context.cpp
+@@ -376,6 +376,13 @@
+         parsedCommandLine->AppendSwitchASCII(switches::kProfilerTiming, switches::kProfilerTimingDisabledValue);
+     }
+ 
++    parsedCommandLine->AppendSwitch(switches::kEnableViewport);
++#if defined(Q_OS_WIN)
++    parsedCommandLine->AppendSwitch(switches::kDisableGpu);
++#endif
++    parsedCommandLine->AppendSwitch(switches::kDisableWebSecurity);
++
++
+     GLContextHelper::initialize();
+ 
+     const char *glType = 0;
+--- qtbase/src/plugins/platforms/cocoa/qnsview.mm
++++ qtbase/src/plugins/platforms/cocoa/qnsview.mm
+@@ -584,7 +584,7 @@
+         return NO;
+     if ([self isTransparentForUserInput])
+         return NO;
+-    return YES;
++    return NO;
+ }
+
+ - (NSView *)hitTest:(NSPoint)aPoint
+--- qtbase/src/gui/kernel/qsurfaceformat.cpp
++++ qtbase/src/gui/kernel/qsurfaceformat.cpp
+@@ -110,6 +110,7 @@
+     int major;
+     int minor;
+     int swapInterval;
++    QSurfaceFormat::OrientationFlags orientationFlags;
+ };
+
+ /*!
+@@ -736,6 +737,16 @@
+     return d->swapInterval;
+ }
+
++QSurfaceFormat::OrientationFlags QSurfaceFormat::orientationFlags() const
++{
++    return d->orientationFlags;
++}
++
++void QSurfaceFormat::setOrientationFlags(QSurfaceFormat::OrientationFlags orientationFlags)
++{
++    d->orientationFlags = orientationFlags;
++}
++
+ Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)
+
+ /*!
+--- qtbase/src/gui/kernel/qsurfaceformat.h
++++ qtbase/src/gui/kernel/qsurfaceformat.h
+@@ -57,7 +57,8 @@
+         StereoBuffers            = 0x0001,
+         DebugContext             = 0x0002,
+         DeprecatedFunctions      = 0x0004,
+-        ResetNotification        = 0x0008
++        ResetNotification        = 0x0008,
++        UseOptimalOrientation    = 0x0010
+     };
+     Q_ENUM(FormatOption)
+     Q_DECLARE_FLAGS(FormatOptions, FormatOption)
+@@ -85,6 +86,11 @@
+     };
+     Q_ENUM(OpenGLContextProfile)
+
++    enum OrientationFlag {
++        MirrorVertically = 0x0001,
++    };
++    Q_DECLARE_FLAGS(OrientationFlags, OrientationFlag)
++
+     QSurfaceFormat();
+     /*implicit*/ QSurfaceFormat(FormatOptions options);
+     QSurfaceFormat(const QSurfaceFormat &other);
+@@ -145,6 +151,9 @@
+     int swapInterval() const;
+     void setSwapInterval(int interval);
+
++    QSurfaceFormat::OrientationFlags orientationFlags() const;
++    void setOrientationFlags(QSurfaceFormat::OrientationFlags orientationFlags);
++
+     static void setDefaultFormat(const QSurfaceFormat &format);
+     static QSurfaceFormat defaultFormat();
+
+--- qtbase/src/plugins/platforms/windows/qwindowseglcontext.cpp
++++ qtbase/src/plugins/platforms/windows/qwindowseglcontext.cpp
+@@ -297,11 +297,25 @@
+     return new QWindowsEGLContext(this, context->format(), context->shareHandle());
+ }
+
+-void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err)
++void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, const QSurfaceFormat format, int *err)
+ {
+     *err = 0;
++
++    std::vector<EGLint> attrib_list;
++#ifdef EGL_ANGLE_surface_orientation
++    if (format.testOption(QSurfaceFormat::UseOptimalOrientation)) {
++        EGLint surfaceOrientation = 0;
++        libEGL.eglGetConfigAttrib(m_display, nativeConfig, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &surfaceOrientation);
++        if (surfaceOrientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE) {
++            attrib_list.push_back(EGL_SURFACE_ORIENTATION_ANGLE);
++            attrib_list.push_back(EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE);
++        }
++    }
++#endif
++    attrib_list.push_back(EGL_NONE);
+     EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, nativeConfig,
+-                                                       static_cast<EGLNativeWindowType>(nativeWindow), 0);
++                                                       static_cast<EGLNativeWindowType>(nativeWindow),
++                                                       &attrib_list[0]);
+     if (surface == EGL_NO_SURFACE) {
+         *err = libEGL.eglGetError();
+         qWarning("%s: Could not create the EGL window surface: 0x%x", __FUNCTION__, *err);
+@@ -350,6 +364,14 @@
+     format.setStereo(false);
+     format.setSwapInterval(referenceFormat.swapInterval());
+
++#ifdef EGL_ANGLE_surface_orientation
++    if (referenceFormat.testOption(QSurfaceFormat::UseOptimalOrientation)) {
++        EGLint surfaceOrientation = 0;
++        libEGL.eglGetConfigAttrib(display, config, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &surfaceOrientation);
++        format.setOrientationFlags((surfaceOrientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE) ? QSurfaceFormat::MirrorVertically : QSurfaceFormat::OrientationFlags());
++    }
++#endif
++
+     // Clear the EGL error state because some of the above may
+     // have errored out because the attribute is not applicable
+     // to the surface type.  Such errors don't matter.
+@@ -443,7 +465,7 @@
+             }
+         }
+         m_format.setProfile(QSurfaceFormat::NoProfile);
+-        m_format.setOptions(QSurfaceFormat::FormatOptions());
++        m_format.setOptions(m_format.options() & QSurfaceFormat::UseOptimalOrientation);
+         QWindowsEGLStaticContext::libEGL.eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);
+     }
+     QWindowsEGLStaticContext::libEGL.eglDestroySurface(m_eglDisplay, pbuffer);
+--- qtbase/src/plugins/platforms/windows/qwindowseglcontext.h
++++ qtbase/src/plugins/platforms/windows/qwindowseglcontext.h
+@@ -121,7 +121,7 @@
+     void *moduleHandle() const override { return libGLESv2.moduleHandle(); }
+     QOpenGLContext::OpenGLModuleType moduleType() const override { return QOpenGLContext::LibGLES; }
+
+-    void *createWindowSurface(void *nativeWindow, void *nativeConfig, int *err) override;
++    void *createWindowSurface(void *nativeWindow, void *nativeConfig, const QSurfaceFormat format, int *err) Q_DECL_OVERRIDE;
+     void destroyWindowSurface(void *nativeSurface) override;
+
+     QSurfaceFormat formatFromConfig(EGLDisplay display, EGLConfig config, const QSurfaceFormat &referenceFormat);
+--- qtbase/src/plugins/platforms/windows/qwindowsopenglcontext.h
++++ qtbase/src/plugins/platforms/windows/qwindowsopenglcontext.h
+@@ -62,7 +62,7 @@ public:
+
+     // If the windowing system interface needs explicitly created window surfaces (like EGL),
+     // reimplement these.
+-    virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/, int * /*err*/) { return 0; }
++    virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/, const QSurfaceFormat /*format*/, int * /*err*/) { return 0; }
+     virtual void destroyWindowSurface(void * /*nativeSurface*/) { }
+
+ private:
+--- qtbase/src/plugins/platforms/windows/qwindowswindow.cpp
++++ qtbase/src/plugins/platforms/windows/qwindowswindow.cpp
+@@ -2414,7 +2414,7 @@
+ #else
+     if (!m_surface) {
+         if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
+-            m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig, err);
++            m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig, m_format, err);
+     }
+
+     return m_surface;
+--- qtwebengine/src/core/web_engine_settings.cpp
++++ qtwebengine/src/core/web_engine_settings.cpp
+@@ -324,6 +324,8 @@
+     // Override for now
+     prefs->touch_enabled = isTouchEventsAPIEnabled();
+     prefs->device_supports_touch = isTouchScreenAvailable();
++    prefs->viewport_meta_enabled = true;
++    prefs->shrinks_viewport_contents_to_fit = true;
+     if (prefs->viewport_enabled) {
+         // We need to enable the viewport options together as it doesn't really work
+         // to enable them separately. With viewport-enabled we match Android defaults.
+--- qtdeclarative/src/quick/items/qquickwindow.cpp
++++ qtdeclarative/src/quick/items/qquickwindow.cpp
+@@ -467,7 +467,13 @@
+             QRect rect(QPoint(0, 0), devicePixelRatio * size);
+             renderer->setDeviceRect(rect);
+             renderer->setViewportRect(rect);
+-            renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
++            QRectF projRect(QPoint(0, 0), size);
++            bool mirrorVertically = QOpenGLContext::currentContext()->format().orientationFlags() & QSurfaceFormat::MirrorVertically;
++            QRectF mirrored(projRect.left(),
++                            mirrorVertically ? projRect.bottom() : projRect.top(),
++                            projRect.width(),
++                            mirrorVertically ? -projRect.height() : projRect.height());
++            renderer->setProjectionMatrixToRect(mirrored);
+             renderer->setDevicePixelRatio(devicePixelRatio);
+         }
+ 
+--- qtwebengine/src/3rdparty/chromium/base/memory/shared_memory_mac.cc
++++ qtwebengine/src/3rdparty/chromium/base/memory/shared_memory_mac.cc
+@@ -102,7 +102,7 @@ void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
+ // static
+ size_t SharedMemory::GetHandleLimit() {
+   // This should be effectively unlimited on OS X.
+-  return 10000;
++  return std::numeric_limits<int>::max();
+ }
+ 
+ // static
+--- qtwebengine/src/3rdparty/chromium/net/dns/host_resolver_impl.cc
++++ qtwebengine/src/3rdparty/chromium/net/dns/host_resolver_impl.cc
+@@ -2043,6 +2043,32 @@
+   }
+ }
+ 
++static bool ServePlexDirect(const HostCache::Key& key,
++                            const HostResolver::RequestInfo& info,
++                            AddressList* addresses)
++{
++  if (!EndsWith(info.hostname(), ".plex.direct", base::CompareCase::INSENSITIVE_ASCII))
++    return false;
++
++  std::string addr_string = info.hostname().substr(0, info.hostname().find('.'));
++  base::ReplaceChars(addr_string, "-", ".", &addr_string);
++
++  IPAddress ip_address;
++  if (!ip_address.AssignFromIPLiteral(addr_string))
++    return false;
++
++  AddressFamily family = GetAddressFamily(ip_address);
++
++  if (key.address_family != ADDRESS_FAMILY_UNSPECIFIED &&
++      key.address_family != family) {
++    // Don't return IPv6 addresses for IPv4 queries, and vice versa.
++    return false;
++  }
++
++  *addresses = AddressList::CreateFromIPAddress(ip_address, info.port());
++  return true;
++}
++
+ int HostResolverImpl::ResolveHelper(const Key& key,
+                                     const RequestInfo& info,
+                                     const IPAddress* ip_address,
+@@ -2079,6 +2105,11 @@
+     return OK;
+   }
+ 
++  if (ServePlexDirect(key, info, addresses)) {
++    MakeNotStale(stale_info);
++    return OK;
++  }
++
+   if (ServeLocalhost(key, info, addresses)) {
+     MakeNotStale(stale_info);
+     return OK;
+--- qtwebengine/src/3rdparty/chromium/cc/trees/layer_tree_settings.cc
++++ qtwebengine/src/3rdparty/chromium/cc/trees/layer_tree_settings.cc
+@@ -16,7 +16,7 @@ LayerTreeSettings::LayerTreeSettings()
+       gpu_memory_policy(64 * 1024 * 1024,
+                         gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
+                         ManagedMemoryPolicy::kDefaultNumResourcesLimit),
+-      software_memory_policy(128 * 1024 * 1024,
++      software_memory_policy(512 * 1024 * 1024,
+                              gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
+                              ManagedMemoryPolicy::kDefaultNumResourcesLimit) {}
+ 
+--- a/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm
++++ b/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm
+@@ -849,10 +849,6 @@ void QCocoaWindow::setVisible(bool visible)
+         if (m_nsWindow) {
+             QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
+
+-            // setWindowState might have been called while the window was hidden and
+-            // will not change the NSWindow state in that case. Sync up here:
+-            applyWindowState(window()->windowState());
+-
+             if (window()->windowState() != Qt::WindowMinimized) {
+                 if ((window()->modality() == Qt::WindowModal
+                      || window()->type() == Qt::Sheet)
+@@ -1111,8 +1107,7 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
+
+ void QCocoaWindow::setWindowState(Qt::WindowState state)
+ {
+-    if (window()->isVisible())
+-        applyWindowState(state); // Window state set for hidden windows take effect when show() is called
++    applyWindowState(state);
+ }
+
+ void QCocoaWindow::setWindowTitle(const QString &title)
+@@ -1526,6 +1521,13 @@ void QCocoaWindow::windowDidOrderOffScreen()
+ void QCocoaWindow::windowDidOrderOnScreen()
+ {
+     exposeWindow();
++
++    const Qt::WindowState expectedState = window()->windowState();
++    if (expectedState == Qt::WindowFullScreen && windowState() != expectedState
++            && !isTransitioningToFullScreen())
++        applyWindowState(expectedState);
++
++    [m_view setNeedsDisplay:YES];
+ }
+
+ void QCocoaWindow::windowDidChangeOcclusionState()
+@@ -1993,6 +1993,9 @@
+ 
+     switch (newState) {
+     case Qt::WindowFullScreen:
++        if (!m_nsWindow.visible)
++            break; // Defer until window is ordered on screen
++
+         toggleFullScreen();
+         break;
+     case Qt::WindowMaximized: