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

Commit 42ddbb44 authored by Chia-I Wu's avatar Chia-I Wu Committed by Gerrit Code Review
Browse files

Merge "surfaceflinger: fix fencing when composition mode switches"

parents 5de5abde 7b549593
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -1924,13 +1924,22 @@ void SurfaceFlinger::postFramebuffer()
        displayDevice->onSwapBuffersCompleted();
        displayDevice->makeCurrent(mEGLDisplay, mEGLContext);
        for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) {
            sp<Fence> releaseFence = Fence::NO_FENCE;
            if (layer->getCompositionType(hwcId) == HWC2::Composition::Client) {
                releaseFence = displayDevice->getClientTargetAcquireFence();
            } else {
            // The layer buffer from the previous frame (if any) is released
            // by HWC only when the release fence from this frame (if any) is
            // signaled.  Always get the release fence from HWC first.
            auto hwcLayer = layer->getHwcLayer(hwcId);
                releaseFence = mHwc->getLayerReleaseFence(hwcId, hwcLayer);
            sp<Fence> releaseFence = mHwc->getLayerReleaseFence(hwcId, hwcLayer);

            // If the layer was client composited in the previous frame, we
            // need to merge with the previous client target acquire fence.
            // Since we do not track that, always merge with the current
            // client target acquire fence when it is available, even though
            // this is suboptimal.
            if (layer->getCompositionType(hwcId) == HWC2::Composition::Client) {
                releaseFence = Fence::merge("LayerRelease", releaseFence,
                        displayDevice->getClientTargetAcquireFence());
            }

            layer->onLayerDisplayed(releaseFence);
        }
        if (hwcId >= 0) {