diff options
author | 2023-12-04 03:37:44 +0000 | |
---|---|---|
committer | 2023-12-04 03:37:44 +0000 | |
commit | b51a073a2968fb60624f4e000d2f8729d85cf0b9 (patch) | |
tree | 51496ed68e81d45c9968e2c9e3b73587c04e3e13 | |
parent | 90a50a830ff2cad9d8170d7e4e8be1574181669e (diff) | |
parent | 3667800c553fddb1627b455d2cb0d32c258d2085 (diff) |
Merge "SF: guard texture view update tolerance logic with small area allow list" into main
7 files changed, 13 insertions, 12 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 949a161a35..f7800bb485 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -3264,7 +3264,7 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer, // If the layer had been updated a TextureView, this would make sure the present time could be // same to TextureView update when it's a small dirty, and get the correct heuristic rate. - if (mFlinger->mScheduler->supportSmallDirtyDetection()) { + if (mFlinger->mScheduler->supportSmallDirtyDetection(mOwnerAppId)) { if (mDrawingState.useVsyncIdForRefreshRateSelection) { mUsedVsyncIdForRefreshRateSelection = true; } @@ -3297,7 +3297,7 @@ void Layer::recordLayerHistoryBufferUpdate(const scheduler::LayerProps& layerPro } } - if (!mFlinger->mScheduler->supportSmallDirtyDetection()) { + if (!mFlinger->mScheduler->supportSmallDirtyDetection(mOwnerAppId)) { return static_cast<nsecs_t>(0); } @@ -4440,7 +4440,7 @@ void Layer::updateLastLatchTime(nsecs_t latchTime) { void Layer::setIsSmallDirty(const Region& damageRegion, const ui::Transform& layerToDisplayTransform) { mSmallDirty = false; - if (!mFlinger->mScheduler->supportSmallDirtyDetection()) { + if (!mFlinger->mScheduler->supportSmallDirtyDetection(mOwnerAppId)) { return; } diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp index b91985e889..aa8d54d69e 100644 --- a/services/surfaceflinger/Scheduler/Scheduler.cpp +++ b/services/surfaceflinger/Scheduler/Scheduler.cpp @@ -1248,7 +1248,7 @@ void Scheduler::updateSmallAreaDetection( } void Scheduler::setSmallAreaDetectionThreshold(int32_t appId, float threshold) { - mSmallAreaDetectionAllowMappings.setThesholdForAppId(appId, threshold); + mSmallAreaDetectionAllowMappings.setThresholdForAppId(appId, threshold); } bool Scheduler::isSmallDirtyArea(int32_t appId, uint32_t dirtyArea) { diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h index 65470480af..454ef83632 100644 --- a/services/surfaceflinger/Scheduler/Scheduler.h +++ b/services/surfaceflinger/Scheduler/Scheduler.h @@ -323,9 +323,10 @@ public: bool updateFrameRateOverrides(GlobalSignals, Fps displayRefreshRate) EXCLUDES(mPolicyLock); - // Returns true if the small dirty detection is enabled. - bool supportSmallDirtyDetection() const { - return mFeatures.test(Feature::kSmallDirtyContentDetection); + // Returns true if the small dirty detection is enabled for the appId. + bool supportSmallDirtyDetection(int32_t appId) { + return mFeatures.test(Feature::kSmallDirtyContentDetection) && + mSmallAreaDetectionAllowMappings.getThresholdForAppId(appId).has_value(); } // Injects a delay that is a fraction of the predicted frame duration for the next frame. diff --git a/services/surfaceflinger/Scheduler/SmallAreaDetectionAllowMappings.cpp b/services/surfaceflinger/Scheduler/SmallAreaDetectionAllowMappings.cpp index 38c6da48f6..7510ebf2df 100644 --- a/services/surfaceflinger/Scheduler/SmallAreaDetectionAllowMappings.cpp +++ b/services/surfaceflinger/Scheduler/SmallAreaDetectionAllowMappings.cpp @@ -29,7 +29,7 @@ void SmallAreaDetectionAllowMappings::update( } } -void SmallAreaDetectionAllowMappings::setThesholdForAppId(int32_t appId, float threshold) { +void SmallAreaDetectionAllowMappings::setThresholdForAppId(int32_t appId, float threshold) { if (!isValidThreshold(threshold)) return; std::lock_guard lock(mLock); diff --git a/services/surfaceflinger/Scheduler/SmallAreaDetectionAllowMappings.h b/services/surfaceflinger/Scheduler/SmallAreaDetectionAllowMappings.h index e10301c1e8..4ec5e3b5e4 100644 --- a/services/surfaceflinger/Scheduler/SmallAreaDetectionAllowMappings.h +++ b/services/surfaceflinger/Scheduler/SmallAreaDetectionAllowMappings.h @@ -28,7 +28,7 @@ class SmallAreaDetectionAllowMappings { public: void update(std::vector<std::pair<int32_t, float>>& appIdThresholdMappings); - void setThesholdForAppId(int32_t appId, float threshold) EXCLUDES(mLock); + void setThresholdForAppId(int32_t appId, float threshold) EXCLUDES(mLock); std::optional<float> getThresholdForAppId(int32_t uid) EXCLUDES(mLock); private: diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 2f7ff5db3e..848cbb511b 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2217,7 +2217,7 @@ void SurfaceFlinger::updateLayerHistory(nsecs_t now) { continue; } - const bool updateSmallDirty = mScheduler->supportSmallDirtyDetection() && + const bool updateSmallDirty = FlagManager::getInstance().enable_small_area_detection() && ((snapshot->clientChanges & layer_state_t::eSurfaceDamageRegionChanged) || snapshot->changes.any(Changes::Geometry)); diff --git a/services/surfaceflinger/tests/unittests/SmallAreaDetectionAllowMappingsTest.cpp b/services/surfaceflinger/tests/unittests/SmallAreaDetectionAllowMappingsTest.cpp index 05f9eed30b..8615035483 100644 --- a/services/surfaceflinger/tests/unittests/SmallAreaDetectionAllowMappingsTest.cpp +++ b/services/surfaceflinger/tests/unittests/SmallAreaDetectionAllowMappingsTest.cpp @@ -44,8 +44,8 @@ TEST_F(SmallAreaDetectionAllowMappingsTest, testUpdate) { ASSERT_EQ(mMappings.getThresholdForAppId(kAppId2).value(), kThreshold2); } -TEST_F(SmallAreaDetectionAllowMappingsTest, testSetThesholdForAppId) { - mMappings.setThesholdForAppId(kAppId1, kThreshold1); +TEST_F(SmallAreaDetectionAllowMappingsTest, testSetThresholdForAppId) { + mMappings.setThresholdForAppId(kAppId1, kThreshold1); ASSERT_EQ(mMappings.getThresholdForAppId(kAppId1), kThreshold1); } |