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

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

Merge "adding getters to Sampler ProgramRaster, ProgramStore, Element. Element...

Merge "adding getters to Sampler ProgramRaster, ProgramStore, Element. Element adds ability to get subelement info. Tests for new stuff."
parents 5b6f2386 7d5f5e7c
Loading
Loading
Loading
Loading
+84 −3
Original line number Diff line number Diff line
@@ -46,13 +46,18 @@ public class Element extends BaseObj {
    Element[] mElements;
    String[] mElementNames;
    int[] mArraySizes;
    int[] mOffsetInBytes;

    DataType mType;
    DataKind mKind;
    boolean mNormalized;
    int mVectorSize;

    int getSizeBytes() {return mSize;}
    /**
    * @hide
    * @return element size in bytes
    */
    public int getSizeBytes() {return mSize;}


    /**
@@ -151,6 +156,77 @@ public class Element extends BaseObj {
        return false;
    }

    /**
    * @hide
    * @return number of sub-elements in this element
    */
    public int getSubElementCount() {
        if (mElements == null) {
            return 0;
        }
        return mElements.length;
    }

    /**
    * @hide
    * @param index index of the sub-element to return
    * @return sub-element in this element at given index
    */
    public Element getSubElement(int index) {
        if (mElements == null) {
            throw new RSIllegalArgumentException("Element contains no sub-elements");
        }
        if (index < 0 || index >= mElements.length) {
            throw new RSIllegalArgumentException("Illegal sub-element index");
        }
        return mElements[index];
    }

    /**
    * @hide
    * @param index index of the sub-element
    * @return sub-element in this element at given index
    */
    public String getSubElementName(int index) {
        if (mElements == null) {
            throw new RSIllegalArgumentException("Element contains no sub-elements");
        }
        if (index < 0 || index >= mElements.length) {
            throw new RSIllegalArgumentException("Illegal sub-element index");
        }
        return mElementNames[index];
    }

    /**
    * @hide
    * @param index index of the sub-element
    * @return array size of sub-element in this element at given index
    */
    public int getSubElementArraySize(int index) {
        if (mElements == null) {
            throw new RSIllegalArgumentException("Element contains no sub-elements");
        }
        if (index < 0 || index >= mElements.length) {
            throw new RSIllegalArgumentException("Illegal sub-element index");
        }
        return mArraySizes[index];
    }

    /**
    * @hide
    * @param index index of the sub-element
    * @return offset in bytes of sub-element in this element at given index
    */
    public int getSubElementOffsetBytes(int index) {
        if (mElements == null) {
            throw new RSIllegalArgumentException("Element contains no sub-elements");
        }
        if (index < 0 || index >= mElements.length) {
            throw new RSIllegalArgumentException("Illegal sub-element index");
        }
        return mOffsetInBytes[index];
    }

    /**
     * Utility function for returning an Element containing a single Boolean.
     *
@@ -602,7 +678,9 @@ public class Element extends BaseObj {
        mElements = e;
        mElementNames = n;
        mArraySizes = as;
        mOffsetInBytes = new int[mElements.length];
        for (int ct = 0; ct < mElements.length; ct++ ) {
            mOffsetInBytes[ct] = mSize;
            mSize += mElements[ct].mSize * mArraySizes[ct];
        }
    }
@@ -653,13 +731,16 @@ public class Element extends BaseObj {
        if(numSubElements > 0) {
            mElements = new Element[numSubElements];
            mElementNames = new String[numSubElements];
            mArraySizes = new int[numSubElements];
            mOffsetInBytes = new int[numSubElements];

            int[] subElementIds = new int[numSubElements];
            mRS.nElementGetSubElements(getID(), subElementIds, mElementNames);
            mRS.nElementGetSubElements(getID(), subElementIds, mElementNames, mArraySizes);
            for(int i = 0; i < numSubElements; i ++) {
                mElements[i] = new Element(subElementIds[i], mRS);
                mElements[i].updateFromNative();
                mSize += mElements[i].mSize;
                mOffsetInBytes[i] = mSize;
                mSize += mElements[i].mSize * mArraySizes[i];
            }
        }

+20 −8
Original line number Diff line number Diff line
@@ -37,23 +37,32 @@ public class ProgramRaster extends BaseObj {
        }
    }

    boolean mPointSmooth;
    boolean mLineSmooth;
    boolean mPointSprite;
    float mLineWidth;
    CullMode mCullMode;

    ProgramRaster(int id, RenderScript rs) {
        super(id, rs);

        mLineWidth = 1.0f;
        mPointSmooth = false;
        mLineSmooth = false;
        mPointSprite = false;

        mCullMode = CullMode.BACK;
    }

    /**
     * @hide
     * @return whether point sprites are enabled
     */
    public boolean getPointSpriteEnabled() {
        return mPointSprite;
    }

    /**
     * @hide
     * @return cull mode
     */
    public CullMode getCullMode() {
        return mCullMode;
    }

    public static ProgramRaster CULL_BACK(RenderScript rs) {
        if(rs.mProgramRaster_CULL_BACK == null) {
            ProgramRaster.Builder builder = new ProgramRaster.Builder(rs);
@@ -105,7 +114,10 @@ public class ProgramRaster extends BaseObj {
        public ProgramRaster create() {
            mRS.validate();
            int id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID);
            return new ProgramRaster(id, mRS);
            ProgramRaster programRaster = new ProgramRaster(id, mRS);
            programRaster.mPointSprite = mPointSprite;
            programRaster.mCullMode = mCullMode;
            return programRaster;
        }
    }

+92 −1
Original line number Diff line number Diff line
@@ -135,11 +135,92 @@ public class ProgramStore extends BaseObj {
        }
    }

    DepthFunc mDepthFunc;
    boolean mDepthMask;
    boolean mColorMaskR;
    boolean mColorMaskG;
    boolean mColorMaskB;
    boolean mColorMaskA;
    BlendSrcFunc mBlendSrc;
    BlendDstFunc mBlendDst;
    boolean mDither;

    ProgramStore(int id, RenderScript rs) {
        super(id, rs);
    }

    /**
    * @hide
    * @return depth function
    */
    public DepthFunc getDepthFunc() {
        return mDepthFunc;
    }

    /**
    * @hide
    * @return whether depth writes are enabled
    */
    public boolean getDepthMaskEnabled() {
        return mDepthMask;
    }

    /**
    * @hide
    * @return red color channel mask
    */
    public boolean getColorMaskREnabled() {
        return mColorMaskR;
    }

    /**
    * @hide
    * @return green color channel mask
    */
    public boolean getColorMaskGEnabled() {
        return mColorMaskG;
    }

    /**
    * @hide
    * @return blue color channel mask
    */
    public boolean getColorMaskBEnabled() {
        return mColorMaskB;
    }

    /**
    * @hide
    * @return alpha channel mask
    */
    public boolean getColorMaskAEnabled() {
        return mColorMaskA;
    }

    /**
    * @hide
    * @return source blend function
    */
    public BlendSrcFunc getBlendSrcFunc() {
        return mBlendSrc;
    }

    /**
    * @hide
    * @return destination blend function
    */
    public BlendDstFunc getBlendDstFunc() {
        return mBlendDst;
    }

    /**
    * @hide
    * @return whether dither is enabled
    */
    public boolean getDitherEnabled() {
        return mDither;
    }

    /**
    * Returns a pre-defined program store object with the following
    * characteristics:
@@ -340,7 +421,17 @@ public class ProgramStore extends BaseObj {
            int id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA,
                                             mDepthMask, mDither,
                                             mBlendSrc.mID, mBlendDst.mID, mDepthFunc.mID);
            return new ProgramStore(id, mRS);
            ProgramStore programStore = new ProgramStore(id, mRS);
            programStore.mDepthFunc = mDepthFunc;
            programStore.mDepthMask = mDepthMask;
            programStore.mColorMaskR = mColorMaskR;
            programStore.mColorMaskG = mColorMaskG;
            programStore.mColorMaskB = mColorMaskB;
            programStore.mColorMaskA = mColorMaskA;
            programStore.mBlendSrc = mBlendSrc;
            programStore.mBlendDst = mBlendDst;
            programStore.mDither = mDither;
            return programStore;
        }
    }

+4 −3
Original line number Diff line number Diff line
@@ -210,10 +210,11 @@ public class RenderScript {
        validate();
        rsnElementGetNativeData(mContext, id, elementData);
    }
    native void rsnElementGetSubElements(int con, int id, int[] IDs, String[] names);
    synchronized void nElementGetSubElements(int id, int[] IDs, String[] names) {
    native void rsnElementGetSubElements(int con, int id,
                                         int[] IDs, String[] names, int[] arraySizes);
    synchronized void nElementGetSubElements(int id, int[] IDs, String[] names, int[] arraySizes) {
        validate();
        rsnElementGetSubElements(mContext, id, IDs, names);
        rsnElementGetSubElements(mContext, id, IDs, names, arraySizes);
    }

    native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces);
+57 −2
Original line number Diff line number Diff line
@@ -47,10 +47,57 @@ public class Sampler extends BaseObj {
        }
    }

    Value mMin;
    Value mMag;
    Value mWrapS;
    Value mWrapT;
    Value mWrapR;
    float mAniso;

    Sampler(int id, RenderScript rs) {
        super(id, rs);
    }

    /**
     * @hide
     * @return minification setting for the sampler
     */
    public Value getMinification() {
        return mMin;
    }

    /**
     * @hide
     * @return magnification setting for the sampler
     */
    public Value getMagnification() {
        return mMag;
    }

    /**
     * @hide
     * @return S wrapping mode for the sampler
     */
    public Value getWrapS() {
        return mWrapS;
    }

    /**
     * @hide
     * @return T wrapping mode for the sampler
     */
    public Value getWrapT() {
        return mWrapT;
    }

    /**
     * @hide
     * @return anisotropy setting for the sampler
     */
    public float getAnisotropy() {
        return mAniso;
    }

    /**
     * Retrieve a sampler with min and mag set to nearest and wrap modes set to
     * clamp.
@@ -241,8 +288,16 @@ public class Sampler extends BaseObj {

        public Sampler create() {
            mRS.validate();
            int id = mRS.nSamplerCreate(mMag.mID, mMin.mID, mWrapS.mID, mWrapT.mID, mWrapR.mID, mAniso);
            return new Sampler(id, mRS);
            int id = mRS.nSamplerCreate(mMag.mID, mMin.mID, 
                                        mWrapS.mID, mWrapT.mID, mWrapR.mID, mAniso);
            Sampler sampler = new Sampler(id, mRS);
            sampler.mMin = mMin;
            sampler.mMag = mMag;
            sampler.mWrapS = mWrapS;
            sampler.mWrapT = mWrapT;
            sampler.mWrapR = mWrapR;
            sampler.mAniso = mAniso;
            return sampler;
        }
    }

Loading