Change small area detection to support new front end design
This will still use legacy layer to calculate the small dirty, and
update the info to the LayerSnapshot.
Also fix some issues in setIsSmallDirty() for
1. Set mSmallDirty flag as false if the surface damage region is
invalid.
2. Apply the scaling to the damage region before dirty area
calculations.
Bug: 295062543
Bug: 303258910
Bug: 303609027
Test: atest LayerHistoryTest
Test: atest SmallAreaDetectionTest
Change-Id: Ib0e3737e63b5653422b5b5054b893578dc63f768
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index b13c0e8..181a9bf 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2211,8 +2211,29 @@
continue;
}
- if (!snapshot->changes.any(Changes::FrameRate | Changes::Buffer | Changes::Animation) &&
- (snapshot->clientChanges & layer_state_t::eDefaultFrameRateCompatibilityChanged) == 0) {
+ const bool updateSmallDirty = mScheduler->supportSmallDirtyDetection() &&
+ ((snapshot->clientChanges & layer_state_t::eSurfaceDamageRegionChanged) ||
+ snapshot->changes.any(Changes::Geometry));
+
+ const bool hasChanges =
+ snapshot->changes.any(Changes::FrameRate | Changes::Buffer | Changes::Animation) ||
+ (snapshot->clientChanges & layer_state_t::eDefaultFrameRateCompatibilityChanged) !=
+ 0;
+
+ if (!updateSmallDirty && !hasChanges) {
+ continue;
+ }
+
+ auto it = mLegacyLayers.find(snapshot->sequence);
+ LOG_ALWAYS_FATAL_IF(it == mLegacyLayers.end(), "Couldn't find layer object for %s",
+ snapshot->getDebugString().c_str());
+
+ if (updateSmallDirty) {
+ // Update small dirty flag while surface damage region or geometry changed
+ it->second->setIsSmallDirty(snapshot.get());
+ }
+
+ if (!hasChanges) {
continue;
}
@@ -2222,12 +2243,9 @@
.transform = snapshot->geomLayerTransform,
.setFrameRateVote = snapshot->frameRate,
.frameRateSelectionPriority = snapshot->frameRateSelectionPriority,
+ .isSmallDirty = snapshot->isSmallDirty,
};
- auto it = mLegacyLayers.find(snapshot->sequence);
- LOG_ALWAYS_FATAL_IF(it == mLegacyLayers.end(), "Couldnt find layer object for %s",
- snapshot->getDebugString().c_str());
-
if (snapshot->clientChanges & layer_state_t::eDefaultFrameRateCompatibilityChanged) {
mScheduler->setDefaultFrameRateCompatibility(snapshot->sequence,
snapshot->defaultFrameRateCompatibility);
@@ -8492,15 +8510,6 @@
void SurfaceFlinger::onActiveDisplaySizeChanged(const DisplayDevice& activeDisplay) {
mScheduler->onActiveDisplayAreaChanged(activeDisplay.getWidth() * activeDisplay.getHeight());
getRenderEngine().onActiveDisplaySizeChanged(activeDisplay.getSize());
-
- // Notify layers to update small dirty flag.
- if (mScheduler->supportSmallDirtyDetection()) {
- mCurrentState.traverse([&](Layer* layer) {
- if (layer->getLayerStack() == activeDisplay.getLayerStack()) {
- layer->setIsSmallDirty();
- }
- });
- }
}
sp<DisplayDevice> SurfaceFlinger::getActivatableDisplay() const {