public class Element extends BaseObj
The most basic data type. An element represents one cell of a memory allocation. Element is the basic data type of Renderscript. An element can be of two forms: Basic elements or Complex forms. Examples of basic elements are:
Complex elements contain a list of sub-elements and names that represents a structure of data. The fields can be accessed by name from a script or shader. The memory layout is defined and ordered. Data alignment is determined by the most basic primitive type. i.e. a float4 vector will be aligned to sizeof(float) and not sizeof(float4). The ordering of elements in memory will be the order in which they were added with each component aligned as necessary. No re-ordering will be done.
The primary source of elements are from scripts. A script that exports a bind point for a data structure generates a Renderscript element to represent the data exported by the script. The other common source of elements is from bitmap formats.
For more information about creating an application that uses Renderscript, read the Renderscript developer guide.
Modifier and Type | Class and Description |
---|---|
static class |
Element.Builder
Builder class for producing complex elements with matching field and name
pairs.
|
static class |
Element.DataKind
The special interpretation of the data if required.
|
static class |
Element.DataType
DataType represents the basic type information for a basic element.
|
Modifier and Type | Method and Description |
---|---|
static Element |
A_8(RenderScript rs) |
static Element |
ALLOCATION(RenderScript rs) |
static Element |
BOOLEAN(RenderScript rs)
Utility function for returning an Element containing a single Boolean.
|
static Element |
createPixel(RenderScript rs,
Element.DataType dt,
Element.DataKind dk)
Create a new pixel Element type.
|
static Element |
createVector(RenderScript rs,
Element.DataType dt,
int size)
Create a custom vector element of the specified DataType and vector size.
|
static Element |
ELEMENT(RenderScript rs) |
static Element |
F32_2(RenderScript rs) |
static Element |
F32_3(RenderScript rs) |
static Element |
F32_4(RenderScript rs) |
static Element |
F32(RenderScript rs) |
static Element |
F64_2(RenderScript rs) |
static Element |
F64_3(RenderScript rs) |
static Element |
F64_4(RenderScript rs) |
static Element |
F64(RenderScript rs) |
static Element |
FONT(RenderScript rs) |
int |
getBytesSize() |
Element.DataKind |
getDataKind() |
Element.DataType |
getDataType() |
Element |
getSubElement(int index)
For complex elements, this function will return the
sub-element at index
|
int |
getSubElementArraySize(int index)
For complex elements, some sub-elements could be statically
sized arrays.
|
int |
getSubElementCount()
Elements could be simple, such as an int or a float, or a
structure with multiple sub elements, such as a collection of
floats, float2, float4.
|
String |
getSubElementName(int index)
For complex elements, this function will return the
sub-element name at index
|
int |
getSubElementOffsetBytes(int index)
This function specifies the location of a sub-element within
the element
|
int |
getVectorSize()
Returns the number of vector components.
|
static Element |
I16_2(RenderScript rs) |
static Element |
I16_3(RenderScript rs) |
static Element |
I16_4(RenderScript rs) |
static Element |
I16(RenderScript rs) |
static Element |
I32_2(RenderScript rs) |
static Element |
I32_3(RenderScript rs) |
static Element |
I32_4(RenderScript rs) |
static Element |
I32(RenderScript rs) |
static Element |
I64_2(RenderScript rs) |
static Element |
I64_3(RenderScript rs) |
static Element |
I64_4(RenderScript rs) |
static Element |
I64(RenderScript rs) |
static Element |
I8_2(RenderScript rs) |
static Element |
I8_3(RenderScript rs) |
static Element |
I8_4(RenderScript rs) |
static Element |
I8(RenderScript rs)
Utility function for returning an Element containing a single SIGNED_8.
|
boolean |
isCompatible(Element e)
Check if the current Element is compatible with another Element.
|
boolean |
isComplex()
Return if a element is too complex for use as a data source for a Mesh or
a Program.
|
static Element |
MATRIX_2X2(RenderScript rs) |
static Element |
MATRIX_3X3(RenderScript rs) |
static Element |
MATRIX_4X4(RenderScript rs) |
static Element |
MATRIX4X4(RenderScript rs)
Deprecated.
use MATRIX_4X4
|
static Element |
MESH(RenderScript rs) |
static Element |
PROGRAM_FRAGMENT(RenderScript rs) |
static Element |
PROGRAM_RASTER(RenderScript rs) |
static Element |
PROGRAM_STORE(RenderScript rs) |
static Element |
PROGRAM_VERTEX(RenderScript rs) |
static Element |
RGB_565(RenderScript rs) |
static Element |
RGB_888(RenderScript rs) |
static Element |
RGBA_4444(RenderScript rs) |
static Element |
RGBA_5551(RenderScript rs) |
static Element |
RGBA_8888(RenderScript rs) |
static Element |
SAMPLER(RenderScript rs) |
static Element |
SCRIPT(RenderScript rs) |
static Element |
TYPE(RenderScript rs) |
static Element |
U16_2(RenderScript rs) |
static Element |
U16_3(RenderScript rs) |
static Element |
U16_4(RenderScript rs) |
static Element |
U16(RenderScript rs) |
static Element |
U32_2(RenderScript rs) |
static Element |
U32_3(RenderScript rs) |
static Element |
U32_4(RenderScript rs) |
static Element |
U32(RenderScript rs) |
static Element |
U64_2(RenderScript rs) |
static Element |
U64_3(RenderScript rs) |
static Element |
U64_4(RenderScript rs) |
static Element |
U64(RenderScript rs) |
static Element |
U8_2(RenderScript rs) |
static Element |
U8_3(RenderScript rs) |
static Element |
U8_4(RenderScript rs) |
static Element |
U8(RenderScript rs)
Utility function for returning an Element containing a single UNSIGNED_8.
|
public int getBytesSize()
public int getVectorSize()
public boolean isComplex()
public int getSubElementCount()
public Element getSubElement(int index)
index
- index of the sub-element to returnpublic String getSubElementName(int index)
index
- index of the sub-elementpublic int getSubElementArraySize(int index)
index
- index of the sub-elementpublic int getSubElementOffsetBytes(int index)
index
- index of the sub-elementpublic Element.DataType getDataType()
public Element.DataKind getDataKind()
public static Element BOOLEAN(RenderScript rs)
rs
- Context to which the element will belong.public static Element U8(RenderScript rs)
rs
- Context to which the element will belong.public static Element I8(RenderScript rs)
rs
- Context to which the element will belong.public static Element U16(RenderScript rs)
public static Element I16(RenderScript rs)
public static Element U32(RenderScript rs)
public static Element I32(RenderScript rs)
public static Element U64(RenderScript rs)
public static Element I64(RenderScript rs)
public static Element F32(RenderScript rs)
public static Element F64(RenderScript rs)
public static Element ELEMENT(RenderScript rs)
public static Element TYPE(RenderScript rs)
public static Element ALLOCATION(RenderScript rs)
public static Element SAMPLER(RenderScript rs)
public static Element SCRIPT(RenderScript rs)
public static Element MESH(RenderScript rs)
public static Element PROGRAM_FRAGMENT(RenderScript rs)
public static Element PROGRAM_VERTEX(RenderScript rs)
public static Element PROGRAM_RASTER(RenderScript rs)
public static Element PROGRAM_STORE(RenderScript rs)
public static Element FONT(RenderScript rs)
public static Element A_8(RenderScript rs)
public static Element RGB_565(RenderScript rs)
public static Element RGB_888(RenderScript rs)
public static Element RGBA_5551(RenderScript rs)
public static Element RGBA_4444(RenderScript rs)
public static Element RGBA_8888(RenderScript rs)
public static Element F32_2(RenderScript rs)
public static Element F32_3(RenderScript rs)
public static Element F32_4(RenderScript rs)
public static Element F64_2(RenderScript rs)
public static Element F64_3(RenderScript rs)
public static Element F64_4(RenderScript rs)
public static Element U8_2(RenderScript rs)
public static Element U8_3(RenderScript rs)
public static Element U8_4(RenderScript rs)
public static Element I8_2(RenderScript rs)
public static Element I8_3(RenderScript rs)
public static Element I8_4(RenderScript rs)
public static Element U16_2(RenderScript rs)
public static Element U16_3(RenderScript rs)
public static Element U16_4(RenderScript rs)
public static Element I16_2(RenderScript rs)
public static Element I16_3(RenderScript rs)
public static Element I16_4(RenderScript rs)
public static Element U32_2(RenderScript rs)
public static Element U32_3(RenderScript rs)
public static Element U32_4(RenderScript rs)
public static Element I32_2(RenderScript rs)
public static Element I32_3(RenderScript rs)
public static Element I32_4(RenderScript rs)
public static Element U64_2(RenderScript rs)
public static Element U64_3(RenderScript rs)
public static Element U64_4(RenderScript rs)
public static Element I64_2(RenderScript rs)
public static Element I64_3(RenderScript rs)
public static Element I64_4(RenderScript rs)
public static Element MATRIX_4X4(RenderScript rs)
public static Element MATRIX4X4(RenderScript rs)
public static Element MATRIX_3X3(RenderScript rs)
public static Element MATRIX_2X2(RenderScript rs)
public static Element createVector(RenderScript rs, Element.DataType dt, int size)
rs
- The context associated with the new Element.dt
- The DataType for the new Element.size
- Vector size for the new Element. Range 2-4 inclusive
supported.public static Element createPixel(RenderScript rs, Element.DataType dt, Element.DataKind dk)
rs
- The context associated with the new Element.dt
- The DataType for the new element.dk
- The DataKind to specify the mapping of each component in the
DataType.public boolean isCompatible(Element e)
e
- The Element to check compatibility with.