diff options
9 files changed, 155 insertions, 82 deletions
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/CompositionRefreshArgs.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/CompositionRefreshArgs.h index d3712d9a5e..a0606b48f0 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/CompositionRefreshArgs.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/CompositionRefreshArgs.h @@ -24,6 +24,7 @@ #include <compositionengine/LayerFE.h> #include <compositionengine/OutputColorSetting.h> #include <math/mat4.h> +#include <ui/Transform.h> namespace android::compositionengine { @@ -57,6 +58,9 @@ struct CompositionRefreshArgs { // Forces a color mode on the outputs being refreshed ui::ColorMode forceOutputColorMode{ui::ColorMode::NATIVE}; + // Used to correctly apply an inverse-display buffer transform if applicable + ui::Transform::RotationFlags internalDisplayRotationFlags{ui::Transform::ROT_0}; + // If true, GPU clocks will be increased when rendering blurs bool blursAreExpensive{false}; diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/OutputLayer.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/OutputLayer.h index cf77738ced..aa70ef836d 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/OutputLayer.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/OutputLayer.h @@ -19,6 +19,7 @@ #include <optional> #include <string> +#include <ui/Transform.h> #include <utils/StrongPointer.h> // TODO(b/129481165): remove the #pragma below and fix conversion issues @@ -77,7 +78,12 @@ public: // Recalculates the state of the output layer from the output-independent // layer. If includeGeometry is false, the geometry state can be skipped. - virtual void updateCompositionState(bool includeGeometry, bool forceClientComposition) = 0; + // internalDisplayRotationFlags must be set to the rotation flags for the + // internal display, and is used to properly compute the inverse-display + // transform, if needed. + virtual void updateCompositionState( + bool includeGeometry, bool forceClientComposition, + ui::Transform::RotationFlags internalDisplayRotationFlags) = 0; // Writes the geometry state to the HWC, or does nothing if this layer does // not use the HWC. If includeGeometry is false, the geometry state can be diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h index 79df9b2551..8cb5ae8b8e 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayer.h @@ -39,7 +39,8 @@ public: void setHwcLayer(std::shared_ptr<HWC2::Layer>) override; - void updateCompositionState(bool includeGeometry, bool forceClientComposition) override; + void updateCompositionState(bool includeGeometry, bool forceClientComposition, + ui::Transform::RotationFlags) override; void writeStateToHWC(bool) override; void writeCursorPositionToHWC() const override; @@ -55,7 +56,8 @@ public: virtual FloatRect calculateOutputSourceCrop() const; virtual Rect calculateOutputDisplayFrame() const; - virtual uint32_t calculateOutputRelativeBufferTransform() const; + virtual uint32_t calculateOutputRelativeBufferTransform( + uint32_t internalDisplayRotationFlags) const; protected: // Implemented by the final implementation for the final state it uses. diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/OutputLayer.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/OutputLayer.h index 2ecbad803f..81e1fc7ea0 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/OutputLayer.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/mock/OutputLayer.h @@ -38,7 +38,7 @@ public: MOCK_CONST_METHOD0(getState, const impl::OutputLayerCompositionState&()); MOCK_METHOD0(editState, impl::OutputLayerCompositionState&()); - MOCK_METHOD2(updateCompositionState, void(bool, bool)); + MOCK_METHOD3(updateCompositionState, void(bool, bool, ui::Transform::RotationFlags)); MOCK_METHOD1(writeStateToHWC, void(bool)); MOCK_CONST_METHOD0(writeCursorPositionToHWC, void()); diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp index cb7ddda662..e8f54f57b1 100644 --- a/services/surfaceflinger/CompositionEngine/src/Output.cpp +++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp @@ -588,7 +588,8 @@ void Output::updateAndWriteCompositionState( for (auto* layer : getOutputLayersOrderedByZ()) { layer->updateCompositionState(refreshArgs.updatingGeometryThisFrame, refreshArgs.devOptForceClientComposition || - forceClientComposition); + forceClientComposition, + refreshArgs.internalDisplayRotationFlags); if (mLayerRequestingBackgroundBlur == layer) { forceClientComposition = false; diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp index c9a070d6f9..81f2dd1e08 100644 --- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp +++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp @@ -223,7 +223,8 @@ Rect OutputLayer::calculateOutputDisplayFrame() const { return displayTransform.transform(frame); } -uint32_t OutputLayer::calculateOutputRelativeBufferTransform() const { +uint32_t OutputLayer::calculateOutputRelativeBufferTransform( + uint32_t internalDisplayRotationFlags) const { const auto& layerState = *getLayerFE().getCompositionState(); const auto& outputState = getOutput().getState(); @@ -241,10 +242,11 @@ uint32_t OutputLayer::calculateOutputRelativeBufferTransform() const { if (layerState.geomBufferUsesDisplayInverseTransform) { /* - * the code below applies the primary display's inverse transform to the - * buffer + * We must apply the internal display's inverse transform to the buffer + * transform, and not the one for the output this layer is on. */ - uint32_t invTransform = outputState.orientation; + uint32_t invTransform = internalDisplayRotationFlags; + // calculate the inverse transform if (invTransform & HAL_TRANSFORM_ROT_90) { invTransform ^= HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_FLIP_H; @@ -261,9 +263,11 @@ uint32_t OutputLayer::calculateOutputRelativeBufferTransform() const { // this gives us only the "orientation" component of the transform return transform.getOrientation(); -} // namespace impl +} -void OutputLayer::updateCompositionState(bool includeGeometry, bool forceClientComposition) { +void OutputLayer::updateCompositionState( + bool includeGeometry, bool forceClientComposition, + ui::Transform::RotationFlags internalDisplayRotationFlags) { const auto* layerFEState = getLayerFE().getCompositionState(); if (!layerFEState) { return; @@ -283,8 +287,8 @@ void OutputLayer::updateCompositionState(bool includeGeometry, bool forceClientC state.displayFrame = calculateOutputDisplayFrame(); state.sourceCrop = calculateOutputSourceCrop(); - state.bufferTransform = - static_cast<Hwc2::Transform>(calculateOutputRelativeBufferTransform()); + state.bufferTransform = static_cast<Hwc2::Transform>( + calculateOutputRelativeBufferTransform(internalDisplayRotationFlags)); if ((layerFEState->isSecure && !outputState.isSecure) || (state.bufferTransform & ui::Transform::ROT_INVALID)) { diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp index bdacb22686..020f93a607 100644 --- a/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/OutputLayerTest.cpp @@ -361,7 +361,7 @@ TEST_F(OutputLayerTest, calculateOutputRelativeBufferTransformTestsNeeded) { mOutputState.orientation = entry.display; mOutputState.transform = ui::Transform{entry.display}; - auto actual = mOutputLayer.calculateOutputRelativeBufferTransform(); + const auto actual = mOutputLayer.calculateOutputRelativeBufferTransform(entry.display); EXPECT_EQ(entry.expected, actual) << "entry " << i; } } @@ -371,56 +371,109 @@ TEST_F(OutputLayerTest, mLayerFEState.geomBufferUsesDisplayInverseTransform = true; struct Entry { - uint32_t layer; + uint32_t layer; /* shouldn't affect the result, so we just use arbitrary values */ uint32_t buffer; uint32_t display; + uint32_t internal; uint32_t expected; }; - // Not an exhaustive list of cases, but hopefully enough. - const std::array<Entry, 24> testData = { + const std::array<Entry, 64> testData = { // clang-format off - // layer buffer display expected - /* 0 */ Entry{TR_IDENT, TR_IDENT, TR_IDENT, TR_IDENT}, - /* 1 */ Entry{TR_IDENT, TR_IDENT, TR_ROT_90, TR_IDENT}, - /* 2 */ Entry{TR_IDENT, TR_IDENT, TR_ROT_180, TR_IDENT}, - /* 3 */ Entry{TR_IDENT, TR_IDENT, TR_ROT_270, TR_IDENT}, - - /* 4 */ Entry{TR_IDENT, TR_FLP_H, TR_IDENT, TR_FLP_H}, - /* 5 */ Entry{TR_IDENT, TR_FLP_H, TR_ROT_90, TR_FLP_H}, - /* 6 */ Entry{TR_IDENT, TR_FLP_H, TR_ROT_180, TR_FLP_H}, - /* 7 */ Entry{TR_IDENT, TR_FLP_H, TR_ROT_270, TR_FLP_H}, - - /* 8 */ Entry{TR_IDENT, TR_FLP_V, TR_IDENT, TR_FLP_V}, - /* 9 */ Entry{TR_IDENT, TR_ROT_90, TR_ROT_90, TR_ROT_90}, - /* 10 */ Entry{TR_IDENT, TR_ROT_180, TR_ROT_180, TR_ROT_180}, - /* 11 */ Entry{TR_IDENT, TR_ROT_270, TR_ROT_270, TR_ROT_270}, - - /* 12 */ Entry{TR_ROT_90, TR_IDENT, TR_IDENT, TR_IDENT}, - /* 13 */ Entry{TR_ROT_90, TR_FLP_H, TR_ROT_90, TR_FLP_H}, - /* 14 */ Entry{TR_ROT_90, TR_IDENT, TR_ROT_180, TR_IDENT}, - /* 15 */ Entry{TR_ROT_90, TR_FLP_H, TR_ROT_270, TR_FLP_H}, - - /* 16 */ Entry{TR_ROT_180, TR_FLP_H, TR_IDENT, TR_FLP_H}, - /* 17 */ Entry{TR_ROT_180, TR_IDENT, TR_ROT_90, TR_IDENT}, - /* 18 */ Entry{TR_ROT_180, TR_FLP_H, TR_ROT_180, TR_FLP_H}, - /* 19 */ Entry{TR_ROT_180, TR_IDENT, TR_ROT_270, TR_IDENT}, - - /* 20 */ Entry{TR_ROT_270, TR_IDENT, TR_IDENT, TR_IDENT}, - /* 21 */ Entry{TR_ROT_270, TR_FLP_H, TR_ROT_90, TR_FLP_H}, - /* 22 */ Entry{TR_ROT_270, TR_FLP_H, TR_ROT_180, TR_FLP_H}, - /* 23 */ Entry{TR_ROT_270, TR_IDENT, TR_ROT_270, TR_IDENT}, + // layer buffer display internal expected + Entry{TR_IDENT, TR_IDENT, TR_IDENT, TR_IDENT, TR_IDENT}, + Entry{TR_IDENT, TR_IDENT, TR_IDENT, TR_ROT_90, TR_ROT_270}, + Entry{TR_IDENT, TR_IDENT, TR_IDENT, TR_ROT_180, TR_ROT_180}, + Entry{TR_IDENT, TR_IDENT, TR_IDENT, TR_ROT_270, TR_ROT_90}, + + Entry{TR_IDENT, TR_IDENT, TR_ROT_90, TR_IDENT, TR_ROT_90}, + Entry{TR_ROT_90, TR_IDENT, TR_ROT_90, TR_ROT_90, TR_IDENT}, + Entry{TR_ROT_180, TR_IDENT, TR_ROT_90, TR_ROT_180, TR_ROT_270}, + Entry{TR_ROT_90, TR_IDENT, TR_ROT_90, TR_ROT_270, TR_ROT_180}, + + Entry{TR_ROT_180, TR_IDENT, TR_ROT_180, TR_IDENT, TR_ROT_180}, + Entry{TR_ROT_90, TR_IDENT, TR_ROT_180, TR_ROT_90, TR_ROT_90}, + Entry{TR_ROT_180, TR_IDENT, TR_ROT_180, TR_ROT_180, TR_IDENT}, + Entry{TR_ROT_270, TR_IDENT, TR_ROT_180, TR_ROT_270, TR_ROT_270}, + + Entry{TR_ROT_270, TR_IDENT, TR_ROT_270, TR_IDENT, TR_ROT_270}, + Entry{TR_ROT_270, TR_IDENT, TR_ROT_270, TR_ROT_90, TR_ROT_180}, + Entry{TR_ROT_180, TR_IDENT, TR_ROT_270, TR_ROT_180, TR_ROT_90}, + Entry{TR_IDENT, TR_IDENT, TR_ROT_270, TR_ROT_270, TR_IDENT}, + + // layer buffer display internal expected + Entry{TR_IDENT, TR_ROT_90, TR_IDENT, TR_IDENT, TR_ROT_90}, + Entry{TR_ROT_90, TR_ROT_90, TR_IDENT, TR_ROT_90, TR_IDENT}, + Entry{TR_ROT_180, TR_ROT_90, TR_IDENT, TR_ROT_180, TR_ROT_270}, + Entry{TR_ROT_270, TR_ROT_90, TR_IDENT, TR_ROT_270, TR_ROT_180}, + + Entry{TR_ROT_90, TR_ROT_90, TR_ROT_90, TR_IDENT, TR_ROT_180}, + Entry{TR_ROT_90, TR_ROT_90, TR_ROT_90, TR_ROT_90, TR_ROT_90}, + Entry{TR_ROT_90, TR_ROT_90, TR_ROT_90, TR_ROT_180, TR_IDENT}, + Entry{TR_ROT_270, TR_ROT_90, TR_ROT_90, TR_ROT_270, TR_ROT_270}, + + Entry{TR_IDENT, TR_ROT_90, TR_ROT_180, TR_IDENT, TR_ROT_270}, + Entry{TR_ROT_90, TR_ROT_90, TR_ROT_180, TR_ROT_90, TR_ROT_180}, + Entry{TR_ROT_180, TR_ROT_90, TR_ROT_180, TR_ROT_180, TR_ROT_90}, + Entry{TR_ROT_90, TR_ROT_90, TR_ROT_180, TR_ROT_270, TR_IDENT}, + + Entry{TR_IDENT, TR_ROT_90, TR_ROT_270, TR_IDENT, TR_IDENT}, + Entry{TR_ROT_270, TR_ROT_90, TR_ROT_270, TR_ROT_90, TR_ROT_270}, + Entry{TR_ROT_180, TR_ROT_90, TR_ROT_270, TR_ROT_180, TR_ROT_180}, + Entry{TR_ROT_270, TR_ROT_90, TR_ROT_270, TR_ROT_270, TR_ROT_90}, + + // layer buffer display internal expected + Entry{TR_IDENT, TR_ROT_180, TR_IDENT, TR_IDENT, TR_ROT_180}, + Entry{TR_IDENT, TR_ROT_180, TR_IDENT, TR_ROT_90, TR_ROT_90}, + Entry{TR_ROT_180, TR_ROT_180, TR_IDENT, TR_ROT_180, TR_IDENT}, + Entry{TR_ROT_270, TR_ROT_180, TR_IDENT, TR_ROT_270, TR_ROT_270}, + + Entry{TR_IDENT, TR_ROT_180, TR_ROT_90, TR_IDENT, TR_ROT_270}, + Entry{TR_ROT_90, TR_ROT_180, TR_ROT_90, TR_ROT_90, TR_ROT_180}, + Entry{TR_ROT_180, TR_ROT_180, TR_ROT_90, TR_ROT_180, TR_ROT_90}, + Entry{TR_ROT_180, TR_ROT_180, TR_ROT_90, TR_ROT_270, TR_IDENT}, + + Entry{TR_IDENT, TR_ROT_180, TR_ROT_180, TR_IDENT, TR_IDENT}, + Entry{TR_ROT_180, TR_ROT_180, TR_ROT_180, TR_ROT_90, TR_ROT_270}, + Entry{TR_ROT_180, TR_ROT_180, TR_ROT_180, TR_ROT_180, TR_ROT_180}, + Entry{TR_ROT_270, TR_ROT_180, TR_ROT_180, TR_ROT_270, TR_ROT_90}, + + Entry{TR_ROT_270, TR_ROT_180, TR_ROT_270, TR_IDENT, TR_ROT_90}, + Entry{TR_ROT_180, TR_ROT_180, TR_ROT_270, TR_ROT_90, TR_IDENT}, + Entry{TR_ROT_180, TR_ROT_180, TR_ROT_270, TR_ROT_180, TR_ROT_270}, + Entry{TR_ROT_270, TR_ROT_180, TR_ROT_270, TR_ROT_270, TR_ROT_180}, + + // layer buffer display internal expected + Entry{TR_IDENT, TR_ROT_270, TR_IDENT, TR_IDENT, TR_ROT_270}, + Entry{TR_ROT_90, TR_ROT_270, TR_IDENT, TR_ROT_90, TR_ROT_180}, + Entry{TR_ROT_270, TR_ROT_270, TR_IDENT, TR_ROT_180, TR_ROT_90}, + Entry{TR_IDENT, TR_ROT_270, TR_IDENT, TR_ROT_270, TR_IDENT}, + + Entry{TR_ROT_270, TR_ROT_270, TR_ROT_90, TR_IDENT, TR_IDENT}, + Entry{TR_ROT_90, TR_ROT_270, TR_ROT_90, TR_ROT_90, TR_ROT_270}, + Entry{TR_ROT_180, TR_ROT_270, TR_ROT_90, TR_ROT_180, TR_ROT_180}, + Entry{TR_ROT_90, TR_ROT_270, TR_ROT_90, TR_ROT_270, TR_ROT_90}, + + Entry{TR_IDENT, TR_ROT_270, TR_ROT_180, TR_IDENT, TR_ROT_90}, + Entry{TR_ROT_270, TR_ROT_270, TR_ROT_180, TR_ROT_90, TR_IDENT}, + Entry{TR_ROT_180, TR_ROT_270, TR_ROT_180, TR_ROT_180, TR_ROT_270}, + Entry{TR_ROT_270, TR_ROT_270, TR_ROT_180, TR_ROT_270, TR_ROT_180}, + + Entry{TR_IDENT, TR_ROT_270, TR_ROT_270, TR_IDENT, TR_ROT_180}, + Entry{TR_ROT_90, TR_ROT_270, TR_ROT_270, TR_ROT_90, TR_ROT_90}, + Entry{TR_ROT_270, TR_ROT_270, TR_ROT_270, TR_ROT_180, TR_IDENT}, + Entry{TR_ROT_270, TR_ROT_270, TR_ROT_270, TR_ROT_270, TR_ROT_270}, // clang-format on }; for (size_t i = 0; i < testData.size(); i++) { const auto& entry = testData[i]; - mLayerFEState.geomLayerTransform = ui::Transform{entry.layer}; + 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(); + const auto actual = mOutputLayer.calculateOutputRelativeBufferTransform(entry.internal); EXPECT_EQ(entry.expected, actual) << "entry " << i; } } @@ -436,7 +489,7 @@ struct OutputLayerPartialMockForUpdateCompositionState : public impl::OutputLaye // Mock everything called by updateCompositionState to simplify testing it. MOCK_CONST_METHOD0(calculateOutputSourceCrop, FloatRect()); MOCK_CONST_METHOD0(calculateOutputDisplayFrame, Rect()); - MOCK_CONST_METHOD0(calculateOutputRelativeBufferTransform, uint32_t()); + MOCK_CONST_METHOD1(calculateOutputRelativeBufferTransform, uint32_t(uint32_t)); // compositionengine::OutputLayer overrides const compositionengine::Output& getOutput() const override { return mOutput; } @@ -463,10 +516,11 @@ public: ~OutputLayerUpdateCompositionStateTest() = default; - void setupGeometryChildCallValues() { + void setupGeometryChildCallValues(ui::Transform::RotationFlags internalDisplayRotationFlags) { EXPECT_CALL(mOutputLayer, calculateOutputSourceCrop()).WillOnce(Return(kSourceCrop)); EXPECT_CALL(mOutputLayer, calculateOutputDisplayFrame()).WillOnce(Return(kDisplayFrame)); - EXPECT_CALL(mOutputLayer, calculateOutputRelativeBufferTransform()) + EXPECT_CALL(mOutputLayer, + calculateOutputRelativeBufferTransform(internalDisplayRotationFlags)) .WillOnce(Return(mBufferTransform)); } @@ -489,7 +543,7 @@ public: TEST_F(OutputLayerUpdateCompositionStateTest, doesNothingIfNoFECompositionState) { EXPECT_CALL(*mLayerFE, getCompositionState()).WillOnce(Return(nullptr)); - mOutputLayer.updateCompositionState(true, false); + mOutputLayer.updateCompositionState(true, false, ui::Transform::RotationFlags::ROT_90); } TEST_F(OutputLayerUpdateCompositionStateTest, setsStateNormally) { @@ -497,9 +551,9 @@ TEST_F(OutputLayerUpdateCompositionStateTest, setsStateNormally) { mOutputState.isSecure = true; mOutputLayer.editState().forceClientComposition = true; - setupGeometryChildCallValues(); + setupGeometryChildCallValues(ui::Transform::RotationFlags::ROT_90); - mOutputLayer.updateCompositionState(true, false); + mOutputLayer.updateCompositionState(true, false, ui::Transform::RotationFlags::ROT_90); validateComputedGeometryState(); @@ -511,9 +565,9 @@ TEST_F(OutputLayerUpdateCompositionStateTest, mLayerFEState.isSecure = true; mOutputState.isSecure = false; - setupGeometryChildCallValues(); + setupGeometryChildCallValues(ui::Transform::RotationFlags::ROT_0); - mOutputLayer.updateCompositionState(true, false); + mOutputLayer.updateCompositionState(true, false, ui::Transform::RotationFlags::ROT_0); validateComputedGeometryState(); @@ -527,9 +581,9 @@ TEST_F(OutputLayerUpdateCompositionStateTest, mBufferTransform = ui::Transform::ROT_INVALID; - setupGeometryChildCallValues(); + setupGeometryChildCallValues(ui::Transform::RotationFlags::ROT_0); - mOutputLayer.updateCompositionState(true, false); + mOutputLayer.updateCompositionState(true, false, ui::Transform::RotationFlags::ROT_0); validateComputedGeometryState(); @@ -544,7 +598,7 @@ TEST_F(OutputLayerUpdateCompositionStateTest, setsOutputLayerColorspaceCorrectly // should use the layers requested colorspace. mLayerFEState.isColorspaceAgnostic = false; - mOutputLayer.updateCompositionState(false, false); + mOutputLayer.updateCompositionState(false, false, ui::Transform::RotationFlags::ROT_0); EXPECT_EQ(ui::Dataspace::DISPLAY_P3, mOutputLayer.getState().dataspace); @@ -552,7 +606,7 @@ TEST_F(OutputLayerUpdateCompositionStateTest, setsOutputLayerColorspaceCorrectly // should use the colorspace chosen for the whole output. mLayerFEState.isColorspaceAgnostic = true; - mOutputLayer.updateCompositionState(false, false); + mOutputLayer.updateCompositionState(false, false, ui::Transform::RotationFlags::ROT_0); EXPECT_EQ(ui::Dataspace::V0_SCRGB, mOutputLayer.getState().dataspace); } @@ -560,7 +614,7 @@ TEST_F(OutputLayerUpdateCompositionStateTest, setsOutputLayerColorspaceCorrectly TEST_F(OutputLayerUpdateCompositionStateTest, doesNotRecomputeGeometryIfNotRequested) { mOutputLayer.editState().forceClientComposition = false; - mOutputLayer.updateCompositionState(false, false); + mOutputLayer.updateCompositionState(false, false, ui::Transform::RotationFlags::ROT_0); EXPECT_EQ(false, mOutputLayer.getState().forceClientComposition); } @@ -569,7 +623,7 @@ TEST_F(OutputLayerUpdateCompositionStateTest, doesNotClearForceClientCompositionIfNotDoingGeometry) { mOutputLayer.editState().forceClientComposition = true; - mOutputLayer.updateCompositionState(false, false); + mOutputLayer.updateCompositionState(false, false, ui::Transform::RotationFlags::ROT_0); EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); } @@ -578,7 +632,7 @@ TEST_F(OutputLayerUpdateCompositionStateTest, clientCompositionForcedFromFrontEn mLayerFEState.forceClientComposition = true; mOutputLayer.editState().forceClientComposition = false; - mOutputLayer.updateCompositionState(false, false); + mOutputLayer.updateCompositionState(false, false, ui::Transform::RotationFlags::ROT_0); EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); } @@ -588,7 +642,7 @@ TEST_F(OutputLayerUpdateCompositionStateTest, mOutputLayer.editState().forceClientComposition = false; EXPECT_CALL(mDisplayColorProfile, isDataspaceSupported(_)).WillRepeatedly(Return(false)); - mOutputLayer.updateCompositionState(false, false); + mOutputLayer.updateCompositionState(false, false, ui::Transform::RotationFlags::ROT_0); EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); } @@ -597,15 +651,15 @@ TEST_F(OutputLayerUpdateCompositionStateTest, clientCompositionForcedFromArgumen mLayerFEState.forceClientComposition = false; mOutputLayer.editState().forceClientComposition = false; - mOutputLayer.updateCompositionState(false, true); + mOutputLayer.updateCompositionState(false, true, ui::Transform::RotationFlags::ROT_0); EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); mOutputLayer.editState().forceClientComposition = false; - setupGeometryChildCallValues(); + setupGeometryChildCallValues(ui::Transform::RotationFlags::ROT_0); - mOutputLayer.updateCompositionState(true, true); + mOutputLayer.updateCompositionState(true, true, ui::Transform::RotationFlags::ROT_0); EXPECT_EQ(true, mOutputLayer.getState().forceClientComposition); } @@ -810,7 +864,7 @@ TEST_F(OutputLayerTest, displayInstallOrientationBufferTransformSetTo90) { // geomBufferTransform is set to the inverse transform. mLayerFEState.geomBufferTransform = TR_ROT_270; - EXPECT_EQ(TR_IDENT, mOutputLayer.calculateOutputRelativeBufferTransform()); + EXPECT_EQ(TR_IDENT, mOutputLayer.calculateOutputRelativeBufferTransform(ui::Transform::ROT_90)); } TEST_F(OutputLayerWriteStateToHWCTest, canSetPerFrameStateForSolidColor) { diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp index 762d76c6ad..59ed72e928 100644 --- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp @@ -696,11 +696,11 @@ TEST_F(OutputUpdateAndWriteCompositionStateTest, updatesLayerContentForAllLayers InjectedLayer layer2; InjectedLayer layer3; - EXPECT_CALL(*layer1.outputLayer, updateCompositionState(false, false)); + EXPECT_CALL(*layer1.outputLayer, updateCompositionState(false, false, ui::Transform::ROT_180)); EXPECT_CALL(*layer1.outputLayer, writeStateToHWC(false)); - EXPECT_CALL(*layer2.outputLayer, updateCompositionState(false, false)); + EXPECT_CALL(*layer2.outputLayer, updateCompositionState(false, false, ui::Transform::ROT_180)); EXPECT_CALL(*layer2.outputLayer, writeStateToHWC(false)); - EXPECT_CALL(*layer3.outputLayer, updateCompositionState(false, false)); + EXPECT_CALL(*layer3.outputLayer, updateCompositionState(false, false, ui::Transform::ROT_180)); EXPECT_CALL(*layer3.outputLayer, writeStateToHWC(false)); injectOutputLayer(layer1); @@ -712,6 +712,7 @@ TEST_F(OutputUpdateAndWriteCompositionStateTest, updatesLayerContentForAllLayers CompositionRefreshArgs args; args.updatingGeometryThisFrame = false; args.devOptForceClientComposition = false; + args.internalDisplayRotationFlags = ui::Transform::ROT_180; mOutput->updateAndWriteCompositionState(args); } @@ -720,11 +721,11 @@ TEST_F(OutputUpdateAndWriteCompositionStateTest, updatesLayerGeometryAndContentF InjectedLayer layer2; InjectedLayer layer3; - EXPECT_CALL(*layer1.outputLayer, updateCompositionState(true, false)); + EXPECT_CALL(*layer1.outputLayer, updateCompositionState(true, false, ui::Transform::ROT_0)); EXPECT_CALL(*layer1.outputLayer, writeStateToHWC(true)); - EXPECT_CALL(*layer2.outputLayer, updateCompositionState(true, false)); + EXPECT_CALL(*layer2.outputLayer, updateCompositionState(true, false, ui::Transform::ROT_0)); EXPECT_CALL(*layer2.outputLayer, writeStateToHWC(true)); - EXPECT_CALL(*layer3.outputLayer, updateCompositionState(true, false)); + EXPECT_CALL(*layer3.outputLayer, updateCompositionState(true, false, ui::Transform::ROT_0)); EXPECT_CALL(*layer3.outputLayer, writeStateToHWC(true)); injectOutputLayer(layer1); @@ -744,11 +745,11 @@ TEST_F(OutputUpdateAndWriteCompositionStateTest, forcesClientCompositionForAllLa InjectedLayer layer2; InjectedLayer layer3; - EXPECT_CALL(*layer1.outputLayer, updateCompositionState(false, true)); + EXPECT_CALL(*layer1.outputLayer, updateCompositionState(false, true, ui::Transform::ROT_0)); EXPECT_CALL(*layer1.outputLayer, writeStateToHWC(false)); - EXPECT_CALL(*layer2.outputLayer, updateCompositionState(false, true)); + EXPECT_CALL(*layer2.outputLayer, updateCompositionState(false, true, ui::Transform::ROT_0)); EXPECT_CALL(*layer2.outputLayer, writeStateToHWC(false)); - EXPECT_CALL(*layer3.outputLayer, updateCompositionState(false, true)); + EXPECT_CALL(*layer3.outputLayer, updateCompositionState(false, true, ui::Transform::ROT_0)); EXPECT_CALL(*layer3.outputLayer, writeStateToHWC(false)); injectOutputLayer(layer1); @@ -3337,7 +3338,7 @@ struct OutputComposeSurfacesTest_SetsExpensiveRendering_ForBlur mLayer.layerFEState.backgroundBlurRadius = 10; mOutput.editState().isEnabled = true; - EXPECT_CALL(mLayer.outputLayer, updateCompositionState(false, true)); + EXPECT_CALL(mLayer.outputLayer, updateCompositionState(false, true, ui::Transform::ROT_0)); EXPECT_CALL(mLayer.outputLayer, writeStateToHWC(false)); EXPECT_CALL(mOutput, generateClientCompositionRequests(_, _, kDefaultOutputDataspace)) .WillOnce(Return(std::vector<LayerFE::LayerSettings>{})); @@ -3916,11 +3917,11 @@ TEST_F(OutputUpdateAndWriteCompositionStateTest, handlesBackgroundBlurRequests) InjectedLayer layer3; // Layer requesting blur, or below, should request client composition. - EXPECT_CALL(*layer1.outputLayer, updateCompositionState(false, true)); + EXPECT_CALL(*layer1.outputLayer, updateCompositionState(false, true, ui::Transform::ROT_0)); EXPECT_CALL(*layer1.outputLayer, writeStateToHWC(false)); - EXPECT_CALL(*layer2.outputLayer, updateCompositionState(false, true)); + EXPECT_CALL(*layer2.outputLayer, updateCompositionState(false, true, ui::Transform::ROT_0)); EXPECT_CALL(*layer2.outputLayer, writeStateToHWC(false)); - EXPECT_CALL(*layer3.outputLayer, updateCompositionState(false, false)); + EXPECT_CALL(*layer3.outputLayer, updateCompositionState(false, false, ui::Transform::ROT_0)); EXPECT_CALL(*layer3.outputLayer, writeStateToHWC(false)); layer2.layerFEState.backgroundBlurRadius = 10; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 4ca2074ad5..87e73a0e7a 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2047,6 +2047,7 @@ void SurfaceFlinger::onMessageRefresh() { refreshArgs.updatingOutputGeometryThisFrame = mVisibleRegionsDirty; refreshArgs.updatingGeometryThisFrame = mGeometryInvalid || mVisibleRegionsDirty; refreshArgs.blursAreExpensive = mBlursAreExpensive; + refreshArgs.internalDisplayRotationFlags = DisplayDevice::getPrimaryDisplayRotationFlags(); if (CC_UNLIKELY(mDrawingState.colorMatrixChanged)) { refreshArgs.colorTransformMatrix = mDrawingState.colorMatrix; |