From: Zack Rusin Date: Sun, 10 Apr 2011 23:51:44 +0000 (-0400) Subject: Show the currently bound fbos in the gui. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=a68464141d0ad5a833d5661a52b06950db6c61a5;p=apitrace Show the currently bound fbos in the gui. that's very, very cool :) --- diff --git a/gui/apisurface.cpp b/gui/apisurface.cpp index 32ebff2..8c985ae 100644 --- a/gui/apisurface.cpp +++ b/gui/apisurface.cpp @@ -114,3 +114,18 @@ void ApiTexture::setLevel(int l) { m_level = l; } + +ApiFramebuffer::ApiFramebuffer() + : ApiSurface() +{ +} + +QString ApiFramebuffer::type() const +{ + return m_type; +} + +void ApiFramebuffer::setType(const QString &str) +{ + m_type = str; +} diff --git a/gui/apisurface.h b/gui/apisurface.h index 50dd5d0..9cf2a96 100644 --- a/gui/apisurface.h +++ b/gui/apisurface.h @@ -45,4 +45,17 @@ private: QString m_target; }; +class ApiFramebuffer : public ApiSurface +{ +public: + ApiFramebuffer(); + + QString type() const; + void setType(const QString &str); + +private: + QString m_type; + +}; + #endif diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp index 7fabc9c..4664102 100644 --- a/gui/apitracecall.cpp +++ b/gui/apitracecall.cpp @@ -481,6 +481,32 @@ ApiTraceState::ApiTraceState(const QVariantMap &parsedJson) } } } + + QVariantMap fbos = + parsedJson[QLatin1String("framebuffer")].toMap(); + QVariantMap::const_iterator itr; + for (itr = fbos.constBegin(); itr != fbos.constEnd(); ++itr) { + QVariantMap buffer = itr.value().toMap(); + QSize size(buffer[QLatin1String("__width__")].toInt(), + buffer[QLatin1String("__height__")].toInt()); + QString cls = buffer[QLatin1String("__class__")].toString(); + QString type = buffer[QLatin1String("__type__")].toString(); + bool normalized = buffer[QLatin1String("__normalized__")].toBool(); + int numChannels = buffer[QLatin1String("__channels__")].toInt(); + + Q_ASSERT(numChannels == 4); + Q_ASSERT(type == QLatin1String("uint8")); + Q_ASSERT(normalized == true); + + QByteArray dataArray = + buffer[QLatin1String("__data__")].toByteArray(); + + ApiFramebuffer fbo; + fbo.setSize(size); + fbo.setType(itr.key()); + fbo.contentsFromBase64(dataArray); + m_framebuffers.append(fbo); + } } QVariantMap ApiTraceState::parameters() const @@ -503,4 +529,9 @@ QList ApiTraceState::textures() const return m_textures; } +QList ApiTraceState::framebuffers() const +{ + return m_framebuffers; +} + diff --git a/gui/apitracecall.h b/gui/apitracecall.h index dd69b0e..975c3f6 100644 --- a/gui/apitracecall.h +++ b/gui/apitracecall.h @@ -112,11 +112,13 @@ public: QVariantMap parameters() const; QStringList shaderSources() const; QList textures() const; + QList framebuffers() const; private: QVariantMap m_parameters; QStringList m_shaderSources; QList m_textures; + QList m_framebuffers; }; Q_DECLARE_METATYPE(ApiTraceState); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 4fc1362..ff9f05c 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -321,32 +321,59 @@ void MainWindow::fillStateForFrame() const QList &textures = state.textures(); + const QList &fbos = + state.framebuffers(); m_ui.surfacesTreeWidget->clear(); - if (textures.isEmpty()) { + if (textures.isEmpty() && fbos.isEmpty()) { m_ui.surfacesTab->setDisabled(false); } else { - QTreeWidgetItem *textureItem = - new QTreeWidgetItem(m_ui.surfacesTreeWidget); m_ui.surfacesTreeWidget->setIconSize(QSize(64, 64)); - textureItem->setText(0, tr("Textures")); - for (int i = 0; i < textures.count(); ++i) { - const ApiTexture &texture = - textures[i]; - QIcon icon(QPixmap::fromImage(texture.thumb())); - QTreeWidgetItem *item = new QTreeWidgetItem(textureItem); - item->setIcon(0, icon); - int width = texture.size().width(); - int height = texture.size().height(); - QString descr = - QString::fromLatin1("%1, %2 x %3") - .arg(texture.target()) - .arg(width) - .arg(height); - item->setText(1, descr); - - item->setData(0, Qt::UserRole, - texture.image()); + if (!textures.isEmpty()) { + QTreeWidgetItem *textureItem = + new QTreeWidgetItem(m_ui.surfacesTreeWidget); + textureItem->setText(0, tr("Textures")); + for (int i = 0; i < textures.count(); ++i) { + const ApiTexture &texture = + textures[i]; + QIcon icon(QPixmap::fromImage(texture.thumb())); + QTreeWidgetItem *item = new QTreeWidgetItem(textureItem); + item->setIcon(0, icon); + int width = texture.size().width(); + int height = texture.size().height(); + QString descr = + QString::fromLatin1("%1, %2 x %3") + .arg(texture.target()) + .arg(width) + .arg(height); + item->setText(1, descr); + + item->setData(0, Qt::UserRole, + texture.image()); + } + } + if (!fbos.isEmpty()) { + QTreeWidgetItem *fboItem = + new QTreeWidgetItem(m_ui.surfacesTreeWidget); + fboItem->setText(0, tr("Framebuffers")); + for (int i = 0; i < fbos.count(); ++i) { + const ApiFramebuffer &fbo = + fbos[i]; + QIcon icon(QPixmap::fromImage(fbo.thumb())); + QTreeWidgetItem *item = new QTreeWidgetItem(fboItem); + item->setIcon(0, icon); + int width = fbo.size().width(); + int height = fbo.size().height(); + QString descr = + QString::fromLatin1("%1, %2 x %3") + .arg(fbo.type()) + .arg(width) + .arg(height); + item->setText(1, descr); + + item->setData(0, Qt::UserRole, + fbo.image()); + } } m_ui.surfacesTab->setEnabled(true); }