Avoid calling into HWC in onFirstRef
The information is already available - no need to call into HWC.
This saved around 150-200us per onFirstRef call.
Test: atest UiAutomationTest#testWindowContentFrameStats
Test: PerfTransitionTest
Test: LayerTypeTransactionTest#RefreshRateIsInitialized
Bug: 112352758
Change-Id: I406754d33d53d6c60e354f5a403f1d5568f714c4
Merged-In: I406754d33d53d6c60e354f5a403f1d5568f714c4
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 90e0e9e..0caac9b 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -133,22 +133,7 @@
CompositorTiming compositorTiming;
flinger->getCompositorTiming(&compositorTiming);
mFrameEventHistory.initializeCompositorTiming(compositorTiming);
-}
-
-void Layer::onFirstRef() NO_THREAD_SAFETY_ANALYSIS {
- if (!isCreatedFromMainThread()) {
- // Grab the SF state lock during this since it's the only way to safely access HWC
- mFlinger->mStateLock.lock();
- }
-
- const auto& hwc = mFlinger->getHwComposer();
- const auto& activeConfig = hwc.getActiveConfig(HWC_DISPLAY_PRIMARY);
- nsecs_t displayPeriod = activeConfig->getVsyncPeriod();
- mFrameTracker.setDisplayRefreshPeriod(displayPeriod);
-
- if (!isCreatedFromMainThread()) {
- mFlinger->mStateLock.unlock();
- }
+ mFrameTracker.setDisplayRefreshPeriod(compositorTiming.interval);
}
Layer::~Layer() {
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 2239679..301f190 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -618,8 +618,6 @@
: mFlinger(flinger), mLayer(layer) {}
};
- virtual void onFirstRef();
-
friend class impl::SurfaceInterceptor;
void commitTransaction(const State& stateToCommit);