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

List:       kde-commits
Subject:    [kde-workspace/KDE/4.11] kwin/effects/showfps: support fps counter text on xrender
From:       Thomas_Lübking <thomas.luebking () gmail ! com>
Date:       2013-08-05 19:01:55
Message-ID: E1V6Q2V-0000IE-Bk () scm ! kde ! org
[Download RAW message or body]

Git commit 61c5a801ba75d51ee17e53e13250d9151c7923e3 by Thomas Lübking.
Committed on 04/08/2013 at 12:50.
Pushed by luebking into branch 'KDE/4.11'.

support fps counter text on xrender

BUG: 323006
FIXED-IN: 4.11
REVIEW: 111878

M  +25   -15   kwin/effects/showfps/showfps.cpp
M  +1    -1    kwin/effects/showfps/showfps.h

http://commits.kde.org/kde-workspace/61c5a801ba75d51ee17e53e13250d9151c7923e3

diff --git a/kwin/effects/showfps/showfps.cpp b/kwin/effects/showfps/showfps.cpp
index 0439941..1ab7d57 100644
--- a/kwin/effects/showfps/showfps.cpp
+++ b/kwin/effects/showfps/showfps.cpp
@@ -232,7 +232,18 @@ void ShowFpsEffect::paintGL(int fps)
     paintDrawSizeGraph(x, y);
 
     // Paint FPS numerical value
-    paintFPSText(fps);
+    if (fpsTextRect.isValid()) {
+        delete fpsText;
+        fpsText = new GLTexture(fpsTextImage(fps));
+        fpsText->bind();
+        ShaderBinder binder(ShaderManager::SimpleShader);
+        if (effects->compositingType() == OpenGL2Compositing) {
+            binder.shader()->setUniform("offset", QVector2D(0, 0));
+        }
+        fpsText->render(QRegion(fpsTextRect), fpsTextRect);
+        fpsText->unbind();
+        effects->addRepaint(fpsTextRect);
+    }
 
     // Paint paint sizes
     glDisable(GL_BLEND);
@@ -284,6 +295,15 @@ void ShowFpsEffect::paintXrender(int fps)
 
     // Paint amount of rendered pixels graph
     paintDrawSizeGraph(x + FPS_WIDTH + MAX_TIME, y);
+
+    // Paint FPS numerical value
+    if (fpsTextRect.isValid()) {
+        QImage textImg(fpsTextImage(fps));
+        XRenderPicture textPic(textImg);
+        xcb_render_composite(connection(), XCB_RENDER_PICT_OP_OVER, textPic, \
XCB_RENDER_PICTURE_NONE, +                        effects->xrenderBufferPicture(), 0, \
0, 0, 0, fpsTextRect.x(), fpsTextRect.y(), textImg.width(), textImg.height()); +      \
effects->addRepaint(fpsTextRect); +    }
 }
 #endif
 
@@ -450,26 +470,16 @@ void ShowFpsEffect::postPaintScreen()
     effects->addRepaint(fps_rect);
 }
 
-void ShowFpsEffect::paintFPSText(int fps)
+QImage ShowFpsEffect::fpsTextImage(int fps)
 {
-    if (!fpsTextRect.isValid())
-        return;
     QImage im(100, 100, QImage::Format_ARGB32);
-    im.fill(0);
+    im.fill(Qt::transparent);
     QPainter painter(&im);
     painter.setFont(textFont);
     painter.setPen(textColor);
     painter.drawText(QRect(0, 0, 100, 100), textAlign, QString::number(fps));
-    delete fpsText;
-    fpsText = new GLTexture(im);
-    fpsText->bind();
-    ShaderBinder binder(ShaderManager::SimpleShader);
-    if (effects->compositingType() == OpenGL2Compositing) {
-        binder.shader()->setUniform("offset", QVector2D(0, 0));
-    }
-    fpsText->render(QRegion(fpsTextRect), fpsTextRect);
-    fpsText->unbind();
-    effects->addRepaint(fpsTextRect);
+    painter.end();
+    return im;
 }
 
 } // namespace
diff --git a/kwin/effects/showfps/showfps.h b/kwin/effects/showfps/showfps.h
index 5f46d0c..3c30c39 100644
--- a/kwin/effects/showfps/showfps.h
+++ b/kwin/effects/showfps/showfps.h
@@ -80,7 +80,7 @@ private:
     void paintFPSGraph(int x, int y);
     void paintDrawSizeGraph(int x, int y);
     void paintGraph(int x, int y, QList<int> values, QList<int> lines, bool \
                colorize);
-    void paintFPSText(int fps);
+    QImage fpsTextImage(int fps);
     QTime t;
     enum { NUM_PAINTS = 100 }; // remember time needed to paint this many paints
     int paints[ NUM_PAINTS ]; // time needed to paint


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

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