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
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user