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

Commit 3d91a351 authored by Chia-I Wu's avatar Chia-I Wu Committed by android-build-merger
Browse files

Merge "surfaceflinger: fix fencing when composition mode switches" am: 42ddbb44

am: 4256a729

Change-Id: I1414b9899336f34aac86116cf4d39fd68f2b0fdd
parents e73db291 4256a729
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -2032,13 +2032,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) {