diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc | 23 | ||||
-rw-r--r-- | src/datavisualizationqml2/abstractdeclarative.cpp | 37 |
2 files changed, 16 insertions, 44 deletions
diff --git a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc index bc68d2fb..df2143a3 100644 --- a/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization-qml-abstractdeclarative.qdoc @@ -89,26 +89,19 @@ How the graph will be rendered. Defaults to \c{RenderIndirect}. \value RenderDirectToBackground - Indicates that the graph will be rendered directly on the window background. + Indicates that the graph will be rendered directly on the window background and QML items are + rendered on top of it. Using non-transparent QML item as a background will hide the graph. Clears the whole window before rendering the graph, including the areas - outside the graph. - Since the graphs in this rendering mode are drawn on the window background under other QML - items, the regular QML window clearing before rendering is suppressed. The graphs handle the clearing - themselves instead. - If the surface format of the window supports antialiasing, it will be used (see - \c {qDefaultSurfaceFormat()}). + outside the graph. If the surface format of the window supports antialiasing, it will be used (see + \c {QtDataVisualization::qDefaultSurfaceFormat()}). This rendering mode offers the best performance at the expense of non-standard QML behavior. For example, the graphs do not obey the z ordering of QML items and the opacity value has no effect on them. + \value RenderDirectToBackground_NoClear - Similar to \c RenderDirectToBackground mode, except that the graph will not clear the whole - window before rendering the graph. This mode is better for windows where you have other custom items - besides the graphs that also draw on the window background. In that case you need to either take care - of the window clearing yourself or ensure that all areas of the window are fully covered with opaque - items. - If one graph in the window uses either of the direct rendering modes, then all other graphs in the - same window also drawn in direct modes should use the exact same direct rendering mode. - Otherwise some graphs may not show up, depending on the drawing order of the graphs. + \obsolete + \note This will work exactly the same way as \c RenderDirectToBackground does in Qt 6 + as not clearing the window is not supported anymore. \value RenderIndirect Indicates the graph will be first rendered to an offscreen surface that diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp index ccc03d19..dbbd803d 100644 --- a/src/datavisualizationqml2/abstractdeclarative.cpp +++ b/src/datavisualizationqml2/abstractdeclarative.cpp @@ -46,9 +46,7 @@ QT_BEGIN_NAMESPACE -static QList<const QQuickWindow *> clearList; static QHash<AbstractDeclarative *, QQuickWindow *> graphWindowList; -static QHash<QQuickWindow *, bool> windowClearList; AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) : QQuickItem(parent), @@ -106,7 +104,7 @@ void AbstractDeclarative::setRenderingMode(AbstractDeclarative::RenderingMode mo update(); setFlag(ItemHasContents, false); if (win) { - QObject::connect(win, &QQuickWindow::beforeRendering, this, + QObject::connect(win, &QQuickWindow::beforeRenderPassRecording, this, &AbstractDeclarative::render, Qt::DirectConnection); checkWindowList(win); setAntialiasing(m_windowSamples > 0); @@ -120,7 +118,7 @@ void AbstractDeclarative::setRenderingMode(AbstractDeclarative::RenderingMode mo setFlag(ItemHasContents, !m_runningInDesigner); update(); if (win) { - QObject::disconnect(win, &QQuickWindow::beforeRendering, this, + QObject::disconnect(win, &QQuickWindow::beforeRenderPassRecording, this, &AbstractDeclarative::render); checkWindowList(win); } @@ -407,9 +405,6 @@ void AbstractDeclarative::doneOpenGLContext(QQuickWindow *window) void AbstractDeclarative::synchDataToRenderer() { - if (m_renderMode == RenderDirectToBackground && clearList.size()) - clearList.clear(); - QQuickWindow *win = window(); activateOpenGLContext(win); m_controller->synchDataToRenderer(); @@ -444,7 +439,6 @@ void AbstractDeclarative::setMsaaSamples(int samples) void AbstractDeclarative::handleWindowChanged(QQuickWindow *window) { checkWindowList(window); - if (!window) return; @@ -473,7 +467,7 @@ void AbstractDeclarative::handleWindowChanged(QQuickWindow *window) if (m_renderMode == RenderDirectToBackground_NoClear || m_renderMode == RenderDirectToBackground) { - connect(window, &QQuickWindow::beforeRendering, this, &AbstractDeclarative::render, + connect(window, &QQuickWindow::beforeRenderPassRecording, this, &AbstractDeclarative::render, Qt::DirectConnection); setAntialiasing(m_windowSamples > 0); if (m_windowSamples != oldWindowSamples) @@ -580,14 +574,10 @@ void AbstractDeclarative::render() // Clear the background once per window as that is not done by default QQuickWindow *win = window(); + win->beginExternalCommands(); activateOpenGLContext(win); + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - if (m_renderMode == RenderDirectToBackground && !clearList.contains(win)) { - clearList.append(win); - QColor clearColor = win->color(); - funcs->glClearColor(clearColor.redF(), clearColor.greenF(), clearColor.blueF(), 1.0f); - funcs->glClear(GL_COLOR_BUFFER_BIT); - } if (isVisible()) { funcs->glDepthMask(GL_TRUE); @@ -601,7 +591,9 @@ void AbstractDeclarative::render() funcs->glEnable(GL_BLEND); } + doneOpenGLContext(win); + win->endExternalCommands(); } QAbstract3DInputHandler* AbstractDeclarative::inputHandler() const @@ -653,7 +645,6 @@ void AbstractDeclarative::wheelEvent(QWheelEvent *event) void AbstractDeclarative::checkWindowList(QQuickWindow *window) { QQuickWindow *oldWindow = graphWindowList.value(this); - graphWindowList[this] = window; if (oldWindow != window && oldWindow) { @@ -661,7 +652,7 @@ void AbstractDeclarative::checkWindowList(QQuickWindow *window) &AbstractDeclarative::windowDestroyed); QObject::disconnect(oldWindow, &QQuickWindow::beforeSynchronizing, this, &AbstractDeclarative::synchDataToRenderer); - QObject::disconnect(oldWindow, &QQuickWindow::beforeRendering, this, + QObject::disconnect(oldWindow, &QQuickWindow::beforeRenderPassRecording, this, &AbstractDeclarative::render); if (!m_controller.isNull()) { QObject::disconnect(m_controller.data(), &Abstract3DController::needRender, @@ -678,20 +669,10 @@ void AbstractDeclarative::checkWindowList(QQuickWindow *window) } } - if (oldWindow && !windowList.contains(oldWindow) - && windowClearList.contains(oldWindow)) { - windowClearList.remove(oldWindow); - } - if (!window) { graphWindowList.remove(this); return; } - - if ((m_renderMode == RenderDirectToBackground - || m_renderMode == RenderDirectToBackground_NoClear) - && !windowClearList.contains(window)) { - } } void AbstractDeclarative::setMeasureFps(bool enable) @@ -829,8 +810,6 @@ void AbstractDeclarative::windowDestroyed(QObject *obj) if (win == oldWindow) graphWindowList.remove(this); - - windowClearList.remove(win); } void AbstractDeclarative::destroyContext() |