summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/Layer.cpp
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2020-01-21 14:36:08 -0800
committer Vishnu Nair <vishnun@google.com> 2020-01-21 21:17:50 -0800
commit9b079a2fef76ed1dfa69b158889edd0af5e6e52c (patch)
tree0072ca6810ee57122aa5b56abf52b18032b0f6f1 /services/surfaceflinger/Layer.cpp
parent0a4b951a590910bab35f20f03d25316426dbf8ae (diff)
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
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
-rw-r--r--services/surfaceflinger/Layer.cpp17
1 files changed, 11 insertions, 6 deletions
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<renderengine::LayerSettings> Layer::prepareClientComposition(
+std::optional<compositionengine::LayerFE::LayerSettings> Layer::prepareClientComposition(
compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) {
if (!getCompositionLayer()) {
return {};
@@ -559,7 +559,8 @@ std::optional<renderengine::LayerSettings> 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<renderengine::LayerSettings> Layer::prepareClientComposition(
return layerSettings;
}
-std::optional<renderengine::LayerSettings> Layer::prepareShadowClientComposition(
- const renderengine::LayerSettings& casterLayerSettings, const Rect& displayViewport,
+std::optional<compositionengine::LayerFE::LayerSettings> 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<renderengine::LayerSettings> 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<renderengine::LayerSettings> 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