Send dimming ratio to composer instead of white point nits

* Send the dimming ratio over to composer as the HWC api is changing to
  not expose the notion of nits to composer, as the white point nits are
  part of logical SF state that does not map as nicely to display
  hardware
* Fixes an issue where scheduling a recomposite for a frame when
  brightness changes is contingent on the presence of HDR layers, which
  is not valid when an HDR layer exits the scene, but DisplayManager
  animates the display brightness down to the SDR white point.

Bug: 217961164
Test: builds, boots
Test: HDR test videos on youtube
Change-Id: Icc07b00f60859bbd3ee078cd2bb793eda42e7781
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index f99a2a3..df8f6e6 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1733,11 +1733,15 @@
                    // If we support applying display brightness as a command, then we also support
                    // dimming SDR layers.
                    if (supportsDisplayBrightnessCommand) {
-                       display->getCompositionDisplay()
-                               ->setDisplayBrightness(brightness.sdrWhitePointNits,
-                                                      brightness.displayBrightnessNits);
+                       auto compositionDisplay = display->getCompositionDisplay();
+                       float currentDimmingRatio =
+                               compositionDisplay->editState().sdrWhitePointNits /
+                               compositionDisplay->editState().displayBrightnessNits;
+                       compositionDisplay->setDisplayBrightness(brightness.sdrWhitePointNits,
+                                                                brightness.displayBrightnessNits);
                        MAIN_THREAD_GUARD(display->stageBrightness(brightness.displayBrightness));
-                       if (hasVisibleHdrLayer(display)) {
+                       if (brightness.sdrWhitePointNits / brightness.displayBrightnessNits !=
+                           currentDimmingRatio) {
                            scheduleComposite(FrameHint::kNone);
                        } else {
                            scheduleCommit(FrameHint::kNone);