Allocation


public class Allocation
extends BaseObj

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


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

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

interface Allocation.OnBufferAvailableListener

Interface to handle notification when new buffers are available via Allocation.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