More thorough check for expensive rendering
The intent of this check is to determine whether we need to do any color
conversion. For simplicity, we assumed we would need to do color
conversion if the display is P3. This isn't necessarily the case,
though; if all the input buffers are P3, we won't need color conversion.
And if the display is anything besides P3, we still may need it. Check
all the layers; if any does not match the outputDataspace, we will do
color conversion.
Bug: 221067687
Test: manual (logcat)
Test: jank tracking
Change-Id: I5c77769cf9fd2f07806c97022fa4bb940bfcc1ac
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index ff332eb..aef55d4 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -1112,8 +1112,12 @@
// because high frequency consumes extra battery.
const bool expensiveBlurs =
refreshArgs.blursAreExpensive && mLayerRequestingBackgroundBlur != nullptr;
- const bool expensiveRenderingExpected =
- clientCompositionDisplay.outputDataspace == ui::Dataspace::DISPLAY_P3 || expensiveBlurs;
+ const bool expensiveRenderingExpected = expensiveBlurs ||
+ std::any_of(clientCompositionLayers.begin(), clientCompositionLayers.end(),
+ [outputDataspace =
+ clientCompositionDisplay.outputDataspace](const auto& layer) {
+ return layer.sourceDataspace != outputDataspace;
+ });
if (expensiveRenderingExpected) {
setExpensiveRenderingExpected(true);
}