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

Commit f5638339 authored by Stan Iliev's avatar Stan Iliev
Browse files

Optimize Outline::setRoundRect

Reuse Outline internal memory if the new shape has the same
memory requirement as the previous outline.

Bug: 69849202
Test: Ran APCT, setOutline_mean decreased from ~1400 to ~1000
Change-Id: Ie0185d22122c3c17cb001316ff5a19a833f18f05
parent 1f272d89
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -42,8 +42,15 @@ public:
        mBounds.set(left, top, right, bottom);
        mRadius = radius;

        // update mPath to reflect new outline

        // Reuse memory if previous outline was the same shape (rect or round rect).
        if ( mPath.countVerbs() > 10) {
            mPath.reset();
        } else {
            mPath.rewind();
        }

        // update mPath to reflect new outline
        if (MathUtils::isPositive(radius)) {
            mPath.addRoundRect(SkRect::MakeLTRB(left, top, right, bottom), radius, radius);
        } else {