Add support for render-ahead

For periods of time during which latency is less important
allow a client to request a deeper render-ahead pipeline.

The latency tradeoff results in less overall visual jank

Test: none, only used by macrobench

Change-Id: I516203b70bdc75b6415fa08bf9c4fb1b598b0102
diff --git a/libs/hwui/tests/macrobench/main.cpp b/libs/hwui/tests/macrobench/main.cpp
index 0a9a74e..4cb5cfd 100644
--- a/libs/hwui/tests/macrobench/main.cpp
+++ b/libs/hwui/tests/macrobench/main.cpp
@@ -68,6 +68,7 @@
                        are offscreen rendered
   --benchmark_format   Set output format. Possible values are tabular, json, csv
   --renderer=TYPE      Sets the render pipeline to use. May be opengl, skiagl, or skiavk
+  --render-ahead=NUM   Sets how far to render-ahead. Must be 0 (default), 1, or 2.
 )");
 }
 
@@ -173,6 +174,7 @@
     Onscreen,
     Offscreen,
     Renderer,
+    RenderAhead,
 };
 }
 
@@ -188,6 +190,7 @@
         {"onscreen", no_argument, nullptr, LongOpts::Onscreen},
         {"offscreen", no_argument, nullptr, LongOpts::Offscreen},
         {"renderer", required_argument, nullptr, LongOpts::Renderer},
+        {"render-ahead", required_argument, nullptr, LongOpts::RenderAhead},
         {0, 0, 0, 0}};
 
 static const char* SHORT_OPTIONS = "c:r:h";
@@ -286,6 +289,16 @@
                 gOpts.renderOffscreen = true;
                 break;
 
+            case LongOpts::RenderAhead:
+                if (!optarg) {
+                    error = true;
+                }
+                gOpts.renderAhead = atoi(optarg);
+                if (gOpts.renderAhead < 0 || gOpts.renderAhead > 2) {
+                    error = true;
+                }
+                break;
+
             case 'h':
                 printHelp();
                 exit(EXIT_SUCCESS);