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

Commit 88b773e4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I136e2263,Idb7fd5a9

* changes:
  Don't wait for extra frame when changing configs.
  Fix up reference times for period changes.
parents 7c0ddb73 7ea0f7ea
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -76,9 +76,18 @@ public:
    void updateModel(nsecs_t period, nsecs_t phase, nsecs_t referenceTime) {
        if (mTraceDetailedInfo) ATRACE_CALL();
        Mutex::Autolock lock(mMutex);
        mPeriod = period;

        mPhase = phase;
        mReferenceTime = referenceTime;
        if (mPeriod != period && mReferenceTime != 0) {
            // Inflate the reference time to be the most recent predicted
            // vsync before the current time.
            const nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
            const nsecs_t baseTime = now - mReferenceTime;
            const nsecs_t numOldPeriods = baseTime / mPeriod;
            mReferenceTime = mReferenceTime + (numOldPeriods)*mPeriod;
        }
        mPeriod = period;
        if (mTraceDetailedInfo) {
            ATRACE_INT64("DispSync:Period", mPeriod);
            ATRACE_INT64("DispSync:Phase", mPhase + mPeriod / 2);
@@ -429,8 +438,16 @@ void DispSync::reset() {

void DispSync::resetLocked() {
    mPhase = 0;
    mReferenceTime = 0;
    const size_t lastSampleIdx = (mFirstResyncSample + mNumResyncSamples - 1) % MAX_RESYNC_SAMPLES;
    // Keep the most recent sample, when we resync to hardware we'll overwrite this
    // with a more accurate signal
    if (mResyncSamples[lastSampleIdx] != 0) {
        mReferenceTime = mResyncSamples[lastSampleIdx];
    }
    mModelUpdated = false;
    for (size_t i = 0; i < MAX_RESYNC_SAMPLES; i++) {
        mResyncSamples[i] = 0;
    }
    mNumResyncSamples = 0;
    mFirstResyncSample = 0;
    mNumResyncSamplesSincePresent = 0;
@@ -530,7 +547,6 @@ void DispSync::setPeriod(nsecs_t period) {
    Mutex::Autolock lock(mMutex);
    mPeriod = period;
    mPhase = 0;
    mReferenceTime = 0;
    mThread->updateModel(mPeriod, mPhase, mReferenceTime);
}

+1 −1
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ private:
    // These member variables are the state used during the resynchronization
    // process to store information about the hardware vsync event times used
    // to compute the model.
    nsecs_t mResyncSamples[MAX_RESYNC_SAMPLES];
    nsecs_t mResyncSamples[MAX_RESYNC_SAMPLES] = {0};
    size_t mFirstResyncSample;
    size_t mNumResyncSamples;
    int mNumResyncSamplesSincePresent;
+0 −10
Original line number Diff line number Diff line
@@ -986,15 +986,6 @@ void SurfaceFlinger::setActiveConfigInternal() {

bool SurfaceFlinger::performSetActiveConfig() NO_THREAD_SAFETY_ANALYSIS {
    ATRACE_CALL();
    // we may be in the process of changing the active state
    if (mWaitForNextInvalidate) {
        mWaitForNextInvalidate = false;

        repaintEverythingForHWC();
        // We do not want to give another frame to HWC while we are transitioning.
        return true;
    }

    if (mCheckPendingFence) {
        if (mPreviousPresentFence != Fence::NO_FENCE &&
            (mPreviousPresentFence->getStatus() == Fence::Status::Unsignaled)) {
@@ -1046,7 +1037,6 @@ bool SurfaceFlinger::performSetActiveConfig() NO_THREAD_SAFETY_ANALYSIS {
    getHwComposer().setActiveConfig(*displayId, mUpcomingActiveConfig.configId);

    // we need to submit an empty frame to HWC to start the process
    mWaitForNextInvalidate = true;
    mCheckPendingFence = true;

    return false;
+0 −1
Original line number Diff line number Diff line
@@ -1132,7 +1132,6 @@ private:

    // below flags are set by main thread only
    bool mDesiredActiveConfigChanged GUARDED_BY(mActiveConfigLock) = false;
    bool mWaitForNextInvalidate = false;
    bool mCheckPendingFence = false;

    /* ------------------------------------------------------------------------ */