[sf] Add support for generic layer metadata to HWComposer and HWC2
HWComposer construction is slightly modified to make it easier to test.
Data is retrieved about the device on the call SurfaceFlinger makes
right after creaton (was registerCallbacks, now called
setConfiguration). This now includes obtaining the supported layer
metadata information from the HAL implementation.
Since getting capabilities is now no longer done by just construction,
the existing tests were adjusted to not expect the call, especially as
none of them were testing any variance in capabilities.
A HWC2::Layer::setLayerGenericMetadata function is also added to set
the metadata.
Tests are explicitly added for both retrieving the supported metadata
and for setting layer generic metadata.
Bug: 139747351
Test: atest libsurfaceflinger_unittest
Change-Id: I3e95be932d94d4e9f200b870acea965744c68d2c
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index effe43b..76e831b 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -55,11 +55,16 @@
class Output;
} // namespace compositionengine
+struct KnownHWCGenericLayerMetadata {
+ const char* name;
+ const uint32_t id;
+};
+
class HWComposer {
public:
virtual ~HWComposer();
- virtual void registerCallback(HWC2::ComposerCallback* callback, int32_t sequenceId) = 0;
+ virtual void setConfiguration(HWC2::ComposerCallback* callback, int32_t sequenceId) = 0;
virtual bool getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
DisplayIdentificationData* outData) const = 0;
@@ -194,6 +199,8 @@
virtual status_t getSupportedContentTypes(
DisplayId displayId, std::vector<HWC2::ContentType>* outSupportedContentTypes) = 0;
virtual status_t setContentType(DisplayId displayId, HWC2::ContentType contentType) = 0;
+ virtual const std::unordered_map<std::string, bool>& getSupportedLayerGenericMetadata()
+ const = 0;
// for debugging ----------------------------------------------------------
virtual void dump(std::string& out) const = 0;
@@ -217,7 +224,7 @@
~HWComposer() override;
- void registerCallback(HWC2::ComposerCallback* callback, int32_t sequenceId) override;
+ void setConfiguration(HWC2::ComposerCallback* callback, int32_t sequenceId) override;
bool getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
DisplayIdentificationData* outData) const override;
@@ -329,6 +336,8 @@
std::vector<HWC2::ContentType>*) override;
status_t setContentType(DisplayId displayId, HWC2::ContentType) override;
+ const std::unordered_map<std::string, bool>& getSupportedLayerGenericMetadata() const override;
+
// for debugging ----------------------------------------------------------
void dump(std::string& out) const override;
@@ -351,6 +360,7 @@
std::optional<DisplayIdentificationInfo> onHotplugConnect(hwc2_display_t hwcDisplayId);
void loadCapabilities();
+ void loadLayerMetadataSupport();
uint32_t getMaxVirtualDisplayCount() const;
struct DisplayData {
@@ -379,6 +389,7 @@
std::unique_ptr<android::Hwc2::Composer> mComposer;
std::unordered_set<HWC2::Capability> mCapabilities;
+ std::unordered_map<std::string, bool> mSupportedLayerGenericMetadata;
bool mRegisteredCallback = false;
std::unordered_map<hwc2_display_t, DisplayId> mPhysicalDisplayIdMap;