drm_hwcomposer: Stop using HWC2 hooks for layer plane alpha

Add an alpha member to LayerProperties and set it along with other
LayerCommand properties

Change-Id: Ib4e491718ec7772e6733f96a30dc63dcf0ed0598
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcLayer.cpp b/hwc2_device/HwcLayer.cpp
index a993acf..2dd51ca 100644
--- a/hwc2_device/HwcLayer.cpp
+++ b/hwc2_device/HwcLayer.cpp
@@ -40,6 +40,10 @@
   if (layer_properties.display_frame) {
     layer_data_.pi.display_frame = layer_properties.display_frame.value();
   }
+  if (layer_properties.alpha) {
+    layer_data_.pi.alpha = std::lround(layer_properties.alpha.value() *
+                                       UINT16_MAX);
+  }
 }
 
 // NOLINTNEXTLINE(readability-convert-member-functions-to-static)
diff --git a/hwc2_device/HwcLayer.h b/hwc2_device/HwcLayer.h
index 953e589..6b234f7 100644
--- a/hwc2_device/HwcLayer.h
+++ b/hwc2_device/HwcLayer.h
@@ -35,6 +35,7 @@
     std::optional<BufferSampleRange> sample_range;
     std::optional<HWC2::Composition> composition_type;
     std::optional<hwc_rect_t> display_frame;
+    std::optional<float> alpha;
   };
 
   explicit HwcLayer(HwcDisplay *parent_display) : parent_(parent_display){};
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index 60cafad..728361b 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -211,6 +211,13 @@
   return hwc_rect{rect->left, rect->top, rect->right, rect->bottom};
 }
 
+std::optional<float> AidlToAlpha(const std::optional<PlaneAlpha>& alpha) {
+  if (!alpha) {
+    return std::nullopt;
+  }
+  return alpha->alpha;
+}
+
 }  // namespace
 
 ComposerClient::ComposerClient() {
@@ -471,11 +478,9 @@
   properties.sample_range = AidlToSampleRange(command.dataspace);
   properties.composition_type = AidlToCompositionType(command.composition);
   properties.display_frame = AidlToRect(command.displayFrame);
+  properties.alpha = AidlToAlpha(command.planeAlpha);
   layer->SetLayerProperties(properties);
 
-  if (command.planeAlpha) {
-    ExecuteSetLayerPlaneAlpha(display_id, layer_wrapper, *command.planeAlpha);
-  }
   if (command.sourceCrop) {
     ExecuteSetLayerSourceCrop(display_id, layer_wrapper, *command.sourceCrop);
   }
@@ -1179,16 +1184,6 @@
   }
 }
 
-void ComposerClient::ExecuteSetLayerPlaneAlpha(int64_t /*display_id*/,
-                                               HwcLayerWrapper& layer,
-                                               const PlaneAlpha& plane_alpha) {
-  auto err = Hwc2toHwc3Error(
-      layer.layer->SetLayerPlaneAlpha(plane_alpha.alpha));
-  if (err != hwc3::Error::kNone) {
-    cmd_result_writer_->AddError(err);
-  }
-}
-
 void ComposerClient::ExecuteSetLayerSourceCrop(
     int64_t /*display_id*/, HwcLayerWrapper& layer,
     const common::FRect& source_crop) {
diff --git a/hwc3/ComposerClient.h b/hwc3/ComposerClient.h
index 95641ee..7e2d19c 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 ExecuteSetLayerPlaneAlpha(int64_t display_id, HwcLayerWrapper& layer,
-                                 const PlaneAlpha& plane_alpha);
   void ExecuteSetLayerSourceCrop(int64_t display_id, HwcLayerWrapper& layer,
                                  const common::FRect& source_crop);
   void ExecuteSetLayerTransform(int64_t display_id, HwcLayerWrapper& layer,