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

Commit fe520ba6 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Fix dirty region updates if a layer becomes invisible" into main

parents 59d9feb3 438a0acc
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1265,6 +1265,12 @@ void LayerSnapshotBuilder::forEachSnapshot(const Visitor& visitor,
    }
}

void LayerSnapshotBuilder::forEachSnapshot(const ConstVisitor& visitor) const {
    for (auto& snapshot : mSnapshots) {
        visitor(*snapshot);
    }
}

void LayerSnapshotBuilder::forEachInputSnapshot(const ConstVisitor& visitor) const {
    for (int i = mNumInterestingSnapshots - 1; i >= 0; i--) {
        LayerSnapshot& snapshot = *mSnapshots[(size_t)i];
+3 −0
Original line number Diff line number Diff line
@@ -91,6 +91,9 @@ public:
    // snapshots in z-order
    void forEachSnapshot(const Visitor& visitor, const ConstPredicate& predicate);

    // Visit each snapshot
    void forEachSnapshot(const ConstVisitor& visitor) const;

    // Visit each snapshot interesting to input reverse z-order
    void forEachInputSnapshot(const ConstVisitor& visitor) const;

+12 −14
Original line number Diff line number Diff line
@@ -2520,12 +2520,18 @@ bool SurfaceFlinger::updateLayerSnapshots(VsyncId vsyncId, nsecs_t frameTimeNs,
    }

    updateLayerHistory(latchTime);
    mLayerSnapshotBuilder.forEachVisibleSnapshot([&](const frontend::LayerSnapshot& snapshot) {
        if (mLayersIdsWithQueuedFrames.find(snapshot.path.id) == mLayersIdsWithQueuedFrames.end())
            return;
    mLayerSnapshotBuilder.forEachSnapshot([&](const frontend::LayerSnapshot& snapshot) {
        // update output dirty region if we have a queued buffer that is visible or a snapshot
        // recently became invisible
        // TODO(b/360050020) investigate if we need to update dirty region when layer color changes
        if ((snapshot.isVisible &&
             (mLayersIdsWithQueuedFrames.find(snapshot.path.id) !=
              mLayersIdsWithQueuedFrames.end())) ||
            (!snapshot.isVisible && snapshot.changes.test(Changes::Visibility))) {
            Region visibleReg;
            visibleReg.set(snapshot.transformedBoundsWithoutTransparentRegion);
            invalidateLayerStack(snapshot.outputFilter, visibleReg);
        }
    });

    for (auto& destroyedLayer : mLayerLifecycleManager.getDestroyedLayers()) {
@@ -3984,14 +3990,6 @@ void SurfaceFlinger::commitTransactionsLocked(uint32_t transactionFlags) {
        mLayersRemoved = false;
        mVisibleRegionsDirty = true;
        mUpdateInputInfo = true;
        mDrawingState.traverseInZOrder([&](Layer* layer) {
            if (mLayersPendingRemoval.indexOf(sp<Layer>::fromExisting(layer)) >= 0) {
                // this layer is not visible anymore
                Region visibleReg;
                visibleReg.set(layer->getScreenBounds());
                invalidateLayerStack(layer->getOutputFilter(), visibleReg);
            }
        });
    }

    if (transactionFlags & eInputInfoUpdateNeeded) {