Add support for restricting HDR headroom for video
This is needed for allowing apps to vote for HDR headroom restrictions
for SurfaceView and SurfaceControl
Bug: 323964760
Test: manually poking at test app
Test: SurfaceViewTests
Test: SurfaceControlTest
Test: ASurfaceControlTest
Change-Id: Ie886e67879525462d49fdedc535aea659d69321a
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7626fe7..1a40bc2 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3119,6 +3119,7 @@
for (auto& [compositionDisplay, listener] : hdrInfoListeners) {
HdrLayerInfoReporter::HdrLayerInfo info;
int32_t maxArea = 0;
+
auto updateInfoFn =
[&](const std::shared_ptr<compositionengine::Display>& compositionDisplay,
const frontend::LayerSnapshot& snapshot, const sp<LayerFE>& layerFe) {
@@ -3129,7 +3130,7 @@
compositionDisplay->getOutputLayerForLayer(layerFe);
if (outputLayer) {
const float desiredHdrSdrRatio =
- snapshot.desiredHdrSdrRatio <= 1.f
+ snapshot.desiredHdrSdrRatio < 1.f
? std::numeric_limits<float>::infinity()
: snapshot.desiredHdrSdrRatio;
info.mergeDesiredRatio(desiredHdrSdrRatio);
@@ -5415,6 +5416,11 @@
flags |= eTraversalNeeded;
}
}
+ if (what & layer_state_t::eDesiredHdrHeadroomChanged) {
+ if (layer->setDesiredHdrHeadroom(s.desiredHdrSdrRatio)) {
+ flags |= eTraversalNeeded;
+ }
+ }
if (what & layer_state_t::eCachingHintChanged) {
if (layer->setCachingHint(s.cachingHint)) {
flags |= eTraversalNeeded;
@@ -5600,6 +5606,11 @@
flags |= eTraversalNeeded;
}
}
+ if (what & layer_state_t::eDesiredHdrHeadroomChanged) {
+ if (layer->setDesiredHdrHeadroom(s.desiredHdrSdrRatio)) {
+ flags |= eTraversalNeeded;
+ }
+ }
if (what & layer_state_t::eBufferChanged) {
std::optional<ui::Transform::RotationFlags> transformHint = std::nullopt;
frontend::LayerSnapshot* snapshot = mLayerSnapshotBuilder.getSnapshot(layer->sequence);