From a96cf650b967d88757bc4e550dbdbbd24dfe55cc Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 29 Oct 2014 12:22:26 +0200 Subject: Fix crash when initializing QCustom3DLabel out of context. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTRD-3391 Change-Id: I5c2f2b674e50e7d39bc9355ebc9bcf05f22d5a39 Reviewed-by: Tomi Korpipää --- src/datavisualization/utils/utils.cpp | 71 +++++++++++++++++++---------------- src/datavisualization/utils/utils_p.h | 1 + tests/barstest/main.cpp | 22 +++++------ 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index 42a1e532..685e0707 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -28,7 +28,10 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION #define NUM_IN_POWER(y, x) for (;yfunctions()->glGetIntegerv( - GL_MAX_TEXTURE_SIZE, &maxTextureSize); - } + if (!staticsResolved) + resolveStatics(); + GLuint paddingWidth = 20; GLuint paddingHeight = 20; GLuint prePadding = 20; @@ -317,39 +319,44 @@ QQuaternion Utils::calculateRotation(const QVector3D &xyzRotations) bool Utils::isOpenGLES() { + if (!staticsResolved) + resolveStatics(); + return isES; +} + +void Utils::resolveStatics() +{ + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QWindow *dummySurface = 0; + if (!ctx) { + QSurfaceFormat surfaceFormat = qDefaultSurfaceFormat(); + dummySurface = new QWindow(); + dummySurface->setSurfaceType(QWindow::OpenGLSurface); + dummySurface->setFormat(surfaceFormat); + dummySurface->create(); + ctx = new QOpenGLContext; + ctx->setFormat(surfaceFormat); + ctx->create(); + ctx->makeCurrent(dummySurface); + } + #if defined(QT_OPENGL_ES_2) - return true; + isES = true; #elif (QT_VERSION < QT_VERSION_CHECK(5, 3, 0)) - return false; + isES = false; #else - static bool resolved = false; - static bool isES = false; - if (!resolved) { - QOpenGLContext *ctx = QOpenGLContext::currentContext(); - QWindow *dummySurface = 0; - if (!ctx) { - QSurfaceFormat surfaceFormat = qDefaultSurfaceFormat(); - dummySurface = new QWindow(); - dummySurface->setSurfaceType(QWindow::OpenGLSurface); - dummySurface->setFormat(surfaceFormat); - dummySurface->create(); - ctx = new QOpenGLContext; - ctx->setFormat(surfaceFormat); - ctx->create(); - ctx->makeCurrent(dummySurface); - } + isES = ctx->isOpenGLES(); +#endif - isES = ctx->isOpenGLES(); - resolved = true; + ctx->functions()->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); - if (dummySurface) { - ctx->doneCurrent(); - delete ctx; - delete dummySurface; - } + if (dummySurface) { + ctx->doneCurrent(); + delete ctx; + delete dummySurface; } - return isES; -#endif + + staticsResolved = true; } QT_END_NAMESPACE_DATAVISUALIZATION diff --git a/src/datavisualization/utils/utils_p.h b/src/datavisualization/utils/utils_p.h index 1a46c731..06895bcf 100644 --- a/src/datavisualization/utils/utils_p.h +++ b/src/datavisualization/utils/utils_p.h @@ -70,6 +70,7 @@ public: static float wrapValue(float value, float min, float max); static QQuaternion calculateRotation(const QVector3D &xyzRotations); static bool isOpenGLES(); + static void resolveStatics(); private: static ParamType mapFormatCharToParamType(char formatSpec); diff --git a/tests/barstest/main.cpp b/tests/barstest/main.cpp index af033990..1305fff9 100644 --- a/tests/barstest/main.cpp +++ b/tests/barstest/main.cpp @@ -35,22 +35,19 @@ #include #include #include - -static bool isOpenGLES() -{ -#if defined(QT_OPENGL_ES_2) - return true; -#elif (QT_VERSION < QT_VERSION_CHECK(5, 3, 0)) - return false; -#else - return QOpenGLContext::currentContext()->isOpenGLES(); -#endif -} +#include +#include +#include int main(int argc, char **argv) { QApplication app(argc, argv); + // Test creating custom items before graph is created + QCustom3DItem customItem; + QCustom3DLabel customLabel; + QCustom3DVolume customVolume; + QWidget *widget = new QWidget; QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); @@ -60,8 +57,7 @@ int main(int argc, char **argv) // For testing custom surface format QSurfaceFormat surfaceFormat; surfaceFormat.setDepthBufferSize(24); - if (!isOpenGLES()) - surfaceFormat.setSamples(8); + surfaceFormat.setSamples(8); Q3DBars *widgetchart = new Q3DBars(&surfaceFormat); QSize screenSize = widgetchart->screen()->size(); -- cgit v1.2.3 From 8abb93bef689861a768defa6ba7cc3c25c67be8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Thu, 30 Oct 2014 09:53:18 +0200 Subject: Designer plugin bug fix Radiallabeloffset needs 2 decimals, as step size is 0.01 Change-Id: I7766613737beb217f6dd68b5a9aca666b15c7fab Change-Id: I7766613737beb217f6dd68b5a9aca666b15c7fab Reviewed-by: Miikka Heikkinen --- src/datavisualizationqml2/designer/Scatter3DSpecifics.qml | 2 +- src/datavisualizationqml2/designer/Surface3DSpecifics.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/datavisualizationqml2/designer/Scatter3DSpecifics.qml b/src/datavisualizationqml2/designer/Scatter3DSpecifics.qml index 131f71fd..00dddcc2 100644 --- a/src/datavisualizationqml2/designer/Scatter3DSpecifics.qml +++ b/src/datavisualizationqml2/designer/Scatter3DSpecifics.qml @@ -159,7 +159,7 @@ Column { minimumValue: 0.0 maximumValue: 1.0 stepSize: 0.01 - decimals: 1 + decimals: 2 Layout.fillWidth: true } } diff --git a/src/datavisualizationqml2/designer/Surface3DSpecifics.qml b/src/datavisualizationqml2/designer/Surface3DSpecifics.qml index a834f677..9804c32c 100644 --- a/src/datavisualizationqml2/designer/Surface3DSpecifics.qml +++ b/src/datavisualizationqml2/designer/Surface3DSpecifics.qml @@ -277,7 +277,7 @@ Column { minimumValue: 0.0 maximumValue: 1.0 stepSize: 0.01 - decimals: 1 + decimals: 2 Layout.fillWidth: true } } -- cgit v1.2.3 From d430a517683096a79289ff71f942e9021868de35 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 30 Oct 2014 10:07:10 +0200 Subject: Fix crash on application shutdown. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Label items should not try to delete their textures at destructor if they are already deleted. Change-Id: I8131301bec47a0a2617b4a923d7cce430d35e18b Reviewed-by: Tomi Korpipää --- src/datavisualization/data/labelitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datavisualization/data/labelitem.cpp b/src/datavisualization/data/labelitem.cpp index ec8ba3fd..98c92854 100644 --- a/src/datavisualization/data/labelitem.cpp +++ b/src/datavisualization/data/labelitem.cpp @@ -28,7 +28,7 @@ LabelItem::LabelItem() LabelItem::~LabelItem() { - QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_textureId); + clear(); } void LabelItem::setSize(const QSize &size) -- cgit v1.2.3 From bed7f3fbf6ef94e11c9b8620f7926a1b6751024f Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 30 Oct 2014 12:32:50 +0200 Subject: Fix another crash at app shutdown. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Context doesn't exist on all envs at shutdown. Change-Id: I6c0398203f0ab3ceaa38f64936cdf375c43e9f55 Reviewed-by: Tomi Korpipää --- src/datavisualization/data/labelitem.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/datavisualization/data/labelitem.cpp b/src/datavisualization/data/labelitem.cpp index 98c92854..4e0e9b5c 100644 --- a/src/datavisualization/data/labelitem.cpp +++ b/src/datavisualization/data/labelitem.cpp @@ -54,10 +54,9 @@ GLuint LabelItem::textureId() const void LabelItem::clear() { - if (m_textureId) { + if (m_textureId && QOpenGLContext::currentContext()) QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_textureId); - m_textureId = 0; - } + m_textureId = 0; m_size = QSize(0, 0); } -- cgit v1.2.3 From 20d1d25119e67724ac8fcb0a69451cd8c1fb984c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 30 Oct 2014 13:19:28 +0200 Subject: Fix crash on qmloscilloscope in Qt 5.4 Binding slider value to its minimum value is not correct, so just initialize it on component complete. Change-Id: Ia21ecbffdef84448b70c6b09d240ea4f854ca541 Reviewed-by: Mika Salmela --- examples/datavisualization/qmloscilloscope/datasource.cpp | 2 +- examples/datavisualization/qmloscilloscope/qml/qmloscilloscope/main.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/datavisualization/qmloscilloscope/datasource.cpp b/examples/datavisualization/qmloscilloscope/datasource.cpp index f466b2b0..0bb5ec2b 100644 --- a/examples/datavisualization/qmloscilloscope/datasource.cpp +++ b/examples/datavisualization/qmloscilloscope/datasource.cpp @@ -45,7 +45,7 @@ void DataSource::generateData(int cacheCount, int rowCount, int columnCount, float xMin, float xMax, float yMin, float yMax, float zMin, float zMax) { - if (!cacheCount) + if (!cacheCount || !rowCount || !columnCount) return; clearData(); diff --git a/examples/datavisualization/qmloscilloscope/qml/qmloscilloscope/main.qml b/examples/datavisualization/qmloscilloscope/qml/qmloscilloscope/main.qml index c2e6b70b..2ad43e97 100644 --- a/examples/datavisualization/qmloscilloscope/qml/qmloscilloscope/main.qml +++ b/examples/datavisualization/qmloscilloscope/qml/qmloscilloscope/main.qml @@ -150,7 +150,7 @@ Item { maximumValue: minimumValue * 10 stepSize: mainView.sampleCache updateValueWhileDragging: false - value: minimumValue * 2 + Component.onCompleted: value = minimumValue * 2 } Rectangle { -- cgit v1.2.3 From 2d61b8f27a74168ca06a32c4d2f077af2cbc7b88 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 30 Oct 2014 14:00:43 +0200 Subject: Use QOffscreenSurface instead of QWindow for dummy surfaces. Android doesn't like creating extra QWindows, so changed dummy surfaces used to do static initialization and cleanup to use QOffscreenSurface. Change-Id: Ia42e288a05ef49524252c457f3a3494677e3fc63 Reviewed-by: Mika Salmela --- src/datavisualization/engine/abstract3drenderer.cpp | 5 ++--- src/datavisualization/engine/abstract3drenderer_p.h | 4 ++-- src/datavisualization/utils/utils.cpp | 7 +++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp index cfc691af..fc3b4a19 100644 --- a/src/datavisualization/engine/abstract3drenderer.cpp +++ b/src/datavisualization/engine/abstract3drenderer.cpp @@ -28,7 +28,7 @@ #include "scatter3drenderer_p.h" #include -#include +#include #include QT_BEGIN_NAMESPACE_DATAVISUALIZATION @@ -1789,8 +1789,7 @@ void Abstract3DRenderer::fixContextBeforeDelete() // Otherwise we expect it to be our shared context, so we can use it for cleanup. if (!QOpenGLContext::currentContext() && !m_context.isNull() && QThread::currentThread() == this->thread()) { - m_dummySurfaceAtDelete = new QWindow(); - m_dummySurfaceAtDelete->setSurfaceType(QWindow::OpenGLSurface); + m_dummySurfaceAtDelete = new QOffscreenSurface(); m_dummySurfaceAtDelete->setFormat(m_context->format()); m_dummySurfaceAtDelete->create(); diff --git a/src/datavisualization/engine/abstract3drenderer_p.h b/src/datavisualization/engine/abstract3drenderer_p.h index 1e38023d..15793797 100644 --- a/src/datavisualization/engine/abstract3drenderer_p.h +++ b/src/datavisualization/engine/abstract3drenderer_p.h @@ -39,7 +39,7 @@ #include "seriesrendercache_p.h" #include "customrenderitem_p.h" -class QSurface; +class QOffscreenSurface; QT_BEGIN_NAMESPACE_DATAVISUALIZATION @@ -327,7 +327,7 @@ protected: QOpenGLFunctions_2_1 *m_funcs_2_1; // Not owned #endif QPointer m_context; // Not owned - QWindow *m_dummySurfaceAtDelete; + QOffscreenSurface *m_dummySurfaceAtDelete; bool m_isOpenGLES; private: diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index 685e0707..15ef444c 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include QT_BEGIN_NAMESPACE_DATAVISUALIZATION @@ -327,11 +327,10 @@ bool Utils::isOpenGLES() void Utils::resolveStatics() { QOpenGLContext *ctx = QOpenGLContext::currentContext(); - QWindow *dummySurface = 0; + QOffscreenSurface *dummySurface = 0; if (!ctx) { QSurfaceFormat surfaceFormat = qDefaultSurfaceFormat(); - dummySurface = new QWindow(); - dummySurface->setSurfaceType(QWindow::OpenGLSurface); + dummySurface = new QOffscreenSurface(); dummySurface->setFormat(surfaceFormat); dummySurface->create(); ctx = new QOpenGLContext; -- cgit v1.2.3 From 89911624cf0d8726ee594d5b689881990592e09b Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 30 Oct 2014 14:45:15 +0200 Subject: Allow small delay in scene test for viewport resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On linux, there seems to be some asynchronous activity related to window resizing, since calling processEvents() is not enough to ensure viewport size gets updated in subViews test. Use QTRY_COMPARE to allow for small delay. Change-Id: Idae04ff9436c819ef150caa57f6fa988e4011746 Reviewed-by: Tomi Korpipää --- tests/auto/cpptest/q3dscene/tst_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/cpptest/q3dscene/tst_scene.cpp b/tests/auto/cpptest/q3dscene/tst_scene.cpp index 7d1ecad3..83eff9eb 100644 --- a/tests/auto/cpptest/q3dscene/tst_scene.cpp +++ b/tests/auto/cpptest/q3dscene/tst_scene.cpp @@ -136,7 +136,7 @@ void tst_scene::subViews() QCoreApplication::processEvents(); - QCOMPARE(scene->viewport(), QRect(0, 0, 200, 200)); + QTRY_COMPARE(scene->viewport(), QRect(0, 0, 200, 200)); QCOMPARE(scene->primarySubViewport(), QRect(0, 0, 200, 200)); QCOMPARE(scene->secondarySubViewport(), QRect(0, 0, 0, 0)); -- cgit v1.2.3 From 8cebfaed9071b67cc58755fbcade70c88de60529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpipa=CC=88a=CC=88?= Date: Fri, 31 Oct 2014 13:08:42 +0200 Subject: Fixed surface slice problem Task-number: QTRD-3402 Change-Id: I70ef641fc7249b144d6e98971f1fb74f2935d706 Reviewed-by: Mika Salmela --- src/datavisualization/utils/texturehelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datavisualization/utils/texturehelper.cpp b/src/datavisualization/utils/texturehelper.cpp index 3944fb0c..16396de7 100644 --- a/src/datavisualization/utils/texturehelper.cpp +++ b/src/datavisualization/utils/texturehelper.cpp @@ -58,7 +58,7 @@ GLuint TextureHelper::create2DTexture(const QImage &image, bool useTrilinearFilt QImage texImage = image; - if (!Utils::isOpenGLES()) { + if (Utils::isOpenGLES()) { GLuint imageWidth = Utils::getNearestPowerOfTwo(image.width()); GLuint imageHeight = Utils::getNearestPowerOfTwo(image.height()); if (smoothScale) { -- cgit v1.2.3 From 8a7c69cb943a1d0676549e7cee47863524e10fb6 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 31 Oct 2014 14:05:21 +0200 Subject: Fix qmloscilloscope linking issue on some envs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iab45f95e8ff0faacc5cf50fdf052bf2c69d7988a Reviewed-by: Tomi Korpipää --- examples/datavisualization/qmloscilloscope/datasource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/datavisualization/qmloscilloscope/datasource.cpp b/examples/datavisualization/qmloscilloscope/datasource.cpp index 0bb5ec2b..353c878b 100644 --- a/examples/datavisualization/qmloscilloscope/datasource.cpp +++ b/examples/datavisualization/qmloscilloscope/datasource.cpp @@ -84,7 +84,7 @@ void DataSource::generateData(int cacheCount, int rowCount, int columnCount, float colWave = float(qSin((2.0 * M_PI * colMod) - (1.0 / 2.0 * M_PI)) + 1.0); float y = (colWave * ((float(qSin(rowColWaveAngleMul * colMod) + 1.0)))) * rowColWaveMul - + (0.15f * float(rand()) / float(RAND_MAX)) * yRangeMod; + + (0.15f * float(qrand()) / float(RAND_MAX)) * yRangeMod; int index = k + cacheIndexAdjustment; if (index >= columnCount) { -- cgit v1.2.3 From 0090db160242374d7ab6e3bedf064b366716f770 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 31 Oct 2014 14:53:26 +0200 Subject: Fix compiler warning on 64bit linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4ab8d595ac9f8b069057178079ad7714eaf6e13c Reviewed-by: Tomi Korpipää --- src/datavisualizationqml2/glstatestore.cpp | 4 ++-- src/datavisualizationqml2/glstatestore_p.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/datavisualizationqml2/glstatestore.cpp b/src/datavisualizationqml2/glstatestore.cpp index 973d5054..5775694d 100644 --- a/src/datavisualizationqml2/glstatestore.cpp +++ b/src/datavisualizationqml2/glstatestore.cpp @@ -57,7 +57,7 @@ GLStateStore::GLStateStore(QOpenGLContext *context, QObject *parent) : m_vertexAttribArrayTypes.reset(new GLint[maxVertexAttribs]); m_vertexAttribArrayNormalized.reset(new GLint[maxVertexAttribs]); m_vertexAttribArrayStrides.reset(new GLint[maxVertexAttribs]); - m_vertexAttribArrayOffsets.reset(new GLint[maxVertexAttribs]); + m_vertexAttribArrayOffsets.reset(new void *[maxVertexAttribs]); initGLDefaultState(); } @@ -336,7 +336,7 @@ void GLStateStore::restoreGLState() m_vertexAttribArrayTypes[i], m_vertexAttribArrayNormalized[i], m_vertexAttribArrayStrides[i], - (void *) m_vertexAttribArrayOffsets[i]); + m_vertexAttribArrayOffsets[i]); } glBindBuffer(GL_ARRAY_BUFFER, m_boundArrayBuffer); diff --git a/src/datavisualizationqml2/glstatestore_p.h b/src/datavisualizationqml2/glstatestore_p.h index 4add606b..48b30a15 100644 --- a/src/datavisualizationqml2/glstatestore_p.h +++ b/src/datavisualizationqml2/glstatestore_p.h @@ -71,7 +71,7 @@ public: QScopedArrayPointer m_vertexAttribArrayTypes; QScopedArrayPointer m_vertexAttribArrayNormalized; QScopedArrayPointer m_vertexAttribArrayStrides; - QScopedArrayPointer m_vertexAttribArrayOffsets; + QScopedArrayPointer m_vertexAttribArrayOffsets; GLint m_activeTexture; GLint m_texBinding2D; -- cgit v1.2.3 From a1feedcf46975a65970fb946282c742b091b508e Mon Sep 17 00:00:00 2001 From: Mika Salmela Date: Mon, 3 Nov 2014 11:22:23 +0200 Subject: Qml perf data generation on cpp Change-Id: If770c96ff84e49a747c4355e56bff002556cd659 Reviewed-by: Mika Salmela --- tests/qmlperf/datagenerator.cpp | 67 +++++++++++++++++++++++++++++++++++++ tests/qmlperf/datagenerator.h | 41 +++++++++++++++++++++++ tests/qmlperf/main.cpp | 6 ++++ tests/qmlperf/qml/qmlperf/main.qml | 18 +++------- tests/qmlperf/qml/qmlperf/script.js | 33 ------------------ tests/qmlperf/qmlperf.pro | 6 +++- tests/qmlperf/qmlperf.qrc | 1 - 7 files changed, 123 insertions(+), 49 deletions(-) create mode 100644 tests/qmlperf/datagenerator.cpp create mode 100644 tests/qmlperf/datagenerator.h delete mode 100644 tests/qmlperf/qml/qmlperf/script.js diff --git a/tests/qmlperf/datagenerator.cpp b/tests/qmlperf/datagenerator.cpp new file mode 100644 index 00000000..4819f59d --- /dev/null +++ b/tests/qmlperf/datagenerator.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include "datagenerator.h" +#include + +using namespace QtDataVisualization; + +Q_DECLARE_METATYPE(QScatter3DSeries *) + +DataGenerator::DataGenerator(QObject *parent) : + QObject(parent) +{ + qRegisterMetaType(); +} + +DataGenerator::~DataGenerator() +{ + qDebug() << __FUNCTION__; +} + +void DataGenerator::generateData(QScatter3DSeries *series, uint count) +{ + QScatterDataArray *dataArray = new QScatterDataArray; + dataArray->resize(count); + QScatterDataItem *ptrToDataArray = &dataArray->first(); + + float rand_max = float(RAND_MAX); + for (uint i = 0; i < count; i++) { + ptrToDataArray->setPosition(QVector3D(float(qrand()) / rand_max, + float(qrand()) / rand_max, + float(qrand()) / rand_max)); + ptrToDataArray++; + } + + series->dataProxy()->resetArray(dataArray); +} + +void DataGenerator::add(QScatter3DSeries *series, uint count) +{ + QScatterDataArray appendArray; + appendArray.resize(count); + + float rand_max = float(RAND_MAX); + for (uint i = 0; i < count; i++) { + appendArray[i].setPosition(QVector3D(float(qrand()) / rand_max, + float(qrand()) / rand_max, + float(qrand()) / rand_max)); + } + + series->dataProxy()->addItems(appendArray); +} diff --git a/tests/qmlperf/datagenerator.h b/tests/qmlperf/datagenerator.h new file mode 100644 index 00000000..0687ecec --- /dev/null +++ b/tests/qmlperf/datagenerator.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#ifndef DATAGENERATOR_H +#define DATAGENERATOR_H + +#include + +using namespace QtDataVisualization; + +class DataGenerator : public QObject +{ + Q_OBJECT +public: + DataGenerator(QObject *parent = 0); + virtual ~DataGenerator(); + +public slots: + void generateData(QScatter3DSeries *series, uint count); + void add(QScatter3DSeries *series, uint count); + +private: + QScatter3DSeries m_series; +}; + +#endif // DATAGENERATOR_H diff --git a/tests/qmlperf/main.cpp b/tests/qmlperf/main.cpp index 7d35b2ed..06b18816 100644 --- a/tests/qmlperf/main.cpp +++ b/tests/qmlperf/main.cpp @@ -16,8 +16,11 @@ ** ****************************************************************************/ +#include "datagenerator.h" + #include #include +#include #include #include @@ -38,6 +41,9 @@ int main(int argc, char *argv[]) QString::fromLatin1("qml"))); QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); + DataGenerator dataGenerator; + viewer.rootContext()->setContextProperty("dataGenerator", &dataGenerator); + viewer.setTitle(QStringLiteral("QML Performance")); viewer.setSource(QUrl("qrc:/qml/qmlperf/main.qml")); viewer.setResizeMode(QQuickView::SizeRootObjectToView); diff --git a/tests/qmlperf/qml/qmlperf/main.qml b/tests/qmlperf/qml/qmlperf/main.qml index 35f8df5d..bb3f1b82 100644 --- a/tests/qmlperf/qml/qmlperf/main.qml +++ b/tests/qmlperf/qml/qmlperf/main.qml @@ -20,7 +20,6 @@ import QtQuick 2.1 import QtQuick.Layouts 1.0 import QtQuick.Controls 1.0 import QtDataVisualization 1.1 -import "script.js" as Script import "." Rectangle { @@ -29,7 +28,7 @@ Rectangle { height: 1024 property var itemCount: 1000.0 - property var addItems: 1000.0 + property var addItems: 500.0 Button { id: changeButton @@ -90,7 +89,7 @@ Rectangle { text: "Add" onClicked: { itemCount = itemCount + addItems; - Script.createData(addItems); + dataGenerator.add(scatterSeries, addItems); } } @@ -102,11 +101,6 @@ Rectangle { anchors.left: mainview.left state: "meshsphere" - ListModel { - id: dataModel - Component.onCompleted: Script.createData(itemCount) - } - Scatter3D { id: scatterPlot width: graphView.width @@ -134,13 +128,9 @@ Rectangle { Scatter3DSeries { id: scatterSeries mesh: Abstract3DSeries.MeshSphere - ItemModelScatterDataProxy { - itemModel: dataModel - xPosRole: "x" - yPosRole: "y" - zPosRole: "z" - } } + + Component.onCompleted: dataGenerator.generateData(scatterSeries, itemCount); } states: [ diff --git a/tests/qmlperf/qml/qmlperf/script.js b/tests/qmlperf/qml/qmlperf/script.js deleted file mode 100644 index dc271e8d..00000000 --- a/tests/qmlperf/qml/qmlperf/script.js +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVisualization module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -//function createData(base) { -// for (var z = 0; z < 30; z++) { -// for (var x = 0; x < 30; x++) { -// var angle = (((z - 16) * (x - 16)) / 144.0) * 1.57; -// var y = Math.sin(angle + base); -// dataModel.append({"z": z, "x": x, "y": y}); -// } -// } -//} - -function createData(base) { - for (var i = 0; i < base; i++) { - dataModel.append({"z": Math.random(), "x": Math.random(), "y": Math.random()}); - } -} diff --git a/tests/qmlperf/qmlperf.pro b/tests/qmlperf/qmlperf.pro index 6560f55c..e29ef75d 100644 --- a/tests/qmlperf/qmlperf.pro +++ b/tests/qmlperf/qmlperf.pro @@ -3,10 +3,14 @@ } # The .cpp file which was generated for your project. Feel free to hack it. -SOURCES += main.cpp +SOURCES += main.cpp \ + datagenerator.cpp RESOURCES += qmlperf.qrc OTHER_FILES += doc/src/* \ doc/images/* \ qml/qmlperf/* + +HEADERS += \ + datagenerator.h diff --git a/tests/qmlperf/qmlperf.qrc b/tests/qmlperf/qmlperf.qrc index e50815c5..b52f4bb9 100644 --- a/tests/qmlperf/qmlperf.qrc +++ b/tests/qmlperf/qmlperf.qrc @@ -1,6 +1,5 @@ qml/qmlperf/main.qml - qml/qmlperf/script.js -- cgit v1.2.3 From 39d5ffbdc42f6645e13511828ea7a9997497068e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Wed, 5 Nov 2014 08:43:49 +0200 Subject: Force software renderer to using ES2 Task-number: QTRD-3410 Change-Id: I86b240b6548ec4c94f6be0dc352ed112965926f3 Change-Id: I86b240b6548ec4c94f6be0dc352ed112965926f3 Reviewed-by: Miikka Heikkinen --- README | 3 +- .../doc/src/qtdatavisualization.qdoc | 2 + src/datavisualization/utils/qutils.h | 57 ++++++++++++++++++---- src/datavisualization/utils/utils.cpp | 8 ++- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/README b/README index 667dcdaa..96099dbe 100644 --- a/README +++ b/README @@ -88,4 +88,5 @@ Known Issues "QT += datavisualization" in the pro file. This is because Qt Data Visualization QML plugin has a dependency to Qt Data Visualization C++ library, which Qt Creator doesn't automatically add to the deployment package. - +- Only OpenGL ES2 emulation is available for software renderer (that is, when using + QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL)) diff --git a/src/datavisualization/doc/src/qtdatavisualization.qdoc b/src/datavisualization/doc/src/qtdatavisualization.qdoc index b07074b1..c243a1cd 100644 --- a/src/datavisualization/doc/src/qtdatavisualization.qdoc +++ b/src/datavisualization/doc/src/qtdatavisualization.qdoc @@ -338,6 +338,8 @@ "QT += datavisualization" in the pro file. This is because Qt Data Visualization QML plugin has a dependency to Qt Data Visualization C++ library, which Qt Creator doesn't automatically add to the deployment package. + \li Only OpenGL ES2 emulation is available for software renderer (that is, when using + QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL)) \endlist */ diff --git a/src/datavisualization/utils/qutils.h b/src/datavisualization/utils/qutils.h index d4acfc99..86a0af5e 100644 --- a/src/datavisualization/utils/qutils.h +++ b/src/datavisualization/utils/qutils.h @@ -20,29 +20,68 @@ #define QUTILS_H #include +#include +#include +#include namespace QtDataVisualization { inline static QSurfaceFormat qDefaultSurfaceFormat(bool antialias = true) { + bool isES = false; + QSurfaceFormat surfaceFormat; + // Common attributes surfaceFormat.setDepthBufferSize(24); surfaceFormat.setStencilBufferSize(8); surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer); surfaceFormat.setRenderableType(QSurfaceFormat::DefaultRenderableType); + + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QOffscreenSurface *dummySurface = 0; + if (!ctx) { + dummySurface = new QOffscreenSurface(); + dummySurface->setFormat(surfaceFormat); + dummySurface->create(); + ctx = new QOpenGLContext; + ctx->setFormat(surfaceFormat); + ctx->create(); + ctx->makeCurrent(dummySurface); + } + #if defined(QT_OPENGL_ES_2) - // Antialias not supported for ES - antialias = false; - surfaceFormat.setRedBufferSize(8); - surfaceFormat.setBlueBufferSize(8); - surfaceFormat.setGreenBufferSize(8); + isES = true; +#elif (QT_VERSION < QT_VERSION_CHECK(5, 3, 0)) + isES = false; +#else + isES = ctx->isOpenGLES(); #endif - if (antialias) - surfaceFormat.setSamples(8); - else - surfaceFormat.setSamples(0); + if (dummySurface) { + ctx->doneCurrent(); + delete ctx; + delete dummySurface; + } + + // We support only ES2 emulation with software renderer for now + if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) { + qWarning("Only OpenGL ES2 emulation is available for software rendering."); + isES = true; + } + + if (isES) { + // For ES2 only attributes + surfaceFormat.setRedBufferSize(8); + surfaceFormat.setBlueBufferSize(8); + surfaceFormat.setGreenBufferSize(8); + } else { + // For OpenGL only attributes + if (antialias) + surfaceFormat.setSamples(8); + else + surfaceFormat.setSamples(0); + } return surfaceFormat; } diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index 15ef444c..df74cbd3 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -329,7 +329,7 @@ void Utils::resolveStatics() QOpenGLContext *ctx = QOpenGLContext::currentContext(); QOffscreenSurface *dummySurface = 0; if (!ctx) { - QSurfaceFormat surfaceFormat = qDefaultSurfaceFormat(); + QSurfaceFormat surfaceFormat; dummySurface = new QOffscreenSurface(); dummySurface->setFormat(surfaceFormat); dummySurface->create(); @@ -355,6 +355,12 @@ void Utils::resolveStatics() delete dummySurface; } + // We support only ES2 emulation with software renderer for now + if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) { + qWarning("Only OpenGL ES2 emulation is available for software rendering."); + isES = true; + } + staticsResolved = true; } -- cgit v1.2.3 From f19693253db3a00812a53758e88e607b8be1215e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Wed, 5 Nov 2014 10:34:10 +0200 Subject: Fixed font size jumping in ES2 Task-number: QTRD-3412 Change-Id: I7f19ee34ccdde3a227033e3a88994e157b0092c4 Change-Id: I7f19ee34ccdde3a227033e3a88994e157b0092c4 Reviewed-by: Miikka Heikkinen Reviewed-by: Mika Salmela --- src/datavisualization/utils/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index df74cbd3..edec8236 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -89,7 +89,7 @@ QImage Utils::printTextToImage(const QFont &font, const QString &text, const QCo // make a label with large empty space uint testWidth = getNearestPowerOfTwo(valueStrWidth + prePadding) >> 1; int diffToFit = (valueStrWidth + prePadding) - testWidth; - int maxSqueeze = int((valueStrWidth + prePadding) * 0.1f); + int maxSqueeze = int((valueStrWidth + prePadding) * 0.25f); if (diffToFit < maxSqueeze && maxTextureSize > GLint(testWidth)) targetWidth = testWidth; } -- cgit v1.2.3 From 46ef32d424d7e0209e52528286e31f656c654289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Wed, 5 Nov 2014 11:50:08 +0200 Subject: Added flags to software renderer test Change-Id: I0667a0e53fd07fe9c6ce7b2d63887eda1692bf3b Change-Id: I0667a0e53fd07fe9c6ce7b2d63887eda1692bf3b Reviewed-by: Miikka Heikkinen --- src/datavisualization/utils/qutils.h | 2 ++ src/datavisualization/utils/utils.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/datavisualization/utils/qutils.h b/src/datavisualization/utils/qutils.h index 86a0af5e..93226be9 100644 --- a/src/datavisualization/utils/qutils.h +++ b/src/datavisualization/utils/qutils.h @@ -64,11 +64,13 @@ inline static QSurfaceFormat qDefaultSurfaceFormat(bool antialias = true) delete dummySurface; } +#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)) // We support only ES2 emulation with software renderer for now if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) { qWarning("Only OpenGL ES2 emulation is available for software rendering."); isES = true; } +#endif if (isES) { // For ES2 only attributes diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp index edec8236..7f10bac7 100644 --- a/src/datavisualization/utils/utils.cpp +++ b/src/datavisualization/utils/utils.cpp @@ -355,11 +355,13 @@ void Utils::resolveStatics() delete dummySurface; } +#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)) // We support only ES2 emulation with software renderer for now if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) { qWarning("Only OpenGL ES2 emulation is available for software rendering."); isES = true; } +#endif staticsResolved = true; } -- cgit v1.2.3