Avoid creating a layer for linear stretch

Bug: 187718492
Test: manual logging no layer updates during benchmark
Change-Id: I9a231625142e404882be6c53fa6d01b2fb81af1a
diff --git a/libs/hwui/effects/StretchEffect.h b/libs/hwui/effects/StretchEffect.h
index c49d53a..3b3067d 100644
--- a/libs/hwui/effects/StretchEffect.h
+++ b/libs/hwui/effects/StretchEffect.h
@@ -16,6 +16,7 @@
 
 #pragma once
 
+#include "Properties.h"
 #include "utils/MathUtils.h"
 
 #include <SkImage.h>
@@ -108,6 +109,11 @@
         return matrix;
     }
 
+    bool requiresLayer() const {
+        return !(isEmpty() ||
+                 Properties::stretchEffectBehavior == StretchEffectBehavior::LinearScale);
+    }
+
 private:
     static sk_sp<SkRuntimeEffect> getStretchEffect();
     mutable SkVector mStretchDirection{0, 0};