summaryrefslogtreecommitdiff
path: root/retrace
diff options
context:
space:
mode:
authorMark Janes <mark.a.janes@intel.com>2017-04-20 15:00:00 -0700
committerMark Janes <mark.a.janes@intel.com>2017-06-19 14:04:51 -0700
commita24d7abd1116bc1b0a5d8035bc9459db72ce9d51 (patch)
tree088a3c49cfa6ed56f5925110e05910a415c3d974 /retrace
parent722f9b39d2884e8615ba016daaf1694f48e8f96d (diff)
Api: Provide filtering of api log
Text box allows the user to find selected renders that contain a substring in their api logs.
Diffstat (limited to 'retrace')
-rw-r--r--retrace/daemon/ui/glframe_api_model.cpp64
-rw-r--r--retrace/daemon/ui/glframe_api_model.hpp6
-rw-r--r--retrace/daemon/ui/qml/ApiControl.qml43
3 files changed, 97 insertions, 16 deletions
diff --git a/retrace/daemon/ui/glframe_api_model.cpp b/retrace/daemon/ui/glframe_api_model.cpp
index 469498e9..00537045 100644
--- a/retrace/daemon/ui/glframe_api_model.cpp
+++ b/retrace/daemon/ui/glframe_api_model.cpp
@@ -47,39 +47,73 @@ QApiModel::~QApiModel() {
QString
QApiModel::apiCalls() {
+ ScopedLock s(m_protect);
if (m_index < 0)
return QString("");
- return m_api_calls[m_renders[m_index]];
+ if (m_index >= m_filtered_renders.size())
+ return QString("");
+ return m_api_calls[m_filtered_renders[m_index]];
}
void
QApiModel::onApi(SelectionId selectionCount,
RenderId renderId,
const std::vector<std::string> &api_calls) {
- if (m_sel_count != selectionCount) {
- m_api_calls.clear();
- m_renders.clear();
- m_sel_count = selectionCount;
- }
+ {
+ ScopedLock s(m_protect);
+ if (m_sel_count != selectionCount) {
+ m_api_calls.clear();
+ m_renders.clear();
+ m_sel_count = selectionCount;
+ }
- m_renders.push_back(QString("%1").arg(renderId.index()));
- QString &api = m_api_calls[m_renders.back()];
- for (auto i : api_calls) {
- api.append(QString::fromStdString(i));
+ m_renders.push_back(QString("%1").arg(renderId.index()));
+ QString &api = m_api_calls[m_renders.back()];
+ for (auto i : api_calls) {
+ api.append(QString::fromStdString(i));
+ }
+ m_api_calls[m_renders.back()] = api;
+ filter();
}
- m_api_calls[m_renders.back()] = api;
- if (m_api_calls.size() == 1)
- setIndex(0);
+ setIndex(0);
emit onRenders();
}
void
QApiModel::setIndex(int index) {
- m_index = index;
+ {
+ ScopedLock s(m_protect);
+ m_index = index;
+ }
emit onApiCalls();
}
QStringList
QApiModel::renders() const {
- return m_renders;
+ ScopedLock s(m_protect);
+ return m_filtered_renders;
+}
+
+void
+QApiModel::filter(QString substring) {
+ {
+ ScopedLock s(m_protect);
+ m_filter = substring;
+ filter();
+ }
+ emit onRenders();
+ setIndex(0);
+}
+
+void
+QApiModel::filter() {
+ m_filtered_renders.clear();
+ if (m_filter.length() == 0) {
+ m_filtered_renders = m_renders;
+ } else {
+ for (auto i : m_renders) {
+ if (m_api_calls[i].contains(m_filter, Qt::CaseInsensitive))
+ m_filtered_renders.append(i);
+ }
+ }
}
diff --git a/retrace/daemon/ui/glframe_api_model.hpp b/retrace/daemon/ui/glframe_api_model.hpp
index bb20ba3e..e2fa38ca 100644
--- a/retrace/daemon/ui/glframe_api_model.hpp
+++ b/retrace/daemon/ui/glframe_api_model.hpp
@@ -55,16 +55,22 @@ class QApiModel : public QObject,
RenderId renderId,
const std::vector<std::string> &api_calls);
Q_INVOKABLE void setIndex(int index);
+ Q_INVOKABLE void filter(QString substring);
signals:
void onApiCalls();
void onRenders();
private:
+ void filter();
+
std::map<QString, QString> m_api_calls;
QStringList m_renders;
+ QStringList m_filtered_renders;
SelectionId m_sel_count;
int m_index;
+ QString m_filter;
+ mutable std::mutex m_protect;
};
} // namespace glretrace
diff --git a/retrace/daemon/ui/qml/ApiControl.qml b/retrace/daemon/ui/qml/ApiControl.qml
index 52ff6ae7..96ea6675 100644
--- a/retrace/daemon/ui/qml/ApiControl.qml
+++ b/retrace/daemon/ui/qml/ApiControl.qml
@@ -6,8 +6,49 @@ import ApiTrace 1.0
Item {
property QApiModel apiModel
+ Item {
+ id: apiItem
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ width: 400
+ height: textRect.height
+
+ Text {
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.topMargin: 5
+ id: filterText
+ text: "Api Filter:"
+ }
+ Rectangle {
+ anchors.top: parent.top
+ anchors.left: filterText.right
+ anchors.leftMargin: 20
+ height: filterText.height * 1.5
+ border.width: 1
+ width: apiItem.width/2
+ id: textRect
+ TextInput {
+ height: filterText.height
+ width: parent.width
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.leftMargin: 4
+ id: metricFilter
+ text: ""
+ onDisplayTextChanged: {
+ apiModel.filter(displayText)
+ }
+ }
+ }
+ }
+
SplitView {
- anchors.fill: parent
+ anchors.top: apiItem.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
ScrollView {
Layout.preferredWidth: 100