Most visited

Recently visited

Added in API level 11

Element

public class Element
extends BaseObj

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


元素表示Allocation内的一个项目。 元素大致相当于RenderScript内核中的C类型。 元素可能是基本的或复杂的。 一些基本要素是

一个复杂的元素大致相当于一个C结构,并且包含许多基本元素或复杂元素。 从Java代码中,复杂元素包含代表特定数据结构的子元素和名称列表。 通过使用从特定脚本反映的ScriptField_structname类,RS脚本中使用的结构可用于Java代码。

基本要素由Element.DataTypeElement.DataKind DataType编码一个元素的C类型信息,而DataKind编码该元素应该如何解释Sampler 需要注意的是Allocation对象与DataKind USER不能用作输入为Sampler 一般来说,打算与Sampler一起使用的Allocation对象应使用位图派生的元素,例如RGBA_8888(RenderScript)android.renderscript

Developer Guides

有关创建使用RenderScript的应用程序的更多信息,请阅读 RenderScript开发人员指南。

Summary

Nested classes

class Element.Builder

生成器类用于生成具有匹配字段和名称对的复杂元素。

枚举 Element.DataKind

必要时对数据进行特殊解释。

枚举 Element.DataType

DataType表示基本元素的基本类型信息。

Public methods

static Element ALLOCATION(RenderScript rs)
static Element A_8(RenderScript rs)
static Element BOOLEAN(RenderScript rs)

用于返回包含单个布尔值的元素的实用程序函数。

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)

用于返回包含单个SIGNED_8的Element的实用程序函数。

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

此方法在API级别16中已弃用。使用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)
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 U16_2(RenderScript rs)
static Element U16_3(RenderScript rs)
static Element U16_4(RenderScript rs)
static Element U32(RenderScript rs)
static Element U32_2(RenderScript rs)
static Element U32_3(RenderScript rs)
static Element U32_4(RenderScript rs)
static Element U64(RenderScript rs)
static Element U64_2(RenderScript rs)
static Element U64_3(RenderScript rs)
static Element U64_4(RenderScript rs)
static Element U8(RenderScript rs)

用于返回包含单个UNSIGNED_8的Element的实用程序函数。

static Element U8_2(RenderScript rs)
static Element U8_3(RenderScript rs)
static Element U8_4(RenderScript rs)
static Element YUV(RenderScript rs)
static Element createPixel(RenderScript rs, Element.DataType dt, Element.DataKind dk)

创建一个新的像素元素类型。

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

创建指定DataType和矢量大小的自定义矢量元素。

int getBytesSize()
Element.DataKind getDataKind()
Element.DataType getDataType()
Element getSubElement(int index)

对于复杂的元素,这个函数将返回索引处的子元素

int getSubElementArraySize(int index)

对于复杂的元素,一些子元素可能是静态大小的数组。

int getSubElementCount()

元素可能很简单,例如int或float,或者具有多个子元素的结构,例如float,float2,float4的集合。

String getSubElementName(int index)

对于复杂的元素,该函数将返回索引处的子元素名称

int getSubElementOffsetBytes(int index)

该函数指定元素内子元素的位置

int getVectorSize()

返回矢量分量的数量。

boolean isCompatible(Element e)

检查当前元素是否与另一个元素兼容。

boolean isComplex()

如果元素太复杂,无法用作Mesh或程序的数据源,则返回。

Inherited methods

From class android.renderscript.BaseObj
From class java.lang.Object

Public methods

ALLOCATION

Added in API level 11
Element ALLOCATION (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

A_8

Added in API level 11
Element A_8 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

BOOLEAN

Added in API level 11
Element BOOLEAN (RenderScript rs)

用于返回包含单个布尔值的元素的实用程序函数。

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

ELEMENT

Added in API level 11
Element ELEMENT (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F16

Added in API level 23
Element F16 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F16_2

Added in API level 23
Element F16_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F16_3

Added in API level 23
Element F16_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F16_4

Added in API level 23
Element F16_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F32

Added in API level 11
Element F32 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F32_2

Added in API level 11
Element F32_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F32_3

Added in API level 11
Element F32_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F32_4

Added in API level 11
Element F32_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F64

Added in API level 11
Element F64 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F64_2

Added in API level 14
Element F64_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F64_3

Added in API level 14
Element F64_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

F64_4

Added in API level 14
Element F64_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

FONT

Added in API level 16
Element FONT (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I16

Added in API level 11
Element I16 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I16_2

Added in API level 14
Element I16_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I16_3

Added in API level 14
Element I16_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I16_4

Added in API level 14
Element I16_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I32

Added in API level 11
Element I32 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I32_2

Added in API level 14
Element I32_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I32_3

Added in API level 14
Element I32_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I32_4

Added in API level 14
Element I32_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I64

Added in API level 11
Element I64 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I64_2

Added in API level 14
Element I64_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I64_3

Added in API level 14
Element I64_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I64_4

Added in API level 14
Element I64_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I8

Added in API level 11
Element I8 (RenderScript rs)

用于返回包含单个SIGNED_8的Element的实用程序函数。

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

I8_2

Added in API level 14
Element I8_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I8_3

Added in API level 14
Element I8_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

I8_4

Added in API level 14
Element I8_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

MATRIX4X4

Added in API level 11
Element MATRIX4X4 (RenderScript rs)

此方法在API级别16中已被弃用。
使用MATRIX_4X4

Parameters
rs RenderScript
Returns
Element

MATRIX_2X2

Added in API level 11
Element MATRIX_2X2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

MATRIX_3X3

Added in API level 11
Element MATRIX_3X3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

MATRIX_4X4

Added in API level 11
Element MATRIX_4X4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

MESH

Added in API level 11
Element MESH (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

PROGRAM_FRAGMENT

Added in API level 11
Element PROGRAM_FRAGMENT (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

PROGRAM_RASTER

Added in API level 11
Element PROGRAM_RASTER (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

PROGRAM_STORE

Added in API level 11
Element PROGRAM_STORE (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

PROGRAM_VERTEX

Added in API level 11
Element PROGRAM_VERTEX (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

RGBA_4444

Added in API level 11
Element RGBA_4444 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

RGBA_5551

Added in API level 11
Element RGBA_5551 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

RGBA_8888

Added in API level 11
Element RGBA_8888 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

RGB_565

Added in API level 11
Element RGB_565 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

RGB_888

Added in API level 11
Element RGB_888 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

SAMPLER

Added in API level 11
Element SAMPLER (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

SCRIPT

Added in API level 11
Element SCRIPT (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

TYPE

Added in API level 11
Element TYPE (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U16

Added in API level 11
Element U16 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U16_2

Added in API level 14
Element U16_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U16_3

Added in API level 14
Element U16_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U16_4

Added in API level 14
Element U16_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U32

Added in API level 11
Element U32 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U32_2

Added in API level 14
Element U32_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U32_3

Added in API level 14
Element U32_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U32_4

Added in API level 14
Element U32_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U64

Added in API level 11
Element U64 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U64_2

Added in API level 14
Element U64_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U64_3

Added in API level 14
Element U64_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U64_4

Added in API level 14
Element U64_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U8

Added in API level 11
Element U8 (RenderScript rs)

用于返回包含单个UNSIGNED_8的Element的实用程序函数。

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

U8_2

Added in API level 14
Element U8_2 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U8_3

Added in API level 14
Element U8_3 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

U8_4

Added in API level 11
Element U8_4 (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

YUV

Added in API level 19
Element YUV (RenderScript rs)

Parameters
rs RenderScript
Returns
Element

createPixel

Added in API level 11
Element createPixel (RenderScript rs, 
                Element.DataType dt, 
                Element.DataKind dk)

创建一个新的像素元素类型。 必须提供匹配的DataType和DataKind。 DataType和DataKind必须包含相同数量的组件。 矢量大小将被设置为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.
Returns
Element Element

createVector

Added in API level 11
Element createVector (RenderScript rs, 
                Element.DataType dt, 
                int size)

创建指定DataType和矢量大小的自定义矢量元素。 DataKind将被设置为USER。 只支持原始类型(FLOAT_32,FLOAT_64,SIGNED_8,SIGNED_16,SIGNED_32,SIGNED_64,UNSIGNED_8,UNSIGNED_16,UNSIGNED_32,UNSIGNED_64,BOOLEAN)。

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

getBytesSize

Added in API level 16
int getBytesSize ()

Returns
int element size in bytes

getDataKind

Added in API level 16
Element.DataKind getDataKind ()

Returns
Element.DataKind element data kind

getDataType

Added in API level 16
Element.DataType getDataType ()

Returns
Element.DataType element data type

getSubElement

Added in API level 16
Element getSubElement (int index)

对于复杂的元素,这个函数将返回索引处的子元素

Parameters
index int: index of the sub-element to return
Returns
Element sub-element in this element at given index

getSubElementArraySize

Added in API level 16
int getSubElementArraySize (int index)

对于复杂的元素,一些子元素可能是静态大小的数组。 该函数将返回索引处子元素的数组大小

Parameters
index int: index of the sub-element
Returns
int array size of sub-element in this element at given index

getSubElementCount

Added in API level 16
int getSubElementCount ()

元素可能很简单,例如int或float,或者具有多个子元素的结构,例如float,float2,float4的集合。 这个函数返回零为简单的元素或否则子元素的数量。

Returns
int number of sub-elements in this element

getSubElementName

Added in API level 16
String getSubElementName (int index)

对于复杂的元素,该函数将返回索引处的子元素名称

Parameters
index int: index of the sub-element
Returns
String sub-element in this element at given index

getSubElementOffsetBytes

Added in API level 16
int getSubElementOffsetBytes (int index)

该函数指定元素内子元素的位置

Parameters
index int: index of the sub-element
Returns
int offset in bytes of sub-element in this element at given index

getVectorSize

Added in API level 16
int getVectorSize ()

返回矢量分量的数量。 2代表float2,4代表float4等。

Returns
int element vector size

isCompatible

Added in API level 14
boolean isCompatible (Element e)

检查当前元素是否与另一个元素兼容。 如果原始元素共享相同的基础大小和类型(即U8与A_8兼容),则它们是兼容的。 用户定义的元素必须相同才能兼容。 这要求对所有子元素进行严格的名称等价(除了结构等价)。

Parameters
e Element: The Element to check compatibility with.
Returns
boolean boolean true if the Elements are compatible, otherwise false.

isComplex

Added in API level 11
boolean isComplex ()

如果元素太复杂,无法用作Mesh或程序的数据源,则返回。

Returns
boolean boolean

Hooray!