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

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

Merge "SurfaceFlinger: add TracedOrdinal"

parents 26300b4d 50204dd2
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public:
    DispSyncThread(const char* name, bool showTraceDetailedInfo)
          : mName(name),
            mStop(false),
            mModelLocked(false),
            mModelLocked("DispSync:ModelLocked", false),
            mPeriod(0),
            mPhase(0),
            mReferenceTime(0),
@@ -121,13 +121,11 @@ public:
    void lockModel() {
        Mutex::Autolock lock(mMutex);
        mModelLocked = true;
        ATRACE_INT("DispSync:ModelLocked", mModelLocked);
    }

    void unlockModel() {
        Mutex::Autolock lock(mMutex);
        mModelLocked = false;
        ATRACE_INT("DispSync:ModelLocked", mModelLocked);
    }

    virtual bool threadLoop() {
@@ -431,7 +429,7 @@ private:
    const char* const mName;

    bool mStop;
    bool mModelLocked;
    TracedOrdinal<bool> mModelLocked;

    nsecs_t mPeriod;
    nsecs_t mPhase;
@@ -454,15 +452,14 @@ private:

class ZeroPhaseTracer : public DispSync::Callback {
public:
    ZeroPhaseTracer() : mParity(false) {}
    ZeroPhaseTracer() : mParity("ZERO_PHASE_VSYNC", false) {}

    virtual void onDispSyncEvent(nsecs_t /*when*/) {
        mParity = !mParity;
        ATRACE_INT("ZERO_PHASE_VSYNC", mParity ? 1 : 0);
    }

private:
    bool mParity;
    TracedOrdinal<bool> mParity;
};

DispSync::DispSync(const char* name) : mName(name), mRefreshSkipCount(0) {
+2 −17
Original line number Diff line number Diff line
@@ -31,19 +31,16 @@ DispSyncSource::DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset,
                               nsecs_t offsetThresholdForNextVsync, bool traceVsync,
                               const char* name)
      : mName(name),
        mValue(base::StringPrintf("VSYNC-%s", name), 0),
        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),
        mPhaseOffset(base::StringPrintf("VsyncOffset-%s", name), phaseOffset),
        mOffsetThresholdForNextVsync(offsetThresholdForNextVsync) {}

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);
@@ -83,7 +80,6 @@ void DispSyncSource::setPhaseOffset(nsecs_t phaseOffset) {
    }

    mPhaseOffset = phaseOffset;
    tracePhaseOffset();

    // If we're not enabled, we don't need to mess with the listeners
    if (!mEnabled) {
@@ -106,7 +102,6 @@ void DispSyncSource::onDispSyncEvent(nsecs_t when) {

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

    if (callback != nullptr) {
@@ -114,14 +109,4 @@ void DispSyncSource::onDispSyncEvent(nsecs_t 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
+3 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include "DispSync.h"
#include "EventThread.h"
#include "TracedOrdinal.h"

namespace android {

@@ -39,16 +40,11 @@ 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;
    TracedOrdinal<int> mValue;

    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;
@@ -57,7 +53,7 @@ private:
    VSyncSource::Callback* mCallback GUARDED_BY(mCallbackMutex) = nullptr;

    std::mutex mVsyncMutex;
    nsecs_t mPhaseOffset GUARDED_BY(mVsyncMutex);
    TracedOrdinal<nsecs_t> mPhaseOffset GUARDED_BY(mVsyncMutex);
    const nsecs_t mOffsetThresholdForNextVsync;
    bool mEnabled GUARDED_BY(mVsyncMutex) = false;
};
+9 −10
Original line number Diff line number Diff line
@@ -976,7 +976,6 @@ void SurfaceFlinger::setDesiredActiveConfig(const ActiveConfigInfo& info) {
                                        mPhaseOffsets->getOffsetThresholdForNextVsync());
    }
    mDesiredActiveConfigChanged = true;
    ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged);

    if (mRefreshRateOverlay) {
        mRefreshRateOverlay->changeRefreshRate(mDesiredActiveConfig.type);
@@ -1021,7 +1020,6 @@ void SurfaceFlinger::desiredActiveConfigChangeDone() {
    std::lock_guard<std::mutex> lock(mActiveConfigLock);
    mDesiredActiveConfig.event = Scheduler::ConfigEvent::None;
    mDesiredActiveConfigChanged = false;
    ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged);

    mScheduler->resyncToHardwareVsync(true, getVsyncPeriod());
    mPhaseOffsets->setRefreshRateType(mUpcomingActiveConfig.type);
@@ -1713,12 +1711,12 @@ void SurfaceFlinger::onMessageReceived(int32_t what) NO_THREAD_SAFETY_ANALYSIS {
            // seeing this same value.
            populateExpectedPresentTime();

            bool frameMissed = previousFrameMissed();
            bool hwcFrameMissed = mHadDeviceComposition && frameMissed;
            bool gpuFrameMissed = mHadClientComposition && frameMissed;
            ATRACE_INT("FrameMissed", static_cast<int>(frameMissed));
            ATRACE_INT("HwcFrameMissed", static_cast<int>(hwcFrameMissed));
            ATRACE_INT("GpuFrameMissed", static_cast<int>(gpuFrameMissed));
            const TracedOrdinal<bool> frameMissed = {"FrameMissed", previousFrameMissed()};
            const TracedOrdinal<bool> hwcFrameMissed = {"HwcFrameMissed",
                                                        mHadDeviceComposition && frameMissed};
            const TracedOrdinal<bool> gpuFrameMissed = {"GpuFrameMissed",
                                                        mHadClientComposition && frameMissed};

            if (frameMissed) {
                mFrameMissedCount++;
                mTimeStats->incrementMissedFrames();
@@ -3402,8 +3400,9 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<DisplayDevice>& displayDevice,

    const Region bounds(displayState.bounds);
    const DisplayRenderArea renderArea(displayDevice);
    const bool hasClientComposition = getHwComposer().hasClientComposition(displayId);
    ATRACE_INT("hasClientComposition", hasClientComposition);
    const TracedOrdinal<bool> hasClientComposition = {"hasClientComposition",
                                                      getHwComposer().hasClientComposition(
                                                              displayId)};

    bool applyColorMatrix = false;

+3 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@
#include "Scheduler/VSyncModulator.h"
#include "SurfaceFlingerFactory.h"
#include "SurfaceTracing.h"
#include "TracedOrdinal.h"
#include "TransactionCompletedThread.h"

#include <atomic>
@@ -1147,7 +1148,8 @@ private:
    ActiveConfigInfo mDesiredActiveConfig GUARDED_BY(mActiveConfigLock);

    // below flags are set by main thread only
    bool mDesiredActiveConfigChanged GUARDED_BY(mActiveConfigLock) = false;
    TracedOrdinal<bool> mDesiredActiveConfigChanged
            GUARDED_BY(mActiveConfigLock) = {"DesiredActiveConfigChanged", false};
    bool mCheckPendingFence = false;

    bool mLumaSampling = true;
Loading