Lines Matching full:allocation
35 * and from RenderScript kernels. An Allocation provides the backing store for
38 * <p>An Allocation also contains a set of usage flags that denote how the
39 * Allocation could be used. For example, an Allocation may have usage flags
42 * different usages using {@link android.renderscript.Allocation#syncAll} in
43 * order to ensure that different users of the Allocation have a consistent view
44 * of memory. For example, in the case where an Allocation is used as the output
46 * {@link #syncAll syncAll(Allocation.USAGE_SCRIPT)} prior to launching the
49 * <p>An Allocation can be populated with the {@link #copyFrom} routines. For
59 public class Allocation extends BaseObj {
63 Allocation mAdaptedAllocation;
81 static HashMap<Integer, Allocation> mAllocationMap =
82 new HashMap<Integer, Allocation>();
86 * The usage of the Allocation. These signal to RenderScript where to place
87 * the Allocation in memory.
92 * The Allocation will be bound to and accessed by scripts.
97 * The Allocation will be used as a texture source by one or more graphics
104 * The Allocation will be used as a graphics mesh.
113 * The Allocation will be used as the source of shader constants by one or
122 * The Allocation will be used as a target for offscreen rendering
130 * The Allocation will be used as a {@link android.graphics.SurfaceTexture}
131 * consumer. This usage will cause the Allocation to be created as
138 * The Allocation will be used as a {@link android.graphics.SurfaceTexture}
141 * Allocation.
147 * The Allocation's backing store will be inherited from another object
150 * copy. {@link #syncAll} may also be used to synchronize the Allocation
172 * the Allocation will contain a full mipmap chain. On upload, the full
178 * The Type of the Allocation will be the same as MIPMAP_NONE. It will
179 * not contain mipmaps. On upload, the allocation data will contain a
201 * android.renderscript.Type} of the Allocation.
211 * Get the usage flags of the Allocation.
213 * @return usage this Allocation's set of the USAGE_* flags OR'd together
221 * Get the size of the Allocation in bytes.
223 * @return size of the Allocation in bytes.
247 Allocation(int id, RenderScript rs, Type t, int usage) {
299 "32 bit integer source does not match allocation type " + mType.mElement.mType);
308 "16 bit integer source does not match allocation type " + mType.mElement.mType);
317 "8 bit integer source does not match allocation type " + mType.mElement.mType);
325 "32 bit float source does not match allocation type " + mType.mElement.mType);
342 "Object source does not match allocation type " + mType.mElement.mType);
357 * Get the {@link android.renderscript.Type} of the Allocation.
367 * Propagate changes from one usage of the Allocation to the
368 * other usages of the Allocation.
397 * Send a buffer to the output stream. The contents of the Allocation will
399 * #USAGE_IO_OUTPUT} is set on the Allocation.
423 * Receive the latest input into the Allocation. This operation
424 * is only valid if {@link #USAGE_IO_INPUT} is set on the Allocation.
439 * Copy an array of RS objects to the Allocation.
448 throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " +
467 throw new RSIllegalArgumentException("Allocation kind is " +
477 throw new RSIllegalArgumentException("Allocation kind is " +
487 throw new RSIllegalArgumentException("Allocation kind is " +
497 throw new RSIllegalArgumentException("Allocation kind is " +
510 throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch");
515 * Copy into this Allocation from an array. This method does not guarantee
516 * that the Allocation is compatible with the input buffer; it copies memory
535 * Copy into this Allocation from an array. This method does not guarantee
536 * that the Allocation is compatible with the input buffer; it copies memory
555 * Copy into this Allocation from an array. This method does not guarantee
556 * that the Allocation is compatible with the input buffer; it copies memory
575 * Copy into this Allocation from an array. This method does not guarantee
576 * that the Allocation is compatible with the input buffer; it copies memory
596 * Copy into this Allocation from an array. This variant is type checked
597 * and will generate exceptions if the Allocation's {@link
616 * Copy into this Allocation from an array. This variant is type checked
617 * and will generate exceptions if the Allocation's {@link
636 * Copy into this Allocation from an array. This variant is type checked
637 * and will generate exceptions if the Allocation's {@link
656 * Copy into this Allocation from an array. This variant is type checked
657 * and will generate exceptions if the Allocation's {@link
676 * Copy into an Allocation from a {@link android.graphics.Bitmap}. The
678 * allocation.
681 * android.graphics.Bitmap} used to create the Allocation with {@link
682 * #createFromBitmap} and {@link #USAGE_SHARED} is set on the Allocation,
683 * this will synchronize the Allocation with the latest data from the {@link
705 * Copy an Allocation from an Allocation. The types of both allocations
708 * @param a the source allocation
710 public void copyFrom(Allocation a) {
783 throw new RSIllegalArgumentException("Array too small for allocation type.");
788 * Generate a mipmap chain. This is only valid if the Type of the Allocation
794 * <p>If the Allocation is also using other memory spaces, a call to {@link
795 * #syncAll syncAll(Allocation.USAGE_SCRIPT)} is required.</p>
802 * Copy an array into part of this Allocation. This method does not
803 * guarantee that the Allocation is compatible with the input buffer.
818 * Copy an array into part of this Allocation. This method does not
819 * guarantee that the Allocation is compatible with the input buffer.
834 * Copy an array into part of this Allocation. This method does not
835 * guarantee that the Allocation is compatible with the input buffer.
850 * Copy an array into part of this Allocation. This method does not
851 * guarantee that the Allocation is compatible with the input buffer.
866 * Copy an array into part of this Allocation. This variant is type checked
867 * and will generate exceptions if the Allocation type is not a 32 bit
882 * Copy an array into part of this Allocation. This variant is type checked
883 Allocation type is not a 16 bit
898 * Copy an array into part of this Allocation. This variant is type checked
899 * and will generate exceptions if the Allocation type is not an 8 bit
914 * Copy an array into part of this Allocation. This variant is type checked
915 * and will generate exceptions if the Allocation type is not a 32 bit float
929 * Copy part of an Allocation into this Allocation.
933 * @param data the source data allocation.
937 public void copy1DRangeFrom(int off, int count, Allocation data, int dataOff) {
957 throw new RSIllegalArgumentException("Updated region larger than allocation.");
999 * Copy from an array into a rectangular region in this Allocation. The
1002 * @param xoff X offset of the region to update in this Allocation
1003 * @param yoff Y offset of the region to update in this Allocation
1006 * @param data to be placed into the Allocation
1016 * Copy from an array into a rectangular region in this Allocation. The
1019 * @param xoff X offset of the region to update in this Allocation
1020 * @param yoff Y offset of the region to update in this Allocation
1023 * @param data to be placed into the Allocation
1033 * Copy from an array into a rectangular region in this Allocation. The
1036 * @param xoff X offset of the region to update in this Allocation
1037 * @param yoff Y offset of the region to update in this Allocation
1040 * @param data to be placed into the Allocation
1050 * Copy from an array into a rectangular region in this Allocation. The
1053 * @param xoff X offset of the region to update in this Allocation
1054 * @param yoff Y offset of the region to update in this Allocation
1057 * @param data to be placed into the Allocation
1067 * Copy a rectangular region from an Allocation into a rectangular region in
1068 * this Allocation.
1070 * @param xoff X offset of the region in this Allocation
1071 * @param yoff Y offset of the region in this Allocation
1074 * @param data source Allocation.
1075 * @param dataXoff X offset in source Allocation
1076 * @param dataYoff Y offset in source Allocation
1079 Allocation data, int dataXoff, int dataYoff) {
1091 * Copy a {@link android.graphics.Bitmap} into an Allocation. The height
1095 * @param xoff X offset of the region to update in this Allocation
1096 * @param yoff Y offset of the region to update in this Allocation
1127 throw new RSIllegalArgumentException("Updated region larger than allocation.");
1179 * Copy a rectangular region from the array into the allocation.
1182 * @param xoff X offset of the region to update in this Allocation
1183 * @param yoff Y offset of the region to update in this Allocation
1184 * @param zoff Z offset of the region to update in this Allocation
1188 * @param data to be placed into the allocation
1224 * Copy a rectangular region into the allocation from another
1225 * allocation.
1227 * @param xoff X offset of the region to update in this Allocation
1228 * @param yoff Y offset of the region to update in this Allocation
1229 * @param zoff Z offset of the region to update in this Allocation
1233 * @param data source allocation.
1234 * @param dataXoff X offset of the region in the source Allocation
1235 * @param dataYoff Y offset of the region in the source Allocation
1236 * @param dataZoff Z offset of the region in the source Allocation
1239 Allocation data, int dataXoff, int dataYoff, int dataZoff) {
1249 * Copy from the Allocation into a {@link android.graphics.Bitmap}. The
1250 * bitmap must match the dimensions of the Allocation.
1252 * @param b The bitmap to be set from the Allocation.
1264 * Copy from the Allocation into a byte array. The array must be at least
1265 * as large as the Allocation. The allocation must be of an 8 bit integer
1268 * @param d The array to be set from the Allocation.
1279 * Copy from the Allocation into a short array. The array must be at least
1280 * as large as the Allocation. The allocation must be of an 16 bit integer
1283 * @param d The array to be set from the Allocation.
1294 * Copy from the Allocation
1295 * large as the Allocation. The allocation must be of an 32 bit integer
1298 * @param d The array to be set from the Allocation.
1309 * Copy from the Allocation into a float array. The array must be at least
1310 * as large as the Allocation. The allocation must be of an 32 bit float
1313 * @param d The array to be set from the Allocation.
1324 * Resize a 1D allocation. The contents of the allocation are preserved.
1333 * @param dimX The new size of the allocation.
1336 * replacement is to create a new allocation and copy the contents.
1360 * Creates a new Allocation with the given {@link
1365 * allocation
1366 * @param usage bit field specifying how the Allocation is
1369 static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips, int usage) {
1377 throw new RSRuntimeException("Allocation creation failed.");
1380 return new Allocation(id, rs, type, usage);
1384 * Creates an Allocation with the size specified by the type and no mipmaps
1387 * @param rs Context to which the allocation will belong.
1389 * @param usage bit field specifying how the allocation is
1392 * @return allocation
1394 static public Allocation createTyped(RenderScript rs, Type type, int usage) {
1399 * Creates an Allocation for use by scripts with a given {@link
1402 * @param rs Context to which the Allocation will belong.
1405 * @return allocation
1407 static public Allocation createTyped(RenderScript rs, Type type) {
1412 * Creates an Allocation with a specified number of given elements
1414 * @param rs Context to which the Allocation will belong.
1415 * @param e Element to use in the Allocation
1416 * @param count the number of Elements in the Allocation
1417 * @param usage bit field specifying how the Allocation is
1420 * @return allocation
1422 static public Allocation createSized(RenderScript rs, Element e,
1432 throw new RSRuntimeException("Allocation creation failed.");
1435 return new Allocation(id, rs, t, usage);
1439 * Creates an Allocation with a specified number of given elements
1441 * @param rs Context to which the Allocation will belong.
1442 * @param e Element to use in the Allocation
1443 * @param count the number of Elements in the Allocation
1445 * @return allocation
1447 static public Allocation createSized(RenderScript rs, Element e, int count) {
1479 * Creates an Allocation from a {@link android.graphics.Bitmap}.
1481 * @param rs Context to which the allocation will belong.
1482 * @param b Bitmap source for the allocation data
1484 * allocation
1485 * @param usage bit field specifying how the allocation is
1488 * @return Allocation containing bitmap data
1491 static public Allocation createFromBitmap(RenderScript rs, Bitmap b,
1520 Allocation alloc = new Allocation(id, rs, t, usage);
1531 return new Allocation(id, rs, t, usage);
1539 * @return Surface object associated with allocation
1544 throw new RSInvalidStateException("Allocation is not a surface texture.");
1557 * Associate a {@link android.view.Surface} with this Allocation. This
1560 * @param sur Surface to associate with allocation
1565 throw new RSInvalidStateException("Allocation is not USAGE_IO_OUTPUT.");
1572 * Creates an Allocation from a {@link android.graphics.Bitmap}.
1574 * <p>With target API version 18 or greater, this Allocation will be created
1577 * Allocation will be created with {@link #USAGE_GRAPHICS_TEXTURE}.</p>
1579 * @param rs Context to which the allocation will belong.
1580 * @param b bitmap source for the allocation data
1582 * @return Allocation containing bitmap data
1585 static public Allocation createFromBitmap(RenderScript rs, Bitmap b) {
1595 * Creates a cubemap Allocation from a {@link android.graphics.Bitmap}
1600 * @param rs Context to which the allocation will belong.
1606 * @return allocation containing cubemap data
1609 static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b,
1640 return new Allocation(id, rs, t, usage);
1644 * Creates a non-mipmapped cubemap Allocation for use as a graphics texture
1649 * @param rs Context to which the allocation will belong.
1653 * @return allocation containing cubemap data
1656 static public Allocation createCubemapFromBitmap(RenderScript rs,
1663 * Creates a cubemap Allocation from 6 {@link android.graphics.Bitmap}
1667 * @param rs Context to which the allocation will belong.
1677 * @return allocation containing cubemap data
1680 static public Allocation createCubemapFromCubeFaces(RenderScript rs,
1710 Allocation cubemap = Allocation.createTyped(rs, t, mips, usage);
1730 * Creates a non-mipmapped cubemap Allocation for use as a sampler input
1735 * @param rs Context to which the allocation will belong.
1743 * @return allocation containing cubemap data
1746 static public Allocation createCubemapFromCubeFaces(RenderScript rs,
1759 * Creates an Allocation from the Bitmap referenced
1762 * @param rs Context to which the allocation will belong.
1766 * allocation
1767 * @param usage bit field specifying how the allocation is
1770 * @return Allocation containing resource data
1773 static public Allocation createFromBitmapResource(RenderScript rs,
1784 Allocation alloc = createFromBitmap(rs, b, mips, usage);
1790 * Creates a non-mipmapped Allocation to use as a graphics texture from the
1793 * <p>With target API version 18 or greater, this allocation will be created
1795 * target API version 17 or lower, this allocation will be created with
1798 * @param rs Context to which the allocation will belong.
1802 * @return Allocation containing resource data
1805 static public Allocation createFromBitmapResource(RenderScript rs,
1819 * Creates an Allocation containing string data encoded in UTF-8 format.
1821 * @param rs Context to which the allocation will belong.
1822 * @param str string to create the allocation from
1827 static public Allocation createFromString(RenderScript rs,
1834 Allocation alloc = Allocation.createSized(rs, Element.U8(rs), allocArray.length, usage);
1850 public void onBufferAvailable(Allocation a);
1868 Allocation a = mAllocationMap.get(new Integer(id));