SF: Move/Refactor doComposition and doDisplayComposition to CompositionEngine
Test: atest libsurfaceflinger_unittest libcompositionengine_test
Test: atest CtsColorModeTestCases
Test: atest CtsDisplayTestCases
Test: atest CtsGraphicsTestCases
Test: atest CtsUiRenderingTestCases
Test: atest CtsViewTestCases
Test: atest android.media.cts.EncodeVirtualDisplayWithCompositionTest
Bug: 121291683
Change-Id: I6c796ec613ce163764a403bcd669dab38300f437
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index dd0890c..1875151 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1801,7 +1801,8 @@
display->beginFrame();
display->prepareFrame();
display->devOptRepaintFlash(refreshArgs);
- doComposition(displayDevice, refreshArgs.repaintEverything);
+ display->finishFrame(refreshArgs);
+ display->postFramebuffer();
}
postFrame();
@@ -2321,26 +2322,6 @@
profile->getBestColorMode(bestDataSpace, intent, outDataSpace, outMode, outRenderIntent);
}
-void SurfaceFlinger::doComposition(const sp<DisplayDevice>& displayDevice, bool repaintEverything) {
- ATRACE_CALL();
- ALOGV("doComposition");
-
- auto display = displayDevice->getCompositionDisplay();
- const auto& displayState = display->getState();
-
- if (displayState.isEnabled) {
- // transform the dirty region into this screen's coordinate space
- const Region dirtyRegion = display->getDirtyRegion(repaintEverything);
-
- // repaint the framebuffer (if needed)
- doDisplayComposition(displayDevice, dirtyRegion);
-
- display->editState().dirtyRegion.clear();
- display->getRenderSurface()->flip();
- }
- displayDevice->getCompositionDisplay()->postFramebuffer();
-}
-
void SurfaceFlinger::postFrame()
{
// |mStateLock| not needed as we are on the main thread
@@ -3162,26 +3143,6 @@
mGeometryInvalid = true;
}
-void SurfaceFlinger::doDisplayComposition(const sp<DisplayDevice>& displayDevice,
- const Region& inDirtyRegion) {
- auto display = displayDevice->getCompositionDisplay();
- // We only need to actually compose the display if:
- // 1) It is being handled by hardware composer, which may need this to
- // keep its virtual display state machine in sync, or
- // 2) There is work to be done (the dirty region isn't empty)
- if (!displayDevice->getId() && inDirtyRegion.isEmpty()) {
- ALOGV("Skipping display composition");
- return;
- }
-
- ALOGV("doDisplayComposition");
- base::unique_fd readyFence;
- if (!display->composeSurfaces(Region::INVALID_REGION, &readyFence)) return;
-
- // swap buffers (presentation)
- display->getRenderSurface()->queueBuffer(std::move(readyFence));
-}
-
status_t SurfaceFlinger::addClientLayer(const sp<Client>& client, const sp<IBinder>& handle,
const sp<IGraphicBufferProducer>& gbc, const sp<Layer>& lbc,
const sp<IBinder>& parentHandle,