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

Commit 3cef465d authored by Sally Qi's avatar Sally Qi Committed by Android (Google) Code Review
Browse files

Merge "Optimize the way of calling setDisplayBrightness."

parents 6e7899d3 0ea47b50
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));