Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. DropShadow with static source is faster when using “cached:true”

DropShadow with static source is faster when using “cached:true”

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
performancedropshadow
1 Posts 1 Posters 636 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stefan Monov76
    wrote on 13 Oct 2016, 18:30 last edited by
    #1

    I'll begin with my testcase. It creates 21 unchanging shadowed blue rectangles. It also creates a 1x1px Canvas3D repainted constantly, so I can check how often it manages to get repainted with all the other stuff going on (Canvas3D has a built-in fps property). When cached: true is set on the DropShadow items, I get 60 FPS. When not, I get 30 FPS. But what I expect is to get the same FPS in both cases, since I don't expect the shadows' blur to ever get recalculated, considering that the source rects never get updated.

    main.cpp: (trivial)

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
        
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        
        return app.exec();
    }
    

    main.qml:

    import QtQuick 2.5
    import QtQuick.Window 2.2
    import QtCanvas3D 1.1
    
    Window {
        visible: true
        width: 800
        height: 600
        id: window
        
        Column {
            Text {
                text: canvas3d.fps + " FPS"
                font.pointSize: 18
            }
            Flow {
                width: window.width
                spacing: 10
                Repeater {
                    model: 21
                    
                    ShadowedItem {
                    }
                }
            }
            Canvas3D {
                id: canvas3d
                width: 1; height: 1 // nonzero size so it can be redrawn
                property var gl;
                
                onInitializeGL: {
                    // should get and save context, otherwise FPS isn't measured for some reason
                    gl = canvas3d.getContext("canvas3d", {depth:true, antialias:true, alpha:true});
                }
            }
        }
    }
    

    ShadowedItem.qml:

    import QtQuick 2.0
    import QtGraphicalEffects 1.0
    
    Item {
        width: 100
        height: 100
        
        Rectangle {
            anchors.fill: parent
            id: rect
            visible: false
            color: "blue"
        }
        
        DropShadow {
            source: rect
            anchors.fill: rect
            cached: true // !
            radius: 8
        }
    }
    

    Any idea on the difference in performance?

    1 Reply Last reply
    0

    1/1

    13 Oct 2016, 18:30

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved