[SurfaceFlinger] Plumb getPerFrameMetadataKeys and setLayerPerFrameMetadata.

This patch compresses supported metdata types into a bitmask and stores it in
DisplayDevice and refactors the code in Hwc2::Layer regarding HdrMetadata. When
DisplayDevice is created, the ability of accepting metadata will be queried
from hardware composer and stored in DisplayDevice. Hwc2::Layer will construct
HdrMetadata to PerFrameMetadata when setPerFrameHdrMetadata is called if the
incoming meta data is changed.

Previously, setLayerPerFrameMetadata was named as setLayerHdrMetadata, but
since we move the responsibility of constructing PerFrameMetadata from
ComposerHal to Hwc2::Layer, we change the name to setLayerPerFrameMetadata,
which is more generic and matches the HIDL interface.

BUG: 77831156
Test: Build and flash
Change-Id: I447956f4dcf42c90ceb3d29091cd5034ad91061a
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index cd0bed6..df5d945 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -23,17 +23,16 @@
 
 #include <math/mat4.h>
 
-#include <ui/Region.h>
-
 #include <binder/IBinder.h>
+#include <gui/ISurfaceComposer.h>
+#include <hardware/hwcomposer_defs.h>
+#include <ui/GraphicTypes.h>
+#include <ui/Region.h>
 #include <utils/RefBase.h>
 #include <utils/Mutex.h>
 #include <utils/String8.h>
 #include <utils/Timers.h>
 
-#include <gui/ISurfaceComposer.h>
-#include <hardware/hwcomposer_defs.h>
-#include <ui/GraphicTypes.h>
 #include "RenderArea.h"
 #include "RenderEngine/Surface.h"
 
@@ -86,6 +85,7 @@
             int displayHeight,
             bool hasWideColorGamut,
             const HdrCapabilities& hdrCapabilities,
+            const int32_t supportedPerFrameMetadata,
             int initialPowerMode);
     // clang-format on
 
@@ -131,6 +131,8 @@
     int32_t                 getHwcDisplayId() const { return mHwcDisplayId; }
     const wp<IBinder>&      getDisplayToken() const { return mDisplayToken; }
 
+    int32_t getSupportedPerFrameMetadata() const { return mSupportedPerFrameMetadata; }
+
     // We pass in mustRecompose so we can keep VirtualDisplaySurface's state
     // machine happy without actually queueing a buffer if nothing has changed
     status_t beginFrame(bool mustRecompose) const;
@@ -259,6 +261,8 @@
     bool mHasHdr10;
     bool mHasHLG;
     bool mHasDolbyVision;
+
+    const int32_t mSupportedPerFrameMetadata;
 };
 
 struct DisplayDeviceState {