summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2014-02-18 12:56:10 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-02-18 12:56:54 +0200
commit5bd455cbd04a61b251c466dd641e3ef31fcbe93b (patch)
tree36c13c892305e98c5c4225013f7c53fe8aa536f1
parentd91e065526fe084374b206b6e7c9f0d628abb93d (diff)
Crash fix
Also fixes messing up the quick controls when switching between rendering modes. Change-Id: I8c383ee948b0ba363d09a93b35f14028702296d3 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
-rw-r--r--examples/datavisualization/qmlsurfacelayers/qml/qmlsurfacelayers/main.qml23
-rw-r--r--src/datavisualizationqml2/abstractdeclarative.cpp55
-rw-r--r--src/datavisualizationqml2/abstractdeclarative_p.h1
-rw-r--r--src/datavisualizationqml2/declarativerendernode.cpp5
-rw-r--r--src/datavisualizationqml2/declarativerendernode_p.h5
5 files changed, 70 insertions, 19 deletions
diff --git a/examples/datavisualization/qmlsurfacelayers/qml/qmlsurfacelayers/main.qml b/examples/datavisualization/qmlsurfacelayers/qml/qmlsurfacelayers/main.qml
index 22c527a2..65378660 100644
--- a/examples/datavisualization/qmlsurfacelayers/qml/qmlsurfacelayers/main.qml
+++ b/examples/datavisualization/qmlsurfacelayers/qml/qmlsurfacelayers/main.qml
@@ -230,5 +230,28 @@ Item {
}
}
}
+
+ NewButton {
+ id: aaButton
+ text: "Disable Antialiasing"
+ Layout.fillWidth: true
+ Layout.minimumHeight: 40
+ visible: false
+ onClicked: {
+ if (surfaceLayers.renderingMode === AbstractGraph3D.Indirect_NoAA) {
+ surfaceLayers.renderingMode = AbstractGraph3D.DirectToBackground
+ text = "Disable Antialiasing"
+ } else {
+ surfaceLayers.renderingMode = AbstractGraph3D.Indirect_NoAA
+ text = "Enable Antialiasing"
+ }
+ }
+ }
+
+ Component.onCompleted: {
+ if (surfaceLayers.antialiasing) {
+ aaButton.visible = true
+ }
+ }
}
}
diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp
index 3bdb2a3a..04c4e371 100644
--- a/src/datavisualizationqml2/abstractdeclarative.cpp
+++ b/src/datavisualizationqml2/abstractdeclarative.cpp
@@ -35,11 +35,14 @@ AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) :
QQuickItem(parent),
m_controller(0),
m_renderMode(DirectToBackground),
- m_node(0),
m_initialisedSize(0, 0)
{
connect(this, &QQuickItem::windowChanged, this, &AbstractDeclarative::handleWindowChanged);
+#if !defined(QT_OPENGL_ES_2)
setAntialiasing(true);
+#else
+ setAntialiasing(false);
+#endif
}
AbstractDeclarative::~AbstractDeclarative()
@@ -53,24 +56,41 @@ void AbstractDeclarative::setRenderingMode(AbstractDeclarative::RenderingMode mo
if (mode == m_renderMode)
return;
+ RenderingMode previousMode = m_renderMode;
+
m_renderMode = mode;
+ QQuickWindow *win = window();
+
switch (mode) {
case DirectToBackground:
// Intentional flowthrough
case DirectToBackground_NoClear:
- // Delete render node
- delete m_node;
- m_node = 0;
m_initialisedSize = QSize(0, 0);
+#if !defined(QT_OPENGL_ES_2)
setAntialiasing(true);
+#else
+ setAntialiasing(false);
+#endif
setFlag(QQuickItem::ItemHasContents, false);
+
+ if (win && previousMode == Indirect_NoAA) {
+ QObject::connect(win, &QQuickWindow::beforeRendering, this,
+ &AbstractDeclarative::render);
+ checkWindowList(win);
+ }
+
break;
case Indirect_NoAA:
// Force recreation of render node by resetting the initialized size
setAntialiasing(false);
m_initialisedSize = QSize(0, 0);
setFlag(QQuickItem::ItemHasContents, true);
+ if (win) {
+ QObject::disconnect(win, &QQuickWindow::beforeRendering, this,
+ &AbstractDeclarative::render);
+ checkWindowList(win);
+ }
break;
}
@@ -98,15 +118,13 @@ QSGNode *AbstractDeclarative::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeD
m_initialisedSize = boundingRect().size().toSize();
// Delete old node
- if (oldNode) {
- m_node = 0;
+ if (oldNode)
delete oldNode;
- }
// Create a new one and set its bounding rectangle
- DeclarativeRenderNode *node = new DeclarativeRenderNode(window(), m_controller, m_renderMode, this);
+ DeclarativeRenderNode *node = new DeclarativeRenderNode(window(), m_controller,
+ m_renderMode, this);
node->setRect(boundingRect());
- m_node = node;
return node;
}
@@ -198,9 +216,11 @@ void AbstractDeclarative::handleWindowChanged(QQuickWindow *window)
connect(window, &QQuickWindow::beforeSynchronizing,
this, &AbstractDeclarative::synchDataToRenderer,
Qt::DirectConnection);
- connect(window, &QQuickWindow::beforeRendering,
- this, &AbstractDeclarative::render,
- Qt::DirectConnection);
+ if (m_renderMode == DirectToBackground_NoClear || m_renderMode == DirectToBackground) {
+ connect(window, &QQuickWindow::beforeRendering,
+ this, &AbstractDeclarative::render,
+ Qt::DirectConnection);
+ }
connect(m_controller.data(), &Abstract3DController::needRender,
window, &QQuickWindow::update);
@@ -342,7 +362,7 @@ void AbstractDeclarative::checkWindowList(QQuickWindow *window)
graphWindowList[this] = window;
- if (oldWindow) {
+ if (oldWindow != window && oldWindow) {
QObject::disconnect(oldWindow, &QQuickWindow::beforeSynchronizing, this,
&AbstractDeclarative::synchDataToRenderer);
QObject::disconnect(oldWindow, &QQuickWindow::beforeRendering, this,
@@ -353,7 +373,12 @@ void AbstractDeclarative::checkWindowList(QQuickWindow *window)
}
}
- const QList<QQuickWindow *> windowList = graphWindowList.values();
+ QList<QQuickWindow *> windowList;
+
+ foreach (AbstractDeclarative *graph, graphWindowList.keys()) {
+ if (graph->m_renderMode == DirectToBackground)
+ windowList.append(graphWindowList.value(graph));
+ }
if (oldWindow && !windowList.contains(oldWindow)) {
// Return window clear value
@@ -366,7 +391,7 @@ void AbstractDeclarative::checkWindowList(QQuickWindow *window)
return;
}
- if (window != oldWindow && windowList.size() == 1) {
+ if (m_renderMode == DirectToBackground && windowClearList.values(window).size() == 0) {
// Save old value clear value
windowClearList[window] = window->clearBeforeRendering();
// Disable clearing of the window as we render underneath
diff --git a/src/datavisualizationqml2/abstractdeclarative_p.h b/src/datavisualizationqml2/abstractdeclarative_p.h
index a26f2ffa..22013787 100644
--- a/src/datavisualizationqml2/abstractdeclarative_p.h
+++ b/src/datavisualizationqml2/abstractdeclarative_p.h
@@ -150,7 +150,6 @@ private:
QPointer<Abstract3DController> m_controller;
QRectF m_cachedGeometry;
AbstractDeclarative::RenderingMode m_renderMode;
- DeclarativeRenderNode *m_node;
QSize m_initialisedSize;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractDeclarative::SelectionFlags)
diff --git a/src/datavisualizationqml2/declarativerendernode.cpp b/src/datavisualizationqml2/declarativerendernode.cpp
index 612d11df..cc65b4f4 100644
--- a/src/datavisualizationqml2/declarativerendernode.cpp
+++ b/src/datavisualizationqml2/declarativerendernode.cpp
@@ -22,7 +22,10 @@
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
-DeclarativeRenderNode::DeclarativeRenderNode(QQuickWindow *window, Abstract3DController *controller, AbstractDeclarative::RenderingMode mode, QObject *parent)
+DeclarativeRenderNode::DeclarativeRenderNode(QQuickWindow *window,
+ Abstract3DController *controller,
+ AbstractDeclarative::RenderingMode mode,
+ QObject *parent)
: QObject(parent),
m_fbo(0),
m_texture(0),
diff --git a/src/datavisualizationqml2/declarativerendernode_p.h b/src/datavisualizationqml2/declarativerendernode_p.h
index b8250512..559e27e1 100644
--- a/src/datavisualizationqml2/declarativerendernode_p.h
+++ b/src/datavisualizationqml2/declarativerendernode_p.h
@@ -45,7 +45,8 @@ class DeclarativeRenderNode : public QObject, public QSGSimpleTextureNode
{
Q_OBJECT
public:
- explicit DeclarativeRenderNode(QQuickWindow *window, Abstract3DController *controller, AbstractDeclarative::RenderingMode mode, QObject *parent = 0);
+ explicit DeclarativeRenderNode(QQuickWindow *window, Abstract3DController *controller,
+ AbstractDeclarative::RenderingMode mode, QObject *parent = 0);
virtual ~DeclarativeRenderNode();
// Renders view to FBO before render cycle starts.
@@ -61,4 +62,4 @@ private:
QT_END_NAMESPACE_DATAVISUALIZATION
-#endif // DECLARATIVERENDERNODE_P_H
+#endif