]> git.cworth.org Git - apitrace/blobdiff - cli/cli_dump_images.cpp
qapitrace: Adjust PATH only once and for all.
[apitrace] / cli / cli_dump_images.cpp
index d42b3f784a3894bb26653a6c7d04281707920a64..0e2dd8c8b6cfaf6919253a0ffdc8b841fad1dd5e 100644 (file)
 #include <getopt.h>
 #include <iostream>
 
-#include "cli.hpp"
-
 #include "os_string.hpp"
-#include "os_process.hpp"
+
+#include "cli.hpp"
+#include "cli_retrace.hpp"
 
 static const char *synopsis = "Dump frame images obtained from a trace.";
 
@@ -72,7 +72,9 @@ static int
 command(int argc, char *argv[])
 {
     os::String prefix;
-    const char *calls, *filename, *output = NULL;
+    const char *calls = NULL;
+    const char *traceName = NULL;
+    const char *output = NULL;
 
     int opt;
     while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
@@ -105,36 +107,27 @@ command(int argc, char *argv[])
         return 1;
     }
 
-    filename = argv[optind];
+    traceName = argv[optind];
 
     if (output == NULL) {
-        prefix = filename;
+        prefix = traceName;
         prefix.trimDirectory();
         prefix.trimExtension();
+        prefix.append('.');
         output = prefix.str();
     }
 
-    /* FIXME: It would be cleaner to pull the replaying of the trace
-     * in-process here and generate the images directly. But that
-     * pulls in a non-trivial amount of the existing 'retrace' code,
-     * along with dependencies on GL, etc.
-     *
-     * It will definitely make sense to do that once all that code has
-     * already been pulled in for the "apitrace retrace" (or "apitrace
-     * replay") command. */
-    std::vector<const char *> command;
-    command.push_back("glretrace");
-    command.push_back("-s");
-    command.push_back(output);
-    command.push_back("-S");
+    std::vector<const char *> opts;
+
+    opts.push_back("-s");
+    opts.push_back(output);
+    opts.push_back("-S");
     if (calls)
-        command.push_back(calls);
+        opts.push_back(calls);
     else
-        command.push_back("*/frame");
-    command.push_back(filename);
-    command.push_back(NULL);
+        opts.push_back("*/frame");
 
-    return os::execute((char * const *)&command[0]);
+    return executeRetrace(opts, traceName);
 }
 
 const Command dump_images_command = {