Commit 35e0abb0 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

kwineffects: Rename generateShaderFromResources() to generateShaderFromFile()

It works both with resource files and normal files.
parent 754e0d8f
......@@ -71,7 +71,7 @@ bool InvertEffect::loadData()
ensureResources();
m_inited = true;
m_shader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral(":/effects/invert/shaders/invert.frag"));
m_shader = ShaderManager::instance()->generateShaderFromFile(ShaderTrait::MapTexture, QString(), QStringLiteral(":/effects/invert/shaders/invert.frag"));
if (!m_shader->isValid()) {
qCCritical(KWIN_INVERT) << "The shader failed to load!";
return false;
......
......@@ -114,7 +114,7 @@ bool LookingGlassEffect::loadData()
return false;
}
m_shader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral(":/effects/lookingglass/shaders/lookingglass.frag"));
m_shader = ShaderManager::instance()->generateShaderFromFile(ShaderTrait::MapTexture, QString(), QStringLiteral(":/effects/lookingglass/shaders/lookingglass.frag"));
if (m_shader->isValid()) {
ShaderBinder binder(m_shader);
m_shader->setUniform("u_textureSize", QVector2D(screenSize.width(), screenSize.height()));
......
......@@ -152,7 +152,7 @@ void StartupFeedbackEffect::reconfigure(Effect::ReconfigureFlags flags)
m_type = BlinkingFeedback;
if (effects->compositingType() == OpenGLCompositing) {
ensureResources();
m_blinkingShader.reset(ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral(":/effects/startupfeedback/shaders/blinking-startup.frag")));
m_blinkingShader.reset(ShaderManager::instance()->generateShaderFromFile(ShaderTrait::MapTexture, QString(), QStringLiteral(":/effects/startupfeedback/shaders/blinking-startup.frag")));
if (m_blinkingShader->isValid()) {
qCDebug(KWIN_STARTUPFEEDBACK) << "Blinking Shader is valid";
} else {
......
......@@ -800,7 +800,7 @@ static QString resolveShaderFilePath(const QString &filePath)
return prefix + suffix + extension;
}
GLShader *ShaderManager::generateShaderFromResources(ShaderTraits traits, const QString &vertexFile, const QString &fragmentFile)
GLShader *ShaderManager::generateShaderFromFile(ShaderTraits traits, const QString &vertexFile, const QString &fragmentFile)
{
auto loadShaderFile = [](const QString &filePath) {
QFile file(filePath);
......
......@@ -262,9 +262,6 @@ public:
/**
* Creates a custom shader with the given @p traits and custom @p vertexFile and or @p fragmentFile.
* The file names specified in @p vertexFile and @p fragmentFile are relative paths to the shaders
* resource file shipped together with KWin. This means this method can only be used for built-in
* effects, for 3rd party effects generateCustomShader should be used.
*
* If the @p vertexFile is empty a vertex shader with the given @p traits is generated.
* If it is not empty the @p vertexFile is used as the source for the vertex shader.
......@@ -274,14 +271,16 @@ public:
* So if both @p vertexFile and @p fragmentFile are provided the @p traits are ignored.
* If neither are provided a new shader following the @p traits is generated.
*
* If a custom shader stage is provided and core profile is used, the final file path will
* be resolved by appending "_core" to the basename.
*
* @param traits The shader traits for generating the shader
* @param vertexFile optional vertex shader source code to be used instead of shader traits
* @param fragmentFile optional fragment shader source code to be used instead of shader traits
* @return new generated shader
* @see generateCustomShader
* @since 5.6
*/
GLShader *generateShaderFromResources(ShaderTraits traits, const QString &vertexFile = QString(), const QString &fragmentFile = QString());
GLShader *generateShaderFromFile(ShaderTraits traits, const QString &vertexFile = QString(), const QString &fragmentFile = QString());
/**
* @return a pointer to the ShaderManager instance
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment