Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84379677 authored by Tim Murray's avatar Tim Murray Committed by Android (Google) Code Review
Browse files

Merge "Convert Java/JNI to 64-bit, part 2."

parents 52909212 460a0497
Loading
Loading
Loading
Loading
+16 −14
Original line number Diff line number Diff line
@@ -73,8 +73,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;

    /**
@@ -183,7 +183,7 @@ public class Allocation extends BaseObj {
    }


    private int getIDSafe() {
    private long getIDSafe() {
        if (mAdaptedAllocation != null) {
            return mAdaptedAllocation.getID(mRS);
        }
@@ -239,7 +239,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 |
@@ -340,7 +340,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();
@@ -435,9 +435,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);
@@ -1329,7 +1331,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);
@@ -1359,7 +1361,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.");
        }
@@ -1414,7 +1416,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.");
        }
@@ -1498,7 +1500,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.");
            }
@@ -1510,7 +1512,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.");
        }
@@ -1613,7 +1615,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);
        }
@@ -1838,14 +1840,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);
+2 −2
Original line number Diff line number Diff line
@@ -21,12 +21,12 @@ package android.renderscript;
 *
 **/
public class AllocationAdapter extends Allocation {
    AllocationAdapter(int id, RenderScript rs, Allocation alloc) {
    AllocationAdapter(long id, RenderScript rs, Allocation alloc) {
        super(id, rs, alloc.mType, alloc.mUsage);
        mAdaptedAllocation = alloc;
    }

    int getID(RenderScript rs) {
    long getID(RenderScript rs) {
        throw new RSInvalidStateException(
            "This operation is not supported with adapters at this time.");
    }
+5 −5
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ package android.renderscript;
 *
 **/
public class BaseObj {
    BaseObj(int id, RenderScript rs) {
    BaseObj(long id, RenderScript rs) {
        rs.validate();
        mRS = rs;
        mID = id;
@@ -44,9 +44,9 @@ public class BaseObj {
     * @param rs Context to verify against internal context for
     *           match.
     *
     * @return int
     * @return long
     */
    int getID(RenderScript rs) {
    long getID(RenderScript rs) {
        mRS.validate();
        if (mDestroyed) {
            throw new RSInvalidStateException("using a destroyed object.");
@@ -66,7 +66,7 @@ public class BaseObj {
        }
    }

    private int mID;
    private long mID;
    private boolean mDestroyed;
    private String mName;
    RenderScript mRS;
@@ -150,7 +150,7 @@ public class BaseObj {
     */
    @Override
    public int hashCode() {
        return mID;
        return (int)((mID & 0xfffffff) ^ (mID >> 32));
    }

    /**
+11 −8
Original line number Diff line number Diff line
@@ -756,7 +756,7 @@ public class Element extends BaseObj {
        return rs.mElement_MATRIX_2X2;
    }

    Element(int id, RenderScript rs, Element[] e, String[] n, int[] as) {
    Element(long id, RenderScript rs, Element[] e, String[] n, int[] as) {
        super(id, rs);
        mSize = 0;
        mVectorSize = 1;
@@ -773,7 +773,7 @@ public class Element extends BaseObj {
        updateVisibleSubElements();
    }

    Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) {
    Element(long id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) {
        super(id, rs);
        if ((dt != DataType.UNSIGNED_5_6_5) &&
            (dt != DataType.UNSIGNED_4_4_4_4) &&
@@ -792,7 +792,7 @@ public class Element extends BaseObj {
        mVectorSize = size;
    }

    Element(int id, RenderScript rs) {
    Element(long id, RenderScript rs) {
        super(id, rs);
    }

@@ -800,6 +800,8 @@ public class Element extends BaseObj {
    void updateFromNative() {
        super.updateFromNative();

        // FIXME: updateFromNative is broken in JNI for 64-bit

        // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
        int[] dataBuffer = new int[5];
        mRS.nElementGetNativeData(getID(mRS), dataBuffer);
@@ -850,7 +852,7 @@ public class Element extends BaseObj {
        DataKind dk = DataKind.USER;
        boolean norm = false;
        int vecSize = 1;
        int id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize);
        long id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize);
        return new Element(id, rs, dt, dk, norm, vecSize);
    }

@@ -887,7 +889,7 @@ public class Element extends BaseObj {
        case BOOLEAN: {
            DataKind dk = DataKind.USER;
            boolean norm = false;
            int id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
            long id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
            return new Element(id, rs, dt, dk, norm, size);
        }

@@ -958,7 +960,7 @@ public class Element extends BaseObj {
        }

        boolean norm = true;
        int id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
        long id = rs.nElementCreate(dt.mID, dk.mID, norm, size);
        return new Element(id, rs, dt, dk, norm, size);
    }

@@ -1085,11 +1087,12 @@ public class Element extends BaseObj {
            java.lang.System.arraycopy(mElementNames, 0, sin, 0, mCount);
            java.lang.System.arraycopy(mArraySizes, 0, asin, 0, mCount);

            // FIXME: broken for 64-bit
            int[] ids = new int[ein.length];
            for (int ct = 0; ct < ein.length; ct++ ) {
                ids[ct] = ein[ct].getID(mRS);
                ids[ct] = (int)ein[ct].getID(mRS);
            }
            int id = mRS.nElementCreate2(ids, sin, asin);
            long id = mRS.nElementCreate2(ids, sin, asin);
            return new Element(id, mRS, ein, sin, asin);
        }
    }
+2 −1
Original line number Diff line number Diff line
@@ -231,7 +231,8 @@ public class FieldPacker {

    public void addObj(BaseObj obj) {
        if (obj != null) {
            addI32(obj.getID(null));
            // FIXME: this is fine for 32-bit but needs a path for 64-bit
            addI32((int)obj.getID(null));
        } else {
            addI32(0);
        }
Loading