diff options
author | 2021-05-07 15:10:42 -0700 | |
---|---|---|
committer | 2021-05-13 23:10:21 +0000 | |
commit | 562c2718fcf8f465fe54a88c7ac948cd21a77ce5 (patch) | |
tree | 5301119a29366d8c8a71f3e1e525f75e9f597a17 /services/surfaceflinger/SurfaceFlinger.cpp | |
parent | b5d3afa06ccf11f9f78026d946468818a65cec76 (diff) |
SF: region sampling scheduling optimization
Schedule the region sampling thread more wisely by estimating when
the next invalidate is going to happen. This makes the region sampling
to be scheduled often at times where the main thread is idle, without
eating the budget in an invalidate message.
Bug: 181983990
Test: SF unit tests
Test: observe systrace
Change-Id: I1faca3aa7f882ed7c69e77e6a0877c10d57f0f1c
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 267dd6d9d0..41aacc0ab7 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1909,6 +1909,7 @@ void SurfaceFlinger::onMessageInvalidate(int64_t vsyncId, nsecs_t expectedVSyncT mRefreshPending = true; onMessageRefresh(); } + notifyRegionSamplingThread(); } bool SurfaceFlinger::handleMessageTransaction() { @@ -2311,10 +2312,6 @@ void SurfaceFlinger::postComposition() { } } - if (mLumaSampling && mRegionSamplingThread) { - mRegionSamplingThread->notifyNewContent(); - } - // Even though ATRACE_INT64 already checks if tracing is enabled, it doesn't prevent the // side-effect of getTotalSize(), so we check that again here if (ATRACE_ENABLED()) { @@ -3067,8 +3064,7 @@ void SurfaceFlinger::initScheduler(const DisplayDeviceState& displayState) { configs.late.sfWorkDuration); mRegionSamplingThread = - new RegionSamplingThread(*this, *mScheduler, - RegionSamplingThread::EnvironmentTimingTunables()); + new RegionSamplingThread(*this, RegionSamplingThread::EnvironmentTimingTunables()); mFpsReporter = new FpsReporter(*mFrameTimeline, *this); // Dispatch a mode change request for the primary display on scheduler // initialization, so that the EventThreads always contain a reference to a @@ -6752,6 +6748,19 @@ sp<Layer> SurfaceFlinger::handleLayerCreatedLocked(const sp<IBinder>& handle, bo return layer; } + +void SurfaceFlinger::scheduleRegionSamplingThread() { + static_cast<void>(schedule([&] { notifyRegionSamplingThread(); })); +} + +void SurfaceFlinger::notifyRegionSamplingThread() { + if (!mLumaSampling || !mRegionSamplingThread) { + return; + } + + mRegionSamplingThread->onCompositionComplete(mEventQueue->nextExpectedInvalidate()); +} + } // namespace android #if defined(__gl_h_) |