]> git.cworth.org Git - apitrace/commitdiff
Use normalized ubytes for now.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 10 Apr 2011 18:25:01 +0000 (19:25 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 10 Apr 2011 18:25:01 +0000 (19:25 +0100)
glretrace doesn't have the logic to choose the most appropriate data type,
nor does qapitrace have the logic to cope with multiple data types or
HDR data, so make it easier on everybody by choose the common denominator.

glstate.py
gui/apisurface.cpp
gui/apitracecall.cpp

index 7c17a3530db8c03dc49ed7f9e74282ab86b129e9..64696715a03d4704c2ec179f3cc0aab2be8ac309 100644 (file)
@@ -3065,12 +3065,13 @@ writeTextureImage(JSONWriter &json, GLenum target, GLint level)
 
         // Hardcoded for now, but we could chose types more adequate to the
         // texture internal format
-        json.writeStringMember("__type__", "float");
+        json.writeStringMember("__type__", "uint8");
+        json.writeBoolMember("__normalized__", true);
         json.writeNumberMember("__channels__", 4);
         
-        float *pixels = new float[depth*width*height*4];
+        GLubyte *pixels = new GLubyte[depth*width*height*4];
         
-        glGetTexImage(target, level, GL_RGBA, GL_FLOAT, pixels);
+        glGetTexImage(target, level, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
 
         json.writeStringMember("__encoding__", "base64");
         json.beginMember("__data__");
@@ -3102,10 +3103,11 @@ writeDrawBufferImage(JSONWriter &json)
 
         // Hardcoded for now, but we could chose types more adequate to the
         // texture internal format
-        json.writeStringMember("__type__", "float");
+        json.writeStringMember("__type__", "uint8");
+        json.writeBoolMember("__normalized__", true);
         json.writeNumberMember("__channels__", 4);
         
-        float *pixels = new float[width*height*4];
+        GLubyte *pixels = new GLubyte[width*height*4];
         
         GLint drawbuffer = glretrace::double_buffer ? GL_BACK : GL_FRONT;
         GLint readbuffer = glretrace::double_buffer ? GL_BACK : GL_FRONT;
index 105532e9a2c07cc9dfc5b07fca644a828382a211..32ebff2853452144fc5ade36ce5373a20e33afe3 100644 (file)
@@ -17,6 +17,12 @@ void ApiSurface::setSize(const QSize &size)
     m_size = size;
 }
 
+static inline int
+rgba8_to_argb(quint8 r, quint8 g, quint8 b, quint8 a)
+{
+    return (a << 24 | r << 16 | g << 8 | b);
+}
+
 static inline int
 rgbaf2argb(float r, float g, float b, float a)
 {
@@ -31,7 +37,7 @@ rgbaf2argb(float r, float g, float b, float a)
 void ApiSurface::contentsFromBase64(const QByteArray &base64)
 {
     QByteArray dataArray = QByteArray::fromBase64(base64);
-    const float *data = (const float*)dataArray.data();
+    const quint8 *data = (const quint8*)dataArray.data();
     int width = m_size.width();
     int height = m_size.height();
 
@@ -45,10 +51,10 @@ void ApiSurface::contentsFromBase64(const QByteArray &base64)
 
     for (int y = 0; y < height; ++y) {
         for (int x = 0; x < width; ++x) {
-            int pixel = rgbaf2argb(data[(y * width + x) * 4 + 0],
-                                   data[(y * width + x) * 4 + 1],
-                                   data[(y * width + x) * 4 + 2],
-                                   data[(y * width + x) * 4 + 3]);
+            int pixel = rgba8_to_argb(data[(y * width + x) * 4 + 0],
+                                      data[(y * width + x) * 4 + 1],
+                                      data[(y * width + x) * 4 + 2],
+                                      data[(y * width + x) * 4 + 3]);
             pixelData[y * width + x] = pixel;
         }
     }
index 351b2a98ddd7232e9da0a42b9be8ceff9d837faa..7fabc9cf0389d0eef1059b785560f5134dbbce65 100644 (file)
@@ -457,11 +457,14 @@ ApiTraceState::ApiTraceState(const QVariantMap &parsedJson)
                                image[QLatin1String("__height__")].toInt());
                     QString cls = image[QLatin1String("__class__")].toString();
                     QString type = image[QLatin1String("__type__")].toString();
+                    bool normalized =
+                        image[QLatin1String("__normalized__")].toBool();
                     int numChannels =
                         image[QLatin1String("__channels__")].toInt();
 
                     Q_ASSERT(numChannels == 4);
-                    Q_ASSERT(type == QLatin1String("float"));
+                    Q_ASSERT(type == QLatin1String("uint8"));
+                    Q_ASSERT(normalized == true);
 
                     QByteArray dataArray =
                         image[QLatin1String("__data__")].toByteArray();