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

Commit 7d0a7747 authored by Huihong Luo's avatar Huihong Luo Committed by Automerger Merge Worker
Browse files

Merge "Add sysprop for tuning caching inactive layer" into sc-dev am: cda04d4f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14908675

Change-Id: I6a8c25a7a42acb78d9b7f6fe83dfe0e7b326e14a
parents 122279f3 cda04d4f
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()) {