Typepublic class Type extends BaseObj A Type describes the {@link android.renderscript.Element} and dimensions used for an {@link
android.renderscript.Allocation} or a parallel operation. Types are created through {@link
android.renderscript.Type.Builder}.
A Type always includes an {@link android.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.renderscript.Allocation} in a YUV format. The YUV formats
supported are {@link android.graphics.ImageFormat#YV12},
{@link android.graphics.ImageFormat#NV21}, and
{@link android.graphics.ImageFormat#YUV_420_888}
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 |
Methods Summary |
---|
void | calcElementCount()
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 static android.renderscript.Type | createX(RenderScript rs, Element e, int dimX)Utility function for creating basic 1D types. The type is
created without mipmaps enabled.
if (dimX < 1) {
throw new RSInvalidStateException("Dimension must be >= 1.");
}
long id = rs.nTypeCreate(e.getID(rs), dimX, 0, 0, false, false, 0);
Type t = new Type(id, rs);
t.mElement = e;
t.mDimX = dimX;
t.calcElementCount();
return t;
| public static android.renderscript.Type | createXY(RenderScript rs, Element e, int dimX, int dimY)Utility function for creating basic 2D types. The type is
created without mipmaps or cubemaps.
if ((dimX < 1) || (dimY < 1)) {
throw new RSInvalidStateException("Dimension must be >= 1.");
}
long id = rs.nTypeCreate(e.getID(rs), dimX, dimY, 0, false, false, 0);
Type t = new Type(id, rs);
t.mElement = e;
t.mDimX = dimX;
t.mDimY = dimY;
t.calcElementCount();
return t;
| public static android.renderscript.Type | createXYZ(RenderScript rs, Element e, int dimX, int dimY, int dimZ)Utility function for creating basic 3D types. The type is
created without mipmaps.
if ((dimX < 1) || (dimY < 1) || (dimZ < 1)) {
throw new RSInvalidStateException("Dimension must be >= 1.");
}
long id = rs.nTypeCreate(e.getID(rs), dimX, dimY, dimZ, false, false, 0);
Type t = new Type(id, rs);
t.mElement = e;
t.mDimX = dimX;
t.mDimY = dimY;
t.mDimZ = dimZ;
t.calcElementCount();
return t;
| public int | getCount()Return the total number of accessable cells in the Type.
return mElementCount;
| public Element | getElement()Return the element associated with this Type.
return mElement;
| public int | getX()Return the value of the X dimension.
return mDimX;
| public int | getY()Return the value of the Y dimension or 0 for a 1D allocation.
return mDimY;
| public int | getYuv()Get the YUV format
return mDimYuv;
| public int | getZ()Return the value of the Z dimension or 0 for a 1D or 2D allocation.
return mDimZ;
| public boolean | hasFaces()Return if the Type is a cube map.
return mDimFaces;
| public boolean | hasMipmaps()Return if the Type has a mipmap chain.
return mDimMipmaps;
| void | updateFromNative()
// We have 6 integer/long to obtain mDimX; mDimY; mDimZ;
// mDimLOD; mDimFaces; mElement;
long[] dataBuffer = new long[6];
mRS.nTypeGetNativeData(getID(mRS), dataBuffer);
mDimX = (int)dataBuffer[0];
mDimY = (int)dataBuffer[1];
mDimZ = (int)dataBuffer[2];
mDimMipmaps = dataBuffer[3] == 1 ? true : false;
mDimFaces = dataBuffer[4] == 1 ? true : false;
long elementID = dataBuffer[5];
if(elementID != 0) {
mElement = new Element(elementID, mRS);
mElement.updateFromNative();
}
calcElementCount();
|
|