kwin: adding a proper clipping to the lanczosfilter
This commit is contained in:
parent
05a8777edf
commit
8e8212b0ef
1 changed files with 17 additions and 4 deletions
|
@ -191,6 +191,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
|
||||||
int tw = width * data.xScale;
|
int tw = width * data.xScale;
|
||||||
int th = height * data.yScale;
|
int th = height * data.yScale;
|
||||||
const QRect textureRect(tx, ty, tw, th);
|
const QRect textureRect(tx, ty, tw, th);
|
||||||
|
const bool hardwareClipping = !(QRegion(textureRect)-region).isEmpty();
|
||||||
|
|
||||||
int sw = width;
|
int sw = width;
|
||||||
int sh = height;
|
int sh = height;
|
||||||
|
@ -199,6 +200,9 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
|
||||||
if (cachedTexture) {
|
if (cachedTexture) {
|
||||||
if (cachedTexture->width() == tw && cachedTexture->height() == th) {
|
if (cachedTexture->width() == tw && cachedTexture->height() == th) {
|
||||||
cachedTexture->bind();
|
cachedTexture->bind();
|
||||||
|
if (hardwareClipping) {
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
}
|
||||||
if (ShaderManager::instance()->isValid()) {
|
if (ShaderManager::instance()->isValid()) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
@ -212,15 +216,18 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
|
||||||
shader->setUniform(GLShader::Saturation, data.saturation);
|
shader->setUniform(GLShader::Saturation, data.saturation);
|
||||||
shader->setUniform(GLShader::AlphaToOne, 0);
|
shader->setUniform(GLShader::AlphaToOne, 0);
|
||||||
|
|
||||||
cachedTexture->render(textureRect, textureRect);
|
cachedTexture->render(region, textureRect, hardwareClipping);
|
||||||
|
|
||||||
ShaderManager::instance()->popShader();
|
ShaderManager::instance()->popShader();
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
} else {
|
} else {
|
||||||
prepareRenderStates(cachedTexture, data.opacity, data.brightness, data.saturation);
|
prepareRenderStates(cachedTexture, data.opacity, data.brightness, data.saturation);
|
||||||
cachedTexture->render(textureRect, textureRect);
|
cachedTexture->render(region, textureRect, hardwareClipping);
|
||||||
restoreRenderStates(cachedTexture, data.opacity, data.brightness, data.saturation);
|
restoreRenderStates(cachedTexture, data.opacity, data.brightness, data.saturation);
|
||||||
}
|
}
|
||||||
|
if (hardwareClipping) {
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
}
|
||||||
cachedTexture->unbind();
|
cachedTexture->unbind();
|
||||||
m_timer.start(5000, this);
|
m_timer.start(5000, this);
|
||||||
return;
|
return;
|
||||||
|
@ -330,6 +337,9 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, m_offscreenTex->height() - th, tw, th);
|
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, m_offscreenTex->height() - th, tw, th);
|
||||||
GLRenderTarget::popRenderTarget();
|
GLRenderTarget::popRenderTarget();
|
||||||
|
|
||||||
|
if (hardwareClipping) {
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
}
|
||||||
if (ShaderManager::instance()->isValid()) {
|
if (ShaderManager::instance()->isValid()) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
@ -343,15 +353,18 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region,
|
||||||
shader->setUniform(GLShader::Saturation, data.saturation);
|
shader->setUniform(GLShader::Saturation, data.saturation);
|
||||||
shader->setUniform(GLShader::AlphaToOne, 0);
|
shader->setUniform(GLShader::AlphaToOne, 0);
|
||||||
|
|
||||||
cache->render(textureRect, textureRect);
|
cache->render(region, textureRect, hardwareClipping);
|
||||||
|
|
||||||
ShaderManager::instance()->popShader();
|
ShaderManager::instance()->popShader();
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
} else {
|
} else {
|
||||||
prepareRenderStates(cache, data.opacity, data.brightness, data.saturation);
|
prepareRenderStates(cache, data.opacity, data.brightness, data.saturation);
|
||||||
cache->render(textureRect, textureRect);
|
cache->render(region, textureRect, hardwareClipping);
|
||||||
restoreRenderStates(cache, data.opacity, data.brightness, data.saturation);
|
restoreRenderStates(cache, data.opacity, data.brightness, data.saturation);
|
||||||
}
|
}
|
||||||
|
if (hardwareClipping) {
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
cache->unbind();
|
cache->unbind();
|
||||||
w->setData(LanczosCacheRole, QVariant::fromValue(static_cast<void*>(cache)));
|
w->setData(LanczosCacheRole, QVariant::fromValue(static_cast<void*>(cache)));
|
||||||
|
|
Loading…
Reference in a new issue