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

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

Merge "SurfaceFlinger: Make LayerHistory virtual class"

parents 3ea3c119 e3ed2f91
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
#include "LayerInfo.h"
#include "SchedulerUtils.h"

namespace android::scheduler {
namespace android::scheduler::impl {

namespace {

@@ -157,4 +157,4 @@ void LayerHistory::clear() {
    mActiveLayersEnd = 0;
}

} // namespace android::scheduler
} // namespace android::scheduler::impl
+29 −10
Original line number Diff line number Diff line
@@ -32,33 +32,51 @@ class TestableScheduler;

namespace scheduler {

class LayerHistoryTest;
class LayerInfo;

// Records per-layer history of scheduling-related information (primarily present time),
// heuristically categorizes layers as active or inactive, and summarizes stats about
// active layers (primarily maximum refresh rate). See go/content-fps-detection-in-scheduler.
class LayerHistory {
public:
    LayerHistory();
    ~LayerHistory();
    virtual ~LayerHistory() = default;

    // Layers are unregistered when the weak reference expires.
    void registerLayer(Layer*, float lowRefreshRate, float highRefreshRate);
    virtual void registerLayer(Layer*, float lowRefreshRate, float highRefreshRate) = 0;

    // Marks the layer as active, and records the given state to its history.
    void record(Layer*, nsecs_t presentTime, nsecs_t now);
    virtual void record(Layer*, nsecs_t presentTime, nsecs_t now) = 0;

    struct Summary {
        float maxRefreshRate; // Maximum refresh rate among recently active layers.
    };

    // Rebuilds sets of active/inactive layers, and accumulates stats for active layers.
    Summary summarize(nsecs_t now);
    virtual Summary summarize(nsecs_t now) = 0;

    virtual void clear() = 0;
};

namespace impl {
// Records per-layer history of scheduling-related information (primarily present time),
// heuristically categorizes layers as active or inactive, and summarizes stats about
// active layers (primarily maximum refresh rate). See go/content-fps-detection-in-scheduler.
class LayerHistory : public android::scheduler::LayerHistory {
public:
    LayerHistory();
    virtual ~LayerHistory();

    // Layers are unregistered when the weak reference expires.
    void registerLayer(Layer*, float lowRefreshRate, float highRefreshRate) override;

    // Marks the layer as active, and records the given state to its history.
    void record(Layer*, nsecs_t presentTime, nsecs_t now) override;

    // Rebuilds sets of active/inactive layers, and accumulates stats for active layers.
    android::scheduler::LayerHistory::Summary summarize(nsecs_t now) override;

    void clear();
    void clear() override;

private:
    friend class LayerHistoryTest;
    friend class android::scheduler::LayerHistoryTest;
    friend TestableScheduler;

    using LayerPair = std::pair<wp<Layer>, std::unique_ptr<LayerInfo>>;
@@ -90,5 +108,6 @@ private:
    const bool mTraceEnabled;
};

} // namespace impl
} // namespace scheduler
} // namespace android
+2 −2
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ Scheduler::Scheduler(impl::EventControlThread::SetVSyncEnabledFunction function,
    using namespace sysprop;

    if (property_get_bool("debug.sf.use_smart_90_for_video", 0) || use_smart_90_for_video(false)) {
        mLayerHistory.emplace();
        mLayerHistory = std::make_unique<scheduler::impl::LayerHistory>();
    }

    const int setIdleTimerMs = property_get_int32("debug.sf.set_idle_timer_ms", 0);
@@ -493,7 +493,7 @@ void Scheduler::dump(std::string& result) const {

    const bool supported = mRefreshRateConfigs.refreshRateSwitchingSupported();
    StringAppendF(&result, "+  Refresh rate switching: %s\n", states[supported]);
    StringAppendF(&result, "+  Content detection: %s\n", states[mLayerHistory.has_value()]);
    StringAppendF(&result, "+  Content detection: %s\n", states[mLayerHistory != nullptr]);

    StringAppendF(&result, "+  Idle timer: %s\n",
                  mIdleTimer ? mIdleTimer->dump().c_str() : states[0]);
+1 −1
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ private:
    std::unique_ptr<EventControlThread> mEventControlThread;

    // Used to choose refresh rate if content detection is enabled.
    std::optional<scheduler::LayerHistory> mLayerHistory;
    std::unique_ptr<scheduler::LayerHistory> mLayerHistory;

    // Whether to use idle timer callbacks that support the kernel timer.
    const bool mSupportKernelTimer;
+2 −2
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ protected:

    LayerHistoryTest() { mFlinger.resetScheduler(mScheduler); }

    LayerHistory& history() { return *mScheduler->mutableLayerHistory(); }
    const LayerHistory& history() const { return *mScheduler->mutableLayerHistory(); }
    impl::LayerHistory& history() { return *mScheduler->mutableLayerHistory(); }
    const impl::LayerHistory& history() const { return *mScheduler->mutableLayerHistory(); }

    size_t layerCount() const { return mScheduler->layerHistorySize(); }
    size_t activeLayerCount() const NO_THREAD_SAFETY_ANALYSIS { return history().mActiveLayersEnd; }
Loading