drm_hwcomposer: Stop using HWC2 hooks for layer transform
Add a transform member to LayerProperties.
Change-Id: Id81386ce1565941e477534717cefb745de8738ca
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcLayer.cpp b/hwc2_device/HwcLayer.cpp
index c972e0b..ded8acd 100644
--- a/hwc2_device/HwcLayer.cpp
+++ b/hwc2_device/HwcLayer.cpp
@@ -47,6 +47,9 @@
if (layer_properties.source_crop) {
layer_data_.pi.source_crop = layer_properties.source_crop.value();
}
+ if (layer_properties.transform) {
+ layer_data_.pi.transform = layer_properties.transform.value();
+ }
}
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
diff --git a/hwc2_device/HwcLayer.h b/hwc2_device/HwcLayer.h
index 31bafed..ed84219 100644
--- a/hwc2_device/HwcLayer.h
+++ b/hwc2_device/HwcLayer.h
@@ -37,6 +37,7 @@
std::optional<hwc_rect_t> display_frame;
std::optional<float> alpha;
std::optional<hwc_frect_t> source_crop;
+ std::optional<LayerTransform> transform;
};
explicit HwcLayer(HwcDisplay *parent_display) : parent_(parent_display){};
diff --git a/hwc3/ComposerClient.cpp b/hwc3/ComposerClient.cpp
index fba8222..4038b27 100644
--- a/hwc3/ComposerClient.cpp
+++ b/hwc3/ComposerClient.cpp
@@ -52,6 +52,7 @@
using ::android::HwcDisplayConfig;
using ::android::HwcDisplayConfigs;
using ::android::HwcLayer;
+using ::android::LayerTransform;
#include "utils/log.h"
@@ -225,6 +226,36 @@
return alpha->alpha;
}
+std::optional<LayerTransform> AidlToLayerTransform(
+ const std::optional<ParcelableTransform>& aidl_transform) {
+ if (!aidl_transform) {
+ return std::nullopt;
+ }
+
+ uint32_t transform = LayerTransform::kIdentity;
+ // 270* and 180* cannot be combined with flips. More specifically, they
+ // already contain both horizontal and vertical flips, so those fields are
+ // redundant in this case. 90* rotation can be combined with either horizontal
+ // flip or vertical flip, so treat it differently
+ if (aidl_transform->transform == common::Transform::ROT_270) {
+ transform = LayerTransform::kRotate270;
+ } else if (aidl_transform->transform == common::Transform::ROT_180) {
+ transform = LayerTransform::kRotate180;
+ } else {
+ auto aidl_transform_bits = static_cast<uint32_t>(aidl_transform->transform);
+ if ((aidl_transform_bits &
+ static_cast<uint32_t>(common::Transform::FLIP_H)) != 0)
+ transform |= LayerTransform::kFlipH;
+ if ((aidl_transform_bits &
+ static_cast<uint32_t>(common::Transform::FLIP_V)) != 0)
+ transform |= LayerTransform::kFlipV;
+ if ((aidl_transform_bits &
+ static_cast<uint32_t>(common::Transform::ROT_90)) != 0)
+ transform |= LayerTransform::kRotate90;
+ }
+ return static_cast<LayerTransform>(transform);
+}
+
} // namespace
ComposerClient::ComposerClient() {
@@ -487,12 +518,10 @@
properties.display_frame = AidlToRect(command.displayFrame);
properties.alpha = AidlToAlpha(command.planeAlpha);
properties.source_crop = AidlToFRect(command.sourceCrop);
+ properties.transform = AidlToLayerTransform(command.transform);
layer->SetLayerProperties(properties);
- if (command.transform) {
- ExecuteSetLayerTransform(display_id, layer_wrapper, *command.transform);
- }
if (command.z) {
ExecuteSetLayerZOrder(display_id, layer_wrapper, *command.z);
}
@@ -1190,15 +1219,6 @@
}
}
-void ComposerClient::ExecuteSetLayerTransform(
- int64_t /*display_id*/, HwcLayerWrapper& layer,
- const ParcelableTransform& transform) {
- auto err = Hwc2toHwc3Error(
- layer.layer->SetLayerTransform(Hwc3TransformToHwc2(transform.transform)));
- if (err != hwc3::Error::kNone) {
- cmd_result_writer_->AddError(err);
- }
-}
void ComposerClient::ExecuteSetLayerZOrder(int64_t /*display_id*/,
HwcLayerWrapper& layer,
const ZOrder& z_order) {
diff --git a/hwc3/ComposerClient.h b/hwc3/ComposerClient.h
index d6a4107..fc8cc80 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 ExecuteSetLayerTransform(int64_t display_id, HwcLayerWrapper& layer,
- const ParcelableTransform& transform);
void ExecuteSetLayerZOrder(int64_t display_id, HwcLayerWrapper& layer,
const ZOrder& z_order);
void ExecuteSetLayerBrightness(int64_t display_id, HwcLayerWrapper& layer,
diff --git a/hwc3/Utils.h b/hwc3/Utils.h
index 3887440..b322f5d 100644
--- a/hwc3/Utils.h
+++ b/hwc3/Utils.h
@@ -165,11 +165,4 @@
return static_cast<int32_t>(dataspace);
}
-// Values match, so static_cast is okay.
-// https://cs.android.com/android/platform/superproject/main/+/main:hardware/interfaces/graphics/common/aidl/android/hardware/graphics/common/Transform.aidl
-// https://cs.android.com/android/platform/superproject/main/+/main:system/core/libsystem/include/system/graphics-base-v1.0.h;l=41
-inline int32_t Hwc3TransformToHwc2(common::Transform transform) {
- return static_cast<int32_t>(transform);
-}
-
}; // namespace aidl::android::hardware::graphics::composer3
\ No newline at end of file