Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd6480f7 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

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
parent 09cb30e3
Loading
Loading
Loading
Loading
+1 −16
Original line number Diff line number Diff line
@@ -132,22 +132,7 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n
    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() {
+0 −2
Original line number Diff line number Diff line
@@ -604,8 +604,6 @@ protected:
              : mFlinger(flinger), mLayer(layer) {}
    };

    virtual void onFirstRef();

    friend class impl::SurfaceInterceptor;

    void commitTransaction(const State& stateToCommit);