test-hwc2: add client target support

Test: Add "#define HAVE_NO_SURFACE_FLINGER" to
      frameworks/native/libs/gui/BufferQueueCore.cpp.
      Recompile and flash.
      Run "mm" in frameworks/native/services/surfaceflinger/tests/hwc2.
      Push test-hwc2 to device.
      Run "adb root && adb shell stop".
      Run test case. Ex: "./test-hwc2"

Change-Id: I94c86795b2e334df0570c6c5a3cbbcb5a8ca2826
diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestLayers.h b/services/surfaceflinger/tests/hwc2/Hwc2TestLayers.h
index b4c3558..a8579ee 100644
--- a/services/surfaceflinger/tests/hwc2/Hwc2TestLayers.h
+++ b/services/surfaceflinger/tests/hwc2/Hwc2TestLayers.h
@@ -40,12 +40,21 @@
     bool advance();
     bool advanceVisibleRegions();
 
+    /* Test cases with multiple layers and property values can take quite some
+     * time to run. A significant amount of time can be spent on test cases
+     * where one layer is changing property values but is not visible. To
+     * decrease runtime, this function can be called. Removes layouts where a
+     * layer is completely blocked from view. It also removes layouts that do
+     * not cover the entire display.*/
+    bool optimizeLayouts();
+
     bool contains(hwc2_layer_t layer) const;
 
     int  getBuffer(hwc2_layer_t layer, buffer_handle_t* outHandle,
             int32_t* outAcquireFence);
 
     hwc2_blend_mode_t      getBlendMode(hwc2_layer_t layer) const;
+    Area                   getBufferArea(hwc2_layer_t layer) const;
     hwc_color_t            getColor(hwc2_layer_t layer) const;
     hwc2_composition_t     getComposition(hwc2_layer_t layer) const;
     hwc_rect_t             getCursorPosition(hwc2_layer_t layer) const;
@@ -60,11 +69,13 @@
     uint32_t               getZOrder(hwc2_layer_t layer) const;
 
 private:
-    void setVisibleRegions();
+    bool setVisibleRegions();
 
     std::map<hwc2_layer_t, Hwc2TestLayer> mTestLayers;
 
     Area mDisplayArea;
+
+    bool mOptimize = false;
 };
 
 #endif /* ifndef _HWC2_TEST_LAYERS_H */