aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/gifs
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-08-10 10:12:37 +0200
committerMitch Curtis <mitch.curtis@theqtcompany.com>2015-08-10 08:17:41 +0000
commite71d18ec59406a789689e7d5f3103be88a792396 (patch)
tree5797193c5e0f6668b77f230bb7cc4b9beafc4be7 /tests/manual/gifs
parentff91fbfa59cf3434efd6da7109bb46856f6a5105 (diff)
GifRecorder: add a gifsicle optimization step.
qtquickcontrols2-busyindicator.gif: 39 kB => 31kB (20%) qtquickcontrols2-slider.gif: 34 kB => 13kB (61%) Change-Id: Iee2c74f1a9e3900572966bd600921d0ad2af80cf Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/manual/gifs')
-rw-r--r--tests/manual/gifs/gifrecorder.cpp55
-rw-r--r--tests/manual/gifs/gifrecorder.h8
2 files changed, 37 insertions, 26 deletions
diff --git a/tests/manual/gifs/gifrecorder.cpp b/tests/manual/gifs/gifrecorder.cpp
index 04dd1746..dda74e4d 100644
--- a/tests/manual/gifs/gifrecorder.cpp
+++ b/tests/manual/gifs/gifrecorder.cpp
@@ -64,11 +64,7 @@ GifRecorder::GifRecorder() :
mRecordingDuration(0),
mRecordCursor(false),
mByzanzProcessName(QStringLiteral("byzanz-record")),
- mByzanzProcessFinished(false),
- mAvconvProcessName(QStringLiteral("avconv")),
- mAvconvProcessFinished(false),
- mConvertProcessName(QStringLiteral("convert")),
- mConvertProcessFinished(false)
+ mByzanzProcessFinished(false)
{
if (lcGifRecorder().isDebugEnabled()) {
// Ensures output from the process goes directly into the console.
@@ -196,40 +192,61 @@ void GifRecorder::waitForFinish()
if (mHighQuality) {
mAvconvProcess.setStandardOutputProcess(&mConvertProcess);
- mAvconvArgs = QString::fromLatin1("%1 -i %2 -r 20 -f image2pipe -vcodec ppm -").arg(mAvconvProcessName).arg(mByzanzOutputFileName);
- qCDebug(lcGifRecorder) << "Starting" << mAvconvProcessName << "with the following arguments:" << mAvconvArgs;
- mAvconvProcess.start(mAvconvArgs);
+ const QString avconvProcessName = QStringLiteral("avconv");
+ const QString avconvArgs = QString::fromLatin1("%1 -i %2 -r 20 -f image2pipe -vcodec ppm -").arg(avconvProcessName).arg(mByzanzOutputFileName);
+ qCDebug(lcGifRecorder) << "Starting" << avconvProcessName << "with the following arguments:" << avconvArgs;
+ mAvconvProcess.start(avconvArgs);
if (!mAvconvProcess.waitForStarted(1000)) {
QString message = QString::fromLatin1("Could not launch %1 with the following arguments: %2\nError:\n%3");
- message = message.arg(mAvconvProcessName).arg(mAvconvArgs).arg(mAvconvProcess.errorString());
+ message = message.arg(avconvProcessName).arg(avconvArgs).arg(mAvconvProcess.errorString());
QFAIL(qPrintable(message));
} else {
- qCDebug(lcGifRecorder) << "Successfully started" << mAvconvProcessName;
+ qCDebug(lcGifRecorder) << "Successfully started" << avconvProcessName;
}
- mConvertArgs = QString::fromLatin1("%1 -delay 5 -loop 0 - %2").arg(mConvertProcessName).arg(mGifFileName);
- qCDebug(lcGifRecorder) << "Starting" << mConvertProcessName << "with the following arguments:" << mConvertArgs;
- mConvertProcess.start(mConvertArgs);
+ const QString convertProcessName = QStringLiteral("convert");
+ const QString convertArgs = QString::fromLatin1("%1 -delay 5 -loop 0 - %2").arg(convertProcessName).arg(mGifFileName);
+ qCDebug(lcGifRecorder) << "Starting" << convertProcessName << "with the following arguments:" << convertArgs;
+ mConvertProcess.start(convertArgs);
if (!mConvertProcess.waitForStarted(1000)) {
QString message = QString::fromLatin1("Could not launch %1 with the following arguments: %2\nError:\n%3");
- message = message.arg(mConvertProcessName).arg(mConvertArgs).arg(mConvertProcess.errorString());
+ message = message.arg(convertProcessName).arg(convertArgs).arg(mConvertProcess.errorString());
QFAIL(qPrintable(message));
} else {
- qCDebug(lcGifRecorder) << "Successfully started" << mConvertProcessName;
+ qCDebug(lcGifRecorder) << "Successfully started" << convertProcessName;
}
if (!mAvconvProcess.waitForFinished(waitDuration)) {
const QString message = QString::fromLatin1("%1 failed to finish: %2");
- QFAIL(qPrintable(message.arg(mAvconvProcessName).arg(mAvconvProcess.errorString())));
+ QFAIL(qPrintable(message.arg(avconvProcessName).arg(mAvconvProcess.errorString())));
} else {
- qCDebug(lcGifRecorder) << mAvconvProcessName << "finished";
+ qCDebug(lcGifRecorder) << avconvProcessName << "finished";
}
if (!mConvertProcess.waitForFinished(waitDuration)) {
const QString message = QString::fromLatin1("%1 failed to finish: %2");
- QFAIL(qPrintable(message.arg(mConvertProcessName).arg(mConvertProcess.errorString())));
+ QFAIL(qPrintable(message.arg(convertProcessName).arg(mConvertProcess.errorString())));
} else {
- qCDebug(lcGifRecorder) << mConvertProcessName << "finished";
+ qCDebug(lcGifRecorder) << convertProcessName << "finished";
+ }
+
+ const QString gifsicleProcessName = QStringLiteral("gifsicle");
+ const QString gifsicleArgs = QString::fromLatin1("%1 -b -O %2").arg(gifsicleProcessName).arg(mGifFileName);
+ qCDebug(lcGifRecorder) << "Starting" << gifsicleProcessName << "with the following arguments:" << gifsicleArgs;
+ mGifsicleProcess.start(gifsicleArgs);
+ if (!mGifsicleProcess.waitForStarted(1000)) {
+ QString message = QString::fromLatin1("Could not launch %1 with the following arguments: %2\nError:\n%3");
+ message = message.arg(gifsicleProcessName).arg(gifsicleArgs).arg(mGifsicleProcess.errorString());
+ QFAIL(qPrintable(message));
+ } else {
+ qCDebug(lcGifRecorder) << "Successfully started" << gifsicleProcessName;
+ }
+
+ if (!mGifsicleProcess.waitForFinished(waitDuration)) {
+ const QString message = QString::fromLatin1("%1 failed to finish: %2");
+ QFAIL(qPrintable(message.arg(gifsicleProcessName).arg(mGifsicleProcess.errorString())));
+ } else {
+ qCDebug(lcGifRecorder) << gifsicleProcessName << "finished";
}
if (QFile::exists(mByzanzOutputFileName)) {
diff --git a/tests/manual/gifs/gifrecorder.h b/tests/manual/gifs/gifrecorder.h
index 74469f9b..13eea2bf 100644
--- a/tests/manual/gifs/gifrecorder.h
+++ b/tests/manual/gifs/gifrecorder.h
@@ -83,15 +83,9 @@ private:
QProcess mByzanzProcess;
bool mByzanzProcessFinished;
- const QString mAvconvProcessName;
- QString mAvconvArgs;
QProcess mAvconvProcess;
- bool mAvconvProcessFinished;
-
- const QString mConvertProcessName;
- QString mConvertArgs;
QProcess mConvertProcess;
- bool mConvertProcessFinished;
+ QProcess mGifsicleProcess;
};
#endif // GIFRECORDER_H