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

Commit 2b1856e8 authored by Ady Abraham's avatar Ady Abraham Committed by Vishnu Nair
Browse files

SF: clamp alpha value instead of error

SF tests expect that invalid alpha values
will be clamped instead of returning failure.

Test: atest SurfaceFlinger_test:SurfaceFlinger_test
Bug: 274213741
Merged-In: I1318f21c21ec9b3fe9577ac3b9f32605e7f7f13a
Change-Id: I1318f21c21ec9b3fe9577ac3b9f32605e7f7f13a
(cherry picked from commit 24d0b2a1)
parent f4bd36b7
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -1275,13 +1275,10 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAlpha
        return *this;
    }
    if (alpha < 0.0f || alpha > 1.0f) {
        ALOGE("SurfaceComposerClient::Transaction::setAlpha: invalid alpha %f", alpha);
        mStatus = BAD_VALUE;
        return *this;

        ALOGE("SurfaceComposerClient::Transaction::setAlpha: invalid alpha %f, clamping", alpha);
    }
    s->what |= layer_state_t::eAlphaChanged;
    s->alpha = alpha;
    s->alpha = std::clamp(alpha, 0.f, 1.f);

    registerSurfaceControlForCallback(sc);
    return *this;