drm_hwcomposer: Simplify LayerTransform
Fixes clang-analyzer-optin.core.EnumCastOutOfRange clang tidy check.
Change-Id: I0a88d1ef084848c924198e8bd3831533b6578675
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/hwc2_device/hwc2_device.cpp b/hwc2_device/hwc2_device.cpp
index 98f5953..c7bce5f 100644
--- a/hwc2_device/hwc2_device.cpp
+++ b/hwc2_device/hwc2_device.cpp
@@ -300,27 +300,12 @@
GET_DISPLAY(display);
GET_LAYER(layer);
- uint32_t l_transform = 0;
-
- // 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 (transform == HWC_TRANSFORM_ROT_270) {
- l_transform = LayerTransform::kRotate270;
- } else if (transform == HWC_TRANSFORM_ROT_180) {
- l_transform = LayerTransform::kRotate180;
- } else {
- if ((transform & HWC_TRANSFORM_FLIP_H) != 0)
- l_transform |= LayerTransform::kFlipH;
- if ((transform & HWC_TRANSFORM_FLIP_V) != 0)
- l_transform |= LayerTransform::kFlipV;
- if ((transform & HWC_TRANSFORM_ROT_90) != 0)
- l_transform |= LayerTransform::kRotate90;
- }
-
HwcLayer::LayerProperties layer_properties;
- layer_properties.transform = static_cast<LayerTransform>(l_transform);
+ layer_properties.transform = {
+ .hflip = (transform & HAL_TRANSFORM_FLIP_H) != 0,
+ .vflip = (transform & HAL_TRANSFORM_FLIP_V) != 0,
+ .rotate90 = (transform & HAL_TRANSFORM_ROT_90) != 0,
+ };
ilayer->SetLayerProperties(layer_properties);
return 0;