From 9b079a2fef76ed1dfa69b158889edd0af5e6e52c Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Tue, 21 Jan 2020 14:36:08 -0800 Subject: Skip client composition requests Keep track of client compositions requests in CompositionEngine and the buffer used to render the request. If the requests do not change and the buffer matches, reuse the buffer instead of going to client composition. Certain layers properties (buffer format, rounded corner or shadows) will force the device to go into GPU or mixed composition. In mixed composition scenarios, we can avoid redundant client composition requests by reusing the RenderSurface buffers. If the device goes into GPU composition then all the layers will be composited and there will be no performance benefit. Bug: b/136561771, b/144690120 Test: dump SurfaceFlinger --timestats -dump Test: manual testing with mixed and gpu composition scenarios Test: atest libcompositionengine_test libsurfaceflinger_unittest SurfaceFlinger_test Change-Id: I466d5dcded0c9fcfa64bc72fd91dfaddd795f315 --- services/surfaceflinger/BufferLayer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'services/surfaceflinger/BufferLayer.cpp') diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp index 7845cab397..35d0215fa1 100644 --- a/services/surfaceflinger/BufferLayer.cpp +++ b/services/surfaceflinger/BufferLayer.cpp @@ -144,11 +144,12 @@ static constexpr mat4 inverseOrientation(uint32_t transform) { return inverse(tr); } -std::optional BufferLayer::prepareClientComposition( +std::optional BufferLayer::prepareClientComposition( compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) { ATRACE_CALL(); - auto result = Layer::prepareClientComposition(targetSettings); + std::optional result = + Layer::prepareClientComposition(targetSettings); if (!result) { return result; } @@ -183,7 +184,7 @@ std::optional BufferLayer::prepareClientComposition bool blackOutLayer = (isProtected() && !targetSettings.supportsProtectedContent) || (isSecure() && !targetSettings.isSecure); const State& s(getDrawingState()); - auto& layer = *result; + LayerFE::LayerSettings& layer = *result; if (!blackOutLayer) { layer.source.buffer.buffer = mBufferInfo.mBuffer; layer.source.buffer.isOpaque = isOpaque(s); @@ -199,6 +200,9 @@ std::optional BufferLayer::prepareClientComposition layer.source.buffer.maxContentLuminance = hasCta861_3 ? mBufferInfo.mHdrMetadata.cta8613.maxContentLightLevel : defaultMaxContentLuminance; + layer.frameNumber = mCurrentFrameNumber; + layer.bufferId = mBufferInfo.mBuffer ? mBufferInfo.mBuffer->getId() : 0; + // TODO: we could be more subtle with isFixedSize() const bool useFiltering = targetSettings.needsFiltering || mNeedsFiltering || isFixedSize(); @@ -264,9 +268,11 @@ std::optional BufferLayer::prepareClientComposition // layer. layer.source.buffer.buffer = nullptr; layer.alpha = 1.0; + layer.frameNumber = 0; + layer.bufferId = 0; } - return result; + return layer; } bool BufferLayer::isHdrY410() const { -- cgit v1.2.3-59-g8ed1b