Pass the max desired hdr/sdr ratio to DisplayManager
SurfaceFlinger already computes this, but DisplayManager needs to use
this for apps that don't want as large of a ratio than the system
supports.
Bug: 267350616
Test: SilkFX test app
Change-Id: I03b6b458e220a9fdc30eb137a7455101d5a8f51a
diff --git a/libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl b/libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl
index fc809c4..e8c36ee 100644
--- a/libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl
+++ b/libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl
@@ -19,7 +19,9 @@
/** @hide */
oneway interface IHdrLayerInfoListener {
// Callback with the total number of HDR layers, the dimensions of the largest layer,
- // and a placeholder flags
+ // a placeholder flags, and the max desired HDR/SDR ratio. The max desired HDR/SDR
+ // ratio may be positive infinity to indicate an unbounded ratio.
// TODO (b/182312559): Define the flags (likely need an indicator that a UDFPS layer is present)
- void onHdrLayerInfoChanged(int numberOfHdrLayers, int maxW, int maxH, int flags);
+ void onHdrLayerInfoChanged(int numberOfHdrLayers, int maxW, int maxH,
+ int flags, float maxDesiredHdrSdrRatio);
}
\ No newline at end of file
diff --git a/services/surfaceflinger/HdrLayerInfoReporter.cpp b/services/surfaceflinger/HdrLayerInfoReporter.cpp
index c88554e..9eefbe4 100644
--- a/services/surfaceflinger/HdrLayerInfoReporter.cpp
+++ b/services/surfaceflinger/HdrLayerInfoReporter.cpp
@@ -40,7 +40,8 @@
for (const auto& listener : toInvoke) {
ATRACE_NAME("invoking onHdrLayerInfoChanged");
- listener->onHdrLayerInfoChanged(info.numberOfHdrLayers, info.maxW, info.maxH, info.flags);
+ listener->onHdrLayerInfoChanged(info.numberOfHdrLayers, info.maxW, info.maxH, info.flags,
+ info.maxDesiredHdrSdrRatio);
}
}
diff --git a/services/surfaceflinger/HdrLayerInfoReporter.h b/services/surfaceflinger/HdrLayerInfoReporter.h
index 9b70c16..bf7c775 100644
--- a/services/surfaceflinger/HdrLayerInfoReporter.h
+++ b/services/surfaceflinger/HdrLayerInfoReporter.h
@@ -43,27 +43,18 @@
// With peak display brightnesses exceeding 1,000 nits currently, HLG's request could
// actually be satisfied in some ambient conditions such that limiting that max for that
// content in theory makes sense
- float maxDesiredSdrHdrRatio = 0.f;
+ float maxDesiredHdrSdrRatio = 0.f;
bool operator==(const HdrLayerInfo& other) const {
return numberOfHdrLayers == other.numberOfHdrLayers && maxW == other.maxW &&
- maxH == other.maxH && flags == other.flags;
+ maxH == other.maxH && flags == other.flags &&
+ maxDesiredHdrSdrRatio == other.maxDesiredHdrSdrRatio;
}
bool operator!=(const HdrLayerInfo& other) const { return !(*this == other); }
void mergeDesiredRatio(float update) {
- if (maxDesiredSdrHdrRatio == 0.f) {
- // If nothing is set, take the incoming value
- maxDesiredSdrHdrRatio = update;
- } else if (update == 1.f) {
- // If the request is to "go to max", then take it regardless
- maxDesiredSdrHdrRatio = 1.f;
- } else if (maxDesiredSdrHdrRatio != 1.f) {
- // If we're not currently asked to "go to max", then take the max
- // of the incoming requests
- maxDesiredSdrHdrRatio = std::max(maxDesiredSdrHdrRatio, update);
- }
+ maxDesiredHdrSdrRatio = std::max(maxDesiredHdrSdrRatio, update);
}
};
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 5f95859..b67188b 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2800,7 +2800,12 @@
const auto* outputLayer =
compositionDisplay->getOutputLayerForLayer(layerFe);
if (outputLayer) {
- info.mergeDesiredRatio(snapshot.desiredSdrHdrRatio);
+ // TODO(b/267350616): Rename SdrHdrRatio -> HdrSdrRatio
+ // everywhere
+ const float desiredHdrSdrRatio = snapshot.desiredSdrHdrRatio <= 1.f
+ ? std::numeric_limits<float>::infinity()
+ : snapshot.desiredSdrHdrRatio;
+ info.mergeDesiredRatio(desiredHdrSdrRatio);
info.numberOfHdrLayers++;
const auto displayFrame = outputLayer->getState().displayFrame;
const int32_t area = displayFrame.width() * displayFrame.height();