Move parts of QmlEvent and QmlEventType to timeline

Timeline will become a generic trace handling library. It needs some
abstract concept of events and event types.

Move operator== and operator!= for QmlEvent into the test as we don't
use them anywhere else.

Move the operators for QmlEventType to QmlProfilerTraceClient. We want
to get rid of the hash there as soon as we can assume that no
application we want to profile doesn't support server type IDs.

Change-Id: Icde4e3e7634e387171dc1d8bef7bbe8e71684a1a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ulf Hermann
2018-03-27 17:39:17 +02:00
parent 5c8c208f26
commit 507c2d6b5b
13 changed files with 216 additions and 94 deletions

View File

@@ -36,6 +36,25 @@
namespace QmlProfiler {
inline uint qHash(const QmlEventType &type)
{
return qHash(type.location())
^ (((type.message() << 12) & 0xf000) // 4 bits of message
| ((type.rangeType() << 24) & 0xf000000) // 4 bits of rangeType
| ((type.detailType() << 28) & 0xf0000000)); // 4 bits of detailType
}
inline bool operator==(const QmlEventType &type1, const QmlEventType &type2)
{
return type1.message() == type2.message() && type1.rangeType() == type2.rangeType()
&& type1.detailType() == type2.detailType() && type1.location() == type2.location();
}
inline bool operator!=(const QmlEventType &type1, const QmlEventType &type2)
{
return !(type1 == type2);
}
class QmlProfilerTraceClientPrivate {
public:
QmlProfilerTraceClientPrivate(QmlProfilerTraceClient *q,
@@ -53,7 +72,7 @@ public:
}
void sendRecordingStatus(int engineId);
bool updateFeatures(ProfileFeature feature);
bool updateFeatures(quint8 feature);
int resolveType(const QmlTypedEvent &type);
int resolveStackTop();
void forwardEvents(const QmlEvent &last);
@@ -321,7 +340,7 @@ void QmlProfilerTraceClient::setFlushInterval(quint32 flushInterval)
d->flushInterval = flushInterval;
}
bool QmlProfilerTraceClientPrivate::updateFeatures(ProfileFeature feature)
bool QmlProfilerTraceClientPrivate::updateFeatures(quint8 feature)
{
quint64 flag = 1ULL << feature;
if (!(requestedFeatures & flag))