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

Commit cdc60881 authored by Leon Scroggins's avatar Leon Scroggins Committed by Android (Google) Code Review
Browse files

Merge changes Id305effe,I065f1968,I18b6d921 into sc-dev

* changes:
  SF: Only buildCachedSets if (mergeWithCachedSets)
  Remove Flattener::mLayersHash
  Mark CachedSet::mFingerprint as const
parents fdec5f27 04b992cb
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -108,7 +108,7 @@ public:
private:
private:
    CachedSet() = default;
    CachedSet() = default;


    NonBufferHash mFingerprint = 0;
    const NonBufferHash mFingerprint;
    std::chrono::steady_clock::time_point mLastUpdate = std::chrono::steady_clock::now();
    std::chrono::steady_clock::time_point mLastUpdate = std::chrono::steady_clock::now();
    std::vector<Layer> mLayers;
    std::vector<Layer> mLayers;
    Rect mBounds = Rect::EMPTY_RECT;
    Rect mBounds = Rect::EMPTY_RECT;
+1 −2
Original line number Original line Diff line number Diff line
@@ -54,7 +54,7 @@ private:


    void resetActivities(NonBufferHash, std::chrono::steady_clock::time_point now);
    void resetActivities(NonBufferHash, std::chrono::steady_clock::time_point now);


    void updateLayersHash();
    NonBufferHash computeLayersHash() const;


    bool mergeWithCachedSets(const std::vector<const LayerState*>& layers,
    bool mergeWithCachedSets(const std::vector<const LayerState*>& layers,
                             std::chrono::steady_clock::time_point now);
                             std::chrono::steady_clock::time_point now);
@@ -69,7 +69,6 @@ private:
    std::chrono::steady_clock::time_point mLastGeometryUpdate;
    std::chrono::steady_clock::time_point mLastGeometryUpdate;


    std::vector<CachedSet> mLayers;
    std::vector<CachedSet> mLayers;
    NonBufferHash mLayersHash = 0;
    std::optional<CachedSet> mNewCachedSet;
    std::optional<CachedSet> mNewCachedSet;


    // Statistics
    // Statistics
+13 −7
Original line number Original line Diff line number Diff line
@@ -40,13 +40,17 @@ NonBufferHash Flattener::flattenLayers(const std::vector<const LayerState*>& lay


    ++mInitialLayerCounts[layers.size()];
    ++mInitialLayerCounts[layers.size()];


    if (mergeWithCachedSets(layers, now)) {
    // Only buildCachedSets if these layers are already stored in mLayers.
        hash = mLayersHash;
    // Otherwise (i.e. mergeWithCachedSets returns false), the time has not
    }
    // changed, so buildCachedSets will never find any runs.
    const bool alreadyHadCachedSets = mergeWithCachedSets(layers, now);


    ++mFinalLayerCounts[mLayers.size()];
    ++mFinalLayerCounts[mLayers.size()];


    if (alreadyHadCachedSets) {
        buildCachedSets(now);
        buildCachedSets(now);
        hash = computeLayersHash();
    }


    return hash;
    return hash;
}
}
@@ -157,14 +161,17 @@ void Flattener::resetActivities(NonBufferHash hash, time_point now) {
    }
    }
}
}


void Flattener::updateLayersHash() {
NonBufferHash Flattener::computeLayersHash() const{
    size_t hash = 0;
    size_t hash = 0;
    for (const auto& layer : mLayers) {
    for (const auto& layer : mLayers) {
        android::hashCombineSingleHashed(hash, layer.getNonBufferHash());
        android::hashCombineSingleHashed(hash, layer.getNonBufferHash());
    }
    }
    mLayersHash = hash;
    return hash;
}
}


// Only called if the geometry matches the last frame. Return true if mLayers
// was already populated with these layers, i.e. on the second and following
// calls with the same geometry.
bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers, time_point now) {
bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers, time_point now) {
    std::vector<CachedSet> merged;
    std::vector<CachedSet> merged;


@@ -272,7 +279,6 @@ bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers
    }
    }


    mLayers = std::move(merged);
    mLayers = std::move(merged);
    updateLayersHash();
    return true;
    return true;
}
}