TestsTab.qml
author sl
Fri, 30 May 2014 13:45:14 +0200
changeset 21 434d6b8a406d
parent 18 79801cc3bc94
child 22 ca9e48af31e6
permissions -rw-r--r--
Frame diff algo now working nicely and providing twice the frame rate.
sl@0
     1
import QtQuick 2.2
sl@0
     2
import QtQuick.Controls 1.2
sl@15
     3
import QtQuick.Window 2.1
sl@15
     4
import MiniDisplay 1.0
sl@15
     5
import QtQuick.Layouts 1.1
sl@15
     6
sl@0
     7
sl@0
     8
Item {
sl@17
     9
    id: testTab
sl@15
    10
    //width: 100
sl@15
    11
    //height: 62
sl@0
    12
    //SystemPalette { id: palette }
sl@0
    13
    clip: true
sl@15
    14
    //anchors.fill:parent
sl@0
    15
sl@15
    16
sl@18
    17
    //This window is our VFD frame
sl@15
    18
    Window {
sl@15
    19
        //parent: appWindow
sl@15
    20
        id: splash
sl@15
    21
        color: "transparent"
sl@15
    22
        title: "Splash Window"
sl@15
    23
        modality: Qt.NonModal
sl@15
    24
        flags: Qt.SplashScreen
sl@21
    25
        //24 FPS
sl@21
    26
        //property int timeoutInterval: 41
sl@21
    27
        //32 FPS
sl@21
    28
        property int timeoutInterval: 33
sl@15
    29
        signal timeout
sl@15
    30
    //! [splash-properties]
sl@15
    31
    //! [screen-properties]
sl@17
    32
        //x: (Screen.width - rectangleScreen.width) / 2
sl@17
    33
        //y: (Screen.height - rectangleScreen.height) / 2
sl@17
    34
        x: appWindow.x+appWindow.width-256-13
sl@17
    35
        y: appWindow.y+appWindow.height-64-30
sl@17
    36
sl@15
    37
    //! [screen-properties]
sl@15
    38
        width: rectangleScreen.width
sl@15
    39
        height: rectangleScreen.height
sl@15
    40
        property int frameCounter:0;
sl@15
    41
        property var startTime:new Date();
sl@15
    42
sl@15
    43
        Rectangle {
sl@15
    44
            id: rectangleScreen
sl@15
    45
            anchors.centerIn: parent
sl@15
    46
            width: 256
sl@15
    47
            height: 64
sl@15
    48
            color: "white"
sl@15
    49
            border.width:1
sl@15
    50
            border.color: "black"
sl@15
    51
            smooth: false
sl@15
    52
        }
sl@15
    53
sl@16
    54
        GridLayout {
sl@15
    55
            anchors.fill:parent
sl@15
    56
            anchors.margins: 6
sl@16
    57
            //spacing: 4
sl@16
    58
            columns: 4
sl@16
    59
sl@16
    60
            Label {
sl@16
    61
                text: "Frames:"
sl@16
    62
                antialiasing: false
sl@16
    63
            }
sl@16
    64
sl@16
    65
            Label {
sl@16
    66
                text: "Time (s):"
sl@16
    67
                antialiasing: false
sl@16
    68
            }
sl@16
    69
sl@16
    70
            Label {
sl@16
    71
                text: "Time/Frame (ms):"
sl@16
    72
                antialiasing: false
sl@16
    73
            }
sl@16
    74
sl@16
    75
            Label {
sl@16
    76
                text: "FPS:"
sl@16
    77
                antialiasing: false
sl@16
    78
            }
sl@15
    79
sl@15
    80
            Label {
sl@15
    81
                id: labelFrameCount
sl@15
    82
                text: "Frame Count"
sl@15
    83
                antialiasing: false
sl@15
    84
            }
sl@15
    85
sl@15
    86
            Label {
sl@15
    87
                id: labelTime
sl@15
    88
                text: "Time"
sl@15
    89
                antialiasing: false
sl@15
    90
            }
sl@15
    91
sl@16
    92
            Label {
sl@16
    93
                id: labelTimePerFrame
sl@16
    94
                text: "Time/Frame"
sl@16
    95
                antialiasing: false
sl@16
    96
            }
sl@16
    97
sl@16
    98
            Label {
sl@16
    99
                id: labelFps
sl@16
   100
                text: "FPS"
sl@16
   101
                antialiasing: false
sl@16
   102
            }
sl@16
   103
sl@15
   104
        }
sl@15
   105
sl@15
   106
sl@15
   107
sl@15
   108
sl@15
   109
sl@15
   110
        //! [timer]
sl@15
   111
        Timer {
sl@16
   112
            id: timer
sl@15
   113
            interval: splash.timeoutInterval; running: true; repeat: true
sl@15
   114
            onTriggered: {
sl@15
   115
                //visible = false
sl@15
   116
sl@15
   117
                var current = new Date();
sl@16
   118
                var milliseconds = (current.getTime() - splash.startTime.getTime());
sl@15
   119
sl@15
   120
                splash.frameCounter++;
sl@15
   121
                labelFrameCount.text=splash.frameCounter;
sl@16
   122
                labelTime.text=milliseconds/1000;
sl@16
   123
                labelTimePerFrame.text=(milliseconds/splash.frameCounter).toFixed(3);
sl@16
   124
                labelFps.text=(1000/(milliseconds/splash.frameCounter)).toFixed(0);
sl@16
   125
sl@16
   126
                if (checkBoxDoClear.checked)
sl@16
   127
                {
sl@16
   128
                    display.clear();
sl@16
   129
                }
sl@16
   130
sl@16
   131
                if (checkBoxRenderToDisplay.checked)
sl@16
   132
                {
sl@16
   133
                    if (checkBoxFillOnly.checked)
sl@16
   134
                    {
sl@21
   135
                        //Trying to make it a worth case scenario for our frame diff algo
sl@21
   136
                        (splash.frameCounter%3?display.fill():display.clear());
sl@16
   137
                    }
sl@16
   138
                    else if (checkBoxOnePixelOnly.checked)
sl@16
   139
                    {
sl@18
   140
                        display.setPixel(0,0,splash.frameCounter%2);
sl@16
   141
                    }
sl@16
   142
                    else
sl@16
   143
                    {
sl@16
   144
                        display.renderWindow(splash);
sl@16
   145
                    }
sl@16
   146
sl@16
   147
                    if (!checkBoxNoSwapBuffers.checked)
sl@16
   148
                    {
sl@16
   149
                        display.swapBuffers();
sl@16
   150
                    }
sl@16
   151
sl@16
   152
                }
sl@16
   153
sl@16
   154
sl@16
   155
sl@16
   156
                splash.timeout();
sl@15
   157
            }
sl@15
   158
        }
sl@15
   159
        //! [timer]
sl@15
   160
        Component.onCompleted: {
sl@15
   161
            visible = true
sl@15
   162
        }
sl@15
   163
sl@15
   164
    }
sl@15
   165
sl@15
   166
    Column {
sl@15
   167
        anchors.fill: parent
sl@15
   168
        anchors.margins: 8
sl@15
   169
        spacing: 8
sl@15
   170
sl@15
   171
        Button {
sl@15
   172
            text: qsTr("Render Window")
sl@15
   173
            onClicked: {
sl@15
   174
                display.renderWindow(splash);
sl@15
   175
                display.swapBuffers();
sl@15
   176
            }
sl@15
   177
        }
sl@16
   178
sl@16
   179
        Button {
sl@16
   180
            text: qsTr("Reset stats")
sl@16
   181
            onClicked: {
sl@16
   182
                splash.startTime = new Date();
sl@16
   183
                splash.frameCounter = 0;
sl@16
   184
            }
sl@16
   185
        }
sl@16
   186
sl@16
   187
        CheckBox {
sl@16
   188
            text: qsTr("Run timer")
sl@16
   189
            checked: true
sl@16
   190
            onCheckedChanged: {
sl@16
   191
                (checked?timer.start():timer.stop())
sl@16
   192
            }
sl@16
   193
        }
sl@16
   194
sl@16
   195
        CheckBox {
sl@16
   196
            id: checkBoxDoClear
sl@16
   197
            text: qsTr("Do clear")
sl@16
   198
            checked: true
sl@16
   199
        }
sl@16
   200
sl@16
   201
        CheckBox {
sl@16
   202
            id: checkBoxRenderToDisplay
sl@16
   203
            text: qsTr("Render to display")
sl@16
   204
            checked: true
sl@16
   205
        }
sl@16
   206
sl@16
   207
        CheckBox {
sl@16
   208
            id: checkBoxFillOnly
sl@21
   209
            text: qsTr("Only fill and clear")
sl@16
   210
            checked: false
sl@16
   211
        }
sl@16
   212
sl@16
   213
        CheckBox {
sl@16
   214
            id: checkBoxNoSwapBuffers
sl@16
   215
            text: qsTr("No swap buffers")
sl@16
   216
            checked: false
sl@16
   217
        }
sl@16
   218
sl@16
   219
        CheckBox {
sl@16
   220
            id: checkBoxOnePixelOnly
sl@16
   221
            text: qsTr("One pixel only")
sl@16
   222
            checked: false
sl@16
   223
        }
sl@18
   224
sl@18
   225
        CheckBox {
sl@18
   226
            //id: checkBoxOnePixelOnly
sl@18
   227
            text: qsTr("Off-Screen")
sl@18
   228
            checked: true
sl@18
   229
            onCheckedChanged: {display.offScreenMode = checked;}
sl@18
   230
        }
sl@15
   231
    }
sl@0
   232
}