skvm for picture-shader

After this, it appears that the only remaining shaders w/o skvm are:
- perlinnoise
- lighting
- runtime (sksl)

EmptyShader doesn't, but it is supposed to return failure.

Change-Id: Iab2393e1846b92089de837614ba1fb5543a76432
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278419
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Reed 2020-03-21 18:02:58 -04:00 committed by Skia Commit-Bot
parent bc0fe058f8
commit cb1a2df616
2 changed files with 23 additions and 0 deletions

View File

@ -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 <atomic>
@ -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<sk_sp<SkShader>>();
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

View File

@ -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