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

Commit d204bfc7 authored by Irvel Nduva Matias Vega's avatar Irvel Nduva Matias Vega Committed by Android (Google) Code Review
Browse files

Merge "Fix duplicated VSync tracing in SurfaceInterceptor"

parents 08626ec0 ab046855
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -44,13 +44,14 @@ static void vsyncOffCallback(union sigval val) {
    return;
    return;
}
}


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


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


public:
public:


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


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


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


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


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


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