@@ -102,7 +102,7 @@ public class Allocation extends BaseObj {
102102 public static final int USAGE_SCRIPT = 0x0001 ;
103103
104104 /**
105- * GRAPHICS_TEXTURE The allcation will be used as a texture
105+ * GRAPHICS_TEXTURE The allocation will be used as a texture
106106 * source by one or more graphics programs.
107107 *
108108 */
@@ -124,34 +124,34 @@ public class Allocation extends BaseObj {
124124 public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008 ;
125125
126126 /**
127- * USAGE_GRAPHICS_RENDER_TARGET The allcation will be used as a
127+ * USAGE_GRAPHICS_RENDER_TARGET The allocation will be used as a
128128 * target for offscreen rendering
129129 *
130130 */
131131 public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010 ;
132132
133133 /**
134- * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT The allocation will be
135- * used with a SurfaceTexture object. This usage will cause the
136- * allocation to be created read only .
134+ * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE The allocation
135+ * will be used as a SurfaceTexture graphics consumer. This
136+ * usage may only be used with USAGE_GRAPHICS_TEXTURE .
137137 *
138138 * @hide
139139 */
140140 public static final int USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE = 0x0020 ;
141141
142142 /**
143- * USAGE_IO_INPUT The allocation will be
144- * used with a SurfaceTexture object . This usage will cause the
145- * allocation to be created read only.
143+ * USAGE_IO_INPUT The allocation will be used as SurfaceTexture
144+ * consumer . This usage will cause the allocation to be created
145+ * read only.
146146 *
147147 * @hide
148148 */
149149 public static final int USAGE_IO_INPUT = 0x0040 ;
150150
151151 /**
152- * USAGE_IO_OUTPUT The allocation will be
153- * used with a SurfaceTexture object . This usage will cause the
154- * allocation to be created write only .
152+ * USAGE_IO_OUTPUT The allocation will be used as a
153+ * SurfaceTexture producer . The dimensions and format of the
154+ * SurfaceTexture will be forced to those of the allocation .
155155 *
156156 * @hide
157157 */
@@ -323,6 +323,37 @@ public void syncAll(int srcLocation) {
323323 mRS .nAllocationSyncAll (getIDSafe (), srcLocation );
324324 }
325325
326+ /**
327+ * Send a buffer to the output stream. The contents of the
328+ * Allocation will be undefined after this operation.
329+ *
330+ * @hide
331+ *
332+ */
333+ public void ioSendOutput () {
334+ if ((mUsage & USAGE_IO_OUTPUT ) == 0 ) {
335+ throw new RSIllegalArgumentException (
336+ "Can only send buffer if IO_OUTPUT usage specified." );
337+ }
338+ mRS .validate ();
339+ mRS .nAllocationIoSend (getID ());
340+ }
341+
342+ /**
343+ * Receive the latest input into the Allocation.
344+ *
345+ * @hide
346+ *
347+ */
348+ public void ioGetInput () {
349+ if ((mUsage & USAGE_IO_INPUT ) == 0 ) {
350+ throw new RSIllegalArgumentException (
351+ "Can only send buffer if IO_OUTPUT usage specified." );
352+ }
353+ mRS .validate ();
354+ mRS .nAllocationIoReceive (getID ());
355+ }
356+
326357 public void copyFrom (BaseObj [] d ) {
327358 mRS .validate ();
328359 validateIsObject ();
@@ -887,17 +918,37 @@ public synchronized void resize(int dimX) {
887918 updateCacheInfo (mType );
888919 }
889920
890- /*
921+ /**
922+ * Resize a 2D allocation. The contents of the allocation are
923+ * preserved. If new elements are allocated objects are created
924+ * with null contents and the new region is otherwise undefined.
925+ *
926+ * If the new region is smaller the references of any objects
927+ * outside the new region will be released.
928+ *
929+ * A new type will be created with the new dimension.
930+ *
931+ * @hide
932+ * @param dimX The new size of the allocation.
933+ * @param dimY The new size of the allocation.
934+ */
891935 public void resize (int dimX , int dimY ) {
892- if ((mType.getZ() > 0) || mType.getFaces() || mType.getLOD()) {
893- throw new RSIllegalStateException("Resize only support for 2D allocations at this time.");
936+ if ((mType .getZ () > 0 ) || mType .hasFaces () || mType .hasMipmaps ()) {
937+ throw new RSInvalidStateException (
938+ "Resize only support for 2D allocations at this time." );
894939 }
895940 if (mType .getY () == 0 ) {
896- throw new RSIllegalStateException("Resize only support for 2D allocations at this time.");
941+ throw new RSInvalidStateException (
942+ "Resize only support for 2D allocations at this time." );
897943 }
898944 mRS .nAllocationResize2D (getID (), dimX , dimY );
945+ mRS .finish (); // Necessary because resize is fifoed and update is async.
946+
947+ int typeID = mRS .nAllocationGetType (getID ());
948+ mType = new Type (typeID , mRS );
949+ mType .updateFromNative ();
950+ updateCacheInfo (mType );
899951 }
900- */
901952
902953
903954
@@ -1090,6 +1141,18 @@ public SurfaceTexture getSurfaceTexture() {
10901141
10911142 }
10921143
1144+ /**
1145+ * @hide
1146+ */
1147+ public void setSurfaceTexture (SurfaceTexture sur ) {
1148+ if ((mUsage & USAGE_IO_OUTPUT ) == 0 ) {
1149+ throw new RSInvalidStateException ("Allocation is not USAGE_IO_OUTPUT." );
1150+ }
1151+
1152+ mRS .validate ();
1153+ mRS .nAllocationSetSurfaceTexture (getID (), sur );
1154+ }
1155+
10931156
10941157 /**
10951158 * Creates a non-mipmapped renderscript allocation to use as a
0 commit comments