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

Commit 2dfc98b6 authored by Nader Jawad's avatar Nader Jawad
Browse files

Update SurfaceFlinger to handle stretching

of surfaces that are part of a scrolling container

Bug: 184297961
Test: In progress
Change-Id: I959df097ae1fc833fb755f1fb2d759d79f260963
parent a0e37d28
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -119,9 +119,11 @@ std::string to_string(const LayerDebugInfo& info) {
    info.mSurfaceDamageRegion.dump(result, "SurfaceDamageRegion");
    if (info.mStretchEffect.hasEffect()) {
        const auto& se = info.mStretchEffect;
        StringAppendF(&result, "  StretchEffect area=[%f, %f, %f, %f] vec=(%f, %f) maxAmount=%f\n",
                      se.area.left, se.area.top, se.area.right, se.area.bottom, se.vectorX,
                      se.vectorY, se.maxAmount);
        StringAppendF(&result,
                      "  StretchEffect width = %f, height = %f vec=(%f, %f) "
                      "maxAmount=(%f, %f)\n",
                      se.width, se.height,
                      se.vectorX, se.vectorY, se.maxAmountX, se.maxAmountY);
    }

    StringAppendF(&result, "      layerStack=%4d, z=%9d, pos=(%g,%g), size=(%4d,%4d), ",
+2 −6
Original line number Diff line number Diff line
@@ -1648,8 +1648,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setApply
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setStretchEffect(
        const sp<SurfaceControl>& sc, float left, float top, float right, float bottom, float vecX,
        float vecY, float maxAmount) {
    const sp<SurfaceControl>& sc, const StretchEffect& stretchEffect) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
@@ -1657,10 +1656,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setStret
    }

    s->what |= layer_state_t::eStretchChanged;
    s->stretchEffect = StretchEffect{.area = {left, top, right, bottom},
                                     .vectorX = vecX,
                                     .vectorY = vecY,
                                     .maxAmount = maxAmount};
    s->stretchEffect = stretchEffect;
    return *this;
}

+14 −3
Original line number Diff line number Diff line
@@ -538,9 +538,20 @@ public:
        // transactions from blocking each other.
        Transaction& setApplyToken(const sp<IBinder>& token);

        Transaction& setStretchEffect(const sp<SurfaceControl>& sc, float left, float top,
                                      float right, float bottom, float vecX, float vecY,
                                      float maxAmount);
        /**
         * Provides the stretch effect configured on a container that the
         * surface is rendered within.
         * @param sc target surface the stretch should be applied to
         * @param stretchEffect the corresponding stretch effect to be applied
         *    to the surface. This can be directly on the surface itself or
         *    configured from a parent of the surface in which case the
         *    StretchEffect provided has parameters mapping the position of
         *    the surface within the container that has the stretch configured
         *    on it
         * @return The transaction being constructed
         */
        Transaction& setStretchEffect(const sp<SurfaceControl>& sc,
                                      const StretchEffect& stretchEffect);

        Transaction& setBufferCrop(const sp<SurfaceControl>& sc, const Rect& bufferCrop);

+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ filegroup {
        "skia/debug/SkiaMemoryReporter.cpp",
        "skia/filters/BlurFilter.cpp",
        "skia/filters/LinearEffect.cpp",
        "skia/filters/StretchShaderFactory.cpp"
    ],
}

+19 −1
Original line number Diff line number Diff line
@@ -222,7 +222,8 @@ static inline bool operator==(const LayerSettings& lhs, const LayerSettings& rhs
            lhs.sourceDataspace == rhs.sourceDataspace &&
            lhs.colorTransform == rhs.colorTransform &&
            lhs.disableBlending == rhs.disableBlending && lhs.shadow == rhs.shadow &&
            lhs.backgroundBlurRadius == rhs.backgroundBlurRadius;
            lhs.backgroundBlurRadius == rhs.backgroundBlurRadius &&
            lhs.stretchEffect == rhs.stretchEffect;
}

// Defining PrintTo helps with Google Tests.
@@ -272,6 +273,21 @@ static inline void PrintTo(const ShadowSettings& settings, ::std::ostream* os) {
    *os << "\n}";
}

static inline void PrintTo(const StretchEffect& effect, ::std::ostream* os) {
    *os << "StretchEffect {";
    *os << "\n     .width = " << effect.width;
    *os << "\n     .height = " << effect.height;
    *os << "\n     .vectorX = " << effect.vectorX;
    *os << "\n     .vectorY = " << effect.vectorY;
    *os << "\n     .maxAmountX = " << effect.maxAmountX;
    *os << "\n     .maxAmountY = " << effect.maxAmountY;
    *os << "\n     .mappedLeft = " << effect.mappedChildBounds.left;
    *os << "\n     .mappedTop = " << effect.mappedChildBounds.top;
    *os << "\n     .mappedRight = " << effect.mappedChildBounds.right;
    *os << "\n     .mappedBottom = " << effect.mappedChildBounds.bottom;
    *os << "\n}";
}

static inline void PrintTo(const LayerSettings& settings, ::std::ostream* os) {
    *os << "LayerSettings {";
    *os << "\n    .geometry = ";
@@ -290,6 +306,8 @@ static inline void PrintTo(const LayerSettings& settings, ::std::ostream* os) {
    }
    *os << "\n    .shadow = ";
    PrintTo(settings.shadow, os);
    *os << "\n    .stretchEffect = ";
    PrintTo(settings.stretchEffect, os);
    *os << "\n}";
}

Loading