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

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

Merge "Seperate ProgramRaster. Cleanup ProgramRaster and ProgramStore creation."

parents d57a93b2 331bf9b1
Loading
Loading
Loading
Loading
+3 −20
Original line number Diff line number Diff line
@@ -55,18 +55,6 @@ public class ProgramRaster extends BaseObj {
        mCullMode = CullMode.BACK;
    }

    void setLineWidth(float w) {
        mRS.validate();
        mLineWidth = w;
        mRS.nProgramRasterSetLineWidth(getID(), w);
    }

    void setCullMode(CullMode m) {
        mRS.validate();
        mCullMode = m;
        mRS.nProgramRasterSetCullMode(getID(), m.mID);
    }

    public static ProgramRaster CULL_BACK(RenderScript rs) {
        if(rs.mProgramRaster_CULL_BACK == null) {
            ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
@@ -119,16 +107,11 @@ public class ProgramRaster extends BaseObj {
            return this;
        }

        static synchronized ProgramRaster internalCreate(RenderScript rs, Builder b) {
            int id = rs.nProgramRasterCreate(b.mPointSmooth, b.mLineSmooth, b.mPointSprite);
            ProgramRaster pr = new ProgramRaster(id, rs);
            pr.setCullMode(b.mCullMode);
            return pr;
        }

        public ProgramRaster create() {
            mRS.validate();
            return internalCreate(mRS, this);
            int id = mRS.nProgramRasterCreate(mPointSmooth, mLineSmooth, mPointSprite,
                                             1.f, mCullMode.mID);
            return new ProgramRaster(id, mRS);
        }
    }

+4 −16
Original line number Diff line number Diff line
@@ -333,27 +333,15 @@ public class ProgramStore extends BaseObj {
            return this;
        }

        static synchronized ProgramStore internalCreate(RenderScript rs, Builder b) {
            rs.nProgramStoreBegin(0, 0);
            rs.nProgramStoreDepthFunc(b.mDepthFunc.mID);
            rs.nProgramStoreDepthMask(b.mDepthMask);
            rs.nProgramStoreColorMask(b.mColorMaskR,
                                              b.mColorMaskG,
                                              b.mColorMaskB,
                                              b.mColorMaskA);
            rs.nProgramStoreBlendFunc(b.mBlendSrc.mID, b.mBlendDst.mID);
            rs.nProgramStoreDither(b.mDither);

            int id = rs.nProgramStoreCreate();
            return new ProgramStore(id, rs);
        }

        /**
        * Creates a program store from the current state of the builder
        */
        public ProgramStore create() {
            mRS.validate();
            return internalCreate(mRS, this);
            int id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA,
                                             mDepthMask, mDither,
                                             mBlendSrc.mID, mBlendDst.mID, mDepthFunc.mID);
            return new ProgramStore(id, mRS);
        }
    }

+12 −46
Original line number Diff line number Diff line
@@ -485,56 +485,22 @@ public class RenderScript {
        return rsnSamplerCreate(mContext);
    }

    native void rsnProgramStoreBegin(int con, int in, int out);
    synchronized void nProgramStoreBegin(int in, int out) {
    native int  rsnProgramStoreCreate(int con, boolean r, boolean g, boolean b, boolean a,
                                      boolean depthMask, boolean dither,
                                      int srcMode, int dstMode, int depthFunc);
    synchronized int nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a,
                                         boolean depthMask, boolean dither,
                                         int srcMode, int dstMode, int depthFunc) {
        validate();
        rsnProgramStoreBegin(mContext, in, out);
    }
    native void rsnProgramStoreDepthFunc(int con, int func);
    synchronized void nProgramStoreDepthFunc(int func) {
        validate();
        rsnProgramStoreDepthFunc(mContext, func);
    }
    native void rsnProgramStoreDepthMask(int con, boolean enable);
    synchronized void nProgramStoreDepthMask(boolean enable) {
        validate();
        rsnProgramStoreDepthMask(mContext, enable);
    }
    native void rsnProgramStoreColorMask(int con, boolean r, boolean g, boolean b, boolean a);
    synchronized void nProgramStoreColorMask(boolean r, boolean g, boolean b, boolean a) {
        validate();
        rsnProgramStoreColorMask(mContext, r, g, b, a);
    }
    native void rsnProgramStoreBlendFunc(int con, int src, int dst);
    synchronized void nProgramStoreBlendFunc(int src, int dst) {
        validate();
        rsnProgramStoreBlendFunc(mContext, src, dst);
    }
    native void rsnProgramStoreDither(int con, boolean enable);
    synchronized void nProgramStoreDither(boolean enable) {
        validate();
        rsnProgramStoreDither(mContext, enable);
    }
    native int  rsnProgramStoreCreate(int con);
    synchronized int nProgramStoreCreate() {
        validate();
        return rsnProgramStoreCreate(mContext);
        return rsnProgramStoreCreate(mContext, r, g, b, a, depthMask, dither, srcMode, dstMode, depthFunc);
    }

    native int  rsnProgramRasterCreate(int con, boolean pointSmooth, boolean lineSmooth, boolean pointSprite);
    synchronized int nProgramRasterCreate(boolean pointSmooth, boolean lineSmooth, boolean pointSprite) {
        validate();
        return rsnProgramRasterCreate(mContext, pointSmooth, lineSmooth, pointSprite);
    }
    native void rsnProgramRasterSetLineWidth(int con, int pr, float v);
    synchronized void nProgramRasterSetLineWidth(int pr, float v) {
        validate();
        rsnProgramRasterSetLineWidth(mContext, pr, v);
    }
    native void rsnProgramRasterSetCullMode(int con, int pr, int mode);
    synchronized void nProgramRasterSetCullMode(int pr, int mode) {
    native int  rsnProgramRasterCreate(int con, boolean pointSmooth, boolean lineSmooth,
                                       boolean pointSprite, float lineWidth, int cullMode);
    synchronized int nProgramRasterCreate(boolean pointSmooth, boolean lineSmooth,
                                          boolean pointSprite, float lineWidth, int cullMode) {
        validate();
        rsnProgramRasterSetCullMode(mContext, pr, mode);
        return rsnProgramRasterCreate(mContext, pointSmooth, lineSmooth, pointSprite, lineWidth, cullMode);
    }

    native void rsnProgramBindConstants(int con, int pv, int slot, int mID);
+13 −72
Original line number Diff line number Diff line
@@ -897,53 +897,17 @@ exit:

// ---------------------------------------------------------------------------

static void
nProgramStoreBegin(JNIEnv *_env, jobject _this, RsContext con, jint in, jint out)
{
    LOG_API("nProgramStoreBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out);
    rsProgramStoreBegin(con, (RsElement)in, (RsElement)out);
}

static void
nProgramStoreDepthFunc(JNIEnv *_env, jobject _this, RsContext con, jint func)
{
    LOG_API("nProgramStoreDepthFunc, con(%p), func(%i)", con, func);
    rsProgramStoreDepthFunc(con, (RsDepthFunc)func);
}

static void
nProgramStoreDepthMask(JNIEnv *_env, jobject _this, RsContext con, jboolean enable)
{
    LOG_API("nProgramStoreDepthMask, con(%p), enable(%i)", con, enable);
    rsProgramStoreDepthMask(con, enable);
}

static void
nProgramStoreColorMask(JNIEnv *_env, jobject _this, RsContext con, jboolean r, jboolean g, jboolean b, jboolean a)
{
    LOG_API("nProgramStoreColorMask, con(%p), r(%i), g(%i), b(%i), a(%i)", con, r, g, b, a);
    rsProgramStoreColorMask(con, r, g, b, a);
}

static void
nProgramStoreBlendFunc(JNIEnv *_env, jobject _this, RsContext con, int src, int dst)
{
    LOG_API("nProgramStoreBlendFunc, con(%p), src(%i), dst(%i)", con, src, dst);
    rsProgramStoreBlendFunc(con, (RsBlendSrcFunc)src, (RsBlendDstFunc)dst);
}

static void
nProgramStoreDither(JNIEnv *_env, jobject _this, RsContext con, jboolean enable)
{
    LOG_API("nProgramStoreDither, con(%p), enable(%i)", con, enable);
    rsProgramStoreDither(con, enable);
}

static jint
nProgramStoreCreate(JNIEnv *_env, jobject _this, RsContext con)
nProgramStoreCreate(JNIEnv *_env, jobject _this, RsContext con,
                    jboolean colorMaskR, jboolean colorMaskG, jboolean colorMaskB, jboolean colorMaskA,
                    jboolean depthMask, jboolean ditherEnable,
                    jint srcFunc, jint destFunc,
                    jint depthFunc)
{
    LOG_API("nProgramStoreCreate, con(%p)", con);
    return (jint)rsProgramStoreCreate(con);
    return (jint)rsProgramStoreCreate(con, colorMaskR, colorMaskG, colorMaskB, colorMaskA,
                                      depthMask, ditherEnable, (RsBlendSrcFunc)srcFunc,
                                      (RsBlendDstFunc)destFunc, (RsDepthFunc)depthFunc);
}

// ---------------------------------------------------------------------------
@@ -1005,25 +969,12 @@ nProgramVertexCreate(JNIEnv *_env, jobject _this, RsContext con, jstring shader,
// ---------------------------------------------------------------------------

static jint
nProgramRasterCreate(JNIEnv *_env, jobject _this, RsContext con, jboolean pointSmooth, jboolean lineSmooth, jboolean pointSprite)
nProgramRasterCreate(JNIEnv *_env, jobject _this, RsContext con, jboolean pointSmooth,
                     jboolean lineSmooth, jboolean pointSprite, jfloat lineWidth, jint cull)
{
    LOG_API("nProgramRasterCreate, con(%p), pointSmooth(%i), lineSmooth(%i), pointSprite(%i)",
            con, pointSmooth, lineSmooth, pointSprite);
    return (jint)rsProgramRasterCreate(con, pointSmooth, lineSmooth, pointSprite);
}

static void
nProgramRasterSetLineWidth(JNIEnv *_env, jobject _this, RsContext con, jint vpr, jfloat v)
{
    LOG_API("nProgramRasterSetLineWidth, con(%p), vpf(%p), value(%f)", con, (RsProgramRaster)vpr, v);
    rsProgramRasterSetLineWidth(con, (RsProgramRaster)vpr, v);
}

static void
nProgramRasterSetCullMode(JNIEnv *_env, jobject _this, RsContext con, jint vpr, jint v)
{
    LOG_API("nProgramRasterSetCullMode, con(%p), vpf(%p), value(%i)", con, (RsProgramRaster)vpr, v);
    rsProgramRasterSetCullMode(con, (RsProgramRaster)vpr, (RsCullMode)v);
    return (jint)rsProgramRasterCreate(con, pointSmooth, lineSmooth, pointSprite, lineWidth, (RsCullMode)cull);
}


@@ -1270,24 +1221,14 @@ static JNINativeMethod methods[] = {

{"rsnScriptCCreate",                 "(ILjava/lang/String;Ljava/lang/String;[BI)I",  (void*)nScriptCCreate },

{"rsnProgramStoreBegin",             "(III)V",                                (void*)nProgramStoreBegin },
{"rsnProgramStoreDepthFunc",         "(II)V",                                 (void*)nProgramStoreDepthFunc },
{"rsnProgramStoreDepthMask",         "(IZ)V",                                 (void*)nProgramStoreDepthMask },
{"rsnProgramStoreColorMask",         "(IZZZZ)V",                              (void*)nProgramStoreColorMask },
{"rsnProgramStoreBlendFunc",         "(III)V",                                (void*)nProgramStoreBlendFunc },
{"rsnProgramStoreDither",            "(IZ)V",                                 (void*)nProgramStoreDither },
{"rsnProgramStoreCreate",            "(I)I",                                  (void*)nProgramStoreCreate },
{"rsnProgramStoreCreate",            "(IZZZZZZIII)I",                         (void*)nProgramStoreCreate },

{"rsnProgramBindConstants",          "(IIII)V",                               (void*)nProgramBindConstants },
{"rsnProgramBindTexture",            "(IIII)V",                               (void*)nProgramBindTexture },
{"rsnProgramBindSampler",            "(IIII)V",                               (void*)nProgramBindSampler },

{"rsnProgramFragmentCreate",         "(ILjava/lang/String;[I)I",              (void*)nProgramFragmentCreate },

{"rsnProgramRasterCreate",           "(IZZZ)I",                               (void*)nProgramRasterCreate },
{"rsnProgramRasterSetLineWidth",     "(IIF)V",                                (void*)nProgramRasterSetLineWidth },
{"rsnProgramRasterSetCullMode",      "(III)V",                                (void*)nProgramRasterSetCullMode },

{"rsnProgramRasterCreate",           "(IZZZFI)I",                             (void*)nProgramRasterCreate },
{"rsnProgramVertexCreate",           "(ILjava/lang/String;[I)I",              (void*)nProgramVertexCreate },

{"rsnContextBindRootScript",         "(II)V",                                 (void*)nContextBindRootScript },
+1 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ LOCAL_SRC_FILES:= \
	rsVertexArray.cpp \
	driver/rsdBcc.cpp \
	driver/rsdCore.cpp \
	driver/rsdProgramRaster.cpp \
	driver/rsdProgramStore.cpp


Loading