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

  • 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;
        return app.exec();


    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});


    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?

Log in to reply