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

Commit efc921d5 authored by Nader Jawad's avatar Nader Jawad Committed by Automerger Merge Worker
Browse files

Merge "Updated SkiaGLRenderEngine to no longer adjust stretch bounds" into...

Merge "Updated SkiaGLRenderEngine to no longer adjust stretch bounds" into sc-dev am: d16d3a03 am: 3a023c4f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14470203

Change-Id: If16d22b75165f419b7f6bb0b5bb99d65a14458af
parents e4e9302b 3a023c4f
Loading
Loading
Loading
Loading
+6 −39
Original line number Diff line number Diff line
@@ -560,7 +560,11 @@ sk_sp<SkShader> SkiaGLRenderEngine::createRuntimeEffectShader(
        const LayerSettings* layer, const DisplaySettings& display, bool undoPremultipliedAlpha,
        bool requiresLinearEffect) {
    const auto stretchEffect = layer->stretchEffect;
    if (stretchEffect.hasEffect()) {
    // The given surface will be stretched by HWUI via matrix transformation
    // which gets similar results for most surfaces
    // Determine later on if we need to leverage the stertch shader within
    // surface flinger
    if (stretchEffect.hasEffect() && /* DISABLES CODE */ (false)) {
        const auto targetBuffer = layer->source.buffer.buffer;
        const auto graphicsBuffer = targetBuffer ? targetBuffer->getBuffer() : nullptr;
        if (graphicsBuffer && shader) {
@@ -653,33 +657,6 @@ private:
    int mSaveCount;
};

void drawStretch(const SkRect& bounds, const StretchEffect& stretchEffect,
                 SkCanvas* canvas, const SkPaint& paint) {
    float top = bounds.top();
    float left = bounds.left();
    float bottom = bounds.bottom();
    float right = bounds.right();
    // Adjust the drawing bounds based on the stretch itself.
    float stretchOffsetX =
        round(bounds.width() * stretchEffect.getStretchWidthMultiplier());
    float stretchOffsetY =
        round(bounds.height() * stretchEffect.getStretchHeightMultiplier());
    if (stretchEffect.vectorY < 0.f) {
        top -= stretchOffsetY;
    } else if (stretchEffect.vectorY > 0.f){
        bottom += stretchOffsetY;
    }

    if (stretchEffect.vectorX < 0.f) {
        left -= stretchOffsetX;
    } else if (stretchEffect.vectorX > 0.f) {
        right += stretchOffsetX;
    }

    auto stretchBounds = SkRect::MakeLTRB(left, top, right, bottom);
    canvas->drawRect(stretchBounds, paint);
}

static SkRRect getBlurRRect(const BlurRegion& region) {
    const auto rect = SkRect::MakeLTRB(region.left, region.top, region.right, region.bottom);
    const SkVector radii[4] = {SkVector::Make(region.cornerRadiusTL, region.cornerRadiusTL),
@@ -1052,19 +1029,9 @@ status_t SkiaGLRenderEngine::drawLayers(const DisplaySettings& display,
        if (!bounds.isRect()) {
            paint.setAntiAlias(true);
            canvas->drawRRect(bounds, paint);
        } else {
            auto& stretchEffect = layer->stretchEffect;
            // TODO (njawad) temporarily disable manipulation of geometry
            //  the layer bounds will be updated in HWUI instead of RenderEngine
            //  in a subsequent CL
            // Keep the method call in a dead code path to make -Werror happy
            // with unused methods
            if (stretchEffect.hasEffect() && /* DISABLES CODE */ (false)) {
                drawStretch(bounds.rect(), stretchEffect, canvas, paint);
        } else {
            canvas->drawRect(bounds.rect(), paint);
        }
        }
        if (kFlushAfterEveryLayer) {
            ATRACE_NAME("flush surface");
            activeSurface->flush();
+4 −5
Original line number Diff line number Diff line
@@ -69,9 +69,8 @@ static const SkString stretchShader = SkString(R"(
    // and the other way around.
    uniform float uInterpolationStrength;

    float easeInCubic(float t, float d) {
        float tmp = t * d;
        return tmp * tmp * tmp;
    float easeIn(float t, float d) {
        return t * d;
    }

    float computeOverscrollStart(
@@ -84,7 +83,7 @@ static const SkString stretchShader = SkString(R"(
    ) {
        float offsetPos = uStretchAffectedDist - inPos;
        float posBasedVariation = mix(
                1. ,easeInCubic(offsetPos, uInverseStretchAffectedDist), interpolationStrength);
                1. ,easeIn(offsetPos, uInverseStretchAffectedDist), interpolationStrength);
        float stretchIntensity = overscroll * posBasedVariation;
        return distanceStretched - (offsetPos / (1. + stretchIntensity));
    }
@@ -100,7 +99,7 @@ static const SkString stretchShader = SkString(R"(
    ) {
        float offsetPos = inPos - reverseStretchDist;
        float posBasedVariation = mix(
                1. ,easeInCubic(offsetPos, uInverseStretchAffectedDist), interpolationStrength);
                1. ,easeIn(offsetPos, uInverseStretchAffectedDist), interpolationStrength);
        float stretchIntensity = (-overscroll) * posBasedVariation;
        return 1 - (distanceStretched - (offsetPos / (1. + stretchIntensity)));
    }