Ensure ScriptIntrinsicHistogram is given a valid Element in constructor when used via C++ bindings. Correct checks for compatible elements within ScriptIntrinsicHistogram. Add missing setVar within variable setters. Change-Id: I404058d231676d9c7403d4327053421a624f5ae9
diff --git a/cpp/ScriptIntrinsics.cpp b/cpp/ScriptIntrinsics.cpp index a9a31f8..e40d1a0 100644 --- a/cpp/ScriptIntrinsics.cpp +++ b/cpp/ScriptIntrinsics.cpp
@@ -419,8 +419,8 @@ Script::setVar(0, (void*)v, sizeof(float) * 25); } -sp<ScriptIntrinsicHistogram> ScriptIntrinsicHistogram::create(sp<RS> rs) { - return new ScriptIntrinsicHistogram(rs, nullptr); +sp<ScriptIntrinsicHistogram> ScriptIntrinsicHistogram::create(sp<RS> rs, sp<const Element> e) { + return new ScriptIntrinsicHistogram(rs, e); } ScriptIntrinsicHistogram::ScriptIntrinsicHistogram(sp<RS> rs, sp<const Element> e) @@ -476,7 +476,7 @@ return; } - if (!(ain->getType()->getElement()->isCompatible(Element::U8(mRS))) || + if (!(ain->getType()->getElement()->isCompatible(Element::U8(mRS))) && !(ain->getType()->getElement()->isCompatible(Element::U8_4(mRS)))) { mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Input allocation to Histogram must be U8 or U8_4"); @@ -494,7 +494,7 @@ "when used with forEach_dot"); return; } - if (!(ain->getType()->getElement()->isCompatible(Element::U8(mRS))) || + if (!(ain->getType()->getElement()->isCompatible(Element::U8(mRS))) && !(ain->getType()->getElement()->isCompatible(Element::U8_4(mRS)))) { mRS->throwError(RS_ERROR_INVALID_ELEMENT, "Input allocation to Histogram must be U8 or U8_4");