aboutsummaryrefslogtreecommitdiffstats
path: root/benchmarks/auto/canvas/canvas_text_simple.qml
blob: 45e5a596420db9971a45e0b7203f71f430325c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import QtQuick 2.0

// Testing the performance of canvas-based text rendering
Item {
    id: root;
    property int count: 100;
    property int staticCount: 1000;

    property real t;
    NumberAnimation on t { from: 0; to: 1; duration: 2347; loops: Animation.Infinite }

    Canvas {
        anchors.fill: parent

        property real t: root.t;
        onTChanged: requestPaint();

        onPaint: {
            var ctx = getContext("2d");
            ctx.clearRect(0, 0, width, height);
            var str = "" + Math.floor( t * 1000 ) / 1000;

            for (var i = 0; i < root.count; ++i) {
                ctx.fillText(str, QmlBench.getRandom() * root.width, QmlBench.getRandom() * root.height);
            }
        }
    }
}