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

Commit ab046855 authored by Irvel's avatar Irvel
Browse files

Fix duplicated VSync tracing in SurfaceInterceptor

Change-Id: Id02bb2916d0c53dc11d7106c4aec6954a1acc035
parent ffc9efc4
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -44,13 +44,14 @@ static void vsyncOffCallback(union sigval val) {
    return;
}

EventThread::EventThread(const sp<VSyncSource>& src, SurfaceFlinger& flinger)
EventThread::EventThread(const sp<VSyncSource>& src, SurfaceFlinger& flinger, bool interceptVSyncs)
    : mVSyncSource(src),
      mFlinger(flinger),
      mUseSoftwareVSync(false),
      mVsyncEnabled(false),
      mDebugVsyncEnabled(false),
      mVsyncHintSent(false) {
      mVsyncHintSent(false),
      mInterceptVSyncs(interceptVSyncs) {

    for (int32_t i=0 ; i<DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES ; i++) {
        mVSyncEvent[i].header.type = DisplayEventReceiver::DISPLAY_EVENT_VSYNC;
@@ -226,7 +227,9 @@ Vector< sp<EventThread::Connection> > EventThread::waitForEvent(
            timestamp = mVSyncEvent[i].header.timestamp;
            if (timestamp) {
                // we have a vsync event to dispatch
                if (mInterceptVSyncs) {
                    mFlinger.mInterceptor.saveVSyncEvent(timestamp);
                }
                *event = mVSyncEvent[i];
                mVSyncEvent[i].header.timestamp = 0;
                vsyncCount = mVSyncEvent[i].vsync.count;
+2 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ class EventThread : public Thread, private VSyncSource::Callback {

public:

    EventThread(const sp<VSyncSource>& src, SurfaceFlinger& flinger);
    EventThread(const sp<VSyncSource>& src, SurfaceFlinger& flinger, bool interceptVSyncs);

    sp<Connection> createEventConnection() const;
    status_t registerDisplayEventConnection(const sp<Connection>& connection);
@@ -132,6 +132,7 @@ private:
    bool mDebugVsyncEnabled;

    bool mVsyncHintSent;
    const bool mInterceptVSyncs;
    timer_t mTimerId;
};

+3 −3
Original line number Diff line number Diff line
@@ -503,10 +503,10 @@ void SurfaceFlinger::init() {
        // start the EventThread
        sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
                vsyncPhaseOffsetNs, true, "app");
        mEventThread = new EventThread(vsyncSrc, *this);
        mEventThread = new EventThread(vsyncSrc, *this, false);
        sp<VSyncSource> sfVsyncSrc = new DispSyncSource(&mPrimaryDispSync,
                sfVsyncPhaseOffsetNs, true, "sf");
        mSFEventThread = new EventThread(sfVsyncSrc, *this);
        mSFEventThread = new EventThread(sfVsyncSrc, *this, true);
        mEventQueue.setEventThread(mSFEventThread);

        // set SFEventThread to SCHED_FIFO to minimize jitter
@@ -896,7 +896,7 @@ status_t SurfaceFlinger::enableVSyncInjections(bool enable) {
        ALOGV("VSync Injections enabled");
        if (mVSyncInjector.get() == nullptr) {
            mVSyncInjector = new InjectVSyncSource();
            mInjectorEventThread = new EventThread(mVSyncInjector, *this);
            mInjectorEventThread = new EventThread(mVSyncInjector, *this, false);
        }
        mEventQueue.setEventThread(mInjectorEventThread);
    } else {
+3 −3
Original line number Diff line number Diff line
@@ -499,10 +499,10 @@ void SurfaceFlinger::init() {
    // start the EventThread
    sp<VSyncSource> vsyncSrc = new DispSyncSource(&mPrimaryDispSync,
            vsyncPhaseOffsetNs, true, "app");
    mEventThread = new EventThread(vsyncSrc, *this);
    mEventThread = new EventThread(vsyncSrc, *this, false);
    sp<VSyncSource> sfVsyncSrc = new DispSyncSource(&mPrimaryDispSync,
            sfVsyncPhaseOffsetNs, true, "sf");
    mSFEventThread = new EventThread(sfVsyncSrc, *this);
    mSFEventThread = new EventThread(sfVsyncSrc, *this, true);
    mEventQueue.setEventThread(mSFEventThread);

    // set SFEventThread to SCHED_FIFO to minimize jitter
@@ -859,7 +859,7 @@ status_t SurfaceFlinger::enableVSyncInjections(bool enable) {
        ALOGV("VSync Injections enabled");
        if (mVSyncInjector.get() == nullptr) {
            mVSyncInjector = new InjectVSyncSource();
            mInjectorEventThread = new EventThread(mVSyncInjector, *this);
            mInjectorEventThread = new EventThread(mVSyncInjector, *this, false);
        }
        mEventQueue.setEventThread(mInjectorEventThread);
    } else {