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

Commit 98153bca authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5656431 from 0cc91e5d to qt-qpr1-release

Change-Id: Ie8ee49f61c8958a2115cac07cf52b880390ea145
parents 3a088212 0cc91e5d
Loading
Loading
Loading
Loading
+8 −20
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ public:
        mPeriod = period;
        if (!mModelLocked && referenceTimeChanged) {
            for (auto& eventListener : mEventListeners) {
                eventListener.mHasFired = false;
                eventListener.mLastEventTime =
                        mReferenceTime - mPeriod + mPhase + eventListener.mPhase;
            }
@@ -123,13 +122,6 @@ public:

    void unlockModel() {
        Mutex::Autolock lock(mMutex);
        if (mModelLocked) {
            for (auto& eventListener : mEventListeners) {
                if (eventListener.mLastEventTime > mReferenceTime) {
                    eventListener.mHasFired = true;
                }
            }
        }
        mModelLocked = false;
        ATRACE_INT("DispSync:ModelLocked", mModelLocked);
    }
@@ -259,10 +251,6 @@ public:
            listener.mLastCallbackTime = lastCallbackTime;
        }

        if (!mModelLocked && listener.mLastEventTime > mReferenceTime) {
            listener.mHasFired = true;
        }

        mEventListeners.push_back(listener);

        mCond.signal();
@@ -305,7 +293,14 @@ public:
                } else if (diff < -mPeriod / 2) {
                    diff += mPeriod;
                }

                if (phase < 0 && oldPhase > 0) {
                    diff += mPeriod;
                } else if (phase > 0 && oldPhase < 0) {
                    diff -= mPeriod;
                }
                eventListener.mLastEventTime -= diff;
                eventListener.mLastCallbackTime -= diff;
                mCond.signal();
                return NO_ERROR;
            }
@@ -320,7 +315,6 @@ private:
        nsecs_t mLastEventTime;
        nsecs_t mLastCallbackTime;
        DispSync::Callback* mCallback;
        bool mHasFired = false;
    };

    struct CallbackInvocation {
@@ -368,12 +362,7 @@ private:
                          eventListener.mName);
                    continue;
                }
                if (eventListener.mHasFired && !mModelLocked) {
                    eventListener.mLastEventTime = t;
                    ALOGV("[%s] [%s] Skipping event due to already firing", mName,
                          eventListener.mName);
                    continue;
                }

                CallbackInvocation ci;
                ci.mCallback = eventListener.mCallback;
                ci.mEventTime = t;
@@ -382,7 +371,6 @@ private:
                callbackInvocations.push_back(ci);
                eventListener.mLastEventTime = t;
                eventListener.mLastCallbackTime = now;
                eventListener.mHasFired = true;
            }
        }

+12 −10
Original line number Diff line number Diff line
@@ -27,14 +27,16 @@

namespace android {

DispSyncSource::DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset, bool traceVsync,
DispSyncSource::DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset,
                               nsecs_t offsetThresholdForNextVsync, bool traceVsync,
                               const char* name)
      : mName(name),
        mTraceVsync(traceVsync),
        mVsyncOnLabel(base::StringPrintf("VsyncOn-%s", name)),
        mVsyncEventLabel(base::StringPrintf("VSYNC-%s", name)),
        mDispSync(dispSync),
        mPhaseOffset(phaseOffset) {}
        mPhaseOffset(phaseOffset),
        mOffsetThresholdForNextVsync(offsetThresholdForNextVsync) {}

void DispSyncSource::setVSyncEnabled(bool enable) {
    std::lock_guard lock(mVsyncMutex);
@@ -64,15 +66,15 @@ void DispSyncSource::setCallback(VSyncSource::Callback* callback) {

void DispSyncSource::setPhaseOffset(nsecs_t phaseOffset) {
    std::lock_guard lock(mVsyncMutex);

    // Normalize phaseOffset to [0, period)
    auto period = mDispSync->getPeriod();
    phaseOffset %= period;
    if (phaseOffset < 0) {
        // If we're here, then phaseOffset is in (-period, 0). After this
        // operation, it will be in (0, period)
        phaseOffset += period;
    const nsecs_t period = mDispSync->getPeriod();
    // Check if offset should be handled as negative
    if (phaseOffset >= mOffsetThresholdForNextVsync) {
        phaseOffset -= period;
    }

    // Normalize phaseOffset to [-period, period)
    const int numPeriods = phaseOffset / period;
    phaseOffset -= numPeriods * period;
    mPhaseOffset = phaseOffset;

    // If we're not enabled, we don't need to mess with the listeners
+3 −1
Original line number Diff line number Diff line
@@ -25,7 +25,8 @@ namespace android {

class DispSyncSource final : public VSyncSource, private DispSync::Callback {
public:
    DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset, bool traceVsync, const char* name);
    DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset, nsecs_t offsetThresholdForNextVsync,
                   bool traceVsync, const char* name);

    ~DispSyncSource() override = default;

@@ -53,6 +54,7 @@ private:

    std::mutex mVsyncMutex;
    nsecs_t mPhaseOffset GUARDED_BY(mVsyncMutex);
    const nsecs_t mOffsetThresholdForNextVsync;
    bool mEnabled GUARDED_BY(mVsyncMutex) = false;
};

+13 −0
Original line number Diff line number Diff line
@@ -173,5 +173,18 @@ void LayerHistory::removeIrrelevantLayers() {
    }
}

void LayerHistory::clearHistory() {
    std::lock_guard lock(mLock);

    auto it = mActiveLayerInfos.begin();
    while (it != mActiveLayerInfos.end()) {
        auto id = it->first;
        auto layerInfo = it->second;
        layerInfo->clearHistory();
        mInactiveLayerInfos.insert({id, layerInfo});
        it = mActiveLayerInfos.erase(it);
    }
}

} // namespace scheduler
} // namespace android
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ public:
    // layers. See go/content-fps-detection-in-scheduler for more information.
    std::pair<float, bool> getDesiredRefreshRateAndHDR();

    // Clears all layer history.
    void clearHistory();

    // Removes the handle and the object from the map.
    void destroyLayer(const int64_t id);

Loading