diff --git a/libs/hwui/RenderNode.h b/libs/hwui/RenderNode.h index c770150650e2b..45a4f6c9c70db 100644 --- a/libs/hwui/RenderNode.h +++ b/libs/hwui/RenderNode.h @@ -331,6 +331,8 @@ public: mSkiaLayer.reset(); } + mProperties.mutateLayerProperties().mutableStretchEffect().clear(); + mStretchMask.clear(); // Clear out the previous snapshot and the image filter the previous // snapshot was created with whenever the layer changes. mSnapshotResult.snapshot = nullptr; diff --git a/libs/hwui/effects/StretchEffect.cpp b/libs/hwui/effects/StretchEffect.cpp index 43f805d906a5e..17cd3ceb577c8 100644 --- a/libs/hwui/effects/StretchEffect.cpp +++ b/libs/hwui/effects/StretchEffect.cpp @@ -186,6 +186,7 @@ static const SkString stretchShader = SkString(R"( static const float ZERO = 0.f; static const float INTERPOLATION_STRENGTH_VALUE = 0.7f; +static const char CONTENT_TEXTURE[] = "uContentTexture"; sk_sp StretchEffect::getShader(float width, float height, const sk_sp& snapshotImage, @@ -207,7 +208,7 @@ sk_sp StretchEffect::getShader(float width, float height, mBuilder = std::make_unique(getStretchEffect()); } - mBuilder->child("uContentTexture") = + mBuilder->child(CONTENT_TEXTURE) = snapshotImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, SkSamplingOptions(SkFilterMode::kLinear), matrix); mBuilder->uniform("uInterpolationStrength").set(&INTERPOLATION_STRENGTH_VALUE, 1); @@ -226,7 +227,9 @@ sk_sp StretchEffect::getShader(float width, float height, mBuilder->uniform("viewportWidth").set(&width, 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 StretchEffect::getStretchEffect() { diff --git a/libs/hwui/effects/StretchEffect.h b/libs/hwui/effects/StretchEffect.h index 25777c278a118..3eab9f05ebe52 100644 --- a/libs/hwui/effects/StretchEffect.h +++ b/libs/hwui/effects/StretchEffect.h @@ -113,6 +113,10 @@ public: return !isEmpty(); } + void clear() { + mBuilder = nullptr; + } + private: static sk_sp getStretchEffect(); mutable SkVector mStretchDirection{0, 0};