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

Commit 0ea47b50 authored by Sally Qi's avatar Sally Qi
Browse files

Optimize the way of calling setDisplayBrightness.

 - Only call it when display brightness difference ratio is over than
   threshold.

Bug: 267262025
Test: play with Youtube HDR video
Change-Id: I24cf0f01db342711d6b2a160b384c006c44fdad4
parent f0049a04
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -1830,8 +1830,21 @@ status_t SurfaceFlinger::setDisplayBrightness(const sp<IBinder>& displayToken,
                       float currentDimmingRatio =
                               compositionDisplay->editState().sdrWhitePointNits /
                               compositionDisplay->editState().displayBrightnessNits;
                       compositionDisplay->setDisplayBrightness(brightness.sdrWhitePointNits,
                       static constexpr float kDimmingThreshold = 0.02f;
                       if (brightness.sdrWhitePointNits == 0.f ||
                           abs(brightness.sdrWhitePointNits - brightness.displayBrightnessNits) /
                                           brightness.sdrWhitePointNits >=
                                   kDimmingThreshold) {
                           // to optimize, skip brightness setter if the brightness difference ratio
                           // is lower than threshold
                           compositionDisplay
                                   ->setDisplayBrightness(brightness.sdrWhitePointNits,
                                                          brightness.displayBrightnessNits);
                       } else {
                           compositionDisplay->setDisplayBrightness(brightness.sdrWhitePointNits,
                                                                    brightness.sdrWhitePointNits);
                       }

                       FTL_FAKE_GUARD(kMainThreadContext,
                                      display->stageBrightness(brightness.displayBrightness));