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

Commit c3ae1127 authored by Jason Sams's avatar Jason Sams Committed by Android (Google) Code Review
Browse files

Merge "Delete old createFromClass methods. It no longer makes sense to create...

Merge "Delete old createFromClass methods. It no longer makes sense to create type info from Java since this cannot be exported to scripts.  The new flow is in the opposite direction."
parents 71491ab2 b42315d3
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -315,29 +315,6 @@ public class Element extends BaseObj {
        super.destroy();
    }

    public static Element createFromClass(RenderScript rs, Class c) {
        rs.validate();
        Field[] fields = c.getFields();
        Builder b = new Builder(rs);

        for(Field f: fields) {
            Class fc = f.getType();
            if(fc == int.class) {
                b.add(createUser(rs, DataType.SIGNED_32), f.getName());
            } else if(fc == short.class) {
                b.add(createUser(rs, DataType.SIGNED_16), f.getName());
            } else if(fc == byte.class) {
                b.add(createUser(rs, DataType.SIGNED_8), f.getName());
            } else if(fc == float.class) {
                b.add(createUser(rs, DataType.FLOAT_32), f.getName());
            } else {
                throw new IllegalArgumentException("Unkown field type");
            }
        }
        return b.create();
    }


    /////////////////////////////////////////
    public static Element createUser(RenderScript rs, DataType dt) {
        return new Element(rs, dt, DataKind.USER, false, 1);
+2 −41
Original line number Diff line number Diff line
@@ -108,48 +108,9 @@ public class Type extends BaseObj {
        super.finalize();
    }

    public static Type createFromClass(RenderScript rs, Class c, int size) {
        Element e = Element.createFromClass(rs, c);
        Builder b = new Builder(rs, e);
        b.add(Dimension.X, size);
        Type t = b.create();
        e.destroy();

        // native fields
        {
            Field[] fields = c.getFields();
            int[] arTypes = new int[fields.length];
            int[] arBits = new int[fields.length];

            for(int ct=0; ct < fields.length; ct++) {
                Field f = fields[ct];
                Class fc = f.getType();
                if(fc == int.class) {
                    arTypes[ct] = Element.DataType.SIGNED_32.mID;
                    arBits[ct] = 32;
                } else if(fc == short.class) {
                    arTypes[ct] = Element.DataType.SIGNED_16.mID;
                    arBits[ct] = 16;
                } else if(fc == byte.class) {
                    arTypes[ct] = Element.DataType.SIGNED_8.mID;
                    arBits[ct] = 8;
                } else if(fc == float.class) {
                    arTypes[ct] = Element.DataType.FLOAT_32.mID;
                    arBits[ct] = 32;
                } else {
                    throw new IllegalArgumentException("Unkown field type");
                }
            }
            rs.nTypeSetupFields(t, arTypes, arBits, fields);
        }
        t.mJavaClass = c;
        return t;
    }

    public static Type createFromClass(RenderScript rs, Class c, int size, String scriptName) {
        Type t = createFromClass(rs, c, size);
        t.setName(scriptName);
        return t;
        android.util.Log.e("RenderScript", "Calling depricated createFromClass");
        return null;
    }


+1 −1
Original line number Diff line number Diff line
@@ -213,7 +213,7 @@ public class FilmRS {

        Log.e("rs", "Done loading named");

        mStripPositionType = Type.createFromClass(mRS, StripPosition.class, 1);
        //mStripPositionType = Type.createFromClass(mRS, StripPosition.class, 1);

        ScriptC.Builder sb = new ScriptC.Builder(mRS);
        sb.setScript(mRes, R.raw.filmstrip);