diff options
| author | 2021-04-06 09:53:26 -0400 | |
|---|---|---|
| committer | 2021-04-21 17:34:57 -0400 | |
| commit | d305ef2847c7ab6f496fcda0aa41dfc3b1e574a4 (patch) | |
| tree | 330be6e7ac765c55b53696039c620bbe00f6e0c0 | |
| parent | e2ee040d21294c55a8c76f90ea82b2c9dc93277f (diff) | |
SF: Ignore rounded corners if the layer can peek through
Bug: 163076219
Test: manual
Test: I53fc851eca876d44ba7cb9347f1c62d659c38932
In Layer::preparePerFrameCompositionState, no longer set
forceClientComposition to true based on the presence of rounded corners.
This will be determined later, based on whether the Layer will peek
through a Layer with a hole-punch.
In CachedSet::requiresHolePunch, return false if the layer must be
client composited for reasons other than rounded corners (which no
longer force client composition). While we could still use a hole punch,
it would not provide the desired effect (preventing waking up the GPU).
Add an extra field to overrideInfo, denoting whether this layer will
peek through another layer. Set it on a peekThroughLayer before sending
it to the HWC. If it's not set, and the layer has rounded corners, the
layer must be client composited, as before.
Change-Id: I3b4341d049c0fa5020dfd89ca9e765588a457eb1
5 files changed, 17 insertions, 3 deletions
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h index 356965cf48..3ecbb60110 100644 --- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h +++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/OutputLayerCompositionState.h @@ -103,6 +103,11 @@ struct OutputLayerCompositionState { // be visible through it. Unowned - the OutputLayer's lifetime will // outlast this.) OutputLayer* peekThroughLayer = nullptr; + + // True if the OutputLayer represented by this CompositionState is + // peeking through another layer, so it can be device composited even if + // it should visually have rounded corners. + bool isPeekingThrough = false; } overrideInfo; /* diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp index 29534764d4..5c2a148cd0 100644 --- a/services/surfaceflinger/CompositionEngine/src/Output.cpp +++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp @@ -720,7 +720,7 @@ void Output::writeCompositionState(const compositionengine::CompositionRefreshAr continue; } bool skipLayer = false; - auto& overrideInfo = layer->getState().overrideInfo; + const auto& overrideInfo = layer->getState().overrideInfo; if (overrideInfo.buffer != nullptr) { if (previousOverride && overrideInfo.buffer->getBuffer() == previousOverride) { ALOGV("Skipping redundant buffer"); @@ -729,6 +729,8 @@ void Output::writeCompositionState(const compositionengine::CompositionRefreshAr // First layer with the override buffer. if (overrideInfo.peekThroughLayer) { peekThroughLayer = overrideInfo.peekThroughLayer; + peekThroughLayer->editState().overrideInfo.isPeekingThrough = true; + // Draw peekThroughLayer first. const bool includeGeometry = refreshArgs.updatingGeometryThisFrame; peekThroughLayer->writeStateToHWC(includeGeometry, false, z++); diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp index 89d5a23293..444ac46556 100644 --- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp +++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp @@ -567,7 +567,8 @@ void OutputLayer::writeCompositionTypeToHWC(HWC2::Layer* hwcLayer, auto& outputDependentState = editState(); // If we are forcing client composition, we need to tell the HWC - if (outputDependentState.forceClientComposition) { + if (outputDependentState.forceClientComposition || + (!getState().overrideInfo.isPeekingThrough && getLayerFE().hasRoundedCorners())) { requestedCompositionType = hal::Composition::CLIENT; } diff --git a/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp b/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp index 6f6649924b..989b155189 100644 --- a/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp +++ b/services/surfaceflinger/CompositionEngine/src/planner/CachedSet.cpp @@ -271,6 +271,10 @@ bool CachedSet::requiresHolePunch() const { } const auto& layerFE = mLayers[0].getState()->getOutputLayer()->getLayerFE(); + if (layerFE.getCompositionState()->forceClientComposition) { + return false; + } + return layerFE.hasRoundedCorners(); } diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index cf215adba2..4461420b46 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -531,7 +531,9 @@ void Layer::preparePerFrameCompositionState() { isOpaque(drawingState) && !usesRoundedCorners && getAlpha() == 1.0_hf; // Force client composition for special cases known only to the front-end. - if (isHdrY410() || usesRoundedCorners || drawShadows() || drawingState.blurRegions.size() > 0 || + // Rounded corners no longer force client composition, since we may use a + // hole punch so that the layer will appear to have rounded corners. + if (isHdrY410() || drawShadows() || drawingState.blurRegions.size() > 0 || compositionState->stretchEffect.hasEffect()) { compositionState->forceClientComposition = true; } |