summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qperformancetimer.cpp
diff options
context:
space:
mode:
authorFrantisek Vacek <fvacek@rim.com>2012-09-28 11:27:49 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-28 13:14:47 +0200
commitfdbad25c5d5a1792bec5ab72a573fc4ad60378fc (patch)
treea62d84a60eed150e186ca5cdad53ec2d1cf52a54 /src/declarative/qml/qperformancetimer.cpp
parenta8b637e9b70bb420690523cd3f77f139813deec8 (diff)
QDeclarativeTrace patch for a custom trace instance
Needed for the BB10 Cascades profiling. There are more reasons for introducing this patch: 1) Cascades do not use QtGui library for QML rendering. It has its own paint engine with client-server architecture. Profiler traces are sent asynchronously from non Qt renderer thread to the Qt client. The QPerformanceTimer has to be patched too, cause we need to know time difference between tracing zero time and some time in past, see: qint64 QPerformanceTimer::elapsed(qint64 to_monotonic_time_ns) const 2) Since we need more sophisticated trace engine in cascades, this patch allows explicitly assign custom class derived from QDeclaraqtiveDebugtrace to the trace framework. If no custom instance is assigned, the default QDeclarativeDebugTrace instance is created implicitly on first trace request. Using custom trace instance which is not part of Qt (it is part of libbbcascades) allows us to implement all Cascades trace special needs in libbbcascades and not to carry Qt with the platform specific code. 3) The NO_CUSTOM_DECLARATIVE_DEBUG_TRACE_INSTANCE macro is introduced to allow custom trace engine only on the bleckberry platform, see declarative.pro. If this macro is defined Qt compiles from its original code. 4) Possibility of custom QDeclaraqtiveDebugTrace instance might be usable for other projects which needs to extends somehow default Qt trace functionality. 5) Patch is not intended to be applied to Qt Quick 2, since declarative debugging infrastructure is changed there. Change-Id: I199211c1de66e930e252e8c033503d7f4940565f Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
Diffstat (limited to 'src/declarative/qml/qperformancetimer.cpp')
-rw-r--r--src/declarative/qml/qperformancetimer.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/declarative/qml/qperformancetimer.cpp b/src/declarative/qml/qperformancetimer.cpp
index b7c2f47c..9e2e0734 100644
--- a/src/declarative/qml/qperformancetimer.cpp
+++ b/src/declarative/qml/qperformancetimer.cpp
@@ -80,6 +80,13 @@ qint64 QPerformanceTimer::elapsed() const
return absoluteToNSecs(cpu_time - t1);
}
+// return number of nsecs elapsed from timer start time till absoluteMonotonicTimeNs
+qint64 QPerformanceTimer::elapsedToAbsoluteTime(qint64 absoluteMonotonicTimeNs) const
+{
+ uint64_t cpu_time = absoluteMonotonicTimeNs;
+ return absoluteToNSecs(cpu_time - t1);
+}
+
////////////////////////////// Unix //////////////////////////////
#elif defined(Q_OS_UNIX)
@@ -154,6 +161,16 @@ qint64 QPerformanceTimer::elapsed() const
return sec * Q_INT64_C(1000000000) + frac;
}
+qint64 QPerformanceTimer::elapsedToAbsoluteTime(qint64 absoluteMonotonicTimeNs) const
+{
+ qint64 sec = absoluteMonotonicTimeNs / Q_INT64_C(1000000000);
+ qint64 frac = absoluteMonotonicTimeNs % Q_INT64_C(1000000000);
+ sec = sec - t1;
+ frac = frac - t2;
+
+ return sec * Q_INT64_C(1000000000) + frac;
+}
+
////////////////////////////// Windows //////////////////////////////
#elif defined(Q_OS_WIN)
@@ -179,6 +196,11 @@ qint64 QPerformanceTimer::elapsed() const
return getTimeFromTick(li.QuadPart - t1);
}
+qint64 QPerformanceTimer::elapsedToAbsoluteTime(qint64 absoluteMonotonicTimeNs) const
+{
+ return absoluteMonotonicTimeNs - t1;
+}
+
////////////////////////////// Default //////////////////////////////
#else
@@ -192,6 +214,12 @@ qint64 QPerformanceTimer::elapsed() const
return 0;
}
+qint64 QPerformanceTimer::elapsedToAbsoluteTime(qint64 absoluteMonotonicTimeNs) const
+{
+ Q_UNUSED(absoluteMonotonicTimeNs);
+ return 0;
+}
+
#endif
QT_END_NAMESPACE