| java.lang.Object | |
| ↳ | 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.
| 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_TEXTURE | GRAPHICS_TEXTURE The allcation will be used as a texture source by one or more graphcics programs. | |||||||||
| int | USAGE_GRAPHICS_VERTEX | GRAPHICS_VERTEX The allocation will be used as a graphics mesh. | |||||||||
| int | USAGE_SCRIPT | The usage of the allocation. | |||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
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 part of an allocation from an array.
| |||||||||||
Copy a rectanglular region from the array into the
allocation.
| |||||||||||
Copy a bitmap into an 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.
| |||||||||||
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
| |||||||||||
destroy disconnects the object from the native object effectivly
rendering this java object dead.
| |||||||||||
Generate a mipmap chain.
| |||||||||||
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.
| |||||||||||
setName assigns a name to an object.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Called before the object's memory is reclaimed by the VM.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
GRAPHICS_CONSTANTS The allocation will be used as the source of shader constants by one or more programs.
GRAPHICS_TEXTURE The allcation will be used as a texture source by one or more graphcics programs.
GRAPHICS_VERTEX The allocation will be used as a graphics mesh.
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 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 rectanglular 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 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 |
|---|
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 |
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.
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.
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.
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.
| name | The name to assign to the object. |
|---|
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.
| Throwable |
|---|