diff options
author | Jason Sams <jsams@google.com> | 2015-03-17 21:06:32 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-03-17 21:06:32 +0000 |
commit | c3851d58e6f0a97a3f5239d78515acd2be47b507 (patch) | |
tree | d1b35215f04e8369479572ab070aeb4a0d08387c | |
parent | 9b36e3f02365783d7703f86a930ed404840891b2 (diff) | |
parent | b05c850a493a769c88b58be2a6721a9bb06b3a0a (diff) | |
download | rs-c3851d58e6f0a97a3f5239d78515acd2be47b507.tar.gz |
Merge "Ensure ScriptIntrinsicHistogram is given a valid Element in constructor when used via C++ bindings."
-rw-r--r-- | cpp/ScriptIntrinsics.cpp | 8 | ||||
-rw-r--r-- | cpp/rsCppStructs.h | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/cpp/ScriptIntrinsics.cpp b/cpp/ScriptIntrinsics.cpp index a9a31f81..e40d1a03 100644 --- a/cpp/ScriptIntrinsics.cpp +++ b/cpp/ScriptIntrinsics.cpp @@ -419,8 +419,8 @@ void ScriptIntrinsicConvolve5x5::setCoefficients(float* v) { 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 @@ void ScriptIntrinsicHistogram::forEach(sp<Allocation> ain) { 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 @@ void ScriptIntrinsicHistogram::forEach_dot(sp<Allocation> ain) { "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"); diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h index 26e19545..cd8f39a1 100644 --- a/cpp/rsCppStructs.h +++ b/cpp/rsCppStructs.h @@ -1351,6 +1351,9 @@ protected: void setVar(uint32_t index, int32_t v) const { setVar(index, &v, sizeof(v)); } + void setVar(uint32_t index, uint32_t v) const { + setVar(index, &v, sizeof(v)); + } void setVar(uint32_t index, int64_t v) const { setVar(index, &v, sizeof(v)); } @@ -1722,7 +1725,7 @@ class ScriptIntrinsicHistogram : public ScriptIntrinsic { * * @return ScriptIntrinsicHistogram */ - static sp<ScriptIntrinsicHistogram> create(sp<RS> rs); + static sp<ScriptIntrinsicHistogram> create(sp<RS> rs, sp<const Element> e); /** * Set the output of the histogram. 32 bit integer types are * supported. |