diff options
| -rw-r--r-- | services/surfaceflinger/CompositionEngine/src/Output.cpp | 8 | ||||
| -rw-r--r-- | services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp | 17 |
2 files changed, 19 insertions, 6 deletions
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp index 2893031ad9..01b5781987 100644 --- a/services/surfaceflinger/CompositionEngine/src/Output.cpp +++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp @@ -89,14 +89,14 @@ void Output::setLayerStackFilter(uint32_t layerStackId, bool isInternal) { } void Output::setColorTransform(const mat4& transform) { + if (mState.colorTransformMat == transform) { + return; + } + const bool isIdentity = (transform == mat4()); const auto newColorTransform = isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY : HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX; - if (mState.colorTransform == newColorTransform) { - return; - } - mState.colorTransform = newColorTransform; mState.colorTransformMat = transform; diff --git a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp index a84af3a82f..fee0c11e25 100644 --- a/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp +++ b/services/surfaceflinger/CompositionEngine/tests/OutputTest.cpp @@ -172,16 +172,29 @@ TEST_F(OutputTest, setColorTransformSetsTransform) { mOutput.setColorTransform(identity); EXPECT_EQ(HAL_COLOR_TRANSFORM_IDENTITY, mOutput.getState().colorTransform); + EXPECT_EQ(identity, mOutput.getState().colorTransformMat); // Since identity is the default, the dirty region should be unchanged (empty) EXPECT_THAT(mOutput.getState().dirtyRegion, RegionEq(Region())); // Non-identity matrix sets a non-identity state value - const mat4 nonIdentity = mat4() * 2; + const mat4 nonIdentityHalf = mat4() * 0.5; - mOutput.setColorTransform(nonIdentity); + mOutput.setColorTransform(nonIdentityHalf); EXPECT_EQ(HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX, mOutput.getState().colorTransform); + EXPECT_EQ(nonIdentityHalf, mOutput.getState().colorTransformMat); + + // Since this is a state change, the entire output should now be dirty. + EXPECT_THAT(mOutput.getState().dirtyRegion, RegionEq(Region(kDefaultDisplaySize))); + + // Non-identity matrix sets a non-identity state value + const mat4 nonIdentityQuarter = mat4() * 0.25; + + mOutput.setColorTransform(nonIdentityQuarter); + + EXPECT_EQ(HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX, mOutput.getState().colorTransform); + EXPECT_EQ(nonIdentityQuarter, mOutput.getState().colorTransformMat); // Since this is a state change, the entire output should now be dirty. EXPECT_THAT(mOutput.getState().dirtyRegion, RegionEq(Region(kDefaultDisplaySize))); |