From 90d98e1330bd46b5defafd5d6b86fa8fe157b48d Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 15 Mar 2016 13:39:41 +0100 Subject: Enable building Qt Quick module with QT_NO_OPENGL defined Currently the Qt Quick module depends on either the OpenGL or OpenGLES headers being available at build time. Since we are adding support for adaptations that do not depend on OpenGL, it should be possible to build Qt Quick in environments that do not have OpenGL development headers. This does present many challenges though because in some cases GL types, and classes that require OpenGL are part of the public APIs. However since these classes were never available when QT_NO_OPENGL was defined, it should be possible to redefine the function signatures under this scenario, since it's not possible to break binary compatibility if there never were any binaries to break compatibility with. One of the bigger changes that was necessary to facilitate this change is creating interfaces out of QSGContext and QSGRenderContext. Here the default behavior was usage of OpenGL directly, even though subclasses could override all OpenGL usage. Making them interfaces should bring QSGContext and QSGRenderContext more in line with the other classes present in the adaptation layer. Change-Id: Iaa54dc0f6cfd18d2da1d059548abf509bd71f200 Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/qsgcontext_p.h | 68 +++++++++---------------------------- 1 file changed, 16 insertions(+), 52 deletions(-) (limited to 'src/quick/scenegraph/qsgcontext_p.h') diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 38d0cdaccc..3893560142 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -53,6 +53,7 @@ #include #include +#include #include #include @@ -61,14 +62,9 @@ #include #include -#include QT_BEGIN_NAMESPACE -namespace QSGAtlasTexture { - class Manager; -} - class QSGContextPrivate; class QSGRectangleNode; class QSGImageNode; @@ -80,13 +76,8 @@ class QSGDistanceFieldGlyphCache; class QQuickWindow; class QSGTexture; class QSGMaterial; -class QSGMaterialShader; class QSGRenderLoop; class QSGLayer; - -class QOpenGLContext; -class QOpenGLFramebufferObject; - class QQuickTextureFactory; class QSGDistanceFieldGlyphCacheManager; class QSGContext; @@ -112,39 +103,24 @@ 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 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 QSGRenderer *createRenderer(); + virtual QSGTexture *createTexture(const QImage &image, uint flags = CreateTexture_Alpha) const = 0; + virtual QSGRenderer *createRenderer() = 0; - virtual void compile(QSGMaterialShader *shader, QSGMaterial *material, const char *vertexCode = 0, const char *fragmentCode = 0); - virtual void initialize(QSGMaterialShader *shader); - - 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 +129,20 @@ public Q_SLOTS: void textureFactoryDestroyed(QObject *o); protected: - QOpenGLContext *m_gl; QSGContext *m_sg; QMutex m_mutex; QHash m_textures; QSet m_texturesToDelete; - QSGAtlasTexture::Manager *m_atlasManager; - - QSGDepthStencilBufferManager *m_depthStencilManager; QSGDistanceFieldGlyphCacheManager *m_distanceFieldCacheManager; QSet 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,26 +152,23 @@ public: }; explicit QSGContext(QObject *parent = 0); - ~QSGContext(); + virtual ~QSGContext(); virtual void renderContextInitialized(QSGRenderContext *renderContext); virtual void renderContextInvalidated(QSGRenderContext *renderContext); - virtual QSGRenderContext *createRenderContext(); + virtual QSGRenderContext *createRenderContext() = 0; 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 QSGRectangleNode *createRectangleNode() = 0; + virtual QSGImageNode *createImageNode() = 0; + virtual QSGPainterNode *createPainterNode(QQuickPaintedItem *item) = 0; + virtual QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) = 0; + virtual QSGNinePatchNode *createNinePatchNode() = 0; + virtual QSGLayer *createLayer(QSGRenderContext *renderContext) = 0; virtual QAnimationDriver *createAnimationDriver(QObject *parent); virtual QSize minimumFBOSize() const; - virtual QSurfaceFormat defaultSurfaceFormat() const; - - void setDistanceFieldEnabled(bool enabled); - bool isDistanceFieldEnabled() const; + virtual QSurfaceFormat defaultSurfaceFormat() const = 0; static QSGContext *createDefaultContext(); static QQuickTextureFactory *createTextureFactoryFromImage(const QImage &image); -- cgit v1.2.3