kwin: avoid unnecessary texture binds
In cases where we do neither update nor render textures we don't have to bind them.
This commit is contained in:
parent
59c8ce32c1
commit
ca8484eff7
1 changed files with 18 additions and 16 deletions
|
@ -586,18 +586,21 @@ void SceneOpenGL::Window::performPaint(int mask, QRegion region, WindowPaintData
|
||||||
}
|
}
|
||||||
|
|
||||||
// paint the content
|
// paint the content
|
||||||
texture.bind();
|
WindowQuadList contentQuads = data.quads.select(WindowQuadContents);
|
||||||
prepareStates(Content, data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader);
|
if (!contentQuads.empty()) {
|
||||||
renderQuads(mask, region, data.quads.select(WindowQuadContents), &texture);
|
texture.bind();
|
||||||
restoreStates(Content, data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader);
|
prepareStates(Content, data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader);
|
||||||
texture.unbind();
|
renderQuads(mask, region, contentQuads, &texture);
|
||||||
|
restoreStates(Content, data.opacity * data.contents_opacity, data.brightness, data.saturation, data.shader);
|
||||||
|
texture.unbind();
|
||||||
#ifndef KWIN_HAVE_OPENGLES
|
#ifndef KWIN_HAVE_OPENGLES
|
||||||
if (static_cast<SceneOpenGL*>(scene)->debug) {
|
if (static_cast<SceneOpenGL*>(scene)->debug) {
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
renderQuads(mask, region, data.quads.select(WindowQuadContents), &texture);
|
renderQuads(mask, region, contentQuads, &texture);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (sceneShader) {
|
if (sceneShader) {
|
||||||
ShaderManager::instance()->popShader();
|
ShaderManager::instance()->popShader();
|
||||||
|
@ -626,17 +629,16 @@ void SceneOpenGL::Window::paintDecoration(const QPixmap* decoration, TextureType
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (decorationTexture->texture() != None && !updateDeco) {
|
if (decoration->isNull()) {
|
||||||
// texture doesn't need updating, just bind it
|
return;
|
||||||
decorationTexture->bind();
|
}
|
||||||
} else if (!decoration->isNull()) {
|
if (decorationTexture->isNull() || updateDeco) {
|
||||||
bool success = decorationTexture->load(*decoration);
|
bool success = decorationTexture->load(*decoration);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
kDebug(1212) << "Failed to bind decoartion";
|
kDebug(1212) << "Failed to bind decoartion";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
// We have to update the texture although we do not paint anything.
|
// We have to update the texture although we do not paint anything.
|
||||||
// This is especially needed if we draw the opaque part of the window
|
// This is especially needed if we draw the opaque part of the window
|
||||||
|
|
Loading…
Reference in a new issue