Incorporate Runtime Effect options into hash.
Previously, the first created Runtime Effect with a given source string was being returned for each subsequent call to Make, regardless of the passed-in Options. Change-Id: Iab95df842efd17091365291dc8ab9f54314f1276 Bug: skia:11362 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388098 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
7508b54af3
commit
bac6c8fbc8
@ -158,6 +158,7 @@ public:
|
||||
private:
|
||||
SkRuntimeEffect(SkString sksl,
|
||||
std::unique_ptr<SkSL::Program> baseProgram,
|
||||
const Options& options,
|
||||
const SkSL::FunctionDefinition& main,
|
||||
std::vector<Uniform>&& uniforms,
|
||||
std::vector<SkString>&& children,
|
||||
|
@ -243,6 +243,7 @@ SkRuntimeEffect::Result SkRuntimeEffect::Make(SkString sksl, const Options& opti
|
||||
|
||||
sk_sp<SkRuntimeEffect> effect(new SkRuntimeEffect(std::move(sksl),
|
||||
std::move(program),
|
||||
options,
|
||||
*main,
|
||||
std::move(uniforms),
|
||||
std::move(children),
|
||||
@ -313,6 +314,7 @@ size_t SkRuntimeEffect::Uniform::sizeInBytes() const {
|
||||
|
||||
SkRuntimeEffect::SkRuntimeEffect(SkString sksl,
|
||||
std::unique_ptr<SkSL::Program> baseProgram,
|
||||
const Options& options,
|
||||
const SkSL::FunctionDefinition& main,
|
||||
std::vector<Uniform>&& uniforms,
|
||||
std::vector<SkString>&& children,
|
||||
@ -332,6 +334,14 @@ SkRuntimeEffect::SkRuntimeEffect(SkString sksl,
|
||||
, fAllowColorFilter(allowColorFilter) {
|
||||
SkASSERT(fBaseProgram);
|
||||
SkASSERT(fChildren.size() == fSampleUsages.size());
|
||||
|
||||
// Everything from SkRuntimeEffect::Options which could influence the compiled result needs to
|
||||
// be accounted for in `fHash`. If you've added a new field to Options and caused the static-
|
||||
// assert below to trigger, please incorporate your field into `fHash` and update KnownOptions
|
||||
// to match the layout of Options.
|
||||
struct KnownOptions { int i; };
|
||||
static_assert(sizeof(Options) == sizeof(KnownOptions));
|
||||
fHash = SkOpts::hash_fn(&options.inlineThreshold, sizeof(options.inlineThreshold), fHash);
|
||||
}
|
||||
|
||||
SkRuntimeEffect::~SkRuntimeEffect() = default;
|
||||
|
Loading…
Reference in New Issue
Block a user