SF: Move/Refactor calculateWorkingSet to CompositionEngine
The functionality is made part of CompositionEngine::present()
Test: atest libsurfaceflinger_unittest libcompositionengine_test
Bug: 121291683
Change-Id: I0eb74f9fe8421468fbc1048aec23d7c91ce4f302
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index e0d1609..34981ae 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1794,6 +1794,15 @@
: compositionengine::OutputColorSetting::kUnmanaged;
refreshArgs.colorSpaceAgnosticDataspace = mColorSpaceAgnosticDataspace;
refreshArgs.forceOutputColorMode = mForceColorMode;
+ refreshArgs.updatingGeometryThisFrame = mGeometryInvalid;
+
+ if (CC_UNLIKELY(mDrawingState.colorMatrixChanged)) {
+ refreshArgs.colorTransformMatrix = mDrawingState.colorMatrix;
+ mDrawingState.colorMatrixChanged = false;
+ }
+
+ refreshArgs.devOptForceClientComposition = mDebugDisableHWC || mDebugRegion;
+
if (mDebugRegion != 0) {
refreshArgs.devOptFlashDirtyRegionsDelay =
std::chrono::milliseconds(mDebugRegion > 1 ? mDebugRegion : 0);
@@ -1801,9 +1810,11 @@
mCompositionEngine->preComposition(refreshArgs);
rebuildLayerStacks();
- calculateWorkingSet(refreshArgs);
+ refreshArgs.updatingGeometryThisFrame = mGeometryInvalid; // Can be set by rebuildLayerStacks()
mCompositionEngine->present(refreshArgs);
+ mGeometryInvalid = false;
+
postFrame();
postComposition();
@@ -1851,68 +1862,6 @@
return refreshNeeded;
}
-void SurfaceFlinger::calculateWorkingSet(
- const compositionengine::CompositionRefreshArgs& refreshArgs) {
- ATRACE_CALL();
- ALOGV(__FUNCTION__);
-
- const bool updatingGeometryThisFrame = mGeometryInvalid;
- mGeometryInvalid = false;
-
- // Latch the frontend layer composition state for each layer being
- // composed.
- for (const auto& [token, displayDevice] : mDisplays) {
- auto display = displayDevice->getCompositionDisplay();
- for (auto& layer : display->getOutputLayersOrderedByZ()) {
- layer->getLayerFE().latchCompositionState(layer->getLayer().editState().frontEnd,
- updatingGeometryThisFrame);
- }
- }
-
- if (CC_UNLIKELY(updatingGeometryThisFrame)) {
- for (const auto& [token, displayDevice] : mDisplays) {
- auto display = displayDevice->getCompositionDisplay();
- uint32_t zOrder = 0;
-
- for (auto& layer : display->getOutputLayersOrderedByZ()) {
- // Assign a simple Z order sequence to each visible layer.
- layer->editState().z = zOrder++;
- }
- }
- }
-
- // Determine the color configuration of each output
- for (const auto& [token, displayDevice] : mDisplays) {
- auto display = displayDevice->getCompositionDisplay();
- display->updateColorProfile(refreshArgs);
- }
-
- for (const auto& [token, displayDevice] : mDisplays) {
- auto display = displayDevice->getCompositionDisplay();
-
- for (auto& layer : display->getOutputLayersOrderedByZ()) {
- if (mDebugDisableHWC || mDebugRegion) {
- layer->editState().forceClientComposition = true;
- }
-
- // Update the composition state of the output layer, as needed
- // recomputing it from the state given by the front-end layer.
- layer->updateCompositionState(updatingGeometryThisFrame);
-
- // Send the updated state to the HWC, if appropriate.
- layer->writeStateToHWC(updatingGeometryThisFrame);
- }
- }
-
- if (CC_UNLIKELY(mDrawingState.colorMatrixChanged)) {
- for (const auto& [token, displayDevice] : mDisplays) {
- auto display = displayDevice->getCompositionDisplay();
- display->setColorTransform(mDrawingState.colorMatrix);
- }
- mDrawingState.colorMatrixChanged = false;
- }
-}
-
void SurfaceFlinger::updateCompositorTiming(const DisplayStatInfo& stats, nsecs_t compositeTime,
std::shared_ptr<FenceTime>& presentFenceTime) {
// Update queue of past composite+present times and determine the