am d70e0951: Merge "[RenderScript] Update the java API about Allocation copyTo & From FieldPacker"

* commit 'd70e095192fae4b53daa440727c9008d172f08da':
  [RenderScript] Update the java API about Allocation copyTo & From FieldPacker
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/Allocation.java b/v8/renderscript/java/src/android/support/v8/renderscript/Allocation.java
index 8cf4e9d..4b019e9 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/Allocation.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/Allocation.java
@@ -796,22 +796,6 @@
      *
      * @param xoff
      * @param yoff
-     * @param component_number
-     * @param fp
-     */
-    /*
-    public void setFromFieldPacker(int xoff, int yoff, int component_number, FieldPacker fp) {
-        setFromFieldPacker(xoff, yoff, 0, component_number, fp);
-    }
-    */
-
-    /**
-     * @hide
-     * This is only intended to be used by auto-generated code reflected from
-     * the RenderScript script files.
-     *
-     * @param xoff
-     * @param yoff
      * @param zoff
      * @param component_number
      * @param fp
@@ -1388,39 +1372,8 @@
 
     /**
      * @hide
-     * Copy subelement from the Allocation into an object array.
-     * This is intended to be used with user defined structs
-     *
-     * @param xoff
-     * @param component_number
-     * @param array
-     */
-    /*
-    public void copyElementTo(int xoff, int component_number, Object array) {
-        copyElementTo(xoff, 0, 0, component_number, array);
-    }
-    */
-
-    /**
-     * @hide
-     * Copy subelement from the Allocation into an object array.
-     * This is intended to be used with user defined structs
-     *
-     * @param xoff
-     * @param yoff
-     * @param component_number
-     * @param array
-     */
-    /*
-    public void copyElementTo(int xoff, int yoff, int component_number, Object array) {
-        copyElementTo(xoff, yoff, 0, component_number, array);
-    }
-    */
-
-    /**
-     * @hide
-     * Copy subelement from the Allocation into an object array.
-     * This is intended to be used with user defined structs
+     * This is only intended to be used by auto-generated code reflected from
+     * the RenderScript script files and should not be used by developers.
      *
      * @param xoff
      * @param yoff
@@ -1429,7 +1382,7 @@
      * @param array
      */
     /*
-    public void copyElementTo(int xoff, int yoff, int zoff, int component_number, Object array) {
+    public void copyToFieldPacker(int xoff, int yoff, int zoff, int component_number, FieldPacker fp) {
         mRS.validate();
         if (component_number >= mType.mElement.mElements.length) {
             throw new RSIllegalArgumentException("Component_number " + component_number + " out of range.");
@@ -1444,18 +1397,18 @@
             throw new RSIllegalArgumentException("Offset z must be >= 0.");
         }
 
-        Element.DataType dt = validateObjectIsPrimitiveArray(array, false);
-        int array_size = java.lang.reflect.Array.getLength(array) * dt.mSize;
+        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 (array_size < eSize) {
-            throw new RSIllegalArgumentException("Array Size (bytes)" + array_size +
-                                               " is smaller than component size " + eSize + ".");
+        if (data_length != eSize) {
+            throw new RSIllegalArgumentException("Field packer sizelength " + data_length +
+                                               " does not match component size " + eSize + ".");
         }
 
         mRS.nAllocationElementRead(getIDSafe(), xoff, yoff, zoff, mSelectedLOD,
-                                   component_number, array, eSize, dt);
+                                   component_number, data, data_length);
     }
     */
 
diff --git a/v8/renderscript/java/src/android/support/v8/renderscript/RenderScript.java b/v8/renderscript/java/src/android/support/v8/renderscript/RenderScript.java
index 4de926c..8f681d8 100644
--- a/v8/renderscript/java/src/android/support/v8/renderscript/RenderScript.java
+++ b/v8/renderscript/java/src/android/support/v8/renderscript/RenderScript.java
@@ -484,12 +484,11 @@
     
     /*
     native void rsnAllocationElementRead(long con,long id, int xoff, int yoff, int zoff,
-                                         int mip, int compIdx, Object d, int sizeBytes, int dt);
+                                         int mip, int compIdx, byte[] d, int sizeBytes);
     synchronized void nAllocationElementRead(long id, int xoff, int yoff, int zoff,
-                                             int mip, int compIdx, Object d, int sizeBytes,
-                                             Element.DataType dt) {
+                                             int mip, int compIdx, byte[] d, int sizeBytes) {
         validate();
-        rsnAllocationElementRead(mContext, id, xoff, yoff, zoff, mip, compIdx, d, sizeBytes, dt.mID);
+        rsnAllocationElementRead(mContext, id, xoff, yoff, zoff, mip, compIdx, d, sizeBytes);
     }
     */
 
diff --git a/v8/renderscript/jni/android_renderscript_RenderScript.cpp b/v8/renderscript/jni/android_renderscript_RenderScript.cpp
index 7b97a85..76f1876 100644
--- a/v8/renderscript/jni/android_renderscript_RenderScript.cpp
+++ b/v8/renderscript/jni/android_renderscript_RenderScript.cpp
@@ -970,13 +970,17 @@
 static void
 nAllocationElementRead(JNIEnv *_env, jobject _this, jlong con, jlong _alloc,
                        jint xoff, jint yoff, jint zoff,
-                       jint lod, jint compIdx, jobject data, jint sizeBytes, int dataType)
+                       jint lod, jint compIdx, jobject data, jint sizeBytes)
 {
-    RsAllocation *alloc = (RsAllocation *)_alloc;
-    LOG_API("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), "
-            "sizeBytes(%i)", (RsContext)con, alloc, xoff, yoff, zoff, compIdx, sizeBytes);
-    PER_ARRAY_TYPE(0, dispatchTab.AllocationElementRead, false, (RsContext)con, alloc, 
-                   xoff, yoff, zoff, lod, ptr, sizeBytes, compIdx);
+    jint len = _env->GetArrayLength(data);
+    LOG_API("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), "
+            "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len,
+            sizeBytes);
+    jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
+    dispatchTab.AllocationElementRead((RsContext)con, (RsAllocation)alloc,
+                                      xoff, yoff, zoff,
+                                      lod, ptr, sizeBytes, compIdx);
+    _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
 }
 */
 
@@ -1647,7 +1651,7 @@
 {"rsnAllocationData3D",              "(JJIIIIIIIJIIII)V",                     (void*)nAllocationData3D_alloc },
 {"rsnAllocationRead",                "(JJLjava/lang/Object;IIZ)V",            (void*)nAllocationRead },
 {"rsnAllocationRead1D",              "(JJIIILjava/lang/Object;IIIZ)V",        (void*)nAllocationRead1D },
-//{"rsnAllocationElementRead",         "(JJIIIIILjava/lang/Object;II)V",        (void*)nAllocationElementRead },
+//{"rsnAllocationElementRead",         "(JJIIIII[BI)V",                         (void*)nAllocationElementRead },
 {"rsnAllocationRead2D",              "(JJIIIIIILjava/lang/Object;IIIZ)V",     (void*)nAllocationRead2D },
 //{"rsnAllocationRead3D",              "(JJIIIIIIILjava/lang/Object;IIIZ)V",  (void*)nAllocationRead3D },
 {"rsnAllocationGetType",             "(JJ)J",                                 (void*)nAllocationGetType},