diff options
| -rw-r--r-- | libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl | 6 | ||||
| -rw-r--r-- | services/surfaceflinger/HdrLayerInfoReporter.cpp | 3 | ||||
| -rw-r--r-- | services/surfaceflinger/HdrLayerInfoReporter.h | 17 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 7 |
4 files changed, 16 insertions, 17 deletions
diff --git a/libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl b/libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl index fc809c4c88..e8c36ee001 100644 --- a/libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl +++ b/libs/gui/aidl/android/gui/IHdrLayerInfoListener.aidl @@ -19,7 +19,9 @@ package android.gui; /** @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 c88554ee52..9eefbe463d 100644 --- a/services/surfaceflinger/HdrLayerInfoReporter.cpp +++ b/services/surfaceflinger/HdrLayerInfoReporter.cpp @@ -40,7 +40,8 @@ void HdrLayerInfoReporter::dispatchHdrLayerInfo(const HdrLayerInfo& info) { 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 9b70c164de..bf7c7753d2 100644 --- a/services/surfaceflinger/HdrLayerInfoReporter.h +++ b/services/surfaceflinger/HdrLayerInfoReporter.h @@ -43,27 +43,18 @@ public: // 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 e902a3dadf..63b7f75c84 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2890,7 +2890,12 @@ void SurfaceFlinger::postComposition(nsecs_t callTime) { 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(); |