#include "shaderssourcewidget.h"
#include "tracedialog.h"
#include "traceprocess.h"
+#include "trimprocess.h"
+#include "thumbnail.h"
#include "ui_retracerdialog.h"
#include "vertexdatainterpreter.h"
if (dialog.exec() == QDialog::Accepted) {
qDebug()<< "App : " <<dialog.applicationPath();
qDebug()<< " Arguments: "<<dialog.arguments();
+ m_traceProcess->setApi(dialog.api());
m_traceProcess->setExecutablePath(dialog.applicationPath());
m_traceProcess->setArguments(dialog.arguments());
m_traceProcess->start();
}
}
+void MainWindow::callItemActivated(const QModelIndex &index) {
+ lookupState();
+}
+
void MainWindow::replayStart()
{
if (m_trace->isSaving()) {
dlgUi.doubleBufferingCB->isChecked());
m_retracer->setBenchmarking(
!dlgUi.errorCheckCB->isChecked());
- replayTrace(false);
+ replayTrace(false, true);
}
}
m_ui.actionStop->setEnabled(false);
m_ui.actionReplay->setEnabled(true);
m_ui.actionLookupState->setEnabled(true);
+ m_ui.actionShowThumbnails->setEnabled(true);
}
void MainWindow::newTraceFile(const QString &fileName)
if (fileName.isEmpty()) {
m_ui.actionReplay->setEnabled(false);
m_ui.actionLookupState->setEnabled(false);
+ m_ui.actionShowThumbnails->setEnabled(false);
setWindowTitle(tr("QApiTrace"));
} else {
QFileInfo info(fileName);
m_ui.actionReplay->setEnabled(true);
m_ui.actionLookupState->setEnabled(true);
+ m_ui.actionShowThumbnails->setEnabled(true);
+ m_ui.actionTrim->setEnabled(true);
setWindowTitle(
tr("QApiTrace - %1").arg(info.fileName()));
}
}
-void MainWindow::replayFinished(const QString &output)
+void MainWindow::replayFinished(const QString &message)
{
m_ui.actionStop->setEnabled(false);
m_ui.actionReplay->setEnabled(true);
m_ui.actionLookupState->setEnabled(true);
+ m_ui.actionShowThumbnails->setEnabled(true);
m_progressBar->hide();
- if (output.length() < 80) {
- statusBar()->showMessage(output);
- }
+ statusBar()->showMessage(message, 2000);
m_stateEvent = 0;
m_ui.actionShowErrorsDock->setEnabled(m_trace->hasErrors());
m_ui.errorsDock->setVisible(m_trace->hasErrors());
if (!m_trace->hasErrors()) {
m_ui.errorsTreeWidget->clear();
}
-
- statusBar()->showMessage(
- tr("Replaying finished!"), 2000);
}
void MainWindow::replayError(const QString &message)
m_ui.actionStop->setEnabled(false);
m_ui.actionReplay->setEnabled(true);
m_ui.actionLookupState->setEnabled(true);
+ m_ui.actionShowThumbnails->setEnabled(true);
m_stateEvent = 0;
m_nonDefaultsLookupEvent = 0;
if (!m_trace) {
return;
}
+ m_api = m_trace->api();
QFileInfo info(m_trace->fileName());
statusBar()->showMessage(
tr("Loaded %1").arg(info.fileName()), 3000);
}
}
-void MainWindow::replayTrace(bool dumpState)
+void MainWindow::replayTrace(bool dumpState, bool dumpThumbnails)
{
if (m_trace->fileName().isEmpty()) {
return;
m_retracer->setFileName(m_trace->fileName());
m_retracer->setAPI(m_api);
m_retracer->setCaptureState(dumpState);
+ m_retracer->setCaptureThumbnails(dumpThumbnails);
if (m_retracer->captureState() && m_selectedEvent) {
int index = 0;
if (m_selectedEvent->type() == ApiTraceEvent::Call) {
m_ui.actionStop->setEnabled(true);
m_progressBar->show();
- if (dumpState) {
- statusBar()->showMessage(
- tr("Looking up the state..."));
+ if (dumpState || dumpThumbnails) {
+ if (dumpState && dumpThumbnails) {
+ statusBar()->showMessage(
+ tr("Looking up the state and capturing thumbnails..."));
+ } else if (dumpState) {
+ statusBar()->showMessage(
+ tr("Looking up the state..."));
+ } else if (dumpThumbnails) {
+ statusBar()->showMessage(
+ tr("Capturing thumbnails..."));
+ }
} else {
statusBar()->showMessage(
tr("Replaying the trace file..."));
}
}
+void MainWindow::trimEvent()
+{
+
+ int trimIndex;
+ if (m_trimEvent->type() == ApiTraceEvent::Call) {
+ ApiTraceCall *call = static_cast<ApiTraceCall*>(m_trimEvent);
+ trimIndex = call->index();
+ } else if (m_trimEvent->type() == ApiTraceEvent::Frame) {
+ ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(m_trimEvent);
+ const QList<ApiTraceFrame*> frames = m_trace->frames();
+ trimIndex = frame->lastCallIndex();
+ }
+
+ m_trimProcess->setTracePath(m_trace->fileName());
+ m_trimProcess->setTrimIndex(trimIndex);
+
+ m_trimProcess->start();
+}
+
void MainWindow::lookupState()
{
if (!m_selectedEvent) {
return;
}
m_stateEvent = m_selectedEvent;
- replayTrace(true);
+ replayTrace(true, false);
+}
+
+void MainWindow::showThumbnails()
+{
+ replayTrace(false, true);
+}
+
+void MainWindow::trim()
+{
+ if (!m_selectedEvent) {
+ QMessageBox::warning(
+ this, tr("Unknown Event"),
+ tr("To trim select a frame or an event in the event list."));
+ return;
+ }
+ m_trimEvent = m_selectedEvent;
+ trimEvent();
}
MainWindow::~MainWindow()
if (textures.isEmpty() && fbos.isEmpty()) {
m_ui.surfacesTab->setDisabled(false);
} else {
- m_ui.surfacesTreeWidget->setIconSize(QSize(64, 64));
+ m_ui.surfacesTreeWidget->setIconSize(QSize(THUMBNAIL_SIZE, THUMBNAIL_SIZE));
if (!textures.isEmpty()) {
QTreeWidgetItem *textureItem =
new QTreeWidgetItem(m_ui.surfacesTreeWidget);
m_searchWidget->hide();
m_traceProcess = new TraceProcess(this);
+ m_trimProcess = new TrimProcess(this);
}
void MainWindow::initConnections()
this, SLOT(slotStartedSaving()));
connect(m_trace, SIGNAL(saved()),
this, SLOT(slotSaved()));
- connect(m_trace, SIGNAL(changed(ApiTraceCall*)),
- this, SLOT(slotTraceChanged(ApiTraceCall*)));
+ connect(m_trace, SIGNAL(changed(ApiTraceEvent*)),
+ this, SLOT(slotTraceChanged(ApiTraceEvent*)));
connect(m_trace, SIGNAL(findResult(ApiTrace::SearchRequest,ApiTrace::SearchResult,ApiTraceCall*)),
this, SLOT(slotSearchResult(ApiTrace::SearchRequest,ApiTrace::SearchResult,ApiTraceCall*)));
connect(m_trace, SIGNAL(foundFrameStart(ApiTraceFrame*)),
this, SLOT(replayError(const QString&)));
connect(m_retracer, SIGNAL(foundState(ApiTraceState*)),
this, SLOT(replayStateFound(ApiTraceState*)));
+ connect(m_retracer, SIGNAL(foundThumbnails(const QList<QImage>&)),
+ this, SLOT(replayThumbnailsFound(const QList<QImage>&)));
connect(m_retracer, SIGNAL(retraceErrors(const QList<ApiTraceError>&)),
this, SLOT(slotRetraceErrors(const QList<ApiTraceError>&)));
this, SLOT(replayStop()));
connect(m_ui.actionLookupState, SIGNAL(triggered()),
this, SLOT(lookupState()));
+ connect(m_ui.actionTrim, SIGNAL(triggered()),
+ this, SLOT(trim()));
+ connect(m_ui.actionShowThumbnails, SIGNAL(triggered()),
+ this, SLOT(showThumbnails()));
connect(m_ui.actionOptions, SIGNAL(triggered()),
this, SLOT(showSettings()));
connect(m_ui.callView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(callItemSelected(const QModelIndex &)));
+ connect(m_ui.callView, SIGNAL(doubleClicked(const QModelIndex &)),
+ this, SLOT(callItemActivated(const QModelIndex &)));
connect(m_ui.callView, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(customContextMenuRequested(QPoint)));
connect(m_traceProcess, SIGNAL(error(const QString&)),
SLOT(traceError(const QString&)));
+ connect(m_trimProcess, SIGNAL(trimmedFile(const QString&)),
+ SLOT(createdTrim(const QString&)));
+ connect(m_trimProcess, SIGNAL(error(const QString&)),
+ SLOT(trimError(const QString&)));
+
connect(m_ui.errorsDock, SIGNAL(visibilityChanged(bool)),
m_ui.actionShowErrorsDock, SLOT(setChecked(bool)));
connect(m_ui.actionShowErrorsDock, SIGNAL(triggered(bool)),
m_nonDefaultsLookupEvent = 0;
}
+void MainWindow::replayThumbnailsFound(const QList<QImage> &thumbnails)
+{
+ m_ui.callView->setUniformRowHeights(false);
+ m_trace->bindThumbnailsToFrames(thumbnails);
+}
+
void MainWindow::slotGoTo()
{
m_searchWidget->hide();
msg);
}
+void MainWindow::createdTrim(const QString &path)
+{
+ qDebug()<<"Done trimming "<<path;
+
+ newTraceFile(path);
+}
+
+void MainWindow::trimError(const QString &msg)
+{
+ QMessageBox::warning(
+ this,
+ tr("Trim Error"),
+ msg);
+}
+
void MainWindow::slotSearch()
{
m_jumpWidget->hide();
return NULL;
}
-void MainWindow::slotTraceChanged(ApiTraceCall *call)
+void MainWindow::slotTraceChanged(ApiTraceEvent *event)
{
- Q_ASSERT(call);
- if (call == m_selectedEvent) {
- m_ui.detailsWebView->setHtml(call->toHtml());
+ Q_ASSERT(event);
+ if (event == m_selectedEvent) {
+ if (event->type() == ApiTraceEvent::Call) {
+ ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
+ m_ui.detailsWebView->setHtml(call->toHtml());
+ }
}
}