4 #include "apisurface.h"
11 #include "trace_model.hpp"
17 class VariantVisitor : public Trace::Visitor
20 VariantVisitor(TraceLoader *loader)
23 virtual void visit(Trace::Null *);
24 virtual void visit(Trace::Bool *node);
25 virtual void visit(Trace::SInt *node);
26 virtual void visit(Trace::UInt *node);
27 virtual void visit(Trace::Float *node);
28 virtual void visit(Trace::String *node);
29 virtual void visit(Trace::Enum *e);
30 virtual void visit(Trace::Bitmask *bitmask);
31 virtual void visit(Trace::Struct *str);
32 virtual void visit(Trace::Array *array);
33 virtual void visit(Trace::Blob *blob);
34 virtual void visit(Trace::Pointer *ptr);
36 QVariant variant() const
41 TraceLoader *m_loader;
53 class ApiTraceEnumSignature
56 ApiTraceEnumSignature(const QString &name = QString(),
57 const QVariant &val=QVariant())\
62 QVariant value() const { return m_value; }
63 QString name() const { return m_name; }
72 ApiEnum(ApiTraceEnumSignature *sig=0);
74 QString toString() const;
76 QVariant value() const;
79 ApiTraceEnumSignature *m_sig;
81 Q_DECLARE_METATYPE(ApiEnum);
86 ApiPointer(unsigned long long val=0);
88 QString toString() const;
90 unsigned long long value() const;
93 unsigned long long m_value;
95 Q_DECLARE_METATYPE(ApiPointer);
100 typedef QList<QPair<QString, unsigned long long> > Signature;
102 ApiBitmask(const Trace::Bitmask *bitmask = 0);
104 QString toString() const;
106 unsigned long long value() const;
107 Signature signature() const;
110 void init(const Trace::Bitmask *bitmask);
113 unsigned long long m_value;
115 Q_DECLARE_METATYPE(ApiBitmask);
122 QStringList memberNames;
125 ApiStruct(const Trace::Struct *s = 0);
127 QString toString() const;
128 Signature signature() const;
129 QList<QVariant> values() const;
132 void init(const Trace::Struct *bitmask);
135 QList<QVariant> m_members;
137 Q_DECLARE_METATYPE(ApiStruct);
142 ApiArray(const Trace::Array *arr = 0);
143 ApiArray(const QVector<QVariant> &vals);
145 QString toString() const;
147 QVector<QVariant> values() const;
149 void init(const Trace::Array *arr);
151 QVector<QVariant> m_array;
153 Q_DECLARE_METATYPE(ApiArray);
156 QString apiVariantToString(const QVariant &variant, bool multiLine = false);
160 class ApiTraceState {
163 explicit ApiTraceState(const QVariantMap &parseJson);
165 bool isEmpty() const;
166 const QVariantMap & parameters() const;
167 const QMap<QString, QString> & shaderSources() const;
168 const QVariantMap & uniforms() const;
169 const QList<ApiTexture> & textures() const;
170 const QList<ApiFramebuffer> & framebuffers() const;
172 ApiFramebuffer colorBuffer() const;
174 QVariantMap m_parameters;
175 QMap<QString, QString> m_shaderSources;
176 QVariantMap m_uniforms;
177 QList<ApiTexture> m_textures;
178 QList<ApiFramebuffer> m_framebuffers;
180 Q_DECLARE_METATYPE(ApiTraceState);
182 class ApiTraceCallSignature
185 ApiTraceCallSignature(const QString &name,
186 const QStringList &argNames);
187 ~ApiTraceCallSignature();
193 QStringList argNames() const
198 QUrl helpUrl() const;
199 void setHelpUrl(const QUrl &url);
203 QStringList m_argNames;
217 ApiTraceEvent(Type t);
218 virtual ~ApiTraceEvent();
220 Type type() const { return (Type)m_type; }
222 virtual QStaticText staticText() const = 0;
223 virtual int numChildren() const = 0;
225 QVariantMap stateParameters() const;
226 ApiTraceState *state() const;
227 void setState(ApiTraceState *state);
228 bool hasState() const
230 return m_state && !m_state->isEmpty();
235 mutable bool m_hasBinaryData;
236 mutable int m_binaryDataIndex:8;
237 ApiTraceState *m_state;
239 mutable QStaticText *m_staticText;
241 Q_DECLARE_METATYPE(ApiTraceEvent*);
243 class ApiTraceCall : public ApiTraceEvent
246 ApiTraceCall(ApiTraceFrame *parentFrame, TraceLoader *loader,
247 const Trace::Call *tcall);
251 QString name() const;
252 QStringList argNames() const;
253 QVector<QVariant> arguments() const;
254 QVariant returnValue() const;
255 QUrl helpUrl() const;
256 void setHelpUrl(const QUrl &url);
257 ApiTraceFrame *parentFrame()const;
258 void setParentFrame(ApiTraceFrame *frame);
260 bool hasError() const;
261 QString error() const;
262 void setError(const QString &msg);
264 QVector<QVariant> originalValues() const;
267 void setEditedValues(const QVector<QVariant> &lst);
268 QVector<QVariant> editedValues() const;
271 bool contains(const QString &str,
272 Qt::CaseSensitivity sensitivity) const;
274 ApiTrace *parentTrace() const;
276 QString toHtml() const;
277 QString searchText() const;
278 QStaticText staticText() const;
279 int numChildren() const;
280 bool hasBinaryData() const;
281 int binaryDataIndex() const;
284 ApiTraceCallSignature *m_signature;
285 QVector<QVariant> m_argValues;
286 QVariant m_returnValue;
287 ApiTraceFrame *m_parentFrame;
289 QVector<QVariant> m_editedValues;
293 mutable QString m_richText;
294 mutable QString m_searchText;
296 Q_DECLARE_METATYPE(ApiTraceCall*);
298 class ApiTraceFrame : public ApiTraceEvent
301 ApiTraceFrame(ApiTrace *parent=0);
305 bool isEmpty() const;
307 void setParentTrace(ApiTrace *parent);
308 ApiTrace *parentTrace() const;
310 void setNumChildren(int num);
311 int numChildren() const;
312 int numChildrenToLoad() const;
313 QStaticText staticText() const;
315 int callIndex(ApiTraceCall *call) const;
316 ApiTraceCall *call(int idx) const;
317 ApiTraceCall *callWithIndex(int index) const;
318 void addCall(ApiTraceCall *call);
319 QVector<ApiTraceCall*> calls() const;
320 void setCalls(const QVector<ApiTraceCall*> &calls,
321 quint64 binaryDataSize);
323 ApiTraceCall *findNextCall(ApiTraceCall *from,
325 Qt::CaseSensitivity sensitivity) const;
327 ApiTraceCall *findPrevCall(ApiTraceCall *from,
329 Qt::CaseSensitivity sensitivity) const;
331 int binaryDataSize() const;
334 void setLoaded(bool l);
336 void setLastCallIndex(unsigned index);
337 unsigned lastCallIndex() const;
339 ApiTrace *m_parentTrace;
340 quint64 m_binaryDataSize;
341 QVector<ApiTraceCall*> m_calls;
343 unsigned m_callsToLoad;
344 unsigned m_lastCallIndex;
346 Q_DECLARE_METATYPE(ApiTraceFrame*);