mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-02 07:15:27 +08:00
qt 6.5.1 original
This commit is contained in:
14
tests/benchmarks/plugins/imageformats/jpeg/CMakeLists.txt
Normal file
14
tests/benchmarks/plugins/imageformats/jpeg/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## jpeg Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_benchmark(jpeg
|
||||
SOURCES
|
||||
jpeg.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Test
|
||||
)
|
52
tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp
Normal file
52
tests/benchmarks/plugins/imageformats/jpeg/jpeg.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QDebug>
|
||||
#include <qtest.h>
|
||||
#include <QTest>
|
||||
#include <QFile>
|
||||
#include <QByteArray>
|
||||
#include <QBuffer>
|
||||
#include <QImageReader>
|
||||
#include <QSize>
|
||||
|
||||
class tst_jpeg : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void jpegDecodingQtWebkitStyle();
|
||||
};
|
||||
|
||||
void tst_jpeg::jpegDecodingQtWebkitStyle()
|
||||
{
|
||||
// QtWebkit currently calls size() to get the image size for layouting purposes.
|
||||
// Then when it is in the viewport (we assume that here) it actually gets decoded.
|
||||
QString testFile = QFINDTESTDATA("n900.jpeg");
|
||||
QVERIFY2(!testFile.isEmpty(), "cannot find test file n900.jpeg!");
|
||||
QFile inputJpeg(testFile);
|
||||
QVERIFY(inputJpeg.exists());
|
||||
inputJpeg.open(QIODevice::ReadOnly);
|
||||
QByteArray imageData = inputJpeg.readAll();
|
||||
QBuffer buffer;
|
||||
buffer.setData(imageData);
|
||||
buffer.open(QBuffer::ReadOnly);
|
||||
QCOMPARE(buffer.size(), qint64(19016));
|
||||
|
||||
|
||||
QBENCHMARK{
|
||||
for (int i = 0; i < 50; i++) {
|
||||
QImageReader reader(&buffer, "jpeg");
|
||||
QSize size = reader.size();
|
||||
QVERIFY(!size.isNull());
|
||||
QByteArray format = reader.format();
|
||||
QVERIFY(!format.isEmpty());
|
||||
QImage img = reader.read();
|
||||
QVERIFY(!img.isNull());
|
||||
buffer.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_jpeg)
|
||||
|
||||
#include "jpeg.moc"
|
BIN
tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg
Normal file
BIN
tests/benchmarks/plugins/imageformats/jpeg/n900.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Reference in New Issue
Block a user