Most visited

Recently visited

Added in API level 11

Allocation

public class Allocation
extends BaseObj

java.lang.Object
   ↳ android.renderscript.BaseObj
     ↳ android.renderscript.Allocation
Known Direct Subclasses


This class provides the primary method through which data is passed to and from RenderScript kernels. An Allocation provides the backing store for a given Type.

An Allocation also contains a set of usage flags that denote how the Allocation could be used. For example, an Allocation may have usage flags specifying that it can be used from a script as well as input to a Sampler. A developer must synchronize across these different usages using syncAll(int) in order to ensure that different users of the Allocation have a consistent view of memory. For example, in the case where an Allocation is used as the output of one kernel and as Sampler input in a later kernel, a developer must call syncAll(Allocation.USAGE_SCRIPT) prior to launching the second kernel to ensure correctness.

An Allocation can be populated with the copyFrom(Bitmap) routines. For more complex Element types, the copyFromUnchecked(byte[]) methods can be used to copy from byte arrays or similar constructs.

Developer Guides

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

Summary

Nested classes

enum Allocation.MipmapControl

Controls mipmap behavior when using the bitmap creation and update functions. 

interface Allocation.OnBufferAvailableListener

Interface to handle notification when new buffers are available via USAGE_IO_INPUT

Constants

int USAGE_GRAPHICS_CONSTANTS

The Allocation will be used as the source of shader constants by one or more programs.

int USAGE_GRAPHICS_RENDER_TARGET

The Allocation will be used as a target for offscreen rendering This was deprecated in API level 16.

int USAGE_GRAPHICS_TEXTURE

The Allocation will be used as a texture source by one or more graphics programs.

int USAGE_GRAPHICS_VERTEX

The Allocation will be used as a graphics mesh.

int USAGE_IO_INPUT

The Allocation will be used as a Surface consumer.

int USAGE_IO_OUTPUT

The Allocation will be used as a Surface producer.

int USAGE_SCRIPT

The Allocation will be bound to and accessed by scripts.

int USAGE_SHARED

The Allocation's backing store will be inherited from another object (usually a Bitmap); copying to or from the original source Bitmap will cause a synchronization rather than a full copy.

Public methods

void copy1DRangeFrom(int off, int count, float[] d)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFrom(int off, int count, short[] d)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFrom(int off, int count, Object array)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFrom(int off, int count, Allocation data, int dataOff)

Copy part of an Allocation into this Allocation.

void copy1DRangeFrom(int off, int count, int[] d)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFrom(int off, int count, byte[] d)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFromUnchecked(int off, int count, byte[] d)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFromUnchecked(int off, int count, short[] d)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFromUnchecked(int off, int count, Object array)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFromUnchecked(int off, int count, int[] d)

Copy an array into a 1D region of this Allocation.

void copy1DRangeFromUnchecked(int off, int count, float[] d)

Copy an array into a 1D region of this Allocation.

void copy1DRangeTo(int off, int count, short[] d)

Copy a 1D region of this Allocation into an array.

void copy1DRangeTo(int off, int count, Object array)

Copy a 1D region of this Allocation into an array.

void copy1DRangeTo(int off, int count, int[] d)

Copy a 1D region of this Allocation into an array.

void copy1DRangeTo(int off, int count, float[] d)

Copy a 1D region of this Allocation into an array.

void copy1DRangeTo(int off, int count, byte[] d)

Copy a 1D region of this Allocation into an array.

void copy1DRangeToUnchecked(int off, int count, byte[] d)

Copy a 1D region of this Allocation into an array.

void copy1DRangeToUnchecked(int off, int count, short[] d)

Copy a 1D region of this Allocation into an array.

void copy1DRangeToUnchecked(int off, int count, Object array)

Copy a 1D region of this Allocation into an array.

void copy1DRangeToUnchecked(int off, int count, int[] d)

Copy a 1D region of this Allocation into an array.

void copy1DRangeToUnchecked(int off, int count, float[] d)

Copy a 1D region of this Allocation into an array.

void copy2DRangeFrom(int xoff, int yoff, int w, int h, Allocation data, int dataXoff, int dataYoff)

Copy a rectangular region from an Allocation into a rectangular region in this Allocation.

void copy2DRangeFrom(int xoff, int yoff, Bitmap data)

Copy a Bitmap into an Allocation.

void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data)

Copy from an array into a rectangular region in this Allocation.

void copy2DRangeFrom(int xoff, int yoff, int w, int h, Object array)

Copy from an array into a rectangular region in this Allocation.

void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data)

Copy from an array into a rectangular region in this Allocation.

void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data)

Copy from an array into a rectangular region in this Allocation.

void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data)

Copy from an array into a rectangular region in this Allocation.

void copy2DRangeTo(int xoff, int yoff, int w, int h, short[] data)

Copy from a rectangular region in this Allocation into an array.

void copy2DRangeTo(int xoff, int yoff, int w, int h, byte[] data)

Copy from a rectangular region in this Allocation into an array.

void copy2DRangeTo(int xoff, int yoff, int w, int h, Object array)

Copy from a rectangular region in this Allocation into an array.

void copy2DRangeTo(int xoff, int yoff, int w, int h, float[] data)

Copy from a rectangular region in this Allocation into an array.

void copy2DRangeTo(int xoff, int yoff, int w, int h, int[] data)

Copy from a rectangular region in this Allocation into an array.

void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, Allocation data, int dataXoff, int dataYoff, int dataZoff)

Copy a rectangular region into the allocation from another allocation.

void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, Object array)

Copy from an array into a 3D region in this Allocation.

void copy3DRangeTo(int xoff, int yoff, int zoff, int w, int h, int d, Object array)
void copyFrom(Bitmap b)

Copy into an Allocation from a Bitmap.

void copyFrom(short[] d)

Copy into this Allocation from an array.

void copyFrom(int[] d)

Copy into this Allocation from an array.

void copyFrom(BaseObj[] d)

Copy an array of RS objects to the Allocation.

void copyFrom(byte[] d)

Copy into this Allocation from an array.

void copyFrom(float[] d)

Copy into this Allocation from an array.

void copyFrom(Allocation a)

Copy an Allocation from an Allocation.

void copyFrom(Object array)

Copy into this Allocation from an array.

void copyFromUnchecked(float[] d)

Copy into this Allocation from an array.

void copyFromUnchecked(Object array)

Copy into this Allocation from an array.

void copyFromUnchecked(short[] d)

Copy into this Allocation from an array.

void copyFromUnchecked(int[] d)

Copy into this Allocation from an array.

void copyFromUnchecked(byte[] d)

Copy into this Allocation from an array.

void copyTo(Bitmap b)

Copy from the Allocation into a Bitmap.

void copyTo(short[] d)

Copy from the Allocation into a short array.

void copyTo(byte[] d)

Copy from the Allocation into a byte array.

void copyTo(float[] d)

Copy from the Allocation into a float array.

void copyTo(int[] d)

Copy from the Allocation into a int array.

void copyTo(Object array)

Copy from the Allocation into an array.

static Allocation[] createAllocations(RenderScript rs, Type t, int usage, int numAlloc)

Creates a new Allocation Array with the given Type, and usage flags.

static Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b, Allocation.MipmapControl mips, int usage)

Creates a cubemap Allocation from a Bitmap containing the horizontal list of cube faces.

static Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b)

Creates a non-mipmapped cubemap Allocation for use as a graphics texture from a Bitmap containing the horizontal list of cube faces.

static Allocation createCubemapFromCubeFaces(RenderScript rs, Bitmap xpos, Bitmap xneg, Bitmap ypos, Bitmap yneg, Bitmap zpos, Bitmap zneg)

Creates a non-mipmapped cubemap Allocation for use as a sampler input from 6 Bitmap objects containing the cube faces.

static Allocation createCubemapFromCubeFaces(RenderScript rs, Bitmap xpos, Bitmap xneg, Bitmap ypos, Bitmap yneg, Bitmap zpos, Bitmap zneg, Allocation.MipmapControl mips, int usage)

Creates a cubemap Allocation from 6 Bitmap objects containing the cube faces.

static Allocation createFromBitmap(RenderScript rs, Bitmap b)

Creates an Allocation from a Bitmap.

static Allocation createFromBitmap(RenderScript rs, Bitmap b, Allocation.MipmapControl mips, int usage)

Creates an Allocation from a Bitmap.

static Allocation createFromBitmapResource(RenderScript rs, Resources res, int id, Allocation.MipmapControl mips, int usage)

Creates an Allocation from the Bitmap referenced by resource ID.

static Allocation createFromBitmapResource(RenderScript rs, Resources res, int id)

Creates a non-mipmapped Allocation to use as a graphics texture from the Bitmap referenced by resource ID.

static Allocation createFromString(RenderScript rs, String str, int usage)

Creates an Allocation containing string data encoded in UTF-8 format.

static Allocation createSized(RenderScript rs, Element e, int count)

Creates an Allocation with a specified number of given elements

static Allocation createSized(RenderScript rs, Element e, int count, int usage)

Creates an Allocation with a specified number of given elements

static Allocation createTyped(RenderScript rs, Type type, Allocation.MipmapControl mips, int usage)

Creates a new Allocation with the given Type, mipmap flag, and usage flags.

static Allocation createTyped(RenderScript rs, Type type)

Creates an Allocation for use by scripts with a given Type and no mipmaps

static Allocation createTyped(RenderScript rs, Type type, int usage)

Creates an Allocation with the size specified by the type and no mipmaps generated by default

void destroy()

For USAGE_IO_OUTPUT, destroy() implies setSurface(null).

void generateMipmaps()

Generate a mipmap chain.

ByteBuffer getByteBuffer()

Gets or creates a ByteBuffer that contains the raw data of the current Allocation.

int getBytesSize()

Get the size of the Allocation in bytes.

Element getElement()

Get the Element of the Type of the Allocation.

long getStride()

Gets the stride of the Allocation.

Surface getSurface()

Returns the handle to a raw buffer that is being managed by the screen compositor.

long getTimeStamp()

Get the timestamp for the most recent buffer held by this Allocation.

Type getType()

Get the Type of the Allocation.

int getUsage()

Get the usage flags of the Allocation.

void ioReceive()

Receive the latest input into the Allocation.

void ioSend()

Send a buffer to the output stream.

void resize(int dimX)

This method was deprecated in API level 18. RenderScript objects should be immutable once created. The replacement is to create a new allocation and copy the contents. This function will throw an exception if API 21 or higher is used.

void setAutoPadding(boolean useAutoPadding)

Specifies the mapping between the Allocation's cells and an array's elements when data is copied from the Allocation to the array, or vice-versa.

void setFromFieldPacker(int xoff, int component_number, FieldPacker fp)

This is only intended to be used by auto-generated code reflected from the RenderScript script files and should not be used by developers.

void setFromFieldPacker(int xoff, FieldPacker fp)

This is only intended to be used by auto-generated code reflected from the RenderScript script files and should not be used by developers.

void setFromFieldPacker(int xoff, int yoff, int zoff, int component_number, FieldPacker fp)

This is only intended to be used by auto-generated code reflected from the RenderScript script files and should not be used by developers.

void setOnBufferAvailableListener(Allocation.OnBufferAvailableListener callback)

Set a notification handler for USAGE_IO_INPUT.

void setSurface(Surface sur)

Associate a Surface with this Allocation.

void syncAll(int srcLocation)

Propagate changes from one usage of the Allocation to the other usages of the Allocation.

Protected methods

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

Inherited methods

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

Constants

USAGE_GRAPHICS_CONSTANTS

Added in API level 11
int USAGE_GRAPHICS_CONSTANTS

The Allocation will be used as the source of shader constants by one or more programs. This was deprecated in API level 16.

Constant Value: 8 (0x00000008)

USAGE_GRAPHICS_RENDER_TARGET

Added in API level 14
int USAGE_GRAPHICS_RENDER_TARGET

The Allocation will be used as a target for offscreen rendering This was deprecated in API level 16.

Constant Value: 16 (0x00000010)

USAGE_GRAPHICS_TEXTURE

Added in API level 11
int USAGE_GRAPHICS_TEXTURE

The Allocation will be used as a texture source by one or more graphics programs.

Constant Value: 2 (0x00000002)

USAGE_GRAPHICS_VERTEX

Added in API level 11
int USAGE_GRAPHICS_VERTEX

The Allocation will be used as a graphics mesh. This was deprecated in API level 16.

Constant Value: 4 (0x00000004)

USAGE_IO_INPUT

Added in API level 16
int USAGE_IO_INPUT

The Allocation will be used as a Surface consumer. This usage will cause the Allocation to be created as read-only.

Constant Value: 32 (0x00000020)

USAGE_IO_OUTPUT

Added in API level 16
int USAGE_IO_OUTPUT

The Allocation will be used as a Surface producer. The dimensions and format of the Surface will be forced to those of the Allocation.

Constant Value: 64 (0x00000040)

USAGE_SCRIPT

Added in API level 11
int USAGE_SCRIPT

The Allocation will be bound to and accessed by scripts.

Constant Value: 1 (0x00000001)

USAGE_SHARED

Added in API level 18
int USAGE_SHARED

The Allocation's backing store will be inherited from another object (usually a Bitmap); copying to or from the original source Bitmap will cause a synchronization rather than a full copy. syncAll(int) may also be used to synchronize the Allocation and the source Bitmap.

This is set by default for allocations created with createFromBitmap(RenderScript, Bitmap) in API version 18 and higher.

Constant Value: 128 (0x00000080)

Public methods

copy1DRangeFrom

Added in API level 11
void copy1DRangeFrom (int off, 
                int count, 
                float[] d)

Copy an array into a 1D region of this Allocation. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 32 bit float nor a vector of 32 bit floats Element.DataType.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d float: the source array.

copy1DRangeFrom

Added in API level 11
void copy1DRangeFrom (int off, 
                int count, 
                short[] d)

Copy an array into a 1D region of this Allocation. This variant is type checked and will generate exceptions if the Allocation's Element is not an 16 bit integer nor a vector of 16 bit integers Element.DataType.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d short: the source array

copy1DRangeFrom

Added in API level 21
void copy1DRangeFrom (int off, 
                int count, 
                Object array)

Copy an array into a 1D region of this Allocation. This variant is type checked and will generate exceptions if the Allocation's Element does not match the component type of the array passed in.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
array Object: The source array.

copy1DRangeFrom

Added in API level 14
void copy1DRangeFrom (int off, 
                int count, 
                Allocation data, 
                int dataOff)

Copy part of an Allocation into this Allocation.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
data Allocation: the source data allocation.
dataOff int: off The offset of the first element in data to be copied.

copy1DRangeFrom

Added in API level 11
void copy1DRangeFrom (int off, 
                int count, 
                int[] d)

Copy an array into a 1D region of this Allocation. This variant is type checked and will generate exceptions if the Allocation's Element is not an 32 bit integer nor a vector of 32 bit integers Element.DataType.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d int: the source array

copy1DRangeFrom

Added in API level 11
void copy1DRangeFrom (int off, 
                int count, 
                byte[] d)

Copy an array into a 1D region of this Allocation. This variant is type checked and will generate exceptions if the Allocation's Element is not an 8 bit integer nor a vector of 8 bit integers Element.DataType.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d byte: the source array

copy1DRangeFromUnchecked

Added in API level 11
void copy1DRangeFromUnchecked (int off, 
                int count, 
                byte[] d)

Copy an array into a 1D region of this Allocation. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d byte: the source array

copy1DRangeFromUnchecked

Added in API level 11
void copy1DRangeFromUnchecked (int off, 
                int count, 
                short[] d)

Copy an array into a 1D region of this Allocation. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d short: the source array

copy1DRangeFromUnchecked

Added in API level 21
void copy1DRangeFromUnchecked (int off, 
                int count, 
                Object array)

Copy an array into a 1D region of this Allocation. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
array Object: The source array

copy1DRangeFromUnchecked

Added in API level 11
void copy1DRangeFromUnchecked (int off, 
                int count, 
                int[] d)

Copy an array into a 1D region of this Allocation. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d int: the source array

copy1DRangeFromUnchecked

Added in API level 11
void copy1DRangeFromUnchecked (int off, 
                int count, 
                float[] d)

Copy an array into a 1D region of this Allocation. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d float: the source array

copy1DRangeTo

Added in API level 23
void copy1DRangeTo (int off, 
                int count, 
                short[] d)

Copy a 1D region of this Allocation into an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 16 bit integer nor a vector of 16 bit integers Element.DataType.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d short: the source array

copy1DRangeTo

Added in API level 23
void copy1DRangeTo (int off, 
                int count, 
                Object array)

Copy a 1D region of this Allocation into an array. This method is type checked and will generate exceptions if the Allocation's Element does not match the component type of the array passed in.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
array Object: The source array.

copy1DRangeTo

Added in API level 23
void copy1DRangeTo (int off, 
                int count, 
                int[] d)

Copy a 1D region of this Allocation into an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 32 bit integer nor a vector of 32 bit integers Element.DataType.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d int: the source array

copy1DRangeTo

Added in API level 23
void copy1DRangeTo (int off, 
                int count, 
                float[] d)

Copy a 1D region of this Allocation into an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 32 bit float nor a vector of 32 bit floats Element.DataType.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d float: the source array.

copy1DRangeTo

Added in API level 23
void copy1DRangeTo (int off, 
                int count, 
                byte[] d)

Copy a 1D region of this Allocation into an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither an 8 bit integer nor a vector of 8 bit integers Element.DataType.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d byte: the source array

copy1DRangeToUnchecked

Added in API level 23
void copy1DRangeToUnchecked (int off, 
                int count, 
                byte[] d)

Copy a 1D region of this Allocation into an array. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d byte: the source array

copy1DRangeToUnchecked

Added in API level 23
void copy1DRangeToUnchecked (int off, 
                int count, 
                short[] d)

Copy a 1D region of this Allocation into an array. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d short: the source array

copy1DRangeToUnchecked

Added in API level 23
void copy1DRangeToUnchecked (int off, 
                int count, 
                Object array)

Copy a 1D region of this Allocation into an array. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
array Object: The dest array

copy1DRangeToUnchecked

Added in API level 23
void copy1DRangeToUnchecked (int off, 
                int count, 
                int[] d)

Copy a 1D region of this Allocation into an array. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d int: the source array

copy1DRangeToUnchecked

Added in API level 23
void copy1DRangeToUnchecked (int off, 
                int count, 
                float[] d)

Copy a 1D region of this Allocation into an array. This method does not guarantee that the Allocation is compatible with the input buffer.

The size of the region is: count * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
off int: The offset of the first element to be copied.
count int: The number of elements to be copied.
d float: the source array

copy2DRangeFrom

Added in API level 14
void copy2DRangeFrom (int xoff, 
                int yoff, 
                int w, 
                int h, 
                Allocation data, 
                int dataXoff, 
                int dataYoff)

Copy a rectangular region from an Allocation into a rectangular region in this Allocation.

Parameters
xoff int: X offset of the region in this Allocation
yoff int: Y offset of the region in this Allocation
w int: Width of the region to update.
h int: Height of the region to update.
data Allocation: source Allocation.
dataXoff int: X offset in source Allocation
dataYoff int: Y offset in source Allocation

copy2DRangeFrom

Added in API level 11
void copy2DRangeFrom (int xoff, 
                int yoff, 
                Bitmap data)

Copy a Bitmap into an Allocation. The height and width of the update will use the height and width of the Bitmap.

Parameters
xoff int: X offset of the region to update in this Allocation
yoff int: Y offset of the region to update in this Allocation
data Bitmap: the Bitmap to be copied

copy2DRangeFrom

Added in API level 11
void copy2DRangeFrom (int xoff, 
                int yoff, 
                int w, 
                int h, 
                byte[] data)

Copy from an array into a rectangular region in this Allocation. The array is assumed to be tightly packed. This variant is type checked and will generate exceptions if the Allocation's Element is not an 8 bit integer nor a vector of 8 bit integers Element.DataType.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to update in this Allocation
yoff int: Y offset of the region to update in this Allocation
w int: Width of the region to update
h int: Height of the region to update
data byte: to be placed into the Allocation

copy2DRangeFrom

Added in API level 21
void copy2DRangeFrom (int xoff, 
                int yoff, 
                int w, 
                int h, 
                Object array)

Copy from an array into a rectangular region in this Allocation. The array is assumed to be tightly packed. This variant is type checked and will generate exceptions if the Allocation's Element does not match the input data type.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to update in this Allocation
yoff int: Y offset of the region to update in this Allocation
w int: Width of the region to update
h int: Height of the region to update
array Object: Data to be placed into the Allocation

copy2DRangeFrom

Added in API level 11
void copy2DRangeFrom (int xoff, 
                int yoff, 
                int w, 
                int h, 
                int[] data)

Copy from an array into a rectangular region in this Allocation. The array is assumed to be tightly packed. This variant is type checked and will generate exceptions if the Allocation's Element is not a 32 bit integer nor a vector of 32 bit integers Element.DataType.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to update in this Allocation
yoff int: Y offset of the region to update in this Allocation
w int: Width of the region to update
h int: Height of the region to update
data int: to be placed into the Allocation

copy2DRangeFrom

Added in API level 11
void copy2DRangeFrom (int xoff, 
                int yoff, 
                int w, 
                int h, 
                float[] data)

Copy from an array into a rectangular region in this Allocation. The array is assumed to be tightly packed. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 32 bit float nor a vector of 32 bit floats Element.DataType.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to update in this Allocation
yoff int: Y offset of the region to update in this Allocation
w int: Width of the region to update
h int: Height of the region to update
data float: to be placed into the Allocation

copy2DRangeFrom

Added in API level 11
void copy2DRangeFrom (int xoff, 
                int yoff, 
                int w, 
                int h, 
                short[] data)

Copy from an array into a rectangular region in this Allocation. The array is assumed to be tightly packed. This variant is type checked and will generate exceptions if the Allocation's Element is not a 16 bit integer nor a vector of 16 bit integers Element.DataType.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to update in this Allocation
yoff int: Y offset of the region to update in this Allocation
w int: Width of the region to update
h int: Height of the region to update
data short: to be placed into the Allocation

copy2DRangeTo

Added in API level 23
void copy2DRangeTo (int xoff, 
                int yoff, 
                int w, 
                int h, 
                short[] data)

Copy from a rectangular region in this Allocation into an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 16 bit integer nor a vector of 16 bit integers Element.DataType.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to copy in this Allocation
yoff int: Y offset of the region to copy in this Allocation
w int: Width of the region to copy
h int: Height of the region to copy
data short: Dest Array to be copied into

copy2DRangeTo

Added in API level 23
void copy2DRangeTo (int xoff, 
                int yoff, 
                int w, 
                int h, 
                byte[] data)

Copy from a rectangular region in this Allocation into an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither an 8 bit integer nor a vector of 8 bit integers Element.DataType.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to copy in this Allocation
yoff int: Y offset of the region to copy in this Allocation
w int: Width of the region to copy
h int: Height of the region to copy
data byte: Dest Array to be copied into

copy2DRangeTo

Added in API level 23
void copy2DRangeTo (int xoff, 
                int yoff, 
                int w, 
                int h, 
                Object array)

Copy from a rectangular region in this Allocation into an array. This method is type checked and will generate exceptions if the Allocation's Element does not match the component type of the array passed in.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to copy in this Allocation
yoff int: Y offset of the region to copy in this Allocation
w int: Width of the region to copy
h int: Height of the region to copy
array Object: Dest Array to be copied into

copy2DRangeTo

Added in API level 23
void copy2DRangeTo (int xoff, 
                int yoff, 
                int w, 
                int h, 
                float[] data)

Copy from a rectangular region in this Allocation into an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 32 bit float nor a vector of 32 bit floats Element.DataType.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to copy in this Allocation
yoff int: Y offset of the region to copy in this Allocation
w int: Width of the region to copy
h int: Height of the region to copy
data float: Dest Array to be copied into

copy2DRangeTo

Added in API level 23
void copy2DRangeTo (int xoff, 
                int yoff, 
                int w, 
                int h, 
                int[] data)

Copy from a rectangular region in this Allocation into an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 32 bit integer nor a vector of 32 bit integers Element.DataType.

The size of the region is: w * h * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to copy in this Allocation
yoff int: Y offset of the region to copy in this Allocation
w int: Width of the region to copy
h int: Height of the region to copy
data int: Dest Array to be copied into

copy3DRangeFrom

Added in API level 23
void copy3DRangeFrom (int xoff, 
                int yoff, 
                int zoff, 
                int w, 
                int h, 
                int d, 
                Allocation data, 
                int dataXoff, 
                int dataYoff, 
                int dataZoff)

Copy a rectangular region into the allocation from another allocation.

Parameters
xoff int: X offset of the region to update in this Allocation
yoff int: Y offset of the region to update in this Allocation
zoff int: Z offset of the region to update in this Allocation
w int: Width of the region to update.
h int: Height of the region to update.
d int: Depth of the region to update.
data Allocation: source allocation.
dataXoff int: X offset of the region in the source Allocation
dataYoff int: Y offset of the region in the source Allocation
dataZoff int: Z offset of the region in the source Allocation

copy3DRangeFrom

Added in API level 23
void copy3DRangeFrom (int xoff, 
                int yoff, 
                int zoff, 
                int w, 
                int h, 
                int d, 
                Object array)

Copy from an array into a 3D region in this Allocation. The array is assumed to be tightly packed. This variant is type checked and will generate exceptions if the Allocation's Element does not match the input data type.

The size of the region is: w * h * d * getElement().getBytesSize().

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the region.

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the region. The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the region. The padding bytes for the cells must not be part of the array.

Parameters
xoff int: X offset of the region to update in this Allocation
yoff int: Y offset of the region to update in this Allocation
zoff int: Z offset of the region to update in this Allocation
w int: Width of the region to update
h int: Height of the region to update
d int: Depth of the region to update
array Object: to be placed into the allocation

copy3DRangeTo

Added in API level 23
void copy3DRangeTo (int xoff, 
                int yoff, 
                int zoff, 
                int w, 
                int h, 
                int d, 
                Object array)

Parameters
xoff int
yoff int
zoff int
w int
h int
d int
array Object

copyFrom

Added in API level 11
void copyFrom (Bitmap b)

Copy into an Allocation from a Bitmap. The height, width, and format of the bitmap must match the existing allocation.

If the Bitmap is the same as the Bitmap used to create the Allocation with createFromBitmap(RenderScript, Bitmap) and USAGE_SHARED is set on the Allocation, this will synchronize the Allocation with the latest data from the Bitmap, potentially avoiding the actual copy.

Parameters
b Bitmap: the source bitmap

copyFrom

Added in API level 11
void copyFrom (short[] d)

Copy into this Allocation from an array. This variant is type checked and will generate exceptions if the Allocation's Element is not a 16 bit integer nor a vector of 16 bit integers Element.DataType.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d short: the source array

copyFrom

Added in API level 11
void copyFrom (int[] d)

Copy into this Allocation from an array. This variant is type checked and will generate exceptions if the Allocation's Element is not a 32 bit integer nor a vector of 32 bit integers Element.DataType.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d int: the source array

copyFrom

Added in API level 11
void copyFrom (BaseObj[] d)

Copy an array of RS objects to the Allocation.

Parameters
d BaseObj: Source array.

copyFrom

Added in API level 11
void copyFrom (byte[] d)

Copy into this Allocation from an array. This variant is type checked and will generate exceptions if the Allocation's Element is not an 8 bit integer nor a vector of 8 bit integers Element.DataType.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d byte: the source array

copyFrom

Added in API level 11
void copyFrom (float[] d)

Copy into this Allocation from an array. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 32 bit float nor a vector of 32 bit floats Element.DataType.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d float: the source array

copyFrom

Added in API level 18
void copyFrom (Allocation a)

Copy an Allocation from an Allocation. The types of both allocations must be identical.

Parameters
a Allocation: the source allocation

copyFrom

Added in API level 21
void copyFrom (Object array)

Copy into this Allocation from an array. This variant is type checked and will generate exceptions if the Allocation's Element does not match the array's primitive type.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
array Object: The source array

copyFromUnchecked

Added in API level 11
void copyFromUnchecked (float[] d)

Copy into this Allocation from an array. This method does not guarantee that the Allocation is compatible with the input buffer; it copies memory without reinterpretation.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d float: the source array

copyFromUnchecked

Added in API level 21
void copyFromUnchecked (Object array)

Copy into this Allocation from an array. This method does not guarantee that the Allocation is compatible with the input buffer; it copies memory without reinterpretation.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
array Object: The source array

copyFromUnchecked

Added in API level 11
void copyFromUnchecked (short[] d)

Copy into this Allocation from an array. This method does not guarantee that the Allocation is compatible with the input buffer; it copies memory without reinterpretation.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d short: the source array

copyFromUnchecked

Added in API level 11
void copyFromUnchecked (int[] d)

Copy into this Allocation from an array. This method does not guarantee that the Allocation is compatible with the input buffer; it copies memory without reinterpretation.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d int: the source array

copyFromUnchecked

Added in API level 11
void copyFromUnchecked (byte[] d)

Copy into this Allocation from an array. This method does not guarantee that the Allocation is compatible with the input buffer; it copies memory without reinterpretation.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells must be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d byte: the source array

copyTo

Added in API level 11
void copyTo (Bitmap b)

Copy from the Allocation into a Bitmap. The bitmap must match the dimensions of the Allocation.

Parameters
b Bitmap: The bitmap to be set from the Allocation.

copyTo

Added in API level 11
void copyTo (short[] d)

Copy from the Allocation into a short array. This variant is type checked and will generate exceptions if the Allocation's Element is not a 16 bit integer nor a vector of 16 bit integers Element.DataType.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells will be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d short: The array to be set from the Allocation.

copyTo

Added in API level 11
void copyTo (byte[] d)

Copy from the Allocation into a byte array. This variant is type checked and will generate exceptions if the Allocation's Element is neither an 8 bit integer nor a vector of 8 bit integers Element.DataType.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells will be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d byte: The array to be set from the Allocation.

copyTo

Added in API level 11
void copyTo (float[] d)

Copy from the Allocation into a float array. This variant is type checked and will generate exceptions if the Allocation's Element is neither a 32 bit float nor a vector of 32 bit floats Element.DataType.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells will be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d float: The array to be set from the Allocation.

copyTo

Added in API level 11
void copyTo (int[] d)

Copy from the Allocation into a int array. This variant is type checked and will generate exceptions if the Allocation's Element is not a 32 bit integer nor a vector of 32 bit integers Element.DataType.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells will be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
d int: The array to be set from the Allocation.

copyTo

Added in API level 21
void copyTo (Object array)

Copy from the Allocation into an array. The method is type checked and will generate exceptions if the Allocation's Element does not match the input data type.

If the Allocation does not have Vec3 Elements, then the size of the array in bytes must be at least the size of the Allocation getBytesSize().

If the Allocation has Vec3 Elements and AutoPadding is disabled, then the size of the array in bytes must be at least the size of the Allocation getBytesSize(). The padding bytes for the cells will be part of the array.

If the Allocation has Vec3 Elements and AutoPadding is enabled, then the size of the array in bytes must be at least 3/4 the size of the Allocation getBytesSize(). The padding bytes for the cells must not be part of the array.

Parameters
array Object: The array to be set from the Allocation.

createAllocations

Added in API level 24
Allocation[] createAllocations (RenderScript rs, 
                Type t, 
                int usage, 
                int numAlloc)

Creates a new Allocation Array with the given Type, and usage flags. Note: If the input allocation is of usage: USAGE_IO_INPUT, the created Allocation will be sharing the same BufferQueue.

Parameters
rs RenderScript: RenderScript context
t Type: RenderScript type describing data layout
usage int: bit field specifying how the Allocation is utilized
numAlloc int: Number of Allocations in the array.
Returns
Allocation[] Allocation[]

createCubemapFromBitmap

Added in API level 11
Allocation createCubemapFromBitmap (RenderScript rs, 
                Bitmap b, 
                Allocation.MipmapControl mips, 
                int usage)

Creates a cubemap Allocation from a Bitmap containing the horizontal list of cube faces. Each face must be a square, have the same size as all other faces, and have a width that is a power of 2.

Parameters
rs RenderScript: Context to which the allocation will belong.
b Bitmap: Bitmap with cubemap faces layed out in the following format: right, left, top, bottom, front, back
mips Allocation.MipmapControl: specifies desired mipmap behaviour for the cubemap
usage int: bit field specifying how the cubemap is utilized
Returns
Allocation allocation containing cubemap data

createCubemapFromBitmap

Added in API level 11
Allocation createCubemapFromBitmap (RenderScript rs, 
                Bitmap b)

Creates a non-mipmapped cubemap Allocation for use as a graphics texture from a Bitmap containing the horizontal list of cube faces. Each face must be a square, have the same size as all other faces, and have a width that is a power of 2.

Parameters
rs RenderScript: Context to which the allocation will belong.
b Bitmap: bitmap with cubemap faces layed out in the following format: right, left, top, bottom, front, back
Returns
Allocation allocation containing cubemap data

createCubemapFromCubeFaces

Added in API level 11
Allocation createCubemapFromCubeFaces (RenderScript rs, 
                Bitmap xpos, 
                Bitmap xneg, 
                Bitmap ypos, 
                Bitmap yneg, 
                Bitmap zpos, 
                Bitmap zneg)

Creates a non-mipmapped cubemap Allocation for use as a sampler input from 6 Bitmap objects containing the cube faces. Each face must be a square, have the same size as all other faces, and have a width that is a power of 2.

Parameters
rs RenderScript: Context to which the allocation will belong.
xpos Bitmap: cubemap face in the positive x direction
xneg Bitmap: cubemap face in the negative x direction
ypos Bitmap: cubemap face in the positive y direction
yneg Bitmap: cubemap face in the negative y direction
zpos Bitmap: cubemap face in the positive z direction
zneg Bitmap: cubemap face in the negative z direction
Returns
Allocation allocation containing cubemap data

createCubemapFromCubeFaces

Added in API level 11
Allocation createCubemapFromCubeFaces (RenderScript rs, 
                Bitmap xpos, 
                Bitmap xneg, 
                Bitmap ypos, 
                Bitmap yneg, 
                Bitmap zpos, 
                Bitmap zneg, 
                Allocation.MipmapControl mips, 
                int usage)

Creates a cubemap Allocation from 6 Bitmap objects containing the cube faces. Each face must be a square, have the same size as all other faces, and have a width that is a power of 2.

Parameters
rs RenderScript: Context to which the allocation will belong.
xpos Bitmap: cubemap face in the positive x direction
xneg Bitmap: cubemap face in the negative x direction
ypos Bitmap: cubemap face in the positive y direction
yneg Bitmap: cubemap face in the negative y direction
zpos Bitmap: cubemap face in the positive z direction
zneg Bitmap: cubemap face in the negative z direction
mips Allocation.MipmapControl: specifies desired mipmap behaviour for the cubemap
usage int: bit field specifying how the cubemap is utilized
Returns
Allocation allocation containing cubemap data

createFromBitmap

Added in API level 11
Allocation createFromBitmap (RenderScript rs, 
                Bitmap b)

Creates an Allocation from a Bitmap.

With target API version 18 or greater, this Allocation will be created with USAGE_SHARED, USAGE_SCRIPT, and USAGE_GRAPHICS_TEXTURE. With target API version 17 or lower, this Allocation will be created with USAGE_GRAPHICS_TEXTURE.

Parameters
rs RenderScript: Context to which the allocation will belong.
b Bitmap: bitmap source for the allocation data
Returns
Allocation Allocation containing bitmap data

createFromBitmap

Added in API level 11
Allocation createFromBitmap (RenderScript rs, 
                Bitmap b, 
                Allocation.MipmapControl mips, 
                int usage)

Creates an Allocation from a Bitmap.

Parameters
rs RenderScript: Context to which the allocation will belong.
b Bitmap: Bitmap source for the allocation data
mips Allocation.MipmapControl: specifies desired mipmap behaviour for the allocation
usage int: bit field specifying how the allocation is utilized
Returns
Allocation Allocation containing bitmap data

createFromBitmapResource

Added in API level 11
Allocation createFromBitmapResource (RenderScript rs, 
                Resources res, 
                int id, 
                Allocation.MipmapControl mips, 
                int usage)

Creates an Allocation from the Bitmap referenced by resource ID.

Parameters
rs RenderScript: Context to which the allocation will belong.
res Resources: application resources
id int: resource id to load the data from
mips Allocation.MipmapControl: specifies desired mipmap behaviour for the allocation
usage int: bit field specifying how the allocation is utilized
Returns
Allocation Allocation containing resource data

createFromBitmapResource

Added in API level 11
Allocation createFromBitmapResource (RenderScript rs, 
                Resources res, 
                int id)

Creates a non-mipmapped Allocation to use as a graphics texture from the Bitmap referenced by resource ID.

With target API version 18 or greater, this allocation will be created with USAGE_SCRIPT and USAGE_GRAPHICS_TEXTURE. With target API version 17 or lower, this allocation will be created with USAGE_GRAPHICS_TEXTURE.

Parameters
rs RenderScript: Context to which the allocation will belong.
res Resources: application resources
id int: resource id to load the data from
Returns
Allocation Allocation containing resource data

createFromString

Added in API level 11
Allocation createFromString (RenderScript rs, 
                String str, 
                int usage)

Creates an Allocation containing string data encoded in UTF-8 format.

Parameters
rs RenderScript: Context to which the allocation will belong.
str String: string to create the allocation from
usage int: bit field specifying how the allocaiton is utilized
Returns
Allocation

createSized

Added in API level 11
Allocation createSized (RenderScript rs, 
                Element e, 
                int count)

Creates an Allocation with a specified number of given elements

Parameters
rs RenderScript: Context to which the Allocation will belong.
e Element: Element to use in the Allocation
count int: the number of Elements in the Allocation
Returns
Allocation allocation

createSized

Added in API level 11
Allocation createSized (RenderScript rs, 
                Element e, 
                int count, 
                int usage)

Creates an Allocation with a specified number of given elements

Parameters
rs RenderScript: Context to which the Allocation will belong.
e Element: Element to use in the Allocation
count int: the number of Elements in the Allocation
usage int: bit field specifying how the Allocation is utilized
Returns
Allocation allocation

createTyped

Added in API level 11
Allocation createTyped (RenderScript rs, 
                Type type, 
                Allocation.MipmapControl mips, 
                int usage)

Creates a new Allocation with the given Type, mipmap flag, and usage flags.

Parameters
rs RenderScript
type Type: RenderScript type describing data layout
mips Allocation.MipmapControl: specifies desired mipmap behaviour for the allocation
usage int: bit field specifying how the Allocation is utilized
Returns
Allocation

createTyped

Added in API level 11
Allocation createTyped (RenderScript rs, 
                Type type)

Creates an Allocation for use by scripts with a given Type and no mipmaps

Parameters
rs RenderScript: Context to which the Allocation will belong.
type Type: RenderScript Type describing data layout
Returns
Allocation allocation

createTyped

Added in API level 11
Allocation createTyped (RenderScript rs, 
                Type type, 
                int usage)

Creates an Allocation with the size specified by the type and no mipmaps generated by default

Parameters
rs RenderScript: Context to which the allocation will belong.
type Type: renderscript type describing data layout
usage int: bit field specifying how the allocation is utilized
Returns
Allocation allocation

destroy

Added in API level 11
void destroy ()

For USAGE_IO_OUTPUT, destroy() implies setSurface(null).

generateMipmaps

Added in API level 11
void generateMipmaps ()

Generate a mipmap chain. This is only valid if the Type of the Allocation includes mipmaps.

This function will generate a complete set of mipmaps from the top level LOD and place them into the script memory space.

If the Allocation is also using other memory spaces, a call to syncAll(Allocation.USAGE_SCRIPT) is required.

getByteBuffer

Added in API level 24
ByteBuffer getByteBuffer ()

Gets or creates a ByteBuffer that contains the raw data of the current Allocation.

If the Allocation is created with USAGE_IO_INPUT, the returned ByteBuffer would contain the up-to-date data as READ ONLY. For a 2D or 3D Allocation, the raw data maybe padded so that each row of the Allocation has certain alignment. The size of each row including padding, called stride, can be queried using the getStride() method. Note: Operating on the ByteBuffer of a destroyed Allocation will triger errors.

Returns
ByteBuffer ByteBuffer The ByteBuffer associated with raw data pointer of the Allocation.

getBytesSize

Added in API level 16
int getBytesSize ()

Get the size of the Allocation in bytes.

Returns
int size of the Allocation in bytes.

getElement

Added in API level 16
Element getElement ()

Get the Element of the Type of the Allocation.

Returns
Element Element

getStride

Added in API level 24
long getStride ()

Gets the stride of the Allocation. For a 2D or 3D Allocation, the raw data maybe padded so that each row of the Allocation has certain alignment. The size of each row including such padding is called stride.

Returns
long the stride. For 1D Allocation, the stride will be the number of bytes of this Allocation. For 2D and 3D Allocations, the stride will be the stride in X dimension measuring in bytes.

getSurface

Added in API level 16
Surface getSurface ()

Returns the handle to a raw buffer that is being managed by the screen compositor. This operation is only valid for Allocations with USAGE_IO_INPUT.

Returns
Surface Surface object associated with allocation

getTimeStamp

Added in API level 24
long getTimeStamp ()

Get the timestamp for the most recent buffer held by this Allocation. The timestamp is guaranteed to be unique and monotonically increasing. Default value: -1. The timestamp will be updated after each ioReceive() call. It can be used to identify the images by comparing the unique timestamps when used with android.hardware.camera2 APIs. Example steps: 1. Save TotalCaptureResult when the capture is completed. 2. Get the timestamp after ioReceive() call. 3. Comparing totalCaptureResult.get(CaptureResult.SENSOR_TIMESTAMP) with alloc.getTimeStamp().

Returns
long long Timestamp associated with the buffer held by the Allocation.

getType

Added in API level 11
Type getType ()

Get the Type of the Allocation.

Returns
Type Type

getUsage

Added in API level 16
int getUsage ()

Get the usage flags of the Allocation.

Returns
int usage this Allocation's set of the USAGE_* flags OR'd together

ioReceive

Added in API level 16
void ioReceive ()

Receive the latest input into the Allocation. This operation is only valid if USAGE_IO_INPUT is set on the Allocation.

ioSend

Added in API level 16
void ioSend ()

Send a buffer to the output stream. The contents of the Allocation will be undefined after this operation. This operation is only valid if USAGE_IO_OUTPUT is set on the Allocation.

resize

Added in API level 11
void resize (int dimX)

This method was deprecated in API level 18.
RenderScript objects should be immutable once created. The replacement is to create a new allocation and copy the contents. This function will throw an exception if API 21 or higher is used.

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.

Parameters
dimX int: The new size of the allocation.

setAutoPadding

Added in API level 23
void setAutoPadding (boolean useAutoPadding)

Specifies the mapping between the Allocation's cells and an array's elements when data is copied from the Allocation to the array, or vice-versa. Only applies to an Allocation whose Element is a vector of length 3 (such as U8_3(RenderScript) or RGB_888(RenderScript)). Enabling this feature may make copying data from the Allocation to an array or vice-versa less efficient.

Vec3 Element cells are stored in an Allocation as Vec4 Element cells with the same Element.DataType, with the fourth vector component treated as padding. When this feature is enabled, only the data components, i.e. the first 3 vector components of each cell, will be mapped between the array and the Allocation. When disabled, explicit mapping of the padding components is required, as described in the following example.

For example, when copying an integer array to an Allocation of two I32_3(RenderScript) cells using copyFrom(int[]):

When disabled: The array must have at least 8 integers, with the first 4 integers copied to the first cell of the Allocation, and the next 4 integers copied to the second cell. The 4th and 8th integers are mapped as the padding components.

When enabled: The array just needs to have at least 6 integers, with the first 3 integers copied to the the first cell as data components, and the next 3 copied to the second cell. There is no mapping for the padding components.

Similarly, when copying a byte array to an Allocation of two I32_3(RenderScript) cells, using copyFromUnchecked(int[]):

When disabled: The array must have at least 32 bytes, with the first 16 bytes copied to the first cell of the Allocation, and the next 16 bytes copied to the second cell. The 13th-16th and 29th-32nd bytes are mapped as padding components.

When enabled: The array just needs to have at least 24 bytes, with the first 12 bytes copied to the first cell of the Allocation, and the next 12 bytes copied to the second cell. There is no mapping for the padding components.

Similar to copying data to an Allocation from an array, when copying data from an Allocation to an array, the padding components for Vec3 Element cells will not be copied/mapped to the array if AutoPadding is enabled.

Default: Disabled.

Parameters
useAutoPadding boolean: True: enable AutoPadding; False: disable AutoPadding

setFromFieldPacker

Added in API level 11
void setFromFieldPacker (int xoff, 
                int component_number, 
                FieldPacker fp)

This is only intended to be used by auto-generated code reflected from the RenderScript script files and should not be used by developers.

setFromFieldPacker

Added in API level 11
void setFromFieldPacker (int xoff, 
                FieldPacker fp)

This is only intended to be used by auto-generated code reflected from the RenderScript script files and should not be used by developers.

setFromFieldPacker

Added in API level 23
void setFromFieldPacker (int xoff, 
                int yoff, 
                int zoff, 
                int component_number, 
                FieldPacker fp)

This is only intended to be used by auto-generated code reflected from the RenderScript script files and should not be used by developers.

setOnBufferAvailableListener

Added in API level 19
void setOnBufferAvailableListener (Allocation.OnBufferAvailableListener callback)

Set a notification handler for USAGE_IO_INPUT.

Parameters
callback Allocation.OnBufferAvailableListener: instance of the OnBufferAvailableListener class to be called when buffer arrive.

setSurface

Added in API level 16
void setSurface (Surface sur)

Associate a Surface with this Allocation. This operation is only valid for Allocations with USAGE_IO_OUTPUT.

Parameters
sur Surface: Surface to associate with allocation

syncAll

Added in API level 11
void syncAll (int srcLocation)

Propagate changes from one usage of the Allocation to the other usages of the Allocation.

Parameters
srcLocation int

Protected methods

finalize

Added in API level 11
void finalize ()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Throws
Throwable

Hooray!