]> git.cworth.org Git - apitrace/commitdiff
Encode format as a member and not part of the label.
authorZack Rusin <zack@kde.org>
Thu, 17 Nov 2011 21:00:41 +0000 (16:00 -0500)
committerZack Rusin <zack@kde.org>
Thu, 17 Nov 2011 21:01:18 +0000 (16:01 -0500)
glstate.cpp
gui/apisurface.cpp
gui/apisurface.h
gui/apitracecall.cpp
gui/mainwindow.cpp

index 0dff118b87dc5558d6f64480a1e0ec9bd2528c90..665f887f20d317edd6ef45ca76b482e67975d66e 100644 (file)
@@ -591,8 +591,8 @@ dumpTextureImage(JSONWriter &json, GLenum target, GLint level)
 
         GLint active_texture = GL_TEXTURE0;
         glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
-        snprintf(label, sizeof label, "%s, %s, %s, %d level",
-                 enumToString(active_texture), enumToString(target), enumToString(format), level);
+        snprintf(label, sizeof label, "%s, %s, level = %d",
+                 enumToString(active_texture), enumToString(target), level);
 
         json.beginMember(label);
 
@@ -605,6 +605,8 @@ dumpTextureImage(JSONWriter &json, GLenum target, GLint level)
         json.writeNumberMember("__height__", height);
         json.writeNumberMember("__depth__", depth);
 
+        json.writeStringMember("__format__", enumToString(format));
+
         // Hardcoded for now, but we could chose types more adequate to the
         // texture internal format
         json.writeStringMember("__type__", "uint8");
@@ -1009,7 +1011,8 @@ getDrawBufferImage(GLenum format) {
  * Dump the image of the currently bound read buffer.
  */
 static inline void
-dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format)
+dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format,
+                    GLint internalFormat = GL_NONE)
 {
     GLint channels = __gl_format_channels(format);
 
@@ -1022,6 +1025,8 @@ dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format)
     json.writeNumberMember("__height__", height);
     json.writeNumberMember("__depth__", 1);
 
+    json.writeStringMember("__format__", enumToString(internalFormat));
+
     // Hardcoded for now, but we could chose types more adequate to the
     // texture internal format
     json.writeStringMember("__type__", "uint8");
@@ -1223,15 +1228,9 @@ dumpFramebufferAttachment(JSONWriter &json, GLenum target, GLenum attachment, GL
     }
 
     GLint internalFormat = getFramebufferAttachmentFormat(target, attachment);
-    std::stringstream ss;
-    ss << enumToString(attachment);
-    if (internalFormat != GL_NONE) {
-        ss << ", ";
-        ss << enumToString(internalFormat);
-    }
 
-    json.beginMember(ss.str());
-    dumpReadBufferImage(json, width, height, format);
+    json.beginMember(enumToString(attachment));
+    dumpReadBufferImage(json, width, height, format, internalFormat);
     json.endMember();
 }
 
index b8e820bc82f16f333aed5639fa0e59e93207f0f8..7bf3c8fe5f20c8531d27a4a4feacbfc320c5ad6c 100644 (file)
@@ -44,7 +44,6 @@ QImage ApiSurface::thumb() const
     return m_thumb;
 }
 
-
 int ApiSurface::depth() const
 {
     return m_depth;
@@ -55,6 +54,17 @@ void ApiSurface::setDepth(int depth)
     m_depth = depth;
 }
 
+QString ApiSurface::formatName() const
+{
+    return m_formatName;
+}
+
+void ApiSurface::setFormatName(const QString &str)
+{
+    m_formatName = str;
+}
+
+
 ApiTexture::ApiTexture()
     : ApiSurface()
 {
index 9c7115ec2b4696844157be6ec757585758d82013..bc403af27409c103deeeb431710a67238f6481f1 100644 (file)
@@ -19,6 +19,9 @@ public:
     int depth() const;
     void setDepth(int depth);
 
+    QString formatName() const;
+    void setFormatName(const QString &str);
+
     void contentsFromBase64(const QByteArray &base64);
 
     QImage image() const;
@@ -30,6 +33,7 @@ private:
     QImage m_image;
     QImage m_thumb;
     int m_depth;
+    QString m_formatName;
 };
 
 
index 356ef9c668d81e3c9a71d6ba516777a8dfb5ddc5..c8c2245effe5e1562d40f3ca64b407944cf7a063 100644 (file)
@@ -460,6 +460,8 @@ ApiTraceState::ApiTraceState(const QVariantMap &parsedJson)
             image[QLatin1String("__channels__")].toInt();
         int depth =
             image[QLatin1String("__depth__")].toInt();
+        QString formatName =
+            image[QLatin1String("__format__")].toString();
 
         Q_ASSERT(type == QLatin1String("uint8"));
         Q_ASSERT(normalized == true);
@@ -471,6 +473,7 @@ ApiTraceState::ApiTraceState(const QVariantMap &parsedJson)
         ApiTexture tex;
         tex.setSize(size);
         tex.setDepth(depth);
+        tex.setFormatName(formatName);
         tex.setNumChannels(numChannels);
         tex.setLabel(itr.key());
         tex.contentsFromBase64(dataArray);
@@ -489,6 +492,7 @@ ApiTraceState::ApiTraceState(const QVariantMap &parsedJson)
         bool normalized = buffer[QLatin1String("__normalized__")].toBool();
         int numChannels = buffer[QLatin1String("__channels__")].toInt();
         int depth = buffer[QLatin1String("__depth__")].toInt();
+        QString formatName = buffer[QLatin1String("__format__")].toString();
 
         Q_ASSERT(type == QLatin1String("uint8"));
         Q_ASSERT(normalized == true);
@@ -500,6 +504,7 @@ ApiTraceState::ApiTraceState(const QVariantMap &parsedJson)
         ApiFramebuffer fbo;
         fbo.setSize(size);
         fbo.setDepth(depth);
+        fbo.setFormatName(formatName);
         fbo.setNumChannels(numChannels);
         fbo.setType(itr.key());
         fbo.contentsFromBase64(dataArray);
index 13ff529f9a01fb51f0de5635fd7b3fc78798b00f..6e3e8a3c064a9425a071737fb19a5cbd86de3a1c 100644 (file)
@@ -462,8 +462,9 @@ static void addSurfaceItem(const ApiSurface &surface,
     int width = surface.size().width();
     int height = surface.size().height();
     QString descr =
-        QString::fromLatin1("%1, %2 x %3")
+        QString::fromLatin1("%1, %2, %3 x %4")
         .arg(label)
+        .arg(surface.formatName())
         .arg(width)
         .arg(height);