diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index b643333dbb..c0bc67bcfc 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -987,8 +987,13 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const GLShader *ShaderManager::generateShader(ShaderTraits traits) { - const QByteArray vertex = generateVertexSource(traits); - const QByteArray fragment = generateFragmentSource(traits); + return generateCustomShader(traits); +} + +GLShader *ShaderManager::generateCustomShader(ShaderTraits traits, const QByteArray &vertexSource, const QByteArray &fragmentSource) +{ + const QByteArray vertex = vertexSource.isEmpty() ? generateVertexSource(traits) : vertexSource; + const QByteArray fragment = fragmentSource.isEmpty() ? generateFragmentSource(traits) : fragmentSource; #if 0 qCDebug(LIBKWINGLUTILS) << "**************"; diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h index 553e713cff..1db702e6c9 100644 --- a/libkwineffects/kwinglutils.h +++ b/libkwineffects/kwinglutils.h @@ -361,6 +361,24 @@ public: **/ GLShader *loadShaderFromCode(const QByteArray &vertexSource, const QByteArray &fragmentSource); + /** + * Creates a custom shader with the given @p traits and custom @p vertexSource and or @p fragmentSource. + * If the @p vertexSource is empty a vertex shader with the given @p traits is generated. + * If it is not empty the @p vertexSource is used as the source for the vertex shader. + * + * The same applies for argument @p fragmentSource just for the fragment shader. + * + * So if both @p vertesSource and @p fragmentSource are provided the @p traits are ignored. + * If neither are provided a new shader following the @p traits is generated. + * + * @param traits The shader traits for generating the shader + * @param vertesSource optional vertex shader source code to be used instead of shader traits + * @param fragmentSource optional fragment shader source code to be used instead of shader traits + * @return new generated shader + * @since 5.6 + **/ + GLShader *generateCustomShader(ShaderTraits traits, const QByteArray &vertexSource = QByteArray(), const QByteArray &fragmentSource = QByteArray()); + /** * Compiles and tests the dynamically generated shaders. * Returns true if successful and false otherwise.