]> git.cworth.org Git - apitrace/commitdiff
Show the currently bound fbos in the gui.
authorZack Rusin <zack@kde.org>
Sun, 10 Apr 2011 23:51:44 +0000 (19:51 -0400)
committerZack Rusin <zack@kde.org>
Sun, 10 Apr 2011 23:51:44 +0000 (19:51 -0400)
that's very, very cool :)

gui/apisurface.cpp
gui/apisurface.h
gui/apitracecall.cpp
gui/apitracecall.h
gui/mainwindow.cpp

index 32ebff2853452144fc5ade36ce5373a20e33afe3..8c985ae282a0b2321484705c8c054bdfa40ef5f6 100644 (file)
@@ -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;
+}
index 50dd5d0ce68c771a3d035cb9ea44f4471fb2ed6e..9cf2a96c34aa813697c9477beda893992586d6e4 100644 (file)
@@ -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
index 7fabc9cf0389d0eef1059b785560f5134dbbce65..4664102e48eb1d22de154ff7de437f8185a49d2c 100644 (file)
@@ -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<ApiTexture> ApiTraceState::textures() const
     return m_textures;
 }
 
+QList<ApiFramebuffer> ApiTraceState::framebuffers() const
+{
+    return m_framebuffers;
+}
+
 
index dd69b0e4c9f2fbf7db7c0f37fecfb891fe890864..975c3f6bfc9e51f21cd2cdcafec71ecc701d87f8 100644 (file)
@@ -112,11 +112,13 @@ public:
     QVariantMap parameters() const;
     QStringList shaderSources() const;
     QList<ApiTexture> textures() const;
+    QList<ApiFramebuffer> framebuffers() const;
 
 private:
     QVariantMap m_parameters;
     QStringList m_shaderSources;
     QList<ApiTexture> m_textures;
+    QList<ApiFramebuffer> m_framebuffers;
 };
 Q_DECLARE_METATYPE(ApiTraceState);
 
index 4fc1362879d325a7c0b2166b8b48deea1ee796c2..ff9f05ca10116a799f647c9b675dac281d48edbb 100644 (file)
@@ -321,32 +321,59 @@ void MainWindow::fillStateForFrame()
 
     const QList<ApiTexture> &textures =
         state.textures();
+    const QList<ApiFramebuffer> &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);
     }