1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
#pragma once
#include "apisurface.h"
#include <QStaticText>
#include <QStringList>
#include <QUrl>
#include <QVariant>
#include "trace_model.hpp"
class ApiTrace;
class TraceLoader;
class VariantVisitor : public trace::Visitor
{
public:
virtual void visit(trace::Null *) override;
virtual void visit(trace::Bool *node) override;
virtual void visit(trace::SInt *node) override;
virtual void visit(trace::UInt *node) override;
virtual void visit(trace::Float *node) override;
virtual void visit(trace::Double *node) override;
virtual void visit(trace::String *node) override;
virtual void visit(trace::WString *node) override;
virtual void visit(trace::Enum *e) override;
virtual void visit(trace::Bitmask *bitmask) override;
virtual void visit(trace::Struct *str) override;
virtual void visit(trace::Array *array) override;
virtual void visit(trace::Blob *blob) override;
virtual void visit(trace::Pointer *ptr) override;
virtual void visit(trace::Repr *ptr) override;
QVariant variant() const
{
return m_variant;
}
private:
QVariant m_variant;
};
struct ApiTraceError
{
int callIndex;
QString type;
QString message;
};
class ApiEnum
{
public:
ApiEnum(const trace::EnumSig *sig=0, signed long long value = 0);
QString toString() const;
QVariant value() const;
private:
const trace::EnumSig *m_sig;
signed long long m_value;
};
Q_DECLARE_METATYPE(ApiEnum);
class ApiPointer
{
public:
ApiPointer(unsigned long long val=0);
QString toString() const;
unsigned long long value() const;
private:
unsigned long long m_value;
};
Q_DECLARE_METATYPE(ApiPointer);
class ApiBitmask
{
public:
typedef QList<QPair<QString, unsigned long long> > Signature;
ApiBitmask(const trace::Bitmask *bitmask = 0);
QString toString() const;
unsigned long long value() const;
Signature signature() const;
private:
void init(const trace::Bitmask *bitmask);
private:
Signature m_sig;
unsigned long long m_value;
};
Q_DECLARE_METATYPE(ApiBitmask);
class ApiStruct
{
public:
struct Signature {
QString name;
QStringList memberNames;
};
ApiStruct(const trace::Struct *s = 0);
QString toString(bool multiLine = false) const;
Signature signature() const;
QList<QVariant> values() const;
private:
void init(const trace::Struct *bitmask);
private:
Signature m_sig;
QList<QVariant> m_members;
};
Q_DECLARE_METATYPE(ApiStruct);
class ApiArray
{
public:
ApiArray(const trace::Array *arr = 0);
ApiArray(const QVector<QVariant> &vals);
QString toString(bool multiLine = false) const;
QVector<QVariant> values() const;
private:
void init(const trace::Array *arr);
private:
QVector<QVariant> m_array;
};
Q_DECLARE_METATYPE(ApiArray);
QString apiVariantToString(const QVariant &variant, bool multiLine = false);
class ApiTraceFrame;
class ApiTraceState {
public:
ApiTraceState();
explicit ApiTraceState(const QVariantMap &parseJson);
bool isEmpty() const;
const QVariantMap & parameters() const;
const QMap<QString, QString> & shaderSources() const;
const QVariantMap & uniforms() const;
const QVariantMap & buffers() const;
const QList<ApiTexture> & textures() const;
const QList<ApiFramebuffer> & framebuffers() const;
ApiFramebuffer colorBuffer() const;
private:
QVariantMap m_parameters;
QMap<QString, QString> m_shaderSources;
QVariantMap m_uniforms;
QVariantMap m_buffers;
QList<ApiTexture> m_textures;
QList<ApiFramebuffer> m_framebuffers;
};
Q_DECLARE_METATYPE(ApiTraceState);
class ApiTraceCallSignature
{
public:
ApiTraceCallSignature(const QString &name,
const QStringList &argNames);
~ApiTraceCallSignature();
QString name() const
{
return m_name;
}
QStringList argNames() const
{
return m_argNames;
}
QUrl helpUrl() const;
void setHelpUrl(const QUrl &url);
private:
QString m_name;
QStringList m_argNames;
QUrl m_helpUrl;
};
class ApiTraceCall;
class ApiTraceEvent
{
public:
enum Type {
None = 0,
Call = 1 << 0,
Frame = 1 << 1
};
public:
ApiTraceEvent();
ApiTraceEvent(Type t);
virtual ~ApiTraceEvent();
Type type() const { return (Type)m_type; }
virtual QStaticText staticText() const = 0;
virtual int numChildren() const = 0;
virtual int callIndex(ApiTraceCall *call) const = 0;
virtual ApiTraceEvent *eventAtRow(int row) const = 0;
ApiTraceState *state() const;
void setState(ApiTraceState *state);
bool hasState() const
{
return m_state && !m_state->isEmpty();
}
void setThumbnail(const QImage & thumbnail);
const QImage & thumbnail() const;
virtual void missingThumbnail() = 0;
protected:
int m_type : 4;
mutable int m_binaryDataIndex:8;
ApiTraceState *m_state;
mutable QStaticText *m_staticText;
QImage m_thumbnail;
};
Q_DECLARE_METATYPE(ApiTraceEvent*);
class ApiTraceCall : public ApiTraceEvent
{
public:
ApiTraceCall(ApiTraceCall *parentCall, TraceLoader *loader,
const trace::Call *tcall);
ApiTraceCall(ApiTraceFrame *parentFrame, TraceLoader *loader,
const trace::Call *tcall);
~ApiTraceCall();
int index() const;
QString name() const;
QStringList argNames() const;
QVector<QVariant> arguments() const;
QVariant returnValue() const;
trace::CallFlags flags() const;
QUrl helpUrl() const;
void setHelpUrl(const QUrl &url);
ApiTraceFrame *parentFrame()const;
void setParentFrame(ApiTraceFrame *frame);
int callIndex(ApiTraceCall *call) const override;
ApiTraceEvent *parentEvent() const;
ApiTraceCall *parentCall() const;
QVector<ApiTraceCall*> children() const;
ApiTraceEvent *eventAtRow(int row) const override;
void addChild(ApiTraceCall *call);
void finishedAddingChildren();
bool hasError() const;
QString error() const;
void setError(const QString &msg);
QVector<QVariant> originalValues() const;
bool edited() const;
void setEditedValues(const QVector<QVariant> &lst);
QVector<QVariant> editedValues() const;
void revert();
bool contains(const QString &str,
Qt::CaseSensitivity sensitivity) const;
ApiTrace *parentTrace() const;
QString toHtml() const;
QString searchText() const;
QStaticText staticText() const override;
int numChildren() const override;
bool hasBinaryData() const;
int binaryDataIndex() const;
QString backtrace() const;
void setBacktrace(QString backtrace);
void missingThumbnail() override;
private:
void loadData(TraceLoader *loader,
const trace::Call *tcall);
private:
int m_index;
unsigned m_thread;
ApiTraceCallSignature *m_signature;
QVector<QVariant> m_argValues;
QVariant m_returnValue;
trace::CallFlags m_flags;
ApiTraceFrame *m_parentFrame;
ApiTraceCall *m_parentCall;
QVector<ApiTraceCall*> m_children;
QVector<QVariant> m_editedValues;
QString m_error;
QString m_backtrace;
mutable QString m_richText;
mutable QString m_searchText;
};
Q_DECLARE_METATYPE(ApiTraceCall*);
class ApiTraceFrame : public ApiTraceEvent
{
public:
ApiTraceFrame(ApiTrace *parent=0);
~ApiTraceFrame();
int number;
bool isEmpty() const;
void setParentTrace(ApiTrace *parent);
ApiTrace *parentTrace() const;
void setNumChildren(int num);
int numChildren() const override;
int numChildrenToLoad() const;
int numTotalCalls() const;
QStaticText staticText() const override;
ApiTraceEvent *eventAtRow(int row) const override;
int callIndex(ApiTraceCall *call) const override;
ApiTraceCall *callWithIndex(int index) const;
QVector<ApiTraceCall*> calls() const;
void setCalls(const QVector<ApiTraceCall*> &topLevelCalls,
const QVector<ApiTraceCall*> &allCalls,
quint64 binaryDataSize);
ApiTraceCall *findNextCall(ApiTraceCall *from,
const QString &str,
Qt::CaseSensitivity sensitivity) const;
ApiTraceCall *findPrevCall(ApiTraceCall *from,
const QString &str,
Qt::CaseSensitivity sensitivity) const;
int binaryDataSize() const;
bool isLoaded() const;
void setLastCallIndex(unsigned index);
unsigned lastCallIndex() const;
void missingThumbnail() override;
private:
ApiTrace *m_parentTrace;
quint64 m_binaryDataSize;
QVector<ApiTraceCall*> m_children;
QVector<ApiTraceCall*> m_calls;
bool m_loaded;
unsigned m_callsToLoad;
unsigned m_lastCallIndex;
};
Q_DECLARE_METATYPE(ApiTraceFrame*);
|