From f73a4a7ef8cdc51c29f3683b93eb9fada46c9762 Mon Sep 17 00:00:00 2001 From: Baldev Sahu Date: Thu, 27 Sep 2018 15:02:33 +0530 Subject: sf: Fix issue with makeCurrent when multiple display present swapBuffers is called even for device composition on MDP3 target based on flip client target request. makeCurrent call is skipped as there is no client composition. This is fine for single display but if multiple display i.e. vds is present, this will be an issue as current surface will not be switched and swapBuffers will fail. When flip client target request is present, make sure makeCurrent is also called before swapBuffers. CRs-Fixed: 2311294 Bug: 151698217 Change-Id: I933cbae2f09f81eef6555b1bb1e5991d2c450930 --- services/surfaceflinger/SurfaceFlinger.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index d0207f9e5b..9c02886885 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3011,6 +3011,7 @@ bool SurfaceFlinger::doComposeSurfaces(const sp& displayDev const DisplayRenderArea renderArea(displayDevice); const auto hwcId = displayDevice->getHwcDisplayId(); const bool hasClientComposition = getBE().mHwc->hasClientComposition(hwcId); + const bool hasFlipClientTargetReq = getBE().mHwc->hasFlipClientTargetRequest(hwcId); ATRACE_INT("hasClientComposition", hasClientComposition); bool applyColorMatrix = false; @@ -3097,6 +3098,18 @@ bool SurfaceFlinger::doComposeSurfaces(const sp& displayDev getBE().mRenderEngine->setScissor(scissor.left, height - scissor.bottom, scissor.getWidth(), scissor.getHeight()); } + } else if (hasFlipClientTargetReq) { + if (!displayDevice->makeCurrent()) { + ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s", + displayDevice->getDisplayName().string()); + getRenderEngine().resetCurrentSurface(); + + // |mStateLock| not needed as we are on the main thread + if(!getDefaultDisplayDeviceLocked()->makeCurrent()) { + ALOGE("DisplayDevice::makeCurrent on default display failed. Aborting."); + } + return false; + } } /* -- cgit v1.2.3