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

Commit ef36b00d authored by Lloyd Pique's avatar Lloyd Pique
Browse files

SF: Fix a defect in the layer filtering logic

Change 32cbe2 broke the layer filtering logic when moving it over to
CompositionEngine. It would allow certain layers to appear on a virtual
display when they were supposed to be filtered out.

This corrects the logic to be what it was supposed to be, and adds a
unit test that verifies and documents the expected behavior.

Bug: 123248930
Test: atest libsurfaceflinger_unittest libcompositionengine_test
Test: atest android.media.cts.EncodeVirtualDisplayWithCompositionTest

Change-Id: Id2c4b4d32da405c64533924027795620f2d6ee61
parent 0c326e33
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -52,11 +52,9 @@ public:
    // Sets the bounds to use
    virtual void setBounds(const ui::Size&) = 0;

    // Sets the layer stack filter for this output. If singleLayerStack is true,
    // this output displays just the single layer stack specified by
    // singleLayerStackId. Otherwise all layer stacks will be visible on this
    // output.
    virtual void setLayerStackFilter(bool singleLayerStack, uint32_t singleLayerStackId) = 0;
    // Sets the layer stack filtering settings for this output. See
    // belongsInOutput for full details.
    virtual void setLayerStackFilter(uint32_t layerStackId, bool isInternal) = 0;

    // Sets the color transform matrix to use
    virtual void setColorTransform(const mat4&) = 0;
@@ -96,8 +94,14 @@ public:
    // logical (aka layer stack) space.
    virtual Region getPhysicalSpaceDirtyRegion(bool repaintEverything) const = 0;

    // Tests whether a given layerStackId belongs in this output
    virtual bool belongsInOutput(uint32_t layerStackId) const = 0;
    // Tests whether a given layerStackId belongs in this output.
    // A layer belongs to the output if its layerStackId matches the of the output layerStackId,
    // unless the layer should display on the primary output only and this is not the primary output

    // A layer belongs to the output if its layerStackId matches. Additionally
    // if the layer should only show in the internal (primary) display only and
    // this output allows that.
    virtual bool belongsInOutput(uint32_t layerStackId, bool internalOnly) const = 0;

protected:
    ~Output() = default;
+2 −2
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public:
    void setProjection(const ui::Transform&, int32_t orientation, const Rect& frame,
                       const Rect& viewport, const Rect& scissor, bool needsFiltering) override;
    void setBounds(const ui::Size&) override;
    void setLayerStackFilter(bool singleLayerStack, uint32_t singleLayerStackId) override;
    void setLayerStackFilter(uint32_t layerStackId, bool isInternal) override;

    void setColorTransform(const mat4&) override;
    void setColorMode(ui::ColorMode, ui::Dataspace, ui::RenderIntent) override;
@@ -58,7 +58,7 @@ public:
    OutputCompositionState& editState() override;

    Region getPhysicalSpaceDirtyRegion(bool repaintEverything) const override;
    bool belongsInOutput(uint32_t) const override;
    bool belongsInOutput(uint32_t, bool) const override;

    // Testing
    void setDisplayColorProfileForTest(std::unique_ptr<compositionengine::DisplayColorProfile>);
+3 −4
Original line number Diff line number Diff line
@@ -34,12 +34,11 @@ struct OutputCompositionState {
    // If false, this output is not considered secure
    bool isSecure{false};

    // If true, only layer stacks with a matching layerStack value will be
    // displayed. If false, all layer stacks will be displayed.
    bool singleLayerStack{true};
    // If true, this output displays layers that are internal-only
    bool layerStackInternal{false};

    // The layer stack to display on this display
    uint32_t singleLayerStackId{~0u};
    uint32_t layerStackId{~0u};

    // The physical space screen bounds
    Rect bounds;
+2 −2
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ public:
    MOCK_METHOD6(setProjection,
                 void(const ui::Transform&, int32_t, const Rect&, const Rect&, const Rect&, bool));
    MOCK_METHOD1(setBounds, void(const ui::Size&));
    MOCK_METHOD2(setLayerStackFilter, void(bool, uint32_t));
    MOCK_METHOD2(setLayerStackFilter, void(uint32_t, bool));

    MOCK_METHOD1(setColorTransform, void(const mat4&));
    MOCK_METHOD3(setColorMode, void(ui::ColorMode, ui::Dataspace, ui::RenderIntent));
@@ -54,7 +54,7 @@ public:
    MOCK_METHOD0(editState, OutputCompositionState&());

    MOCK_CONST_METHOD1(getPhysicalSpaceDirtyRegion, Region(bool));
    MOCK_CONST_METHOD1(belongsInOutput, bool(uint32_t));
    MOCK_CONST_METHOD2(belongsInOutput, bool(uint32_t, bool));
};

} // namespace android::compositionengine::mock
+7 −5
Original line number Diff line number Diff line
@@ -75,9 +75,9 @@ void Output::setBounds(const ui::Size& size) {
    dirtyEntireOutput();
}

void Output::setLayerStackFilter(bool singleLayerStack, uint32_t singleLayerStackId) {
    mState.singleLayerStack = singleLayerStack;
    mState.singleLayerStackId = singleLayerStackId;
void Output::setLayerStackFilter(uint32_t layerStackId, bool isInternal) {
    mState.layerStackId = layerStackId;
    mState.layerStackInternal = isInternal;

    dirtyEntireOutput();
}
@@ -175,8 +175,10 @@ Region Output::getPhysicalSpaceDirtyRegion(bool repaintEverything) const {
    return dirty;
}

bool Output::belongsInOutput(uint32_t layerStackId) const {
    return !mState.singleLayerStack || (layerStackId == mState.singleLayerStackId);
bool Output::belongsInOutput(uint32_t layerStackId, bool internalOnly) const {
    // The layerStackId's must match, and also the layer must not be internal
    // only when not on an internal output.
    return (layerStackId == mState.layerStackId) && (!internalOnly || mState.layerStackInternal);
}

void Output::dirtyEntireOutput() {
Loading