diff options
Diffstat (limited to 'tests/manual/wasm/rasterwindow')
-rw-r--r-- | tests/manual/wasm/rasterwindow/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/manual/wasm/rasterwindow/main.cpp | 51 | ||||
-rw-r--r-- | tests/manual/wasm/rasterwindow/rasterwindow.cpp | 65 | ||||
-rw-r--r-- | tests/manual/wasm/rasterwindow/rasterwindow.h | 53 |
4 files changed, 23 insertions, 151 deletions
diff --git a/tests/manual/wasm/rasterwindow/CMakeLists.txt b/tests/manual/wasm/rasterwindow/CMakeLists.txt index cd3a2eef3d..ed5b7ecd18 100644 --- a/tests/manual/wasm/rasterwindow/CMakeLists.txt +++ b/tests/manual/wasm/rasterwindow/CMakeLists.txt @@ -1,8 +1,11 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_internal_add_manual_test(rasterwindow GUI SOURCES main.cpp rasterwindow.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Core Qt::Gui ) diff --git a/tests/manual/wasm/rasterwindow/main.cpp b/tests/manual/wasm/rasterwindow/main.cpp index fad3803282..576b73112b 100644 --- a/tests/manual/wasm/rasterwindow/main.cpp +++ b/tests/manual/wasm/rasterwindow/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtGui> #include "rasterwindow.h" diff --git a/tests/manual/wasm/rasterwindow/rasterwindow.cpp b/tests/manual/wasm/rasterwindow/rasterwindow.cpp index d46a6bc5b6..8fd036c274 100644 --- a/tests/manual/wasm/rasterwindow/rasterwindow.cpp +++ b/tests/manual/wasm/rasterwindow/rasterwindow.cpp @@ -1,57 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "rasterwindow.h" RasterWindow::RasterWindow() :m_eventCount(0) ,m_timeoutCount(0) +,m_frameCount(0) +,m_fps(0) ,m_pressed(false) { qDebug() << "RasterWindow()"; @@ -64,6 +19,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 +31,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,12 +55,13 @@ 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); } void RasterWindow::exposeEvent(QExposeEvent * ev) { - qDebug() << __PRETTY_FUNCTION__ << ev->region(); + qDebug() << __PRETTY_FUNCTION__; QRasterWindow::exposeEvent(ev); incrementEventCount(); } @@ -155,8 +115,8 @@ void RasterWindow::mouseMoveEvent(QMouseEvent * ev) incrementEventCount(); if (m_pressed) - m_offset += ev->localPos().toPoint() - m_lastPos; - m_lastPos = ev->localPos().toPoint(); + m_offset += ev->position().toPoint() - m_lastPos; + m_lastPos = ev->position().toPoint(); } void RasterWindow::mousePressEvent(QMouseEvent * ev) @@ -215,6 +175,7 @@ void RasterWindow::wheelEvent(QWheelEvent * ev) qDebug() << __PRETTY_FUNCTION__; QRasterWindow::wheelEvent(ev); incrementEventCount(); + m_offset += ev->pixelDelta(); } void RasterWindow::incrementEventCount() diff --git a/tests/manual/wasm/rasterwindow/rasterwindow.h b/tests/manual/wasm/rasterwindow/rasterwindow.h index 8f13182015..e488420440 100644 --- a/tests/manual/wasm/rasterwindow/rasterwindow.h +++ b/tests/manual/wasm/rasterwindow/rasterwindow.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef RASTERWINDOW_H #define RASTERWINDOW_H @@ -80,6 +33,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; |