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

Commit 7d7e0f6e authored by Ben Widawsky's avatar Ben Widawsky
Browse files

SF: Subsume frametimeline namespace in scheduler

TokenManager logically belongs as part of the scheduler. Once it is
removed from FrameTimeline it becomes apparent that there really is no
need for a frametimeline namespace and having it around only makes the
code integrating the timeline and token components more difficult to
read and write due to navagating around the namespaces.

Bug: 414584347
Test: none
Flag: EXEMPT, refactor
Change-Id: I9bf32fceffc019c0fa10a0082505bc9a365068c7
parent 92a0abec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@

namespace android {

FpsReporter::FpsReporter(frametimeline::FrameTimeline& frameTimeline, std::unique_ptr<Clock> clock)
FpsReporter::FpsReporter(scheduler::FrameTimeline& frameTimeline, std::unique_ptr<Clock> clock)
      : mFrameTimeline(frameTimeline), mClock(std::move(clock)) {
    LOG_ALWAYS_FATAL_IF(mClock == nullptr, "Passed in null clock when constructing FpsReporter!");
}
+3 −3
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ class SurfaceFlinger;

class FpsReporter : public IBinder::DeathRecipient {
public:
    FpsReporter(frametimeline::FrameTimeline& frameTimeline,
    FpsReporter(scheduler::FrameTimeline& frameTimeline,
                std::unique_ptr<Clock> clock = std::make_unique<SteadyClock>());

    // Dispatches updated layer fps values for the registered listeners
@@ -58,7 +58,7 @@ private:
        int32_t taskId;
    };

    frametimeline::FrameTimeline& mFrameTimeline;
    scheduler::FrameTimeline& mFrameTimeline;
    static const constexpr std::chrono::steady_clock::duration kMinDispatchDuration =
            std::chrono::milliseconds(500);
    std::unique_ptr<Clock> mClock;
+3 −3
Original line number Diff line number Diff line
@@ -25,9 +25,9 @@
#include <utils/Mutex.h>

namespace android {
namespace frametimeline {
namespace scheduler {
class FrameTimelineTest;
}
} // namespace scheduler

/**
 * JankTracker maintains a backlog of frame jank classification and manages and notififies any
@@ -52,7 +52,7 @@ protected:
    static std::vector<gui::JankData> getCollectedJankDataForTesting(int32_t layerId);
    static void clearAndStopCollectingAllJankDataForTesting();

    friend class frametimeline::FrameTimelineTest;
    friend class scheduler::FrameTimelineTest;

private:
    JankTracker() {}
+6 −6
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ using gui::LayerMetadata;
using gui::WindowInfo;
using ui::Size;

using PresentState = frametimeline::SurfaceFrame::PresentState;
using PresentState = scheduler::SurfaceFrame::PresentState;

Layer::Layer(const surfaceflinger::LayerCreationArgs& args)
      : sequence(args.sequence),
@@ -450,15 +450,15 @@ void Layer::setFrameTimelineVsyncForBufferlessTransaction(const FrameTimelineInf
    setFrameTimelineVsyncForSkippedFrames(info, postTime, mTransactionName, gameMode);
}

void Layer::addSurfaceFrameDroppedForBuffer(
        std::shared_ptr<frametimeline::SurfaceFrame>& surfaceFrame, nsecs_t dropTime) {
void Layer::addSurfaceFrameDroppedForBuffer(std::shared_ptr<scheduler::SurfaceFrame>& surfaceFrame,
                                            nsecs_t dropTime) {
    surfaceFrame->setDropTime(dropTime);
    surfaceFrame->setPresentState(PresentState::Dropped);
    mFlinger->mFrameTimeline->addSurfaceFrame(surfaceFrame);
}

void Layer::addSurfaceFramePresentedForBuffer(
        std::shared_ptr<frametimeline::SurfaceFrame>& surfaceFrame, nsecs_t acquireFenceTime,
        std::shared_ptr<scheduler::SurfaceFrame>& surfaceFrame, nsecs_t acquireFenceTime,
        nsecs_t currentLatchTime) REQUIRES(mFlinger->mStateLock) {
    surfaceFrame->setAcquireFenceTime(acquireFenceTime);
    surfaceFrame->setPresentState(PresentState::Presented, mLastLatchTime);
@@ -466,7 +466,7 @@ void Layer::addSurfaceFramePresentedForBuffer(
    updateLastLatchTime(currentLatchTime);
}

std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForTransaction(
std::shared_ptr<scheduler::SurfaceFrame> Layer::createSurfaceFrameForTransaction(
        const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode)
        REQUIRES(mFlinger->mStateLock) {
    auto surfaceFrame =
@@ -488,7 +488,7 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForTransac
    return surfaceFrame;
}

std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForBuffer(
std::shared_ptr<scheduler::SurfaceFrame> Layer::createSurfaceFrameForBuffer(
        const FrameTimelineInfo& info, nsecs_t queueTime, std::string debugName,
        gui::GameMode gameMode) REQUIRES(mFlinger->mStateLock) {
    auto surfaceFrame =
+10 −11
Original line number Diff line number Diff line
@@ -73,9 +73,9 @@ class OutputLayer;
struct LayerFECompositionState;
}

namespace frametimeline {
namespace scheduler {
class SurfaceFrame;
} // namespace frametimeline
} // namespace scheduler

class Layer : public virtual RefBase {
public:
@@ -143,11 +143,11 @@ public:
        // such SurfaceFrame exists because only one buffer can be presented on the layer per vsync.
        // If multiple buffers are queued, the prior ones will be dropped, along with the
        // SurfaceFrame that's tracking them.
        std::shared_ptr<frametimeline::SurfaceFrame> bufferSurfaceFrameTX;
        std::shared_ptr<scheduler::SurfaceFrame> bufferSurfaceFrameTX;
        // A map of token(frametimelineVsyncId) to the SurfaceFrame that's tracking a transaction
        // that contains the token. Only one SurfaceFrame exisits for transactions that share the
        // same token, unless they are presented in different vsyncs.
        std::unordered_map<int64_t, std::shared_ptr<frametimeline::SurfaceFrame>>
        std::unordered_map<int64_t, std::shared_ptr<scheduler::SurfaceFrame>>
                bufferlessSurfaceFramesTX;
        // An arbitrary threshold for the number of BufferlessSurfaceFrames in the state. Used to
        // trigger a warning if the number of SurfaceFrames crosses the threshold.
@@ -336,15 +336,14 @@ public:
    void setFrameTimelineVsyncForBufferlessTransaction(const FrameTimelineInfo& info,
                                                       nsecs_t postTime, gui::GameMode gameMode);

    void addSurfaceFrameDroppedForBuffer(std::shared_ptr<frametimeline::SurfaceFrame>& surfaceFrame,
    void addSurfaceFrameDroppedForBuffer(std::shared_ptr<scheduler::SurfaceFrame>& surfaceFrame,
                                         nsecs_t dropTime);
    void addSurfaceFramePresentedForBuffer(
            std::shared_ptr<frametimeline::SurfaceFrame>& surfaceFrame, nsecs_t acquireFenceTime,
            nsecs_t currentLatchTime);
    void addSurfaceFramePresentedForBuffer(std::shared_ptr<scheduler::SurfaceFrame>& surfaceFrame,
                                           nsecs_t acquireFenceTime, nsecs_t currentLatchTime);

    std::shared_ptr<frametimeline::SurfaceFrame> createSurfaceFrameForTransaction(
    std::shared_ptr<scheduler::SurfaceFrame> createSurfaceFrameForTransaction(
            const FrameTimelineInfo& info, nsecs_t postTime, gui::GameMode gameMode);
    std::shared_ptr<frametimeline::SurfaceFrame> createSurfaceFrameForBuffer(
    std::shared_ptr<scheduler::SurfaceFrame> createSurfaceFrameForBuffer(
            const FrameTimelineInfo& info, nsecs_t queueTime, std::string debugName,
            gui::GameMode gameMode);
    void setFrameTimelineVsyncForSkippedFrames(const FrameTimelineInfo& info, nsecs_t postTime,
@@ -561,7 +560,7 @@ private:

    std::vector<std::pair<frontend::LayerHierarchy::TraversalPath, sp<LayerFE>>> mLayerFEs;
    bool mHandleAlive = false;
    std::optional<std::reference_wrapper<frametimeline::FrameTimeline>> getTimeline() const {
    std::optional<std::reference_wrapper<scheduler::FrameTimeline>> getTimeline() const {
        return *mFlinger->mFrameTimeline;
    }
};
Loading