summaryrefslogtreecommitdiff
path: root/gui/loaderthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/loaderthread.cpp')
-rw-r--r--gui/loaderthread.cpp122
1 files changed, 0 insertions, 122 deletions
diff --git a/gui/loaderthread.cpp b/gui/loaderthread.cpp
deleted file mode 100644
index 10a787b..0000000
--- a/gui/loaderthread.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "loaderthread.h"
-
-#include "trace_parser.hpp"
-
-#include <QFile>
-#include <QHash>
-#include <QUrl>
-
-#include <QDebug>
-
-#define FRAMES_TO_CACHE 100
-
-static ApiTraceCall *
-apiCallFromTraceCall(const Trace::Call *call,
- const QHash<QString, QUrl> &helpHash,
- ApiTraceFrame *frame)
-{
- ApiTraceCall *apiCall = new ApiTraceCall(frame, call);
-
- apiCall->setHelpUrl(helpHash.value(apiCall->name()));
-
- return apiCall;
-}
-
-LoaderThread::LoaderThread(ApiTrace *parent)
- : QThread(parent),
- m_frameMarker(ApiTrace::FrameMarker_SwapBuffers),
- m_trace(parent)
-{
-}
-
-void LoaderThread::run()
-{
- QList<ApiTraceFrame*> frames;
- ApiTraceFrame *currentFrame = 0;
- int frameCount = 0;
-
- QHash<QString, QUrl> helpHash;
-
-
- QFile file(":/resources/glreference.tsv");
- if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QString line;
- while (!file.atEnd()) {
- line = file.readLine();
- QString function = line.section('\t', 0, 0).trimmed();
- QUrl url = QUrl(line.section('\t', 1, 1).trimmed());
- //qDebug()<<"function = "<<function<<", url = "<<url.toString();
- helpHash.insert(function, url);
- }
- } else {
- qWarning() << "Couldn't open reference file "
- << file.fileName();
- }
- file.close();
-
- Trace::Parser p;
- QVector<ApiTraceCall*> calls;
- quint64 binaryDataSize = 0;
- if (p.open(m_fileName.toLatin1().constData())) {
- Trace::Call *call = p.parse_call();
- while (call) {
- //std::cout << *call;
- if (!currentFrame) {
- currentFrame = new ApiTraceFrame(m_trace);
- currentFrame->number = frameCount;
- ++frameCount;
- }
- ApiTraceCall *apiCall =
- apiCallFromTraceCall(call, helpHash, currentFrame);
- calls.append(apiCall);
- if (apiCall->hasBinaryData()) {
- QByteArray data =
- apiCall->arguments()[apiCall->binaryDataIndex()].toByteArray();
- binaryDataSize += data.size();
- }
- if (ApiTrace::isCallAFrameMarker(apiCall,
- m_frameMarker)) {
- calls.squeeze();
- currentFrame->setCalls(calls, binaryDataSize);
- calls.clear();
- frames.append(currentFrame);
- currentFrame = 0;
- binaryDataSize = 0;
- if (frames.count() >= FRAMES_TO_CACHE) {
- emit parsedFrames(frames);
- frames.clear();
- }
- }
- delete call;
- call = p.parse_call();
- }
- }
- if (currentFrame) {
- calls.squeeze();
- currentFrame->setCalls(calls, binaryDataSize);
- frames.append(currentFrame);
- currentFrame = 0;
- }
- if (frames.count()) {
- emit parsedFrames(frames);
- }
-}
-
-void LoaderThread::loadFile(const QString &fileName)
-{
- m_fileName = fileName;
- start();
-}
-
-ApiTrace::FrameMarker LoaderThread::frameMarker() const
-{
- return m_frameMarker;
-}
-
-void LoaderThread::setFrameMarker(ApiTrace::FrameMarker marker)
-{
- Q_ASSERT(!isRunning());
- m_frameMarker = marker;
-}
-
-#include "loaderthread.moc"