FileDocCategorySizeDatePackage
Type.javaAPI DocAndroid 5.1 API8870Thu Mar 12 22:22:56 GMT 2015android.support.v8.renderscript

Type

public class Type extends BaseObj

A Type describes the {@link android.support.v8.renderscript.Element} and dimensions used for an {@link android.support.v8.renderscript.Allocation} or a parallel operation. Types are created through {@link android.support.v8.renderscript.Type.Builder}.

A Type always includes an {@link android.support.v8.renderscript.Element} and an X dimension. A Type may be multidimensional, up to three dimensions. A nonzero value in the Y or Z dimensions indicates that the dimension is present. Note that a Type with only a given X dimension and a Type with the same X dimension but Y = 1 are not equivalent.

A Type also supports inclusion of level of detail (LOD) or cube map faces. LOD and cube map faces are booleans to indicate present or not present.

A Type also supports YUV format information to support an {@link android.support.v8.renderscript.Allocation} in a YUV format. The YUV formats supported are {@link android.graphics.ImageFormat#YV12} and {@link android.graphics.ImageFormat#NV21}.

Developer Guides

For more information about creating an application that uses RenderScript, read the RenderScript developer guide.

Fields Summary
int
mDimX
int
mDimY
int
mDimZ
boolean
mDimMipmaps
boolean
mDimFaces
int
mDimYuv
int
mElementCount
Element
mElement
Constructors Summary
Type(int id, RenderScript rs)

        super(id, rs);
    
Methods Summary
voidcalcElementCount()

        boolean hasLod = hasMipmaps();
        int x = getX();
        int y = getY();
        int z = getZ();
        int faces = 1;
        if (hasFaces()) {
            faces = 6;
        }
        if (x == 0) {
            x = 1;
        }
        if (y == 0) {
            y = 1;
        }
        if (z == 0) {
            z = 1;
        }

        int count = x * y * z * faces;

        while (hasLod && ((x > 1) || (y > 1) || (z > 1))) {
            if(x > 1) {
                x >>= 1;
            }
            if(y > 1) {
                y >>= 1;
            }
            if(z > 1) {
                z >>= 1;
            }

            count += x * y * z * faces;
        }
        mElementCount = count;
    
public intgetCount()
Return the total number of accessable cells in the Type.

return
int

        return mElementCount;
    
public ElementgetElement()
Return the element associated with this Type.

return
Element

        return mElement;
    
public intgetX()
Return the value of the X dimension.

return
int

        return mDimX;
    
public intgetY()
Return the value of the Y dimension or 0 for a 1D allocation.

return
int

        return mDimY;
    
public intgetYuv()
Get the YUV format

hide
return
int

        return mDimYuv;
    
public intgetZ()
Return the value of the Z dimension or 0 for a 1D or 2D allocation.

return
int

        return mDimZ;
    
public booleanhasFaces()
Return if the Type is a cube map.

return
boolean

        return mDimFaces;
    
public booleanhasMipmaps()
Return if the Type has a mipmap chain.

return
boolean

        return mDimMipmaps;