From 6ce96fdbf59138bebadbd8157d8285327a1a3796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 25 Aug 2016 13:09:27 +0200 Subject: multiwindow: React to mouse press to allow debugging UI responsiveness The animated FPS counter should be enough to observe smooth animations, so we use the color of the window to visualize frame latency. Change-Id: I1171a1c4bdc261ca8655771290c6735357821781 Reviewed-by: Simon Hausmann --- tests/manual/qopenglwindow/multiwindow/main.cpp | 53 ++++++++++--------------- 1 file changed, 20 insertions(+), 33 deletions(-) (limited to 'tests/manual/qopenglwindow') diff --git a/tests/manual/qopenglwindow/multiwindow/main.cpp b/tests/manual/qopenglwindow/multiwindow/main.cpp index 66ebb73c56..31688d717e 100644 --- a/tests/manual/qopenglwindow/multiwindow/main.cpp +++ b/tests/manual/qopenglwindow/multiwindow/main.cpp @@ -31,14 +31,7 @@ ** ****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include +#include const char applicationDescription[] = "\n\ This application opens multiple windows and continuously schedules updates for\n\ @@ -67,40 +60,26 @@ class Window : public QOpenGLWindow { Q_OBJECT public: - Window(int n) : idx(n) { - r = g = b = fps = 0; - y = 0; + Window(int index) : windowNumber(index + 1), y(0), fps(0) { + + color = QColor::fromHsl((index * 30) % 360, 255, 127).toRgb(); + resize(200, 200); + setObjectName(QString("Window %1").arg(windowNumber)); + connect(this, SIGNAL(frameSwapped()), SLOT(frameSwapped())); fpsTimer.start(); } void paintGL() { QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); - f->glClearColor(r, g, b, 1); + f->glClearColor(color.redF(), color.greenF(), color.blueF(), 1); f->glClear(GL_COLOR_BUFFER_BIT); - switch (idx % 3) { - case 0: - r += 0.005f; - break; - case 1: - g += 0.005f; - break; - case 2: - b += 0.005f; - break; - } - if (r > 1) - r = 0; - if (g > 1) - g = 0; - if (b > 1) - b = 0; QPainter p(this); p.setPen(Qt::white); - p.drawText(QPoint(20, y), QString(QLatin1String("Window %1 (%2 FPS)")).arg(idx).arg(fps)); + p.drawText(QPoint(20, y), QString(QLatin1String("Window %1 (%2 FPS)")).arg(windowNumber).arg(fps)); y += 1; if (y > height() - 20) y = 20; @@ -118,9 +97,17 @@ public slots: } } +protected: + void mousePressEvent(QMouseEvent *event) { + qDebug() << this << event; + color.setHsl((color.hue() + 90) % 360, color.saturation(), color.lightness()); + color = color.toRgb(); + } + private: - int idx; - GLfloat r, g, b; + int windowNumber; + QColor color; + int y; int framesSwapped; @@ -163,7 +150,7 @@ int main(int argc, char **argv) int numberOfWindows = qMax(parser.value(numWindowsOption).toInt(), 1); QList windows; for (int i = 0; i < numberOfWindows; ++i) { - Window *w = new Window(i + 1); + Window *w = new Window(i); windows << w; if (i == 0 && parser.isSet(vsyncOneOption)) { -- cgit v1.2.3