Element
open class Element : BaseObj
| kotlin.Any | ||
| ↳ | android.renderscript.BaseObj | |
| ↳ | android.renderscript.Element | |
An Element represents one item within an . An Element is roughly equivalent to a C type in a RenderScript kernel. Elements may be basic or complex. Some basic elements are
- A single float value (equivalent to a float in a kernel)
- A four-element float vector (equivalent to a float4 in a kernel)
- An unsigned 32-bit integer (equivalent to an unsigned int in a kernel)
- A single signed 8-bit integer (equivalent to a char in a kernel)
A complex element is roughly equivalent to a C struct and contains a number of basic or complex Elements. From Java code, a complex element contains a list of sub-elements and names that represents a particular data structure. Structs used in RS scripts are available to Java code by using the ScriptField_structname class that is reflected from a particular script.
Basic Elements are comprised of a and a . The DataType encodes C type information of an Element, while the DataKind encodes how that Element should be interpreted by a android.renderscript.Sampler. Note that objects with DataKind cannot be used as input for a android.renderscript.Sampler. In general, objects that are intended for use with a android.renderscript.Sampler should use bitmap-derived Elements such as android.renderscript.Element#RGBA_8888 or android.renderscript#Element.A_8.
Summary
Nested classes |
|
|---|---|
| open |
Builder class for producing complex elements with matching field and name pairs. |
|
The special interpretation of the data if required. |
|
|
DataType represents the basic type information for a basic element. |
|
Public methods |
|
|---|---|
| open static Element! |
ALLOCATION(rs: RenderScript!) |
| open static Element! |
A_8(rs: RenderScript!) |
| open static Element! |
BOOLEAN(rs: RenderScript!)Utility function for returning an Element containing a single Boolean. |
| open static Element! |
ELEMENT(rs: RenderScript!) |
| open static Element! |
F16(rs: RenderScript!) |
| open static Element! |
F16_2(rs: RenderScript!) |
| open static Element! |
F16_3(rs: RenderScript!) |
| open static Element! |
F16_4(rs: RenderScript!) |
| open static Element! |
F32(rs: RenderScript!) |
| open static Element! |
F32_2(rs: RenderScript!) |
| open static Element! |
F32_3(rs: RenderScript!) |
| open static Element! |
F32_4(rs: RenderScript!) |
| open static Element! |
F64(rs: RenderScript!) |
| open static Element! |
F64_2(rs: RenderScript!) |
| open static Element! |
F64_3(rs: RenderScript!) |
| open static Element! |
F64_4(rs: RenderScript!) |
| open static Element! |
FONT(rs: RenderScript!) |
| open static Element! |
I16(rs: RenderScript!) |
| open static Element! |
I16_2(rs: RenderScript!) |
| open static Element! |
I16_3(rs: RenderScript!) |
| open static Element! |
I16_4(rs: RenderScript!) |
| open static Element! |
I32(rs: RenderScript!) |
| open static Element! |
I32_2(rs: RenderScript!) |
| open static Element! |
I32_3(rs: RenderScript!) |
| open static Element! |
I32_4(rs: RenderScript!) |
| open static Element! |
I64(rs: RenderScript!) |
| open static Element! |
I64_2(rs: RenderScript!) |
| open static Element! |
I64_3(rs: RenderScript!) |
| open static Element! |
I64_4(rs: RenderScript!) |
| open static Element! |
I8(rs: RenderScript!)Utility function for returning an Element containing a single SIGNED_8. |
| open static Element! |
I8_2(rs: RenderScript!) |
| open static Element! |
I8_3(rs: RenderScript!) |
| open static Element! |
I8_4(rs: RenderScript!) |
| open static Element! |
MATRIX4X4(rs: RenderScript!) |
| open static Element! |
MATRIX_2X2(rs: RenderScript!) |
| open static Element! |
MATRIX_3X3(rs: RenderScript!) |
| open static Element! |
MATRIX_4X4(rs: RenderScript!) |
| open static Element! |
MESH(rs: RenderScript!) |
| open static Element! |
PROGRAM_FRAGMENT(rs: RenderScript!) |
| open static Element! |
PROGRAM_RASTER(rs: RenderScript!) |
| open static Element! |
PROGRAM_STORE(rs: RenderScript!) |
| open static Element! |
PROGRAM_VERTEX(rs: RenderScript!) |
| open static Element! |
RGBA_4444(rs: RenderScript!) |
| open static Element! |
RGBA_5551(rs: RenderScript!) |
| open static Element! |
RGBA_8888(rs: RenderScript!) |
| open static Element! |
RGB_565(rs: RenderScript!) |
| open static Element! |
RGB_888(rs: RenderScript!) |
| open static Element! |
SAMPLER(rs: RenderScript!) |
| open static Element! |
SCRIPT(rs: RenderScript!) |
| open static Element! |
TYPE(rs: RenderScript!) |
| open static Element! |
U16(rs: RenderScript!) |
| open static Element! |
U16_2(rs: RenderScript!) |
| open static Element! |
U16_3(rs: RenderScript!) |
| open static Element! |
U16_4(rs: RenderScript!) |
| open static Element! |
U32(rs: RenderScript!) |
| open static Element! |
U32_2(rs: RenderScript!) |
| open static Element! |
U32_3(rs: RenderScript!) |
| open static Element! |
U32_4(rs: RenderScript!) |
| open static Element! |
U64(rs: RenderScript!) |
| open static Element! |
U64_2(rs: RenderScript!) |
| open static Element! |
U64_3(rs: RenderScript!) |
| open static Element! |
U64_4(rs: RenderScript!) |
| open static Element! |
U8(rs: RenderScript!)Utility function for returning an Element containing a single UNSIGNED_8. |
| open static Element! |
U8_2(rs: RenderScript!) |
| open static Element! |
U8_3(rs: RenderScript!) |
| open static Element! |
U8_4(rs: RenderScript!) |
| open static Element! |
YUV(rs: RenderScript!) |
| open static Element! |
createPixel(rs: RenderScript!, dt: Element.DataType!, dk: Element.DataKind!)Create a new pixel Element type. |
| open static Element! |
createVector(rs: RenderScript!, dt: Element.DataType!, size: Int)Create a custom vector element of the specified DataType and vector size. |
| open Int | |
| open Element.DataKind! | |
| open Element.DataType! | |
| open Element! |
getSubElement(index: Int)For complex elements, this function will return the sub-element at index |
| open Int |
getSubElementArraySize(index: Int)For complex elements, some sub-elements could be statically sized arrays. |
| open Int |
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. |
| open String! |
getSubElementName(index: Int)For complex elements, this function will return the sub-element name at index |
| open Int |
getSubElementOffsetBytes(index: Int)This function specifies the location of a sub-element within the element |
| open Int |
Returns the number of vector components. |
| open Boolean |
isCompatible(e: Element!)Check if the current Element is compatible with another Element. |
| open Boolean |
Return if a element is too complex for use as a data source for a Mesh or a Program. |
Inherited functions |
|
|---|---|
Public methods
BOOLEAN
open static fun BOOLEAN(rs: RenderScript!): Element!
Utility function for returning an Element containing a single Boolean.
| Parameters | |
|---|---|
rs |
RenderScript!: Context to which the element will belong. |
| Return | |
|---|---|
Element! |
Element |
I8
open static fun I8(rs: RenderScript!): Element!
Utility function for returning an Element containing a single SIGNED_8.
| Parameters | |
|---|---|
rs |
RenderScript!: Context to which the element will belong. |
| Return | |
|---|---|
Element! |
Element |
PROGRAM_FRAGMENT
open static fun PROGRAM_FRAGMENT(rs: RenderScript!): Element!
U8
open static fun U8(rs: RenderScript!): Element!
Utility function for returning an Element containing a single UNSIGNED_8.
| Parameters | |
|---|---|
rs |
RenderScript!: Context to which the element will belong. |
| Return | |
|---|---|
Element! |
Element |
createPixel
open static fun createPixel(
rs: RenderScript!,
dt: Element.DataType!,
dk: Element.DataKind!
): Element!
Create a new pixel Element type. A matching DataType and DataKind must be provided. The DataType and DataKind must contain the same number of components. Vector size will be set to 1.
| Parameters | |
|---|---|
rs |
RenderScript!: The context associated with the new Element. |
dt |
Element.DataType!: The DataType for the new element. |
dk |
Element.DataKind!: The DataKind to specify the mapping of each component in the DataType. |
| Return | |
|---|---|
Element! |
Element |
createVector
open static fun createVector(
rs: RenderScript!,
dt: Element.DataType!,
size: Int
): Element!
Create a custom vector element of the specified DataType and vector size. DataKind will be set to USER. Only primitive types (FLOAT_32, FLOAT_64, SIGNED_8, SIGNED_16, SIGNED_32, SIGNED_64, UNSIGNED_8, UNSIGNED_16, UNSIGNED_32, UNSIGNED_64, BOOLEAN) are supported.
| Parameters | |
|---|---|
rs |
RenderScript!: The context associated with the new Element. |
dt |
Element.DataType!: The DataType for the new Element. |
size |
Int: Vector size for the new Element. Range 2-4 inclusive supported. |
| Return | |
|---|---|
Element! |
Element |
getDataKind
open fun getDataKind(): Element.DataKind!
| Return | |
|---|---|
Element.DataKind! |
element data kind |
getDataType
open fun getDataType(): Element.DataType!
| Return | |
|---|---|
Element.DataType! |
element data type |
getSubElement
open fun getSubElement(index: Int): Element!
For complex elements, this function will return the sub-element at index
| Parameters | |
|---|---|
index |
Int: index of the sub-element to return |
| Return | |
|---|---|
Element! |
sub-element in this element at given index |
getSubElementArraySize
open fun getSubElementArraySize(index: Int): Int
For complex elements, some sub-elements could be statically sized arrays. This function will return the array size for sub-element at index
| Parameters | |
|---|---|
index |
Int: index of the sub-element |
| Return | |
|---|---|
Int |
array size of sub-element in this element at given index |
getSubElementCount
open fun getSubElementCount(): Int
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. This function returns zero for simple elements or the number of sub-elements otherwise.
| Return | |
|---|---|
Int |
number of sub-elements in this element |
getSubElementName
open fun getSubElementName(index: Int): String!
For complex elements, this function will return the sub-element name at index
| Parameters | |
|---|---|
index |
Int: index of the sub-element |
| Return | |
|---|---|
String! |
sub-element in this element at given index |
getSubElementOffsetBytes
open fun getSubElementOffsetBytes(index: Int): Int
This function specifies the location of a sub-element within the element
| Parameters | |
|---|---|
index |
Int: index of the sub-element |
| Return | |
|---|---|
Int |
offset in bytes of sub-element in this element at given index |
getVectorSize
open fun getVectorSize(): Int
Returns the number of vector components. 2 for float2, 4 for float4, etc.
| Return | |
|---|---|
Int |
element vector size |
isCompatible
open fun isCompatible(e: Element!): Boolean
Check if the current Element is compatible with another Element. Primitive Elements are compatible if they share the same underlying size and type (i.e. U8 is compatible with A_8). User-defined Elements must be equal in order to be compatible. This requires strict name equivalence for all sub-Elements (in addition to structural equivalence).
| Parameters | |
|---|---|
e |
Element!: The Element to check compatibility with. |
| Return | |
|---|---|
Boolean |
boolean true if the Elements are compatible, otherwise false. |
isComplex
open fun isComplex(): Boolean
Return if a element is too complex for use as a data source for a Mesh or a Program.
| Return | |
|---|---|
Boolean |
boolean |