summaryrefslogtreecommitdiffstats
path: root/src/datavisualization
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2015-10-20 13:18:59 +0300
committerMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2015-10-22 10:08:51 +0000
commit31f9c57bc50ae053cfaf039a1dfdb128e2494458 (patch)
tree316138cb73c49877f5a80a8496c2f1b737122fb5 /src/datavisualization
parent4162ddeb02ee41fd4217d7f3d93d45cab3313ba8 (diff)
Fix issues with COIN builds
-Fix miscellaneous compile errors -Move manual tests to manual folder and enable export of autotests -Added widgets requirement -Fixed autotests -Fixed renderer and controller synchronization in QML case -Treat fallback Mesa as ES2 similar to setting AA_UseSoftwareOpenGL Change-Id: If6619733725d079e339bef16262e5ea1450ab20f Reviewed-by: Tomi Korpipää <tomi.korpipaa@theqtcompany.com>
Diffstat (limited to 'src/datavisualization')
-rw-r--r--src/datavisualization/engine/abstract3dcontroller.cpp6
-rw-r--r--src/datavisualization/engine/abstract3dcontroller_p.h3
-rw-r--r--src/datavisualization/engine/bars3dcontroller.cpp7
-rw-r--r--src/datavisualization/engine/qabstract3dgraph.cpp1
-rw-r--r--src/datavisualization/engine/scatter3dcontroller.cpp7
-rw-r--r--src/datavisualization/engine/surface3dcontroller.cpp5
-rw-r--r--src/datavisualization/utils/qutils.h21
-rw-r--r--src/datavisualization/utils/texturehelper.cpp3
-rw-r--r--src/datavisualization/utils/utils.cpp19
9 files changed, 54 insertions, 18 deletions
diff --git a/src/datavisualization/engine/abstract3dcontroller.cpp b/src/datavisualization/engine/abstract3dcontroller.cpp
index 7a592e04..1c8c0958 100644
--- a/src/datavisualization/engine/abstract3dcontroller.cpp
+++ b/src/datavisualization/engine/abstract3dcontroller.cpp
@@ -31,6 +31,7 @@
#include "utils_p.h"
#include <QtCore/QThread>
#include <QtGui/QOpenGLFramebufferObject>
+#include <QtCore/QMutexLocker>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -103,6 +104,7 @@ Abstract3DController::~Abstract3DController()
void Abstract3DController::destroyRenderer()
{
+ QMutexLocker mutexLocker(&m_renderMutex);
// Renderer can be in another thread, don't delete it directly in that case
if (m_renderer && m_renderer->thread() && m_renderer->thread() != this->thread())
m_renderer->deleteLater();
@@ -117,6 +119,7 @@ void Abstract3DController::destroyRenderer()
*/
void Abstract3DController::setRenderer(Abstract3DRenderer *renderer)
{
+ // Note: This function must be called within render mutex
m_renderer = renderer;
// If renderer is created in different thread than controller, make sure renderer gets
@@ -527,6 +530,8 @@ void Abstract3DController::synchDataToRenderer()
void Abstract3DController::render(const GLuint defaultFboHandle)
{
+ QMutexLocker mutexLocker(&m_renderMutex);
+
// If not initialized, do nothing.
if (!m_renderer)
return;
@@ -978,6 +983,7 @@ void Abstract3DController::markSeriesVisualsDirty()
void Abstract3DController::requestRender(QOpenGLFramebufferObject *fbo)
{
+ QMutexLocker mutexLocker(&m_renderMutex);
m_renderer->render(fbo->handle());
}
diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h
index e6209bb3..9ed5a7d7 100644
--- a/src/datavisualization/engine/abstract3dcontroller_p.h
+++ b/src/datavisualization/engine/abstract3dcontroller_p.h
@@ -42,6 +42,7 @@
#include <QtGui/QLinearGradient>
#include <QtCore/QTime>
#include <QtCore/QLocale>
+#include <QtCore/QMutex>
QT_FORWARD_DECLARE_CLASS(QOpenGLFramebufferObject)
@@ -215,6 +216,8 @@ protected:
int m_selectedCustomItemIndex;
qreal m_margin;
+ QMutex m_renderMutex;
+
explicit Abstract3DController(QRect initialViewport, Q3DScene *scene, QObject *parent = 0);
public:
diff --git a/src/datavisualization/engine/bars3dcontroller.cpp b/src/datavisualization/engine/bars3dcontroller.cpp
index 9f114f3d..c1858211 100644
--- a/src/datavisualization/engine/bars3dcontroller.cpp
+++ b/src/datavisualization/engine/bars3dcontroller.cpp
@@ -27,6 +27,7 @@
#include "qbar3dseries_p.h"
#include "thememanager_p.h"
#include "q3dtheme_p.h"
+#include <QtCore/QMutexLocker>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -56,6 +57,8 @@ Bars3DController::~Bars3DController()
void Bars3DController::initializeOpenGL()
{
+ QMutexLocker mutexLocker(&m_renderMutex);
+
// Initialization is called multiple times when Qt Quick components are used
if (isInitialized())
return;
@@ -63,6 +66,8 @@ void Bars3DController::initializeOpenGL()
m_renderer = new Bars3DRenderer(this);
setRenderer(m_renderer);
+
+ mutexLocker.unlock();
synchDataToRenderer();
emitNeedRender();
@@ -70,6 +75,8 @@ void Bars3DController::initializeOpenGL()
void Bars3DController::synchDataToRenderer()
{
+ QMutexLocker mutexLocker(&m_renderMutex);
+
if (!isInitialized())
return;
diff --git a/src/datavisualization/engine/qabstract3dgraph.cpp b/src/datavisualization/engine/qabstract3dgraph.cpp
index 0b58b453..2f3caccd 100644
--- a/src/datavisualization/engine/qabstract3dgraph.cpp
+++ b/src/datavisualization/engine/qabstract3dgraph.cpp
@@ -1105,7 +1105,6 @@ QImage QAbstract3DGraphPrivate::renderToImage(int msaaSamples, const QSize &imag
imageSize.height()));
m_visualController->synchDataToRenderer();
fbo->bind();
- m_context->swapBuffers(m_offscreenSurface);
m_visualController->requestRender(fbo);
image = fbo->toImage();
fbo->release();
diff --git a/src/datavisualization/engine/scatter3dcontroller.cpp b/src/datavisualization/engine/scatter3dcontroller.cpp
index a6406cd6..a78c0426 100644
--- a/src/datavisualization/engine/scatter3dcontroller.cpp
+++ b/src/datavisualization/engine/scatter3dcontroller.cpp
@@ -24,6 +24,7 @@
#include "qvalue3daxis_p.h"
#include "qscatterdataproxy_p.h"
#include "qscatter3dseries_p.h"
+#include <QtCore/QMutexLocker>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -50,12 +51,16 @@ Scatter3DController::~Scatter3DController()
void Scatter3DController::initializeOpenGL()
{
+ QMutexLocker mutexLocker(&m_renderMutex);
+
// Initialization is called multiple times when Qt Quick components are used
if (isInitialized())
return;
m_renderer = new Scatter3DRenderer(this);
setRenderer(m_renderer);
+
+ mutexLocker.unlock();
synchDataToRenderer();
emitNeedRender();
@@ -63,6 +68,8 @@ void Scatter3DController::initializeOpenGL()
void Scatter3DController::synchDataToRenderer()
{
+ QMutexLocker mutexLocker(&m_renderMutex);
+
if (!isInitialized())
return;
diff --git a/src/datavisualization/engine/surface3dcontroller.cpp b/src/datavisualization/engine/surface3dcontroller.cpp
index 15dc60e1..82885c01 100644
--- a/src/datavisualization/engine/surface3dcontroller.cpp
+++ b/src/datavisualization/engine/surface3dcontroller.cpp
@@ -24,6 +24,7 @@
#include "qvalue3daxis_p.h"
#include "qsurfacedataproxy_p.h"
#include "qsurface3dseries_p.h"
+#include <QtCore/QMutexLocker>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -49,6 +50,8 @@ Surface3DController::~Surface3DController()
void Surface3DController::initializeOpenGL()
{
+ QMutexLocker mutexLocker(&m_renderMutex);
+
// Initialization is called multiple times when Qt Quick components are used
if (isInitialized())
return;
@@ -61,6 +64,8 @@ void Surface3DController::initializeOpenGL()
void Surface3DController::synchDataToRenderer()
{
+ QMutexLocker mutexLocker(&m_renderMutex);
+
if (!isInitialized())
return;
diff --git a/src/datavisualization/utils/qutils.h b/src/datavisualization/utils/qutils.h
index 22937cae..6bf995b7 100644
--- a/src/datavisualization/utils/qutils.h
+++ b/src/datavisualization/utils/qutils.h
@@ -24,12 +24,14 @@
#include <QtGui/QSurfaceFormat>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLFunctions>
#include <QtGui/QOffscreenSurface>
#include <QtCore/QCoreApplication>
namespace QtDataVisualization {
-inline static QSurfaceFormat qDefaultSurfaceFormat(bool antialias = true)
+static inline QSurfaceFormat qDefaultSurfaceFormat(bool antialias = true) Q_DECL_UNUSED;
+static inline QSurfaceFormat qDefaultSurfaceFormat(bool antialias)
{
bool isES = false;
@@ -61,20 +63,23 @@ inline static QSurfaceFormat qDefaultSurfaceFormat(bool antialias = true)
isES = ctx->isOpenGLES();
#endif
- if (dummySurface) {
- ctx->doneCurrent();
- delete ctx;
- 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)) {
+ const GLubyte *openGLVersion = ctx->functions()->glGetString(GL_VERSION);
+ QString versionStr = QString::fromLatin1((const char *)openGLVersion).toLower();
+ if (versionStr.contains(QStringLiteral("mesa"))
+ || QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) {
qWarning("Only OpenGL ES2 emulation is available for software rendering.");
isES = true;
}
#endif
+ if (dummySurface) {
+ ctx->doneCurrent();
+ delete ctx;
+ delete dummySurface;
+ }
+
if (isES) {
// For ES2 only attributes
surfaceFormat.setRedBufferSize(8);
diff --git a/src/datavisualization/utils/texturehelper.cpp b/src/datavisualization/utils/texturehelper.cpp
index 179525f1..05439665 100644
--- a/src/datavisualization/utils/texturehelper.cpp
+++ b/src/datavisualization/utils/texturehelper.cpp
@@ -337,7 +337,8 @@ GLuint TextureHelper::createDepthTextureFrameBuffer(const QSize &size, GLuint &f
void TextureHelper::deleteTexture(GLuint *texture)
{
if (texture && *texture) {
- glDeleteTextures(1, texture);
+ if (QOpenGLContext::currentContext())
+ glDeleteTextures(1, texture);
*texture = 0;
}
}
diff --git a/src/datavisualization/utils/utils.cpp b/src/datavisualization/utils/utils.cpp
index a3809733..e67e636f 100644
--- a/src/datavisualization/utils/utils.cpp
+++ b/src/datavisualization/utils/utils.cpp
@@ -20,11 +20,11 @@
******************************************************************************/
#include "utils_p.h"
-#include "qutils.h"
#include <QtGui/QPainter>
#include <QtGui/QOpenGLContext>
#include <QtGui/QOffscreenSurface>
+#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
@@ -352,20 +352,23 @@ void Utils::resolveStatics()
ctx->functions()->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
- if (dummySurface) {
- ctx->doneCurrent();
- delete ctx;
- 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)) {
+ const GLubyte *openGLVersion = ctx->functions()->glGetString(GL_VERSION);
+ QString versionStr = QString::fromLatin1((const char *)openGLVersion).toLower();
+ if (versionStr.contains(QStringLiteral("mesa"))
+ || QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) {
qWarning("Only OpenGL ES2 emulation is available for software rendering.");
isES = true;
}
#endif
+ if (dummySurface) {
+ ctx->doneCurrent();
+ delete ctx;
+ delete dummySurface;
+ }
+
staticsResolved = true;
}