[sf-newfe] Update layer history for invisible layers
Fixes a bug with new frontend where we were only updating
layer history for layers that has something to draw.
Cl also adds integration tests to validate frontend to
layerhistory path.
Test: LayerHistoryIntegrationTest
Fixes: 300701739
Change-Id: I223b4817bdf9909e3890de0b5051bc0ff345f829
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 5ae2999..33d1eeb 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1267,7 +1267,8 @@
return parentFrameRate;
}();
- *transactionNeeded |= setFrameRateForLayerTreeLegacy(frameRate);
+ auto now = systemTime();
+ *transactionNeeded |= setFrameRateForLayerTreeLegacy(frameRate, now);
// The frame rate is propagated to the children
bool childrenHaveFrameRate = false;
@@ -1283,7 +1284,8 @@
// layer as NoVote to allow the children to control the refresh rate
if (!frameRate.isValid() && childrenHaveFrameRate) {
*transactionNeeded |=
- setFrameRateForLayerTreeLegacy(FrameRate(Fps(), FrameRateCompatibility::NoVote));
+ setFrameRateForLayerTreeLegacy(FrameRate(Fps(), FrameRateCompatibility::NoVote),
+ now);
}
// We return whether this layer or its children has a vote. We ignore ExactOrMultiple votes for
@@ -1492,7 +1494,7 @@
addSurfaceFrameDroppedForBuffer(surfaceFrame, postTime);
}
-bool Layer::setFrameRateForLayerTreeLegacy(FrameRate frameRate) {
+bool Layer::setFrameRateForLayerTreeLegacy(FrameRate frameRate, nsecs_t now) {
if (mDrawingState.frameRateForLayerTree == frameRate) {
return false;
}
@@ -1506,19 +1508,20 @@
setTransactionFlags(eTransactionNeeded);
mFlinger->mScheduler
- ->recordLayerHistory(sequence, getLayerProps(), systemTime(),
+ ->recordLayerHistory(sequence, getLayerProps(), now, now,
scheduler::LayerHistory::LayerUpdateType::SetFrameRate);
return true;
}
-bool Layer::setFrameRateForLayerTree(FrameRate frameRate, const scheduler::LayerProps& layerProps) {
+bool Layer::setFrameRateForLayerTree(FrameRate frameRate, const scheduler::LayerProps& layerProps,
+ nsecs_t now) {
if (mDrawingState.frameRateForLayerTree == frameRate) {
return false;
}
mDrawingState.frameRateForLayerTree = frameRate;
mFlinger->mScheduler
- ->recordLayerHistory(sequence, layerProps, systemTime(),
+ ->recordLayerHistory(sequence, layerProps, now, now,
scheduler::LayerHistory::LayerUpdateType::SetFrameRate);
return true;
}
@@ -3225,7 +3228,7 @@
mOwnerUid, postTime, getGameMode());
if (mFlinger->mLegacyFrontEndEnabled) {
- recordLayerHistoryBufferUpdate(getLayerProps());
+ recordLayerHistoryBufferUpdate(getLayerProps(), systemTime());
}
setFrameTimelineVsyncForBufferTransaction(info, postTime);
@@ -3256,7 +3259,7 @@
mDrawingState.isAutoTimestamp = isAutoTimestamp;
}
-void Layer::recordLayerHistoryBufferUpdate(const scheduler::LayerProps& layerProps) {
+void Layer::recordLayerHistoryBufferUpdate(const scheduler::LayerProps& layerProps, nsecs_t now) {
ATRACE_CALL();
const nsecs_t presentTime = [&] {
if (!mDrawingState.isAutoTimestamp) {
@@ -3310,14 +3313,14 @@
ATRACE_FORMAT_INSTANT("presentIn %s", to_string(presentIn).c_str());
}
- mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime,
+ mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime, now,
scheduler::LayerHistory::LayerUpdateType::Buffer);
}
-void Layer::recordLayerHistoryAnimationTx(const scheduler::LayerProps& layerProps) {
+void Layer::recordLayerHistoryAnimationTx(const scheduler::LayerProps& layerProps, nsecs_t now) {
const nsecs_t presentTime =
mDrawingState.isAutoTimestamp ? 0 : mDrawingState.desiredPresentTime;
- mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime,
+ mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime, now,
scheduler::LayerHistory::LayerUpdateType::AnimationTX);
}