diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2017-02-26 17:04:40 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-02-26 17:04:40 -0800 |
commit | 3394427d7aa2eeb7c34860a38a0d822dc23a85db (patch) | |
tree | ead21a6c0a28eece0c48f3fcc8ca0d7fc3ae5109 | |
parent | dd54f8443ff30654d475ae9964f84a91c7298ed4 (diff) | |
parent | 5de9c6377870f0f197844d1de4ac07f77a8fe0a5 (diff) | |
download | display-3394427d7aa2eeb7c34860a38a0d822dc23a85db.tar.gz |
Merge "sdm: Add support to recompute rectangles considering flips"
-rw-r--r-- | sdm/include/utils/rect.h | 3 | ||||
-rw-r--r-- | sdm/libs/core/display_primary.cpp | 5 | ||||
-rw-r--r-- | sdm/libs/utils/rect.cpp | 19 |
3 files changed, 20 insertions, 7 deletions
diff --git a/sdm/include/utils/rect.h b/sdm/include/utils/rect.h index 16a9ba99..ea6edfb1 100644 --- a/sdm/include/utils/rect.h +++ b/sdm/include/utils/rect.h @@ -57,7 +57,8 @@ namespace sdm { 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 3a1541e2..409d6592 100644 --- a/sdm/libs/core/display_primary.cpp +++ b/sdm/libs/core/display_primary.cpp @@ -91,16 +91,19 @@ DisplayError DisplayPrimary::Prepare(LayerStack *layer_stack) { 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 dd5a872c..b0cd536e 100644 --- a/sdm/libs/utils/rect.cpp +++ b/sdm/libs/utils/rect.cpp @@ -223,18 +223,27 @@ void MapRect(const LayerRect &src_domain, const LayerRect &dst_domain, const Lay 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) { |