]> git.cworth.org Git - apitrace/blobdiff - gui/retracer.cpp
image: Support reading PFM images.
[apitrace] / gui / retracer.cpp
index 2de9d23ee849de85f12c6cbf51461750ba7edf68..b42446bdd6af2ca064f3b522466dc3b778105cc2 100644 (file)
@@ -130,6 +130,7 @@ Retracer::Retracer(QObject *parent)
     : QThread(parent),
       m_benchmarking(false),
       m_doubleBuffered(true),
+      m_singlethread(false),
       m_captureState(false),
       m_captureCall(0),
       m_profileGpu(false),
@@ -184,6 +185,16 @@ void Retracer::setDoubleBuffered(bool db)
     m_doubleBuffered = db;
 }
 
+bool Retracer::isSinglethread() const
+{
+    return m_singlethread;
+}
+
+void Retracer::setSinglethread(bool singlethread)
+{
+    m_singlethread = singlethread;
+}
+
 bool Retracer::isProfilingGpu() const
 {
     return m_profileGpu;
@@ -281,6 +292,10 @@ void Retracer::run()
         return;
     }
 
+    if (m_singlethread) {
+        arguments << QLatin1String("--singlethread");
+    }
+
     if (m_captureState) {
         arguments << QLatin1String("-D");
         arguments << QString::number(m_captureCall);
@@ -380,9 +395,7 @@ void Retracer::run()
              */
 
             while (!io.atEnd()) {
-                unsigned channels = 0;
-                unsigned width = 0;
-                unsigned height = 0;
+                image::PNMInfo info;
 
                 char header[512];
                 qint64 headerSize = 0;
@@ -399,14 +412,19 @@ void Retracer::run()
                     headerSize += headerRead;
                 }
 
-                const char *headerEnd = image::readPNMHeader(header, headerSize, &channels, &width, &height);
+                const char *headerEnd = image::readPNMHeader(header, headerSize, info);
 
                 // if invalid PNM header was encountered, ...
-                if (header == headerEnd) {
+                if (headerEnd == NULL ||
+                    info.channelType != image::TYPE_UNORM8) {
                     qDebug() << "error: invalid snapshot stream encountered";
                     break;
                 }
 
+                unsigned channels = info.channels;
+                unsigned width = info.width;
+                unsigned height = info.height;
+
                 // qDebug() << "channels: " << channels << ", width: " << width << ", height: " << height";
 
                 QImage snapshot = QImage(width, height, channels == 1 ? QImage::Format_Mono : QImage::Format_RGB888);