summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2012-04-03 15:36:36 -0700
committerJason Sams <jsams@google.com>2012-04-03 15:36:36 -0700
commite07694b24f7d12d72b084b6651356681ebd0efd6 (patch)
treee5cbb853579a105f5910c1c6640358e0cf69b5d9
parent991c8733c3b990b88edf5cf223aebe3d1c71b7f0 (diff)
downloadframeworks_base-e07694b24f7d12d72b084b6651356681ebd0efd6.zip
frameworks_base-e07694b24f7d12d72b084b6651356681ebd0efd6.tar.gz
frameworks_base-e07694b24f7d12d72b084b6651356681ebd0efd6.tar.bz2
Validate context when using RS objects.
BUG=6035422 Change-Id: I8586be0085b36767289e1f634111c0ff076cec3c
-rw-r--r--graphics/java/android/renderscript/Allocation.java60
-rw-r--r--graphics/java/android/renderscript/AllocationAdapter.java2
-rw-r--r--graphics/java/android/renderscript/BaseObj.java10
-rw-r--r--graphics/java/android/renderscript/Element.java6
-rw-r--r--graphics/java/android/renderscript/FieldPacker.java2
-rw-r--r--graphics/java/android/renderscript/FileA3D.java6
-rw-r--r--graphics/java/android/renderscript/Mesh.java16
-rw-r--r--graphics/java/android/renderscript/Path.java2
-rw-r--r--graphics/java/android/renderscript/Program.java14
-rw-r--r--graphics/java/android/renderscript/ProgramFragment.java6
-rw-r--r--graphics/java/android/renderscript/ProgramFragmentFixedFunction.java6
-rw-r--r--graphics/java/android/renderscript/ProgramVertex.java6
-rw-r--r--graphics/java/android/renderscript/ProgramVertexFixedFunction.java6
-rw-r--r--graphics/java/android/renderscript/RenderScript.java2
-rw-r--r--graphics/java/android/renderscript/Script.java32
-rw-r--r--graphics/java/android/renderscript/Type.java5
16 files changed, 94 insertions, 87 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 18a0a0c..cd5300d 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -184,9 +184,9 @@ public class Allocation extends BaseObj {
private int getIDSafe() {
if (mAdaptedAllocation != null) {
- return mAdaptedAllocation.getID();
+ return mAdaptedAllocation.getID(mRS);
}
- return getID();
+ return getID(mRS);
}
@@ -321,7 +321,7 @@ public class Allocation extends BaseObj {
@Override
void updateFromNative() {
super.updateFromNative();
- int typeID = mRS.nAllocationGetType(getID());
+ int typeID = mRS.nAllocationGetType(getID(mRS));
if(typeID != 0) {
mType = new Type(typeID, mRS);
mType.updateFromNative();
@@ -371,7 +371,7 @@ public class Allocation extends BaseObj {
"Can only send buffer if IO_OUTPUT usage specified.");
}
mRS.validate();
- mRS.nAllocationIoSend(getID());
+ mRS.nAllocationIoSend(getID(mRS));
}
/**
@@ -394,7 +394,7 @@ public class Allocation extends BaseObj {
"Can only receive if IO_INPUT usage specified.");
}
mRS.validate();
- mRS.nAllocationIoReceive(getID());
+ mRS.nAllocationIoReceive(getID(mRS));
}
/**
@@ -411,7 +411,7 @@ public class Allocation extends BaseObj {
}
int i[] = new int[d.length];
for (int ct=0; ct < d.length; ct++) {
- i[ct] = d[ct].getID();
+ i[ct] = d[ct].getID(mRS);
}
copy1DRangeFromUnchecked(0, mCurrentCount, i);
}
@@ -571,7 +571,7 @@ public class Allocation extends BaseObj {
mRS.validate();
validateBitmapSize(b);
validateBitmapFormat(b);
- mRS.nAllocationCopyFromBitmap(getID(), b);
+ mRS.nAllocationCopyFromBitmap(getID(mRS), b);
}
/**
@@ -652,7 +652,7 @@ public class Allocation extends BaseObj {
* followup sync will be required.
*/
public void generateMipmaps() {
- mRS.nAllocationGenerateMipmaps(getID());
+ mRS.nAllocationGenerateMipmaps(getID(mRS));
}
/**
@@ -780,7 +780,7 @@ public class Allocation extends BaseObj {
public void copy1DRangeFrom(int off, int count, Allocation data, int dataOff) {
mRS.nAllocationData2D(getIDSafe(), off, 0,
mSelectedLOD, mSelectedFace.mID,
- count, 1, data.getID(), dataOff, 0,
+ count, 1, data.getID(mRS), dataOff, 0,
data.mSelectedLOD, data.mSelectedFace.mID);
}
@@ -857,7 +857,7 @@ public class Allocation extends BaseObj {
validate2DRange(xoff, yoff, w, h);
mRS.nAllocationData2D(getIDSafe(), xoff, yoff,
mSelectedLOD, mSelectedFace.mID,
- w, h, data.getID(), dataXoff, dataYoff,
+ w, h, data.getID(mRS), dataXoff, dataYoff,
data.mSelectedLOD, data.mSelectedFace.mID);
}
@@ -888,7 +888,7 @@ public class Allocation extends BaseObj {
mRS.validate();
validateBitmapFormat(b);
validateBitmapSize(b);
- mRS.nAllocationCopyToBitmap(getID(), b);
+ mRS.nAllocationCopyToBitmap(getID(mRS), b);
}
/**
@@ -901,7 +901,7 @@ public class Allocation extends BaseObj {
public void copyTo(byte[] d) {
validateIsInt8();
mRS.validate();
- mRS.nAllocationRead(getID(), d);
+ mRS.nAllocationRead(getID(mRS), d);
}
/**
@@ -914,7 +914,7 @@ public class Allocation extends BaseObj {
public void copyTo(short[] d) {
validateIsInt16();
mRS.validate();
- mRS.nAllocationRead(getID(), d);
+ mRS.nAllocationRead(getID(mRS), d);
}
/**
@@ -927,7 +927,7 @@ public class Allocation extends BaseObj {
public void copyTo(int[] d) {
validateIsInt32();
mRS.validate();
- mRS.nAllocationRead(getID(), d);
+ mRS.nAllocationRead(getID(mRS), d);
}
/**
@@ -940,7 +940,7 @@ public class Allocation extends BaseObj {
public void copyTo(float[] d) {
validateIsFloat32();
mRS.validate();
- mRS.nAllocationRead(getID(), d);
+ mRS.nAllocationRead(getID(mRS), d);
}
/**
@@ -959,10 +959,10 @@ public class Allocation extends BaseObj {
if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) {
throw new RSInvalidStateException("Resize only support for 1D allocations at this time.");
}
- mRS.nAllocationResize1D(getID(), dimX);
+ mRS.nAllocationResize1D(getID(mRS), dimX);
mRS.finish(); // Necessary because resize is fifoed and update is async.
- int typeID = mRS.nAllocationGetType(getID());
+ int typeID = mRS.nAllocationGetType(getID(mRS));
mType = new Type(typeID, mRS);
mType.updateFromNative();
updateCacheInfo(mType);
@@ -991,10 +991,10 @@ public class Allocation extends BaseObj {
throw new RSInvalidStateException(
"Resize only support for 2D allocations at this time.");
}
- mRS.nAllocationResize2D(getID(), dimX, dimY);
+ mRS.nAllocationResize2D(getID(mRS), dimX, dimY);
mRS.finish(); // Necessary because resize is fifoed and update is async.
- int typeID = mRS.nAllocationGetType(getID());
+ int typeID = mRS.nAllocationGetType(getID(mRS));
mType = new Type(typeID, mRS);
mType.updateFromNative();
updateCacheInfo(mType);
@@ -1019,10 +1019,10 @@ public class Allocation extends BaseObj {
*/
static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips, int usage) {
rs.validate();
- if (type.getID() == 0) {
+ if (type.getID(rs) == 0) {
throw new RSInvalidStateException("Bad Type");
}
- int id = rs.nAllocationCreateTyped(type.getID(), mips.mID, usage, 0);
+ int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0);
if (id == 0) {
throw new RSRuntimeException("Allocation creation failed.");
}
@@ -1043,10 +1043,10 @@ public class Allocation extends BaseObj {
static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips,
int usage, int pointer) {
rs.validate();
- if (type.getID() == 0) {
+ if (type.getID(rs) == 0) {
throw new RSInvalidStateException("Bad Type");
}
- int id = rs.nAllocationCreateTyped(type.getID(), mips.mID, usage, pointer);
+ int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, pointer);
if (id == 0) {
throw new RSRuntimeException("Allocation creation failed.");
}
@@ -1101,7 +1101,7 @@ public class Allocation extends BaseObj {
b.setX(count);
Type t = b.create();
- int id = rs.nAllocationCreateTyped(t.getID(), MipmapControl.MIPMAP_NONE.mID, usage, 0);
+ int id = rs.nAllocationCreateTyped(t.getID(rs), MipmapControl.MIPMAP_NONE.mID, usage, 0);
if (id == 0) {
throw new RSRuntimeException("Allocation creation failed.");
}
@@ -1168,7 +1168,7 @@ public class Allocation extends BaseObj {
rs.validate();
Type t = typeFromBitmap(rs, b, mips);
- int id = rs.nAllocationCreateFromBitmap(t.getID(), mips.mID, b, usage);
+ int id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage);
if (id == 0) {
throw new RSRuntimeException("Load failed.");
}
@@ -1186,9 +1186,9 @@ public class Allocation extends BaseObj {
throw new RSInvalidStateException("Allocation is not a surface texture.");
}
- int id = mRS.nAllocationGetSurfaceTextureID(getID());
+ int id = mRS.nAllocationGetSurfaceTextureID(getID(mRS));
SurfaceTexture st = new SurfaceTexture(id);
- mRS.nAllocationGetSurfaceTextureID2(getID(), st);
+ mRS.nAllocationGetSurfaceTextureID2(getID(mRS), st);
return st;
}
@@ -1211,7 +1211,7 @@ public class Allocation extends BaseObj {
throw new RSInvalidStateException("Allocation is not USAGE_IO_OUTPUT.");
}
- mRS.nAllocationSetSurface(getID(), sur);
+ mRS.nAllocationSetSurface(getID(mRS), sur);
}
/**
@@ -1224,7 +1224,7 @@ public class Allocation extends BaseObj {
}
Surface s = new Surface(st);
- mRS.nAllocationSetSurface(getID(), s);
+ mRS.nAllocationSetSurface(getID(mRS), s);
}
/**
@@ -1283,7 +1283,7 @@ public class Allocation extends BaseObj {
tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL);
Type t = tb.create();
- int id = rs.nAllocationCubeCreateFromBitmap(t.getID(), mips.mID, b, usage);
+ int id = rs.nAllocationCubeCreateFromBitmap(t.getID(rs), mips.mID, b, usage);
if(id == 0) {
throw new RSRuntimeException("Load failed for bitmap " + b + " element " + e);
}
diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/graphics/java/android/renderscript/AllocationAdapter.java
index d38f2df..85d86e5 100644
--- a/graphics/java/android/renderscript/AllocationAdapter.java
+++ b/graphics/java/android/renderscript/AllocationAdapter.java
@@ -30,7 +30,7 @@ public class AllocationAdapter extends Allocation {
mAdaptedAllocation = alloc;
}
- int getID() {
+ int getID(RenderScript rs) {
throw new RSInvalidStateException(
"This operation is not supported with adapters at this time.");
}
diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java
index 2e55c48..f464f9b 100644
--- a/graphics/java/android/renderscript/BaseObj.java
+++ b/graphics/java/android/renderscript/BaseObj.java
@@ -43,16 +43,22 @@ public class BaseObj {
* Lookup the native object ID for this object. Primarily used by the
* generated reflected code.
*
+ * @param rs Context to verify against internal context for
+ * match.
*
* @return int
*/
- int getID() {
+ int getID(RenderScript rs) {
+ mRS.validate();
if (mDestroyed) {
throw new RSInvalidStateException("using a destroyed object.");
}
if (mID == 0) {
throw new RSRuntimeException("Internal error: Object id 0.");
}
+ if ((rs != null) && (rs != mRS)) {
+ throw new RSInvalidStateException("using object with mismatched context.");
+ }
return mID;
}
@@ -138,7 +144,7 @@ public class BaseObj {
*/
void updateFromNative() {
mRS.validate();
- mName = mRS.nGetName(getID());
+ mName = mRS.nGetName(getID(mRS));
}
/**
diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java
index 3d4951f..d75c951 100644
--- a/graphics/java/android/renderscript/Element.java
+++ b/graphics/java/android/renderscript/Element.java
@@ -778,7 +778,7 @@ public class Element extends BaseObj {
// we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
int[] dataBuffer = new int[5];
- mRS.nElementGetNativeData(getID(), dataBuffer);
+ mRS.nElementGetNativeData(getID(mRS), dataBuffer);
mNormalized = dataBuffer[2] == 1 ? true : false;
mVectorSize = dataBuffer[3];
@@ -803,7 +803,7 @@ public class Element extends BaseObj {
mOffsetInBytes = new int[numSubElements];
int[] subElementIds = new int[numSubElements];
- mRS.nElementGetSubElements(getID(), subElementIds, mElementNames, mArraySizes);
+ mRS.nElementGetSubElements(getID(mRS), subElementIds, mElementNames, mArraySizes);
for(int i = 0; i < numSubElements; i ++) {
mElements[i] = new Element(subElementIds[i], mRS);
mElements[i].updateFromNative();
@@ -1062,7 +1062,7 @@ public class Element extends BaseObj {
int[] ids = new int[ein.length];
for (int ct = 0; ct < ein.length; ct++ ) {
- ids[ct] = ein[ct].getID();
+ ids[ct] = ein[ct].getID(mRS);
}
int id = mRS.nElementCreate2(ids, sin, asin);
return new Element(id, mRS, ein, sin, asin);
diff --git a/graphics/java/android/renderscript/FieldPacker.java b/graphics/java/android/renderscript/FieldPacker.java
index 2739a4b8..a215a57 100644
--- a/graphics/java/android/renderscript/FieldPacker.java
+++ b/graphics/java/android/renderscript/FieldPacker.java
@@ -143,7 +143,7 @@ public class FieldPacker {
public void addObj(BaseObj obj) {
if (obj != null) {
- addI32(obj.getID());
+ addI32(obj.getID(null));
} else {
addI32(0);
}
diff --git a/graphics/java/android/renderscript/FileA3D.java b/graphics/java/android/renderscript/FileA3D.java
index b5419a7..6179317 100644
--- a/graphics/java/android/renderscript/FileA3D.java
+++ b/graphics/java/android/renderscript/FileA3D.java
@@ -165,7 +165,7 @@ public class FileA3D extends BaseObj {
}
private void initEntries() {
- int numFileEntries = mRS.nFileA3DGetNumIndexEntries(getID());
+ int numFileEntries = mRS.nFileA3DGetNumIndexEntries(getID(mRS));
if(numFileEntries <= 0) {
return;
}
@@ -174,10 +174,10 @@ public class FileA3D extends BaseObj {
int[] ids = new int[numFileEntries];
String[] names = new String[numFileEntries];
- mRS.nFileA3DGetIndexEntries(getID(), numFileEntries, ids, names);
+ mRS.nFileA3DGetIndexEntries(getID(mRS), numFileEntries, ids, names);
for(int i = 0; i < numFileEntries; i ++) {
- mFileEntries[i] = new IndexEntry(mRS, i, getID(), names[i], EntryType.toEntryType(ids[i]));
+ mFileEntries[i] = new IndexEntry(mRS, i, getID(mRS), names[i], EntryType.toEntryType(ids[i]));
}
}
diff --git a/graphics/java/android/renderscript/Mesh.java b/graphics/java/android/renderscript/Mesh.java
index f641117..ffbb41d 100644
--- a/graphics/java/android/renderscript/Mesh.java
+++ b/graphics/java/android/renderscript/Mesh.java
@@ -137,15 +137,15 @@ public class Mesh extends BaseObj {
@Override
void updateFromNative() {
super.updateFromNative();
- int vtxCount = mRS.nMeshGetVertexBufferCount(getID());
- int idxCount = mRS.nMeshGetIndexCount(getID());
+ int vtxCount = mRS.nMeshGetVertexBufferCount(getID(mRS));
+ int idxCount = mRS.nMeshGetIndexCount(getID(mRS));
int[] vtxIDs = new int[vtxCount];
int[] idxIDs = new int[idxCount];
int[] primitives = new int[idxCount];
- mRS.nMeshGetVertices(getID(), vtxIDs, vtxCount);
- mRS.nMeshGetIndices(getID(), idxIDs, primitives, idxCount);
+ mRS.nMeshGetVertices(getID(mRS), vtxIDs, vtxCount);
+ mRS.nMeshGetIndices(getID(mRS), idxIDs, primitives, idxCount);
mVertexBuffers = new Allocation[vtxCount];
mIndexBuffers = new Allocation[idxCount];
@@ -343,7 +343,7 @@ public class Mesh extends BaseObj {
alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage);
}
vertexBuffers[ct] = alloc;
- vtx[ct] = alloc.getID();
+ vtx[ct] = alloc.getID(mRS);
}
for(int ct = 0; ct < mIndexTypes.size(); ct ++) {
@@ -354,7 +354,7 @@ public class Mesh extends BaseObj {
} else if(entry.e != null) {
alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage);
}
- int allocID = (alloc == null) ? 0 : alloc.getID();
+ int allocID = (alloc == null) ? 0 : alloc.getID(mRS);
indexBuffers[ct] = alloc;
primitives[ct] = entry.prim;
@@ -483,12 +483,12 @@ public class Mesh extends BaseObj {
for(int ct = 0; ct < mVertexTypeCount; ct ++) {
Entry entry = mVertexTypes[ct];
vertexBuffers[ct] = entry.a;
- vtx[ct] = entry.a.getID();
+ vtx[ct] = entry.a.getID(mRS);
}
for(int ct = 0; ct < mIndexTypes.size(); ct ++) {
Entry entry = (Entry)mIndexTypes.elementAt(ct);
- int allocID = (entry.a == null) ? 0 : entry.a.getID();
+ int allocID = (entry.a == null) ? 0 : entry.a.getID(mRS);
indexBuffers[ct] = entry.a;
primitives[ct] = entry.prim;
diff --git a/graphics/java/android/renderscript/Path.java b/graphics/java/android/renderscript/Path.java
index 83ae150..9c4d41b 100644
--- a/graphics/java/android/renderscript/Path.java
+++ b/graphics/java/android/renderscript/Path.java
@@ -67,7 +67,7 @@ public class Path extends BaseObj {
public static Path createStaticPath(RenderScript rs, Primitive p, float quality, Allocation vtx) {
- int id = rs.nPathCreate(p.mID, false, vtx.getID(), 0, quality);
+ int id = rs.nPathCreate(p.mID, false, vtx.getID(rs), 0, quality);
Path newPath = new Path(id, rs, p, null, null, quality);
return newPath;
}
diff --git a/graphics/java/android/renderscript/Program.java b/graphics/java/android/renderscript/Program.java
index 4d60ac8..104d1cd 100644
--- a/graphics/java/android/renderscript/Program.java
+++ b/graphics/java/android/renderscript/Program.java
@@ -134,11 +134,11 @@ public class Program extends BaseObj {
throw new IllegalArgumentException("Slot ID out of range.");
}
if (a != null &&
- a.getType().getID() != mConstants[slot].getID()) {
+ a.getType().getID(mRS) != mConstants[slot].getID(mRS)) {
throw new IllegalArgumentException("Allocation type does not match slot type.");
}
- int id = a != null ? a.getID() : 0;
- mRS.nProgramBindConstants(getID(), slot, id);
+ int id = a != null ? a.getID(mRS) : 0;
+ mRS.nProgramBindConstants(getID(mRS), slot, id);
}
/**
@@ -159,8 +159,8 @@ public class Program extends BaseObj {
throw new IllegalArgumentException("Cannot bind cubemap to 2d texture slot");
}
- int id = va != null ? va.getID() : 0;
- mRS.nProgramBindTexture(getID(), slot, id);
+ int id = va != null ? va.getID(mRS) : 0;
+ mRS.nProgramBindTexture(getID(mRS), slot, id);
}
/**
@@ -179,8 +179,8 @@ public class Program extends BaseObj {
throw new IllegalArgumentException("Slot ID out of range.");
}
- int id = vs != null ? vs.getID() : 0;
- mRS.nProgramBindSampler(getID(), slot, id);
+ int id = vs != null ? vs.getID(mRS) : 0;
+ mRS.nProgramBindSampler(getID(mRS), slot, id);
}
diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java
index ebc15e5..fa6e2d4 100644
--- a/graphics/java/android/renderscript/ProgramFragment.java
+++ b/graphics/java/android/renderscript/ProgramFragment.java
@@ -64,15 +64,15 @@ public class ProgramFragment extends Program {
for (int i=0; i < mInputCount; i++) {
tmp[idx++] = ProgramParam.INPUT.mID;
- tmp[idx++] = mInputs[i].getID();
+ tmp[idx++] = mInputs[i].getID(mRS);
}
for (int i=0; i < mOutputCount; i++) {
tmp[idx++] = ProgramParam.OUTPUT.mID;
- tmp[idx++] = mOutputs[i].getID();
+ tmp[idx++] = mOutputs[i].getID(mRS);
}
for (int i=0; i < mConstantCount; i++) {
tmp[idx++] = ProgramParam.CONSTANT.mID;
- tmp[idx++] = mConstants[i].getID();
+ tmp[idx++] = mConstants[i].getID(mRS);
}
for (int i=0; i < mTextureCount; i++) {
tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID;
diff --git a/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java b/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java
index cd31db3..14f10f1 100644
--- a/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java
+++ b/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java
@@ -52,15 +52,15 @@ public class ProgramFragmentFixedFunction extends ProgramFragment {
for (int i=0; i < mInputCount; i++) {
tmp[idx++] = ProgramParam.INPUT.mID;
- tmp[idx++] = mInputs[i].getID();
+ tmp[idx++] = mInputs[i].getID(mRS);
}
for (int i=0; i < mOutputCount; i++) {
tmp[idx++] = ProgramParam.OUTPUT.mID;
- tmp[idx++] = mOutputs[i].getID();
+ tmp[idx++] = mOutputs[i].getID(mRS);
}
for (int i=0; i < mConstantCount; i++) {
tmp[idx++] = ProgramParam.CONSTANT.mID;
- tmp[idx++] = mConstants[i].getID();
+ tmp[idx++] = mConstants[i].getID(mRS);
}
for (int i=0; i < mTextureCount; i++) {
tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID;
diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java
index a6cd15b..32c908e 100644
--- a/graphics/java/android/renderscript/ProgramVertex.java
+++ b/graphics/java/android/renderscript/ProgramVertex.java
@@ -121,15 +121,15 @@ public class ProgramVertex extends Program {
for (int i=0; i < mInputCount; i++) {
tmp[idx++] = ProgramParam.INPUT.mID;
- tmp[idx++] = mInputs[i].getID();
+ tmp[idx++] = mInputs[i].getID(mRS);
}
for (int i=0; i < mOutputCount; i++) {
tmp[idx++] = ProgramParam.OUTPUT.mID;
- tmp[idx++] = mOutputs[i].getID();
+ tmp[idx++] = mOutputs[i].getID(mRS);
}
for (int i=0; i < mConstantCount; i++) {
tmp[idx++] = ProgramParam.CONSTANT.mID;
- tmp[idx++] = mConstants[i].getID();
+ tmp[idx++] = mConstants[i].getID(mRS);
}
for (int i=0; i < mTextureCount; i++) {
tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID;
diff --git a/graphics/java/android/renderscript/ProgramVertexFixedFunction.java b/graphics/java/android/renderscript/ProgramVertexFixedFunction.java
index 9a43943..fac4c3d 100644
--- a/graphics/java/android/renderscript/ProgramVertexFixedFunction.java
+++ b/graphics/java/android/renderscript/ProgramVertexFixedFunction.java
@@ -75,15 +75,15 @@ public class ProgramVertexFixedFunction extends ProgramVertex {
for (int i=0; i < mInputCount; i++) {
tmp[idx++] = ProgramParam.INPUT.mID;
- tmp[idx++] = mInputs[i].getID();
+ tmp[idx++] = mInputs[i].getID(mRS);
}
for (int i=0; i < mOutputCount; i++) {
tmp[idx++] = ProgramParam.OUTPUT.mID;
- tmp[idx++] = mOutputs[i].getID();
+ tmp[idx++] = mOutputs[i].getID(mRS);
}
for (int i=0; i < mConstantCount; i++) {
tmp[idx++] = ProgramParam.CONSTANT.mID;
- tmp[idx++] = mConstants[i].getID();
+ tmp[idx++] = mConstants[i].getID(mRS);
}
for (int i=0; i < mTextureCount; i++) {
tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID;
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index dffd400..03294b5 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -1000,7 +1000,7 @@ public class RenderScript {
int safeID(BaseObj o) {
if(o != null) {
- return o.getID();
+ return o.getID(this);
}
return 0;
}
diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java
index d00c428..4f59ae3 100644
--- a/graphics/java/android/renderscript/Script.java
+++ b/graphics/java/android/renderscript/Script.java
@@ -26,7 +26,7 @@ public class Script extends BaseObj {
* @param slot
*/
protected void invoke(int slot) {
- mRS.nScriptInvoke(getID(), slot);
+ mRS.nScriptInvoke(getID(mRS), slot);
}
/**
@@ -37,9 +37,9 @@ public class Script extends BaseObj {
*/
protected void invoke(int slot, FieldPacker v) {
if (v != null) {
- mRS.nScriptInvokeV(getID(), slot, v.getData());
+ mRS.nScriptInvokeV(getID(mRS), slot, v.getData());
} else {
- mRS.nScriptInvoke(getID(), slot);
+ mRS.nScriptInvoke(getID(mRS), slot);
}
}
@@ -58,17 +58,17 @@ public class Script extends BaseObj {
}
int in_id = 0;
if (ain != null) {
- in_id = ain.getID();
+ in_id = ain.getID(mRS);
}
int out_id = 0;
if (aout != null) {
- out_id = aout.getID();
+ out_id = aout.getID(mRS);
}
byte[] params = null;
if (v != null) {
params = v.getData();
}
- mRS.nScriptForEach(getID(), slot, in_id, out_id, params);
+ mRS.nScriptForEach(getID(mRS), slot, in_id, out_id, params);
}
@@ -86,9 +86,9 @@ public class Script extends BaseObj {
public void bindAllocation(Allocation va, int slot) {
mRS.validate();
if (va != null) {
- mRS.nScriptBindAllocation(getID(), va.getID(), slot);
+ mRS.nScriptBindAllocation(getID(mRS), va.getID(mRS), slot);
} else {
- mRS.nScriptBindAllocation(getID(), 0, slot);
+ mRS.nScriptBindAllocation(getID(mRS), 0, slot);
}
}
@@ -99,7 +99,7 @@ public class Script extends BaseObj {
* @param v
*/
public void setVar(int index, float v) {
- mRS.nScriptSetVarF(getID(), index, v);
+ mRS.nScriptSetVarF(getID(mRS), index, v);
}
/**
@@ -109,7 +109,7 @@ public class Script extends BaseObj {
* @param v
*/
public void setVar(int index, double v) {
- mRS.nScriptSetVarD(getID(), index, v);
+ mRS.nScriptSetVarD(getID(mRS), index, v);
}
/**
@@ -119,7 +119,7 @@ public class Script extends BaseObj {
* @param v
*/
public void setVar(int index, int v) {
- mRS.nScriptSetVarI(getID(), index, v);
+ mRS.nScriptSetVarI(getID(mRS), index, v);
}
/**
@@ -129,7 +129,7 @@ public class Script extends BaseObj {
* @param v
*/
public void setVar(int index, long v) {
- mRS.nScriptSetVarJ(getID(), index, v);
+ mRS.nScriptSetVarJ(getID(mRS), index, v);
}
/**
@@ -139,7 +139,7 @@ public class Script extends BaseObj {
* @param v
*/
public void setVar(int index, boolean v) {
- mRS.nScriptSetVarI(getID(), index, v ? 1 : 0);
+ mRS.nScriptSetVarI(getID(mRS), index, v ? 1 : 0);
}
/**
@@ -149,7 +149,7 @@ public class Script extends BaseObj {
* @param o
*/
public void setVar(int index, BaseObj o) {
- mRS.nScriptSetVarObj(getID(), index, (o == null) ? 0 : o.getID());
+ mRS.nScriptSetVarObj(getID(mRS), index, (o == null) ? 0 : o.getID(mRS));
}
/**
@@ -159,13 +159,13 @@ public class Script extends BaseObj {
* @param v
*/
public void setVar(int index, FieldPacker v) {
- mRS.nScriptSetVarV(getID(), index, v.getData());
+ mRS.nScriptSetVarV(getID(mRS), index, v.getData());
}
public void setTimeZone(String timeZone) {
mRS.validate();
try {
- mRS.nScriptSetTimeZone(getID(), timeZone.getBytes("UTF-8"));
+ mRS.nScriptSetTimeZone(getID(mRS), timeZone.getBytes("UTF-8"));
} catch (java.io.UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java
index 70d1de4..a707df2 100644
--- a/graphics/java/android/renderscript/Type.java
+++ b/graphics/java/android/renderscript/Type.java
@@ -180,7 +180,7 @@ public class Type extends BaseObj {
// We have 6 integer to obtain mDimX; mDimY; mDimZ;
// mDimLOD; mDimFaces; mElement;
int[] dataBuffer = new int[6];
- mRS.nTypeGetNativeData(getID(), dataBuffer);
+ mRS.nTypeGetNativeData(getID(mRS), dataBuffer);
mDimX = dataBuffer[0];
mDimY = dataBuffer[1];
@@ -280,7 +280,8 @@ public class Type extends BaseObj {
}
}
- int id = mRS.nTypeCreate(mElement.getID(), mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces);
+ int id = mRS.nTypeCreate(mElement.getID(mRS),
+ mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces);
Type t = new Type(id, mRS);
t.mElement = mElement;
t.mDimX = mDimX;