Allow child layers to inherit color transform from their parent
The current implementation only uses the current layers color transform.
However, with the hierarchy structure, children should also inherit the color
transform set on their parent.
Test: SetColorTransformOnParent, SetColorTransformOnChildAndParent
Bug: 117408368
Change-Id: Ica539cefcde92203dd9ead0a732ee44a16978be0
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index c9c0a5c..7b681ea 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1685,12 +1685,20 @@
return true;
}
-const mat4& Layer::getColorTransform() const {
- return getDrawingState().colorTransform;
+mat4 Layer::getColorTransform() const {
+ mat4 colorTransform = mat4(getDrawingState().colorTransform);
+ if (sp<Layer> parent = mDrawingParent.promote(); parent != nullptr) {
+ colorTransform = parent->getColorTransform() * colorTransform;
+ }
+ return colorTransform;
}
bool Layer::hasColorTransform() const {
- return getDrawingState().hasColorTransform;
+ bool hasColorTransform = getDrawingState().hasColorTransform;
+ if (sp<Layer> parent = mDrawingParent.promote(); parent != nullptr) {
+ hasColorTransform = hasColorTransform || parent->hasColorTransform();
+ }
+ return hasColorTransform;
}
bool Layer::isLegacyDataSpace() const {