java.lang.Object | ||
↳ | android.support.v8.renderscript.BaseObj | |
↳ | android.support.v8.renderscript.Element |
An Element represents one item within an Allocation
. An Element is roughly
equivalent to a C type in a RenderScript kernel. Elements may be basic or
complex. Some basic elements are
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 Element.DataType
and a Element.DataKind
. The DataType encodes C
type information of an Element, while the DataKind encodes how that Element
should be interpreted by a Sampler
.
Note that Allocation
objects with
DataKind USER
cannot
be used as input for a Sampler
. In
general, Allocation
objects that are
intended for use with a Sampler
should use bitmap-derived Elements such as
RGBA_8888(RenderScript)
or android.support.v8.renderscript
.
For more information about creating an application that uses RenderScript, read the RenderScript developer guide.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Element.Builder | Builder class for producing complex elements with matching field and name pairs. | ||||||||||
Element.DataKind | The special interpretation of the data if required. | ||||||||||
Element.DataType | DataType represents the basic type information for a basic element. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Utility function for returning an Element containing a single Boolean.
| |||||||||||
Utility function for returning an Element containing a single SIGNED_8.
| |||||||||||
Utility function for returning an Element containing a single UNSIGNED_8.
| |||||||||||
Create a new pixel Element type.
| |||||||||||
Create a custom vector element of the specified DataType and vector size.
| |||||||||||
For complex elements, this function will return the
sub-element at index
| |||||||||||
For complex elements, some sub-elements could be statically
sized arrays.
| |||||||||||
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.
| |||||||||||
For complex elements, this function will return the
sub-element name at index
| |||||||||||
This function specifies the location of a sub-element within
the element
| |||||||||||
Returns the number of vector components.
| |||||||||||
Check if the current Element is compatible with another Element.
| |||||||||||
Return if a element is too complex for use as a data source for a Mesh or
a Program.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.support.v8.renderscript.BaseObj
| |||||||||||
From class
java.lang.Object
|
Utility function for returning an Element containing a single Boolean.
rs | Context to which the element will belong. |
---|
Utility function for returning an Element containing a single SIGNED_8.
rs | Context to which the element will belong. |
---|
Utility function for returning an Element containing a single UNSIGNED_8.
rs | Context to which the element will belong. |
---|
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.
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. |
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.
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. |
For complex elements, this function will return the sub-element at index
index | index of the sub-element to return |
---|
For complex elements, some sub-elements could be statically sized arrays. This function will return the array size for sub-element at index
index | index of the sub-element |
---|
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.
For complex elements, this function will return the sub-element name at index
index | index of the sub-element |
---|
This function specifies the location of a sub-element within the element
index | index of the sub-element |
---|
Returns the number of vector components. 2 for float2, 4 for float4, etc.
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).
e | The Element to check compatibility with. |
---|
Return if a element is too complex for use as a data source for a Mesh or a Program.