Added in API level 11
Deprecated in API level 31

Element


public class Element
extends BaseObj

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


This class was deprecated in API level 31.
Renderscript has been deprecated in API level 31. Please refer to the migration guide for the proposed alternatives.

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 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 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 Element.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 A_8(RenderScript).

Developer Guides

For more information about creating an application that uses RenderScript, read the RenderScript developer guide.

Summary

Nested classes

class Element.Builder

Builder class for producing complex elements with matching field and name pairs. 

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 F16(RenderScript rs)
static Element F16_2(RenderScript rs)
static Element F16_3(RenderScript rs)
static Element F16_4(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 F64_2(RenderScript rs)
static Element F64_3(RenderScript rs)
static Element F64_4(RenderScript rs)
static Element FONT(RenderScript rs)
static Element I16(RenderScript rs)
static Element I16_2(RenderScript rs)
static Element I16_3(RenderScript rs)
static Element I16_4(RenderScript rs)
static Element I32(RenderScript rs)
static Element I32_2(RenderScript rs)
static Element I32_3(RenderScript rs)
static Element I32_4(RenderScript rs)
static Element I64(RenderScript rs)
static Element I64_2(RenderScript rs)
static Element I64_3(RenderScript rs)
static Element I64_4(RenderScript rs)
static Element I8(RenderScript rs)

Utility function for returning an Element containing a single SIGNED_8.

static Element I8_2(RenderScript rs)
static Element I8_3(RenderScript rs)
static Element I8_4(RenderScript rs)
static Element MATRIX4X4(RenderScript rs)

This method was deprecated in API level 16. use MATRIX_4X4

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)