Move hwuimacro to common native benchmark infrastructure

Change-Id: I2d2b358d205b1ed950ddc9caa57360b68001893b
diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk
index 95b28d3..eaea051 100644
--- a/libs/hwui/Android.mk
+++ b/libs/hwui/Android.mk
@@ -283,19 +283,15 @@
 include $(CLEAR_VARS)
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/local/tmp
-LOCAL_MODULE:= hwuitest
+LOCAL_MODULE:= hwuimacro
 LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE_CLASS := EXECUTABLES
 LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := hwuitest
-LOCAL_MODULE_STEM_64 := hwuitest64
 LOCAL_CFLAGS := $(hwui_cflags)
 LOCAL_C_INCLUDES := $(hwui_c_includes)
 
 # set to libhwui_static_debug to skip actual GL commands
 LOCAL_WHOLE_STATIC_LIBRARIES := libhwui_static
 LOCAL_SHARED_LIBRARIES := libmemunreachable
-LOCAL_STATIC_LIBRARIES := libgoogle-benchmark
 
 LOCAL_SRC_FILES += \
     $(hwui_test_common_src_files) \
@@ -303,7 +299,7 @@
     tests/macrobench/main.cpp
 
 include $(LOCAL_PATH)/hwui_static_deps.mk
-include $(BUILD_EXECUTABLE)
+include $(BUILD_NATIVE_BENCHMARK)
 
 # ------------------------
 # Micro-bench app
diff --git a/libs/hwui/tests/common/TestScene.h b/libs/hwui/tests/common/TestScene.h
index 4813ff0..daeb9ea 100644
--- a/libs/hwui/tests/common/TestScene.h
+++ b/libs/hwui/tests/common/TestScene.h
@@ -33,7 +33,7 @@
     struct Options {
         int count = 0;
         int reportFrametimeWeight = 0;
-        bool renderOffscreen = false;
+        bool renderOffscreen = true;
     };
 
     template <class T>
diff --git a/libs/hwui/tests/macrobench/how_to_run.txt b/libs/hwui/tests/macrobench/how_to_run.txt
index b051768f..3c3d36a 100644
--- a/libs/hwui/tests/macrobench/how_to_run.txt
+++ b/libs/hwui/tests/macrobench/how_to_run.txt
@@ -1,5 +1,5 @@
 mmm -j8 frameworks/base/libs/hwui/ &&
-    adb push $OUT/data/local/tmp/hwuitest /data/local/tmp/hwuitest &&
-    adb shell /data/local/tmp/hwuitest
+adb push $OUT/data/benchmarktest/hwuimacro/hwuimacro /data/benchmarktest/hwuimacro/hwuimacro &&
+adb shell /data/benchmarktest/hwuimacro/hwuimacro shadowgrid2 --onscreen
 
 Pass --help to get help
diff --git a/libs/hwui/tests/macrobench/main.cpp b/libs/hwui/tests/macrobench/main.cpp
index ffeef45..ebc1dd7 100644
--- a/libs/hwui/tests/macrobench/main.cpp
+++ b/libs/hwui/tests/macrobench/main.cpp
@@ -49,7 +49,7 @@
 
 static void printHelp() {
     printf(R"(
-USAGE: hwuitest [OPTIONS] <TESTNAME>
+USAGE: hwuimacro [OPTIONS] <TESTNAME>
 
 OPTIONS:
   -c, --count=NUM      NUM loops a test should run (example, number of frames)
@@ -63,6 +63,10 @@
                        moving average frametime. Weight is optional, default is 10
   --cpuset=name        Adds the test to the specified cpuset before running
                        Not supported on all devices and needs root
+  --offscreen          Render tests off device screen. This option is on by default
+  --onscreen           Render tests on device screen. By default tests
+                       are offscreen rendered
+  --benchmark_format   Set output format. Possible values are tabular, json, csv
 )");
 }
 
@@ -150,6 +154,7 @@
     ReportFrametime,
     CpuSet,
     BenchmarkFormat,
+    Onscreen,
     Offscreen,
 };
 }
@@ -163,6 +168,7 @@
     { "report-frametime", optional_argument, nullptr, LongOpts::ReportFrametime },
     { "cpuset", required_argument, nullptr, LongOpts::CpuSet },
     { "benchmark_format", required_argument, nullptr, LongOpts::BenchmarkFormat },
+    { "onscreen", no_argument, nullptr, LongOpts::Onscreen },
     { "offscreen", no_argument, nullptr, LongOpts::Offscreen },
     { 0, 0, 0, 0 }
 };
@@ -247,6 +253,10 @@
             }
             break;
 
+        case LongOpts::Onscreen:
+            gOpts.renderOffscreen = false;
+            break;
+
         case LongOpts::Offscreen:
             gOpts.renderOffscreen = true;
             break;
@@ -274,22 +284,18 @@
     if (optind < argc) {
         do {
             const char* test = argv[optind++];
-            if (!strcmp(test, "all")) {
-                for (auto& iter : TestScene::testMap()) {
-                    gRunTests.push_back(iter.second);
-                }
+            auto pos = TestScene::testMap().find(test);
+            if (pos == TestScene::testMap().end()) {
+                fprintf(stderr, "Unknown test '%s'\n", test);
+                exit(EXIT_FAILURE);
             } else {
-                auto pos = TestScene::testMap().find(test);
-                if (pos == TestScene::testMap().end()) {
-                    fprintf(stderr, "Unknown test '%s'\n", test);
-                    exit(EXIT_FAILURE);
-                } else {
-                    gRunTests.push_back(pos->second);
-                }
+                gRunTests.push_back(pos->second);
             }
         } while (optind < argc);
     } else {
-        gRunTests.push_back(TestScene::testMap()["shadowgrid"]);
+        for (auto& iter : TestScene::testMap()) {
+            gRunTests.push_back(iter.second);
+        }
     }
 }