main.cpp
retracer.cpp
settingsdialog.cpp
+ shaderssourcewidget.cpp
vertexdatainterpreter.cpp
)
set(qapitrace_UIS
ui/mainwindow.ui
ui/retracerdialog.ui
- ui/settings.ui)
+ ui/settings.ui
+ ui/shaderssourcewidget.ui
+ )
QT4_WRAP_UI(qapitrace_UIS_H ${qapitrace_UIS})
{
}
-QVariantMap ApiTraceEvent::state() const
+QVariantMap ApiTraceEvent::stateParameters() const
+{
+ return m_state.parameters();
+}
+
+ApiTraceState ApiTraceEvent::state() const
{
return m_state;
}
-void ApiTraceEvent::setState(const QVariantMap &state)
+void ApiTraceEvent::setState(const ApiTraceState &state)
{
m_state = state;
}
{
return m_binaryDataIndex;
}
+
+ApiTraceState::ApiTraceState()
+{
+}
+
+ApiTraceState::ApiTraceState(const QVariantMap &parsedJson)
+{
+ m_parameters = parsedJson[QLatin1String("parameters")].toMap();
+ QVariantMap currentProgram =
+ parsedJson[QLatin1String("current_program")].toMap();
+ QVariantList attachedShaders =
+ currentProgram[QLatin1String("attached_shaders")].toList();
+
+
+ for (int i = 0; i < attachedShaders.count(); ++i) {
+ QVariantMap var = attachedShaders[i].toMap();
+ m_shaderSources.append(
+ var[QLatin1String("source")].toString());
+ }
+}
+
+QVariantMap ApiTraceState::parameters() const
+{
+ return m_parameters;
+}
+
+QStringList ApiTraceState::shaderSources() const
+{
+ return m_shaderSources;
+}
+
+bool ApiTraceState::isEmpty() const
+{
+ return m_parameters.isEmpty();
+}
+
+
class ApiTraceFrame;
+class ApiTraceState {
+public:
+ ApiTraceState();
+ explicit ApiTraceState(const QVariantMap &parseJson);
+
+ bool isEmpty() const;
+ QVariantMap parameters() const;
+ QStringList shaderSources() const;
+
+private:
+ QVariantMap m_parameters;
+ QStringList m_shaderSources;
+};
+
class ApiTraceEvent
{
public:
virtual QStaticText staticText() const = 0;
virtual int numChildren() const = 0;
- QVariantMap state() const;
- void setState(const QVariantMap &state);
+ QVariantMap stateParameters() const;
+ ApiTraceState state() const;
+ void setState(const ApiTraceState &state);
protected:
Type m_type;
- QVariantMap m_state;
+ ApiTraceState m_state;
};
Q_DECLARE_METATYPE(ApiTraceEvent*);
#include "apitracefilter.h"
#include "retracer.h"
#include "settingsdialog.h"
+#include "shaderssourcewidget.h"
#include "ui_retracerdialog.h"
#include "vertexdatainterpreter.h"
#include <QProgressBar>
#include <QToolBar>
#include <QUrl>
+#include <QVBoxLayout>
#include <QWebPage>
#include <QWebView>
m_ui.setupUi(this);
m_ui.stateTreeWidget->sortByColumn(0, Qt::AscendingOrder);
+ m_sourcesWidget = new ShadersSourceWidget(m_ui.shadersTab);
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(m_sourcesWidget);
+ m_ui.shadersTab->setLayout(layout);
+
m_trace = new ApiTrace();
connect(m_trace, SIGNAL(startedLoadingTrace()),
this, SLOT(startedLoadingTrace()));
if (m_retracer->captureState()) {
bool ok = false;
QVariantMap parsedJson = m_jsonParser->parse(output, &ok).toMap();
- parseState(parsedJson[QLatin1String("parameters")].toMap());
+ parseState(parsedJson);
} else if (output.length() < 80) {
statusBar()->showMessage(output);
}
delete m_jsonParser;
}
-void MainWindow::parseState(const QVariantMap ¶ms)
+void MainWindow::parseState(const QVariantMap &parsedJson)
{
- QVariantMap::const_iterator itr;
-
- m_stateEvent->setState(params);
+ m_stateEvent->setState(ApiTraceState(parsedJson));
m_model->stateSetOnEvent(m_stateEvent);
if (m_selectedEvent == m_stateEvent) {
fillStateForFrame();
if (!m_selectedEvent || m_selectedEvent->state().isEmpty())
return;
+ const ApiTraceState &state = m_selectedEvent->state();
m_ui.stateTreeWidget->clear();
- params = m_selectedEvent->state();
+ params = state.parameters();
QList<QTreeWidgetItem *> items;
for (itr = params.constBegin(); itr != params.constEnd(); ++itr) {
QString key = itr.key();
items.append(new QTreeWidgetItem((QTreeWidget*)0, lst));
}
m_ui.stateTreeWidget->insertTopLevelItems(0, items);
+
+ QStringList shaderSources = state.shaderSources();
+ if (shaderSources.isEmpty()) {
+ m_sourcesWidget->setShaders(shaderSources);
+ } else {
+ m_sourcesWidget->setShaders(shaderSources);
+ }
+
+ m_ui.surfacesTab->setEnabled(false);
m_ui.stateDock->show();
}
class QProgressBar;
class QUrl;
class Retracer;
+class ShadersSourceWidget;
class VertexDataInterpreter;
namespace QJson {
private:
Ui_MainWindow m_ui;
+ ShadersSourceWidget *m_sourcesWidget;
+
ApiTrace *m_trace;
ApiTraceModel *m_model;
ApiTraceFilter *m_proxyModel;
--- /dev/null
+#include "shaderssourcewidget.h"
+
+ShadersSourceWidget::ShadersSourceWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ m_ui.setupUi(this);
+
+ connect(m_ui.shadersCB, SIGNAL(currentIndexChanged(int)),
+ SLOT(changeShader(int)));
+}
+
+void ShadersSourceWidget::setShaders(const QStringList &sources)
+{
+ m_sources = sources;
+
+ m_ui.shadersCB->clear();
+ m_ui.shadersTextEdit->clear();
+
+ if (m_sources.isEmpty()) {
+ m_ui.shadersCB->setDisabled(true);
+ m_ui.shadersTextEdit->setPlainText(
+ tr("No bound shaders."));
+ m_ui.shadersTextEdit->setDisabled(true);
+ return;
+ }
+
+ m_ui.shadersCB->setEnabled(true);
+ m_ui.shadersTextEdit->setEnabled(true);
+
+ for (int i = 0; i < m_sources.count(); ++i) {
+ QString source = m_sources[i];
+ m_ui.shadersCB->insertItem(
+ i,
+ tr("Shader %1").arg(i));
+ }
+ m_ui.shadersCB->setCurrentIndex(0);
+}
+
+void ShadersSourceWidget::changeShader(int idx)
+{
+ m_ui.shadersTextEdit->setPlainText(m_sources.value(idx));
+}
+
+#include "shaderssourcewidget.moc"
--- /dev/null
+#ifndef SHADERSSOURCEWIDGET_H
+#define SHADERSSOURCEWIDGET_H
+
+#include "ui_shaderssourcewidget.h"
+#include <QWidget>
+
+class ShadersSourceWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ ShadersSourceWidget(QWidget *parent=0);
+
+public slots:
+ void setShaders(const QStringList &sources);
+
+private slots:
+ void changeShader(int idx);
+private:
+ Ui::ShadersSourceWidget m_ui;
+ QStringList m_sources;
+};
+
+#endif
<widget class="QWidget" name="dockWidgetContents_2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QTreeWidget" name="stateTreeWidget">
- <property name="alternatingRowColors">
- <bool>true</bool>
+ <widget class="QTabWidget" name="stateTabWidget">
+ <property name="currentIndex">
+ <number>1</number>
</property>
- <property name="selectionMode">
- <enum>QAbstractItemView::NoSelection</enum>
- </property>
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- <property name="sortingEnabled">
- <bool>true</bool>
- </property>
- <property name="animated">
- <bool>true</bool>
- </property>
- <property name="allColumnsShowFocus">
- <bool>true</bool>
- </property>
- <attribute name="headerShowSortIndicator" stdset="0">
- <bool>true</bool>
- </attribute>
- <column>
- <property name="text">
- <string>Variable</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Value</string>
- </property>
- </column>
+ <widget class="QWidget" name="parametersTab">
+ <attribute name="title">
+ <string>Parameters</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QTreeWidget" name="stateTreeWidget">
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="sortingEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>Variable</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="shadersTab">
+ <attribute name="title">
+ <string>Shaders</string>
+ </attribute>
+ </widget>
+ <widget class="QWidget" name="surfacesTab">
+ <attribute name="title">
+ <string>Surfaces</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <item>
+ <widget class="QTreeWidget" name="surfacesTreeWidget">
+ <column>
+ <property name="text">
+ <string>Type</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Size</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ShadersSourceWidget</class>
+ <widget class="QWidget" name="ShadersSourceWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="shadersLabel">
+ <property name="text">
+ <string>Select a shader:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="shadersCB"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPlainTextEdit" name="shadersTextEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>