Ensure that ArithmeticFPInputs is fully initialized

Change-Id: Ia5e94704955aba33e07592711656fbeefef15912
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268840
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2020-02-05 13:13:32 -05:00 committed by Skia Commit-Bot
parent ba51d6859e
commit 0a3c57f1ad
3 changed files with 12 additions and 7 deletions

View File

@ -11,6 +11,15 @@
#include "include/core/SkImageFilter.h"
struct ArithmeticFPInputs {
ArithmeticFPInputs(float k0, float k1, float k2, float k3, bool enforcePMColor) {
memset(this, 0, sizeof(*this));
fK[0] = k0;
fK[1] = k1;
fK[2] = k2;
fK[3] = k3;
fEnforcePMColor = enforcePMColor;
}
float fK[4];
bool fEnforcePMColor;
};

View File

@ -52,7 +52,7 @@ class ArithmeticImageFilterImpl final : public SkImageFilter_Base {
public:
ArithmeticImageFilterImpl(float k1, float k2, float k3, float k4, bool enforcePMColor,
sk_sp<SkImageFilter> inputs[2], const CropRect* cropRect)
: INHERITED(inputs, 2, cropRect), fInputs{{k1, k2, k3, k4}, enforcePMColor} {}
: INHERITED(inputs, 2, cropRect), fInputs{k1, k2, k3, k4, enforcePMColor} {}
protected:
sk_sp<SkSpecialImage> onFilterImage(const Context&, SkIPoint* offset) const override;

View File

@ -279,12 +279,8 @@ std::unique_ptr<GrFragmentProcessor> GrSkSLFP::TestCreate(GrProcessorTestData* d
}
case 1: {
static auto effect = std::get<0>(SkRuntimeEffect::Make(SkString(SKSL_ARITHMETIC_SRC)));
ArithmeticFPInputs inputs;
inputs.fK[0] = d->fRandom->nextF();
inputs.fK[1] = d->fRandom->nextF();
inputs.fK[2] = d->fRandom->nextF();
inputs.fK[3] = d->fRandom->nextF();
inputs.fEnforcePMColor = d->fRandom->nextBool();
ArithmeticFPInputs inputs{d->fRandom->nextF(), d->fRandom->nextF(), d->fRandom->nextF(),
d->fRandom->nextF(), d->fRandom->nextBool()};
auto result = GrSkSLFP::Make(d->context(), effect, "Arithmetic",
SkData::MakeWithCopy(&inputs, sizeof(inputs)));
result->addChild(GrConstColorProcessor::Make(