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

Commit 1d58e97b authored by Robin Lee's avatar Robin Lee
Browse files

Add DoF zoom to SurfaceControl background blur

Test: atest LayerLifecycleManagerTest
Bug: 391463550
Flag: com.android.systemui.spatial_model_pushback_in_shader
Change-Id: Ie83268991bcfe8a7ddfc83e9d33009bf33051e96
parent a01e1977
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ layer_state_t::layer_state_t()
        cornerRadius(0.0f),
        clientDrawnCornerRadius(0.0f),
        backgroundBlurRadius(0),
        backgroundBlurScale{1.0f},
        color(0),
        bufferTransform(0),
        transformToDisplayInverse(false),
@@ -166,6 +167,7 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.writeFloat, cornerRadius);
    SAFE_PARCEL(output.writeFloat, clientDrawnCornerRadius);
    SAFE_PARCEL(output.writeUint32, backgroundBlurRadius);
    SAFE_PARCEL(output.writeFloat, backgroundBlurScale);
    SAFE_PARCEL(output.writeParcelable, metadata);
    SAFE_PARCEL(output.writeFloat, bgColor.r);
    SAFE_PARCEL(output.writeFloat, bgColor.g);
@@ -305,6 +307,7 @@ status_t layer_state_t::read(const Parcel& input)
    SAFE_PARCEL(input.readFloat, &cornerRadius);
    SAFE_PARCEL(input.readFloat, &clientDrawnCornerRadius);
    SAFE_PARCEL(input.readUint32, &backgroundBlurRadius);
    SAFE_PARCEL(input.readFloat, &backgroundBlurScale);
    SAFE_PARCEL(input.readParcelable, &metadata);

    SAFE_PARCEL(input.readFloat, &tmpFloat);
@@ -637,6 +640,10 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eBackgroundBlurRadiusChanged;
        backgroundBlurRadius = other.backgroundBlurRadius;
    }
    if (other.what & eBackgroundBlurScaleChanged) {
        what |= eBackgroundBlurScaleChanged;
        backgroundBlurScale = other.backgroundBlurScale;
    }
    if (other.what & eBlurRegionsChanged) {
        what |= eBlurRegionsChanged;
        blurRegions = other.blurRegions;
@@ -860,6 +867,7 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
    CHECK_DIFF(diff, eCornerRadiusChanged, other, cornerRadius);
    CHECK_DIFF(diff, eClientDrawnCornerRadiusChanged, other, clientDrawnCornerRadius);
    CHECK_DIFF(diff, eBackgroundBlurRadiusChanged, other, backgroundBlurRadius);
    CHECK_DIFF(diff, eBackgroundBlurScaleChanged, other, backgroundBlurScale);
    if (other.what & eBlurRegionsChanged) diff |= eBlurRegionsChanged;
    if (other.what & eRelativeLayerChanged) {
        diff |= eRelativeLayerChanged;
+12 −0
Original line number Diff line number Diff line
@@ -1698,6 +1698,18 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBackg
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBackgroundBlurScale(
        const sp<SurfaceControl>& sc, float backgroundBlurScale) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }
    s->what |= layer_state_t::eBackgroundBlurScaleChanged;
    s->backgroundBlurScale = backgroundBlurScale;
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBlurRegions(
        const sp<SurfaceControl>& sc, const std::vector<BlurRegion>& blurRegions) {
    layer_state_t* s = getLayerState(sc);
+10 −5
Original line number Diff line number Diff line
@@ -255,6 +255,7 @@ struct layer_state_t {
        eBorderSettingsChanged = 0x400000'00000000,
        eBoxShadowSettingsChanged = 0x800000'00000000,
        eStopLayerChanged = 0x1000000'00000000,
        eBackgroundBlurScaleChanged = 0x2000000'00000000,
    };

    layer_state_t();
@@ -293,7 +294,8 @@ struct layer_state_t {
    // Content updates.
    static constexpr uint64_t CONTENT_CHANGES = layer_state_t::BUFFER_CHANGES |
            layer_state_t::eAlphaChanged | layer_state_t::eAutoRefreshChanged |
            layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBackgroundColorChanged |
            layer_state_t::eBackgroundBlurRadiusChanged |
            layer_state_t::eBackgroundBlurScaleChanged | layer_state_t::eBackgroundColorChanged |
            layer_state_t::eBlurRegionsChanged | layer_state_t::eColorChanged |
            layer_state_t::eColorSpaceAgnosticChanged | layer_state_t::eColorTransformChanged |
            layer_state_t::eCornerRadiusChanged | layer_state_t::eDimmingEnabledChanged |
@@ -309,7 +311,8 @@ struct layer_state_t {
    // Changes affecting child states.
    static constexpr uint64_t AFFECTS_CHILDREN = layer_state_t::GEOMETRY_CHANGES |
            layer_state_t::HIERARCHY_CHANGES | layer_state_t::eAlphaChanged |
            layer_state_t::eBackgroundBlurRadiusChanged | layer_state_t::eBlurRegionsChanged |
            layer_state_t::eBackgroundBlurRadiusChanged |
            layer_state_t::eBackgroundBlurScaleChanged | layer_state_t::eBlurRegionsChanged |
            layer_state_t::eColorTransformChanged | layer_state_t::eCornerRadiusChanged |
            layer_state_t::eFlagsChanged | layer_state_t::eTrustedOverlayChanged |
            layer_state_t::eFrameRateChanged | layer_state_t::eFrameRateCategoryChanged |
@@ -327,9 +330,10 @@ struct layer_state_t {

    // Changes that force GPU composition.
    static constexpr uint64_t COMPOSITION_EFFECTS = layer_state_t::eBackgroundBlurRadiusChanged |
            layer_state_t::eBlurRegionsChanged | layer_state_t::eCornerRadiusChanged |
            layer_state_t::eShadowRadiusChanged | layer_state_t::eStretchChanged |
            layer_state_t::eBorderSettingsChanged | layer_state_t::eBoxShadowSettingsChanged;
            layer_state_t::eBackgroundBlurScaleChanged | layer_state_t::eBlurRegionsChanged |
            layer_state_t::eCornerRadiusChanged | layer_state_t::eShadowRadiusChanged |
            layer_state_t::eStretchChanged | layer_state_t::eBorderSettingsChanged |
            layer_state_t::eBoxShadowSettingsChanged;

    bool hasValidBuffer() const;
    void sanitize(int32_t permissions);
@@ -387,6 +391,7 @@ struct layer_state_t {
    float cornerRadius;
    float clientDrawnCornerRadius;
    uint32_t backgroundBlurRadius;
    float backgroundBlurScale;

    half4 color;

+2 −0
Original line number Diff line number Diff line
@@ -583,6 +583,8 @@ public:
                                                float clientDrawnCornerRadius);
        Transaction& setBackgroundBlurRadius(const sp<SurfaceControl>& sc,
                                             int backgroundBlurRadius);
        Transaction& setBackgroundBlurScale(const sp<SurfaceControl>& sc,
                                             float backgroundBlurScale);
        Transaction& setBlurRegions(const sp<SurfaceControl>& sc,
                                    const std::vector<BlurRegion>& regions);
        Transaction& setLayerStack(const sp<SurfaceControl>&, ui::LayerStack);
+3 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ struct LayerSettings {
    gui::BoxShadowSettings boxShadowSettings;

    int backgroundBlurRadius = 0;
    float backgroundBlurScale = 1.0f;

    std::vector<BlurRegion> blurRegions;

@@ -201,6 +202,7 @@ static inline bool operator==(const LayerSettings& lhs, const LayerSettings& rhs
            lhs.disableBlending == rhs.disableBlending &&
            lhs.skipContentDraw == rhs.skipContentDraw && lhs.shadow == rhs.shadow &&
            lhs.backgroundBlurRadius == rhs.backgroundBlurRadius &&
            lhs.backgroundBlurScale == rhs.backgroundBlurScale &&
            lhs.blurRegionTransform == rhs.blurRegionTransform &&
            lhs.stretchEffect == rhs.stretchEffect &&
            lhs.edgeExtensionEffect == rhs.edgeExtensionEffect &&
@@ -303,6 +305,7 @@ static inline void PrintTo(const LayerSettings& settings, ::std::ostream* os) {
        PrintTo(settings.shadow, os);
    }
    *os << "\n    .backgroundBlurRadius = " << settings.backgroundBlurRadius;
    *os << "\n    .backgroundBlurScale = " << settings.backgroundBlurScale;
    if (settings.blurRegions.size()) {
        *os << "\n    .blurRegions =";
        for (auto blurRegion : settings.blurRegions) {
Loading