aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2012-03-05 09:28:10 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-05 11:26:23 +0100
commit416786d0f7fee72e235814c98eb2d887b6098ae3 (patch)
treec5e56a0afe871f5e61c0d60384efa6f6b4902ebf
parent12048b91d95034725830a465c33c387cec26a971 (diff)
Made QQuickWindowManager pluggable via QSGContext.
Also rename paint() to exposureChanged() as that is what the function actually means. The implementation of paint() has been removed in both trivial and threaded version as it is superflous as show() already triggers rendering. Change-Id: I7e53f42786efaf961921f10a39977de511965d71 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
-rw-r--r--src/quick/items/qquickcanvas.cpp2
-rw-r--r--src/quick/items/qquickwindowmanager.cpp43
-rw-r--r--src/quick/items/qquickwindowmanager_p.h5
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h2
-rw-r--r--src/quick/scenegraph/qsgcontextplugin.cpp18
-rw-r--r--src/quick/scenegraph/qsgcontextplugin_p.h4
6 files changed, 45 insertions, 29 deletions
diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp
index 92a422a56d..3d10d55638 100644
--- a/src/quick/items/qquickcanvas.cpp
+++ b/src/quick/items/qquickcanvas.cpp
@@ -166,7 +166,7 @@ QQuickRootItem::QQuickRootItem()
void QQuickCanvas::exposeEvent(QExposeEvent *)
{
Q_D(QQuickCanvas);
- d->windowManager->paint(this);
+ d->windowManager->exposureChanged(this);
}
void QQuickCanvas::resizeEvent(QResizeEvent *)
diff --git a/src/quick/items/qquickwindowmanager.cpp b/src/quick/items/qquickwindowmanager.cpp
index 5de8ad1279..12c5dbd932 100644
--- a/src/quick/items/qquickwindowmanager.cpp
+++ b/src/quick/items/qquickwindowmanager.cpp
@@ -188,7 +188,7 @@ public:
void canvasDestroyed(QQuickCanvas *canvas);
- void paint(QQuickCanvas *canvas);
+ void exposureChanged(QQuickCanvas *canvas);
QImage grab(QQuickCanvas *canvas);
void resize(QQuickCanvas *canvas, const QSize &size);
void handleDeferredUpdate();
@@ -297,7 +297,7 @@ public:
void initializeGL();
void renderCanvas(QQuickCanvas *canvas);
- void paint(QQuickCanvas *canvas);
+ void exposureChanged(QQuickCanvas *canvas);
QImage grab(QQuickCanvas *canvas);
void resize(QQuickCanvas *canvas, const QSize &size);
void wakeup();
@@ -333,14 +333,21 @@ QQuickWindowManager *QQuickWindowManager::instance()
static QQuickWindowManager *theInstance;
if (!theInstance) {
- bool fancy = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedOpenGL);
+
+ theInstance = QSGContext::createWindowManager();
+
+ bool fancy = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::BufferQueueingOpenGL);
if (qmlNoThreadedRenderer())
fancy = false;
+
if (qmlFixedAnimationStep())
QUnifiedTimer::instance(true)->setConsistentTiming(true);
- theInstance = fancy
- ? (QQuickWindowManager*) new QQuickRenderThreadSingleContextWindowManager
- : (QQuickWindowManager*) new QQuickTrivialWindowManager;
+
+ if (!theInstance) {
+ theInstance = fancy
+ ? (QQuickWindowManager*) new QQuickRenderThreadSingleContextWindowManager
+ : (QQuickWindowManager*) new QQuickTrivialWindowManager;
+ }
}
return theInstance;
}
@@ -932,26 +939,15 @@ void QQuickRenderThreadSingleContextWindowManager::animationStopped()
}
-void QQuickRenderThreadSingleContextWindowManager::paint(QQuickCanvas *canvas)
+void QQuickRenderThreadSingleContextWindowManager::exposureChanged(QQuickCanvas *canvas)
{
Q_UNUSED(canvas);
#ifdef THREAD_DEBUG
- printf("GUI: paint called: %p\n", canvas);
+ printf("GUI: exposure changed: %p\n", canvas);
#endif
- lockInGui();
- exhaustSyncEvent();
-
- isPaintCompleted = false;
- while (isRunning() && !isPaintCompleted) {
- if (isRenderBlocked)
- wake();
- wait();
- }
- unlockInGui();
-
#ifdef THREAD_DEBUG
- printf("GUI: paint done: %p\n", canvas);
+ printf("GUI: exposure changed done: %p\n", canvas);
#endif
}
@@ -1234,13 +1230,8 @@ void QQuickTrivialWindowManager::renderCanvas(QQuickCanvas *canvas)
maybeUpdate(canvas);
}
-void QQuickTrivialWindowManager::paint(QQuickCanvas *canvas)
+void QQuickTrivialWindowManager::exposureChanged(QQuickCanvas *canvas)
{
- if (!m_windows.contains(canvas))
- return;
-
- m_windows[canvas].updatePending = true;
- renderCanvas(canvas);
}
QImage QQuickTrivialWindowManager::grab(QQuickCanvas *canvas)
diff --git a/src/quick/items/qquickwindowmanager_p.h b/src/quick/items/qquickwindowmanager_p.h
index 9372e90f5e..eb877d4756 100644
--- a/src/quick/items/qquickwindowmanager_p.h
+++ b/src/quick/items/qquickwindowmanager_p.h
@@ -43,13 +43,14 @@
#define QQUICKWINDOWMANAGER_P_H
#include <QtGui/QImage>
+#include <qtquickglobal.h>
QT_BEGIN_NAMESPACE
class QQuickCanvas;
class QSGContext;
-class QQuickWindowManager
+class Q_QUICK_EXPORT QQuickWindowManager
{
public:
virtual ~QQuickWindowManager();
@@ -59,7 +60,7 @@ public:
virtual void canvasDestroyed(QQuickCanvas *canvas) = 0;
- virtual void paint(QQuickCanvas *canvas) = 0;
+ virtual void exposureChanged(QQuickCanvas *canvas) = 0;
virtual QImage grab(QQuickCanvas *canvas) = 0;
virtual void resize(QQuickCanvas *canvas, const QSize &size) = 0;
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 0f8b5ae1de..dfb960f420 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -68,6 +68,7 @@ class QSGTexture;
class QSGMaterial;
class QSGMaterialShader;
class QSGEngine;
+class QQuickWindowManager;
class QOpenGLContext;
class QOpenGLFramebufferObject;
@@ -122,6 +123,7 @@ public:
virtual QAnimationDriver *createAnimationDriver(QObject *parent);
static QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image);
+ static QQuickWindowManager *createWindowManager();
public slots:
diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp
index b8a66fd0c0..bd1c4cece8 100644
--- a/src/quick/scenegraph/qsgcontextplugin.cpp
+++ b/src/quick/scenegraph/qsgcontextplugin.cpp
@@ -152,5 +152,23 @@ QQuickTextureFactory *QSGContext::createTextureFactoryFromImage(const QImage &im
}
+/*!
+ \fn QQuickWindowManager *createWindowManager()
+
+ Calls into the scene graph adaptation if available and creates a hardware
+ specific window manager.
+ */
+
+QQuickWindowManager *QSGContext::createWindowManager()
+{
+ QSGAdaptionPluginData *plugin = contextFactory();
+ if (plugin->factory)
+ return plugin->factory->createWindowManager();
+ return 0;
+}
+
+
+
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgcontextplugin_p.h b/src/quick/scenegraph/qsgcontextplugin_p.h
index d0d8ea143b..cc7761a095 100644
--- a/src/quick/scenegraph/qsgcontextplugin_p.h
+++ b/src/quick/scenegraph/qsgcontextplugin_p.h
@@ -54,11 +54,14 @@ QT_BEGIN_NAMESPACE
class QSGContext;
+class QQuickWindowManager;
+
struct Q_QUICK_EXPORT QSGContextFactoryInterface : public QFactoryInterface
{
virtual QSGContext *create(const QString &key) const = 0;
virtual QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image) = 0;
+ virtual QQuickWindowManager *createWindowManager() = 0;
};
#define QSGContextFactoryInterface_iid \
@@ -77,6 +80,7 @@ public:
virtual QSGContext *create(const QString &key) const = 0;
virtual QQuickTextureFactory *createTextureFactoryFromImage(const QImage &) { return 0; }
+ virtual QQuickWindowManager *createWindowManager() { return 0; }
};
QT_END_NAMESPACE