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

Commit 12c08f2c authored by Alex Sakhartchouk's avatar Alex Sakhartchouk Committed by Android (Google) Code Review
Browse files

Merge "Adding anisotropic filtering and related samples."

parents 1eb98bdb f5b3510c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -388,6 +388,10 @@ public class RenderScript {
    synchronized void nSamplerSet(int param, int value) {
        rsnSamplerSet(mContext, param, value);
    }
    native void rsnSamplerSet2(int con, int param, float value);
    synchronized void nSamplerSet2(int param, float value) {
        rsnSamplerSet2(mContext, param, value);
    }
    native int  rsnSamplerCreate(int con);
    synchronized int nSamplerCreate() {
        return rsnSamplerCreate(mContext);
+11 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ public class Sampler extends BaseObj {
        Value mWrapS;
        Value mWrapT;
        Value mWrapR;
        float mAniso;

        public Builder(RenderScript rs) {
            mRS = rs;
@@ -138,6 +139,7 @@ public class Sampler extends BaseObj {
            mWrapS = Value.WRAP;
            mWrapT = Value.WRAP;
            mWrapR = Value.WRAP;
            mAniso = 1.0f;
        }

        public void setMin(Value v) {
@@ -182,6 +184,14 @@ public class Sampler extends BaseObj {
            }
        }

        public void setAnisotropy(float v) {
            if(v >= 0.0f) {
                mAniso = v;
            } else {
                throw new IllegalArgumentException("Invalid value");
            }
        }

        static synchronized Sampler internalCreate(RenderScript rs, Builder b) {
            rs.nSamplerBegin();
            rs.nSamplerSet(0, b.mMin.mID);
@@ -189,6 +199,7 @@ public class Sampler extends BaseObj {
            rs.nSamplerSet(2, b.mWrapS.mID);
            rs.nSamplerSet(3, b.mWrapT.mID);
            rs.nSamplerSet(4, b.mWrapR.mID);
            rs.nSamplerSet2(5, b.mAniso);
            int id = rs.nSamplerCreate();
            return new Sampler(id, rs);
        }
+8 −0
Original line number Diff line number Diff line
@@ -1096,6 +1096,13 @@ nSamplerSet(JNIEnv *_env, jobject _this, RsContext con, jint p, jint v)
    rsSamplerSet(con, (RsSamplerParam)p, (RsSamplerValue)v);
}

static void
nSamplerSet2(JNIEnv *_env, jobject _this, RsContext con, jint p, jfloat v)
{
    LOG_API("nSamplerSet2, con(%p), param(%i), value(%f)", con, p, v);
    rsSamplerSet2(con, (RsSamplerParam)p, v);
}

static jint
nSamplerCreate(JNIEnv *_env, jobject _this, RsContext con)
{
@@ -1303,6 +1310,7 @@ static JNINativeMethod methods[] = {

{"rsnSamplerBegin",                  "(I)V",                                  (void*)nSamplerBegin },
{"rsnSamplerSet",                    "(III)V",                                (void*)nSamplerSet },
{"rsnSamplerSet2",                   "(IIF)V",                                (void*)nSamplerSet2 },
{"rsnSamplerCreate",                 "(I)I",                                  (void*)nSamplerCreate },

{"rsnMeshCreate",                    "(III)I",                                (void*)nMeshCreate },
+2 −1
Original line number Diff line number Diff line
@@ -122,7 +122,8 @@ enum RsSamplerParam {
    RS_SAMPLER_MAG_FILTER,
    RS_SAMPLER_WRAP_S,
    RS_SAMPLER_WRAP_T,
    RS_SAMPLER_WRAP_R
    RS_SAMPLER_WRAP_R,
    RS_SAMPLER_ANISO
};

enum RsSamplerValue {
+3.64 KiB
Loading image diff...
Loading