diff options
author | Tim Murray <timmurray@google.com> | 2013-11-19 12:45:54 -0800 |
---|---|---|
committer | Tim Murray <timmurray@google.com> | 2013-11-20 10:18:04 -0800 |
commit | 460a04971c494fec39ffcb38e873bb8fdd82d113 (patch) | |
tree | b1567d93e44eec510a0c3adcd9bacd6f2542a860 /graphics/java/android/renderscript/Allocation.java | |
parent | eff663f391fa4f119685d5c14489b94661ea126f (diff) |
Convert Java/JNI to 64-bit, part 2.
This changes BaseObj to support 64-bit IDs. There are a few caveats:
1. Since it is deprecated, RSG will not support 64-bit.
2. Currently, methods that pass arrays of IDs to the driver are not supported in 64-bit. This will be fixed in a later CL.
bug 11332320
Change-Id: If0dbecc8b285e260f767e441e05088b6a1b749a2
Diffstat (limited to 'graphics/java/android/renderscript/Allocation.java')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 8e69f562336b..98fabcee7e39 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -77,8 +77,8 @@ public class Allocation extends BaseObj { int mCurrentDimY; int mCurrentDimZ; int mCurrentCount; - static HashMap<Integer, Allocation> mAllocationMap = - new HashMap<Integer, Allocation>(); + static HashMap<Long, Allocation> mAllocationMap = + new HashMap<Long, Allocation>(); OnBufferAvailableListener mBufferNotifier; /** @@ -187,7 +187,7 @@ public class Allocation extends BaseObj { } - private int getIDSafe() { + private long getIDSafe() { if (mAdaptedAllocation != null) { return mAdaptedAllocation.getID(mRS); } @@ -243,7 +243,7 @@ public class Allocation extends BaseObj { mBitmap = b; } - Allocation(int id, RenderScript rs, Type t, int usage) { + Allocation(long id, RenderScript rs, Type t, int usage) { super(id, rs); if ((usage & ~(USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE | @@ -344,7 +344,7 @@ public class Allocation extends BaseObj { @Override void updateFromNative() { super.updateFromNative(); - int typeID = mRS.nAllocationGetType(getID(mRS)); + long typeID = mRS.nAllocationGetType(getID(mRS)); if(typeID != 0) { mType = new Type(typeID, mRS); mType.updateFromNative(); @@ -439,9 +439,11 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " + mCurrentCount + ", array length = " + d.length); } + // FIXME: requires 64-bit path + int i[] = new int[d.length]; for (int ct=0; ct < d.length; ct++) { - i[ct] = d[ct].getID(mRS); + i[ct] = (int)d[ct].getID(mRS); } copy1DRangeFromUnchecked(0, mCurrentCount, i); Trace.traceEnd(RenderScript.TRACE_TAG); @@ -1333,7 +1335,7 @@ public class Allocation extends BaseObj { mRS.nAllocationResize1D(getID(mRS), dimX); mRS.finish(); // Necessary because resize is fifoed and update is async. - int typeID = mRS.nAllocationGetType(getID(mRS)); + long typeID = mRS.nAllocationGetType(getID(mRS)); mType = new Type(typeID, mRS); mType.updateFromNative(); updateCacheInfo(mType); @@ -1363,7 +1365,7 @@ public class Allocation extends BaseObj { if (type.getID(rs) == 0) { throw new RSInvalidStateException("Bad Type"); } - int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0); + long id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); } @@ -1418,7 +1420,7 @@ public class Allocation extends BaseObj { b.setX(count); Type t = b.create(); - int id = rs.nAllocationCreateTyped(t.getID(rs), MipmapControl.MIPMAP_NONE.mID, usage, 0); + long id = rs.nAllocationCreateTyped(t.getID(rs), MipmapControl.MIPMAP_NONE.mID, usage, 0); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); } @@ -1502,7 +1504,7 @@ public class Allocation extends BaseObj { if (mips == MipmapControl.MIPMAP_NONE && t.getElement().isCompatible(Element.RGBA_8888(rs)) && usage == (USAGE_SHARED | USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE)) { - int id = rs.nAllocationCreateBitmapBackedAllocation(t.getID(rs), mips.mID, b, usage); + long id = rs.nAllocationCreateBitmapBackedAllocation(t.getID(rs), mips.mID, b, usage); if (id == 0) { throw new RSRuntimeException("Load failed."); } @@ -1514,7 +1516,7 @@ public class Allocation extends BaseObj { } - int id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage); + long id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage); if (id == 0) { throw new RSRuntimeException("Load failed."); } @@ -1617,7 +1619,7 @@ public class Allocation extends BaseObj { tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL); Type t = tb.create(); - int id = rs.nAllocationCubeCreateFromBitmap(t.getID(rs), mips.mID, b, usage); + long id = rs.nAllocationCubeCreateFromBitmap(t.getID(rs), mips.mID, b, usage); if(id == 0) { throw new RSRuntimeException("Load failed for bitmap " + b + " element " + e); } @@ -1842,14 +1844,14 @@ public class Allocation extends BaseObj { */ public void setOnBufferAvailableListener(OnBufferAvailableListener callback) { synchronized(mAllocationMap) { - mAllocationMap.put(new Integer(getID(mRS)), this); + mAllocationMap.put(new Long(getID(mRS)), this); mBufferNotifier = callback; } } static void sendBufferNotification(int id) { synchronized(mAllocationMap) { - Allocation a = mAllocationMap.get(new Integer(id)); + Allocation a = mAllocationMap.get(new Long(id)); if ((a != null) && (a.mBufferNotifier != null)) { a.mBufferNotifier.onBufferAvailable(a); |