Zero-initialize uniform data in SkRuntimeEffectBuilder
Change-Id: Id7445c28fca3a74cb2716832e821d651be7bb883 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/473142 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
acec7450ec
commit
1c3b75bf35
@ -86,6 +86,12 @@ public:
|
||||
*/
|
||||
static sk_sp<SkData> MakeUninitialized(size_t length);
|
||||
|
||||
/**
|
||||
* Create a new data with zero-initialized contents. The caller should call writable_data()
|
||||
* to write into the buffer, but this must be done before another ref() is made.
|
||||
*/
|
||||
static sk_sp<SkData> MakeZeroInitialized(size_t length);
|
||||
|
||||
/**
|
||||
* Create a new dataref by copying the specified c-string
|
||||
* (a null-terminated array of bytes). The returned SkData will have size()
|
||||
|
@ -380,7 +380,7 @@ protected:
|
||||
SkRuntimeEffectBuilder() = delete;
|
||||
explicit SkRuntimeEffectBuilder(sk_sp<SkRuntimeEffect> effect)
|
||||
: fEffect(std::move(effect))
|
||||
, fUniforms(SkData::MakeUninitialized(fEffect->uniformSize()))
|
||||
, fUniforms(SkData::MakeZeroInitialized(fEffect->uniformSize()))
|
||||
, fChildren(fEffect->children().size()) {}
|
||||
|
||||
SkRuntimeEffectBuilder(SkRuntimeEffectBuilder&&) = default;
|
||||
|
@ -111,6 +111,14 @@ sk_sp<SkData> SkData::MakeUninitialized(size_t length) {
|
||||
return PrivateNewWithCopy(nullptr, length);
|
||||
}
|
||||
|
||||
sk_sp<SkData> SkData::MakeZeroInitialized(size_t length) {
|
||||
auto data = MakeUninitialized(length);
|
||||
if (length != 0) {
|
||||
memset(data->writable_data(), 0, data->size());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
sk_sp<SkData> SkData::MakeWithProc(const void* ptr, size_t length, ReleaseProc proc, void* ctx) {
|
||||
return sk_sp<SkData>(new SkData(ptr, length, proc, ctx));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user