test-hwc2: set layer source crop

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: If3079efd7a035d1d182f04c56dc55300cdcedc47
diff --git a/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.h b/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.h
index 25c6ad8..9df532e 100644
--- a/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.h
+++ b/services/surfaceflinger/tests/hwc2/Hwc2TestProperties.h
@@ -74,9 +74,11 @@
     {
         if (mListIdx + 1 < mList.size()) {
             mListIdx++;
+            updateDependents();
             return true;
         }
         reset();
+        updateDependents();
         return false;
     }
 
@@ -86,11 +88,41 @@
     }
 
 protected:
+    /* If a derived class has dependents, override this function */
+    virtual void updateDependents() { }
+
     const std::vector<T>& mList;
     size_t mListIdx = 0;
 };
 
 
+class Hwc2TestSourceCrop;
+
+class Hwc2TestBufferArea : public Hwc2TestProperty<Area> {
+public:
+    Hwc2TestBufferArea(Hwc2TestCoverage coverage, const Area& displayArea);
+
+    std::string dump() const override;
+
+    void setDependent(Hwc2TestSourceCrop* sourceCrop);
+
+protected:
+    void update();
+    void updateDependents() override;
+
+    const std::vector<float>& mScalars;
+    static const std::vector<float> mDefaultScalars;
+    static const std::vector<float> mBasicScalars;
+    static const std::vector<float> mCompleteScalars;
+
+    Area mDisplayArea;
+
+    Hwc2TestSourceCrop* mSourceCrop = nullptr;
+
+    std::vector<Area> mBufferAreas;
+};
+
+
 class Hwc2TestBlendMode : public Hwc2TestProperty<hwc2_blend_mode_t> {
 public:
     Hwc2TestBlendMode(Hwc2TestCoverage coverage);
@@ -163,6 +195,28 @@
 };
 
 
+class Hwc2TestSourceCrop : public Hwc2TestProperty<hwc_frect_t> {
+public:
+    Hwc2TestSourceCrop(Hwc2TestCoverage coverage, const Area& bufferArea = {0, 0});
+
+    std::string dump() const override;
+
+    void updateBufferArea(const Area& bufferArea);
+
+protected:
+    void update();
+
+    const std::vector<hwc_frect_t>& mFrectScalars;
+    const static std::vector<hwc_frect_t> mDefaultFrectScalars;
+    const static std::vector<hwc_frect_t> mBasicFrectScalars;
+    const static std::vector<hwc_frect_t> mCompleteFrectScalars;
+
+    Area mBufferArea;
+
+    std::vector<hwc_frect_t> mSourceCrops;
+};
+
+
 class Hwc2TestTransform : public Hwc2TestProperty<hwc_transform_t> {
 public:
     Hwc2TestTransform(Hwc2TestCoverage coverage);