diff options
author | Chris Kuiper <ckuiper@google.com> | 2022-02-01 17:56:07 -0800 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-24 02:43:31 +0000 |
commit | 46ddcce6644b5209e0c1fb5342554ca7e507f707 (patch) | |
tree | c112be4ce3cbe2293a69780905ce07843b796a57 | |
parent | 682f01c6a92053a622bfb9acd3e78bf4690d3427 (diff) | |
download | base-46ddcce6644b5209e0c1fb5342554ca7e507f707.tar.gz |
[RESTRICT AUTOMERGE]DisplayManager: Make sure RampAnimator sets property in linear space.
This fixes the case where RampAnimator is used the first time and
immediately jumps to the target brightness. In that case the property
was set to a value that has not been converted back into linear
space, causing an incorrect initial brightness value.
To avoid these bugs, consolidate setting of the property into one
function.
Bug: 217289549
Test: Cannot reproduce bug.
Change-Id: I2ccdaa51ddba062fc5de1209470b90eb429280db
(cherry picked from commit 47461bb5aef25af6cdb6234e93c3daa99c166f6d)
Merged-In:I2ccdaa51ddba062fc5de1209470b90eb429280db
-rw-r--r-- | services/core/java/com/android/server/display/RampAnimator.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/display/RampAnimator.java b/services/core/java/com/android/server/display/RampAnimator.java index 1ebd1f5a535c..d8672fc07619 100644 --- a/services/core/java/com/android/server/display/RampAnimator.java +++ b/services/core/java/com/android/server/display/RampAnimator.java @@ -70,7 +70,7 @@ class RampAnimator<T> { mRate = 0; mTargetValue = target; mCurrentValue = target; - mProperty.setValue(mObject, target); + setPropertyValue(target); if (mAnimating) { mAnimating = false; cancelAnimationCallback(); @@ -125,6 +125,15 @@ class RampAnimator<T> { mListener = listener; } + /** + * Sets the brightness property by converting the given value from HLG space + * into linear space. + */ + private void setPropertyValue(float val) { + final float linearVal = BrightnessUtils.convertGammaToLinear(val); + mProperty.setValue(mObject, linearVal); + } + private void postAnimationCallback() { mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, mAnimationCallback, null); } @@ -160,9 +169,7 @@ class RampAnimator<T> { final float oldCurrentValue = mCurrentValue; mCurrentValue = mAnimatedValue; if (oldCurrentValue != mCurrentValue) { - // Convert value from HLG into linear space for the property. - final float linearCurrentVal = BrightnessUtils.convertGammaToLinear(mCurrentValue); - mProperty.setValue(mObject, linearCurrentVal); + setPropertyValue(mCurrentValue); } if (mTargetValue != mCurrentValue) { postAnimationCallback(); |