[sf] Pass metadata to layer during composition
Adds the simple bits of code to grab a snapshot of the front-end Layer
generic metadata, storing a copy in LayerFECompositionState, and then
sending int to the HWC2::Layer along with other "geometry update"
settings.
As the metadata stored in the layers uses integer keys, they need to be
translated to name strings. For hard-coded mapping is defined, with a
TODO left to remove the hard-coded mapping.
A test is added to ensure that the metadata is written by OutputLayer
when present, and that it is not set as part of a "per-frame" update.
Bug: 139747351
Test: atest libcompositionengine_test
Change-Id: I63f2a34e1fb70e1aefc5aa7e97ce56b7c2579a29
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index b538d75..3aa7956 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -406,6 +406,14 @@
ALOGE("[%s] Failed to set info %s (%d)", getLayerFE().getDebugName(),
to_string(error).c_str(), static_cast<int32_t>(error));
}
+
+ for (const auto& [name, entry] : outputIndependentState.metadata) {
+ if (auto error = hwcLayer->setLayerGenericMetadata(name, entry.mandatory, entry.value);
+ error != HWC2::Error::None) {
+ ALOGE("[%s] Failed to set generic metadata %s %s (%d)", getLayerFE().getDebugName(),
+ name.c_str(), to_string(error).c_str(), static_cast<int32_t>(error));
+ }
+ }
}
void OutputLayer::writeOutputDependentPerFrameStateToHWC(HWC2::Layer* hwcLayer) {
@@ -661,4 +669,3 @@
} // namespace impl
} // namespace android::compositionengine
-