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