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

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

Merge changes from topic "presubmit-am-5b736da41d414f9989fab9a41f2ed807" into tm-dev

* changes:
  SF: Simplify setTransactionFlags
  SF: Remove ISchedulerCallback::scheduleComposite
parents 78a7e220 94000c4a
Loading
Loading
Loading
Loading
+8 −18
Original line number Diff line number Diff line
@@ -726,10 +726,6 @@ DisplayModePtr Scheduler::getPreferredDisplayMode() {
}

void Scheduler::onNewVsyncPeriodChangeTimeline(const hal::VsyncPeriodChangeTimeline& timeline) {
    if (timeline.refreshRequired) {
        mSchedulerCallback.scheduleComposite(FrameHint::kNone);
    }

    std::lock_guard<std::mutex> lock(mVsyncTimelineLock);
    mLastVsyncPeriodChangeTimeline = std::make_optional(timeline);

@@ -739,8 +735,7 @@ void Scheduler::onNewVsyncPeriodChangeTimeline(const hal::VsyncPeriodChangeTimel
    }
}

void Scheduler::onPostComposition(nsecs_t presentTime) {
    const bool recomposite = [=] {
bool Scheduler::onPostComposition(nsecs_t presentTime) {
    std::lock_guard<std::mutex> lock(mVsyncTimelineLock);
    if (mLastVsyncPeriodChangeTimeline && mLastVsyncPeriodChangeTimeline->refreshRequired) {
        if (presentTime < mLastVsyncPeriodChangeTimeline->refreshTimeNanos) {
@@ -751,11 +746,6 @@ void Scheduler::onPostComposition(nsecs_t presentTime) {
        mLastVsyncPeriodChangeTimeline->refreshRequired = false;
    }
    return false;
    }();

    if (recomposite) {
        mSchedulerCallback.scheduleComposite(FrameHint::kNone);
    }
}

void Scheduler::onActiveDisplayAreaChanged(uint32_t displayArea) {
+2 −8
Original line number Diff line number Diff line
@@ -83,12 +83,8 @@ class TokenManager;
namespace scheduler {

struct ISchedulerCallback {
    // Indicates frame activity, i.e. whether commit and/or composite is taking place.
    enum class FrameHint { kNone, kActive };

    using DisplayModeEvent = scheduler::DisplayModeEvent;

    virtual void scheduleComposite(FrameHint) = 0;
    virtual void setVsyncEnabled(bool) = 0;
    virtual void requestDisplayMode(DisplayModePtr, DisplayModeEvent) = 0;
    virtual void kernelTimerChanged(bool expired) = 0;
@@ -210,8 +206,8 @@ public:
    // Notifies the scheduler about a refresh rate timeline change.
    void onNewVsyncPeriodChangeTimeline(const hal::VsyncPeriodChangeTimeline& timeline);

    // Notifies the scheduler post composition.
    void onPostComposition(nsecs_t presentTime);
    // Notifies the scheduler post composition. Returns if recomposite is needed.
    bool onPostComposition(nsecs_t presentTime);

    // Notifies the scheduler when the display size has changed. Called from SF's main thread
    void onActiveDisplayAreaChanged(uint32_t displayArea);
@@ -245,8 +241,6 @@ public:
private:
    friend class TestableScheduler;

    using FrameHint = ISchedulerCallback::FrameHint;

    enum class ContentDetectionState { Off, On };
    enum class TimerState { Reset, Expired };
    enum class TouchState { Inactive, Active };
+14 −11
Original line number Diff line number Diff line
@@ -1299,7 +1299,7 @@ void SurfaceFlinger::setActiveModeInHwcIfNeeded() {
        mScheduler->onNewVsyncPeriodChangeTimeline(outTimeline);

        if (outTimeline.refreshRequired) {
            // Scheduler will submit an empty frame to HWC.
            scheduleComposite(FrameHint::kNone);
            mSetActiveModePending = true;
        } else {
            // Updating the internal state should be done outside the loop,
@@ -1940,6 +1940,10 @@ void SurfaceFlinger::onComposerHalVsyncPeriodTimingChanged(
        hal::HWDisplayId, const hal::VsyncPeriodChangeTimeline& timeline) {
    Mutex::Autolock lock(mStateLock);
    mScheduler->onNewVsyncPeriodChangeTimeline(timeline);

    if (timeline.refreshRequired) {
        scheduleComposite(FrameHint::kNone);
    }
}

void SurfaceFlinger::onComposerHalSeamlessPossible(hal::HWDisplayId) {
@@ -2247,7 +2251,9 @@ void SurfaceFlinger::composite(nsecs_t frameTime, int64_t vsyncId) {

    mTimeStats->recordFrameDuration(frameTime, systemTime());

    mScheduler->onPostComposition(presentTime);
    if (mScheduler->onPostComposition(presentTime)) {
        scheduleComposite(FrameHint::kNone);
    }

    postFrame();
    postComposition();
@@ -3669,16 +3675,13 @@ uint32_t SurfaceFlinger::clearTransactionFlags(uint32_t mask) {
    return mTransactionFlags.fetch_and(~mask) & mask;
}

uint32_t SurfaceFlinger::setTransactionFlags(uint32_t mask) {
    return setTransactionFlags(mask, TransactionSchedule::Late);
}

uint32_t SurfaceFlinger::setTransactionFlags(uint32_t mask, TransactionSchedule schedule,
void SurfaceFlinger::setTransactionFlags(uint32_t mask, TransactionSchedule schedule,
                                         const sp<IBinder>& applyToken) {
    const uint32_t old = mTransactionFlags.fetch_or(mask);
    modulateVsync(&VsyncModulator::setTransactionSchedule, schedule, applyToken);
    if ((old & mask) == 0) scheduleCommit(FrameHint::kActive);
    return old;

    if (const bool scheduled = mTransactionFlags.fetch_or(mask) & mask; !scheduled) {
        scheduleCommit(FrameHint::kActive);
    }
}

bool SurfaceFlinger::stopTransactionProcessing(
+8 −11
Original line number Diff line number Diff line
@@ -287,10 +287,13 @@ public:
    SurfaceFlingerBE& getBE() { return mBE; }
    const SurfaceFlingerBE& getBE() const { return mBE; }

    // Indicates frame activity, i.e. whether commit and/or composite is taking place.
    enum class FrameHint { kNone, kActive };

    // Schedule commit of transactions on the main thread ahead of the next VSYNC.
    void scheduleCommit(FrameHint);
    // As above, but also force composite regardless if transactions were committed.
    void scheduleComposite(FrameHint) override;
    void scheduleComposite(FrameHint);
    // As above, but also force dirty geometry to repaint.
    void scheduleRepaint();
    // Schedule sampling independently from commit or composite.
@@ -783,21 +786,15 @@ private:

    uint32_t getTransactionFlags() const;

    // Sets the masked bits, and returns the old flags.
    uint32_t setTransactionFlags(uint32_t mask);
    // Sets the masked bits, and schedules a commit if needed.
    void setTransactionFlags(uint32_t mask, TransactionSchedule = TransactionSchedule::Late,
                             const sp<IBinder>& applyToken = nullptr);

    // Clears and returns the masked bits.
    uint32_t clearTransactionFlags(uint32_t mask);

    // Indicate SF should call doTraversal on layers, but don't trigger a wakeup! We use this cases
    // where there are still pending transactions but we know they won't be ready until a frame
    // arrives from a different layer. So we need to ensure we performTransaction from invalidate
    // but there is no need to try and wake up immediately to do it. Rather we rely on
    // onFrameAvailable or another layer update to wake us up.
    void setTraversalNeeded();
    uint32_t setTransactionFlags(uint32_t mask, TransactionSchedule,
                                 const sp<IBinder>& applyToken = {});
    void commitOffscreenLayers();

    enum class TransactionReadiness {
        NotReady,
        NotReadyBarrier,
+2 −4
Original line number Diff line number Diff line
@@ -140,10 +140,8 @@ void SurfaceFlingerFuzzer::invokeFlinger() {

    mFlinger->enableLatchUnsignaledConfig = mFdp.PickValueInArray(kLatchUnsignaledConfig);

    mFlinger->scheduleComposite(mFdp.ConsumeBool()
                                        ? scheduler::ISchedulerCallback::FrameHint::kActive
                                        : scheduler::ISchedulerCallback::FrameHint::kNone);

    using FrameHint = SurfaceFlinger::FrameHint;
    mFlinger->scheduleComposite(mFdp.ConsumeBool() ? FrameHint::kActive : FrameHint::kNone);
    mFlinger->scheduleRepaint();
    mFlinger->scheduleSample();

Loading