summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMichael Lentine <mlentine@google.com>2014-08-19 11:27:30 -0700
committerMichael Lentine <mlentine@google.com>2014-08-19 16:16:35 -0700
commit1440963470cda68be762957e2efb7ecbe1570366 (patch)
tree4c8dbf0470dac3978ca446fea06c9ca3920fca68 /services
parentf75514079434cefcdb746e8b083708d6de5f86ff (diff)
downloadframeworks_native-1440963470cda68be762957e2efb7ecbe1570366.zip
frameworks_native-1440963470cda68be762957e2efb7ecbe1570366.tar.gz
frameworks_native-1440963470cda68be762957e2efb7ecbe1570366.tar.bz2
Fix camera orientation by swapping horizontal and vertical flips when needed.
Bug: 16637957 Change-Id: I66de597546fdc19e0af9e6150ca20460ab36bf8b
Diffstat (limited to 'services')
-rw-r--r--services/surfaceflinger/Layer.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index cf49798..2bbb223 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -332,6 +332,14 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
if (invTransformOrient & NATIVE_WINDOW_TRANSFORM_ROT_90) {
invTransformOrient ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
NATIVE_WINDOW_TRANSFORM_FLIP_H;
+ // If the transform has been rotated the axis of flip has been swapped
+ // so we need to swap which flip operations we are performing
+ bool is_h_flipped = (invTransform & NATIVE_WINDOW_TRANSFORM_FLIP_H) != 0;
+ bool is_v_flipped = (invTransform & NATIVE_WINDOW_TRANSFORM_FLIP_V) != 0;
+ if (is_h_flipped != is_v_flipped) {
+ invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
+ NATIVE_WINDOW_TRANSFORM_FLIP_H;
+ }
}
// and apply to the current transform
invTransform = (Transform(invTransform) * Transform(invTransformOrient)).getOrientation();
@@ -411,13 +419,22 @@ void Layer::setGeometry(
* the code below applies the display's inverse transform to the buffer
*/
uint32_t invTransform = hw->getOrientationTransform();
+ uint32_t t_orientation = transform.getOrientation();
// calculate the inverse transform
if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
invTransform ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
NATIVE_WINDOW_TRANSFORM_FLIP_H;
+ // If the transform has been rotated the axis of flip has been swapped
+ // so we need to swap which flip operations we are performing
+ bool is_h_flipped = (t_orientation & NATIVE_WINDOW_TRANSFORM_FLIP_H) != 0;
+ bool is_v_flipped = (t_orientation & NATIVE_WINDOW_TRANSFORM_FLIP_V) != 0;
+ if (is_h_flipped != is_v_flipped) {
+ t_orientation ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
+ NATIVE_WINDOW_TRANSFORM_FLIP_H;
+ }
}
// and apply to the current transform
- transform = transform * Transform(invTransform);
+ transform = Transform(t_orientation) * Transform(invTransform);
}
// this gives us only the "orientation" component of the transform