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

Commit bedb44bb authored by Vishnu Nair's avatar Vishnu Nair Committed by Patrick Williams
Browse files

SF: Populate RE layer settings from layer snapshot and CE layer state

Make it easier to break FE dependencies to CE by populating
RE layer settings from a layer snapshot and CE layer composition state.

Test: presubmit
Test: go/wm-smoke
Bug: 238781169

Change-Id: I92bdc0a0f605c13e2dc1465c8d1ddfd17e554633
parent 926bb129
Loading
Loading
Loading
Loading
+166 −145

File changed.

Preview size limit exceeded, changes collapsed.

+36 −3
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <utils/Timers.h>

#include <compositionengine/LayerFE.h>
#include <compositionengine/LayerFECompositionState.h>
#include <scheduler/Fps.h>
#include <scheduler/Seamlessness.h>

@@ -144,6 +145,29 @@ public:
        bool hasRoundedCorners() const { return radius.x > 0.0f && radius.y > 0.0f; }
    };

    // LayerSnapshot stores Layer state used by Composition Engine and Render Engine. Composition
    // Engine uses a pointer to LayerSnapshot (as LayerFECompositionState*) and the LayerSettings
    // passed to Render Engine are created using properties stored on this struct.
    //
    // TODO(b/238781169) Implement LayerFE as a separate subclass. Migrate LayerSnapshot to that
    // LayerFE subclass.
    struct LayerSnapshot : public compositionengine::LayerFECompositionState {
        int32_t sequence;
        std::string name;
        uint32_t textureName;
        bool contentOpaque;
        RoundedCornerState roundedCorner;
        StretchEffect stretchEffect;
        FloatRect transformedBounds;
        renderengine::ShadowSettings shadowSettings;
        bool premultipliedAlpha;
        bool isHdrY410;
        bool bufferNeedsFiltering;
        ui::Transform transform;
        Rect bufferSize;
        std::shared_ptr<renderengine::ExternalTexture> externalTexture;
    };

    using FrameRate = scheduler::LayerInfo::FrameRate;
    using FrameRateCompatibility = scheduler::LayerInfo::FrameRateCompatibility;

@@ -392,7 +416,9 @@ public:
    ui::Dataspace getRequestedDataSpace() const;

    virtual sp<compositionengine::LayerFE> getCompositionEngineLayerFE() const;
    compositionengine::LayerFECompositionState* editCompositionState();

    const LayerSnapshot* getLayerSnapshot() const;
    LayerSnapshot* editLayerSnapshot();

    // If we have received a new buffer this frame, we will pass its surface
    // damage down to hardware composer. Otherwise, we must send a region with
@@ -867,6 +893,13 @@ public:
    bool simpleBufferUpdate(const layer_state_t&) const;

    static bool isOpaqueFormat(PixelFormat format);

    // Updates the LayerSnapshot. This must be called prior to sending layer data to
    // CompositionEngine or RenderEngine (i.e. before calling CompositionEngine::present or
    // Layer::prepareClientComposition).
    //
    // TODO(b/238781169) Remove direct calls to RenderEngine::drawLayers that don't go through
    // CompositionEngine to create a single path for composing layers.
    void updateSnapshot(bool updateGeometry);

protected:
@@ -1166,8 +1199,6 @@ private:
    // the mStateLock.
    ui::Transform::RotationFlags mTransformHint = ui::Transform::ROT_0;

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

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

@@ -1200,6 +1231,8 @@ private:
    ui::Transform mRequestedTransform;

    sp<HwcSlotGenerator> mHwcSlotGenerator;

    std::unique_ptr<LayerSnapshot> mSnapshot = std::make_unique<LayerSnapshot>();
};

std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate);
+5 −0
Original line number Diff line number Diff line
@@ -6653,6 +6653,11 @@ ftl::SharedFuture<FenceResult> SurfaceFlinger::renderScreenImpl(
    std::vector<Layer*> renderedLayers;
    bool disableBlurs = false;
    traverseLayers([&](Layer* layer) {
        // Layer::prepareClientComposition uses the layer's snapshot to populate the resulting
        // LayerSettings. Calling Layer::updateSnapshot ensures that LayerSettings are
        // generated with the layer's current buffer and geometry.
        layer->updateSnapshot(true /* updateGeometry */);

        disableBlurs |= layer->getDrawingState().sidebandStream != nullptr;

        Region clip(renderArea.getBounds());
+1 −1
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ public:
                                       const sp<NativeHandle>& sidebandStream) {
        layer->mDrawingState.sidebandStream = sidebandStream;
        layer->mSidebandStream = sidebandStream;
        layer->editCompositionState()->sidebandStream = sidebandStream;
        layer->editLayerSnapshot()->sidebandStream = sidebandStream;
    }

    void setLayerCompositionType(const sp<Layer>& layer,