Add some more scenes, replace linear with uniform

Test: this
Bug: 187718492
Change-Id: I171b5c15cd18645c2da1cffffa9635f83f8877e6
diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp
index a164233..0adc0f6 100644
--- a/libs/hwui/DamageAccumulator.cpp
+++ b/libs/hwui/DamageAccumulator.cpp
@@ -157,7 +157,7 @@
 static inline void mapRect(const RenderProperties& props, const SkRect& in, SkRect* out) {
     if (in.isEmpty()) return;
     SkRect temp(in);
-    if (Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
+    if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
         const StretchEffect& stretch = props.layerProperties().getStretchEffect();
         if (!stretch.isEmpty()) {
             applyMatrix(stretch.makeLinearStretch(props.getWidth(), props.getHeight()), &temp);
diff --git a/libs/hwui/Properties.cpp b/libs/hwui/Properties.cpp
index 9ed801b..a4614a9 100644
--- a/libs/hwui/Properties.cpp
+++ b/libs/hwui/Properties.cpp
@@ -138,7 +138,7 @@
     if (targetCpuTimePercentage <= 0 || targetCpuTimePercentage > 100) targetCpuTimePercentage = 70;
 
     int stretchType = base::GetIntProperty(PROPERTY_STRETCH_EFFECT_TYPE, 0);
-    stretchType = std::clamp(stretchType, 0, static_cast<int>(StretchEffectBehavior::LinearScale));
+    stretchType = std::clamp(stretchType, 0, static_cast<int>(StretchEffectBehavior::UniformScale));
     stretchEffectBehavior = static_cast<StretchEffectBehavior>(stretchType);
 
     return (prevDebugLayersUpdates != debugLayersUpdates) || (prevDebugOverdraw != debugOverdraw);
diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h
index 9d2b617..9964254 100644
--- a/libs/hwui/Properties.h
+++ b/libs/hwui/Properties.h
@@ -200,9 +200,9 @@
 enum class RenderPipelineType { SkiaGL, SkiaVulkan, NotInitialized = 128 };
 
 enum class StretchEffectBehavior {
-    ShaderHWUI, // Stretch shader in HWUI only, matrix scale in SF
-    Shader, // Stretch shader in both HWUI and SF
-    LinearScale // Linear stretch everywhere
+    ShaderHWUI,   // Stretch shader in HWUI only, matrix scale in SF
+    Shader,       // Stretch shader in both HWUI and SF
+    UniformScale  // Uniform scale stretch everywhere
 };
 
 /**
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 64abd94..ad2cd8c 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -478,7 +478,7 @@
         }
     }
 
-    if (Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
+    if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
         const StretchEffect& stretch = properties().layerProperties().getStretchEffect();
         if (!stretch.isEmpty()) {
             matrix.multiply(
diff --git a/libs/hwui/effects/StretchEffect.h b/libs/hwui/effects/StretchEffect.h
index 3b3067d..0e1a654 100644
--- a/libs/hwui/effects/StretchEffect.h
+++ b/libs/hwui/effects/StretchEffect.h
@@ -111,7 +111,7 @@
 
     bool requiresLayer() const {
         return !(isEmpty() ||
-                 Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale);
+                 Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale);
     }
 
 private:
diff --git a/libs/hwui/jni/android_graphics_RenderNode.cpp b/libs/hwui/jni/android_graphics_RenderNode.cpp
index cd0783f..a096ed0 100644
--- a/libs/hwui/jni/android_graphics_RenderNode.cpp
+++ b/libs/hwui/jni/android_graphics_RenderNode.cpp
@@ -573,8 +573,8 @@
             const RenderProperties& props = node.properties();
 
             uirenderer::Rect bounds(props.getWidth(), props.getHeight());
-            bool useStretchShader = Properties::stretchEffectBehavior !=
-                StretchEffectBehavior::LinearScale;
+            bool useStretchShader =
+                    Properties::stretchEffectBehavior != StretchEffectBehavior::UniformScale;
             if (useStretchShader && info.stretchEffectCount) {
                 handleStretchEffect(info, bounds);
             }
diff --git a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
index 0b43f09..1c5515c7d 100644
--- a/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
+++ b/libs/hwui/pipeline/skia/RenderNodeDrawable.cpp
@@ -248,7 +248,7 @@
 
             const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
             if (stretch.isEmpty() ||
-                Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
+                Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
                 // If we don't have any stretch effects, issue the filtered
                 // canvas draw calls to make sure we still punch a hole
                 // with the same canvas transformation + clip into the target
@@ -327,7 +327,7 @@
             canvas->concat(*properties.getTransformMatrix());
         }
     }
-    if (Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale) {
+    if (Properties::stretchEffectBehavior == StretchEffectBehavior::UniformScale) {
         const StretchEffect& stretch = properties.layerProperties().getStretchEffect();
         if (!stretch.isEmpty()) {
             canvas->concat(
diff --git a/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp b/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp
index 964b8bf..c451112 100644
--- a/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp
+++ b/libs/hwui/tests/common/scenes/StretchyListViewAnimation.cpp
@@ -22,8 +22,10 @@
 
 class StretchyListViewAnimation;
 class StretchyListViewHolePunch;
-class StretchyLinearListView;
-class StretchyLinearListViewHolePunch;
+class StretchyUniformListView;
+class StretchyUniformListViewHolePunch;
+class StretchyUniformLayerListView;
+class StretchyUniformLayerListViewHolePunch;
 
 static TestScene::Registrar _StretchyListViewAnimation(TestScene::Info{
         "stretchylistview",
@@ -36,21 +38,34 @@
         "A mock ListView of scrolling content that's stretching. Includes a hole punch",
         TestScene::simpleCreateScene<StretchyListViewHolePunch>});
 
-static TestScene::Registrar _StretchyLinearListView(TestScene::Info{
-        "stretchylistview_linear",
-        "A mock ListView of scrolling content that's stretching using a linear stretch effect.",
-        TestScene::simpleCreateScene<StretchyLinearListView>});
+static TestScene::Registrar _StretchyUniformListView(TestScene::Info{
+        "stretchylistview_uniform",
+        "A mock ListView of scrolling content that's stretching using a uniform stretch effect.",
+        TestScene::simpleCreateScene<StretchyUniformListView>});
 
-static TestScene::Registrar _StretchyLinearListViewHolePunch(TestScene::Info{
-        "stretchylistview_linear_holepunch",
-        "A mock ListView of scrolling content that's stretching using a linear stretch effect. "
+static TestScene::Registrar _StretchyUniformListViewHolePunch(TestScene::Info{
+        "stretchylistview_uniform_holepunch",
+        "A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
         "Includes a hole punch",
-        TestScene::simpleCreateScene<StretchyLinearListViewHolePunch>});
+        TestScene::simpleCreateScene<StretchyUniformListViewHolePunch>});
+
+static TestScene::Registrar _StretchyUniformLayerListView(TestScene::Info{
+        "stretchylistview_uniform_layer",
+        "A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
+        "Uses a layer",
+        TestScene::simpleCreateScene<StretchyUniformLayerListView>});
+
+static TestScene::Registrar _StretchyUniformLayerListViewHolePunch(TestScene::Info{
+        "stretchylistview_uniform_layer_holepunch",
+        "A mock ListView of scrolling content that's stretching using a uniform stretch effect. "
+        "Uses a layer & includes a hole punch",
+        TestScene::simpleCreateScene<StretchyUniformLayerListViewHolePunch>});
 
 class StretchyListViewAnimation : public TestScene {
 protected:
     virtual StretchEffectBehavior stretchBehavior() { return StretchEffectBehavior::Shader; }
     virtual bool haveHolePunch() { return false; }
+    virtual bool forceLayer() { return false; }
 
 private:
     int mItemHeight;
@@ -172,6 +187,10 @@
     void doFrame(int frameNr) override {
         if (frameNr == 0) {
             Properties::stretchEffectBehavior = stretchBehavior();
+            if (forceLayer()) {
+                mListView->mutateStagingProperties().mutateLayerProperties().setType(
+                        LayerType::RenderLayer);
+            }
         }
         auto& props = mListView->mutateStagingProperties();
         auto& stretch = props.mutateLayerProperties().mutableStretchEffect();
@@ -190,11 +209,22 @@
     bool haveHolePunch() override { return true; }
 };
 
-class StretchyLinearListView : public StretchyListViewAnimation {
-    StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::LinearScale; }
+class StretchyUniformListView : public StretchyListViewAnimation {
+    StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
 };
 
-class StretchyLinearListViewHolePunch : public StretchyListViewAnimation {
-    StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::LinearScale; }
+class StretchyUniformListViewHolePunch : public StretchyListViewAnimation {
+    StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
     bool haveHolePunch() override { return true; }
+};
+
+class StretchyUniformLayerListView : public StretchyListViewAnimation {
+    StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
+    bool forceLayer() override { return true; }
+};
+
+class StretchyUniformLayerListViewHolePunch : public StretchyListViewAnimation {
+    StretchEffectBehavior stretchBehavior() override { return StretchEffectBehavior::UniformScale; }
+    bool haveHolePunch() override { return true; }
+    bool forceLayer() override { return true; }
 };
\ No newline at end of file