diff options
author | Ady Abraham <adyabr@google.com> | 2022-08-11 16:27:34 -0700 |
---|---|---|
committer | Vishnu Nair <vishnun@google.com> | 2023-04-11 20:17:08 +0000 |
commit | 2b1856e8c4177ffc8b8ffb357da56409b4c3e187 (patch) | |
tree | 731b2eb0f12c9e12a2dba3f4102f567117174c5d | |
parent | f4bd36b72dfde8d67cf62d43d56b8ff27e15e2cc (diff) | |
download | native-2b1856e8c4177ffc8b8ffb357da56409b4c3e187.tar.gz |
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 24d0b2a19705cc64933bb6dfaf7147207a64e607)
-rw-r--r-- | libs/gui/SurfaceComposerClient.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 70013396d6..05beb07891 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -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; |