Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 545da0e1 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Some fixes to TrustedPresentationListener

1. Ignore display overlays since we don't want screen decorations
   included in the occlusion

2. Handle occluded region as separate Rects to ensure that disconnected
   Rects in a Region are not considered occluding in the disconnected
   area.

Test: LayerTrustedPresentationListenerTest
Bug: 256993331
Change-Id: Ib0a4b850e2aafb42e206b8728fcc9b6013171f3f
parent 858a6a88
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ struct CompositionRefreshArgs {
    std::optional<std::chrono::steady_clock::time_point> scheduledFrameTime;

    std::vector<BorderRenderInfo> borderInfoList;

    bool hasTrustedPresentationListener = false;
};

} // namespace android::compositionengine
+2 −0
Original line number Diff line number Diff line
@@ -212,6 +212,8 @@ struct LayerFECompositionState {
    float currentSdrHdrRatio = 1.f;
    float desiredSdrHdrRatio = 1.f;

    bool isInternalDisplayOverlay = false;

    virtual ~LayerFECompositionState();

    // Debugging
+4 −0
Original line number Diff line number Diff line
@@ -153,6 +153,10 @@ public:
        Region aboveOpaqueLayers;
        // The region of the output which should be considered dirty
        Region dirtyRegion;
        // The region of the output which is covered by layers, excluding display overlays. This
        // only has a value if there's something needing it, like when a TrustedPresentationListener
        // is set
        std::optional<Region> aboveCoveredLayersExcludingOverlays;
    };

    virtual ~Output();
+7 −1
Original line number Diff line number Diff line
@@ -63,9 +63,15 @@ struct OutputLayerCompositionState {
    // The portion of the layer that is not obscured and is also opaque
    Region visibleNonTransparentRegion;

    // The portion of the layer that is obscured by opaque layers on top
    // The portion of the layer that is obscured by all layers on top. This includes transparent and
    // opaque.
    Region coveredRegion;

    // The portion of the layer that is obscured by all layers on top excluding display overlays.
    // This only has a value if there's something needing it, like when a
    // TrustedPresentationListener is set.
    std::optional<Region> coveredRegionExcludingDisplayOverlays;

    // The visibleRegion transformed to output space
    Region outputSpaceVisibleRegion;

+22 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <ftl/future.h>
#include <gui/TraceUtils.h>

#include <optional>
#include <thread>

#include "renderengine/ExternalTexture.h"
@@ -480,6 +481,9 @@ void Output::rebuildLayerStacks(const compositionengine::CompositionRefreshArgs&

    // Process the layers to determine visibility and coverage
    compositionengine::Output::CoverageState coverage{layerFESet};
    coverage.aboveCoveredLayersExcludingOverlays = refreshArgs.hasTrustedPresentationListener
            ? std::make_optional<Region>()
            : std::nullopt;
    collectVisibleLayers(refreshArgs, coverage);

    // Compute the resulting coverage for this output, and store it for later
@@ -534,6 +538,9 @@ void Output::ensureOutputLayerIfVisible(sp<compositionengine::LayerFE>& layerFE,
        return;
    }

    bool computeAboveCoveredExcludingOverlays =
            coverage.aboveCoveredLayersExcludingOverlays && !layerFEState->isInternalDisplayOverlay;

    /*
     * opaqueRegion: area of a surface that is fully opaque.
     */
@@ -575,6 +582,11 @@ void Output::ensureOutputLayerIfVisible(sp<compositionengine::LayerFE>& layerFE,
     */
    Region shadowRegion;

    /**
     * covered region above excluding internal display overlay layers
     */
    std::optional<Region> coveredRegionExcludingDisplayOverlays = std::nullopt;

    const ui::Transform& tr = layerFEState->geomLayerTransform;

    // Get the visible region
@@ -647,6 +659,12 @@ void Output::ensureOutputLayerIfVisible(sp<compositionengine::LayerFE>& layerFE,
    // Update accumAboveCoveredLayers for next (lower) layer
    coverage.aboveCoveredLayers.orSelf(visibleRegion);

    if (CC_UNLIKELY(computeAboveCoveredExcludingOverlays)) {
        coveredRegionExcludingDisplayOverlays =
                coverage.aboveCoveredLayersExcludingOverlays->intersect(visibleRegion);
        coverage.aboveCoveredLayersExcludingOverlays->orSelf(visibleRegion);
    }

    // subtract the opaque region covered by the layers above us
    visibleRegion.subtractSelf(coverage.aboveOpaqueLayers);

@@ -733,6 +751,10 @@ void Output::ensureOutputLayerIfVisible(sp<compositionengine::LayerFE>& layerFE,
            ? outputState.transform.transform(
                      transparentRegion.intersect(outputState.layerStackSpace.getContent()))
            : Region();
    if (CC_UNLIKELY(computeAboveCoveredExcludingOverlays)) {
        outputLayerState.coveredRegionExcludingDisplayOverlays =
                std::move(coveredRegionExcludingDisplayOverlays);
    }
}

void Output::setReleasedLayers(const compositionengine::CompositionRefreshArgs&) {
Loading