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

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

Merge changes from topic "b:140112642:4" into qt-surfaceflinger-dev

* changes:
  SF: Don't bump to PERFORMANCE refresh rate with infrequent updates
  SurfaceFlinger: DispSync: negative offsets when model is unlocked
  [SurfaceFlinger] Store current offsets in VSyncModulator.
  [SurfaceFlinger] Add vsync offset information to systrace.
  [SurfaceFlinger] Split VSyncModulator into .cpp/.h files
parents da65c5c1 9f10eb9c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -149,9 +149,10 @@ filegroup {
        "Scheduler/LayerHistory.cpp",
        "Scheduler/LayerInfo.cpp",
        "Scheduler/MessageQueue.cpp",
        "Scheduler/PhaseOffsets.cpp",
        "Scheduler/Scheduler.cpp",
        "Scheduler/SchedulerUtils.cpp",
        "Scheduler/PhaseOffsets.cpp",
        "Scheduler/VSyncModulator.cpp",
        "StartPropertySetThread.cpp",
        "SurfaceFlinger.cpp",
        "SurfaceInterceptor.cpp",
+6 −2
Original line number Diff line number Diff line
@@ -92,8 +92,12 @@ public:
        mPeriod = period;
        if (!mModelLocked && referenceTimeChanged) {
            for (auto& eventListener : mEventListeners) {
                eventListener.mLastEventTime =
                        mReferenceTime - mPeriod + mPhase + eventListener.mPhase;
                eventListener.mLastEventTime = mReferenceTime + mPhase + eventListener.mPhase;
                // If mLastEventTime is after mReferenceTime (can happen when positive phase offsets
                // are used) we treat it as like it happened in previous period.
                if (eventListener.mLastEventTime > mReferenceTime) {
                    eventListener.mLastEventTime -= mPeriod;
                }
            }
        }
        if (mTraceDetailedInfo) {
+19 −5
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ DispSyncSource::DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset,
        mTraceVsync(traceVsync),
        mVsyncOnLabel(base::StringPrintf("VsyncOn-%s", name)),
        mVsyncEventLabel(base::StringPrintf("VSYNC-%s", name)),
        mVsyncOffsetLabel(base::StringPrintf("VsyncOffset-%s", name)),
        mVsyncNegativeOffsetLabel(base::StringPrintf("VsyncNegativeOffset-%s", name)),
        mDispSync(dispSync),
        mPhaseOffset(phaseOffset),
        mOffsetThresholdForNextVsync(offsetThresholdForNextVsync) {}
@@ -41,6 +43,7 @@ DispSyncSource::DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset,
void DispSyncSource::setVSyncEnabled(bool enable) {
    std::lock_guard lock(mVsyncMutex);
    if (enable) {
        tracePhaseOffset();
        status_t err = mDispSync->addEventListener(mName, mPhaseOffset,
                                                   static_cast<DispSync::Callback*>(this),
                                                   mLastCallbackTime);
@@ -76,6 +79,7 @@ void DispSyncSource::setPhaseOffset(nsecs_t phaseOffset) {
    const int numPeriods = phaseOffset / period;
    phaseOffset -= numPeriods * period;
    mPhaseOffset = phaseOffset;
    tracePhaseOffset();

    // If we're not enabled, we don't need to mess with the listeners
    if (!mEnabled) {
@@ -94,16 +98,26 @@ void DispSyncSource::onDispSyncEvent(nsecs_t when) {
    {
        std::lock_guard lock(mCallbackMutex);
        callback = mCallback;
    }

    if (mTraceVsync) {
        mValue = (mValue + 1) % 2;
        ATRACE_INT(mVsyncEventLabel.c_str(), mValue);
    }
    }

    if (callback != nullptr) {
        callback->onVSyncEvent(when);
    }
}

void DispSyncSource::tracePhaseOffset() {
    if (mPhaseOffset > 0) {
        ATRACE_INT(mVsyncOffsetLabel.c_str(), mPhaseOffset);
        ATRACE_INT(mVsyncNegativeOffsetLabel.c_str(), 0);
    } else {
        ATRACE_INT(mVsyncOffsetLabel.c_str(), 0);
        ATRACE_INT(mVsyncNegativeOffsetLabel.c_str(), -mPhaseOffset);
    }
}

} // namespace android
+5 −1
Original line number Diff line number Diff line
@@ -39,12 +39,16 @@ private:
    // The following method is the implementation of the DispSync::Callback.
    virtual void onDispSyncEvent(nsecs_t when);

    void tracePhaseOffset() REQUIRES(mVsyncMutex);

    const char* const mName;
    int mValue = 0;

    const bool mTraceVsync;
    const std::string mVsyncOnLabel;
    const std::string mVsyncEventLabel;
    const std::string mVsyncOffsetLabel;
    const std::string mVsyncNegativeOffsetLabel;
    nsecs_t mLastCallbackTime GUARDED_BY(mVsyncMutex) = 0;

    DispSync* mDispSync;
+3 −1
Original line number Diff line number Diff line
@@ -46,11 +46,13 @@ LayerHistory::LayerHistory() {
LayerHistory::~LayerHistory() = default;

std::unique_ptr<LayerHistory::LayerHandle> LayerHistory::createLayer(const std::string name,
                                                                     float minRefreshRate,
                                                                     float maxRefreshRate) {
    const int64_t id = sNextId++;

    std::lock_guard lock(mLock);
    mInactiveLayerInfos.emplace(id, std::make_shared<LayerInfo>(name, maxRefreshRate));
    mInactiveLayerInfos.emplace(id,
                                std::make_shared<LayerInfo>(name, minRefreshRate, maxRefreshRate));
    return std::make_unique<LayerHistory::LayerHandle>(*this, id);
}

Loading