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

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

Merge "SF: Hook up VSYNC injection to Scheduler"

parents 7e5d85ab 6505f79d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public:
    ~DispSyncSource() override = default;

    // The following methods are implementation of VSyncSource.
    const char* getName() const override { return mName; }
    void setVSyncEnabled(bool enable) override;
    void setCallback(VSyncSource::Callback* callback) override;
    void setPhaseOffset(nsecs_t phaseOffset) override;
+5 −17
Original line number Diff line number Diff line
@@ -154,23 +154,11 @@ EventThread::~EventThread() = default;

namespace impl {

EventThread::EventThread(std::unique_ptr<VSyncSource> src,
                         InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName)
      : EventThread(nullptr, std::move(src), std::move(interceptVSyncsCallback), threadName) {}

EventThread::EventThread(VSyncSource* src, InterceptVSyncsCallback interceptVSyncsCallback,
                         const char* threadName)
      : EventThread(src, nullptr, std::move(interceptVSyncsCallback), threadName) {}

EventThread::EventThread(VSyncSource* src, std::unique_ptr<VSyncSource> uniqueSrc,
                         InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName)
      : mVSyncSource(src),
        mVSyncSourceUnique(std::move(uniqueSrc)),
EventThread::EventThread(std::unique_ptr<VSyncSource> vsyncSource,
                         InterceptVSyncsCallback interceptVSyncsCallback)
      : mVSyncSource(std::move(vsyncSource)),
        mInterceptVSyncsCallback(std::move(interceptVSyncsCallback)),
        mThreadName(threadName) {
    if (src == nullptr) {
        mVSyncSource = mVSyncSourceUnique.get();
    }
        mThreadName(mVSyncSource->getName()) {
    mVSyncSource->setCallback(this);

    mThread = std::thread([this]() NO_THREAD_SAFETY_ANALYSIS {
@@ -178,7 +166,7 @@ EventThread::EventThread(VSyncSource* src, std::unique_ptr<VSyncSource> uniqueSr
        threadMain(lock);
    });

    pthread_setname_np(mThread.native_handle(), threadName);
    pthread_setname_np(mThread.native_handle(), mThreadName);

    pid_t tid = pthread_gettid_np(mThread.native_handle());

+4 −10
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ public:
    };

    virtual ~VSyncSource() {}

    virtual const char* getName() const = 0;
    virtual void setVSyncEnabled(bool enable) = 0;
    virtual void setCallback(Callback* callback) = 0;
    virtual void setPhaseOffset(nsecs_t phaseOffset) = 0;
@@ -126,9 +128,7 @@ class EventThread : public android::EventThread, private VSyncSource::Callback {
public:
    using InterceptVSyncsCallback = std::function<void(nsecs_t)>;

    // TODO(b/128863962): Once the Scheduler is complete this constructor will become obsolete.
    EventThread(VSyncSource*, InterceptVSyncsCallback, const char* threadName);
    EventThread(std::unique_ptr<VSyncSource>, InterceptVSyncsCallback, const char* threadName);
    EventThread(std::unique_ptr<VSyncSource>, InterceptVSyncsCallback);
    ~EventThread();

    sp<EventThreadConnection> createEventConnection(
@@ -157,10 +157,6 @@ private:

    using DisplayEventConsumers = std::vector<sp<EventThreadConnection>>;

    // TODO(b/128863962): Once the Scheduler is complete this constructor will become obsolete.
    EventThread(VSyncSource* src, std::unique_ptr<VSyncSource> uniqueSrc,
                InterceptVSyncsCallback interceptVSyncsCallback, const char* threadName);

    void threadMain(std::unique_lock<std::mutex>& lock) REQUIRES(mMutex);

    bool shouldConsumeEvent(const DisplayEventReceiver::Event& event,
@@ -174,9 +170,7 @@ private:
    // Implements VSyncSource::Callback
    void onVSyncEvent(nsecs_t timestamp) override;

    // TODO(b/128863962): Once the Scheduler is complete this pointer will become obsolete.
    VSyncSource* mVSyncSource GUARDED_BY(mMutex) = nullptr;
    std::unique_ptr<VSyncSource> mVSyncSourceUnique GUARDED_BY(mMutex) = nullptr;
    const std::unique_ptr<VSyncSource> mVSyncSource GUARDED_BY(mMutex);

    const InterceptVSyncsCallback mInterceptVSyncsCallback;
    const char* const mThreadName;
+2 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public:
        }
    }

    const char* getName() const override { return "inject"; }
    void setVSyncEnabled(bool) override {}
    void setPhaseOffset(nsecs_t) override {}
    void pauseVsyncCallback(bool) {}
+0 −18
Original line number Diff line number Diff line
@@ -85,24 +85,6 @@ void MessageQueue::init(const sp<SurfaceFlinger>& flinger) {
    mHandler = new Handler(*this);
}

void MessageQueue::setEventThread(android::EventThread* eventThread,
                                  ResyncCallback resyncCallback) {
    if (mEventThread == eventThread) {
        return;
    }

    if (mEventTube.getFd() >= 0) {
        mLooper->removeFd(mEventTube.getFd());
    }

    mEventThread = eventThread;
    mEvents = eventThread->createEventConnection(std::move(resyncCallback),
                                                 ISurfaceComposer::eConfigChangedSuppress);
    mEvents->stealReceiveChannel(&mEventTube);
    mLooper->addFd(mEventTube.getFd(), 0, Looper::EVENT_INPUT, MessageQueue::cb_eventReceiver,
                   this);
}

void MessageQueue::setEventConnection(const sp<EventThreadConnection>& connection) {
    if (mEventTube.getFd() >= 0) {
        mLooper->removeFd(mEventTube.getFd());
Loading