summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rashed Abdel-Tawab <rashed@linux.com> 2019-10-29 10:01:56 -0700
committer Lloyd Pique <lpique@google.com> 2019-12-19 14:59:06 -0800
commit6643cd81ed63d04662bfded60df1eeb11dcf248c (patch)
treed8dc497167f9f6ac87929e0379f5b1001880802b
parent8a5092d0bbf7fd46f2a27e36a727ca0e7d5c35aa (diff)
CompositionEngine: fix HWC transform calculation
Use the correct display transform in calculateOutputRelativeBufferTransform(). When SF_PRIMARY_DISPLAY_ORIENTATION is set, DisplayDevice only updates the logical to physical transform; OutputCompositionState.orientation doesn't change. Test: - OutputLayerTest.displayInstallOrientationBufferTransformSetTo90 - Run "dumpsys SurfaceFlinger" on a device with SF_PRIMARY_DISPLAY_ORIENTATION set to 90 and verify that the HWC transform is 0 (identity) - screencap Change-Id: I079b5ea22de8d47a7fb7233d01decfbd4b578be8
-rw-r--r--services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp2
-rw-r--r--services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp17
2 files changed, 18 insertions, 1 deletions
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index ce0222cee5..82d24222f1 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -231,7 +231,7 @@ uint32_t OutputLayer::calculateOutputRelativeBufferTransform() const {
* (NOTE: the matrices are multiplied in reverse order)
*/
const ui::Transform& layerTransform = layerState.geomLayerTransform;
- const ui::Transform displayTransform{outputState.orientation};
+ const ui::Transform displayTransform{outputState.transform};
const ui::Transform bufferTransform{layerState.geomBufferTransform};
ui::Transform transform(displayTransform * layerTransform * bufferTransform);
diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
index 2e030a1823..0e579fa7e1 100644
--- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp
@@ -364,6 +364,7 @@ TEST_F(OutputLayerTest, calculateOutputRelativeBufferTransformTestsNeeded) {
mLayerFEState.geomLayerTransform.set(entry.layer, 1920, 1080);
mLayerFEState.geomBufferTransform = entry.buffer;
mOutputState.orientation = entry.display;
+ mOutputState.transform = ui::Transform{entry.display};
auto actual = mOutputLayer.calculateOutputRelativeBufferTransform();
EXPECT_EQ(entry.expected, actual) << "entry " << i;
@@ -422,6 +423,7 @@ TEST_F(OutputLayerTest,
mLayerFEState.geomLayerTransform = ui::Transform{entry.layer};
mLayerFEState.geomBufferTransform = entry.buffer;
mOutputState.orientation = entry.display;
+ mOutputState.transform = ui::Transform{entry.display};
auto actual = mOutputLayer.calculateOutputRelativeBufferTransform();
EXPECT_EQ(entry.expected, actual) << "entry " << i;
@@ -764,6 +766,21 @@ TEST_F(OutputLayerWriteStateToHWCTest, canSetAllState) {
mOutputLayer.writeStateToHWC(true);
}
+TEST_F(OutputLayerTest, displayInstallOrientationBufferTransformSetTo90) {
+ mLayerFEState.geomBufferUsesDisplayInverseTransform = false;
+ mLayerFEState.geomLayerTransform = ui::Transform{TR_IDENT};
+ // This test simulates a scenario where displayInstallOrientation is set to
+ // ROT_90. This only has an effect on the transform; orientation stays 0 (see
+ // DisplayDevice::setProjection).
+ mOutputState.orientation = TR_IDENT;
+ mOutputState.transform = ui::Transform{TR_ROT_90};
+ // Buffers are pre-rotated based on the transform hint (ROT_90); their
+ // geomBufferTransform is set to the inverse transform.
+ mLayerFEState.geomBufferTransform = TR_ROT_270;
+
+ EXPECT_EQ(TR_IDENT, mOutputLayer.calculateOutputRelativeBufferTransform());
+}
+
TEST_F(OutputLayerWriteStateToHWCTest, canSetPerFrameStateForSolidColor) {
mLayerFEState.compositionType = Hwc2::IComposerClient::Composition::SOLID_COLOR;