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

Commit add26dca authored by Jason Sams's avatar Jason Sams
Browse files

add support for debug and profile contexts.

Change-Id: I759e54e365a344a93d725eb4fa70a2c4c98bf05a
parent 786525e8
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -20081,6 +20081,14 @@ package android.renderscript {
    method public void setPriority(android.renderscript.RenderScript.Priority);
  }
  public static final class RenderScript.ContextType extends java.lang.Enum {
    method public static android.renderscript.RenderScript.ContextType valueOf(java.lang.String);
    method public static final android.renderscript.RenderScript.ContextType[] values();
    enum_constant public static final android.renderscript.RenderScript.ContextType DEBUG;
    enum_constant public static final android.renderscript.RenderScript.ContextType NORMAL;
    enum_constant public static final android.renderscript.RenderScript.ContextType PROFILE;
  }
  public static final class RenderScript.Priority extends java.lang.Enum {
    method public static android.renderscript.RenderScript.Priority valueOf(java.lang.String);
    method public static final android.renderscript.RenderScript.Priority[] values();
+35 −6
Original line number Diff line number Diff line
@@ -102,6 +102,16 @@ public class RenderScript {
        f.mkdirs();
    }

    public enum ContextType {
        NORMAL (0),
        DEBUG (1),
        PROFILE (2);

        int mID;
        ContextType(int id) {
            mID = id;
        }
    }

    // Methods below are wrapped to protect the non-threadsafe
    // lockless fifo.
@@ -122,9 +132,9 @@ public class RenderScript {
                                  stencilMin, stencilPref,
                                  samplesMin, samplesPref, samplesQ, dpi);
    }
    native int  rsnContextCreate(int dev, int ver, int sdkVer);
    synchronized int nContextCreate(int dev, int ver, int sdkVer) {
        return rsnContextCreate(dev, ver, sdkVer);
    native int  rsnContextCreate(int dev, int ver, int sdkVer, int contextType);
    synchronized int nContextCreate(int dev, int ver, int sdkVer, int contextType) {
        return rsnContextCreate(dev, ver, sdkVer, contextType);
    }
    native void rsnContextDestroy(int con);
    synchronized void nContextDestroy() {
@@ -1011,6 +1021,13 @@ public class RenderScript {
        return mApplicationContext;
    }

    /**
     * @hide
     */
    public static RenderScript create(Context ctx, int sdkVersion) {
        return create(ctx, sdkVersion, ContextType.NORMAL);
    }

    /**
     * Create a basic RenderScript context.
     *
@@ -1018,11 +1035,11 @@ public class RenderScript {
     * @param ctx The context.
     * @return RenderScript
     */
    public static RenderScript create(Context ctx, int sdkVersion) {
    public static RenderScript create(Context ctx, int sdkVersion, ContextType ct) {
        RenderScript rs = new RenderScript(ctx);

        rs.mDev = rs.nDeviceCreate();
        rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion);
        rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion, ct.mID);
        if (rs.mContext == 0) {
            throw new RSDriverException("Failed to create RS context.");
        }
@@ -1038,8 +1055,20 @@ public class RenderScript {
     * @return RenderScript
     */
    public static RenderScript create(Context ctx) {
        return create(ctx, ContextType.NORMAL);
    }

    /**
     * Create a basic RenderScript context.
     *
     * @hide
     *
     * @param ctx The context.
     * @return RenderScript
     */
    public static RenderScript create(Context ctx, ContextType ct) {
        int v = ctx.getApplicationInfo().targetSdkVersion;
        return create(ctx, v);
        return create(ctx, v, ct);
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -182,10 +182,10 @@ nDeviceSetConfig(JNIEnv *_env, jobject _this, jint dev, jint p, jint value)
}

static jint
nContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer)
nContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer, jint ct)
{
    LOG_API("nContextCreate");
    return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer);
    return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer, (RsContextType)ct, false, false);
}

static jint
@@ -1463,7 +1463,7 @@ static JNINativeMethod methods[] = {


// All methods below are thread protected in java.
{"rsnContextCreate",                 "(III)I",                                (void*)nContextCreate },
{"rsnContextCreate",                 "(IIII)I",                               (void*)nContextCreate },
{"rsnContextCreateGL",               "(IIIIIIIIIIIIIFI)I",                    (void*)nContextCreateGL },
{"rsnContextFinish",                 "(I)V",                                  (void*)nContextFinish },
{"rsnContextSetPriority",            "(II)V",                                 (void*)nContextSetPriority },