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

Commit 031ec58c authored by Stephen Hines's avatar Stephen Hines
Browse files

Fix support for 64-bit integers.

Change-Id: I4e2146a5fda41f280ee3f6f685a34f3cff28f05e
parent c2a44325
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -359,6 +359,10 @@ public class RenderScript {
    synchronized void nScriptSetVarI(int id, int slot, int val) {
        rsnScriptSetVarI(mContext, id, slot, val);
    }
    native void rsnScriptSetVarJ(int con, int id, int slot, long val);
    synchronized void nScriptSetVarJ(int id, int slot, long val) {
        rsnScriptSetVarJ(mContext, id, slot, val);
    }
    native void rsnScriptSetVarF(int con, int id, int slot, float val);
    synchronized void nScriptSetVarF(int id, int slot, float val) {
        rsnScriptSetVarF(mContext, id, slot, val);
+4 −0
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@ public class Script extends BaseObj {
        mRS.nScriptSetVarI(mID, index, v);
    }

    public void setVar(int index, long v) {
        mRS.nScriptSetVarJ(mID, index, v);
    }

    public void setVar(int index, boolean v) {
        mRS.nScriptSetVarI(mID, index, v ? 1 : 0);
    }
+8 −0
Original line number Diff line number Diff line
@@ -779,6 +779,13 @@ nScriptSetVarI(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slo
    rsScriptSetVarI(con, (RsScript)script, slot, val);
}

static void
nScriptSetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jlong val)
{
    LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", con, (void *)script, slot, val);
    rsScriptSetVarJ(con, (RsScript)script, slot, val);
}

static void
nScriptSetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, float val)
{
@@ -1266,6 +1273,7 @@ static JNINativeMethod methods[] = {
{"rsnScriptInvoke",                  "(III)V",                                (void*)nScriptInvoke },
{"rsnScriptInvokeV",                 "(III[B)V",                              (void*)nScriptInvokeV },
{"rsnScriptSetVarI",                 "(IIII)V",                               (void*)nScriptSetVarI },
{"rsnScriptSetVarJ",                 "(IIIJ)V",                               (void*)nScriptSetVarJ },
{"rsnScriptSetVarF",                 "(IIIF)V",                               (void*)nScriptSetVarF },
{"rsnScriptSetVarD",                 "(IIID)V",                               (void*)nScriptSetVarD },
{"rsnScriptSetVarV",                 "(III[B)V",                              (void*)nScriptSetVarV },
+55 −3
Original line number Diff line number Diff line
@@ -27,13 +27,65 @@ public class UT_primitives extends UnitTest {
        mRes = res;
    }

    private boolean initializeGlobals(ScriptC_primitives s) {
        float pF = s.get_floatTest();
        if (pF != 1.99f) {
            return false;
        }
        s.set_floatTest(2.99f);

        double pD = s.get_doubleTest();
        if (pD != 2.05) {
            return false;
        }
        s.set_doubleTest(3.05);

        byte pC = s.get_charTest();
        if (pC != -8) {
            return false;
        }
        s.set_charTest((byte)-16);

        short pS = s.get_shortTest();
        if (pS != -16) {
            return false;
        }
        s.set_shortTest((short)-32);

        int pI = s.get_intTest();
        if (pI != -32) {
            return false;
        }
        s.set_intTest(-64);

        /*long pL = s.get_longTest();
        if (pL != 17179869184l) {
            return false;
        }
        s.set_longTest(17179869185l);*/

        long pLL = s.get_longlongTest();
        if (pLL != 68719476736L) {
            return false;
        }
        s.set_longlongTest(68719476735L);
        //s.set_longlongTest(0);

        return true;
    }

    public void run() {
        RenderScript pRS = RenderScript.create();
        ScriptC_primitives s = new ScriptC_primitives(pRS, mRes, R.raw.primitives, true);
        pRS.mMessageCallback = mRsMessage;
        if (!initializeGlobals(s)) {
            // initializeGlobals failed
            result = -1;
        } else {
            s.invoke_primitives_test(0, 0);
            pRS.finish();
            waitForMessage();
        }
        pRS.destroy();
    }
}
+12 −10
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public class UnitTest extends Thread {

    protected RSMessage mRsMessage = new RSMessage() {
        public void run() {
            if (result == 0) {
                switch (mID) {
                    case RS_MSG_TEST_PASSED:
                        result = 1;
@@ -66,6 +67,7 @@ public class UnitTest extends Thread {
                        android.util.Log.v("RenderScript", "Unit test got unexpected message");
                        return;
                }
            }

            if (mItem != null) {
                mItem.result = result;
Loading