Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91a55b61 authored by Nader Jawad's avatar Nader Jawad
Browse files

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
parent 5ac4488f
Loading
Loading
Loading
Loading
+28 −32
Original line number Diff line number Diff line
@@ -115,10 +115,9 @@ static const SkString stretchShader = SkString(R"(
        float distanceDiff,
        float interpolationStrength
    ) {
      float outPos = inPos;
      if (overscroll > 0) {
        if (inPos <= uStretchAffectedDist) {
                outPos = computeOverscrollStart(
            return computeOverscrollStart(
              inPos,
              overscroll,
              uStretchAffectedDist,
@@ -126,14 +125,13 @@ static const SkString stretchShader = SkString(R"(
              distanceStretched,
              interpolationStrength
            );
            } else if (inPos >= distanceStretched) {
                outPos = distanceDiff + inPos;
        } else {
            return distanceDiff + inPos;
        }
        }
        if (overscroll < 0) {
      } else if (overscroll < 0) {
        float stretchAffectedDist = 1. - uStretchAffectedDist;
        if (inPos >= stretchAffectedDist) {
                outPos = computeOverscrollEnd(
            return computeOverscrollEnd(
              inPos,
              overscroll,
              stretchAffectedDist,
@@ -142,11 +140,12 @@ static const SkString stretchShader = SkString(R"(
              distanceStretched,
              interpolationStrength
            );
            } else if (inPos < stretchAffectedDist) {
                outPos = -distanceDiff + inPos;
        } else {
            return -distanceDiff + inPos;
        }
      } else {
        return inPos;
      }
        return outPos;
    }

    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,