SurfaceFlinger: Fix check for ignoring a new color transform
Output::setColorTransform() was trying to detect whether the input value
was actually different from the current value before accepting it and
marking the display as dirty.
The update check was based on how the code originally worked --
distilling the transform down to a HAL_COLOR_TRANSFORM_XXX constant
based on whether the matrix was identity or not.
The code was since changed to actually store the actual value of the
matrix, for use when client composition is used, but that meant that if
the current value was a non-identity matrix, and a DIFFERENT
non-identity matrix was set, the new setting was incorrectly rejected.
The fix is just to do an equality check on the entire matrix rather than
on the distilled value.
And since this function is covered by a unit test, I made additions to
the test to make sure that the failure would be detected should the
logic change again.
Bug: 131571679
Test: atest libcompositionengine_test
Test: Repro steps from bug
Change-Id: I73291ab1f3fbf987353ed59439baf2b4ad5fab33
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 2893031..01b5781 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -89,14 +89,14 @@
}
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;