diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp index 5f3c95c387..b39730467c 100644 --- a/src/shaders/SkPictureShader.cpp +++ b/src/shaders/SkPictureShader.cpp @@ -15,6 +15,7 @@ #include "src/core/SkPicturePriv.h" #include "src/core/SkReadBuffer.h" #include "src/core/SkResourceCache.h" +#include "src/core/SkVM.h" #include "src/shaders/SkBitmapProcShader.h" #include "src/shaders/SkImageShader.h" #include @@ -271,6 +272,23 @@ bool SkPictureShader::onAppendStages(const SkStageRec& rec) const { return as_SB(bitmapShader)->appendStages(localRec); } +skvm::Color SkPictureShader::onProgram(skvm::Builder* p, + skvm::F32 x, skvm::F32 y, skvm::Color paint, + const SkMatrix& ctm, const SkMatrix* localM, + SkFilterQuality quality, const SkColorInfo& dst, + skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const { + auto lm = this->totalLocalMatrix(localM); + + // Keep bitmapShader alive by using alloc instead of stack memory + auto& bitmapShader = *alloc->make>(); + bitmapShader = this->refBitmapShader(ctm, &lm, dst.colorType(), dst.colorSpace()); + if (!bitmapShader) { + return {}; + } + + return as_SB(bitmapShader)->program(p, x,y, paint, ctm, lm, quality, dst, uniforms, alloc); +} + ///////////////////////////////////////////////////////////////////////////////////////// #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT diff --git a/src/shaders/SkPictureShader.h b/src/shaders/SkPictureShader.h index 69a3530b16..0bdc9cd9e0 100644 --- a/src/shaders/SkPictureShader.h +++ b/src/shaders/SkPictureShader.h @@ -37,6 +37,11 @@ protected: SkPictureShader(SkReadBuffer&); void flatten(SkWriteBuffer&) const override; bool onAppendStages(const SkStageRec&) const override; + skvm::Color onProgram(skvm::Builder*, skvm::F32 x, skvm::F32 y, skvm::Color paint, + const SkMatrix& ctm, const SkMatrix* localM, + SkFilterQuality quality, const SkColorInfo& dst, + skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override; + #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override; #endif