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

Commit 2f7d9aeb authored by Alec Mouri's avatar Alec Mouri
Browse files

Store layers with pending frames as smart pointers instead of raw pointers

Layers can be removed in between invalidations, which is problematic
when using raw pointers. Instead, store a set of sp<Layer> with a custom
hash

Bug: 170729573
Test: builds
Change-Id: I87dd48a7767b8c05461cb4e56b3fbcd037d0603e
parent be97cfac
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2110,7 +2110,7 @@ void SurfaceFlinger::postComposition() {
    ALOGV("postComposition");

    nsecs_t dequeueReadyTime = systemTime();
    for (auto layer : mLayersWithQueuedFrames) {
    for (const auto& layer : mLayersWithQueuedFrames) {
        layer->releasePendingBuffer(dequeueReadyTime);
    }

@@ -3055,7 +3055,7 @@ bool SurfaceFlinger::handlePageFlip() {
        // writes to Layer current state. See also b/119481871
        Mutex::Autolock lock(mStateLock);

        for (auto& layer : mLayersWithQueuedFrames) {
        for (const auto& layer : mLayersWithQueuedFrames) {
            if (layer->latchBuffer(visibleRegions, latchTime, expectedPresentTime)) {
                mLayersPendingRefresh.push_back(layer);
            }
+2 −3
Original line number Diff line number Diff line
@@ -1091,9 +1091,8 @@ private:
    bool mAnimCompositionPending = false;

    // Tracks layers that have pending frames which are candidates for being
    // latched. Because this contains a set of raw layer pointers, can only be
    // mutated on the main thread.
    std::unordered_set<Layer*> mLayersWithQueuedFrames;
    // latched.
    std::unordered_set<sp<Layer>, ISurfaceComposer::SpHash<Layer>> mLayersWithQueuedFrames;
    // Tracks layers that need to update a display's dirty region.
    std::vector<sp<Layer>> mLayersPendingRefresh;
    std::array<sp<Fence>, 2> mPreviousPresentFences = {Fence::NO_FENCE, Fence::NO_FENCE};