diff options
author | Stephen Hines <srhines@google.com> | 2014-06-17 17:25:04 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-06-18 00:24:44 -0700 |
commit | fa1275a6e743c4661cc3d5e05bb89559a8e59727 (patch) | |
tree | 4c86df54c9a64caeccd458d68969bd67c65c808d /rs/java/android/renderscript/Allocation.java | |
parent | 88b37edaeab7b31cab0f5115e5c9f63a49991408 (diff) | |
download | frameworks_base-fa1275a6e743c4661cc3d5e05bb89559a8e59727.zip frameworks_base-fa1275a6e743c4661cc3d5e05bb89559a8e59727.tar.gz frameworks_base-fa1275a6e743c4661cc3d5e05bb89559a8e59727.tar.bz2 |
Create FieldPacker.getPos() to get the actual amount of data used for FP.
We need larger buffers to handle 64-bit RS object types, but 32-bit code
will never fill all of the getData().length bytes. This allows us to retain
our verification code.
We have to modify an existing use of FieldPacker that was doing partial
updates of the underlying buffer. This was really relying on the old data
to be implicitly selected and written back, but that is not guaranteed by
the original API. This also required a fix to the FieldPacker.reset() API,
which was not allowing the FieldPacker to ever point to the final entry in
its buffer.
Change-Id: Idcd52790ac2b0ab1eff3f043e7eec2832953f04b
Diffstat (limited to 'rs/java/android/renderscript/Allocation.java')
-rw-r--r-- | rs/java/android/renderscript/Allocation.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java index c2bab91..20b7ee7 100644 --- a/rs/java/android/renderscript/Allocation.java +++ b/rs/java/android/renderscript/Allocation.java @@ -776,10 +776,11 @@ public class Allocation extends BaseObj { mRS.validate(); int eSize = mType.mElement.getBytesSize(); final byte[] data = fp.getData(); + int data_length = fp.getPos(); - int count = data.length / eSize; - if ((eSize * count) != data.length) { - throw new RSIllegalArgumentException("Field packer length " + data.length + + int count = data_length / eSize; + if ((eSize * count) != data_length) { + throw new RSIllegalArgumentException("Field packer length " + data_length + " not divisible by element size " + eSize + "."); } copy1DRangeFromUnchecked(xoff, count, data); @@ -803,16 +804,17 @@ public class Allocation extends BaseObj { } final byte[] data = fp.getData(); + int data_length = fp.getPos(); int eSize = mType.mElement.mElements[component_number].getBytesSize(); eSize *= mType.mElement.mArraySizes[component_number]; - if (data.length != eSize) { - throw new RSIllegalArgumentException("Field packer sizelength " + data.length + + if (data_length != eSize) { + throw new RSIllegalArgumentException("Field packer sizelength " + data_length + " does not match component size " + eSize + "."); } mRS.nAllocationElementData1D(getIDSafe(), xoff, mSelectedLOD, - component_number, data, data.length); + component_number, data, data_length); } private void data1DChecks(int off, int count, int len, int dataSize) { |