From e181b99a776865a5aca43a64cf6afbaa371583ab Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 17 Nov 2011 16:00:41 -0500 Subject: [PATCH] Encode format as a member and not part of the label. --- glstate.cpp | 21 ++++++++++----------- gui/apisurface.cpp | 12 +++++++++++- gui/apisurface.h | 4 ++++ gui/apitracecall.cpp | 5 +++++ gui/mainwindow.cpp | 3 ++- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/glstate.cpp b/glstate.cpp index 0dff118..665f887 100644 --- a/glstate.cpp +++ b/glstate.cpp @@ -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(); } diff --git a/gui/apisurface.cpp b/gui/apisurface.cpp index b8e820b..7bf3c8f 100644 --- a/gui/apisurface.cpp +++ b/gui/apisurface.cpp @@ -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() { diff --git a/gui/apisurface.h b/gui/apisurface.h index 9c7115e..bc403af 100644 --- a/gui/apisurface.h +++ b/gui/apisurface.h @@ -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; }; diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp index 356ef9c..c8c2245 100644 --- a/gui/apitracecall.cpp +++ b/gui/apitracecall.cpp @@ -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); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 13ff529..6e3e8a3 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -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); -- 2.43.0