aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2018-08-31 12:33:05 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2018-09-12 13:55:50 +0000
commit1b9f0b1ef548a248c427b23fb7e4d161d7dc83bb (patch)
tree4fdfdda4f3155071369c3e04c244cd5c043ba0b8 /src
parent49c9a5fbdbb14f87876de2e44b2783239ff2fdff (diff)
Enable Qt Quick path and shapes for the no-thread configuration
Force synchronous rendering in QQuickShapGenericRenderer. (In theory, we could support async also for no-thread by running the tasks on the Gui thread, but there would perhaps be little gain from doing this.) Change-Id: I0fb7526fdaa56d3c609c83c8d4790b4352d782fd Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/configure.json2
-rw-r--r--src/quickshapes/qquickshapegenericrenderer.cpp18
-rw-r--r--src/src.pro4
3 files changed, 19 insertions, 5 deletions
diff --git a/src/quick/configure.json b/src/quick/configure.json
index 9d7bafcb3b..9ec3531ef4 100644
--- a/src/quick/configure.json
+++ b/src/quick/configure.json
@@ -129,7 +129,7 @@
"label": "Path support",
"purpose": "Provides Path elements.",
"section": "Qt Quick",
- "condition": "features.thread && features.quick-shadereffect",
+ "condition": "features.quick-shadereffect",
"output": [
"privateFeature"
]
diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp
index 8a4785a83a..604da2a889 100644
--- a/src/quickshapes/qquickshapegenericrenderer.cpp
+++ b/src/quickshapes/qquickshapegenericrenderer.cpp
@@ -40,7 +40,10 @@
#include "qquickshapegenericrenderer_p.h"
#include <QtGui/private/qtriangulator_p.h>
#include <QtGui/private/qtriangulatingstroker_p.h>
+
+#if QT_CONFIG(thread)
#include <QThreadPool>
+#endif
#if QT_CONFIG(opengl)
#include <QSGVertexColorMaterial>
@@ -278,6 +281,7 @@ void QQuickShapeGenericRenderer::setAsyncCallback(void (*callback)(void *), void
m_asyncCallbackData = data;
}
+#if QT_CONFIG(thread)
static QThreadPool *pathWorkThreadPool = nullptr;
static void deletePathWorkThreadPool()
@@ -285,9 +289,16 @@ static void deletePathWorkThreadPool()
delete pathWorkThreadPool;
pathWorkThreadPool = nullptr;
}
+#endif
void QQuickShapeGenericRenderer::endSync(bool async)
{
+#if !QT_CONFIG(thread)
+ // Force synchronous mode for the no-thread configuration due
+ // to lack of QThreadPool.
+ async = false;
+#endif
+
bool didKickOffAsync = false;
for (int i = 0; i < m_sp.count(); ++i) {
@@ -311,13 +322,14 @@ void QQuickShapeGenericRenderer::endSync(bool async)
continue;
}
+#if QT_CONFIG(thread)
if (async && !pathWorkThreadPool) {
qAddPostRoutine(deletePathWorkThreadPool);
pathWorkThreadPool = new QThreadPool;
const int idealCount = QThread::idealThreadCount();
pathWorkThreadPool->setMaxThreadCount(idealCount > 0 ? idealCount * 2 : 4);
}
-
+#endif
if ((d.syncDirty & DirtyFillGeom) && d.fillColor.a) {
d.path.setFillRule(d.fillRule);
if (m_api == QSGRendererInterface::Unknown)
@@ -348,7 +360,9 @@ void QQuickShapeGenericRenderer::endSync(bool async)
r->deleteLater();
});
didKickOffAsync = true;
+#if QT_CONFIG(thread)
pathWorkThreadPool->start(r);
+#endif
} else {
triangulateFill(d.path, d.fillColor, &d.fillVertices, &d.fillIndices, &d.indexType, q_supportsElementIndexUint(m_api));
}
@@ -376,7 +390,9 @@ void QQuickShapeGenericRenderer::endSync(bool async)
r->deleteLater();
});
didKickOffAsync = true;
+#if QT_CONFIG(thread)
pathWorkThreadPool->start(r);
+#endif
} else {
triangulateStroke(d.path, d.pen, d.strokeColor, &d.strokeVertices,
QSize(m_item->width(), m_item->height()));
diff --git a/src/src.pro b/src/src.pro
index ba96bd09a1..2dc6fc2758 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -9,9 +9,7 @@ SUBDIRS += \
qtHaveModule(gui):qtConfig(qml-animation) {
SUBDIRS += \
quick \
-
- qtConfig(thread): \
- SUBDIRS += quickshapes
+ quickshapes
qtConfig(testlib): \
SUBDIRS += qmltest