Merge "sdm: Add support to recompute rectangles considering flips"
diff --git a/sdm/include/utils/rect.h b/sdm/include/utils/rect.h
index 16a9ba9..ea6edfb 100644
--- a/sdm/include/utils/rect.h
+++ b/sdm/include/utils/rect.h
@@ -57,7 +57,8 @@
bool flip_horizontal, LayerRect *out_rects);
void MapRect(const LayerRect &src_domain, const LayerRect &dst_domain, const LayerRect &in_rect,
LayerRect *out_rect);
- void TransformHV(const LayerRect &src_domain, const LayerRect &in_rect, LayerRect *out_rect);
+ void TransformHV(const LayerRect &src_domain, const LayerRect &in_rect,
+ const LayerTransform &transform, LayerRect *out_rect);
RectOrientation GetOrientation(const LayerRect &in_rect);
} // namespace sdm
diff --git a/sdm/libs/core/display_primary.cpp b/sdm/libs/core/display_primary.cpp
index 3a1541e..409d659 100644
--- a/sdm/libs/core/display_primary.cpp
+++ b/sdm/libs/core/display_primary.cpp
@@ -91,16 +91,19 @@
bool needs_hv_flip = hw_panel_info_.panel_orientation.flip_horizontal &&
hw_panel_info_.panel_orientation.flip_vertical;
LayerRect src_domain = {};
+ LayerTransform panel_transform = {};
DisplayConfigVariableInfo variable_info = {};
if (needs_hv_flip) {
DisplayBase::GetFrameBufferConfig(&variable_info);
src_domain.right = variable_info.x_pixels;
src_domain.bottom = variable_info.y_pixels;
+ panel_transform.flip_horizontal = hw_panel_info_.panel_orientation.flip_horizontal;
+ panel_transform.flip_vertical = hw_panel_info_.panel_orientation.flip_vertical;
for (Layer *layer : layer_stack->layers) {
// Modify destination based on panel flip
- TransformHV(src_domain, layer->dst_rect, &layer->dst_rect);
+ TransformHV(src_domain, layer->dst_rect, panel_transform, &layer->dst_rect);
if (layer->flags.solid_fill) {
continue;
diff --git a/sdm/libs/utils/rect.cpp b/sdm/libs/utils/rect.cpp
index dd5a872..b0cd536 100644
--- a/sdm/libs/utils/rect.cpp
+++ b/sdm/libs/utils/rect.cpp
@@ -223,18 +223,27 @@
out_rect->bottom = dst_domain.top + (height_ratio * modified_in_rect.bottom);
}
-void TransformHV(const LayerRect &src_domain, const LayerRect &in_rect, LayerRect *out_rect) {
+void TransformHV(const LayerRect &src_domain, const LayerRect &in_rect,
+ const LayerTransform &transform, LayerRect *out_rect) {
if (!IsValid(src_domain) || !IsValid(in_rect)) {
return;
}
float in_width = in_rect.right - in_rect.left;
float in_height = in_rect.bottom - in_rect.top;
+ float x_offset = in_rect.left - src_domain.left;
+ float y_offset = in_rect.top - src_domain.top;
+ *out_rect = in_rect;
- out_rect->right = src_domain.right - in_rect.left;
- out_rect->bottom = src_domain.bottom - in_rect.top;
- out_rect->left = out_rect->right - in_width;
- out_rect->top = out_rect->bottom - in_height;
+ if (transform.flip_horizontal) {
+ out_rect->right = src_domain.right - x_offset;
+ out_rect->left = out_rect->right - in_width;
+ }
+
+ if (transform.flip_vertical) {
+ out_rect->bottom = src_domain.bottom - y_offset;
+ out_rect->top = out_rect->bottom - in_height;
+ }
}
RectOrientation GetOrientation(const LayerRect &in_rect) {