diff options
Diffstat (limited to 'graphics/java/android/renderscript')
14 files changed, 113 insertions, 26 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index abe66726..0c33a5f 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -46,15 +46,62 @@ public class Allocation extends BaseObj { Bitmap mBitmap; int mUsage; + /** + * The usage of the allocation. These signal to renderscript + * where to place the allocation in memory. + * + * SCRIPT The allocation will be bound to and accessed by + * scripts. + */ public static final int USAGE_SCRIPT = 0x0001; + + /** + * GRAPHICS_TEXTURE The allcation will be used as a texture + * source by one or more graphcics programs. + * + */ public static final int USAGE_GRAPHICS_TEXTURE = 0x0002; + + /** + * GRAPHICS_VERTEX The allocation will be used as a graphics + * mesh. + * + */ public static final int USAGE_GRAPHICS_VERTEX = 0x0004; + + + /** + * GRAPHICS_CONSTANTS The allocation will be used as the source + * of shader constants by one or more programs. + * + */ public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008; + /** + * Controls mipmap behavior when using the bitmap creation and + * update functions. + */ public enum MipmapControl { + /** + * No mipmaps will be generated and the type generated from the + * incoming bitmap will not contain additional LODs. + */ MIPMAP_NONE(0), + + /** + * A Full mipmap chain will be created in script memory. The + * type of the allocation will contain a full mipmap chain. On + * upload to graphics the full chain will be transfered. + */ MIPMAP_FULL(1), + + /** + * The type of the allocation will be the same as MIPMAP_NONE. + * It will not contain mipmaps. On upload to graphics the + * graphics copy of the allocation data will contain a full + * mipmap chain generated from the top level in script memory. + */ MIPMAP_ON_SYNC_TO_TEXTURE(2); int mID; @@ -256,6 +303,20 @@ public class Allocation extends BaseObj { } } + /** + * Generate a mipmap chain. Requires the type of the allocation + * include mipmaps. + * + * This function will generate a complete set of mipmaps from + * the top level lod and place them into the script memoryspace. + * + * If the allocation is also using other memory spaces a + * followup sync will be required. + */ + public void generateMipmaps() { + mRS.nAllocationGenerateMipmaps(getID()); + } + public void copy1DRangeFrom(int off, int count, int[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 4, dataSize); @@ -278,29 +339,49 @@ public class Allocation extends BaseObj { } - public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] d) { + /** + * Copy a rectanglular region from the array into the + * allocation. The incoming array is assumed to be tightly + * packed. + * + * @param xoff X offset of the region to update + * @param yoff Y offset of the region to update + * @param w Width of the incoming region to update + * @param h Height of the incoming region to update + * @param data to be placed into the allocation + */ + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length); } - public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] d) { + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 2); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 2); } - public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] d) { + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 4); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 4); } - public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] d) { + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 4); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 4); } - public void copy2DRangeFrom(int xoff, int yoff, Bitmap b) { + /** + * Copy a bitmap into an allocation. The height and width of + * the update will use the height and width of the incoming + * bitmap. + * + * @param xoff X offset of the region to update + * @param yoff Y offset of the region to update + * @param data the bitmap to be copied + */ + public void copy2DRangeFrom(int xoff, int yoff, Bitmap data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, b); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, data); } @@ -329,6 +410,18 @@ public class Allocation extends BaseObj { mRS.nAllocationRead(getID(), d); } + /** + * 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. + * + * @param dimX The new size of the allocation. + */ public synchronized void resize(int dimX) { if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) { throw new RSInvalidStateException("Resize only support for 1D allocations at this time."); diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/graphics/java/android/renderscript/AllocationAdapter.java index e682e93..f2fedea 100644 --- a/graphics/java/android/renderscript/AllocationAdapter.java +++ b/graphics/java/android/renderscript/AllocationAdapter.java @@ -24,7 +24,6 @@ import android.util.Log; import android.util.TypedValue; /** - * @hide * **/ public class AllocationAdapter extends Allocation { diff --git a/graphics/java/android/renderscript/FileA3D.java b/graphics/java/android/renderscript/FileA3D.java index 01a9a82..90d102c 100644 --- a/graphics/java/android/renderscript/FileA3D.java +++ b/graphics/java/android/renderscript/FileA3D.java @@ -28,7 +28,6 @@ import android.util.Log; import android.util.TypedValue; /** - * @hide * **/ public class FileA3D extends BaseObj { diff --git a/graphics/java/android/renderscript/Font.java b/graphics/java/android/renderscript/Font.java index ae209fa..252ffc1 100644 --- a/graphics/java/android/renderscript/Font.java +++ b/graphics/java/android/renderscript/Font.java @@ -30,7 +30,6 @@ import android.util.Log; import android.util.TypedValue; /** - * @hide * **/ public class Font extends BaseObj { diff --git a/graphics/java/android/renderscript/Long2.java b/graphics/java/android/renderscript/Long2.java index 11ead2f..834d13c 100644 --- a/graphics/java/android/renderscript/Long2.java +++ b/graphics/java/android/renderscript/Long2.java @@ -21,7 +21,6 @@ import android.util.Log; /** - * @hide * **/ public class Long2 { diff --git a/graphics/java/android/renderscript/Long3.java b/graphics/java/android/renderscript/Long3.java index 1604532..c6d7289 100644 --- a/graphics/java/android/renderscript/Long3.java +++ b/graphics/java/android/renderscript/Long3.java @@ -21,7 +21,6 @@ import android.util.Log; /** - * @hide * **/ public class Long3 { diff --git a/graphics/java/android/renderscript/Long4.java b/graphics/java/android/renderscript/Long4.java index 2fd2747..032c1d3 100644 --- a/graphics/java/android/renderscript/Long4.java +++ b/graphics/java/android/renderscript/Long4.java @@ -21,7 +21,6 @@ import android.util.Log; /** - * @hide * **/ public class Long4 { diff --git a/graphics/java/android/renderscript/Mesh.java b/graphics/java/android/renderscript/Mesh.java index b77fe7d..f1f1237 100644 --- a/graphics/java/android/renderscript/Mesh.java +++ b/graphics/java/android/renderscript/Mesh.java @@ -22,7 +22,6 @@ import android.util.Config; import android.util.Log; /** - * @hide * Mesh class is a container for geometric data displayed in * renderscript. * @@ -205,7 +204,7 @@ public class Mesh extends BaseObj { /** * Adds a vertex data type to the builder object * - * @param r type of the vertex data allocation to be created + * @param t type of the vertex data allocation to be created * * @return this **/ diff --git a/graphics/java/android/renderscript/RSDriverException.java b/graphics/java/android/renderscript/RSDriverException.java index 61787e6..ce85b53 100644 --- a/graphics/java/android/renderscript/RSDriverException.java +++ b/graphics/java/android/renderscript/RSDriverException.java @@ -20,7 +20,6 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * Renderscript - * @hide */ public class RSDriverException extends RSRuntimeException { public RSDriverException(String string) { diff --git a/graphics/java/android/renderscript/RSIllegalArgumentException.java b/graphics/java/android/renderscript/RSIllegalArgumentException.java index 8d67a8d..954c0e8 100644 --- a/graphics/java/android/renderscript/RSIllegalArgumentException.java +++ b/graphics/java/android/renderscript/RSIllegalArgumentException.java @@ -20,7 +20,6 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * Renderscript - * @hide */ public class RSIllegalArgumentException extends RSRuntimeException { public RSIllegalArgumentException(String string) { diff --git a/graphics/java/android/renderscript/RSInvalidStateException.java b/graphics/java/android/renderscript/RSInvalidStateException.java index 53b9479..691aeba 100644 --- a/graphics/java/android/renderscript/RSInvalidStateException.java +++ b/graphics/java/android/renderscript/RSInvalidStateException.java @@ -20,7 +20,6 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * Renderscript - * @hide */ public class RSInvalidStateException extends RSRuntimeException { public RSInvalidStateException(String string) { diff --git a/graphics/java/android/renderscript/RSRuntimeException.java b/graphics/java/android/renderscript/RSRuntimeException.java index 4c97937..5a16478 100644 --- a/graphics/java/android/renderscript/RSRuntimeException.java +++ b/graphics/java/android/renderscript/RSRuntimeException.java @@ -20,7 +20,6 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * Renderscript - * @hide */ public class RSRuntimeException extends java.lang.RuntimeException { diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java index 507f41f..be893bb 100644 --- a/graphics/java/android/renderscript/RSSurfaceView.java +++ b/graphics/java/android/renderscript/RSSurfaceView.java @@ -30,16 +30,16 @@ import android.view.SurfaceHolder; import android.view.SurfaceView; /** - * @hide * - **/ + */ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback { private SurfaceHolder mSurfaceHolder; private RenderScriptGL mRS; /** * Standard View constructor. In order to render something, you - * must call {@link #setRenderer} to register a renderer. + * must call {@link android.opengl.GLSurfaceView#setRenderer} to + * register a renderer. */ public RSSurfaceView(Context context) { super(context); @@ -49,7 +49,8 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback /** * Standard View constructor. In order to render something, you - * must call {@link #setRenderer} to register a renderer. + * must call {@link android.opengl.GLSurfaceView#setRenderer} to + * register a renderer. */ public RSSurfaceView(Context context, AttributeSet attrs) { super(context, attrs); diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 4c9ad56..28b32d5 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -223,6 +223,10 @@ public class RenderScript { synchronized void nAllocationSyncAll(int alloc, int src) { rsnAllocationSyncAll(mContext, alloc, src); } + native void rsnAllocationGenerateMipmaps(int con, int alloc); + synchronized void nAllocationGenerateMipmaps(int alloc) { + rsnAllocationGenerateMipmaps(mContext, alloc); + } native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp); synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) { rsnAllocationCopyFromBitmap(mContext, alloc, bmp); |
