aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger
diff options
context:
space:
mode:
authorChristiaan Janssen <christiaan.janssen@digia.com>2012-10-24 16:09:29 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-30 13:07:16 +0200
commit107444f7c479ed6a1a3d2c42b026ebc9c1fe4b29 (patch)
tree1b2d5de24ac315fc1e57beeb38d0fed141fafab6 /src/qml/debugger
parent3b0a9b27fec09cdab4cde7bfc41578c8c17a8832 (diff)
QmlProfiler: Pixmap Cache
Change-Id: Ibc237bb162c24030438b89d54fa8802ee66b080a Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/qml/debugger')
-rw-r--r--src/qml/debugger/qqmlprofilerservice.cpp33
-rw-r--r--src/qml/debugger/qqmlprofilerservice_p.h66
2 files changed, 96 insertions, 3 deletions
diff --git a/src/qml/debugger/qqmlprofilerservice.cpp b/src/qml/debugger/qqmlprofilerservice.cpp
index cb85fc0e1f..e016b2fdb5 100644
--- a/src/qml/debugger/qqmlprofilerservice.cpp
+++ b/src/qml/debugger/qqmlprofilerservice.cpp
@@ -76,6 +76,15 @@ QByteArray QQmlProfilerData::toByteArray() const
if (messageType == (int)QQmlProfilerService::Event &&
detailType == (int)QQmlProfilerService::AnimationFrame)
ds << framerate << animationcount;
+ if (messageType == (int)QQmlProfilerService::PixmapCacheEvent) {
+ ds << detailData;
+ switch (detailType) {
+ case QQmlProfilerService::PixmapSizeKnown: ds << line << column; break;
+ case QQmlProfilerService::PixmapReferenceCountChanged: ds << animationcount; break;
+ case QQmlProfilerService::PixmapCacheCountChanged: ds << animationcount; break;
+ default: break;
+ }
+ }
return data;
}
@@ -238,6 +247,30 @@ void QQmlProfilerService::endRange(RangeType range)
processMessage(rd);
}
+void QQmlProfilerService::pixmapEventImpl(PixmapEventType eventType, const QUrl &url)
+{
+ // assuming enabled checked by caller
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)PixmapCacheEvent, (int)eventType,
+ url.toString(), -1, -1, -1, -1, -1};
+ processMessage(rd);
+}
+
+void QQmlProfilerService::pixmapEventImpl(PixmapEventType eventType, const QUrl &url, int width, int height)
+{
+ // assuming enabled checked by caller
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)PixmapCacheEvent, (int)eventType,
+ url.toString(), width, height, -1, -1, -1};
+ processMessage(rd);
+}
+
+void QQmlProfilerService::pixmapEventImpl(PixmapEventType eventType, const QUrl &url, int count)
+{
+ // assuming enabled checked by caller
+ QQmlProfilerData rd = {m_timer.nsecsElapsed(), (int)PixmapCacheEvent, (int)eventType,
+ url.toString(), -1, -1, -1, count, -1};
+ processMessage(rd);
+}
+
void QQmlProfilerService::animationFrameImpl(qint64 delta)
{
Q_ASSERT(QQmlDebugService::isDebuggingEnabled());
diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h
index a50fb5ea08..30eb2ebbf4 100644
--- a/src/qml/debugger/qqmlprofilerservice_p.h
+++ b/src/qml/debugger/qqmlprofilerservice_p.h
@@ -74,10 +74,10 @@ struct Q_AUTOTEST_EXPORT QQmlProfilerData
//###
QString detailData; //used by RangeData and RangeLocation
- int line; //used by RangeLocation
- int column; //used by RangeLocation
+ int line; //used by RangeLocation, also as "width" for pixmaps
+ int column; //used by RangeLocation, also as "height" for pixmaps
int framerate; //used by animation events
- int animationcount; //used by animation events
+ int animationcount; //used by animation events, also as "cache/reference count" for pixmaps
int bindingType;
QByteArray toByteArray() const;
@@ -99,6 +99,7 @@ public:
RangeLocation,
RangeEnd,
Complete, // end of transmission
+ PixmapCacheEvent,
MaximumMessage
};
@@ -132,6 +133,17 @@ public:
MaximumBindingType
};
+ enum PixmapEventType {
+ PixmapSizeKnown,
+ PixmapReferenceCountChanged,
+ PixmapCacheCountChanged,
+ PixmapLoadingStarted,
+ PixmapLoadingFinished,
+ PixmapLoadingError,
+
+ MaximumPixmapEventType
+ };
+
static void initialize();
static bool startProfiling();
@@ -163,6 +175,10 @@ private:
void rangeLocation(RangeType, const QUrl &, int, int);
void endRange(RangeType);
+ // overloading depending on parameters
+ void pixmapEventImpl(PixmapEventType eventType, const QUrl &url);
+ void pixmapEventImpl(PixmapEventType eventType, const QUrl &url, int width, int height);
+ void pixmapEventImpl(PixmapEventType eventType, const QUrl &url, int count);
bool profilingEnabled();
void setProfilingEnabled(bool enable);
@@ -183,6 +199,7 @@ private:
friend struct QQmlHandlingSignalProfiler;
friend struct QQmlObjectCreatingProfiler;
friend struct QQmlCompilingProfiler;
+ friend struct QQmlPixmapProfiler;
};
//
@@ -288,6 +305,49 @@ struct QQmlCompilingProfiler {
bool enabled;
};
+struct QQmlPixmapProfiler {
+ QQmlPixmapProfiler() {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ }
+
+ ~QQmlPixmapProfiler() {}
+
+ void startLoading(const QUrl &pixmapUrl) {
+ if (enabled) {
+ QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapLoadingStarted, pixmapUrl);
+ }
+ }
+ void finishLoading(const QUrl &pixmapUrl) {
+ if (enabled) {
+ QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapLoadingFinished, pixmapUrl);
+ }
+ }
+ void errorLoading(const QUrl &pixmapUrl) {
+ if (enabled) {
+ QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapLoadingError, pixmapUrl);
+ }
+ }
+ void cacheCountChanged(const QUrl &pixmapUrl, int cacheCount) {
+ if (enabled) {
+ QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapCacheCountChanged, pixmapUrl, cacheCount);
+ }
+ }
+ void referenceCountChanged(const QUrl &pixmapUrl, int referenceCount) {
+ if (enabled) {
+ QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapReferenceCountChanged, pixmapUrl, referenceCount);
+ }
+ }
+ void setSize(const QUrl &pixmapUrl, int width, int height) {
+ if (enabled) {
+ QQmlProfilerService::instance->pixmapEventImpl(QQmlProfilerService::PixmapSizeKnown, pixmapUrl, width, height);
+ }
+ }
+
+ bool enabled;
+};
+
QT_END_NAMESPACE
#endif // QQMLPROFILERSERVICE_P_H