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

Commit 4a3b07e1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix: Release skia resources when RenderNode layer is configured" into sc-dev am: 43038ca7

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

Change-Id: Ic0b26acf06e5add1bac87aeb95c1e2e7ed698b94
parents 2ba1b392 43038ca7
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -331,6 +331,8 @@ public:
            mSkiaLayer.reset();
            mSkiaLayer.reset();
        }
        }


        mProperties.mutateLayerProperties().mutableStretchEffect().clear();
        mStretchMask.clear();
        // Clear out the previous snapshot and the image filter the previous
        // Clear out the previous snapshot and the image filter the previous
        // snapshot was created with whenever the layer changes.
        // snapshot was created with whenever the layer changes.
        mSnapshotResult.snapshot = nullptr;
        mSnapshotResult.snapshot = nullptr;
+5 −2
Original line number Original line Diff line number Diff line
@@ -186,6 +186,7 @@ static const SkString stretchShader = SkString(R"(


static const float ZERO = 0.f;
static const float ZERO = 0.f;
static const float INTERPOLATION_STRENGTH_VALUE = 0.7f;
static const float INTERPOLATION_STRENGTH_VALUE = 0.7f;
static const char CONTENT_TEXTURE[] = "uContentTexture";


sk_sp<SkShader> StretchEffect::getShader(float width, float height,
sk_sp<SkShader> StretchEffect::getShader(float width, float height,
                                         const sk_sp<SkImage>& snapshotImage,
                                         const sk_sp<SkImage>& snapshotImage,
@@ -207,7 +208,7 @@ sk_sp<SkShader> StretchEffect::getShader(float width, float height,
        mBuilder = std::make_unique<SkRuntimeShaderBuilder>(getStretchEffect());
        mBuilder = std::make_unique<SkRuntimeShaderBuilder>(getStretchEffect());
    }
    }


    mBuilder->child("uContentTexture") =
    mBuilder->child(CONTENT_TEXTURE) =
            snapshotImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp,
            snapshotImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp,
                                      SkSamplingOptions(SkFilterMode::kLinear), matrix);
                                      SkSamplingOptions(SkFilterMode::kLinear), matrix);
    mBuilder->uniform("uInterpolationStrength").set(&INTERPOLATION_STRENGTH_VALUE, 1);
    mBuilder->uniform("uInterpolationStrength").set(&INTERPOLATION_STRENGTH_VALUE, 1);
@@ -226,7 +227,9 @@ sk_sp<SkShader> StretchEffect::getShader(float width, float height,
    mBuilder->uniform("viewportWidth").set(&width, 1);
    mBuilder->uniform("viewportWidth").set(&width, 1);
    mBuilder->uniform("viewportHeight").set(&height, 1);
    mBuilder->uniform("viewportHeight").set(&height, 1);


    return mBuilder->makeShader(nullptr, false);
    auto result = mBuilder->makeShader(nullptr, false);
    mBuilder->child(CONTENT_TEXTURE) = nullptr;
    return result;
}
}


sk_sp<SkRuntimeEffect> StretchEffect::getStretchEffect() {
sk_sp<SkRuntimeEffect> StretchEffect::getStretchEffect() {
+4 −0
Original line number Original line Diff line number Diff line
@@ -113,6 +113,10 @@ public:
        return !isEmpty();
        return !isEmpty();
    }
    }


    void clear() {
        mBuilder = nullptr;
    }

private:
private:
    static sk_sp<SkRuntimeEffect> getStretchEffect();
    static sk_sp<SkRuntimeEffect> getStretchEffect();
    mutable SkVector mStretchDirection{0, 0};
    mutable SkVector mStretchDirection{0, 0};