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

Commit 16d8b2c5 authored by Patrick Williams's avatar Patrick Williams
Browse files

SF: Refactor Layer::prepareClientCompositionList

Replace Layer::prepareClientCompositionList with
Layer::prepareClientComposition now that at most one layer is returned
for any call. Also changes OutputLayer::getOverrideCompositionList to
return an optional for the same reason.

Output::generateClientCompositionRequest is updated to use buffer ids
instead of strong pointers to buffers when determining whether or not
override settings are redundant. This is done to avoid duplicate checks
on whether or not overrideInfo has a non-null buffer.

Change-Id: I777f6ba8c3ca38ea31773e6fcbacb65fad287b03
Bug: b/188891810
Test: atest libcompositionengine_test
parent 1cc4ae8d
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -1109,7 +1109,29 @@ bool BufferStateLayer::isVisible() const {
}

std::optional<compositionengine::LayerFE::LayerSettings> BufferStateLayer::prepareClientComposition(
        compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) {
        compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) const {
    std::optional<compositionengine::LayerFE::LayerSettings> layerSettings =
            prepareClientCompositionInternal(targetSettings);
    // Nothing to render.
    if (!layerSettings) {
        return {};
    }

    // HWC requests to clear this layer.
    if (targetSettings.clearContent) {
        prepareClearClientComposition(*layerSettings, false /* blackout */);
        return *layerSettings;
    }

    // set the shadow for the layer if needed
    prepareShadowClientComposition(*layerSettings, targetSettings.viewport);

    return *layerSettings;
}

std::optional<compositionengine::LayerFE::LayerSettings>
BufferStateLayer::prepareClientCompositionInternal(
        compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) const {
    ATRACE_CALL();

    std::optional<compositionengine::LayerFE::LayerSettings> result =
@@ -1559,7 +1581,7 @@ sp<GraphicBuffer> BufferStateLayer::getBuffer() const {
    return mBufferInfo.mBuffer ? mBufferInfo.mBuffer->getBuffer() : nullptr;
}

void BufferStateLayer::getDrawingTransformMatrix(bool filteringEnabled, float outMatrix[16]) {
void BufferStateLayer::getDrawingTransformMatrix(bool filteringEnabled, float outMatrix[16]) const {
    sp<GraphicBuffer> buffer = getBuffer();
    if (!buffer) {
        ALOGE("Buffer should not be null!");
+7 −4
Original line number Diff line number Diff line
@@ -159,6 +159,9 @@ public:
    std::atomic<int32_t>* getPendingBufferCounter() override { return &mPendingBufferTransactions; }
    std::string getPendingBufferCounterName() override { return mBlastTransactionName; }

    std::optional<compositionengine::LayerFE::LayerSettings> prepareClientComposition(
            compositionengine::LayerFE::ClientCompositionTargetSettings&) const override;

protected:
    void gatherBufferInfo();
    void onSurfaceFrameCreated(const std::shared_ptr<frametimeline::SurfaceFrame>& surfaceFrame);
@@ -188,9 +191,6 @@ protected:

    BufferInfo mBufferInfo;

    std::optional<compositionengine::LayerFE::LayerSettings> prepareClientComposition(
            compositionengine::LayerFE::ClientCompositionTargetSettings&) override;

    /*
     * compositionengine::LayerFE overrides
     */
@@ -236,7 +236,7 @@ private:

    // Computes the transform matrix using the setFilteringEnabled to determine whether the
    // transform matrix should be computed for use with bilinear filtering.
    void getDrawingTransformMatrix(bool filteringEnabled, float outMatrix[16]);
    void getDrawingTransformMatrix(bool filteringEnabled, float outMatrix[16]) const;

    std::unique_ptr<compositionengine::LayerFECompositionState> mCompositionState;

@@ -270,6 +270,9 @@ private:
                                   const sp<Fence>& releaseFence,
                                   uint32_t currentMaxAcquiredBufferCount);

    std::optional<compositionengine::LayerFE::LayerSettings> prepareClientCompositionInternal(
            compositionengine::LayerFE::ClientCompositionTargetSettings&) const;

    ReleaseCallbackId mPreviousReleaseCallbackId = ReleaseCallbackId::INVALID_ID;
    uint64_t mPreviousReleasedFrameNumber = 0;

+5 −5
Original line number Diff line number Diff line
@@ -150,11 +150,11 @@ public:
        uint64_t frameNumber = 0;
    };

    // Returns the z-ordered list of LayerSettings to pass to RenderEngine::drawLayers. The list
    // may contain shadows casted by the layer or the content of the layer itself.  If the layer
    // does not render then an empty list will be returned.
    virtual std::vector<LayerSettings> prepareClientCompositionList(
            ClientCompositionTargetSettings&) = 0;
    // Returns the LayerSettings to pass to RenderEngine::drawLayers. The state may contain shadows
    // casted by the layer or the content of the layer itself. If the layer does not render then an
    // empty optional will be returned.
    virtual std::optional<LayerSettings> prepareClientComposition(
            ClientCompositionTargetSettings&) const = 0;

    // Called after the layer is displayed to update the presentation fence
    virtual void onLayerDisplayed(ftl::SharedFuture<FenceResult>) = 0;
+2 −2
Original line number Diff line number Diff line
@@ -126,9 +126,9 @@ public:
    // Returns true if the composition settings scale pixels
    virtual bool needsFiltering() const = 0;

    // Returns a composition list to be used by RenderEngine if the layer has been overridden
    // Returns LayerSettings to be used by RenderEngine if the layer has been overridden
    // during the composition process
    virtual std::vector<LayerFE::LayerSettings> getOverrideCompositionList() const = 0;
    virtual std::optional<LayerFE::LayerSettings> getOverrideCompositionSettings() const = 0;

    // Debugging
    virtual void dump(std::string& result) const = 0;
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <cstdint>
#include <memory>
#include <optional>
#include <string>

#include <compositionengine/LayerFE.h>
@@ -57,7 +58,7 @@ public:
    void prepareForDeviceLayerRequests() override;
    void applyDeviceLayerRequest(Hwc2::IComposerClient::LayerRequest request) override;
    bool needsFiltering() const override;
    std::vector<LayerFE::LayerSettings> getOverrideCompositionList() const override;
    std::optional<LayerFE::LayerSettings> getOverrideCompositionSettings() const override;

    void dump(std::string&) const override;
    virtual FloatRect calculateOutputSourceCrop(uint32_t internalDisplayRotationFlags) const;
Loading