diff options
| author | 2012-02-02 09:47:26 -0800 | |
|---|---|---|
| committer | 2012-02-02 09:47:26 -0800 | |
| commit | bf3c3f2ab1067b647038170cb201cdd1a9a1c6d2 (patch) | |
| tree | b5a9129e4c9e34d1f043058c0810fc0405b51340 | |
| parent | bbf1bc8b6c3348265930ce08506efbbd3c5ab61f (diff) | |
Fix an incorrect assert that doesn't account for element array size.
Change-Id: Ibcb5c55d91967603391a1721137d010a85025990
| -rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 1 | ||||
| -rw-r--r-- | libs/rs/rsAllocation.cpp | 7 |
2 files changed, 5 insertions, 3 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index f285f5b5ac0c..11c242759d91 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -487,6 +487,7 @@ public class Allocation extends BaseObj { final byte[] data = fp.getData(); int eSize = mType.mElement.mElements[component_number].getSizeBytes(); + eSize *= mType.mElement.mArraySizes[component_number]; if (data.length != eSize) { throw new RSIllegalArgumentException("Field packer sizelength " + data.length + diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 972e3d655115..fd85b077a493 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -124,7 +124,8 @@ void Allocation::elementData(Context *rsc, uint32_t x, const void *data, } const Element * e = mHal.state.type->getElement()->getField(cIdx); - if (sizeBytes != e->getSizeBytes()) { + uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx); + if (sizeBytes != e->getSizeBytes() * elemArraySize) { ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes()); rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size."); return; @@ -157,8 +158,8 @@ void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, } const Element * e = mHal.state.type->getElement()->getField(cIdx); - - if (sizeBytes != e->getSizeBytes()) { + uint32_t elemArraySize = mHal.state.type->getElement()->getFieldArraySize(cIdx); + if (sizeBytes != e->getSizeBytes() * elemArraySize) { ALOGE("Error Allocation::subElementData data size %zu does not match field size %zu.", sizeBytes, e->getSizeBytes()); rsc->setError(RS_ERROR_BAD_VALUE, "subElementData bad size."); return; |