public class

Element

extends Object
java.lang.Object
   ↳ android.renderscript.Element

Class Overview

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:

  • Single float value
  • 4 element float vector
  • single RGB-565 color
  • single unsigned int 16

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 determinied by the most basic primitive type. i.e. a float4 vector will be alligned 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.

Summary

Nested Classes
class Element.Builder Builder class for producing complex elements with matching field and name pairs. 
enum Element.DataKind The special interpretation of the data if required. 
enum Element.DataType DataType represents the basic type information for a basic element. 
Public Methods
static Element ALLOCATION(RenderScript rs)
static Element A_8(RenderScript rs)
static Element BOOLEAN(RenderScript rs)
Utility function for returning an Element containing a single Boolean.
static Element ELEMENT(RenderScript rs)
static Element F32(RenderScript rs)
static Element F32_2(RenderScript rs)
static Element F32_3(RenderScript rs)
static Element F32_4(RenderScript rs)
static Element F64(RenderScript rs)
static Element I16(RenderScript rs)
static Element I32(RenderScript rs)
static Element I64(RenderScript rs)
static Element I8(RenderScript rs)
Utility function for returning an Element containing a single SIGNED_8.
static Element MATRIX4X4(RenderScript rs)
static Element MATRIX_2X2(RenderScript rs)
static Element MATRIX_3X3(RenderScript rs)
static Element MATRIX_4X4(RenderScript rs)
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 RGBA_4444(RenderScript rs)
static Element RGBA_5551(RenderScript rs)
static Element RGBA_8888(RenderScript rs)
static Element RGB_565(RenderScript rs)
static Element RGB_888(RenderScript rs)
static Element SAMPLER(RenderScript rs)
static Element SCRIPT(RenderScript rs)
static Element TYPE(RenderScript rs)
static Element U16(RenderScript rs)
static Element U32(RenderScript rs)
static Element U64(RenderScript rs)
static Element U8(RenderScript rs)
Utility function for returning an Element containing a single UNSIGNED_8.
static Element U8_4(RenderScript rs)
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.
synchronized void destroy()
destroy disconnects the object from the native object effectivly rendering this java object dead.
boolean isComplex()
Return if a element is too complex for use as a data source for a Mesh or a Program.
void setName(String name)
setName assigns a name to an object.
Protected Methods
void finalize()
Called before the object's memory is reclaimed by the VM.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Element ALLOCATION (RenderScript rs)

Since: API Level 11

public static Element A_8 (RenderScript rs)

Since: API Level 11

public static Element BOOLEAN (RenderScript rs)

Since: API Level 11

Utility function for returning an Element containing a single Boolean.

Parameters
rs Context to which the element will belong.
Returns
  • Element

public static Element ELEMENT (RenderScript rs)

Since: API Level 11

public static Element F32 (RenderScript rs)

Since: API Level 11

public static Element F32_2 (RenderScript rs)

Since: API Level 11

public static Element F32_3 (RenderScript rs)

Since: API Level 11

public static Element F32_4 (RenderScript rs)

Since: API Level 11

public static Element F64 (RenderScript rs)

Since: API Level 11

public static Element I16 (RenderScript rs)

Since: API Level 11

public static Element I32 (RenderScript rs)

Since: API Level 11

public static Element I64 (RenderScript rs)

Since: API Level 11

public static Element I8 (RenderScript rs)

Since: API Level 11

Utility function for returning an Element containing a single SIGNED_8.

Parameters
rs Context to which the element will belong.
Returns
  • Element

public static Element MATRIX4X4 (RenderScript rs)

Since: API Level 11

public static Element MATRIX_2X2 (RenderScript rs)

Since: API Level 11

public static Element MATRIX_3X3 (RenderScript rs)

Since: API Level 11

public static Element MATRIX_4X4 (RenderScript rs)

Since: API Level 11

public static Element MESH (RenderScript rs)

Since: API Level 11

public static Element PROGRAM_FRAGMENT (RenderScript rs)

Since: API Level 11

public static Element PROGRAM_RASTER (RenderScript rs)

Since: API Level 11

public static Element PROGRAM_STORE (RenderScript rs)

Since: API Level 11

public static Element PROGRAM_VERTEX (RenderScript rs)

Since: API Level 11

public static Element RGBA_4444 (RenderScript rs)

Since: API Level 11

public static Element RGBA_5551 (RenderScript rs)

Since: API Level 11

public static Element RGBA_8888 (RenderScript rs)

Since: API Level 11

public static Element RGB_565 (RenderScript rs)

Since: API Level 11

public static Element RGB_888 (RenderScript rs)

Since: API Level 11

public static Element SAMPLER (RenderScript rs)

Since: API Level 11

public static Element SCRIPT (RenderScript rs)

Since: API Level 11

public static Element TYPE (RenderScript rs)

Since: API Level 11

public static Element U16 (RenderScript rs)

Since: API Level 11

public static Element U32 (RenderScript rs)

Since: API Level 11

public static Element U64 (RenderScript rs)

Since: API Level 11

public static Element U8 (RenderScript rs)

Since: API Level 11

Utility function for returning an Element containing a single UNSIGNED_8.

Parameters
rs Context to which the element will belong.
Returns
  • Element

public static Element U8_4 (RenderScript rs)

Since: API Level 11

public static Element createPixel (RenderScript rs, Element.DataType dt, Element.DataKind dk)

Since: API Level 11

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 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.
Returns
  • Element

public static Element createVector (RenderScript rs, Element.DataType dt, int size)

Since: API Level 11

Create a custom vector element of the specified DataType and vector size. DataKind will be set to USER.

Parameters
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.
Returns
  • Element

public synchronized void destroy ()

Since: API Level 11

destroy disconnects the object from the native object effectivly rendering this java object dead. The primary use is to force immediate cleanup of resources when its believed the GC will not respond quickly enough.

public boolean isComplex ()

Since: API Level 11

Return if a element is too complex for use as a data source for a Mesh or a Program.

Returns
  • boolean

public void setName (String name)

Since: API Level 11

setName assigns a name to an object. This object can later be looked up by this name. This name will also be retained if the object is written to an A3D file.

Parameters
name The name to assign to the object.

Protected Methods

protected void finalize ()

Since: API Level 11

Called before the object's memory is reclaimed by the VM. This can only happen once the garbage collector has detected that the object is no longer reachable by any thread of the running application.

The method can be used to free system resources or perform other cleanup before the object is garbage collected. The default implementation of the method is empty, which is also expected by the VM, but subclasses can override finalize() as required. Uncaught exceptions which are thrown during the execution of this method cause it to terminate immediately but are otherwise ignored.

Note that the VM does guarantee that finalize() is called at most once for any object, but it doesn't guarantee when (if at all) finalize() will be called. For example, object B's finalize() can delay the execution of object A's finalize() method and therefore it can delay the reclamation of A's memory. To be safe, use a ReferenceQueue, because it provides more control over the way the VM deals with references during garbage collection.

Throws
Throwable