summaryrefslogtreecommitdiffstats
path: root/src/core/api
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2020-07-24 10:30:54 +0200
committerMichael BrĂ¼ning <michael.bruning@qt.io>2020-07-24 15:23:10 +0200
commit54b84e14589b3e51f2f2e7980e2af2559601efe2 (patch)
treeeafef9f5b854cd90f6fa8e1ae5ab9e161a424aa3 /src/core/api
parent27332664b2745d7d322b8afbc1a41dc0fbfc763a (diff)
parenta2a19a6965601ced75e3e48b2bf618ba2bdbd29e (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/core/compositor/delegated_frame_node.cpp src/core/core_chromium.pri src/core/render_widget_host_view_qt.cpp Change-Id: I9387151e9647c87fc387095e7b6d8d66560cdf71
Diffstat (limited to 'src/core/api')
-rw-r--r--src/core/api/qtwebenginecoreglobal.cpp48
-rw-r--r--src/core/api/qwebenginecookiestore.cpp9
2 files changed, 57 insertions, 0 deletions
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index ce4362741..3c9387a10 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -45,6 +45,8 @@
#ifdef Q_OS_MACOS
#include <sys/types.h>
#include <sys/sysctl.h>
+#include <QOffscreenSurface>
+#include "macos_context_type_helper.h"
#endif
#endif
#include <QThread>
@@ -127,6 +129,52 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize()
shareContext = new QOpenGLContext;
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
// format.setOption(QSurfaceFormat::ResetNotification);
+
+#ifdef Q_OS_MACOS
+ if (format == QSurfaceFormat()) {
+ QOpenGLContext testContext;
+
+ // Chromium turns off OpenGL for CoreProfiles with versions < 4.1
+ // The newest Mac that only supports 3.3 was released in Mid 2011,
+ // so it should be safe to request 4.1, but we still double check it
+ // works in order not to set an invalid default surface format.
+ format.setVersion(4, 1);
+ format.setProfile(QSurfaceFormat::CoreProfile);
+
+ testContext.setFormat(format);
+ if (testContext.create()) {
+ QOffscreenSurface surface;
+ surface.setFormat(format);
+ surface.create();
+
+ if (testContext.makeCurrent(&surface)) {
+ // The Cocoa QPA integration allows sharing between OpenGL 3.2 and 4.1 contexts,
+ // which means even though we requested a 4.1 context, if we only get a 3.2 context,
+ // it will still work an Chromium will not black list it.
+ if (testContext.format().version() >= qMakePair(3, 2) &&
+ testContext.format().profile() == QSurfaceFormat::CoreProfile &&
+ !isCurrentContextSoftware()) {
+ QSurfaceFormat::setDefaultFormat(format);
+ } else {
+ qWarning("The available OpenGL surface format was either not version 3.2 or higher or not a Core Profile.\n"
+ "Chromium on macOS will fall back to software rendering in this case.\n"
+ "Hardware acceleration and features such as WebGL will not be available.");
+ format = QSurfaceFormat::defaultFormat();
+ }
+ testContext.doneCurrent();
+ }
+ surface.destroy();
+ }
+ } else {
+ // The user explicitly requested a specific surface format that does not fit Chromium's requirements. Warn them about this.
+ if (format.version() < qMakePair(3,2) || format.profile() != QSurfaceFormat::CoreProfile) {
+ qWarning("An OpenGL surfcace format was requested that is either not version 3.2 or higher or a not Core Profile.\n"
+ "Chromium on macOS will fall back to software rendering in this case.\n"
+ "Hardware acceleration and features such as WebGL will not be available.");
+ }
+ }
+#endif
+
shareContext->setFormat(format);
shareContext->create();
qAddPostRoutine(deleteShareContext);
diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp
index 40594b9c0..a09a74bf6 100644
--- a/src/core/api/qwebenginecookiestore.cpp
+++ b/src/core/api/qwebenginecookiestore.cpp
@@ -89,6 +89,9 @@ void QWebEngineCookieStorePrivate::processPendingUserCookies()
delegate->deleteSessionCookies(CallbackDirectory::DeleteSessionCookiesCallbackId);
}
+ if (bool(filterCallback))
+ delegate->setHasFilter(true);
+
if (m_pendingUserCookies.isEmpty())
return;
@@ -362,7 +365,10 @@ void QWebEngineCookieStore::deleteAllCookies()
*/
void QWebEngineCookieStore::setCookieFilter(const std::function<bool(const FilterRequest &)> &filterCallback)
{
+ bool changed = bool(d_ptr->filterCallback) != bool(filterCallback);
d_ptr->filterCallback = filterCallback;
+ if (changed && d_ptr->delegate)
+ d_ptr->delegate->setHasFilter(bool(d_ptr->filterCallback));
}
/*!
@@ -371,7 +377,10 @@ void QWebEngineCookieStore::setCookieFilter(const std::function<bool(const Filte
*/
void QWebEngineCookieStore::setCookieFilter(std::function<bool(const FilterRequest &)> &&filterCallback)
{
+ bool changed = bool(d_ptr->filterCallback) != bool(filterCallback);
d_ptr->filterCallback = std::move(filterCallback);
+ if (changed && d_ptr->delegate)
+ d_ptr->delegate->setHasFilter(bool(d_ptr->filterCallback));
}
/*!