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

Commit 4332aac6 authored by Huihong Luo's avatar Huihong Luo
Browse files

Add sysprop for tuning caching inactive layer

A system property, debug.sf.layer_caching_active_layer_timeout_ms, is added for user to specify milliseconds timeout to tune inactive layer heuristic.

Bug: 190228095
Test: adb root; adb shell setprop debug.sf.layer_caching_active_layer_timeout_ms 100; adb shell stop; adb shell start
Change-Id: I2607f0817af15f3a8ddcaa237b2a336c7edd315e
parent f156b778
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ class Predictor;

class Flattener {
public:
    Flattener(bool enableHolePunch = false) : mEnableHolePunch(enableHolePunch) {}
    Flattener(bool enableHolePunch = false);

    void setDisplaySize(ui::Size size) { mDisplaySize = size; }

@@ -162,6 +162,7 @@ private:
    size_t mCachedSetCreationCount = 0;
    size_t mCachedSetCreationCost = 0;
    std::unordered_map<size_t, size_t> mInvalidatedCachedSetAges;
    std::chrono::nanoseconds mActiveLayerTimeout = kActiveLayerTimeout;

    static constexpr auto kActiveLayerTimeout = std::chrono::nanoseconds(150ms);
};
+10 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
// #define LOG_NDEBUG 0
#define ATRACE_TAG ATRACE_TAG_GRAPHICS

#include <android-base/properties.h>
#include <compositionengine/impl/planner/Flattener.h>
#include <compositionengine/impl/planner/LayerState.h>

@@ -59,6 +60,14 @@ bool isSameStack(const std::vector<const LayerState*>& incomingLayers,

} // namespace

Flattener::Flattener(bool enableHolePunch) : mEnableHolePunch(enableHolePunch) {
    const int timeoutInMs =
            base::GetIntProperty(std::string("debug.sf.layer_caching_active_layer_timeout_ms"), 0);
    if (timeoutInMs != 0) {
        mActiveLayerTimeout = std::chrono::milliseconds(timeoutInMs);
    }
}

NonBufferHash Flattener::flattenLayers(const std::vector<const LayerState*>& layers,
                                       NonBufferHash hash, time_point now) {
    ATRACE_CALL();
@@ -370,7 +379,7 @@ std::vector<Flattener::Run> Flattener::findCandidateRuns(time_point now) const {
    bool runHasFirstLayer = false;

    for (auto currentSet = mLayers.cbegin(); currentSet != mLayers.cend(); ++currentSet) {
        const bool layerIsInactive = now - currentSet->getLastUpdate() > kActiveLayerTimeout;
        const bool layerIsInactive = now - currentSet->getLastUpdate() > mActiveLayerTimeout;
        const bool layerHasBlur = currentSet->hasBlurBehind();
        if (layerIsInactive && (firstLayer || runHasFirstLayer || !layerHasBlur) &&
            !currentSet->hasHdrLayers() && !currentSet->hasProtectedLayers()) {