diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index fca11a98a7..2d06d120b4 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -2,6 +2,12 @@ Skia Graphics Release Notes This file includes a list of high level updates for each milestone release. +Milestone 104 +------------- + * SkRuntimeEffect takes and returns a const SkData. + +* * * + Milestone 103 ------------- * SkSamplingOptions now includes anisotropic filtering. Implemented on GPU only. diff --git a/include/effects/SkRuntimeEffect.h b/include/effects/SkRuntimeEffect.h index 84c7b78175..bc06c1aa6a 100644 --- a/include/effects/SkRuntimeEffect.h +++ b/include/effects/SkRuntimeEffect.h @@ -187,29 +187,30 @@ public: sk_sp fChild; }; - sk_sp makeShader(sk_sp uniforms, + sk_sp makeShader(sk_sp uniforms, sk_sp children[], size_t childCount, const SkMatrix* localMatrix = nullptr) const; - sk_sp makeShader(sk_sp uniforms, + sk_sp makeShader(sk_sp uniforms, SkSpan children, const SkMatrix* localMatrix = nullptr) const; sk_sp makeImage(GrRecordingContext*, - sk_sp uniforms, + sk_sp uniforms, SkSpan children, const SkMatrix* localMatrix, SkImageInfo resultInfo, bool mipmapped) const; - sk_sp makeColorFilter(sk_sp uniforms) const; - sk_sp makeColorFilter(sk_sp uniforms, + sk_sp makeColorFilter(sk_sp uniforms) const; + sk_sp makeColorFilter(sk_sp uniforms, sk_sp children[], size_t childCount) const; - sk_sp makeColorFilter(sk_sp uniforms, + sk_sp makeColorFilter(sk_sp uniforms, SkSpan children) const; - sk_sp makeBlender(sk_sp uniforms, SkSpan children = {}) const; + sk_sp makeBlender(sk_sp uniforms, + SkSpan children = {}) const; /** * Creates a new Runtime Effect patterned after an already-existing one. The new shader behaves @@ -419,7 +420,7 @@ protected: SkRuntimeEffectBuilder& operator=(SkRuntimeEffectBuilder&&) = delete; SkRuntimeEffectBuilder& operator=(const SkRuntimeEffectBuilder&) = delete; - sk_sp uniforms() { return fUniforms; } + sk_sp uniforms() { return fUniforms; } SkRuntimeEffect::ChildPtr* children() { return fChildren.data(); } size_t numChildren() { return fChildren.size(); } diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp index 195da1c2ea..0b262da5d3 100644 --- a/src/core/SkRuntimeEffect.cpp +++ b/src/core/SkRuntimeEffect.cpp @@ -779,9 +779,9 @@ const SkFilterColorProgram* SkRuntimeEffect::getFilterColorProgram() { /////////////////////////////////////////////////////////////////////////////////////////////////// -static sk_sp get_xformed_uniforms(const SkRuntimeEffect* effect, - sk_sp baseUniforms, - const SkColorSpace* dstCS) { +static sk_sp get_xformed_uniforms(const SkRuntimeEffect* effect, + sk_sp baseUniforms, + const SkColorSpace* dstCS) { using Flags = SkRuntimeEffect::Uniform::Flags; using Type = SkRuntimeEffect::Uniform::Type; SkColorSpaceXformSteps steps(sk_srgb_singleton(), kUnpremul_SkAlphaType, @@ -828,7 +828,7 @@ static sk_sp get_xformed_uniforms(const SkRuntimeEffect* effect, #if SK_SUPPORT_GPU static GrFPResult make_effect_fp(sk_sp effect, const char* name, - sk_sp uniforms, + sk_sp uniforms, std::unique_ptr inputFP, std::unique_ptr destColorFP, SkSpan children, @@ -949,7 +949,7 @@ public: class SkRuntimeColorFilter : public SkColorFilterBase { public: SkRuntimeColorFilter(sk_sp effect, - sk_sp uniforms, + sk_sp uniforms, SkSpan children) : fEffect(std::move(effect)) , fUniforms(std::move(uniforms)) @@ -959,7 +959,7 @@ public: GrFPResult asFragmentProcessor(std::unique_ptr inputFP, GrRecordingContext* context, const GrColorInfo& colorInfo) const override { - sk_sp uniforms = + sk_sp uniforms = get_xformed_uniforms(fEffect.get(), fUniforms, colorInfo.colorSpace()); SkASSERT(uniforms); @@ -982,7 +982,7 @@ public: skvm::Color onProgram(skvm::Builder* p, skvm::Color c, const SkColorInfo& colorInfo, skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override { - sk_sp inputs = + sk_sp inputs = get_xformed_uniforms(fEffect.get(), fUniforms, colorInfo.colorSpace()); SkASSERT(inputs); @@ -1008,7 +1008,7 @@ public: } // Get our specific uniform values - sk_sp inputs = get_xformed_uniforms(fEffect.get(), fUniforms, dstCS); + sk_sp inputs = get_xformed_uniforms(fEffect.get(), fUniforms, dstCS); SkASSERT(inputs); auto evalChild = [&](int index, SkPMColor4f inColor) { @@ -1043,7 +1043,7 @@ public: private: sk_sp fEffect; - sk_sp fUniforms; + sk_sp fUniforms; std::vector fChildren; }; @@ -1080,7 +1080,7 @@ class SkRTShader : public SkShaderBase { public: SkRTShader(sk_sp effect, sk_sp debugTrace, - sk_sp uniforms, + sk_sp uniforms, const SkMatrix* localMatrix, SkSpan children) : SkShaderBase(localMatrix) @@ -1107,7 +1107,7 @@ public: return nullptr; } - sk_sp uniforms = + sk_sp uniforms = get_xformed_uniforms(fEffect.get(), fUniforms, args.fDstColorInfo->colorSpace()); SkASSERT(uniforms); @@ -1135,7 +1135,7 @@ public: const SkMatrixProvider& matrices, const SkMatrix* localM, const SkColorInfo& colorInfo, skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override { - sk_sp inputs = + sk_sp inputs = get_xformed_uniforms(fEffect.get(), fUniforms, colorInfo.colorSpace()); SkASSERT(inputs); @@ -1180,7 +1180,7 @@ private: sk_sp fEffect; sk_sp fDebugTrace; - sk_sp fUniforms; + sk_sp fUniforms; std::vector fChildren; }; @@ -1232,7 +1232,7 @@ sk_sp SkRTShader::CreateProc(SkReadBuffer& buffer) { class SkRuntimeBlender : public SkBlenderBase { public: SkRuntimeBlender(sk_sp effect, - sk_sp uniforms, + sk_sp uniforms, SkSpan children) : fEffect(std::move(effect)) , fUniforms(std::move(uniforms)) @@ -1243,8 +1243,8 @@ public: skvm::Color onProgram(skvm::Builder* p, skvm::Color src, skvm::Color dst, const SkColorInfo& colorInfo, skvm::Uniforms* uniforms, SkArenaAlloc* alloc) const override { - sk_sp inputs = get_xformed_uniforms(fEffect.get(), fUniforms, - colorInfo.colorSpace()); + sk_sp inputs = get_xformed_uniforms(fEffect.get(), fUniforms, + colorInfo.colorSpace()); SkASSERT(inputs); RuntimeEffectVMCallbacks callbacks(p, uniforms, alloc, fChildren, src, colorInfo); @@ -1263,8 +1263,8 @@ public: std::unique_ptr srcFP, std::unique_ptr dstFP, const GrFPArgs& args) const override { - sk_sp uniforms = get_xformed_uniforms(fEffect.get(), fUniforms, - args.fDstColorInfo->colorSpace()); + sk_sp uniforms = get_xformed_uniforms(fEffect.get(), fUniforms, + args.fDstColorInfo->colorSpace()); SkASSERT(uniforms); auto [success, fp] = make_effect_fp(fEffect, "runtime_blender", @@ -1290,7 +1290,7 @@ private: using INHERITED = SkBlenderBase; sk_sp fEffect; - sk_sp fUniforms; + sk_sp fUniforms; std::vector fChildren; }; @@ -1323,7 +1323,7 @@ sk_sp SkRuntimeBlender::CreateProc(SkReadBuffer& buffer) { /////////////////////////////////////////////////////////////////////////////////////////////////// -sk_sp SkRuntimeEffect::makeShader(sk_sp uniforms, +sk_sp SkRuntimeEffect::makeShader(sk_sp uniforms, sk_sp childShaders[], size_t childCount, const SkMatrix* localMatrix) const { @@ -1334,7 +1334,7 @@ sk_sp SkRuntimeEffect::makeShader(sk_sp uniforms, return this->makeShader(std::move(uniforms), SkMakeSpan(children), localMatrix); } -sk_sp SkRuntimeEffect::makeShader(sk_sp uniforms, +sk_sp SkRuntimeEffect::makeShader(sk_sp uniforms, SkSpan children, const SkMatrix* localMatrix) const { if (!this->allowShader()) { @@ -1354,7 +1354,7 @@ sk_sp SkRuntimeEffect::makeShader(sk_sp uniforms, } sk_sp SkRuntimeEffect::makeImage(GrRecordingContext* rContext, - sk_sp uniforms, + sk_sp uniforms, SkSpan children, const SkMatrix* localMatrix, SkImageInfo resultInfo, @@ -1436,7 +1436,7 @@ sk_sp SkRuntimeEffect::makeImage(GrRecordingContext* rContext, return surf->makeImageSnapshot(); } -sk_sp SkRuntimeEffect::makeColorFilter(sk_sp uniforms, +sk_sp SkRuntimeEffect::makeColorFilter(sk_sp uniforms, sk_sp childColorFilters[], size_t childCount) const { SkSTArray<4, ChildPtr> children(childCount); @@ -1446,7 +1446,7 @@ sk_sp SkRuntimeEffect::makeColorFilter(sk_sp uniforms, return this->makeColorFilter(std::move(uniforms), SkMakeSpan(children)); } -sk_sp SkRuntimeEffect::makeColorFilter(sk_sp uniforms, +sk_sp SkRuntimeEffect::makeColorFilter(sk_sp uniforms, SkSpan children) const { if (!this->allowColorFilter()) { return nullptr; @@ -1463,11 +1463,11 @@ sk_sp SkRuntimeEffect::makeColorFilter(sk_sp uniforms, return sk_make_sp(sk_ref_sp(this), std::move(uniforms), children); } -sk_sp SkRuntimeEffect::makeColorFilter(sk_sp uniforms) const { +sk_sp SkRuntimeEffect::makeColorFilter(sk_sp uniforms) const { return this->makeColorFilter(std::move(uniforms), /*children=*/{}); } -sk_sp SkRuntimeEffect::makeBlender(sk_sp uniforms, +sk_sp SkRuntimeEffect::makeBlender(sk_sp uniforms, SkSpan children) const { if (!this->allowBlender()) { return nullptr; diff --git a/src/core/SkWriteBuffer.h b/src/core/SkWriteBuffer.h index b942733bd1..2441087f17 100644 --- a/src/core/SkWriteBuffer.h +++ b/src/core/SkWriteBuffer.h @@ -28,7 +28,7 @@ public: virtual void writePad32(const void* buffer, size_t bytes) = 0; virtual void writeByteArray(const void* data, size_t size) = 0; - void writeDataAsByteArray(SkData* data) { + void writeDataAsByteArray(const SkData* data) { if (!data) { this->write32(0); } else { diff --git a/src/gpu/ganesh/effects/GrSkSLFP.cpp b/src/gpu/ganesh/effects/GrSkSLFP.cpp index dc784d1df8..c039cbbc5c 100644 --- a/src/gpu/ganesh/effects/GrSkSLFP.cpp +++ b/src/gpu/ganesh/effects/GrSkSLFP.cpp @@ -293,7 +293,7 @@ std::unique_ptr GrSkSLFP::MakeWithData( sk_sp dstColorSpace, std::unique_ptr inputFP, std::unique_ptr destColorFP, - sk_sp uniforms, + sk_sp uniforms, SkSpan> childFPs) { if (uniforms->size() != effect->uniformSize()) { return nullptr; diff --git a/src/gpu/ganesh/effects/GrSkSLFP.h b/src/gpu/ganesh/effects/GrSkSLFP.h index 5520e4d0b5..72ed4e45da 100644 --- a/src/gpu/ganesh/effects/GrSkSLFP.h +++ b/src/gpu/ganesh/effects/GrSkSLFP.h @@ -106,7 +106,7 @@ public: sk_sp dstColorSpace, std::unique_ptr inputFP, std::unique_ptr destColorFP, - sk_sp uniforms, + sk_sp uniforms, SkSpan> childFPs); /*