OSDN Git Service

We need to update mPos when we copy a FieldPacker via its data[] member.
authorStephen Hines <srhines@google.com>
Tue, 24 Jun 2014 00:35:04 +0000 (17:35 -0700)
committerStephen Hines <srhines@google.com>
Tue, 24 Jun 2014 00:35:04 +0000 (17:35 -0700)
Bug: 15756600

This change also adds a TODO/FIXME related to subAlign() and our tracking
mechanism for it. We need to further investigate how to make subAlign() work
properly if a user copies their FieldPacker.

Change-Id: I861e529abd11e378f7c73b510d7f418b940fe480

rs/java/android/renderscript/FieldPacker.java

index dccc1ac..9048c31 100644 (file)
@@ -37,10 +37,15 @@ public class FieldPacker {
     }
 
     public FieldPacker(byte[] data) {
-        mPos = 0;
+        // Advance mPos to the end of the buffer, since we are copying in the
+        // full data input.
+        mPos = data.length;
         mLen = data.length;
         mData = data;
         mAlignment = new BitSet();
+        // TODO: We should either have an actual FieldPacker copy constructor
+        // or drop support for computing alignment like this. As it stands,
+        // subAlign() can never work correctly for copied FieldPacker objects.
     }
 
     public void align(int v) {