diff --git a/lanczosfilter.cpp b/lanczosfilter.cpp
index e6054b812f..9042c03415 100644
--- a/lanczosfilter.cpp
+++ b/lanczosfilter.cpp
@@ -33,6 +33,8 @@ along with this program. If not, see .
#include
+#include
+
#include
#include
@@ -45,7 +47,6 @@ LanczosFilter::LanczosFilter(QObject* parent)
, m_offscreenTarget(0)
, m_inited(false)
, m_shader(0)
- , m_uTexUnit(0)
, m_uOffsets(0)
, m_uKernel(0)
{
@@ -84,13 +85,16 @@ void LanczosFilter::init()
if (gl->isRadeon() && gl->chipClass() < R600)
return;
}
- m_shader.reset(ShaderManager::instance()->loadFragmentShader(ShaderManager::SimpleShader,
- gl->glslVersion() >= kVersionNumber(1, 40) ?
- QStringLiteral(":/resources/shaders/1.40/lanczos-fragment.glsl") :
- QStringLiteral(":/resources/shaders/1.10/lanczos-fragment.glsl")));
+ QFile ff(gl->glslVersion() >= kVersionNumber(1, 40) ?
+ QStringLiteral(":/resources/shaders/1.40/lanczos-fragment.glsl") :
+ QStringLiteral(":/resources/shaders/1.10/lanczos-fragment.glsl"));
+ if (!ff.open(QIODevice::ReadOnly)) {
+ qCDebug(KWIN_CORE) << "Failed to open lanczos shader";
+ return;
+ }
+ m_shader.reset(ShaderManager::instance()->generateCustomShader(ShaderTrait::MapTexture, QByteArray(), ff.readAll()));
if (m_shader->isValid()) {
ShaderBinder binder(m_shader.data());
- m_uTexUnit = m_shader->uniformLocation("texUnit");
m_uKernel = m_shader->uniformLocation("kernel");
m_uOffsets = m_shader->uniformLocation("offsets");
} else {
@@ -251,6 +255,10 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
updateOffscreenSurfaces();
GLRenderTarget::pushRenderTarget(m_offscreenTarget);
+ QMatrix4x4 modelViewProjectionMatrix;
+ modelViewProjectionMatrix.ortho(0, m_offscreenTex->width(), m_offscreenTex->height(), 0 , 0, 65535);
+ thumbData.setProjectionMatrix(modelViewProjectionMatrix);
+
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
w->sceneWindow()->performPaint(mask, infiniteRegion(), thumbData);
@@ -270,6 +278,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
createOffsets(kernelSize, sw, Qt::Horizontal);
ShaderManager::instance()->pushShader(m_shader.data());
+ m_shader->setUniform(GLShader::ModelViewProjectionMatrix, modelViewProjectionMatrix);
setUniforms();
// Draw the window back into the FBO, this time scaled horizontally
@@ -408,7 +417,6 @@ void LanczosFilter::discardCacheTexture(EffectWindow *w)
void LanczosFilter::setUniforms()
{
- glUniform1i(m_uTexUnit, 0);
glUniform2fv(m_uOffsets, 16, (const GLfloat*)m_offsets);
glUniform4fv(m_uKernel, 16, (const GLfloat*)m_kernel);
}
diff --git a/lanczosfilter.h b/lanczosfilter.h
index 12a844ee8c..fff5cf28eb 100644
--- a/lanczosfilter.h
+++ b/lanczosfilter.h
@@ -65,7 +65,6 @@ private:
QBasicTimer m_timer;
bool m_inited;
QScopedPointer m_shader;
- int m_uTexUnit;
int m_uOffsets;
int m_uKernel;
QVector2D m_offsets[16];
diff --git a/shaders/1.10/lanczos-fragment.glsl b/shaders/1.10/lanczos-fragment.glsl
index 3141d7907c..b6b135cdbb 100644
--- a/shaders/1.10/lanczos-fragment.glsl
+++ b/shaders/1.10/lanczos-fragment.glsl
@@ -1,15 +1,15 @@
-uniform sampler2D texUnit;
+uniform sampler2D sampler;
uniform vec2 offsets[16];
uniform vec4 kernel[16];
-varying vec2 varyingTexCoords;
+varying vec2 texcoord0;
void main(void)
{
- vec4 sum = texture2D(texUnit, varyingTexCoords.st) * kernel[0];
+ vec4 sum = texture2D(sampler, texcoord0.st) * kernel[0];
for (int i = 1; i < 16; i++) {
- sum += texture2D(texUnit, varyingTexCoords.st - offsets[i]) * kernel[i];
- sum += texture2D(texUnit, varyingTexCoords.st + offsets[i]) * kernel[i];
+ sum += texture2D(sampler, texcoord0.st - offsets[i]) * kernel[i];
+ sum += texture2D(sampler, texcoord0.st + offsets[i]) * kernel[i];
}
gl_FragColor = sum;
}
diff --git a/shaders/1.40/lanczos-fragment.glsl b/shaders/1.40/lanczos-fragment.glsl
index 0852ea1028..a77d560674 100644
--- a/shaders/1.40/lanczos-fragment.glsl
+++ b/shaders/1.40/lanczos-fragment.glsl
@@ -1,18 +1,18 @@
#version 140
-uniform sampler2D texUnit;
+uniform sampler2D sampler;
uniform vec2 offsets[16];
uniform vec4 kernel[16];
-in vec2 varyingTexCoords;
+in vec2 texcoord0;
out vec4 fragColor;
void main(void)
{
- vec4 sum = texture(texUnit, varyingTexCoords.st) * kernel[0];
+ vec4 sum = texture(sampler, texcoord0.st) * kernel[0];
for (int i = 1; i < 16; i++) {
- sum += texture(texUnit, varyingTexCoords.st - offsets[i]) * kernel[i];
- sum += texture(texUnit, varyingTexCoords.st + offsets[i]) * kernel[i];
+ sum += texture(sampler, texcoord0.st - offsets[i]) * kernel[i];
+ sum += texture(sampler, texcoord0.st + offsets[i]) * kernel[i];
}
fragColor = sum;
}