summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-21 11:04:39 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-21 11:04:39 +0200
commitb04131f375a64204be962e7b92c88a3ecaf892c5 (patch)
treead3cac0a277791692eb4374af8b647cec5706cb1 /src/core
parent001ee1d6da4bf6769d702810f8ebcb05978663cc (diff)
parent0e5553a1626cb707499d82c96e136ceb79dfb54d (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts: src/3rdparty src/core/delegated_frame_node.h src/webengine/api/qquickwebenginecontextmenudata.cpp Change-Id: I163488d0d32cd981351608b2886f12e547e24672
Diffstat (limited to 'src/core')
-rw-r--r--src/core/config/linux.pri2
-rw-r--r--src/core/delegated_frame_node.cpp83
-rw-r--r--src/core/delegated_frame_node.h5
-rw-r--r--src/core/gyp_run.pro6
-rw-r--r--src/core/user_resource_controller_host.cpp3
-rw-r--r--src/core/web_contents_delegate_qt.cpp1
6 files changed, 77 insertions, 23 deletions
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index 5fa93e819..fc2b124fb 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -34,7 +34,7 @@ use?(nss) {
use_openssl_certs=1
}
-gcc:!clang: greaterThan(QT_GCC_MAJOR_VERSION, 5): GYP_CONFIG += v8_no_delete_null_pointer_checks=1
+gcc:!clang: greaterThan(QT_GCC_MAJOR_VERSION, 5): GYP_CONFIG += no_delete_null_pointer_checks=1
qtConfig(system-zlib): use?(system_minizip): GYP_CONFIG += use_system_zlib=1
qtConfig(system-png): GYP_CONFIG += use_system_libpng=1
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index d42ad4e7c..3d147226d 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -74,7 +74,6 @@
#include <QOpenGLFunctions>
#include <QSGFlatColorMaterial>
#include <QSGTexture>
-#include <QtGui/QOffscreenSurface>
#include <private/qsgadaptationlayer_p.h>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
@@ -103,6 +102,7 @@ namespace QtWebEngineCore {
class MailboxTexture : public QSGTexture, protected QOpenGLFunctions {
public:
MailboxTexture(const gpu::MailboxHolder &mailboxHolder, const QSize textureSize);
+ ~MailboxTexture();
virtual int textureId() const Q_DECL_OVERRIDE { return m_textureId; }
virtual QSize textureSize() const Q_DECL_OVERRIDE { return m_textureSize; }
virtual bool hasAlphaChannel() const Q_DECL_OVERRIDE { return m_hasAlpha; }
@@ -120,6 +120,9 @@ private:
QSize m_textureSize;
bool m_hasAlpha;
GLenum m_target;
+#if defined(USE_X11)
+ bool m_ownsTexture;
+#endif
#ifdef Q_OS_QNX
EGLStreamData m_eglStreamData;
#endif
@@ -292,6 +295,9 @@ MailboxTexture::MailboxTexture(const gpu::MailboxHolder &mailboxHolder, const QS
, m_textureSize(textureSize)
, m_hasAlpha(false)
, m_target(GL_TEXTURE_2D)
+#if defined(USE_X11)
+ , m_ownsTexture(false)
+#endif
{
initializeOpenGLFunctions();
@@ -302,6 +308,21 @@ MailboxTexture::MailboxTexture(const gpu::MailboxHolder &mailboxHolder, const QS
m_textureSize = QSize(1, 1);
}
+MailboxTexture::~MailboxTexture()
+{
+#if defined(USE_X11)
+ // This is rare case, where context is not shared
+ // we created extra texture in current context, so
+ // delete it now
+ if (m_ownsTexture) {
+ QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
+ QOpenGLFunctions *funcs = currentContext->functions();
+ GLuint id(m_textureId);
+ funcs->glDeleteTextures(1, &id);
+ }
+#endif
+}
+
void MailboxTexture::bind()
{
glBindTexture(m_target, m_textureId);
@@ -401,8 +422,25 @@ RectClipNode::RectClipNode(const QRectF &rect)
DelegatedFrameNode::DelegatedFrameNode()
: m_numPendingSyncPoints(0)
+#if defined(USE_X11)
+ , m_contextShared(true)
+#endif
{
setFlag(UsePreprocess);
+#if defined(USE_X11)
+ QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
+ QOpenGLContext *sharedContext = qt_gl_global_share_context();
+ if (!QOpenGLContext::areSharing(currentContext, sharedContext)) {
+ static bool allowNotSharedContextWarningShown = true;
+ if (allowNotSharedContextWarningShown) {
+ allowNotSharedContextWarningShown = false;
+ qWarning("Context is not shared, textures will be copied between contexts.");
+ }
+ m_offsurface.reset(new QOffscreenSurface);
+ m_offsurface->create();
+ m_contextShared = false;
+ }
+#endif
}
DelegatedFrameNode::~DelegatedFrameNode()
@@ -724,29 +762,28 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
waitChromiumSync(&sync);
deleteChromiumSync(&sync);
}
+
#if defined(USE_X11)
// Workaround when context is not shared QTBUG-48969
// Make slow copy between two contexts.
- QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
- QOpenGLContext *sharedContext = qt_gl_global_share_context();
- if (!QOpenGLContext::areSharing(currentContext,sharedContext)) {
- static bool allowNotSharedContextWarningShown = true;
- if (allowNotSharedContextWarningShown) {
- allowNotSharedContextWarningShown = false;
- qWarning("Context is not shared, textures will be copied between contexts.");
- }
+ if (!m_contextShared) {
+ QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
+ QOpenGLContext *sharedContext = qt_gl_global_share_context();
+
+ QSurface *surface = currentContext->surface();
+ Q_ASSERT(m_offsurface);
+ sharedContext->makeCurrent(m_offsurface.data());
+ QOpenGLFunctions *funcs = sharedContext->functions();
+
+ GLuint fbo = 0;
+ funcs->glGenFramebuffers(1, &fbo);
Q_FOREACH (MailboxTexture *mailboxTexture, mailboxesToFetch) {
- QSurface *surface = currentContext->surface();
// Read texture into QImage from shared context.
// Switch to shared context.
- QOffscreenSurface offsurface;
- offsurface.create();
- sharedContext->makeCurrent(&offsurface);
- QOpenGLFunctions *funcs = sharedContext->functions();
+ sharedContext->makeCurrent(m_offsurface.data());
+ funcs = sharedContext->functions();
QImage img(mailboxTexture->textureSize(), QImage::Format_RGBA8888_Premultiplied);
- GLuint fbo = 0;
- funcs->glGenFramebuffers(1, &fbo);
funcs->glBindFramebuffer(GL_FRAMEBUFFER, fbo);
funcs->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mailboxTexture->m_textureId, 0);
GLenum status = funcs->glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -754,13 +791,12 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
qWarning("fbo error, skipping slow copy...");
continue;
}
-
- funcs->glReadPixels(0, 0, mailboxTexture->textureSize().width(), mailboxTexture->textureSize().height(), GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
- funcs->glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ funcs->glReadPixels(0, 0, mailboxTexture->textureSize().width(), mailboxTexture->textureSize().height(),
+ GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
// Restore current context.
- currentContext->makeCurrent(surface);
// Create texture from QImage in current context.
+ currentContext->makeCurrent(surface);
GLuint texture = 0;
funcs = currentContext->functions();
funcs->glGenTextures(1, &texture);
@@ -772,7 +808,14 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mailboxTexture->textureSize().width(), mailboxTexture->textureSize().height(), 0,
GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
mailboxTexture->m_textureId = texture;
+ mailboxTexture->m_ownsTexture = true;
}
+ // Cleanup allocated resources
+ sharedContext->makeCurrent(m_offsurface.data());
+ funcs = sharedContext->functions();
+ funcs->glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ funcs->glDeleteFramebuffers(1, &fbo);
+ currentContext->makeCurrent(surface);
}
#endif
}
diff --git a/src/core/delegated_frame_node.h b/src/core/delegated_frame_node.h
index e2a3804e3..36ec20f1d 100644
--- a/src/core/delegated_frame_node.h
+++ b/src/core/delegated_frame_node.h
@@ -49,6 +49,7 @@
#include <QSharedData>
#include <QSharedPointer>
#include <QWaitCondition>
+#include <QtGui/QOffscreenSurface>
#include "chromium_gpu_helper.h"
#include "render_widget_host_view_qt_delegate.h"
@@ -104,6 +105,10 @@ private:
QMutex m_mutex;
QList<gl::TransferableFence> m_textureFences;
std::unique_ptr<gpu::SyncPointClient> m_syncPointClient;
+#if defined(USE_X11)
+ bool m_contextShared;
+ QScopedPointer<QOffscreenSurface> m_offsurface;
+#endif
};
} // namespace QtWebEngineCore
diff --git a/src/core/gyp_run.pro b/src/core/gyp_run.pro
index 7014adbf7..9f2a44d7b 100644
--- a/src/core/gyp_run.pro
+++ b/src/core/gyp_run.pro
@@ -19,7 +19,7 @@ cross_compile {
GYP_CONFIG += qtwe_process_name_debug=$$QTWEBENGINEPROCESS_NAME_DEBUG
GYP_CONFIG += qtwe_process_name_release=$$QTWEBENGINEPROCESS_NAME_RELEASE
GYP_CONFIG += disable_glibcxx_debug=1
-!contains(QT_CONFIG, no-pkg-config): GYP_CONFIG += pkg-config=$$pkgConfigExecutable()
+!contains(QT_CONFIG, no-pkg-config): GYP_ARGS += "-D pkg-config=\"$$pkgConfigExecutable()\""
!webcore_debug: GYP_CONFIG += remove_webcore_debug_symbols=1
!v8base_debug: GYP_CONFIG += remove_v8base_debug_symbols=1
@@ -82,6 +82,10 @@ contains(QT_ARCH, "arm") {
contains(MFPU, "neon")|contains(MFPU, "neon-vfpv4"): GYP_CONFIG += arm_fpu=\"$$MFPU\" arm_neon=1
else:!lessThan(MARMV, 7): GYP_CONFIG += arm_neon=0 arm_neon_optional=1
else: GYP_CONFIG += arm_fpu=\"$$MFPU\" arm_neon=0 arm_neon_optional=0
+ } else {
+ # Chromium defaults to arm_neon=1, Qt does not.
+ GYP_CONFIG += arm_neon=0
+ !lessThan(MARMV, 7): GYP_CONFIG += arm_neon_optional=1
}
contains(QMAKE_CFLAGS, "-marm"): GYP_CONFIG += arm_thumb=0
diff --git a/src/core/user_resource_controller_host.cpp b/src/core/user_resource_controller_host.cpp
index b2de41cc0..9d2ba8eb8 100644
--- a/src/core/user_resource_controller_host.cpp
+++ b/src/core/user_resource_controller_host.cpp
@@ -81,7 +81,8 @@ void UserResourceControllerHost::WebContentsObserverHelper::RenderViewCreated(co
void UserResourceControllerHost::WebContentsObserverHelper::RenderViewHostChanged(content::RenderViewHost *oldHost,
content::RenderViewHost *newHost)
{
- oldHost->Send(new RenderViewObserverHelper_ClearScripts(oldHost->GetRoutingID()));
+ if (oldHost)
+ oldHost->Send(new RenderViewObserverHelper_ClearScripts(oldHost->GetRoutingID()));
content::WebContents *contents = web_contents();
Q_FOREACH (const UserScript &script, m_controllerHost->m_perContentsScripts.value(contents))
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 144cb0f19..9d0965818 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -104,6 +104,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents
if (targetAdapter)
target = targetAdapter->webContents();
}
+ Q_ASSERT(target);
content::NavigationController::LoadURLParams load_url_params(params.url);
load_url_params.referrer = params.referrer;