diff options
| author | 2021-05-13 19:08:04 -0700 | |
|---|---|---|
| committer | 2021-05-13 19:08:04 -0700 | |
| commit | 91a55b613d572497a660fb3303a6326d1844cd02 (patch) | |
| tree | 3149947d941d0fcd0e9d84373e0575bc18d24c04 | |
| parent | 5ac4488fecbccb9779b51798d4f3c9c0c7e06fb3 (diff) | |
Improve Stretch shader performance
Refactor stretch shader to return within
conditional blocks instead of falling
through to main function body.
Improves performance on coral by approximately 60%
~600 fps to ~1k fps on non-surfaceview case
~300 fps to 500 fps on surfaceview case
Bug: 187718492
Test: manual
Change-Id: Ida0d0dee9c94b0ac210a024708100283fecc2a5c
| -rw-r--r-- | libs/hwui/effects/StretchEffect.cpp | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/libs/hwui/effects/StretchEffect.cpp b/libs/hwui/effects/StretchEffect.cpp index 0599bfaf02f5..df480afcbe80 100644 --- a/libs/hwui/effects/StretchEffect.cpp +++ b/libs/hwui/effects/StretchEffect.cpp @@ -115,38 +115,37 @@ static const SkString stretchShader = SkString(R"( float distanceDiff, float interpolationStrength ) { - float outPos = inPos; if (overscroll > 0) { - if (inPos <= uStretchAffectedDist) { - outPos = computeOverscrollStart( - inPos, - overscroll, - uStretchAffectedDist, - uInverseStretchAffectedDist, - distanceStretched, - interpolationStrength - ); - } else if (inPos >= distanceStretched) { - outPos = distanceDiff + inPos; - } + if (inPos <= uStretchAffectedDist) { + return computeOverscrollStart( + inPos, + overscroll, + uStretchAffectedDist, + uInverseStretchAffectedDist, + distanceStretched, + interpolationStrength + ); + } else { + return distanceDiff + inPos; } - if (overscroll < 0) { - float stretchAffectedDist = 1. - uStretchAffectedDist; - if (inPos >= stretchAffectedDist) { - outPos = computeOverscrollEnd( - inPos, - overscroll, - stretchAffectedDist, - uStretchAffectedDist, - uInverseStretchAffectedDist, - distanceStretched, - interpolationStrength - ); - } else if (inPos < stretchAffectedDist) { - outPos = -distanceDiff + inPos; - } + } else if (overscroll < 0) { + float stretchAffectedDist = 1. - uStretchAffectedDist; + if (inPos >= stretchAffectedDist) { + return computeOverscrollEnd( + inPos, + overscroll, + stretchAffectedDist, + uStretchAffectedDist, + uInverseStretchAffectedDist, + distanceStretched, + interpolationStrength + ); + } else { + return -distanceDiff + inPos; } - return outPos; + } else { + return inPos; + } } vec4 main(vec2 coord) { @@ -155,12 +154,9 @@ static const SkString stretchShader = SkString(R"( float inV = coord.y / viewportHeight; float outU; float outV; - float stretchIntensity; // Add the normalized scroll position within scrolling list inU += uScrollX; inV += uScrollY; - outU = inU; - outV = inV; outU = computeOverscroll( inU, uOverscrollX, |