summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp49
-rw-r--r--src/webenginewidgets/api/qtwebenginewidgetsglobal.h6
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp4
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp77
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h17
-rw-r--r--src/webenginewidgets/webenginewidgets.pro5
6 files changed, 121 insertions, 37 deletions
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
new file mode 100644
index 000000000..f3792248e
--- /dev/null
+++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtwebenginewidgetsglobal.h"
+
+#include "qtwebengineglobal.h"
+
+void QWebEngineWidgets::initialize()
+{
+ QWebEngine::initialize();
+}
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.h b/src/webenginewidgets/api/qtwebenginewidgetsglobal.h
index d875c1cbe..1836de357 100644
--- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.h
+++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.h
@@ -55,6 +55,12 @@ QT_BEGIN_NAMESPACE
# define QWEBENGINEWIDGETS_EXPORT
#endif
+class QWEBENGINEWIDGETS_EXPORT QWebEngineWidgets
+{
+public:
+ static void initialize();
+};
+
QT_END_NAMESPACE
#endif // QTWEBENGINEWIDGETSGLOBAL_H
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index a5e5f8320..a879a94ef 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -148,7 +148,7 @@ void CallbackDirectory::CallbackSharedDataPointer::doDeref()
QWebEnginePagePrivate::QWebEnginePagePrivate()
: QObjectPrivate(QObjectPrivateVersion)
- , adapter(new WebContentsAdapter(SoftwareRenderingMode))
+ , adapter(new WebContentsAdapter(HardwareAccelerationMode))
, history(new QWebEngineHistory(new QWebEngineHistoryPrivate(this)))
, view(0)
{
@@ -353,7 +353,7 @@ void QWebEnginePagePrivate::_q_webActionTriggered(bool checked)
void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input)
{
- QExplicitlySharedDataPointer<WebContentsAdapter> newWebContents = WebContentsAdapter::createFromSerializedNavigationHistory(input, this, WebContentsAdapterClient::SoftwareRenderingMode);
+ QExplicitlySharedDataPointer<WebContentsAdapter> newWebContents = WebContentsAdapter::createFromSerializedNavigationHistory(input, this, WebContentsAdapterClient::HardwareAccelerationMode);
if (newWebContents) {
adapter = newWebContents.data();
adapter->initialize(this);
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 71d6e235e..308735f70 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -41,19 +41,21 @@
#include "render_widget_host_view_qt_delegate_widget.h"
-#include "qwebengineview.h"
#include "qwebenginepage_p.h"
-#include <QtGlobal>
+#include "qwebengineview.h"
#include <QLayout>
-#include <QResizeEvent>
-#include <QPainter>
-#include <QPaintEvent>
-#include <QWindow>
-#include <QtWidgets/QApplication>
+#include <QSGNode>
+#include <private/qsgadaptationlayer_p.h>
+#include <private/qsgcontext_p.h>
+#include <private/qsgrenderer_p.h>
+#include <private/qwidget_p.h>
RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent)
- : QWidget(parent)
+ : QOpenGLWidget(parent)
, m_client(client)
+ , sgContext(QSGContext::createDefaultContext())
+ , sgRenderContext(new QSGRenderContext(sgContext.data()))
+ , rootNode(new QSGRootNode)
, m_isPopup(false)
{
setFocusPolicy(Qt::ClickFocus);
@@ -68,7 +70,7 @@ void RenderWidgetHostViewQtDelegateWidget::initAsChild(WebContentsAdapterClient*
QWebEnginePagePrivate *pagePrivate = static_cast<QWebEnginePagePrivate *>(container);
if (pagePrivate->view) {
pagePrivate->view->layout()->addWidget(this);
- QWidget::show();
+ QOpenGLWidget::show();
} else
setParent(0);
}
@@ -108,38 +110,38 @@ void RenderWidgetHostViewQtDelegateWidget::show()
// Check if we're attached to a QWebEngineView, we don't
// want to show anything else than popups as top-level.
if (parent() || m_isPopup)
- QWidget::show();
+ QOpenGLWidget::show();
}
void RenderWidgetHostViewQtDelegateWidget::hide()
{
- QWidget::hide();
+ QOpenGLWidget::hide();
}
bool RenderWidgetHostViewQtDelegateWidget::isVisible() const
{
- return QWidget::isVisible();
+ return QOpenGLWidget::isVisible();
}
QWindow* RenderWidgetHostViewQtDelegateWidget::window() const
{
- const QWidget* root = QWidget::window();
+ const QWidget* root = QOpenGLWidget::window();
return root ? root->windowHandle() : 0;
}
-void RenderWidgetHostViewQtDelegateWidget::update(const QRect& rect)
+void RenderWidgetHostViewQtDelegateWidget::update(const QRect&)
{
- QWidget::update(rect);
+ updateGL();
}
void RenderWidgetHostViewQtDelegateWidget::updateCursor(const QCursor &cursor)
{
- QWidget::setCursor(cursor);
+ QOpenGLWidget::setCursor(cursor);
}
void RenderWidgetHostViewQtDelegateWidget::resize(int width, int height)
{
- QWidget::resize(width, height);
+ QOpenGLWidget::resize(width, height);
}
void RenderWidgetHostViewQtDelegateWidget::move(const QPoint &screenPos)
@@ -153,7 +155,7 @@ void RenderWidgetHostViewQtDelegateWidget::inputMethodStateChanged(bool editorVi
if (qApp->inputMethod()->isVisible() == editorVisible)
return;
- QWidget::setAttribute(Qt::WA_InputMethodEnabled, editorVisible);
+ QOpenGLWidget::setAttribute(Qt::WA_InputMethodEnabled, editorVisible);
qApp->inputMethod()->update(Qt::ImQueryInput | Qt::ImEnabled | Qt::ImHints);
qApp->inputMethod()->setVisible(editorVisible);
}
@@ -170,25 +172,44 @@ QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQ
bool RenderWidgetHostViewQtDelegateWidget::supportsHardwareAcceleration() const
{
- return false;
-}
-
-void RenderWidgetHostViewQtDelegateWidget::paintEvent(QPaintEvent * event)
-{
- QPainter painter(this);
- m_client->fetchBackingStore();
- m_client->paint(&painter, event->rect());
+ return true;
}
void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent)
{
- Q_UNUSED(resizeEvent);
+ QOpenGLWidget::resizeEvent(resizeEvent);
m_client->notifyResize();
}
bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
{
if (!m_client->forwardEvent(event))
- return QWidget::event(event);
+ return QOpenGLWidget::event(event);
return true;
}
+
+void RenderWidgetHostViewQtDelegateWidget::initializeGL()
+{
+ sgRenderContext->initialize(QOpenGLContext::currentContext());
+ sgRenderer.reset(sgRenderContext->createRenderer());
+ sgRenderer->setRootNode(rootNode.data());
+}
+
+void RenderWidgetHostViewQtDelegateWidget::paintGL()
+{
+ QSGNode *paintNode = m_client->updatePaintNode(rootNode->firstChild(), sgRenderContext.data());
+ if (paintNode != rootNode->firstChild()) {
+ delete rootNode->firstChild();
+ rootNode->appendChildNode(paintNode);
+ }
+
+ rootNode->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip and opacity update.
+ sgRenderer->nodeChanged(rootNode.data(), QSGNode::DirtyForceUpdate); // Force render list update.
+
+ sgRenderer->setDeviceRect(size());
+ sgRenderer->setViewportRect(size());
+ sgRenderer->setProjectionMatrixToRect(QRectF(QPointF(), size()));
+ sgRenderer->setClearColor(Qt::transparent);
+
+ sgRenderContext->renderNextFrame(sgRenderer.data(), defaultFramebufferObject());
+}
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
index 77a594d61..6a77d8321 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -45,15 +45,17 @@
#include "render_widget_host_view_qt_delegate.h"
#include "web_contents_adapter_client.h"
-#include <QWidget>
-
-class BackingStoreQt;
+#include <private/qopenglwidget_p.h>
QT_BEGIN_NAMESPACE
+class QSGContext;
+class QSGRenderContext;
+class QSGRenderer;
+class QSGRootNode;
class QWindow;
QT_END_NAMESPACE
-class RenderWidgetHostViewQtDelegateWidget : public QWidget, public RenderWidgetHostViewQtDelegate
+class RenderWidgetHostViewQtDelegateWidget : public QOpenGLWidget, public RenderWidgetHostViewQtDelegate
{
public:
RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = 0);
@@ -76,14 +78,19 @@ public:
virtual void setTooltip(const QString &tooltip) Q_DECL_OVERRIDE;
protected:
- void paintEvent(QPaintEvent * event);
bool event(QEvent *event);
void resizeEvent(QResizeEvent *resizeEvent);
+ void initializeGL() Q_DECL_OVERRIDE;
+ void paintGL() Q_DECL_OVERRIDE;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
private:
RenderWidgetHostViewQtDelegateClient *m_client;
+ QScopedPointer<QSGContext> sgContext;
+ QScopedPointer<QSGRenderContext> sgRenderContext;
+ QScopedPointer<QSGRootNode> rootNode;
+ QScopedPointer<QSGRenderer> sgRenderer;
bool m_isPopup;
};
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 182cb5500..1f2eb84b3 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -3,14 +3,15 @@ TARGET = QtWebEngineWidgets
# For our export macros
DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB
-QT += widgets network
-QT_PRIVATE += webenginecore widgets-private gui-private network-private core-private
+QT += webengine widgets network quick
+QT_PRIVATE += webenginecore widgets-private quick-private gui-private network-private core-private
QMAKE_DOCS = $$PWD/doc/qtwebenginewidgets.qdocconf
INCLUDEPATH += $$PWD api ../core
SOURCES = \
+ api/qtwebenginewidgetsglobal.cpp \
api/qwebenginehistory.cpp \
api/qwebenginepage.cpp \
api/qwebengineview.cpp\