diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-12 19:14:46 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-12 19:14:46 +0200 |
commit | 8b32e1cb76e24cdcf0b614c39ad702360fd479fb (patch) | |
tree | 28e52115c70d28bc9fe3e825b06e2c7799780b96 /src/quick/scenegraph | |
parent | 7f526c40345a360cd0f5fa5b707c66ec4612bbec (diff) | |
parent | cac497e7a45fc901798663006ac7894b7197a549 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I045587eac266e9b6296d9cd9e3c73031fe18bbd1
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 28 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgcontext_p.h | 1 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop_p.h | 9 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgthreadedrenderloop.cpp | 10 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgthreadedrenderloop_p.h | 6 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgwindowsrenderloop.cpp | 7 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgwindowsrenderloop_p.h | 6 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgtexture.cpp | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgtexture_p.h | 2 |
10 files changed, 63 insertions, 10 deletions
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index c47250662b..6d327b8d80 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -47,7 +47,9 @@ #include <QtQuick/private/qsgdefaultimagenode_p.h> #include <QtQuick/private/qsgdefaultglyphnode_p.h> #include <QtQuick/private/qsgdistancefieldglyphnode_p.h> +#include <QtQuick/private/qsgdistancefieldglyphnode_p_p.h> #include <QtQuick/private/qsgshareddistancefieldglyphcache_p.h> +#include <QtQuick/QSGFlatColorMaterial> #include <QtQuick/private/qsgtexture_p.h> #include <QtQuick/private/qquickpixmapcache_p.h> @@ -261,9 +263,35 @@ void QSGContext::initialize(QOpenGLContext *context) Q_ASSERT(!d->gl); d->gl = context; + precompileMaterials(); + emit initialized(); } +#define QSG_PRECOMPILE_MATERIAL(name) { name m; prepareMaterial(&m); } + +/* + * Some glsl compilers take their time compiling materials, and + * the way the scene graph is being processed, these materials + * get compiled when they are first taken into use. This can + * easily lead to skipped frames. By precompiling the most + * common materials, we potentially add a few milliseconds to the + * start up, and reduce the chance of avoiding skipped frames + * later on. + */ +void QSGContext::precompileMaterials() +{ + if (qEnvironmentVariableIsEmpty("QSG_NO_MATERIAL_PRELOADING")) { + QSG_PRECOMPILE_MATERIAL(QSGVertexColorMaterial); + QSG_PRECOMPILE_MATERIAL(QSGFlatColorMaterial); + QSG_PRECOMPILE_MATERIAL(QSGOpaqueTextureMaterial); + QSG_PRECOMPILE_MATERIAL(QSGTextureMaterial); + QSG_PRECOMPILE_MATERIAL(SmoothTextureMaterial); + QSG_PRECOMPILE_MATERIAL(SmoothColorMaterial); + QSG_PRECOMPILE_MATERIAL(QSGDistanceFieldTextMaterial); + } +} + /*! Returns if the scene graph context is ready or not, meaning that it has a valid diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index b069c53dd3..bbc42674c6 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -90,6 +90,7 @@ public: bool isReady() const; + virtual void precompileMaterials(); QSGMaterialShader *prepareMaterial(QSGMaterial *material); virtual void renderNextFrame(QSGRenderer *renderer, GLuint fboId); diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 3a608a911d..e099d94a53 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -82,7 +82,7 @@ QSGRenderLoop::~QSGRenderLoop() { } -class QSGGuiThreadRenderLoop : public QObject, public QSGRenderLoop +class QSGGuiThreadRenderLoop : public QSGRenderLoop { Q_OBJECT public: diff --git a/src/quick/scenegraph/qsgrenderloop_p.h b/src/quick/scenegraph/qsgrenderloop_p.h index b18e6f00ad..6ff9c4c5f9 100644 --- a/src/quick/scenegraph/qsgrenderloop_p.h +++ b/src/quick/scenegraph/qsgrenderloop_p.h @@ -51,8 +51,10 @@ class QQuickWindow; class QSGContext; class QAnimationDriver; -class Q_QUICK_PRIVATE_EXPORT QSGRenderLoop +class Q_QUICK_PRIVATE_EXPORT QSGRenderLoop : public QObject { + Q_OBJECT + public: virtual ~QSGRenderLoop(); @@ -77,6 +79,11 @@ public: static QSGRenderLoop *instance(); static void setInstance(QSGRenderLoop *instance); + virtual bool interleaveIncubation() const { return false; } + +signals: + void timeToIncubate(); + private: static QSGRenderLoop *s_instance; }; diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index bd69fd5464..bfd9a2fb20 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -574,6 +574,7 @@ void QSGRenderThread::syncAndRender() int waitTime = vsyncDelta - (int) waitTimer.elapsed(); if (waitTime > 0) msleep(waitTime); + emit wm->timeToIncubate(); return; } @@ -600,6 +601,7 @@ void QSGRenderThread::syncAndRender() d->fireFrameSwapped(); } RLDEBUG(" Render: - rendering done"); + emit wm->timeToIncubate(); #ifndef QSG_NO_RENDER_TIMING if (qsg_render_timing) @@ -723,7 +725,7 @@ QSGContext *QSGThreadedRenderLoop::sceneGraphContext() const return m_thread->sg; } -bool QSGThreadedRenderLoop::anyoneShowing() +bool QSGThreadedRenderLoop::anyoneShowing() const { for (int i=0; i<m_windows.size(); ++i) { QQuickWindow *c = m_windows.at(i).window; @@ -733,6 +735,11 @@ bool QSGThreadedRenderLoop::anyoneShowing() return false; } +bool QSGThreadedRenderLoop::interleaveIncubation() const +{ + return m_animation_driver->isRunning() && anyoneShowing(); +} + void QSGThreadedRenderLoop::animationStarted() { RLDEBUG("GUI: animationStarted()"); @@ -1011,7 +1018,6 @@ void QSGThreadedRenderLoop::polishAndSync() RLDEBUG("GUI: - animations advancing"); m_animation_driver->advance(); RLDEBUG("GUI: - animations done"); - // We need to trigger another sync to keep animations running... maybePostPolishRequest(); } else if (m_sync_triggered_update) { diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h index aab0e8726f..6ff5cabf43 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h +++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE class QSGRenderThread; -class QSGThreadedRenderLoop : public QObject, public QSGRenderLoop +class QSGThreadedRenderLoop : public QSGRenderLoop { Q_OBJECT public: @@ -79,7 +79,7 @@ public: bool event(QEvent *); - void wakeup(); + bool interleaveIncubation() const; public slots: void animationStarted(); @@ -91,7 +91,7 @@ private: void releaseResources(QQuickWindow *window, bool inDestructor); bool checkAndResetForceUpdate(QQuickWindow *window); - bool anyoneShowing(); + bool anyoneShowing() const; void initialize(); void maybePostPolishRequest(); diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index ce43ccf531..8e97f65ea5 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -102,6 +102,11 @@ QSGWindowsRenderLoop::QSGWindowsRenderLoop() #endif } +bool QSGWindowsRenderLoop::interleaveIncubation() const +{ + return m_animationDriver->isRunning() && anyoneShowing(); +} + QSGWindowsRenderLoop::WindowData *QSGWindowsRenderLoop::windowData(QQuickWindow *window) { for (int i=0; i<m_windows.size(); ++i) { @@ -390,6 +395,8 @@ void QSGWindowsRenderLoop::render() // and thus another render pass, so to keep things running, // make sure there is another frame pending. maybePostUpdateTimer(); + + emit timeToIncubate(); } } diff --git a/src/quick/scenegraph/qsgwindowsrenderloop_p.h b/src/quick/scenegraph/qsgwindowsrenderloop_p.h index dc3a409cd5..218e18c3e2 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop_p.h +++ b/src/quick/scenegraph/qsgwindowsrenderloop_p.h @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE -class QSGWindowsRenderLoop : public QObject, public QSGRenderLoop +class QSGWindowsRenderLoop : public QSGRenderLoop { Q_OBJECT public: @@ -80,6 +80,9 @@ public: void resize(QQuickWindow *, const QSize &) { } bool event(QEvent *event); + bool anyoneShowing() const; + + bool interleaveIncubation() const; public slots: void started(); @@ -93,7 +96,6 @@ private: void handleObscurity(); void maybePostUpdateTimer(); - bool anyoneShowing() const; WindowData *windowData(QQuickWindow *window); QList<WindowData> m_windows; diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index a104e4af2f..a69f43f8d6 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -663,6 +663,8 @@ void QSGPlainTexture::bind() QImage tmp = (m_image.format() == QImage::Format_RGB32 || m_image.format() == QImage::Format_ARGB32_Premultiplied) ? m_image : m_image.convertToFormat(QImage::Format_ARGB32_Premultiplied); + if (tmp.width() * 4 != tmp.bytesPerLine()) + tmp = tmp.copy(); #ifndef QSG_NO_RENDER_TIMING qint64 convertTime = 0; diff --git a/src/quick/scenegraph/util/qsgtexture_p.h b/src/quick/scenegraph/util/qsgtexture_p.h index 6430a93ed8..7282d4051f 100644 --- a/src/quick/scenegraph/util/qsgtexture_p.h +++ b/src/quick/scenegraph/util/qsgtexture_p.h @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE class QSGTexturePrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QSGTexture); + Q_DECLARE_PUBLIC(QSGTexture) public: QSGTexturePrivate(); |