diff options
Diffstat (limited to 'src/quick/scenegraph/qsgcontext_p.h')
-rw-r--r-- | src/quick/scenegraph/qsgcontext_p.h | 98 |
1 files changed, 43 insertions, 55 deletions
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 38d0cdaccc..6b9db105e7 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -53,6 +53,7 @@ #include <QtCore/QObject> #include <QtCore/qabstractanimation.h> +#include <QtCore/QMutex> #include <QtGui/QImage> #include <QtGui/QSurfaceFormat> @@ -61,36 +62,32 @@ #include <private/qrawfont_p.h> #include <QtQuick/qsgnode.h> -#include <QtQuick/private/qsgdepthstencilbuffer_p.h> QT_BEGIN_NAMESPACE -namespace QSGAtlasTexture { - class Manager; -} - class QSGContextPrivate; -class QSGRectangleNode; -class QSGImageNode; +class QSGInternalRectangleNode; +class QSGInternalImageNode; class QSGPainterNode; class QSGGlyphNode; -class QSGNinePatchNode; class QSGRenderer; class QSGDistanceFieldGlyphCache; class QQuickWindow; class QSGTexture; class QSGMaterial; -class QSGMaterialShader; class QSGRenderLoop; class QSGLayer; - -class QOpenGLContext; -class QOpenGLFramebufferObject; - class QQuickTextureFactory; class QSGDistanceFieldGlyphCacheManager; class QSGContext; class QQuickPaintedItem; +class QSGRendererInterface; +class QSGShaderEffectNode; +class QSGGuiThreadShaderEffectManager; +class QSGRectangleNode; +class QSGImageNode; +class QSGNinePatchNode; +class QSGSpriteNode; Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_RENDERLOOP) Q_DECLARE_LOGGING_CATEGORY(QSG_LOG_TIME_COMPILATION) @@ -112,39 +109,28 @@ public: }; QSGRenderContext(QSGContext *context); - ~QSGRenderContext(); + virtual ~QSGRenderContext(); - QOpenGLContext *openglContext() const { return m_gl; } QSGContext *sceneGraphContext() const { return m_sg; } - virtual bool isValid() const { return m_gl; } + virtual bool isValid() const { return true; } - virtual void initialize(QOpenGLContext *context); + virtual void initialize(void *context); virtual void invalidate(); - - virtual void renderNextFrame(QSGRenderer *renderer, GLuint fboId); + virtual void renderNextFrame(QSGRenderer *renderer, uint fboId) = 0; virtual void endSync(); - virtual QSharedPointer<QSGDepthStencilBuffer> depthStencilBufferForFbo(QOpenGLFramebufferObject *fbo); - QSGDepthStencilBufferManager *depthStencilBufferManager(); - virtual QSGDistanceFieldGlyphCache *distanceFieldGlyphCache(const QRawFont &font); QSGTexture *textureForFactory(QQuickTextureFactory *factory, QQuickWindow *window); - virtual QSGTexture *createTexture(const QImage &image, uint flags = CreateTexture_Alpha) const; + virtual QSGTexture *createTexture(const QImage &image, uint flags = CreateTexture_Alpha) const = 0; + virtual QSGRenderer *createRenderer() = 0; - virtual QSGRenderer *createRenderer(); + virtual void setAttachToGraphicsContext(bool attach) { Q_UNUSED(attach); } - virtual void compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode = 0, const char *fragmentCode = 0); - virtual void initialize(QSGMaterialShader *shader); + virtual int maxTextureSize() const = 0; - void setAttachToGLContext(bool attach); void registerFontengineForCleanup(QFontEngine *engine); - static QSGRenderContext *from(QOpenGLContext *context); - - bool hasBrokenIndexBufferObjects() const { return m_brokenIBOs; } - int maxTextureSize() const { return m_maxTextureSize; } - Q_SIGNALS: void initialized(); void invalidated(); @@ -153,29 +139,21 @@ public Q_SLOTS: void textureFactoryDestroyed(QObject *o); protected: - QOpenGLContext *m_gl; - QSGContext *m_sg; + // Hold m_sg with QPointer in the rare case it gets deleted before us. + QPointer<QSGContext> m_sg; QMutex m_mutex; QHash<QQuickTextureFactory *, QSGTexture *> m_textures; QSet<QSGTexture *> m_texturesToDelete; - QSGAtlasTexture::Manager *m_atlasManager; - - QSGDepthStencilBufferManager *m_depthStencilManager; QSGDistanceFieldGlyphCacheManager *m_distanceFieldCacheManager; QSet<QFontEngine *> m_fontEnginesToClean; - int m_maxTextureSize; - bool m_brokenIBOs; - bool m_serializedRender; - bool m_attachToGLContext; }; class Q_QUICK_PRIVATE_EXPORT QSGContext : public QObject { Q_OBJECT - Q_DECLARE_PRIVATE(QSGContext) public: enum AntialiasingMethod { @@ -185,30 +163,40 @@ public: }; explicit QSGContext(QObject *parent = 0); - ~QSGContext(); + virtual ~QSGContext(); virtual void renderContextInitialized(QSGRenderContext *renderContext); virtual void renderContextInvalidated(QSGRenderContext *renderContext); - virtual QSGRenderContext *createRenderContext(); - - QSGRectangleNode *createRectangleNode(const QRectF &rect, const QColor &c); - virtual QSGRectangleNode *createRectangleNode(); - virtual QSGImageNode *createImageNode(); - virtual QSGPainterNode *createPainterNode(QQuickPaintedItem *item); - virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode); - virtual QSGNinePatchNode *createNinePatchNode(); - virtual QSGLayer *createLayer(QSGRenderContext *renderContext); + virtual QSGRenderContext *createRenderContext() = 0; + + QSGInternalRectangleNode *createInternalRectangleNode(const QRectF &rect, const QColor &c); + virtual QSGInternalRectangleNode *createInternalRectangleNode() = 0; + virtual QSGInternalImageNode *createInternalImageNode() = 0; + virtual QSGPainterNode *createPainterNode(QQuickPaintedItem *item) = 0; + virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) = 0; + virtual QSGLayer *createLayer(QSGRenderContext *renderContext) = 0; + virtual QSGGuiThreadShaderEffectManager *createGuiThreadShaderEffectManager(); + virtual QSGShaderEffectNode *createShaderEffectNode(QSGRenderContext *renderContext, + QSGGuiThreadShaderEffectManager *mgr); +#if QT_CONFIG(quick_sprite) + virtual QSGSpriteNode *createSpriteNode() = 0; +#endif virtual QAnimationDriver *createAnimationDriver(QObject *parent); virtual QSize minimumFBOSize() const; - virtual QSurfaceFormat defaultSurfaceFormat() const; + virtual QSurfaceFormat defaultSurfaceFormat() const = 0; - void setDistanceFieldEnabled(bool enabled); - bool isDistanceFieldEnabled() const; + virtual QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext); + + virtual QSGRectangleNode *createRectangleNode() = 0; + virtual QSGImageNode *createImageNode() = 0; + virtual QSGNinePatchNode *createNinePatchNode() = 0; static QSGContext *createDefaultContext(); static QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image); static QSGRenderLoop *createWindowManager(); + + static void setBackend(const QString &backend); }; QT_END_NAMESPACE |