wasm: add fps counter to the rasterwindow test
Change-Id: Iddda72287119bc3ee6495d746ac75d64ff0c2f2c Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: David Skoland <david.skoland@qt.io>bb10
parent
c78925f487
commit
8ae20c975a
|
|
@ -52,6 +52,8 @@
|
|||
RasterWindow::RasterWindow()
|
||||
:m_eventCount(0)
|
||||
,m_timeoutCount(0)
|
||||
,m_frameCount(0)
|
||||
,m_fps(0)
|
||||
,m_pressed(false)
|
||||
{
|
||||
qDebug() << "RasterWindow()";
|
||||
|
|
@ -64,6 +66,8 @@ RasterWindow::RasterWindow()
|
|||
QTimer *timer = new QTimer(this);
|
||||
connect(timer, &QTimer::timeout, [this](){
|
||||
++m_timeoutCount;
|
||||
m_fps = m_frameCount;
|
||||
m_frameCount = 0;
|
||||
update();
|
||||
});
|
||||
timer->start(1000);
|
||||
|
|
@ -74,6 +78,8 @@ void RasterWindow::paintEvent(QPaintEvent * event)
|
|||
QRect r = event->rect();
|
||||
qDebug() << "RasterWindow::paintEvent" << r;
|
||||
|
||||
++m_frameCount;
|
||||
|
||||
QPainter p(this);
|
||||
|
||||
QColor fillColor(0, 102, 153);
|
||||
|
|
@ -96,6 +102,7 @@ void RasterWindow::paintEvent(QPaintEvent * event)
|
|||
text += QString("Screen Geometry: %1 %2 %3 %4\n").arg(sg.x()).arg(sg.y()).arg(sg.width()).arg(sg.height());
|
||||
text += QString("Received Events: %1\n").arg(m_eventCount);
|
||||
text += QString("Received Timers: %1\n").arg(m_timeoutCount);
|
||||
text += QString("Frames Per Second: %1\n").arg(m_fps);
|
||||
|
||||
p.drawText(QRectF(0, 0, width(), height()), Qt::AlignCenter, text);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ private:
|
|||
void incrementEventCount();
|
||||
int m_eventCount;
|
||||
int m_timeoutCount;
|
||||
int m_frameCount;
|
||||
int m_fps;
|
||||
QPoint m_offset;
|
||||
QPoint m_lastPos;
|
||||
bool m_pressed;
|
||||
|
|
|
|||
Loading…
Reference in New Issue