summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-07-07 18:21:52 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-06 19:07:45 +0200
commitfffb6233a366a92336aeed690cae0b704358511d (patch)
treed7ee82c5dfc696151aba1e2f134c1b350f15de1c /src/core
parent83a6c1b92f38b4b0bdb3f90d67be7bb1e4caef7a (diff)
Use QSGEngine instead of the private QSGRenderContext
QSGEngine was added in Qt 5.4 to allow using the scene graph without QQuickWindow. Use it for our FBO as well as for the QOpenGLWidget rendering. Change-Id: If4665d4f33c9dad69d2d4269309163bb5ffbd8e3 Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/delegated_frame_node.cpp42
-rw-r--r--src/core/delegated_frame_node.h7
-rw-r--r--src/core/render_widget_host_view_qt.cpp4
-rw-r--r--src/core/render_widget_host_view_qt.h2
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h3
5 files changed, 19 insertions, 39 deletions
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index 546f7395e..434530e17 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -66,13 +66,13 @@
#include "cc/quads/texture_draw_quad.h"
#include "cc/quads/tile_draw_quad.h"
#include "cc/quads/yuv_video_draw_quad.h"
+#include <QOpenGLContext>
#include <QOpenGLFramebufferObject>
+#include <QSGAbstractRenderer>
+#include <QSGEngine>
#include <QSGSimpleRectNode>
#include <QSGSimpleTextureNode>
#include <QSGTexture>
-#include <QtQuick/private/qsgcontext_p.h>
-#include <QtQuick/private/qsgrenderer_p.h>
-#include <QtQuick/private/qsgtexture_p.h>
#if !defined(QT_NO_EGL)
#include <EGL/egl.h>
@@ -82,7 +82,7 @@
class RenderPassTexture : public QSGTexture
{
public:
- RenderPassTexture(const cc::RenderPass::Id &id, QSGRenderContext *context);
+ RenderPassTexture(const cc::RenderPass::Id &id);
const cc::RenderPass::Id &id() const { return m_id; }
void bind();
@@ -94,7 +94,6 @@ public:
void setRect(const QRect &rect) { m_rect = rect; }
void setFormat(GLenum format) { m_format = format; }
- void setDevicePixelRatio(qreal ratio) { m_device_pixel_ratio = ratio; }
QSGNode *rootNode() { return m_rootNode.data(); }
void grab();
@@ -102,14 +101,12 @@ public:
private:
cc::RenderPass::Id m_id;
QRect m_rect;
- qreal m_device_pixel_ratio;
GLenum m_format;
+ QScopedPointer<QSGEngine> m_sgEngine;
QScopedPointer<QSGRootNode> m_rootNode;
- QScopedPointer<QSGRenderer> m_renderer;
+ QScopedPointer<QSGAbstractRenderer> m_renderer;
QScopedPointer<QOpenGLFramebufferObject> m_fbo;
-
- QSGRenderContext *m_context;
};
class MailboxTexture : public QSGTexture {
@@ -263,13 +260,12 @@ static void waitAndDeleteChromiumSync(FenceSync *sync)
Q_ASSERT(!*sync);
}
-RenderPassTexture::RenderPassTexture(const cc::RenderPass::Id &id, QSGRenderContext *context)
+RenderPassTexture::RenderPassTexture(const cc::RenderPass::Id &id)
: QSGTexture()
, m_id(id)
- , m_device_pixel_ratio(1)
, m_format(GL_RGBA)
+ , m_sgEngine(new QSGEngine)
, m_rootNode(new QSGRootNode)
- , m_context(context)
{
}
@@ -281,16 +277,11 @@ void RenderPassTexture::bind()
void RenderPassTexture::grab()
{
- if (!m_rootNode->firstChild()) {
- m_renderer.reset();
- m_fbo.reset();
- return;
- }
if (!m_renderer) {
- m_renderer.reset(m_context->createRenderer());
+ m_sgEngine->initialize(QOpenGLContext::currentContext());
+ m_renderer.reset(m_sgEngine->createRenderer());
m_renderer->setRootNode(m_rootNode.data());
}
- m_renderer->setDevicePixelRatio(m_device_pixel_ratio);
if (!m_fbo || m_fbo->size() != m_rect.size() || m_fbo->format().internalTextureFormat() != m_format)
{
@@ -303,16 +294,13 @@ void RenderPassTexture::grab()
updateBindOptions(true);
}
- m_rootNode->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip and opacity update.
- m_renderer->nodeChanged(m_rootNode.data(), QSGNode::DirtyForceUpdate); // Force render list update.
-
m_renderer->setDeviceRect(m_rect.size());
m_renderer->setViewportRect(m_rect.size());
QRectF mirrored(m_rect.left(), m_rect.bottom(), m_rect.width(), -m_rect.height());
m_renderer->setProjectionMatrixToRect(mirrored);
m_renderer->setClearColor(Qt::transparent);
- m_context->renderNextFrame(m_renderer.data(), m_fbo->handle());
+ m_renderer->renderScene(m_fbo->handle());
}
MailboxTexture::MailboxTexture(const cc::TransferableResource &resource)
@@ -389,9 +377,8 @@ RectClipNode::RectClipNode(const QRectF &rect)
setIsRectangular(true);
}
-DelegatedFrameNode::DelegatedFrameNode(QSGRenderContext *sgRenderContext)
- : m_sgRenderContext(sgRenderContext)
- , m_numPendingSyncPoints(0)
+DelegatedFrameNode::DelegatedFrameNode()
+ : m_numPendingSyncPoints(0)
{
setFlag(UsePreprocess);
}
@@ -481,9 +468,8 @@ void DelegatedFrameNode::commit(DelegatedFrameNodeData* data, cc::ReturnedResour
if (pass != rootRenderPass) {
QSharedPointer<RenderPassTexture> rpTexture = findRenderPassTexture(pass->id, oldRenderPassTextures);
if (!rpTexture)
- rpTexture = QSharedPointer<RenderPassTexture>(new RenderPassTexture(pass->id, m_sgRenderContext));
+ rpTexture = QSharedPointer<RenderPassTexture>(new RenderPassTexture(pass->id));
m_renderPassTextures.append(rpTexture);
- rpTexture->setDevicePixelRatio(m_data->frameDevicePixelRatio);
rpTexture->setRect(toQt(pass->output_rect));
rpTexture->setFormat(pass->has_transparent_background ? GL_RGBA : GL_RGB);
renderPassParent = rpTexture->rootNode();
diff --git a/src/core/delegated_frame_node.h b/src/core/delegated_frame_node.h
index a42e293a5..617e16f6b 100644
--- a/src/core/delegated_frame_node.h
+++ b/src/core/delegated_frame_node.h
@@ -52,10 +52,6 @@
#include "chromium_gpu_helper.h"
-QT_BEGIN_NAMESPACE
-class QSGRenderContext;
-QT_END_NAMESPACE
-
namespace cc {
class DelegatedFrameData;
}
@@ -75,14 +71,13 @@ public:
class DelegatedFrameNode : public QSGTransformNode {
public:
- DelegatedFrameNode(QSGRenderContext *sgRenderContext);
+ DelegatedFrameNode();
~DelegatedFrameNode();
void preprocess();
void commit(DelegatedFrameNodeData* data, cc::ReturnedResourceArray *resourcesToRelease);
private:
QExplicitlySharedDataPointer<DelegatedFrameNodeData> m_data;
- QSGRenderContext *m_sgRenderContext;
QList<QSharedPointer<RenderPassTexture> > m_renderPassTextures;
int m_numPendingSyncPoints;
FenceSync m_mailboxesGLFence;
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 8e2b0db88..7228c51e7 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -687,11 +687,11 @@ void RenderWidgetHostViewQt::DispatchCancelTouchEvent(ui::TouchEvent *event)
m_host->ForwardTouchEventWithLatencyInfo(cancelEvent, *event->latency());
}
-QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode, QSGRenderContext *sgRenderContext)
+QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode)
{
DelegatedFrameNode *frameNode = static_cast<DelegatedFrameNode *>(oldNode);
if (!frameNode)
- frameNode = new DelegatedFrameNode(sgRenderContext);
+ frameNode = new DelegatedFrameNode;
frameNode->commit(m_frameNodeData.data(), &m_resourcesToRelease);
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index b4a75ad89..85a48e2a7 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -167,7 +167,7 @@ public:
virtual void DispatchCancelTouchEvent(ui::TouchEvent*) Q_DECL_OVERRIDE;
// Overridden from RenderWidgetHostViewQtDelegateClient.
- virtual QSGNode *updatePaintNode(QSGNode *, QSGRenderContext *) Q_DECL_OVERRIDE;
+ virtual QSGNode *updatePaintNode(QSGNode *) Q_DECL_OVERRIDE;
virtual void notifyResize() Q_DECL_OVERRIDE;
virtual bool forwardEvent(QEvent *) Q_DECL_OVERRIDE;
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index 122b7c6eb..d83f14235 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -52,7 +52,6 @@ class QCursor;
class QEvent;
class QPainter;
class QSGNode;
-class QSGRenderContext;
class QVariant;
class QWindow;
class QInputMethodEvent;
@@ -63,7 +62,7 @@ class WebContentsAdapterClient;
class QWEBENGINE_EXPORT RenderWidgetHostViewQtDelegateClient {
public:
virtual ~RenderWidgetHostViewQtDelegateClient() { }
- virtual QSGNode *updatePaintNode(QSGNode *, QSGRenderContext *) = 0;
+ virtual QSGNode *updatePaintNode(QSGNode *) = 0;
virtual void notifyResize() = 0;
virtual bool forwardEvent(QEvent *) = 0;
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const = 0;