First patch for async renderengine.
1. return a std::future object from DrawLayers() instead to make it
asynchronously
2. retire drawFence value from drawLayers() parameter list.
Bug: 180657548
Test: android.hardware.graphics.composer@2.2-vts, libcompositionengine_test, libsurfaceflinger_unittest and
librenderengine_test pass
Change-Id: If63c11762d1cce7b053cc72aaeaed6dd7904877f
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 0ff5eca..1747294 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -1030,10 +1030,9 @@
}
}
- base::unique_fd readyFence;
if (!hasClientComposition) {
setExpensiveRenderingExpected(false);
- return readyFence;
+ return base::unique_fd();
}
ALOGV("hasClientComposition");
@@ -1073,7 +1072,7 @@
clientCompositionLayers)) {
outputCompositionState.reusedClientComposition = true;
setExpensiveRenderingExpected(false);
- return readyFence;
+ return base::unique_fd();
}
mClientCompositionRequestCache->add(tex->getBuffer()->getId(), clientCompositionDisplay,
clientCompositionLayers);
@@ -1107,9 +1106,11 @@
// probably to encapsulate the output buffer into a structure that dispatches resource cleanup
// over to RenderEngine, in which case this flag can be removed from the drawLayers interface.
const bool useFramebufferCache = outputState.layerFilter.toInternalDisplay;
- status_t status =
- renderEngine.drawLayers(clientCompositionDisplay, clientCompositionLayerPointers, tex,
- useFramebufferCache, std::move(fd), &readyFence);
+ auto [status, drawFence] =
+ renderEngine
+ .drawLayers(clientCompositionDisplay, clientCompositionLayerPointers, tex,
+ useFramebufferCache, std::move(fd))
+ .get();
if (status != NO_ERROR && mClientCompositionRequestCache) {
// If rendering was not successful, remove the request from the cache.
@@ -1117,15 +1118,15 @@
}
auto& timeStats = getCompositionEngine().getTimeStats();
- if (readyFence.get() < 0) {
+ if (drawFence.get() < 0) {
timeStats.recordRenderEngineDuration(renderEngineStart, systemTime());
} else {
timeStats.recordRenderEngineDuration(renderEngineStart,
std::make_shared<FenceTime>(
- new Fence(dup(readyFence.get()))));
+ new Fence(dup(drawFence.get()))));
}
- return readyFence;
+ return std::move(drawFence);
}
std::vector<LayerFE::LayerSettings> Output::generateClientCompositionRequests(