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/Layer.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'services/surfaceflinger/Layer.cpp') diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index f4d4329f6d..11ae46dbcd 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -551,7 +551,7 @@ const char* Layer::getDebugName() const { // drawing... // --------------------------------------------------------------------------- -std::optional Layer::prepareClientComposition( +std::optional Layer::prepareClientComposition( compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) { if (!getCompositionLayer()) { return {}; @@ -559,7 +559,8 @@ std::optional Layer::prepareClientComposition( FloatRect bounds = getBounds(); half alpha = getAlpha(); - renderengine::LayerSettings layerSettings; + + compositionengine::LayerFE::LayerSettings layerSettings; layerSettings.geometry.boundaries = bounds; if (targetSettings.useIdentityTransform) { layerSettings.geometry.positionTransform = mat4(); @@ -581,8 +582,8 @@ std::optional Layer::prepareClientComposition( return layerSettings; } -std::optional Layer::prepareShadowClientComposition( - const renderengine::LayerSettings& casterLayerSettings, const Rect& displayViewport, +std::optional Layer::prepareShadowClientComposition( + const LayerFE::LayerSettings& casterLayerSettings, const Rect& displayViewport, ui::Dataspace outputDataspace) { renderengine::ShadowSettings shadow = getShadowSettings(displayViewport); if (shadow.length <= 0.f) { @@ -593,7 +594,8 @@ std::optional Layer::prepareShadowClientComposition const bool casterIsOpaque = ((casterLayerSettings.source.buffer.buffer != nullptr) && casterLayerSettings.source.buffer.isOpaque); - renderengine::LayerSettings shadowLayer = casterLayerSettings; + compositionengine::LayerFE::LayerSettings shadowLayer = casterLayerSettings; + shadowLayer.shadow = shadow; shadowLayer.geometry.boundaries = mBounds; // ignore transparent region @@ -604,13 +606,16 @@ std::optional Layer::prepareShadowClientComposition shadowLayer.shadow.spotColor *= casterAlpha; shadowLayer.sourceDataspace = outputDataspace; shadowLayer.source.buffer.buffer = nullptr; + shadowLayer.source.buffer.fence = nullptr; + shadowLayer.frameNumber = 0; + shadowLayer.bufferId = 0; if (shadowLayer.shadow.ambientColor.a <= 0.f && shadowLayer.shadow.spotColor.a <= 0.f) { return {}; } float casterCornerRadius = shadowLayer.geometry.roundedCornersRadius; - const FloatRect& cornerRadiusCropRect = casterLayerSettings.geometry.roundedCornersCrop; + const FloatRect& cornerRadiusCropRect = shadowLayer.geometry.roundedCornersCrop; const FloatRect& casterRect = shadowLayer.geometry.boundaries; // crop used to set the corner radius may be larger than the content rect. Adjust the corner -- cgit v1.2.3-59-g8ed1b