Updated HWUI to calculate the stretch bounds for a surface
Added logic to StretchEffect to be able to calculate the
stretched position of a pixel on an input texture based
on the current stretch parameters.
Updated shader to leverage linear easing instead of
cubic in order to have a reversible method that
can be used to map input textures to the corresponding
stretch position.
Bug: 179047472
Test: manual
Change-Id: Id32afcf0df1cca03e68ac0c594d307a1090264f2
diff --git a/libs/hwui/effects/StretchEffect.h b/libs/hwui/effects/StretchEffect.h
index 61537f0..6d517ac 100644
--- a/libs/hwui/effects/StretchEffect.h
+++ b/libs/hwui/effects/StretchEffect.h
@@ -75,6 +75,22 @@
maxStretchAmountY = std::max(maxStretchAmountY, other.maxStretchAmountY);
}
+ /**
+ * Return the stretched x position given the normalized x position with
+ * the current horizontal stretch direction
+ * @param normalizedX x position on the input texture from 0 to 1
+ * @return x position when the horizontal stretch direction applied
+ */
+ float computeStretchedPositionX(float normalizedX) const;
+
+ /**
+ * Return the stretched y position given the normalized y position with
+ * the current horizontal stretch direction
+ * @param normalizedX y position on the input texture from 0 to 1
+ * @return y position when the horizontal stretch direction applied
+ */
+ float computeStretchedPositionY(float normalizedY) const;
+
sk_sp<SkShader> getShader(float width, float height,
const sk_sp<SkImage>& snapshotImage) const;