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

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

Merge "SurfaceFlinger: cleanup some TODOs for Scheduler"

parents aea5077c 46e2f3e0
Loading
Loading
Loading
Loading
+0 −25
Original line number Original line Diff line number Diff line
@@ -789,31 +789,6 @@ void DispSync::dump(std::string& result) const {
    StringAppendF(&result, "current monotonic time: %" PRId64 "\n", now);
    StringAppendF(&result, "current monotonic time: %" PRId64 "\n", now);
}
}


// TODO(b/113612090): Figure out how much of this is still relevant.
// We need to determine the time when a buffer acquired now will be
// displayed.  This can be calculated:
//   time when previous buffer's actual-present fence was signaled
//    + current display refresh rate * HWC latency
//    + a little extra padding
//
// Buffer producers are expected to set their desired presentation time
// based on choreographer time stamps, which (coming from vsync events)
// will be slightly later then the actual-present timing.  If we get a
// desired-present time that is unintentionally a hair after the next
// vsync, we'll hold the frame when we really want to display it.  We
// need to take the offset between actual-present and reported-vsync
// into account.
//
// If the system is configured without a DispSync phase offset for the app,
// we also want to throw in a bit of padding to avoid edge cases where we
// just barely miss.  We want to do it here, not in every app.  A major
// source of trouble is the app's use of the display's ideal refresh time
// (via Display.getRefreshRate()), which could be off of the actual refresh
// by a few percent, with the error multiplied by the number of frames
// between now and when the buffer should be displayed.
//
// If the refresh reported to the app has a phase offset, we shouldn't need
// to tweak anything here.
nsecs_t DispSync::expectedPresentTime() {
nsecs_t DispSync::expectedPresentTime() {
    // The HWC doesn't currently have a way to report additional latency.
    // The HWC doesn't currently have a way to report additional latency.
    // Assume that whatever we submit now will appear right after the flip.
    // Assume that whatever we submit now will appear right after the flip.
+3 −6
Original line number Original line Diff line number Diff line
@@ -135,7 +135,7 @@ class EventThread : public android::EventThread, private VSyncSource::Callback {
public:
public:
    using InterceptVSyncsCallback = std::function<void(nsecs_t)>;
    using InterceptVSyncsCallback = std::function<void(nsecs_t)>;


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


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


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


@@ -186,10 +186,7 @@ private:
    // Implements VSyncSource::Callback
    // Implements VSyncSource::Callback
    void onVSyncEvent(nsecs_t timestamp) override;
    void onVSyncEvent(nsecs_t timestamp) override;


    // Acquires mutex and requests next vsync.
    // TODO(b/128863962): Once the Scheduler is complete this pointer will become obsolete.
    void requestNextVsyncInternal(const sp<EventThreadConnection>& connection) EXCLUDES(mMutex);

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


+1 −1
Original line number Original line Diff line number Diff line
@@ -85,7 +85,7 @@ public:
    virtual ~MessageQueue();
    virtual ~MessageQueue();


    virtual void init(const sp<SurfaceFlinger>& flinger) = 0;
    virtual void init(const sp<SurfaceFlinger>& flinger) = 0;
    // TODO(akrulec): Remove this function once everything is migrated to Scheduler.
    // TODO(b/128863962): Remove this function once everything is migrated to Scheduler.
    virtual void setEventThread(EventThread* events, ResyncCallback resyncCallback) = 0;
    virtual void setEventThread(EventThread* events, ResyncCallback resyncCallback) = 0;
    virtual void setEventConnection(const sp<EventThreadConnection>& connection) = 0;
    virtual void setEventConnection(const sp<EventThreadConnection>& connection) = 0;
    virtual void waitMessage() = 0;
    virtual void waitMessage() = 0;
+1 −1
Original line number Original line Diff line number Diff line
@@ -1245,7 +1245,7 @@ status_t SurfaceFlinger::enableVSyncInjections(bool enable) {
        auto resyncCallback =
        auto resyncCallback =
                mScheduler->makeResyncCallback(std::bind(&SurfaceFlinger::getVsyncPeriod, this));
                mScheduler->makeResyncCallback(std::bind(&SurfaceFlinger::getVsyncPeriod, this));


        // TODO(akrulec): Part of the Injector should be refactored, so that it
        // TODO(b/128863962): Part of the Injector should be refactored, so that it
        // can be passed to Scheduler.
        // can be passed to Scheduler.
        if (enable) {
        if (enable) {
            ALOGV("VSync Injections enabled");
            ALOGV("VSync Injections enabled");