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/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp
index 94fe243..cf3ef40b 100644
--- a/libs/hwui/DamageAccumulator.cpp
+++ b/libs/hwui/DamageAccumulator.cpp
@@ -272,18 +272,21 @@
DamageAccumulator::StretchResult DamageAccumulator::findNearestStretchEffect() const {
DirtyStack* frame = mHead;
+ const auto& headProperties = mHead->renderNode->properties();
+ float startWidth = headProperties.getWidth();
+ float startHeight = headProperties.getHeight();
while (frame->prev != frame) {
if (frame->type == TransformRenderNode) {
const auto& renderNode = frame->renderNode;
const auto& frameRenderNodeProperties = renderNode->properties();
const auto& effect =
frameRenderNodeProperties.layerProperties().getStretchEffect();
- const float width = (float) renderNode->getWidth();
- const float height = (float) renderNode->getHeight();
+ const float width = (float) frameRenderNodeProperties.getWidth();
+ const float height = (float) frameRenderNodeProperties.getHeight();
if (!effect.isEmpty()) {
Matrix4 stretchMatrix;
computeTransformImpl(mHead, frame, &stretchMatrix);
- Rect stretchRect = Rect(0.f, 0.f, width, height);
+ Rect stretchRect = Rect(0.f, 0.f, startWidth, startHeight);
stretchMatrix.mapRect(stretchRect);
return StretchResult{