From a8a90519cb35481e96fe8889846bfaa424e13e8a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 5 Feb 2014 15:55:23 -0600 Subject: Fix scenegraph backend API for material shaders. Without this change, it is not possible to implement a custom renderer (it has no way to compile or initialize material shaders). Change-Id: Ie8778f739f3551f88f0d44ccb9769063a87ff276 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/coreapi/qsgmaterial.h | 2 +- src/quick/scenegraph/qsgcontext.cpp | 14 ++++++++++++++ src/quick/scenegraph/qsgcontext_p.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h index bfe570ca02..98f4d8aecf 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterial.h +++ b/src/quick/scenegraph/coreapi/qsgmaterial.h @@ -103,7 +103,7 @@ protected: Q_DECLARE_PRIVATE(QSGMaterialShader) QSGMaterialShader(QSGMaterialShaderPrivate &dd); - friend class QSGContext; + friend class QSGRenderContext; friend class QSGBatchRenderer::ShaderManager; void setShaderSourceFile(QOpenGLShader::ShaderType type, const QString &sourceFile); diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index f9bc615f5c..5135cc629c 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -445,6 +445,20 @@ void QSGRenderContext::registerFontengineForCleanup(QFontEngine *engine) m_fontEnginesToClean << engine; } +/*! + compile/initialize are protected member functions of QSGMaterialShader. + We expose them here for custom renderers. + */ +void QSGRenderContext::compileShader(QSGMaterialShader *shader) +{ + shader->compile(); +} + +void QSGRenderContext::initializeShader(QSGMaterialShader *shader) +{ + shader->initialize(); +} + /*! Initializes the scene graph render context with the GL context \a context. This also emits the ready() signal so that the QML graph can start building scene graph nodes. diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 8378fe99b6..ef67dcceba 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -112,6 +112,9 @@ public: bool hasBrokenIndexBufferObjects() const { return m_brokenIBOs; } + void compileShader(QSGMaterialShader *shader); + void initializeShader(QSGMaterialShader *shader); + Q_SIGNALS: void initialized(); void invalidated(); -- cgit v1.2.3