summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorDan McCabe <zen3d.linux@gmail.com>2012-06-01 13:40:03 -0700
committerJose Fonseca <jfonseca@vmware.com>2015-01-26 00:05:44 +0000
commitd139532899de140a3514a730dc77d8bae2cfdb48 (patch)
tree2219ccb09bfa6df6cbf20bb5a563a531af567f01 /gui
parentb6b6d7cd2eed15d019bfc616c9b119e82cddd09e (diff)
gui: Detect and accumulate missing thumbnails.
Previously, ALL frame thumbnails were loaded when the user wanted to see thumbnails. This patch sets the foundations for loading only those thumbnails that are visible in the current (and all previously displayed) window(s). In ApiCallDelegate::paint(), it is noted that a thumbnail may not be valid and therefore is missing. If this is the case, the frame or call is notified that the client of the thumbnail cares that the thumbnail is missing. The frame or call in turn notifies the trace that a thumbnail is missing and is desired. The trace then accumulates the missing thumbnails in a set. Note that the act of querying the thumbnail itself is not sufficient to detect that a thumbnail is missing. This is because ApiCallDelegate::sizeHint() also queries the thumbnail to determine its size. It turns out that these size queries occur even for calls and frames that are not immediately visible. Using just the query for the thumbnail to detect that it is missing results in many more thumbnail capture activities than are otherwise needed.
Diffstat (limited to 'gui')
-rw-r--r--gui/apicalldelegate.cpp4
-rw-r--r--gui/apitrace.cpp29
-rw-r--r--gui/apitrace.h10
-rw-r--r--gui/apitracecall.cpp10
-rw-r--r--gui/apitracecall.h7
5 files changed, 60 insertions, 0 deletions
diff --git a/gui/apicalldelegate.cpp b/gui/apicalldelegate.cpp
index 0e583bca..a38ed78c 100644
--- a/gui/apicalldelegate.cpp
+++ b/gui/apicalldelegate.cpp
@@ -43,6 +43,8 @@ void ApiCallDelegate::paint(QPainter *painter,
if (!thumbnail.isNull()) {
painter->drawImage(offset, thumbnail);
offset += QPoint(textSize.height() + thumbnail.width(), option.rect.height()/2 - textSize.height()/2);
+ } else {
+ frame->missingThumbnail();
}
}
@@ -58,6 +60,8 @@ void ApiCallDelegate::paint(QPainter *painter,
if (!thumbnail.isNull()) {
painter->drawImage(offset, thumbnail);
offset += QPoint(textSize.height() + thumbnail.width(), option.rect.height()/2 - textSize.height()/2);
+ } else {
+ call->missingThumbnail();
}
if (call->hasError()) {
QPixmap px = m_errorEmblem.pixmap(textSize.height(),
diff --git a/gui/apitrace.cpp b/gui/apitrace.cpp
index 46516f5e..fc38f098 100644
--- a/gui/apitrace.cpp
+++ b/gui/apitrace.cpp
@@ -508,4 +508,33 @@ void ApiTrace::bindThumbnailsToFrames(const QList<QImage> &thumbnails)
}
}
+void ApiTrace::missingThumbnail(ApiTraceFrame *frame)
+{
+ missingThumbnail(frame->lastCallIndex());
+}
+
+void ApiTrace::missingThumbnail(ApiTraceCall *call)
+{
+ missingThumbnail(call->index());
+}
+
+void ApiTrace::missingThumbnail(int callIdx)
+{
+ // technically, the contain() test is redundant, since this is a set;
+ // however, it enables debugging techniques to confirm correct behavior
+ if (!m_missingThumbnails.contains(callIdx)) {
+ //qDebug() << QLatin1String("debug: new missing thumbnail: ") << callIdx;
+ m_missingThumbnails.insert(callIdx);
+ }
+}
+
+bool ApiTrace::isMissingThumbnails() const
+{
+ return !m_missingThumbnails.isEmpty();
+}
+void ApiTrace::resetMissingThumbnails()
+{
+ m_missingThumbnails.clear();
+}
+
#include "apitrace.moc"
diff --git a/gui/apitrace.h b/gui/apitrace.h
index 22bedec2..efc9d5b3 100644
--- a/gui/apitrace.h
+++ b/gui/apitrace.h
@@ -77,6 +77,12 @@ public:
trace::API api() const;
+ void missingThumbnail(ApiTraceFrame* frame);
+ void missingThumbnail(ApiTraceCall* call);
+
+ bool isMissingThumbnails() const;
+ void resetMissingThumbnails();
+
public slots:
void setFileName(const QString &name);
void save();
@@ -141,6 +147,8 @@ private slots:
private:
int callInFrame(int callIdx) const;
bool isFrameLoading(ApiTraceFrame *frame) const;
+
+ void missingThumbnail(int callIdx);
private:
QString m_fileName;
QString m_tempFileName;
@@ -159,6 +167,8 @@ private:
QSet<ApiTraceCall*> m_errors;
QList< QPair<ApiTraceFrame*, ApiTraceError> > m_queuedErrors;
QSet<ApiTraceFrame*> m_loadingFrames;
+
+ QSet<int> m_missingThumbnails;
};
#endif
diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp
index 3257fb23..3429e6be 100644
--- a/gui/apitracecall.cpp
+++ b/gui/apitracecall.cpp
@@ -1090,6 +1090,11 @@ bool ApiTraceCall::contains(const QString &str,
return txt.contains(str, sensitivity);
}
+void ApiTraceCall::missingThumbnail()
+{
+ m_parentFrame->parentTrace()->missingThumbnail(this);
+}
+
ApiTraceFrame::ApiTraceFrame(ApiTrace *parentTrace)
: ApiTraceEvent(ApiTraceEvent::Frame),
@@ -1289,3 +1294,8 @@ unsigned ApiTraceFrame::lastCallIndex() const
return m_lastCallIndex;
}
}
+
+void ApiTraceFrame::missingThumbnail()
+{
+ m_parentTrace->missingThumbnail(this);
+}
diff --git a/gui/apitracecall.h b/gui/apitracecall.h
index 12d94cbd..c99784d2 100644
--- a/gui/apitracecall.h
+++ b/gui/apitracecall.h
@@ -221,6 +221,8 @@ public:
void setThumbnail(const QImage & thumbnail);
const QImage & thumbnail() const;
+ virtual void missingThumbnail() = 0;
+
protected:
int m_type : 4;
mutable int m_binaryDataIndex:8;
@@ -286,6 +288,9 @@ public:
QString backtrace() const;
void setBacktrace(QString backtrace);
+
+ void missingThumbnail();
+
private:
void loadData(TraceLoader *loader,
const trace::Call *tcall);
@@ -352,6 +357,8 @@ public:
void setLastCallIndex(unsigned index);
unsigned lastCallIndex() const;
+ void missingThumbnail();
+
private:
ApiTrace *m_parentTrace;
quint64 m_binaryDataSize;