From 0560e0e8ea151004138e6fc39f35fa8985814770 Mon Sep 17 00:00:00 2001 From: Baldev Sahu Date: Thu, 27 Sep 2018 15:02:33 +0530 Subject: [PATCH] sf: Fix issue with dequeueBuffer when multiple display present swapBuffers is called even for device composition when a flip client target request is present. dequeueBuffer 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 buffer is dequeued before swapBuffers. Bug: 151698217 Test: atest libsurfaceflinger_unittest Change-Id: I933cbae2f09f81eef6555b1bb1e5991d2c450930 Merged-In: Ia8a1470affb2596b27986cc4153417f48cf4ed1c --- services/surfaceflinger/DisplayHardware/HWC2.cpp | 2 +- services/surfaceflinger/SurfaceFlinger.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp index c463c4e40a..f4fc7477a3 100644 --- a/services/surfaceflinger/DisplayHardware/HWC2.cpp +++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp @@ -470,7 +470,7 @@ Error Display::getName(std::string* outName) const Error Display::getRequests(HWC2::DisplayRequest* outDisplayRequests, std::unordered_map* outLayerRequests) { - uint32_t intDisplayRequests; + uint32_t intDisplayRequests = 0; std::vector layerIds; std::vector layerRequests; auto intError = mComposer.getDisplayRequests( diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index e311e3fae6..30b380183d 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -3415,6 +3415,7 @@ bool SurfaceFlinger::doComposeSurfaces(const sp& displayDevice, const Region bounds(displayState.bounds); const DisplayRenderArea renderArea(displayDevice); const bool hasClientComposition = getHwComposer().hasClientComposition(displayId); + const bool hasFlipClientTargetRequest = getHwComposer().hasFlipClientTargetRequest(displayId); ATRACE_INT("hasClientComposition", hasClientComposition); bool applyColorMatrix = false; @@ -3480,6 +3481,15 @@ bool SurfaceFlinger::doComposeSurfaces(const sp& displayDevice, if (applyColorMatrix) { clientCompositionDisplay.colorTransform = displayState.colorTransformMat; } + } else if (hasFlipClientTargetRequest) { + buf = display->getRenderSurface()->dequeueBuffer(&fd); + + if (buf == nullptr) { + ALOGW("Dequeuing buffer for display [%s] failed, bailing out of " + "client composition for this frame", + displayDevice->getDisplayName().c_str()); + return false; + } } /*