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

Commit 19c8f0e4 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Add support for background blurs

Bug: 141640413
Fixes: 146384234
Test: adb shell setprop debug.sf.disableBlurs 1
Test: adb shell setprop debug.sf.gaussianBlur 0
Test: adb shell setprop ro.surface_flinger.supports_background_blur 1
Test: ./SurfaceFlinger_test --gtest_filter=Layer*Tests/Layer*Test.SetBackgroundBlur*
Test: ./librenderengine_test --gtest_filter=*BlurBackground*"
Test: atest SurfaceFlinger_test:SurfaceInterceptorTest#InterceptBackgroundBlurRadiusUpdateWorks
Change-Id: I5194c910fe7062f33e70943867012539e6c6626a
parent fbb86a6b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ message SurfaceChange {
        RelativeParentChange        relative_parent         = 18;
        DetachChildrenChange        detach_children         = 19;
        ReparentChildrenChange      reparent_children       = 20;
        BackgroundBlurRadiusChange  background_blur_radius  = 21;
        ShadowRadiusChange          shadow_radius           = 22;
    }
}
@@ -73,6 +74,10 @@ message CornerRadiusChange {
    required float corner_radius = 1;
}

message BackgroundBlurRadiusChange {
    required float background_blur_radius = 1;
}

message LayerChange {
    required uint32 layer = 1;
}
+8 −0
Original line number Diff line number Diff line
@@ -510,6 +510,14 @@ void Replayer::setCornerRadius(SurfaceComposerClient::Transaction& t,
    t.setCornerRadius(mLayers[id], cc.corner_radius());
}

void Replayer::setBackgroundBlurRadius(SurfaceComposerClient::Transaction& t,
        layer_id id, const BackgroundBlurRadiusChange& cc) {
    ALOGV("Layer %d: Setting Background Blur Radius -- backgroundBlurRadius=%d", id,
        cc.background_blur_radius());

    t.setBackgroundBlurRadius(mLayers[id], cc.background_blur_radius());
}

void Replayer::setMatrix(SurfaceComposerClient::Transaction& t,
        layer_id id, const MatrixChange& mc) {
    ALOGV("Layer %d: Setting Matrix -- dsdx=%f, dtdx=%f, dsdy=%f, dtdy=%f", id, mc.dsdx(),
+2 −0
Original line number Diff line number Diff line
@@ -94,6 +94,8 @@ class Replayer {
            layer_id id, const CropChange& cc);
    void setCornerRadius(SurfaceComposerClient::Transaction& t,
            layer_id id, const CornerRadiusChange& cc);
    void setBackgroundBlurRadius(SurfaceComposerClient::Transaction& t,
            layer_id id, const BackgroundBlurRadiusChange& cc);
    void setMatrix(SurfaceComposerClient::Transaction& t,
            layer_id id, const MatrixChange& mc);
    void setOverrideScalingMode(SurfaceComposerClient::Transaction& t,
+6 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ status_t layer_state_t::write(Parcel& output) const
    memcpy(output.writeInplace(16 * sizeof(float)),
           colorTransform.asArray(), 16 * sizeof(float));
    output.writeFloat(cornerRadius);
    output.writeUint32(backgroundBlurRadius);
    output.writeStrongBinder(cachedBuffer.token.promote());
    output.writeUint64(cachedBuffer.id);
    output.writeParcelable(metadata);
@@ -173,6 +174,7 @@ status_t layer_state_t::read(const Parcel& input)

    colorTransform = mat4(static_cast<const float*>(input.readInplace(16 * sizeof(float))));
    cornerRadius = input.readFloat();
    backgroundBlurRadius = input.readUint32();
    cachedBuffer.token = input.readStrongBinder();
    cachedBuffer.id = input.readUint64();
    input.readParcelable(&metadata);
@@ -307,6 +309,10 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eCornerRadiusChanged;
        cornerRadius = other.cornerRadius;
    }
    if (other.what & eBackgroundBlurRadiusChanged) {
        what |= eBackgroundBlurRadiusChanged;
        backgroundBlurRadius = other.backgroundBlurRadius;
    }
    if (other.what & eDeferTransaction_legacy) {
        what |= eDeferTransaction_legacy;
        barrierHandle_legacy = other.barrierHandle_legacy;
+12 −0
Original line number Diff line number Diff line
@@ -918,6 +918,18 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setCorne
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBackgroundBlurRadius(
        const sp<SurfaceControl>& sc, int backgroundBlurRadius) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }
    s->what |= layer_state_t::eBackgroundBlurRadiusChanged;
    s->backgroundBlurRadius = backgroundBlurRadius;
    return *this;
}

SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction::deferTransactionUntil_legacy(const sp<SurfaceControl>& sc,
                                                                 const sp<IBinder>& handle,
Loading