Adding set pixel method to our QML MiniDisplay.
authorsl
Thu, 29 May 2014 15:47:51 +0200
changeset 1635f01a0d460a
parent 15 737f8bb110be
child 17 aa257fdcd093
Adding set pixel method to our QML MiniDisplay.
Adding more metrics and options to our test tab.
MiniDisplay/minidisplay.cpp
MiniDisplay/minidisplay.h
TestsTab.qml
     1.1 --- a/MiniDisplay/minidisplay.cpp	Thu May 29 14:27:08 2014 +0200
     1.2 +++ b/MiniDisplay/minidisplay.cpp	Thu May 29 15:47:51 2014 +0200
     1.3 @@ -198,6 +198,22 @@
     1.4  }
     1.5  
     1.6  /**
     1.7 + * @brief MiniDisplay::setPixel
     1.8 + * @param x
     1.9 + * @param y
    1.10 + * @param on
    1.11 + */
    1.12 +void MiniDisplay::setPixel(int x, int y, bool on)
    1.13 +{
    1.14 +    if (!iDisplay.IsOpen())
    1.15 +    {
    1.16 +        return;
    1.17 +    }
    1.18 +
    1.19 +    iDisplay.SetPixel(x,y,true);
    1.20 +}
    1.21 +
    1.22 +/**
    1.23   * @brief MiniDisplay::vendor
    1.24   * @return
    1.25   */
     2.1 --- a/MiniDisplay/minidisplay.h	Thu May 29 14:27:08 2014 +0200
     2.2 +++ b/MiniDisplay/minidisplay.h	Thu May 29 15:47:51 2014 +0200
     2.3 @@ -36,6 +36,11 @@
     2.4      Q_INVOKABLE void renderOwnWindow();
     2.5      Q_INVOKABLE void renderWindow(QQuickWindow* aWindow);
     2.6      Q_INVOKABLE void renderImage(QImage* aImage);
     2.7 +    //
     2.8 +    Q_INVOKABLE void setPixel(int x, int y, bool on);
     2.9 +
    2.10 +
    2.11 +
    2.12  
    2.13  public:
    2.14      //Properties
     3.1 --- a/TestsTab.qml	Thu May 29 14:27:08 2014 +0200
     3.2 +++ b/TestsTab.qml	Thu May 29 15:47:51 2014 +0200
     3.3 @@ -44,25 +44,56 @@
     3.4              smooth: false
     3.5          }
     3.6  
     3.7 -        ColumnLayout {
     3.8 +        GridLayout {
     3.9              anchors.fill:parent
    3.10              anchors.margins: 6
    3.11 -            spacing: 4
    3.12 +            //spacing: 4
    3.13 +            columns: 4
    3.14 +
    3.15 +            Label {
    3.16 +                text: "Frames:"
    3.17 +                antialiasing: false
    3.18 +            }
    3.19 +
    3.20 +            Label {
    3.21 +                text: "Time (s):"
    3.22 +                antialiasing: false
    3.23 +            }
    3.24 +
    3.25 +            Label {
    3.26 +                text: "Time/Frame (ms):"
    3.27 +                antialiasing: false
    3.28 +            }
    3.29 +
    3.30 +            Label {
    3.31 +                text: "FPS:"
    3.32 +                antialiasing: false
    3.33 +            }
    3.34  
    3.35              Label {
    3.36                  id: labelFrameCount
    3.37 -                //anchors.centerIn: parent
    3.38                  text: "Frame Count"
    3.39                  antialiasing: false
    3.40              }
    3.41  
    3.42              Label {
    3.43                  id: labelTime
    3.44 -                //anchors.centerIn: parent
    3.45                  text: "Time"
    3.46                  antialiasing: false
    3.47              }
    3.48  
    3.49 +            Label {
    3.50 +                id: labelTimePerFrame
    3.51 +                text: "Time/Frame"
    3.52 +                antialiasing: false
    3.53 +            }
    3.54 +
    3.55 +            Label {
    3.56 +                id: labelFps
    3.57 +                text: "FPS"
    3.58 +                antialiasing: false
    3.59 +            }
    3.60 +
    3.61          }
    3.62  
    3.63  
    3.64 @@ -71,19 +102,50 @@
    3.65  
    3.66          //! [timer]
    3.67          Timer {
    3.68 +            id: timer
    3.69              interval: splash.timeoutInterval; running: true; repeat: true
    3.70              onTriggered: {
    3.71                  //visible = false
    3.72  
    3.73                  var current = new Date();
    3.74 -                var seconds = (current.getTime() - splash.startTime.getTime())/1000;
    3.75 +                var milliseconds = (current.getTime() - splash.startTime.getTime());
    3.76  
    3.77                  splash.frameCounter++;
    3.78                  labelFrameCount.text=splash.frameCounter;
    3.79 -                labelTime.text=seconds;
    3.80 -                display.renderWindow(splash);
    3.81 -                display.swapBuffers();
    3.82 -                splash.timeout()
    3.83 +                labelTime.text=milliseconds/1000;
    3.84 +                labelTimePerFrame.text=(milliseconds/splash.frameCounter).toFixed(3);
    3.85 +                labelFps.text=(1000/(milliseconds/splash.frameCounter)).toFixed(0);
    3.86 +
    3.87 +                if (checkBoxDoClear.checked)
    3.88 +                {
    3.89 +                    display.clear();
    3.90 +                }
    3.91 +
    3.92 +                if (checkBoxRenderToDisplay.checked)
    3.93 +                {
    3.94 +                    if (checkBoxFillOnly.checked)
    3.95 +                    {
    3.96 +                        display.fill();
    3.97 +                    }
    3.98 +                    else if (checkBoxOnePixelOnly.checked)
    3.99 +                    {
   3.100 +                        display.setPixel(0,0,true);
   3.101 +                    }
   3.102 +                    else
   3.103 +                    {
   3.104 +                        display.renderWindow(splash);
   3.105 +                    }
   3.106 +
   3.107 +                    if (!checkBoxNoSwapBuffers.checked)
   3.108 +                    {
   3.109 +                        display.swapBuffers();
   3.110 +                    }
   3.111 +
   3.112 +                }
   3.113 +
   3.114 +
   3.115 +
   3.116 +                splash.timeout();
   3.117              }
   3.118          }
   3.119          //! [timer]
   3.120 @@ -105,5 +167,51 @@
   3.121                  display.swapBuffers();
   3.122              }
   3.123          }
   3.124 +
   3.125 +        Button {
   3.126 +            text: qsTr("Reset stats")
   3.127 +            onClicked: {
   3.128 +                splash.startTime = new Date();
   3.129 +                splash.frameCounter = 0;
   3.130 +            }
   3.131 +        }
   3.132 +
   3.133 +        CheckBox {
   3.134 +            text: qsTr("Run timer")
   3.135 +            checked: true
   3.136 +            onCheckedChanged: {
   3.137 +                (checked?timer.start():timer.stop())
   3.138 +            }
   3.139 +        }
   3.140 +
   3.141 +        CheckBox {
   3.142 +            id: checkBoxDoClear
   3.143 +            text: qsTr("Do clear")
   3.144 +            checked: true
   3.145 +        }
   3.146 +
   3.147 +        CheckBox {
   3.148 +            id: checkBoxRenderToDisplay
   3.149 +            text: qsTr("Render to display")
   3.150 +            checked: true
   3.151 +        }
   3.152 +
   3.153 +        CheckBox {
   3.154 +            id: checkBoxFillOnly
   3.155 +            text: qsTr("Fill only")
   3.156 +            checked: false
   3.157 +        }
   3.158 +
   3.159 +        CheckBox {
   3.160 +            id: checkBoxNoSwapBuffers
   3.161 +            text: qsTr("No swap buffers")
   3.162 +            checked: false
   3.163 +        }
   3.164 +
   3.165 +        CheckBox {
   3.166 +            id: checkBoxOnePixelOnly
   3.167 +            text: qsTr("One pixel only")
   3.168 +            checked: false
   3.169 +        }
   3.170      }
   3.171  }