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/Hwc2TestBuffer.h b/services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.h
index 721540f..ca60940 100644
--- a/services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.h
+++ b/services/surfaceflinger/tests/hwc2/Hwc2TestBuffer.h
@@ -18,6 +18,8 @@
 #define _HWC2_TEST_BUFFER_H
 
 #include <android-base/unique_fd.h>
+#include <set>
+
 #include <hardware/hwcomposer2.h>
 
 #include <gui/GraphicBufferAlloc.h>
@@ -26,6 +28,7 @@
 #include "Hwc2TestProperties.h"
 
 class Hwc2TestFenceGenerator;
+class Hwc2TestLayers;
 
 class Hwc2TestBuffer {
 public:
@@ -39,10 +42,6 @@
 protected:
     int generateBuffer();
 
-    void setColor(int32_t x, int32_t y, android_pixel_format_t format,
-            uint32_t stride, uint8_t* img, uint8_t r, uint8_t g, uint8_t b,
-            uint8_t a);
-
     android::GraphicBufferAlloc mGraphicBufferAlloc;
     android::sp<android::GraphicBuffer> mGraphicBuffer;
 
@@ -55,4 +54,24 @@
     buffer_handle_t mHandle = nullptr;
 };
 
+
+class Hwc2TestClientTargetBuffer {
+public:
+    Hwc2TestClientTargetBuffer();
+    ~Hwc2TestClientTargetBuffer();
+
+    int  get(buffer_handle_t* outHandle, int32_t* outFence,
+            const Area& bufferArea, const Hwc2TestLayers* testLayers,
+            const std::set<hwc2_layer_t>* clientLayers,
+            const std::set<hwc2_layer_t>* clearLayers);
+
+protected:
+    android::GraphicBufferAlloc mGraphicBufferAlloc;
+    android::sp<android::GraphicBuffer> mGraphicBuffer;
+
+    std::unique_ptr<Hwc2TestFenceGenerator> mFenceGenerator;
+
+    const android_pixel_format_t mFormat = HAL_PIXEL_FORMAT_RGBA_8888;
+};
+
 #endif /* ifndef _HWC2_TEST_BUFFER_H */