X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gui%2Fretracer.cpp;h=69dca6c6b26f542845b5857952177692210f19e7;hb=2105fa56fc993030bf0d4d79229e2b5523657d04;hp=18947d4f406dc22de09d935e6b0e6d815d6d0652;hpb=6ea8dee938bdb475811657e123af4cc2f1abe991;p=apitrace diff --git a/gui/retracer.cpp b/gui/retracer.cpp index 18947d4..69dca6c 100644 --- a/gui/retracer.cpp +++ b/gui/retracer.cpp @@ -1,6 +1,7 @@ #include "retracer.h" #include "apitracecall.h" +#include "thumbnail.h" #include "image.hpp" @@ -8,7 +9,6 @@ #include #include #include -#include #include @@ -220,7 +220,7 @@ void Retracer::setCaptureThumbnails(bool enable) */ void Retracer::run() { - QString msg; + QString msg = QLatin1String("Replay finished!"); /* * Construct command line @@ -229,12 +229,29 @@ void Retracer::run() QString prog; QStringList arguments; - if (m_api == trace::API_GL) { + switch (m_api) { + case trace::API_GL: prog = QLatin1String("glretrace"); - } else if (m_api == trace::API_EGL) { + break; + case trace::API_EGL: prog = QLatin1String("eglretrace"); - } else { - Q_ASSERT(0); + break; + case trace::API_DX: + case trace::API_D3D7: + case trace::API_D3D8: + case trace::API_D3D9: + case trace::API_D3D10: + case trace::API_D3D10_1: + case trace::API_D3D11: +#ifdef Q_OS_WIN + prog = QLatin1String("d3dretrace"); +#else + prog = QLatin1String("wine"); + arguments << QLatin1String("d3dretrace.exe"); +#endif + break; + default: + emit finished(QLatin1String("Unsupported API")); return; } @@ -283,8 +300,6 @@ void Retracer::run() /* * Parse JSON from the output. * - * XXX: QJSON expects blocking IO. - * * XXX: QJSON's scanner is inneficient as it abuses single * character QIODevice::peek (not cheap), instead of maintaining a * lookahead character on its own. @@ -292,7 +307,16 @@ void Retracer::run() bool ok = false; QJson::Parser jsonParser; +#if 0 parsedJson = jsonParser.parse(&io, &ok).toMap(); +#else + /* + * XXX: QJSON expects blocking IO, and it looks like + * BlockingIODevice does not work reliably in all cases. + */ + process.waitForFinished(-1); + parsedJson = jsonParser.parse(&process, &ok).toMap(); +#endif if (!ok) { msg = QLatin1String("failed to parse JSON"); } @@ -340,8 +364,8 @@ void Retracer::run() Q_ASSERT(readBytes == rowBytes); } - QImage thumbnail = snapshot.scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation); - thumbnails.append(thumbnail); + QImage thumb = thumbnail(snapshot); + thumbnails.append(thumb); } Q_ASSERT(process.state() != QProcess::Running); @@ -349,7 +373,9 @@ void Retracer::run() } else { QByteArray output; output = process.readAllStandardOutput(); - msg = QString::fromUtf8(output); + if (output.length() < 80) { + msg = QString::fromUtf8(output); + } } }