drm_hwcomposer: Convert transform value at HWC hook call
One more step towards "frontend" isolation.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/DrmHwcTwo.cpp b/DrmHwcTwo.cpp
index cfa2f1c..65f6fac 100644
--- a/DrmHwcTwo.cpp
+++ b/DrmHwcTwo.cpp
@@ -1163,7 +1163,27 @@
HWC2::Error DrmHwcTwo::HwcLayer::SetLayerTransform(int32_t transform) {
supported(__func__);
- transform_ = static_cast<HWC2::Transform>(transform);
+
+ 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 = DrmHwcTransform::kRotate270;
+ } else if (transform == HWC_TRANSFORM_ROT_180) {
+ l_transform = DrmHwcTransform::kRotate180;
+ } else {
+ if (transform & HWC_TRANSFORM_FLIP_H)
+ l_transform |= DrmHwcTransform::kFlipH;
+ if (transform & HWC_TRANSFORM_FLIP_V)
+ l_transform |= DrmHwcTransform::kFlipV;
+ if (transform & HWC_TRANSFORM_ROT_90)
+ l_transform |= DrmHwcTransform::kRotate90;
+ }
+
+ transform_ = static_cast<DrmHwcTransform>(l_transform);
return HWC2::Error::None;
}
@@ -1189,7 +1209,7 @@
layer->alpha = lround(65535.0F * alpha_);
layer->blending = blending_;
layer->source_crop = source_crop_;
- layer->SetTransform(static_cast<int32_t>(transform_));
+ layer->transform = transform_;
layer->color_space = color_space_;
layer->sample_range = sample_range_;
}
diff --git a/DrmHwcTwo.h b/DrmHwcTwo.h
index c2da62d..bd45b96 100644
--- a/DrmHwcTwo.h
+++ b/DrmHwcTwo.h
@@ -140,7 +140,7 @@
int32_t cursor_x_;
int32_t cursor_y_;
hwc_color_t layer_color_;
- HWC2::Transform transform_ = HWC2::Transform::None;
+ DrmHwcTransform transform_ = DrmHwcTransform::kIdentity;
uint32_t z_order_ = 0;
DrmHwcBlending blending_ = DrmHwcBlending::kNone;
DrmHwcColorSpace color_space_ = DrmHwcColorSpace::kUndefined;
diff --git a/include/drmhwcomposer.h b/include/drmhwcomposer.h
index 01954a1..d02445b 100644
--- a/include/drmhwcomposer.h
+++ b/include/drmhwcomposer.h
@@ -45,7 +45,7 @@
kLimitedRange,
};
-enum DrmHwcTransform {
+enum DrmHwcTransform : uint32_t {
kIdentity = 0,
kFlipH = 1 << 0,
kFlipV = 1 << 1,
@@ -66,7 +66,7 @@
std::shared_ptr<DrmFbIdHandle> FbIdHandle;
int gralloc_buffer_usage = 0;
- uint32_t transform;
+ DrmHwcTransform transform{};
DrmHwcBlending blending = DrmHwcBlending::kNone;
uint16_t alpha = 0xffff;
hwc_frect_t source_crop;
@@ -78,8 +78,6 @@
int ImportBuffer(DrmDevice *drmDevice);
- void SetTransform(int32_t sf_transform);
-
bool protected_usage() const {
return (gralloc_buffer_usage & GRALLOC_USAGE_PROTECTED) ==
GRALLOC_USAGE_PROTECTED;
diff --git a/utils/hwcutils.cpp b/utils/hwcutils.cpp
index 6de6500..5a46e9b 100644
--- a/utils/hwcutils.cpp
+++ b/utils/hwcutils.cpp
@@ -48,23 +48,4 @@
return 0;
}
-void DrmHwcLayer::SetTransform(int32_t sf_transform) {
- 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 (sf_transform == HWC_TRANSFORM_ROT_270) {
- transform = DrmHwcTransform::kRotate270;
- } else if (sf_transform == HWC_TRANSFORM_ROT_180) {
- transform = DrmHwcTransform::kRotate180;
- } else {
- if (sf_transform & HWC_TRANSFORM_FLIP_H)
- transform |= DrmHwcTransform::kFlipH;
- if (sf_transform & HWC_TRANSFORM_FLIP_V)
- transform |= DrmHwcTransform::kFlipV;
- if (sf_transform & HWC_TRANSFORM_ROT_90)
- transform |= DrmHwcTransform::kRotate90;
- }
-}
} // namespace android