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