[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kde-workspace] kwin: kwin: avoid unnecessary texture binds
From:       Philipp Knechtges <philipp-dev () knechtges ! com>
Date:       2012-01-31 22:15:49
Message-ID: 20120131221549.09202A60BE () git ! kde ! org
[Download RAW message or body]

Git commit 63978ce2befcb849fb912a6aa7dbf68b8ff7ee8d by Philipp Knechtges.
Committed on 07/01/2012 at 21:03.
Pushed by knechtges into branch 'master'.

kwin: avoid unnecessary texture binds

In cases where we do neither update nor render textures
we don't have to bind them.

M  +18   -16   kwin/scene_opengl.cpp

http://commits.kde.org/kde-workspace/63978ce2befcb849fb912a6aa7dbf68b8ff7ee8d

diff --git a/kwin/scene_opengl.cpp b/kwin/scene_opengl.cpp
index 18cbd76..764aedf 100644
--- a/kwin/scene_opengl.cpp
+++ b/kwin/scene_opengl.cpp
@@ -586,18 +586,21 @@ void SceneOpenGL::Window::performPaint(int mask, QRegion \
region, WindowPaintData  }
 
     // paint the content
-    texture.bind();
-    prepareStates(Content, data.opacity * data.contents_opacity, data.brightness, \
                data.saturation, data.shader);
-    renderQuads(mask, region, data.quads.select(WindowQuadContents), &texture);
-    restoreStates(Content, data.opacity * data.contents_opacity, data.brightness, \
                data.saturation, data.shader);
-    texture.unbind();
+    WindowQuadList contentQuads = data.quads.select(WindowQuadContents);
+    if (!contentQuads.empty()) {
+        texture.bind();
+        prepareStates(Content, data.opacity * data.contents_opacity, \
data.brightness, data.saturation, data.shader); +        renderQuads(mask, region, \
contentQuads, &texture); +        restoreStates(Content, data.opacity * \
data.contents_opacity, data.brightness, data.saturation, data.shader); +        \
texture.unbind();  #ifndef KWIN_HAVE_OPENGLES
-    if (static_cast<SceneOpenGL*>(scene)->debug) {
-        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-        renderQuads(mask, region, data.quads.select(WindowQuadContents), &texture);
-        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-    }
+        if (static_cast<SceneOpenGL*>(scene)->debug) {
+            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+            renderQuads(mask, region, contentQuads, &texture);
+            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+        }
 #endif
+    }
 
     if (sceneShader) {
         ShaderManager::instance()->popShader();
@@ -626,17 +629,16 @@ void SceneOpenGL::Window::paintDecoration(const QPixmap* \
decoration, TextureType  default:
         return;
     }
-    if (decorationTexture->texture() != None && !updateDeco) {
-        // texture doesn't need updating, just bind it
-        decorationTexture->bind();
-    } else if (!decoration->isNull()) {
+    if (decoration->isNull()) {
+        return;
+    }
+    if (decorationTexture->isNull() || updateDeco) {
         bool success = decorationTexture->load(*decoration);
         if (!success) {
             kDebug(1212) << "Failed to bind decoartion";
             return;
         }
-    } else
-        return;
+    }
 
     // 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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic