Use the primaryDisplayRotationFlags for the source crop calculation
Source frame and bufferCrop calculations use the
primaryDisplayRotationFlags using the projection space
orientation just for the source crop calculation causes the
unwanted source crop in a situation where bufferCrop and
source frame are in different coordinate system. Using the
same primaryDisplayRotationFlags in Source crop calculation
will make all these calculations in line.
Test: verified manually with provided test apk in the #comment1 on
foldable, tablet and a phone and verified go/wm-smoke
atest libsurfaceflinger_unittest
atest libcompositionengine_test
atest CompositionTest
atest OutputLayerTest
BUG: 204187592
Change-Id: I23c6dcfb39979fd67eb5e1d21c011476c630058b
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 3289d55..744561c 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -106,9 +106,8 @@
return activeCrop;
}
-FloatRect OutputLayer::calculateOutputSourceCrop() const {
+FloatRect OutputLayer::calculateOutputSourceCrop(uint32_t internalDisplayRotationFlags) const {
const auto& layerState = *getLayerFE().getCompositionState();
- const auto& outputState = getOutput().getState();
if (!layerState.geomUsesSourceCrop) {
return {};
@@ -140,8 +139,7 @@
* the code below applies the primary display's inverse transform to the
* buffer
*/
- uint32_t invTransformOrient =
- ui::Transform::toRotationFlags(outputState.displaySpace.getOrientation());
+ uint32_t invTransformOrient = internalDisplayRotationFlags;
// calculate the inverse transform
if (invTransformOrient & HAL_TRANSFORM_ROT_90) {
invTransformOrient ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H;
@@ -304,7 +302,7 @@
state.forceClientComposition = false;
state.displayFrame = calculateOutputDisplayFrame();
- state.sourceCrop = calculateOutputSourceCrop();
+ state.sourceCrop = calculateOutputSourceCrop(internalDisplayRotationFlags);
state.bufferTransform = static_cast<Hwc2::Transform>(
calculateOutputRelativeBufferTransform(internalDisplayRotationFlags));