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

Commit 10cea3ca authored by Tianhao Yao's avatar Tianhao Yao Committed by chaviw
Browse files

Allow using custom widths and colors for layer borders.

Update the enableBorder API in SurfaceComposerClient so
that width and color can be specified for the border.
The information propagates through the pipe all the
way to the render engine so it can render the correct color
and width for the border

Test:go/wm-smoke.
Test: LayerBorder_test
Bug: 226529222

Change-Id: Id3ab853d5b4d6899a915f729b0d7be701cb5b167
parent 8a806249
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -102,6 +102,11 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.writeUint32, transform);
    SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
    SAFE_PARCEL(output.writeBool, borderEnabled);
    SAFE_PARCEL(output.writeFloat, borderWidth);
    SAFE_PARCEL(output.writeFloat, borderColor.r);
    SAFE_PARCEL(output.writeFloat, borderColor.g);
    SAFE_PARCEL(output.writeFloat, borderColor.b);
    SAFE_PARCEL(output.writeFloat, borderColor.a);
    SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dataspace));
    SAFE_PARCEL(output.write, hdrMetadata);
    SAFE_PARCEL(output.write, surfaceDamageRegion);
@@ -202,6 +207,16 @@ status_t layer_state_t::read(const Parcel& input)
    SAFE_PARCEL(input.readUint32, &transform);
    SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
    SAFE_PARCEL(input.readBool, &borderEnabled);
    SAFE_PARCEL(input.readFloat, &tmpFloat);
    borderWidth = tmpFloat;
    SAFE_PARCEL(input.readFloat, &tmpFloat);
    borderColor.r = tmpFloat;
    SAFE_PARCEL(input.readFloat, &tmpFloat);
    borderColor.g = tmpFloat;
    SAFE_PARCEL(input.readFloat, &tmpFloat);
    borderColor.b = tmpFloat;
    SAFE_PARCEL(input.readFloat, &tmpFloat);
    borderColor.a = tmpFloat;

    uint32_t tmpUint32 = 0;
    SAFE_PARCEL(input.readUint32, &tmpUint32);
@@ -555,6 +570,8 @@ void layer_state_t::merge(const layer_state_t& other) {
    if (other.what & eRenderBorderChanged) {
        what |= eRenderBorderChanged;
        borderEnabled = other.borderEnabled;
        borderWidth = other.borderWidth;
        borderColor = other.borderColor;
    }
    if (other.what & eFrameRateSelectionPriority) {
        what |= eFrameRateSelectionPriority;
+3 −1
Original line number Diff line number Diff line
@@ -1940,7 +1940,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDropI
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::enableBorder(
        const sp<SurfaceControl>& sc, bool shouldEnable) {
        const sp<SurfaceControl>& sc, bool shouldEnable, float width, const half4& color) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
@@ -1949,6 +1949,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::enableBo

    s->what |= layer_state_t::eRenderBorderChanged;
    s->borderEnabled = shouldEnable;
    s->borderWidth = width;
    s->borderColor = color;

    registerSurfaceControlForCallback(sc);
    return *this;
+3 −0
Original line number Diff line number Diff line
@@ -295,6 +295,9 @@ struct layer_state_t {

    // Flag to indicate if border needs to be enabled on the layer
    bool borderEnabled;
    float borderWidth;
    half4 borderColor;

    // Stretch effect to be applied to this layer
    StretchEffect stretchEffect;

+2 −1
Original line number Diff line number Diff line
@@ -625,7 +625,8 @@ public:
                                         const Rect& destinationFrame);
        Transaction& setDropInputMode(const sp<SurfaceControl>& sc, gui::DropInputMode mode);

        Transaction& enableBorder(const sp<SurfaceControl>& sc, bool shouldEnable);
        Transaction& enableBorder(const sp<SurfaceControl>& sc, bool shouldEnable, float width,
                                  const half4& color);

        status_t setDisplaySurface(const sp<IBinder>& token,
                const sp<IGraphicBufferProducer>& bufferProducer);
+4 −1
Original line number Diff line number Diff line
@@ -22,10 +22,13 @@ namespace android {
namespace renderengine {

struct BorderRenderInfo {
    float width = 0;
    half4 color;
    Region combinedRegion;

    bool operator==(const BorderRenderInfo& rhs) const {
        return (combinedRegion.hasSameRects(rhs.combinedRegion));
        return (width == rhs.width && color == rhs.color &&
                combinedRegion.hasSameRects(rhs.combinedRegion));
    }
};

Loading