3 #include "loaderthread.h"
6 : m_frameMarker(ApiTrace::FrameMarker_SwapBuffers)
8 m_loader = new LoaderThread(this);
9 connect(m_loader, SIGNAL(parsedFrames(const QList<ApiTraceFrame*>)),
10 this, SLOT(addFrames(const QList<ApiTraceFrame*>)));
20 bool ApiTrace::isCallAFrameMarker(const ApiTraceCall *call,
21 ApiTrace::FrameMarker marker)
27 case FrameMarker_SwapBuffers:
28 return call->name.contains(QLatin1String("SwapBuffers"));
29 case FrameMarker_Flush:
30 return call->name == QLatin1String("glFlush");
31 case FrameMarker_Finish:
32 return call->name == QLatin1String("glFinish");
33 case FrameMarker_Clear:
34 return call->name == QLatin1String("glClear");
37 Q_ASSERT(!"unknown frame marker");
42 bool ApiTrace::isEmpty() const
44 return m_calls.isEmpty();
47 QString ApiTrace::fileName() const
52 ApiTrace::FrameMarker ApiTrace::frameMarker() const
57 QList<ApiTraceCall*> ApiTrace::calls() const
62 ApiTraceCall * ApiTrace::callAt(int idx) const
64 return m_calls.value(idx);
67 int ApiTrace::numCalls() const
69 return m_calls.count();
72 QList<ApiTraceFrame*> ApiTrace::frames() const
77 ApiTraceFrame * ApiTrace::frameAt(int idx) const
79 return m_frames.value(idx);
82 int ApiTrace::numFrames() const
84 return m_frames.count();
87 int ApiTrace::numCallsInFrame(int idx) const
89 const ApiTraceFrame *frame = frameAt(idx);
91 return frame->calls.count();
96 void ApiTrace::setFileName(const QString &name)
98 if (m_fileName != name) {
101 if (m_loader->isRunning()) {
102 m_loader->terminate();
107 m_loader->loadFile(m_fileName);
111 void ApiTrace::setFrameMarker(FrameMarker marker)
113 if (m_frameMarker != marker) {
114 emit framesInvalidated();
116 qDeleteAll(m_frames);
122 void ApiTrace::addFrames(const QList<ApiTraceFrame*> &frames)
124 int currentFrames = m_frames.count();
125 int numNewFrames = frames.count();
128 int currentCalls = m_calls.count();
130 foreach(ApiTraceFrame *frame, frames) {
131 numNewCalls += frame->calls.count();
132 m_calls += frame->calls;
135 emit framesAdded(currentFrames, numNewFrames);
136 emit callsAdded(currentCalls, numNewCalls);
139 void ApiTrace::detectFrames()
141 if (m_calls.isEmpty())
144 ApiTraceFrame *currentFrame = 0;
145 foreach(ApiTraceCall *apiCall, m_calls) {
147 currentFrame = new ApiTraceFrame();
148 currentFrame->number = m_frames.count();
150 apiCall->parentFrame = currentFrame;
151 apiCall->index = currentFrame->calls.count();
152 currentFrame->calls.append(apiCall);
153 if (ApiTrace::isCallAFrameMarker(apiCall,
155 m_frames.append(currentFrame);
159 //last frames won't have markers
160 // it's just a bunch of Delete calls for every object
161 // after the last SwapBuffers
163 m_frames.append(currentFrame);
166 emit framesAdded(0, m_frames.count());
169 #include "apitrace.moc"