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

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

Merge "Begin naming cleanup for renderscript runtime. Prefix functions with "rs" or "rsg"."

parents a3c76f2d d79b2e9f
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -134,9 +134,6 @@ public class RenderScript {
    native int  nAdapter2DCreate();

    native void nScriptBindAllocation(int script, int alloc, int slot);
    native void nScriptSetClearColor(int script, float r, float g, float b, float a);
    native void nScriptSetClearDepth(int script, float depth);
    native void nScriptSetClearStencil(int script, int stencil);
    native void nScriptSetTimeZone(int script, byte[] timeZone);
    native void nScriptInvoke(int id, int slot);
    native void nScriptInvokeData(int id, int slot);
+0 −15
Original line number Diff line number Diff line
@@ -81,21 +81,6 @@ public class Script extends BaseObj {
        mRS.nScriptSetVarV(mID, index, v.getData());
    }

    public void setClearColor(float r, float g, float b, float a) {
        mRS.validate();
        mRS.nScriptSetClearColor(mID, r, g, b, a);
    }

    public void setClearDepth(float d) {
        mRS.validate();
        mRS.nScriptSetClearDepth(mID, d);
    }

    public void setClearStencil(int stencil) {
        mRS.validate();
        mRS.nScriptSetClearStencil(mID, stencil);
    }

    public void setTimeZone(String timeZone) {
        mRS.validate();
        try {
+0 −26
Original line number Diff line number Diff line
@@ -880,29 +880,6 @@ nScriptSetVarV(JNIEnv *_env, jobject _this, jint script, jint slot, jbyteArray d
    _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
}

static void
nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a)
{
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, (void *)script, r, g, b, a);
    rsScriptSetClearColor(con, (RsScript)script, r, g, b, a);
}

static void
nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d)
{
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, (void *)script, d);
    rsScriptSetClearDepth(con, (RsScript)script, d);
}

static void
nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil)
{
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, (void *)script, stencil);
    rsScriptSetClearStencil(con, (RsScript)script, stencil);
}

static void
nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone)
@@ -1410,9 +1387,6 @@ static JNINativeMethod methods[] = {
{"nAdapter2DCreate",               "()I",                                  (void*)nAdapter2DCreate },

{"nScriptBindAllocation",          "(III)V",                               (void*)nScriptBindAllocation },
{"nScriptSetClearColor",           "(IFFFF)V",                             (void*)nScriptSetClearColor },
{"nScriptSetClearDepth",           "(IF)V",                                (void*)nScriptSetClearDepth },
{"nScriptSetClearStencil",         "(II)V",                                (void*)nScriptSetClearStencil },
{"nScriptSetTimeZone",             "(I[B)V",                               (void*)nScriptSetTimeZone },
{"nScriptInvoke",                  "(II)V",                                (void*)nScriptInvoke },
{"nScriptInvokeData",              "(II)V",                                (void*)nScriptInvokeData },
+0 −4
Original line number Diff line number Diff line
@@ -213,13 +213,9 @@ public class FilmRS {

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

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

        ScriptC.Builder sb = new ScriptC.Builder(mRS);
        sb.setScript(mRes, R.raw.filmstrip);
        //sb.setType(mStripPositionType, "Pos", 1);
        mScriptStrip = sb.create();
        mScriptStrip.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);

        mAllocPos = Allocation.createTyped(mRS, mStripPositionType);

+19 −15
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ static int newPart = 0;

float4 partColor;
rs_mesh partMesh;
rs_allocation partBuffer;

typedef struct __attribute__((packed, aligned(4))) Point_s {
    float2 delta;
@@ -18,17 +17,13 @@ typedef struct __attribute__((packed, aligned(4))) Point_s {
} Point_t;
Point_t *point;

#pragma rs export_var(point, partColor, partMesh, partBuffer)
//#pragma rs export_type(Point_s)
//#pragma rs export_element(point)
#pragma rs export_var(point, partColor, partMesh)

int root() {
    debugPf(1, partColor.x);
    debugPi(4, partMesh);
    debugPi(5, partBuffer);

    float height = getHeight();
    int size = allocGetDimX(partBuffer);
    rsgClearColor(0.f, 0.f, 0.f, 1.f);
    float height = rsgGetHeight();
    rs_allocation alloc = rsGetAllocation(point);
    int size = rsAllocationGetDimX(alloc);

    Point_t * p = point;
    for (int ct=0; ct < size; ct++) {
@@ -40,22 +35,31 @@ int root() {
        p++;
    }

    uploadToBufferObject(partBuffer);
    drawSimpleMesh(partMesh);
    rsgUploadToBufferObject(alloc);
    rsgDrawSimpleMesh(partMesh);
    return 1;
}

void addParticles(int rate, int x, int y)
{
    rsDebug("partColor", partColor);
    rsDebug("partColor x", partColor.x);
    rsDebug("partColor y", partColor.y);
    rsDebug("partColor z", partColor.z);
    rsDebug("partColor w", partColor.w);

    float rMax = ((float)rate) * 0.005f;
    int size = allocGetDimX(partBuffer);
    int size = rsAllocationGetDimX(rsGetAllocation(point));

    rs_color4u c = convertColorTo8888(partColor.x, partColor.y, partColor.z);
    rs_color4u c = rsPackColorTo8888(partColor.x, partColor.y, partColor.z);
    Point_t * np = &point[newPart];

    float2 p = {x, y};
    while (rate--) {
        np->delta = vec2Rand(rMax);
        float angle = rsRand(3.14f * 2.f);
        float len = rsRand(rMax);
        np->delta.x = len * sin(angle);
        np->delta.y = len * cos(angle);
        np->pos = p;
        np->color = c;
        newPart++;
Loading