drm_hwcomposer: Stop using HWC2 for layer z order

Add z_order to LayerProperties and set it along with other properties

Change-Id: Ib98c653e0adbc8da0ef50d64bd734b9014b09caa
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcLayer.cpp b/hwc2_device/HwcLayer.cpp
index ded8acd..cd2a319 100644
--- a/hwc2_device/HwcLayer.cpp
+++ b/hwc2_device/HwcLayer.cpp
@@ -50,6 +50,9 @@
   if (layer_properties.transform) {
     layer_data_.pi.transform = layer_properties.transform.value();
   }
+  if (layer_properties.z_order) {
+    z_order_ = layer_properties.z_order.value();
+  }
 }
 
 // NOLINTNEXTLINE(readability-convert-member-functions-to-static)
diff --git a/hwc2_device/HwcLayer.h b/hwc2_device/HwcLayer.h
index ed84219..b8fb959 100644
--- a/hwc2_device/HwcLayer.h
+++ b/hwc2_device/HwcLayer.h
@@ -38,6 +38,7 @@
     std::optional<float> alpha;
     std::optional<hwc_frect_t> source_crop;
     std::optional<LayerTransform> transform;
+    std::optional<uint32_t> z_order;
   };
 
   explicit HwcLayer(HwcDisplay *parent_display) : parent_(parent_display){};
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index 4038b27..1becdb1 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -226,6 +226,13 @@
   return alpha->alpha;
 }
 
+std::optional<uint32_t> AidlToZOrder(const std::optional<ZOrder>& z_order) {
+  if (!z_order) {
+    return std::nullopt;
+  }
+  return z_order->z;
+}
+
 std::optional<LayerTransform> AidlToLayerTransform(
     const std::optional<ParcelableTransform>& aidl_transform) {
   if (!aidl_transform) {
@@ -519,12 +526,10 @@
   properties.alpha = AidlToAlpha(command.planeAlpha);
   properties.source_crop = AidlToFRect(command.sourceCrop);
   properties.transform = AidlToLayerTransform(command.transform);
+  properties.z_order = AidlToZOrder(command.z);
 
   layer->SetLayerProperties(properties);
 
-  if (command.z) {
-    ExecuteSetLayerZOrder(display_id, layer_wrapper, *command.z);
-  }
   if (command.brightness) {
     ExecuteSetLayerBrightness(display_id, layer_wrapper, *command.brightness);
   }
@@ -1219,15 +1224,6 @@
   }
 }
 
-void ComposerClient::ExecuteSetLayerZOrder(int64_t /*display_id*/,
-                                           HwcLayerWrapper& layer,
-                                           const ZOrder& z_order) {
-  auto err = Hwc2toHwc3Error(layer.layer->SetLayerZOrder(z_order.z));
-  if (err != hwc3::Error::kNone) {
-    cmd_result_writer_->AddError(err);
-  }
-}
-
 void ComposerClient::ExecuteSetLayerBrightness(
     int64_t /*display_id*/, HwcLayerWrapper& /*layer*/,
     const LayerBrightness& brightness) {
diff --git a/hwc3/ComposerClient.h b/hwc3/ComposerClient.h
index fc8cc80..fa79187 100644
--- a/hwc3/ComposerClient.h
+++ b/hwc3/ComposerClient.h
@@ -160,8 +160,6 @@
   void DispatchLayerCommand(int64_t display_id, const LayerCommand& command);
   void ExecuteSetLayerBuffer(int64_t display_id, HwcLayerWrapper& layer_id,
                              const Buffer& buffer);
-  void ExecuteSetLayerZOrder(int64_t display_id, HwcLayerWrapper& layer,
-                             const ZOrder& z_order);
   void ExecuteSetLayerBrightness(int64_t display_id, HwcLayerWrapper& layer,
                                  const LayerBrightness& brightness);