drm_hwcomposer: Remove HWC2 usage for Validate
Add HwcDisplay::ValidateStagedComposition to be called after
HwcDisplay::SetDisplayProperties to check whether any
layer composition types need to be updated.
Change-Id: I3a46e97b1c1721ac62de98fb89c73a1ffb0141fe
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 4068e71..9fbd6b9 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -368,6 +368,39 @@
return ConfigError::kNone;
}
+auto HwcDisplay::ValidateStagedComposition() -> std::vector<ChangedLayer> {
+ if (IsInHeadlessMode()) {
+ return {};
+ }
+
+ /* In current drm_hwc design in case previous frame layer was not validated as
+ * a CLIENT, it is used by display controller (Front buffer). We have to store
+ * this state to provide the CLIENT with the release fences for such buffers.
+ */
+ for (auto &l : layers_) {
+ l.second.SetPriorBufferScanOutFlag(l.second.GetValidatedType() !=
+ HWC2::Composition::Client);
+ }
+
+ // ValidateDisplay returns the number of layers that may be changed.
+ uint32_t num_types = 0;
+ uint32_t num_requests = 0;
+ backend_->ValidateDisplay(this, &num_types, &num_requests);
+
+ if (num_types == 0) {
+ return {};
+ }
+
+ // Iterate through the layers to find which layers actually changed.
+ std::vector<ChangedLayer> changed_layers;
+ for (auto &l : layers_) {
+ if (l.second.IsTypeChanged()) {
+ changed_layers.emplace_back(l.first, l.second.GetValidatedType());
+ }
+ }
+ return changed_layers;
+}
+
void HwcDisplay::SetPipeline(std::shared_ptr<DrmDisplayPipeline> pipeline) {
Deinit();
diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h
index 19b4caa..9c113fd 100644
--- a/hwc2_device/HwcDisplay.h
+++ b/hwc2_device/HwcDisplay.h
@@ -89,6 +89,12 @@
// Get the HwcDisplayConfig, or nullptor if none.
auto GetConfig(hwc2_config_t config_id) const -> const HwcDisplayConfig *;
+ // To be called after SetDisplayProperties. Returns an empty vector if the
+ // requested layers have been validated, otherwise the vector describes
+ // the requested composition type changes.
+ using ChangedLayer = std::pair<hwc2_layer_t, HWC2::Composition>;
+ auto ValidateStagedComposition() -> std::vector<ChangedLayer>;
+
// HWC2 Hooks - these should not be used outside of the hwc2 device.
HWC2::Error AcceptDisplayChanges();
HWC2::Error CreateLayer(hwc2_layer_t *layer);