java.lang.Object | ||
↳ | android.renderscript.BaseObj | |
↳ | android.renderscript.Allocation |
Known Direct Subclasses |
Memory allocation class for renderscript. An allocation combines a
Type
with the memory to provide storage for user data and objects.
This implies that all memory in Renderscript is typed.
Allocations are the primary way data moves into and out of scripts. Memory is user synchronized and it's possible for allocations to exist in multiple memory spaces concurrently. Currently those spaces are:
For example, when creating a allocation for a texture, the user can specify its memory spaces as both script and textures. This means that it can both be used as script binding and as a GPU texture for rendering. To maintain synchronization if a script modifies an allocation used by other targets it must call a synchronizing function to push the updates to the memory, otherwise the results are undefined.
By default, Android system side updates are always applied to the script accessable
memory. If this is not present, they are then applied to the various HW
memory types. A syncAll()
call is necessary after the script data is updated to
keep the other memory spaces in sync.
Allocation data is uploaded in one of two primary ways. For simple arrays there are copyFrom() functions that take an array from the control code and copy it to the slave memory store. Both type checked and unchecked copies are provided. The unchecked variants exist to allow apps to copy over arrays of structures from a control language that does not support structures.
For more information about creating an application that uses Renderscript, read the Renderscript developer guide.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Allocation.MipmapControl | Controls mipmap behavior when using the bitmap creation and update functions. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | USAGE_GRAPHICS_CONSTANTS | GRAPHICS_CONSTANTS The allocation will be used as the source of shader constants by one or more programs. | |||||||||
int | USAGE_GRAPHICS_RENDER_TARGET | USAGE_GRAPHICS_RENDER_TARGET The allocation will be used as a target for offscreen rendering | |||||||||
int | USAGE_GRAPHICS_TEXTURE | GRAPHICS_TEXTURE The allocation will be used as a texture source by one or more graphics programs. | |||||||||
int | USAGE_GRAPHICS_VERTEX | GRAPHICS_VERTEX The allocation will be used as a graphics mesh. | |||||||||
int | USAGE_IO_INPUT | USAGE_IO_INPUT The allocation will be used as SurfaceTexture consumer. | |||||||||
int | USAGE_IO_OUTPUT | USAGE_IO_OUTPUT The allocation will be used as a SurfaceTexture producer. | |||||||||
int | USAGE_SCRIPT | The usage of the allocation. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Copy part of an allocation from an array.
| |||||||||||
Copy part of an allocation from another allocation.
| |||||||||||
Copy part of an allocation from an array.
| |||||||||||
Copy part of an allocation from an array.
| |||||||||||
Copy part of an allocation from an array.
| |||||||||||
Copy part of an allocation from an array.
| |||||||||||
Copy part of an allocation from an array.
| |||||||||||
Copy part of an allocation from an array.
| |||||||||||
Copy part of an allocation from an array.
| |||||||||||
Copy a rectangular region from the array into the allocation.
| |||||||||||
Copy a bitmap into an allocation.
| |||||||||||
Copy a rectangular region into the allocation from another
allocation.
| |||||||||||
Copy an array of RS objects to the allocation.
| |||||||||||
Copy an allocation from an array.
| |||||||||||
Copy an allocation from an array.
| |||||||||||
Copy an allocation from an array.
| |||||||||||
Copy an allocation from a bitmap.
| |||||||||||
Copy an allocation from an array.
| |||||||||||
Copy an allocation from an array.
| |||||||||||
Copy an allocation from an array.
| |||||||||||
Copy an allocation from an array.
| |||||||||||
Copy an allocation from an array.
| |||||||||||
Copy from the Allocation into a byte array.
| |||||||||||
Copy from the Allocation into a int array.
| |||||||||||
Copy from the Allocation into a float array.
| |||||||||||
Copy from the Allocation into a short array.
| |||||||||||
Copy from the Allocation into a Bitmap.
| |||||||||||
Creates a cubemap allocation from a bitmap containing the
horizontal list of cube faces.
| |||||||||||
Creates a non-mipmapped cubemap allocation for use as a
graphics texture from a bitmap containing the horizontal list
of cube faces.
| |||||||||||
Creates a non-mipmapped cubemap allocation for use as a
graphics texture from 6 bitmaps containing
the cube faces.
| |||||||||||
Creates a cubemap allocation from 6 bitmaps containing
the cube faces.
| |||||||||||
Creates a non-mipmapped renderscript allocation to use as a
graphics texture
| |||||||||||
Creates a renderscript allocation from a bitmap
| |||||||||||
Creates a non-mipmapped renderscript allocation to use as a
graphics texture from the bitmap referenced by resource id
| |||||||||||
Creates a renderscript allocation from the bitmap referenced
by resource id
| |||||||||||
Creates a renderscript allocation containing string data
encoded in UTF-8 format
| |||||||||||
Creates a renderscript allocation with a specified number of
given elements
| |||||||||||
Creates a renderscript allocation with a specified number of
given elements
| |||||||||||
Creates a renderscript allocation for use by the script with
the size specified by the type and no mipmaps generated by
default
| |||||||||||
Creates a renderscript allocation with the size specified by
the type and no mipmaps generated by default
| |||||||||||
Generate a mipmap chain.
| |||||||||||
Get the size of the Allocation in bytes.
| |||||||||||
Get the element of the type of the Allocation.
| |||||||||||
For allocations used with io operations, returns the handle
onto a raw buffer that is being managed by the screen
compositor.
| |||||||||||
Get the type of the Allocation.
| |||||||||||
Get the usage flags of the Allocation.
| |||||||||||
Receive the latest input into the Allocation.
| |||||||||||
Send a buffer to the output stream.
| |||||||||||
Resize a 1D allocation.
| |||||||||||
This is only intended to be used by auto-generate code reflected from the
renderscript script files.
| |||||||||||
This is only intended to be used by auto-generate code reflected from the
renderscript script files.
| |||||||||||
Associate a surface for io output with this allocation
| |||||||||||
Propagate changes from one usage of the allocation to the
remaining usages of the allocation.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.renderscript.BaseObj
| |||||||||||
From class
java.lang.Object
|
GRAPHICS_CONSTANTS The allocation will be used as the source of shader constants by one or more programs.
USAGE_GRAPHICS_RENDER_TARGET The allocation will be used as a target for offscreen rendering
GRAPHICS_TEXTURE The allocation will be used as a texture source by one or more graphics programs.
GRAPHICS_VERTEX The allocation will be used as a graphics mesh.
USAGE_IO_INPUT The allocation will be used as SurfaceTexture consumer. This usage will cause the allocation to be created read only.
USAGE_IO_OUTPUT The allocation will be used as a SurfaceTexture producer. The dimensions and format of the SurfaceTexture will be forced to those of the allocation.
The usage of the allocation. These signal to renderscript where to place the allocation in memory. SCRIPT The allocation will be bound to and accessed by scripts.
Copy part of an allocation from an array. This variant is type checked and will generate exceptions if the Allocation type is not a 32 bit float type.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
d | the source data array. |
Copy part of an allocation from another allocation.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
data | the source data allocation. |
dataOff | off The offset of the first element in data to be copied. |
Copy part of an allocation from an array. This variant is type checked and will generate exceptions if the Allocation type is not a 16 bit integer type.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
d | the source data array |
Copy part of an allocation from an array. This variant is type checked and will generate exceptions if the Allocation type is not a 32 bit integer type.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
d | the source data array |
Copy part of an allocation from an array. This variant is type checked and will generate exceptions if the Allocation type is not a 8 bit integer type.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
d | the source data array |
Copy part of an allocation from an array. This variant is not type checked which allows an application to fill in structured data from an array.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
d | the source data array |
Copy part of an allocation from an array. This variant is not type checked which allows an application to fill in structured data from an array.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
d | the source data array |
Copy part of an allocation from an array. This variant is not type checked which allows an application to fill in structured data from an array.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
d | the source data array |
Copy part of an allocation from an array. This variant is not type checked which allows an application to fill in structured data from an array.
off | The offset of the first element to be copied. |
---|---|
count | The number of elements to be copied. |
d | the source data array |
Copy a rectangular region from the array into the allocation. The incoming array is assumed to be tightly packed.
xoff | X offset of the region to update |
---|---|
yoff | Y offset of the region to update |
w | Width of the incoming region to update |
h | Height of the incoming region to update |
data | to be placed into the allocation |
Copy a bitmap into an allocation. The height and width of the update will use the height and width of the incoming bitmap.
xoff | X offset of the region to update |
---|---|
yoff | Y offset of the region to update |
data | the bitmap to be copied |
Copy a rectangular region into the allocation from another allocation.
xoff | X offset of the region to update. |
---|---|
yoff | Y offset of the region to update. |
w | Width of the incoming region to update. |
h | Height of the incoming region to update. |
data | source allocation. |
dataXoff | X offset in data of the region to update. |
dataYoff | Y offset in data of the region to update. |
Copy an array of RS objects to the allocation.
d | Source array. |
---|
Copy an allocation from an array. This variant is type checked and will generate exceptions if the Allocation type is not a 8 bit integer type.
d | the source data array |
---|
Copy an allocation from an array. This variant is type checked and will generate exceptions if the Allocation type is not a 32 bit integer type.
d | the source data array |
---|
Copy an allocation from an array. This variant is type checked and will generate exceptions if the Allocation type is not a 32 bit float type.
d | the source data array |
---|
Copy an allocation from a bitmap. The height, width, and format of the bitmap must match the existing allocation.
b | the source bitmap |
---|
Copy an allocation from an array. This variant is type checked and will generate exceptions if the Allocation type is not a 16 bit integer type.
d | the source data array |
---|
Copy an allocation from an array. This variant is not type checked which allows an application to fill in structured data from an array.
d | the source data array |
---|
Copy an allocation from an array. This variant is not type checked which allows an application to fill in structured data from an array.
d | the source data array |
---|
Copy an allocation from an array. This variant is not type checked which allows an application to fill in structured data from an array.
d | the source data array |
---|
Copy an allocation from an array. This variant is not type checked which allows an application to fill in structured data from an array.
d | the source data array |
---|
Copy from the Allocation into a byte array. The array must be at least as large as the Allocation. The allocation must be of an 8 bit elemental type.
d | The array to be set from the Allocation. |
---|
Copy from the Allocation into a int array. The array must be at least as large as the Allocation. The allocation must be of an 32 bit elemental type.
d | The array to be set from the Allocation. |
---|
Copy from the Allocation into a float array. The array must be at least as large as the Allocation. The allocation must be of an 32 bit float elemental type.
d | The array to be set from the Allocation. |
---|
Copy from the Allocation into a short array. The array must be at least as large as the Allocation. The allocation must be of an 16 bit elemental type.
d | The array to be set from the Allocation. |
---|
Copy from the Allocation into a Bitmap. The bitmap must match the dimensions of the Allocation.
b | The bitmap to be set from the Allocation. |
---|
Creates a cubemap allocation from a bitmap containing the horizontal list of cube faces. Each individual face must be the same size and power of 2
rs | Context to which the allocation will belong. |
---|---|
b | bitmap with cubemap faces layed out in the following format: right, left, top, bottom, front, back |
mips | specifies desired mipmap behaviour for the cubemap |
usage | bit field specifying how the cubemap is utilized |
Creates a non-mipmapped cubemap allocation for use as a graphics texture from a bitmap containing the horizontal list of cube faces. Each individual face must be the same size and power of 2
rs | Context to which the allocation will belong. |
---|---|
b | bitmap with cubemap faces layed out in the following format: right, left, top, bottom, front, back |
Creates a non-mipmapped cubemap allocation for use as a graphics texture from 6 bitmaps containing the cube faces. All the faces must be the same size and power of 2
rs | Context to which the allocation will belong. |
---|---|
xpos | cubemap face in the positive x direction |
xneg | cubemap face in the negative x direction |
ypos | cubemap face in the positive y direction |
yneg | cubemap face in the negative y direction |
zpos | cubemap face in the positive z direction |
zneg | cubemap face in the negative z direction |
Creates a cubemap allocation from 6 bitmaps containing the cube faces. All the faces must be the same size and power of 2
rs | Context to which the allocation will belong. |
---|---|
xpos | cubemap face in the positive x direction |
xneg | cubemap face in the negative x direction |
ypos | cubemap face in the positive y direction |
yneg | cubemap face in the negative y direction |
zpos | cubemap face in the positive z direction |
zneg | cubemap face in the negative z direction |
mips | specifies desired mipmap behaviour for the cubemap |
usage | bit field specifying how the cubemap is utilized |
Creates a non-mipmapped renderscript allocation to use as a graphics texture
rs | Context to which the allocation will belong. |
---|---|
b | bitmap source for the allocation data |
Creates a renderscript allocation from a bitmap
rs | Context to which the allocation will belong. |
---|---|
b | bitmap source for the allocation data |
mips | specifies desired mipmap behaviour for the allocation |
usage | bit field specifying how the allocation is utilized |
Creates a non-mipmapped renderscript allocation to use as a graphics texture from the bitmap referenced by resource id
rs | Context to which the allocation will belong. |
---|---|
res | application resources |
id | resource id to load the data from |
Creates a renderscript allocation from the bitmap referenced by resource id
rs | Context to which the allocation will belong. |
---|---|
res | application resources |
id | resource id to load the data from |
mips | specifies desired mipmap behaviour for the allocation |
usage | bit field specifying how the allocation is utilized |
Creates a renderscript allocation containing string data encoded in UTF-8 format
rs | Context to which the allocation will belong. |
---|---|
str | string to create the allocation from |
usage | bit field specifying how the allocaiton is utilized |
Creates a renderscript allocation with a specified number of given elements
rs | Context to which the allocation will belong. |
---|---|
e | describes what each element of an allocation is |
count | specifies the number of element in the allocation |
Creates a renderscript allocation with a specified number of given elements
rs | Context to which the allocation will belong. |
---|---|
e | describes what each element of an allocation is |
count | specifies the number of element in the allocation |
usage | bit field specifying how the allocation is utilized |
Creates a renderscript allocation for use by the script with the size specified by the type and no mipmaps generated by default
rs | Context to which the allocation will belong. |
---|---|
type | renderscript type describing data layout |
Creates a renderscript allocation with the size specified by the type and no mipmaps generated by default
rs | Context to which the allocation will belong. |
---|---|
type | renderscript type describing data layout |
usage | bit field specifying how the allocation is utilized |
type | renderscript type describing data layout |
---|---|
mips | specifies desired mipmap behaviour for the allocation |
usage | bit field specifying how the allocation is utilized |
Generate a mipmap chain. Requires the type of the allocation include mipmaps. This function will generate a complete set of mipmaps from the top level lod and place them into the script memoryspace. If the allocation is also using other memory spaces a followup sync will be required.
Get the size of the Allocation in bytes.
Get the element of the type of the Allocation.
For allocations used with io operations, returns the handle onto a raw buffer that is being managed by the screen compositor.
Get the usage flags of the Allocation.
Send a buffer to the output stream. The contents of the Allocation will be undefined after this operation.
Resize a 1D allocation. The contents of the allocation are preserved. If new elements are allocated objects are created with null contents and the new region is otherwise undefined. If the new region is smaller the references of any objects outside the new region will be released. A new type will be created with the new dimension.
dimX | The new size of the allocation. |
---|
This is only intended to be used by auto-generate code reflected from the renderscript script files.
This is only intended to be used by auto-generate code reflected from the renderscript script files.
Associate a surface for io output with this allocation
sur | Surface to associate with allocation |
---|
Propagate changes from one usage of the allocation to the remaining usages of the allocation.