diff options
Diffstat (limited to 'graphics/java/android')
62 files changed, 1190 insertions, 897 deletions
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java index 429be49..b714fab 100644 --- a/graphics/java/android/graphics/BitmapFactory.java +++ b/graphics/java/android/graphics/BitmapFactory.java @@ -300,17 +300,22 @@ public class BitmapFactory { public boolean inPreferQualityOverSpeed; /** - * The resulting width of the bitmap, set independent of the state of - * inJustDecodeBounds. However, if there is an error trying to decode, - * outWidth will be set to -1. + * The resulting width of the bitmap. If {@link #inJustDecodeBounds} is + * set to false, this will be width of the output bitmap after any + * scaling is applied. If true, it will be the width of the input image + * without any accounting for scaling. + * + * <p>outWidth will be set to -1 if there is an error trying to decode.</p> */ - public int outWidth; /** - * The resulting height of the bitmap, set independent of the state of - * inJustDecodeBounds. However, if there is an error trying to decode, - * outHeight will be set to -1. + * The resulting height of the bitmap. If {@link #inJustDecodeBounds} is + * set to false, this will be height of the output bitmap after any + * scaling is applied. If true, it will be the height of the input image + * without any accounting for scaling. + * + * <p>outHeight will be set to -1 if there is an error trying to decode.</p> */ public int outHeight; diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index d46238f..13f4299 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -1403,7 +1403,7 @@ public class Canvas { throw new IndexOutOfBoundsException(); } native_drawText(mNativeCanvas, text, index, count, x, y, paint.mBidiFlags, - paint.mNativePaint); + paint.mNativePaint, paint.mNativeTypeface); } /** @@ -1417,7 +1417,7 @@ public class Canvas { */ public void drawText(String text, float x, float y, Paint paint) { native_drawText(mNativeCanvas, text, 0, text.length(), x, y, paint.mBidiFlags, - paint.mNativePaint); + paint.mNativePaint, paint.mNativeTypeface); } /** @@ -1436,7 +1436,7 @@ public class Canvas { throw new IndexOutOfBoundsException(); } native_drawText(mNativeCanvas, text, start, end, x, y, paint.mBidiFlags, - paint.mNativePaint); + paint.mNativePaint, paint.mNativeTypeface); } /** @@ -1456,7 +1456,7 @@ public class Canvas { if (text instanceof String || text instanceof SpannedString || text instanceof SpannableString) { native_drawText(mNativeCanvas, text.toString(), start, end, x, y, - paint.mBidiFlags, paint.mNativePaint); + paint.mBidiFlags, paint.mNativePaint, paint.mNativeTypeface); } else if (text instanceof GraphicsOperations) { ((GraphicsOperations) text).drawText(this, start, end, x, y, paint); @@ -1464,7 +1464,7 @@ public class Canvas { char[] buf = TemporaryBuffer.obtain(end - start); TextUtils.getChars(text, start, end, buf, 0); native_drawText(mNativeCanvas, buf, 0, end - start, x, y, - paint.mBidiFlags, paint.mNativePaint); + paint.mBidiFlags, paint.mNativePaint, paint.mNativeTypeface); TemporaryBuffer.recycle(buf); } } @@ -1507,7 +1507,7 @@ public class Canvas { } native_drawTextRun(mNativeCanvas, text, index, count, - contextIndex, contextCount, x, y, dir, paint.mNativePaint); + contextIndex, contextCount, x, y, dir, paint.mNativePaint, paint.mNativeTypeface); } /** @@ -1545,7 +1545,7 @@ public class Canvas { if (text instanceof String || text instanceof SpannedString || text instanceof SpannableString) { native_drawTextRun(mNativeCanvas, text.toString(), start, end, - contextStart, contextEnd, x, y, flags, paint.mNativePaint); + contextStart, contextEnd, x, y, flags, paint.mNativePaint, paint.mNativeTypeface); } else if (text instanceof GraphicsOperations) { ((GraphicsOperations) text).drawTextRun(this, start, end, contextStart, contextEnd, x, y, flags, paint); @@ -1555,7 +1555,7 @@ public class Canvas { char[] buf = TemporaryBuffer.obtain(contextLen); TextUtils.getChars(text, contextStart, contextEnd, buf, 0); native_drawTextRun(mNativeCanvas, buf, start - contextStart, len, - 0, contextLen, x, y, flags, paint.mNativePaint); + 0, contextLen, x, y, flags, paint.mNativePaint, paint.mNativeTypeface); TemporaryBuffer.recycle(buf); } } @@ -1814,18 +1814,18 @@ public class Canvas { private static native void native_drawText(int nativeCanvas, char[] text, int index, int count, float x, - float y, int flags, int paint); + float y, int flags, int paint, int typeface); private static native void native_drawText(int nativeCanvas, String text, int start, int end, float x, - float y, int flags, int paint); + float y, int flags, int paint, int typeface); private static native void native_drawTextRun(int nativeCanvas, String text, int start, int end, int contextStart, int contextEnd, - float x, float y, int flags, int paint); + float x, float y, int flags, int paint, int typeface); private static native void native_drawTextRun(int nativeCanvas, char[] text, int start, int count, int contextStart, int contextCount, - float x, float y, int flags, int paint); + float x, float y, int flags, int paint, int typeface); private static native void native_drawPosText(int nativeCanvas, char[] text, int index, diff --git a/graphics/java/android/graphics/ColorFilter.java b/graphics/java/android/graphics/ColorFilter.java index e5cf830..8e0af77 100644 --- a/graphics/java/android/graphics/ColorFilter.java +++ b/graphics/java/android/graphics/ColorFilter.java @@ -21,22 +21,30 @@ package android.graphics; - +/** + * A color filter can be used with a {@link Paint} to modify the color of + * each pixel drawn with that paint. This is an abstract class that should + * never be used directly. + */ public class ColorFilter { + // Holds the pointer to the native SkColorFilter instance int native_instance; /** + * Holds the pointer to the native SkiaColorFilter instance, from libhwui. + * * @hide */ public int nativeColorFilter; + @Override protected void finalize() throws Throwable { try { super.finalize(); } finally { - finalizer(native_instance, nativeColorFilter); + destroyFilter(native_instance, nativeColorFilter); } } - private static native void finalizer(int native_instance, int nativeColorFilter); + static native void destroyFilter(int native_instance, int nativeColorFilter); } diff --git a/graphics/java/android/graphics/ColorMatrix.java b/graphics/java/android/graphics/ColorMatrix.java index c22cda1..0ef037d 100644 --- a/graphics/java/android/graphics/ColorMatrix.java +++ b/graphics/java/android/graphics/ColorMatrix.java @@ -18,23 +18,29 @@ package android.graphics; import android.util.FloatMath; +import java.util.Arrays; + /** - * 5x4 matrix for transforming the color+alpha components of a Bitmap. - * The matrix is stored in a single array, and its treated as follows: + * 5x4 matrix for transforming the color+alpha components of a Bitmap. + * The matrix is stored in a single array, and its treated as follows: + * <pre> * [ a, b, c, d, e, * f, g, h, i, j, * k, l, m, n, o, * p, q, r, s, t ] + * </pre> * - * When applied to a color [r, g, b, a], the resulting color is computed as - * (after clamping) + * When applied to a color <code>[r, g, b, a]</code>, the resulting color + * is computed as (after clamping): + * <pre> * R' = a*R + b*G + c*B + d*A + e; * G' = f*R + g*G + h*B + i*A + j; * B' = k*R + l*G + m*B + n*A + o; * A' = p*R + q*G + r*B + s*A + t; + * </pre> */ +@SuppressWarnings({ "MismatchedReadAndWriteOfArray", "PointlessArithmeticExpression" }) public class ColorMatrix { - private final float[] mArray = new float[20]; /** @@ -66,17 +72,16 @@ public class ColorMatrix { /** * Set this colormatrix to identity: + * <pre> * [ 1 0 0 0 0 - red vector * 0 1 0 0 0 - green vector * 0 0 1 0 0 - blue vector * 0 0 0 1 0 ] - alpha vector + * </pre> */ public void reset() { final float[] a = mArray; - - for (int i = 19; i > 0; --i) { - a[i] = 0; - } + Arrays.fill(a, 0); a[0] = a[6] = a[12] = a[18] = 1; } @@ -112,9 +117,9 @@ public class ColorMatrix { /** * Set the rotation on a color axis by the specified values. - * axis=0 correspond to a rotation around the RED color - * axis=1 correspond to a rotation around the GREEN color - * axis=2 correspond to a rotation around the BLUE color + * <code>axis=0</code> correspond to a rotation around the RED color + * <code>axis=1</code> correspond to a rotation around the GREEN color + * <code>axis=2</code> correspond to a rotation around the BLUE color */ public void setRotate(int axis, float degrees) { reset(); @@ -144,7 +149,7 @@ public class ColorMatrix { throw new RuntimeException(); } } - + /** * Set this colormatrix to the concatenation of the two specified * colormatrices, such that the resulting colormatrix has the same effect @@ -152,12 +157,10 @@ public class ColorMatrix { * matB to be the same colormatrix as this. */ public void setConcat(ColorMatrix matA, ColorMatrix matB) { - float[] tmp = null; - + float[] tmp; if (matA == this || matB == this) { tmp = new float[20]; - } - else { + } else { tmp = mArray; } @@ -178,7 +181,7 @@ public class ColorMatrix { System.arraycopy(tmp, 0, mArray, 0, 20); } } - + /** * Concat this colormatrix with the specified prematrix. This is logically * the same as calling setConcat(this, prematrix); @@ -186,7 +189,7 @@ public class ColorMatrix { public void preConcat(ColorMatrix prematrix) { setConcat(this, prematrix); } - + /** * Concat this colormatrix with the specified postmatrix. This is logically * the same as calling setConcat(postmatrix, this); @@ -194,7 +197,7 @@ public class ColorMatrix { public void postConcat(ColorMatrix postmatrix) { setConcat(postmatrix, this); } - + /////////////////////////////////////////////////////////////////////////// /** diff --git a/graphics/java/android/graphics/ColorMatrixColorFilter.java b/graphics/java/android/graphics/ColorMatrixColorFilter.java index 4f32342..8de32ec 100644 --- a/graphics/java/android/graphics/ColorMatrixColorFilter.java +++ b/graphics/java/android/graphics/ColorMatrixColorFilter.java @@ -16,24 +16,31 @@ package android.graphics; +/** + * A color filter that transforms colors through a 4x5 color matrix. This filter + * can be used to change the saturation of pixels, convert from YUV to RGB, etc. + * + * @see ColorMatrix + */ public class ColorMatrixColorFilter extends ColorFilter { + private final ColorMatrix mMatrix = new ColorMatrix(); + /** - * Create a colorfilter that transforms colors through a 4x5 color matrix. + * Create a color filter that transforms colors through a 4x5 color matrix. * * @param matrix 4x5 matrix used to transform colors. It is copied into * the filter, so changes made to the matrix after the filter * is constructed will not be reflected in the filter. */ public ColorMatrixColorFilter(ColorMatrix matrix) { - final float[] colorMatrix = matrix.getArray(); - native_instance = nativeColorMatrixFilter(colorMatrix); - nativeColorFilter = nColorMatrixFilter(native_instance, colorMatrix); + mMatrix.set(matrix); + update(); } /** - * Create a colorfilter that transforms colors through a 4x5 color matrix. + * Create a color filter that transforms colors through a 4x5 color matrix. * - * @param array array of floats used to transform colors, treated as a 4x5 + * @param array Array of floats used to transform colors, treated as a 4x5 * matrix. The first 20 entries of the array are copied into * the filter. See ColorMatrix. */ @@ -41,8 +48,75 @@ public class ColorMatrixColorFilter extends ColorFilter { if (array.length < 20) { throw new ArrayIndexOutOfBoundsException(); } - native_instance = nativeColorMatrixFilter(array); - nativeColorFilter = nColorMatrixFilter(native_instance, array); + mMatrix.set(array); + update(); + } + + /** + * Returns the {@link ColorMatrix} used by this filter. The returned + * value is never null. Modifying the returned matrix does not have + * any effect until you call {@link #setColorMatrix(ColorMatrix)}. + * + * @see #setColorMatrix(ColorMatrix) + */ + public ColorMatrix getColorMatrix() { + return mMatrix; + } + + /** + * Specifies the color matrix used by this filter. If the specified + * color matrix is null, this filter's color matrix will be reset to + * the identity matrix. + * + * @param matrix A {@link ColorMatrix} or null + * + * @see #getColorMatrix() + * @see android.graphics.ColorMatrix#reset() + * @see #setColorMatrix(float[]) + */ + public void setColorMatrix(ColorMatrix matrix) { + if (matrix == null) { + mMatrix.reset(); + } else if (matrix != mMatrix) { + mMatrix.set(matrix); + } + update(); + } + + /** + * Specifies the color matrix used by this filter. If the specified + * color matrix is null, this filter's color matrix will be reset to + * the identity matrix. + * + * @param array Array of floats used to transform colors, treated as a 4x5 + * matrix. The first 20 entries of the array are copied into + * the filter. See {@link ColorMatrix}. + * + * @see #getColorMatrix() + * @see android.graphics.ColorMatrix#reset() + * @see #setColorMatrix(ColorMatrix) + * + * @throws ArrayIndexOutOfBoundsException if the specified array's + * length is < 20 + */ + public void setColorMatrix(float[] array) { + if (array == null) { + mMatrix.reset(); + } else { + if (array.length < 20) { + throw new ArrayIndexOutOfBoundsException(); + } + + mMatrix.set(array); + } + update(); + } + + private void update() { + final float[] colorMatrix = mMatrix.getArray(); + destroyFilter(native_instance, nativeColorFilter); + native_instance = nativeColorMatrixFilter(colorMatrix); + nativeColorFilter = nColorMatrixFilter(native_instance, colorMatrix); } private static native int nativeColorMatrixFilter(float[] array); diff --git a/graphics/java/android/graphics/ImageFormat.java b/graphics/java/android/graphics/ImageFormat.java index 1bcfc18..e08ed50 100644 --- a/graphics/java/android/graphics/ImageFormat.java +++ b/graphics/java/android/graphics/ImageFormat.java @@ -187,6 +187,10 @@ public class ImageFormat { * == {@link android.media.Image.Plane#getPixelStride() vPlane.getPixelStride()}; * ).</p> * + * <p>For example, the {@link android.media.Image} object can provide data + * in this format from a {@link android.hardware.camera2.CameraDevice} + * through a {@link android.media.ImageReader} object.</p> + * * @see android.media.Image * @see android.media.ImageReader * @see android.hardware.camera2.CameraDevice @@ -203,8 +207,6 @@ public class ImageFormat { * needed information to interpret a raw sensor image must be queried from * the {@link android.hardware.camera2.CameraDevice} which produced the * image.</p> - * - * @hide */ public static final int RAW_SENSOR = 0x20; diff --git a/graphics/java/android/graphics/LargeBitmap.java b/graphics/java/android/graphics/LargeBitmap.java index 6656b17..c70c709 100644 --- a/graphics/java/android/graphics/LargeBitmap.java +++ b/graphics/java/android/graphics/LargeBitmap.java @@ -16,16 +16,6 @@ package android.graphics; -import android.os.Parcel; -import android.os.Parcelable; -import android.util.DisplayMetrics; - -import java.io.OutputStream; -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.nio.ShortBuffer; - /** * LargeBitmap can be used to decode a rectangle region from an image. * LargeBimap is particularly useful when an original image is large and diff --git a/graphics/java/android/graphics/LightingColorFilter.java b/graphics/java/android/graphics/LightingColorFilter.java index c621de6..75f1827 100644 --- a/graphics/java/android/graphics/LightingColorFilter.java +++ b/graphics/java/android/graphics/LightingColorFilter.java @@ -21,16 +21,87 @@ package android.graphics; +/** + * A color filter that can be used to simulate simple lighting effects. + * A <code>LightingColorFilter</code> is defined by two parameters, one + * used to multiply the source color (called <code>colorMultiply</code>) + * and one used to add to the source color (called <code>colorAdd</code>). + * The alpha channel is left untouched by this color filter. + * + * Given a source color RGB, the resulting R'G'B' color is computed thusly: + * <pre> + * R' = R * colorMultiply.R + colorAdd.R + * G' = G * colorMultiply.G + colorAdd.G + * B' = B * colorMultiply.B + colorAdd.B + * </pre> + * The result is pinned to the <code>[0..255]</code> range for each channel. + */ public class LightingColorFilter extends ColorFilter { + private int mMul; + private int mAdd; /** - * Create a colorfilter that multiplies the RGB channels by one color, and then adds a second color, - * pinning the result for each component to [0..255]. The alpha components of the mul and add arguments - * are ignored. + * Create a colorfilter that multiplies the RGB channels by one color, + * and then adds a second color. The alpha components of the mul and add + * arguments are ignored. + * + * @see #setColorMultiply(int) + * @see #setColorAdd(int) */ public LightingColorFilter(int mul, int add) { - native_instance = native_CreateLightingFilter(mul, add); - nativeColorFilter = nCreateLightingFilter(native_instance, mul, add); + mMul = mul; + mAdd = add; + update(); + } + + /** + * Returns the RGB color used to multiply the source color when the + * color filter is applied. + * + * @see #setColorMultiply(int) + */ + public int getColorMultiply() { + return mMul; + } + + /** + * Specifies the RGB color used to multiply the source color when the + * color filter is applied. + * The alpha channel of this color is ignored. + * + * @see #getColorMultiply() + */ + public void setColorMultiply(int mul) { + mMul = mul; + update(); + } + + /** + * Returns the RGB color that will be added to the source color + * when the color filter is applied. + * + * @see #setColorAdd(int) + */ + public int getColorAdd() { + return mAdd; + } + + /** + * Specifies the RGB that will be added to the source color when + * the color filter is applied. + * The alpha channel of this color is ignored. + * + * @see #getColorAdd() + */ + public void setColorAdd(int add) { + mAdd = add; + update(); + } + + private void update() { + destroyFilter(native_instance, nativeColorFilter); + native_instance = native_CreateLightingFilter(mMul, mAdd); + nativeColorFilter = nCreateLightingFilter(native_instance, mMul, mAdd); } private static native int native_CreateLightingFilter(int mul, int add); diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java index 5fc2588..c2d4df2 100644 --- a/graphics/java/android/graphics/Paint.java +++ b/graphics/java/android/graphics/Paint.java @@ -33,6 +33,10 @@ public class Paint { * @hide */ public int mNativePaint; + /** + * @hide + */ + public int mNativeTypeface; private ColorFilter mColorFilter; private MaskFilter mMaskFilter; @@ -481,6 +485,7 @@ public class Paint { mRasterizer = null; mShader = null; mTypeface = null; + mNativeTypeface = 0; mXfermode = null; mHasCompatScaling = false; @@ -525,6 +530,7 @@ public class Paint { mShader = null; } mTypeface = paint.mTypeface; + mNativeTypeface = paint.mNativeTypeface; mXfermode = paint.mXfermode; mHasCompatScaling = paint.mHasCompatScaling; @@ -1087,6 +1093,7 @@ public class Paint { } native_setTypeface(mNativePaint, typefaceNative); mTypeface = typeface; + mNativeTypeface = typefaceNative; return typeface; } diff --git a/graphics/java/android/graphics/Path.java b/graphics/java/android/graphics/Path.java index 5b04a91..1a7e3ec 100644 --- a/graphics/java/android/graphics/Path.java +++ b/graphics/java/android/graphics/Path.java @@ -16,8 +16,6 @@ package android.graphics; -import android.view.HardwareRenderer; - /** * The Path class encapsulates compound (multiple contour) geometric paths * consisting of straight line segments, quadratic curves, and cubic curves. @@ -39,7 +37,6 @@ public class Path { * @hide */ public Region rects; - private boolean mDetectSimplePaths; private Direction mLastDirection = null; /** @@ -47,7 +44,6 @@ public class Path { */ public Path() { mNativePath = init1(); - mDetectSimplePaths = HardwareRenderer.isAvailable(); } /** @@ -65,7 +61,6 @@ public class Path { } } mNativePath = init2(valNative); - mDetectSimplePaths = HardwareRenderer.isAvailable(); } /** @@ -74,10 +69,8 @@ public class Path { */ public void reset() { isSimplePath = true; - if (mDetectSimplePaths) { - mLastDirection = null; - if (rects != null) rects.setEmpty(); - } + mLastDirection = null; + if (rects != null) rects.setEmpty(); // We promised not to change this, so preserve it around the native // call, which does now reset fill type. final FillType fillType = getFillType(); @@ -91,10 +84,8 @@ public class Path { */ public void rewind() { isSimplePath = true; - if (mDetectSimplePaths) { - mLastDirection = null; - if (rects != null) rects.setEmpty(); - } + mLastDirection = null; + if (rects != null) rects.setEmpty(); native_rewind(mNativePath); } @@ -475,16 +466,14 @@ public class Path { } private void detectSimplePath(float left, float top, float right, float bottom, Direction dir) { - if (mDetectSimplePaths) { - if (mLastDirection == null) { - mLastDirection = dir; - } - if (mLastDirection != dir) { - isSimplePath = false; - } else { - if (rects == null) rects = new Region(); - rects.op((int) left, (int) top, (int) right, (int) bottom, Region.Op.UNION); - } + if (mLastDirection == null) { + mLastDirection = dir; + } + if (mLastDirection != dir) { + isSimplePath = false; + } else { + if (rects == null) rects = new Region(); + rects.op((int) left, (int) top, (int) right, (int) bottom, Region.Op.UNION); } } @@ -703,6 +692,28 @@ public class Path { return mNativePath; } + /** + * Approximate the <code>Path</code> with a series of line segments. + * This returns float[] with the array containing point components. + * There are three components for each point, in order: + * <ul> + * <li>Fraction along the length of the path that the point resides</li> + * <li>The x coordinate of the point</li> + * <li>The y coordinate of the point</li> + * </ul> + * <p>Two points may share the same fraction along its length when there is + * a move action within the Path.</p> + * + * @param acceptableError The acceptable error for a line on the + * Path. Typically this would be 0.5 so that + * the error is less than half a pixel. + * @return An array of components for points approximating the Path. + * @hide + */ + public float[] approximate(float acceptableError) { + return native_approximate(mNativePath, acceptableError); + } + private static native int init1(); private static native int init2(int nPath); private static native void native_reset(int nPath); @@ -749,4 +760,5 @@ public class Path { private static native void native_transform(int nPath, int matrix); private static native boolean native_op(int path1, int path2, int op, int result); private static native void finalizer(int nPath); + private static native float[] native_approximate(int nPath, float error); } diff --git a/graphics/java/android/graphics/PorterDuffColorFilter.java b/graphics/java/android/graphics/PorterDuffColorFilter.java index ecc7c24..9870ad2 100644 --- a/graphics/java/android/graphics/PorterDuffColorFilter.java +++ b/graphics/java/android/graphics/PorterDuffColorFilter.java @@ -16,17 +16,84 @@ package android.graphics; +/** + * A color filter that can be used to tint the source pixels using a single + * color and a specific {@link PorterDuff Porter-Duff composite mode}. + */ public class PorterDuffColorFilter extends ColorFilter { + private int mColor; + private PorterDuff.Mode mMode; + + /** + * Create a color filter that uses the specified color and Porter-Duff mode. + * + * @param color The ARGB source color used with the specified Porter-Duff mode + * @param mode The porter-duff mode that is applied + * + * @see Color + * @see #setColor(int) + * @see #setMode(android.graphics.PorterDuff.Mode) + */ + public PorterDuffColorFilter(int color, PorterDuff.Mode mode) { + mColor = color; + mMode = mode; + update(); + } + + /** + * Returns the ARGB color used to tint the source pixels when this filter + * is applied. + * + * @see Color + * @see #setColor(int) + */ + public int getColor() { + return mColor; + } + /** - * Create a colorfilter that uses the specified color and porter-duff mode. + * Specifies the color to tint the source pixels with when this color + * filter is applied. * - * @param srcColor The source color used with the specified - * porter-duff mode - * @param mode The porter-duff mode that is applied + * @param color An ARGB {@link Color color} + * + * @see Color + * @see #getColor() + * @see #getMode() */ - public PorterDuffColorFilter(int srcColor, PorterDuff.Mode mode) { - native_instance = native_CreatePorterDuffFilter(srcColor, mode.nativeInt); - nativeColorFilter = nCreatePorterDuffFilter(native_instance, srcColor, mode.nativeInt); + public void setColor(int color) { + mColor = color; + update(); + } + + /** + * Returns the Porter-Duff mode used to composite this color filter's + * color with the source pixel when this filter is applied. + * + * @see PorterDuff + * @see #setMode(android.graphics.PorterDuff.Mode) + */ + public PorterDuff.Mode getMode() { + return mMode; + } + + /** + * Specifies the Porter-Duff mode to use when compositing this color + * filter's color with the source pixel at draw time. + * + * @see PorterDuff + * @see #getMode() + * @see #getColor() + */ + public void setMode(PorterDuff.Mode mode) { + mMode = mode; + update(); + } + + private void update() { + destroyFilter(native_instance, nativeColorFilter); + native_instance = native_CreatePorterDuffFilter(mColor, mMode.nativeInt); + nativeColorFilter = nCreatePorterDuffFilter(native_instance, mColor, mMode.nativeInt); } private static native int native_CreatePorterDuffFilter(int srcColor, int porterDuffMode); diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java index c68c9f7..aea3ee5 100644 --- a/graphics/java/android/graphics/Typeface.java +++ b/graphics/java/android/graphics/Typeface.java @@ -48,7 +48,10 @@ public class Typeface { private static final SparseArray<SparseArray<Typeface>> sTypefaceCache = new SparseArray<SparseArray<Typeface>>(3); - int native_instance; + /** + * @hide + */ + public int native_instance; // Style public static final int NORMAL = 0; diff --git a/graphics/java/android/graphics/drawable/AnimationDrawable.java b/graphics/java/android/graphics/drawable/AnimationDrawable.java index bde978d..02b2588 100644 --- a/graphics/java/android/graphics/drawable/AnimationDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimationDrawable.java @@ -81,6 +81,7 @@ import android.util.AttributeSet; public class AnimationDrawable extends DrawableContainer implements Runnable, Animatable { private final AnimationState mAnimationState; private int mCurFrame = -1; + private boolean mAnimating; private boolean mMutated; public AnimationDrawable() { @@ -137,7 +138,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An * @return true if the animation is running, false otherwise */ public boolean isRunning() { - return mCurFrame > -1; + return mAnimating; } /** @@ -153,6 +154,7 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An @Override public void unscheduleSelf(Runnable what) { mCurFrame = -1; + mAnimating = false; super.unscheduleSelf(what); } @@ -222,12 +224,13 @@ public class AnimationDrawable extends DrawableContainer implements Runnable, An } mCurFrame = frame; selectDrawable(frame); - if (unschedule) { + if (unschedule || animate) { unscheduleSelf(this); } if (animate) { - // Unscheduling may have clobbered this value; restore it to record that we're animating + // Unscheduling may have clobbered these values; restore them mCurFrame = frame; + mAnimating = true; scheduleSelf(this, SystemClock.uptimeMillis() + mAnimationState.mDurations[frame]); } } diff --git a/graphics/java/android/graphics/drawable/Drawable.java b/graphics/java/android/graphics/drawable/Drawable.java index 93738b0..c84cdb0 100644 --- a/graphics/java/android/graphics/drawable/Drawable.java +++ b/graphics/java/android/graphics/drawable/Drawable.java @@ -39,6 +39,7 @@ import android.util.DisplayMetrics; import android.util.StateSet; import android.util.TypedValue; import android.util.Xml; +import android.view.View; import java.io.IOException; import java.io.InputStream; @@ -399,7 +400,7 @@ public abstract class Drawable { * * @hide */ - public void setLayoutDirection(int layoutDirection) { + public void setLayoutDirection(@View.ResolvedLayoutDir int layoutDirection) { if (getLayoutDirection() != layoutDirection) { mLayoutDirection = layoutDirection; } diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index b340777..ba4698c 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -16,6 +16,7 @@ package android.graphics.drawable; +import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; @@ -24,12 +25,12 @@ import android.graphics.ColorFilter; import android.graphics.DashPathEffect; import android.graphics.LinearGradient; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.PixelFormat; +import android.graphics.RadialGradient; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Shader; -import android.graphics.Path; -import android.graphics.RadialGradient; import android.graphics.SweepGradient; import android.util.AttributeSet; import android.util.Log; @@ -233,6 +234,23 @@ public class GradientDrawable extends Drawable { } /** + * <p>Set the stroke width and color state list for the drawable. If width + * is zero, then no stroke is drawn.</p> + * <p><strong>Note</strong>: changing this property will affect all instances + * of a drawable loaded from a resource. It is recommended to invoke + * {@link #mutate()} before changing this property.</p> + * + * @param width The width in pixels of the stroke + * @param colorStateList The color state list of the stroke + * + * @see #mutate() + * @see #setStroke(int, ColorStateList, float, float) + */ + public void setStroke(int width, ColorStateList colorStateList) { + setStroke(width, colorStateList, 0, 0); + } + + /** * <p>Set the stroke width and color for the drawable. If width is zero, * then no stroke is drawn. This method can also be used to dash the stroke.</p> * <p><strong>Note</strong>: changing this property will affect all instances @@ -249,7 +267,35 @@ public class GradientDrawable extends Drawable { */ public void setStroke(int width, int color, float dashWidth, float dashGap) { mGradientState.setStroke(width, color, dashWidth, dashGap); + setStrokeInternal(width, color, dashWidth, dashGap); + } + /** + * <p>Set the stroke width and color state list for the drawable. If width + * is zero, then no stroke is drawn. This method can also be used to dash + * the stroke.</p> + * <p><strong>Note</strong>: changing this property will affect all instances + * of a drawable loaded from a resource. It is recommended to invoke + * {@link #mutate()} before changing this property.</p> + * + * @param width The width in pixels of the stroke + * @param colorStateList The color state list of the stroke + * @param dashWidth The length in pixels of the dashes, set to 0 to disable dashes + * @param dashGap The gap in pixels between dashes + * + * @see #mutate() + * @see #setStroke(int, ColorStateList) + */ + public void setStroke( + int width, ColorStateList colorStateList, float dashWidth, float dashGap) { + mGradientState.setStroke(width, colorStateList, dashWidth, dashGap); + + final int[] stateSet = getState(); + final int color = colorStateList.getColorForState(stateSet, 0); + setStrokeInternal(width, color, dashWidth, dashGap); + } + + private void setStrokeInternal(int width, int color, float dashWidth, float dashGap) { if (mStrokePaint == null) { mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mStrokePaint.setStyle(Paint.Style.STROKE); @@ -479,7 +525,8 @@ public class GradientDrawable extends Drawable { mFillPaint.setAlpha(currFillAlpha); mFillPaint.setDither(mDither); mFillPaint.setColorFilter(mColorFilter); - if (mColorFilter != null && !mGradientState.mHasSolidColor) { + if (mColorFilter != null && !mGradientState.mHasSolidColor + && mGradientState.mColorStateList == null) { mFillPaint.setColor(mAlpha << 24); } if (haveStroke) { @@ -610,7 +657,7 @@ public class GradientDrawable extends Drawable { } /** - * <p>Changes this drawbale to use a single color instead of a gradient.</p> + * <p>Changes this drawable to use a single color instead of a gradient.</p> * <p><strong>Note</strong>: changing color will affect all instances * of a drawable loaded from a resource. It is recommended to invoke * {@link #mutate()} before changing the color.</p> @@ -626,6 +673,68 @@ public class GradientDrawable extends Drawable { invalidateSelf(); } + /** + * Changes this drawable to use a single color state list instead of a + * gradient. + * <p> + * <strong>Note</strong>: changing color will affect all instances of a + * drawable loaded from a resource. It is recommended to invoke + * {@link #mutate()} before changing the color.</p> + * + * @param colorStateList The color state list used to fill the shape + * @see #mutate() + */ + public void setColor(ColorStateList colorStateList) { + final int color = colorStateList.getColorForState(getState(), 0); + mGradientState.setColorStateList(colorStateList); + mFillPaint.setColor(color); + invalidateSelf(); + } + + @Override + public boolean onStateChange(int[] stateSet) { + boolean invalidateSelf = false; + + final GradientState s = mGradientState; + final ColorStateList stateList = s.mColorStateList; + if (stateList != null) { + final int newColor = stateList.getColorForState(stateSet, 0); + final int oldColor = mFillPaint.getColor(); + if (oldColor != newColor) { + mFillPaint.setColor(newColor); + invalidateSelf = true; + } + } + + final Paint strokePaint = mStrokePaint; + if (strokePaint != null) { + final ColorStateList strokeStateList = s.mStrokeColorStateList; + if (strokeStateList != null) { + final int newStrokeColor = strokeStateList.getColorForState(stateSet, 0); + final int oldStrokeColor = strokePaint.getColor(); + if (oldStrokeColor != newStrokeColor) { + strokePaint.setColor(newStrokeColor); + invalidateSelf = true; + } + } + } + + if (invalidateSelf) { + invalidateSelf(); + return true; + } + + return false; + } + + @Override + public boolean isStateful() { + final GradientState s = mGradientState; + return super.isStateful() + || (s.mColorStateList != null && s.mColorStateList.isStateful()) + || (s.mStrokeColorStateList != null && s.mStrokeColorStateList.isStateful()); + } + @Override public int getChangingConfigurations() { return super.getChangingConfigurations() | mGradientState.mChangingConfigurations; @@ -791,7 +900,7 @@ public class GradientDrawable extends Drawable { // If we don't have a solid color, the alpha channel must be // maxed out so that alpha modulation works correctly. - if (!st.mHasSolidColor) { + if (!st.mHasSolidColor && st.mColorStateList == null) { mFillPaint.setColor(Color.BLACK); } } @@ -967,25 +1076,25 @@ public class GradientDrawable extends Drawable { } else if (name.equals("solid")) { a = r.obtainAttributes(attrs, com.android.internal.R.styleable.GradientDrawableSolid); - int argb = a.getColor( - com.android.internal.R.styleable.GradientDrawableSolid_color, 0); + final ColorStateList colorStateList = a.getColorStateList( + com.android.internal.R.styleable.GradientDrawableSolid_color); a.recycle(); - setColor(argb); + setColor(colorStateList); } else if (name.equals("stroke")) { a = r.obtainAttributes(attrs, com.android.internal.R.styleable.GradientDrawableStroke); - int width = a.getDimensionPixelSize( + final int width = a.getDimensionPixelSize( com.android.internal.R.styleable.GradientDrawableStroke_width, 0); - int color = a.getColor( - com.android.internal.R.styleable.GradientDrawableStroke_color, 0); - float dashWidth = a.getDimension( + final ColorStateList colorStateList = a.getColorStateList( + com.android.internal.R.styleable.GradientDrawableStroke_color); + final float dashWidth = a.getDimension( com.android.internal.R.styleable.GradientDrawableStroke_dashWidth, 0); if (dashWidth != 0.0f) { - float dashGap = a.getDimension( + final float dashGap = a.getDimension( com.android.internal.R.styleable.GradientDrawableStroke_dashGap, 0); - setStroke(width, color, dashWidth, dashGap); + setStroke(width, colorStateList, dashWidth, dashGap); } else { - setStroke(width, color); + setStroke(width, colorStateList); } a.recycle(); } else if (name.equals("corners")) { @@ -1077,6 +1186,8 @@ public class GradientDrawable extends Drawable { public int mShape = RECTANGLE; public int mGradient = LINEAR_GRADIENT; public Orientation mOrientation; + public ColorStateList mColorStateList; + public ColorStateList mStrokeColorStateList; public int[] mColors; public int[] mTempColors; // no need to copy public float[] mTempPositions; // no need to copy @@ -1113,6 +1224,7 @@ public class GradientDrawable extends Drawable { mShape = state.mShape; mGradient = state.mGradient; mOrientation = state.mOrientation; + mColorStateList = state.mColorStateList; if (state.mColors != null) { mColors = state.mColors.clone(); } @@ -1178,6 +1290,7 @@ public class GradientDrawable extends Drawable { public void setColors(int[] colors) { mHasSolidColor = false; mColors = colors; + mColorStateList = null; computeOpacity(); } @@ -1185,6 +1298,14 @@ public class GradientDrawable extends Drawable { mHasSolidColor = true; mSolidColor = argb; mColors = null; + mColorStateList = null; + computeOpacity(); + } + + public void setColorStateList(ColorStateList colorStateList) { + mHasSolidColor = false; + mColors = null; + mColorStateList = colorStateList; computeOpacity(); } @@ -1199,11 +1320,23 @@ public class GradientDrawable extends Drawable { return; } - if (mStrokeWidth > 0 && !isOpaque(mStrokeColor)) { + if (mStrokeWidth > 0) { + if (mStrokeColorStateList != null) { + if (!mStrokeColorStateList.isOpaque()) { + mOpaque = false; + return; + } + } else if (!isOpaque(mStrokeColor)) { + mOpaque = false; + return; + } + } + + if (mColorStateList != null && !mColorStateList.isOpaque()) { mOpaque = false; return; } - + if (mHasSolidColor) { mOpaque = isOpaque(mSolidColor); return; @@ -1228,12 +1361,23 @@ public class GradientDrawable extends Drawable { public void setStroke(int width, int color) { mStrokeWidth = width; mStrokeColor = color; + mStrokeColorStateList = null; computeOpacity(); } public void setStroke(int width, int color, float dashWidth, float dashGap) { mStrokeWidth = width; mStrokeColor = color; + mStrokeColorStateList = null; + mStrokeDashWidth = dashWidth; + mStrokeDashGap = dashGap; + computeOpacity(); + } + + public void setStroke( + int width, ColorStateList colorStateList, float dashWidth, float dashGap) { + mStrokeWidth = width; + mStrokeColorStateList = colorStateList; mStrokeDashWidth = dashWidth; mStrokeDashGap = dashGap; computeOpacity(); @@ -1274,6 +1418,10 @@ public class GradientDrawable extends Drawable { private void initializeWithState(GradientState state) { if (state.mHasSolidColor) { mFillPaint.setColor(state.mSolidColor); + } else if (state.mColorStateList != null) { + final int[] currentState = getState(); + final int stateColor = state.mColorStateList.getColorForState(currentState, 0); + mFillPaint.setColor(stateColor); } else if (state.mColors == null) { // If we don't have a solid color and we don't have a gradient, // the app is stroking the shape, set the color to the default diff --git a/graphics/java/android/graphics/drawable/PictureDrawable.java b/graphics/java/android/graphics/drawable/PictureDrawable.java index 1f5d4d8..cb2d8f6 100644 --- a/graphics/java/android/graphics/drawable/PictureDrawable.java +++ b/graphics/java/android/graphics/drawable/PictureDrawable.java @@ -16,16 +16,12 @@ package android.graphics.drawable; -import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.ColorFilter; -import android.graphics.Matrix; -import android.graphics.Matrix.ScaleToFit; import android.graphics.drawable.Drawable; import android.graphics.Picture; import android.graphics.PixelFormat; import android.graphics.Rect; -import android.view.Gravity; /** * Drawable subclass that wraps a Picture, allowing the picture to be used diff --git a/graphics/java/android/graphics/drawable/shapes/ArcShape.java b/graphics/java/android/graphics/drawable/shapes/ArcShape.java index b90e853..84731b0 100644 --- a/graphics/java/android/graphics/drawable/shapes/ArcShape.java +++ b/graphics/java/android/graphics/drawable/shapes/ArcShape.java @@ -18,7 +18,6 @@ package android.graphics.drawable.shapes; import android.graphics.Canvas; import android.graphics.Paint; -import android.graphics.RectF; /** * Creates an arc shape. The arc shape starts at a specified diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index dca934f..45dd25a 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -16,17 +16,12 @@ package android.renderscript; -import java.io.IOException; -import java.io.InputStream; import java.util.HashMap; import android.content.res.Resources; -import android.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.view.Surface; -import android.graphics.SurfaceTexture; import android.util.Log; -import android.util.TypedValue; import android.graphics.Canvas; import android.os.Trace; @@ -78,10 +73,69 @@ public class Allocation extends BaseObj { int mCurrentDimY; int mCurrentDimZ; int mCurrentCount; - static HashMap<Integer, Allocation> mAllocationMap = - new HashMap<Integer, Allocation>(); + static HashMap<Long, Allocation> mAllocationMap = + new HashMap<Long, Allocation>(); OnBufferAvailableListener mBufferNotifier; + private Element.DataType validateObjectIsPrimitiveArray(Object d, boolean checkType) { + final Class c = d.getClass(); + if (!c.isArray()) { + throw new RSIllegalArgumentException("Object passed is not an array of primitives."); + } + final Class cmp = c.getComponentType(); + if (!cmp.isPrimitive()) { + throw new RSIllegalArgumentException("Object passed is not an Array of primitives."); + } + + if (cmp == Long.TYPE) { + if (checkType) { + validateIsInt64(); + return mType.mElement.mType; + } + return Element.DataType.SIGNED_64; + } + + if (cmp == Integer.TYPE) { + if (checkType) { + validateIsInt32(); + return mType.mElement.mType; + } + return Element.DataType.SIGNED_32; + } + + if (cmp == Short.TYPE) { + if (checkType) { + validateIsInt16(); + return mType.mElement.mType; + } + return Element.DataType.SIGNED_16; + } + + if (cmp == Byte.TYPE) { + if (checkType) { + validateIsInt8(); + return mType.mElement.mType; + } + return Element.DataType.SIGNED_8; + } + + if (cmp == Float.TYPE) { + if (checkType) { + validateIsFloat32(); + } + return Element.DataType.FLOAT_32; + } + + if (cmp == Double.TYPE) { + if (checkType) { + validateIsFloat64(); + } + return Element.DataType.FLOAT_64; + } + return null; + } + + /** * The usage of the Allocation. These signal to RenderScript where to place * the Allocation in memory. @@ -127,17 +181,17 @@ public class Allocation extends BaseObj { public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010; /** - * The Allocation will be used as a {@link android.graphics.SurfaceTexture} - * consumer. This usage will cause the Allocation to be created as - * read-only. + * The Allocation will be used as a {@link android.view.Surface} + * consumer. This usage will cause the Allocation to be created + * as read-only. * */ public static final int USAGE_IO_INPUT = 0x0020; /** - * The Allocation will be used as a {@link android.graphics.SurfaceTexture} + * The Allocation will be used as a {@link android.view.Surface} * producer. The dimensions and format of the {@link - * android.graphics.SurfaceTexture} will be forced to those of the + * android.view.Surface} will be forced to those of the * Allocation. * */ @@ -188,7 +242,7 @@ public class Allocation extends BaseObj { } - private int getIDSafe() { + private long getIDSafe() { if (mAdaptedAllocation != null) { return mAdaptedAllocation.getID(mRS); } @@ -244,7 +298,7 @@ public class Allocation extends BaseObj { mBitmap = b; } - Allocation(int id, RenderScript rs, Type t, int usage) { + Allocation(long id, RenderScript rs, Type t, int usage) { super(id, rs); if ((usage & ~(USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE | @@ -290,6 +344,15 @@ public class Allocation extends BaseObj { super.finalize(); } + private void validateIsInt64() { + if ((mType.mElement.mType == Element.DataType.SIGNED_64) || + (mType.mElement.mType == Element.DataType.UNSIGNED_64)) { + return; + } + throw new RSIllegalArgumentException( + "64 bit integer source does not match allocation type " + mType.mElement.mType); + } + private void validateIsInt32() { if ((mType.mElement.mType == Element.DataType.SIGNED_32) || (mType.mElement.mType == Element.DataType.UNSIGNED_32)) { @@ -325,6 +388,14 @@ public class Allocation extends BaseObj { "32 bit float source does not match allocation type " + mType.mElement.mType); } + private void validateIsFloat64() { + if (mType.mElement.mType == Element.DataType.FLOAT_64) { + return; + } + throw new RSIllegalArgumentException( + "64 bit float source does not match allocation type " + mType.mElement.mType); + } + private void validateIsObject() { if ((mType.mElement.mType == Element.DataType.RS_ELEMENT) || (mType.mElement.mType == Element.DataType.RS_TYPE) || @@ -345,7 +416,7 @@ public class Allocation extends BaseObj { @Override void updateFromNative() { super.updateFromNative(); - int typeID = mRS.nAllocationGetType(getID(mRS)); + long typeID = mRS.nAllocationGetType(getID(mRS)); if(typeID != 0) { mType = new Type(typeID, mRS); mType.updateFromNative(); @@ -412,14 +483,6 @@ public class Allocation extends BaseObj { } /** - * Delete once code is updated. - * @hide - */ - public void ioSendOutput() { - ioSend(); - } - - /** * Receive the latest input into the Allocation. This operation * is only valid if {@link #USAGE_IO_INPUT} is set on the Allocation. * @@ -448,9 +511,11 @@ public class Allocation extends BaseObj { throw new RSIllegalArgumentException("Array size mismatch, allocation sizeX = " + mCurrentCount + ", array length = " + d.length); } + // FIXME: requires 64-bit path + int i[] = new int[d.length]; for (int ct=0; ct < d.length; ct++) { - i[ct] = d[ct].getID(mRS); + i[ct] = (int)d[ct].getID(mRS); } copy1DRangeFromUnchecked(0, mCurrentCount, i); Trace.traceEnd(RenderScript.TRACE_TAG); @@ -511,23 +576,30 @@ public class Allocation extends BaseObj { } } + private void copyFromUnchecked(Object array, Element.DataType dt, int arrayLen) { + Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked"); + mRS.validate(); + if (mCurrentDimZ > 0) { + copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, array, dt, arrayLen); + } else if (mCurrentDimY > 0) { + copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, array, dt, arrayLen); + } else { + copy1DRangeFromUnchecked(0, mCurrentCount, array, dt, arrayLen); + } + Trace.traceEnd(RenderScript.TRACE_TAG); + } + /** * 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. * - * @param d the source data array + * @param array The source data array */ - public void copyFromUnchecked(int[] d) { + public void copyFromUnchecked(Object array) { Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked"); - mRS.validate(); - if (mCurrentDimZ > 0) { - copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d); - } else if (mCurrentDimY > 0) { - copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d); - } else { - copy1DRangeFromUnchecked(0, mCurrentCount, d); - } + copyFromUnchecked(array, validateObjectIsPrimitiveArray(array, false), + java.lang.reflect.Array.getLength(array)); Trace.traceEnd(RenderScript.TRACE_TAG); } @@ -538,17 +610,19 @@ public class Allocation extends BaseObj { * * @param d the source data array */ + public void copyFromUnchecked(int[] d) { + copyFromUnchecked(d, Element.DataType.SIGNED_32, d.length); + } + + /** + * 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. + * + * @param d the source data array + */ public void copyFromUnchecked(short[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked"); - mRS.validate(); - if (mCurrentDimZ > 0) { - copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d); - } else if (mCurrentDimY > 0) { - copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d); - } else { - copy1DRangeFromUnchecked(0, mCurrentCount, d); - } - Trace.traceEnd(RenderScript.TRACE_TAG); + copyFromUnchecked(d, Element.DataType.SIGNED_16, d.length); } /** @@ -559,16 +633,7 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copyFromUnchecked(byte[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked"); - mRS.validate(); - if (mCurrentDimZ > 0) { - copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d); - } else if (mCurrentDimY > 0) { - copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d); - } else { - copy1DRangeFromUnchecked(0, mCurrentCount, d); - } - Trace.traceEnd(RenderScript.TRACE_TAG); + copyFromUnchecked(d, Element.DataType.SIGNED_8, d.length); } /** @@ -579,37 +644,35 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copyFromUnchecked(float[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked"); - mRS.validate(); - if (mCurrentDimZ > 0) { - copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d); - } else if (mCurrentDimY > 0) { - copy2DRangeFromUnchecked(0, 0, mCurrentDimX, mCurrentDimY, d); - } else { - copy1DRangeFromUnchecked(0, mCurrentCount, d); - } - Trace.traceEnd(RenderScript.TRACE_TAG); + copyFromUnchecked(d, Element.DataType.FLOAT_32, d.length); } /** * Copy into this Allocation from an array. This variant is type checked * and will generate exceptions if the Allocation's {@link + * android.renderscript.Element} does not match the array's + * primitive type. + * + * @param array The source data array + */ + public void copyFrom(Object array) { + Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); + copyFromUnchecked(array, validateObjectIsPrimitiveArray(array, true), + java.lang.reflect.Array.getLength(array)); + Trace.traceEnd(RenderScript.TRACE_TAG); + } + + /** + * Copy into this Allocation from an array. This variant is type checked + * and will generate exceptions if the Allocation's {@link * android.renderscript.Element} is not a 32 bit integer type. * * @param d the source data array */ public void copyFrom(int[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); - mRS.validate(); - if (mCurrentDimZ > 0) { - copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d); - } else if (mCurrentDimY > 0) { - copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d); - } else { - copy1DRangeFrom(0, mCurrentCount, d); - } - Trace.traceEnd(RenderScript.TRACE_TAG); + validateIsInt32(); + copyFromUnchecked(d, Element.DataType.SIGNED_32, d.length); } /** @@ -620,16 +683,8 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copyFrom(short[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); - mRS.validate(); - if (mCurrentDimZ > 0) { - copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d); - } else if (mCurrentDimY > 0) { - copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d); - } else { - copy1DRangeFrom(0, mCurrentCount, d); - } - Trace.traceEnd(RenderScript.TRACE_TAG); + validateIsInt16(); + copyFromUnchecked(d, Element.DataType.SIGNED_16, d.length); } /** @@ -640,16 +695,8 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copyFrom(byte[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); - mRS.validate(); - if (mCurrentDimZ > 0) { - copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d); - } else if (mCurrentDimY > 0) { - copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d); - } else { - copy1DRangeFrom(0, mCurrentCount, d); - } - Trace.traceEnd(RenderScript.TRACE_TAG); + validateIsInt8(); + copyFromUnchecked(d, Element.DataType.SIGNED_8, d.length); } /** @@ -660,16 +707,8 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copyFrom(float[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); - mRS.validate(); - if (mCurrentDimZ > 0) { - copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d); - } else if (mCurrentDimY > 0) { - copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, d); - } else { - copy1DRangeFrom(0, mCurrentCount, d); - } - Trace.traceEnd(RenderScript.TRACE_TAG); + validateIsFloat32(); + copyFromUnchecked(d, Element.DataType.FLOAT_32, d.length); } /** @@ -798,6 +837,29 @@ public class Allocation extends BaseObj { mRS.nAllocationGenerateMipmaps(getID(mRS)); } + private void copy1DRangeFromUnchecked(int off, int count, Object array, + Element.DataType dt, int arrayLen) { + Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked"); + final int dataSize = mType.mElement.getBytesSize() * count; + data1DChecks(off, count, arrayLen * dt.mSize, dataSize); + mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt); + Trace.traceEnd(RenderScript.TRACE_TAG); + } + + /** + * Copy an array into part of this Allocation. This method does not + * guarantee that the Allocation is compatible with the input buffer. + * + * @param off The offset of the first element to be copied. + * @param count The number of elements to be copied. + * @param array The source data array + */ + public void copy1DRangeFromUnchecked(int off, int count, Object array) { + copy1DRangeFromUnchecked(off, count, array, + validateObjectIsPrimitiveArray(array, false), + java.lang.reflect.Array.getLength(array)); + } + /** * Copy an array into part of this Allocation. This method does not * guarantee that the Allocation is compatible with the input buffer. @@ -807,11 +869,7 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copy1DRangeFromUnchecked(int off, int count, int[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked"); - int dataSize = mType.mElement.getBytesSize() * count; - data1DChecks(off, count, d.length * 4, dataSize); - mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy1DRangeFromUnchecked(off, count, (Object)d, Element.DataType.SIGNED_32, d.length); } /** @@ -823,11 +881,7 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copy1DRangeFromUnchecked(int off, int count, short[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked"); - int dataSize = mType.mElement.getBytesSize() * count; - data1DChecks(off, count, d.length * 2, dataSize); - mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy1DRangeFromUnchecked(off, count, (Object)d, Element.DataType.SIGNED_16, d.length); } /** @@ -839,11 +893,7 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copy1DRangeFromUnchecked(int off, int count, byte[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked"); - int dataSize = mType.mElement.getBytesSize() * count; - data1DChecks(off, count, d.length, dataSize); - mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy1DRangeFromUnchecked(off, count, (Object)d, Element.DataType.SIGNED_8, d.length); } /** @@ -855,11 +905,23 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copy1DRangeFromUnchecked(int off, int count, float[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked"); - int dataSize = mType.mElement.getBytesSize() * count; - data1DChecks(off, count, d.length * 4, dataSize); - mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy1DRangeFromUnchecked(off, count, (Object)d, Element.DataType.FLOAT_32, d.length); + } + + + /** + * Copy an array into part of this Allocation. This variant is type checked + * and will generate exceptions if the Allocation type does not + * match the component type of the array passed in. + * + * @param off The offset of the first element to be copied. + * @param count The number of elements to be copied. + * @param array The source data array. + */ + public void copy1DRangeFrom(int off, int count, Object array) { + copy1DRangeFromUnchecked(off, count, array, + validateObjectIsPrimitiveArray(array, true), + java.lang.reflect.Array.getLength(array)); } /** @@ -872,10 +934,8 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copy1DRangeFrom(int off, int count, int[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom"); validateIsInt32(); - copy1DRangeFromUnchecked(off, count, d); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy1DRangeFromUnchecked(off, count, d, Element.DataType.SIGNED_32, d.length); } /** @@ -888,10 +948,8 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copy1DRangeFrom(int off, int count, short[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom"); validateIsInt16(); - copy1DRangeFromUnchecked(off, count, d); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy1DRangeFromUnchecked(off, count, d, Element.DataType.SIGNED_16, d.length); } /** @@ -904,10 +962,8 @@ public class Allocation extends BaseObj { * @param d the source data array */ public void copy1DRangeFrom(int off, int count, byte[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom"); validateIsInt8(); - copy1DRangeFromUnchecked(off, count, d); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy1DRangeFromUnchecked(off, count, d, Element.DataType.SIGNED_8, d.length); } /** @@ -920,11 +976,10 @@ public class Allocation extends BaseObj { * @param d the source data array. */ public void copy1DRangeFrom(int off, int count, float[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom"); validateIsFloat32(); - copy1DRangeFromUnchecked(off, count, d); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy1DRangeFromUnchecked(off, count, d, Element.DataType.FLOAT_32, d.length); } + /** * Copy part of an Allocation into this Allocation. * @@ -959,39 +1014,31 @@ public class Allocation extends BaseObj { } } - void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, byte[] data) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked"); - mRS.validate(); - validate2DRange(xoff, yoff, w, h); - mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, - w, h, data, data.length); - Trace.traceEnd(RenderScript.TRACE_TAG); - } - - void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, short[] data) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked"); - mRS.validate(); - validate2DRange(xoff, yoff, w, h); - mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, - w, h, data, data.length * 2); - Trace.traceEnd(RenderScript.TRACE_TAG); - } - - void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, int[] data) { + void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, Object array, + Element.DataType dt, int arrayLen) { Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked"); mRS.validate(); validate2DRange(xoff, yoff, w, h); - mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, - w, h, data, data.length * 4); + mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, + array, arrayLen * dt.mSize, dt); Trace.traceEnd(RenderScript.TRACE_TAG); } - void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, float[] data) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked"); - mRS.validate(); - validate2DRange(xoff, yoff, w, h); - mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, - w, h, data, data.length * 4); + /** + * Copy from an array into a rectangular region in this Allocation. The + * array is assumed to be tightly packed. + * + * @param xoff X offset of the region to update in this Allocation + * @param yoff Y offset of the region to update in this Allocation + * @param w Width of the region to update + * @param h Height of the region to update + * @param array Data to be placed into the Allocation + */ + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, Object array) { + Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom"); + copy2DRangeFromUnchecked(xoff, yoff, w, h, array, + validateObjectIsPrimitiveArray(array, true), + java.lang.reflect.Array.getLength(array)); Trace.traceEnd(RenderScript.TRACE_TAG); } @@ -1006,10 +1053,9 @@ public class Allocation extends BaseObj { * @param data to be placed into the Allocation */ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom"); validateIsInt8(); - copy2DRangeFromUnchecked(xoff, yoff, w, h, data); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy2DRangeFromUnchecked(xoff, yoff, w, h, data, + Element.DataType.SIGNED_8, data.length); } /** @@ -1023,10 +1069,9 @@ public class Allocation extends BaseObj { * @param data to be placed into the Allocation */ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom"); validateIsInt16(); - copy2DRangeFromUnchecked(xoff, yoff, w, h, data); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy2DRangeFromUnchecked(xoff, yoff, w, h, data, + Element.DataType.SIGNED_16, data.length); } /** @@ -1040,10 +1085,9 @@ public class Allocation extends BaseObj { * @param data to be placed into the Allocation */ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom"); validateIsInt32(); - copy2DRangeFromUnchecked(xoff, yoff, w, h, data); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy2DRangeFromUnchecked(xoff, yoff, w, h, data, + Element.DataType.SIGNED_32, data.length); } /** @@ -1057,10 +1101,9 @@ public class Allocation extends BaseObj { * @param data to be placed into the Allocation */ public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom"); validateIsFloat32(); - copy2DRangeFromUnchecked(xoff, yoff, w, h, data); - Trace.traceEnd(RenderScript.TRACE_TAG); + copy2DRangeFromUnchecked(xoff, yoff, w, h, data, + Element.DataType.FLOAT_32, data.length); } /** @@ -1133,49 +1176,18 @@ public class Allocation extends BaseObj { * @hide * */ - void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, byte[] data) { - mRS.validate(); - validate3DRange(xoff, yoff, zoff, w, h, d); - mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, - w, h, d, data, data.length); - } - - /** - * @hide - * - */ - void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, short[] data) { - mRS.validate(); - validate3DRange(xoff, yoff, zoff, w, h, d); - mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, - w, h, d, data, data.length * 2); - } - - /** - * @hide - * - */ - void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, int[] data) { + private void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, + Object array, Element.DataType dt, int arrayLen) { + Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFromUnchecked"); mRS.validate(); validate3DRange(xoff, yoff, zoff, w, h, d); - mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, - w, h, d, data, data.length * 4); + mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d, + array, arrayLen * dt.mSize, dt); + Trace.traceEnd(RenderScript.TRACE_TAG); } /** * @hide - * - */ - void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, float[] data) { - mRS.validate(); - validate3DRange(xoff, yoff, zoff, w, h, d); - mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, - w, h, d, data, data.length * 4); - } - - - /** - * @hide * Copy a rectangular region from the array into the allocation. * The array is assumed to be tightly packed. * @@ -1187,36 +1199,12 @@ public class Allocation extends BaseObj { * @param d Depth of the region to update * @param data to be placed into the allocation */ - public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, byte[] data) { - validateIsInt8(); - copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data); - } - - /** - * @hide - * - */ - public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, short[] data) { - validateIsInt16(); - copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data); - } - - /** - * @hide - * - */ - public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, int[] data) { - validateIsInt32(); - copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data); - } - - /** - * @hide - * - */ - public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, float[] data) { - validateIsFloat32(); - copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, data); + public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, Object array) { + Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFrom"); + copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, array, + validateObjectIsPrimitiveArray(array, true), + java.lang.reflect.Array.getLength(array)); + Trace.traceEnd(RenderScript.TRACE_TAG); } /** @@ -1260,6 +1248,26 @@ public class Allocation extends BaseObj { Trace.traceEnd(RenderScript.TRACE_TAG); } + private void copyTo(Object array, Element.DataType dt, int arrayLen) { + Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); + mRS.validate(); + mRS.nAllocationRead(getID(mRS), array, dt); + Trace.traceEnd(RenderScript.TRACE_TAG); + } + + /** + * Copy from the Allocation into an array. The array must be at + * least as large as the Allocation. The + * {@link android.renderscript.Element} must match the component + * type of the array passed in. + * + * @param array The array to be set from the Allocation. + */ + public void copyTo(Object array) { + copyTo(array, validateObjectIsPrimitiveArray(array, true), + java.lang.reflect.Array.getLength(array)); + } + /** * Copy from the Allocation into a byte array. The array must be at least * as large as the Allocation. The allocation must be of an 8 bit integer @@ -1268,11 +1276,8 @@ public class Allocation extends BaseObj { * @param d The array to be set from the Allocation. */ public void copyTo(byte[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); validateIsInt8(); - mRS.validate(); - mRS.nAllocationRead(getID(mRS), d); - Trace.traceEnd(RenderScript.TRACE_TAG); + copyTo(d, Element.DataType.SIGNED_8, d.length); } /** @@ -1283,11 +1288,8 @@ public class Allocation extends BaseObj { * @param d The array to be set from the Allocation. */ public void copyTo(short[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); validateIsInt16(); - mRS.validate(); - mRS.nAllocationRead(getID(mRS), d); - Trace.traceEnd(RenderScript.TRACE_TAG); + copyTo(d, Element.DataType.SIGNED_16, d.length); } /** @@ -1298,11 +1300,8 @@ public class Allocation extends BaseObj { * @param d The array to be set from the Allocation. */ public void copyTo(int[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); validateIsInt32(); - mRS.validate(); - mRS.nAllocationRead(getID(mRS), d); - Trace.traceEnd(RenderScript.TRACE_TAG); + copyTo(d, Element.DataType.SIGNED_32, d.length); } /** @@ -1313,11 +1312,8 @@ public class Allocation extends BaseObj { * @param d The array to be set from the Allocation. */ public void copyTo(float[] d) { - Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); validateIsFloat32(); - mRS.validate(); - mRS.nAllocationRead(getID(mRS), d); - Trace.traceEnd(RenderScript.TRACE_TAG); + copyTo(d, Element.DataType.FLOAT_32, d.length); } /** @@ -1342,7 +1338,7 @@ public class Allocation extends BaseObj { mRS.nAllocationResize1D(getID(mRS), dimX); mRS.finish(); // Necessary because resize is fifoed and update is async. - int typeID = mRS.nAllocationGetType(getID(mRS)); + long typeID = mRS.nAllocationGetType(getID(mRS)); mType = new Type(typeID, mRS); mType.updateFromNative(); updateCacheInfo(mType); @@ -1372,7 +1368,7 @@ public class Allocation extends BaseObj { if (type.getID(rs) == 0) { throw new RSInvalidStateException("Bad Type"); } - int id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0); + long id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); } @@ -1427,7 +1423,7 @@ public class Allocation extends BaseObj { b.setX(count); Type t = b.create(); - int id = rs.nAllocationCreateTyped(t.getID(rs), MipmapControl.MIPMAP_NONE.mID, usage, 0); + long id = rs.nAllocationCreateTyped(t.getID(rs), MipmapControl.MIPMAP_NONE.mID, usage, 0); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); } @@ -1511,7 +1507,7 @@ public class Allocation extends BaseObj { if (mips == MipmapControl.MIPMAP_NONE && t.getElement().isCompatible(Element.RGBA_8888(rs)) && usage == (USAGE_SHARED | USAGE_SCRIPT | USAGE_GRAPHICS_TEXTURE)) { - int id = rs.nAllocationCreateBitmapBackedAllocation(t.getID(rs), mips.mID, b, usage); + long id = rs.nAllocationCreateBitmapBackedAllocation(t.getID(rs), mips.mID, b, usage); if (id == 0) { throw new RSRuntimeException("Load failed."); } @@ -1523,7 +1519,7 @@ public class Allocation extends BaseObj { } - int id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage); + long id = rs.nAllocationCreateFromBitmap(t.getID(rs), mips.mID, b, usage); if (id == 0) { throw new RSRuntimeException("Load failed."); } @@ -1547,13 +1543,6 @@ public class Allocation extends BaseObj { } /** - * @hide - */ - public void setSurfaceTexture(SurfaceTexture st) { - setSurface(new Surface(st)); - } - - /** * Associate a {@link android.view.Surface} with this Allocation. This * operation is only valid for Allocations with {@link #USAGE_IO_OUTPUT}. * @@ -1633,7 +1622,7 @@ public class Allocation extends BaseObj { tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL); Type t = tb.create(); - int id = rs.nAllocationCubeCreateFromBitmap(t.getID(rs), mips.mID, b, usage); + long id = rs.nAllocationCubeCreateFromBitmap(t.getID(rs), mips.mID, b, usage); if(id == 0) { throw new RSRuntimeException("Load failed for bitmap " + b + " element " + e); } @@ -1858,14 +1847,14 @@ public class Allocation extends BaseObj { */ public void setOnBufferAvailableListener(OnBufferAvailableListener callback) { synchronized(mAllocationMap) { - mAllocationMap.put(new Integer(getID(mRS)), this); + mAllocationMap.put(new Long(getID(mRS)), this); mBufferNotifier = callback; } } static void sendBufferNotification(int id) { synchronized(mAllocationMap) { - Allocation a = mAllocationMap.get(new Integer(id)); + Allocation a = mAllocationMap.get(new Long(id)); if ((a != null) && (a.mBufferNotifier != null)) { a.mBufferNotifier.onBufferAvailable(a); @@ -1874,4 +1863,3 @@ public class Allocation extends BaseObj { } } - diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/graphics/java/android/renderscript/AllocationAdapter.java index a6645bb..6c1b1ed 100644 --- a/graphics/java/android/renderscript/AllocationAdapter.java +++ b/graphics/java/android/renderscript/AllocationAdapter.java @@ -16,22 +16,17 @@ package android.renderscript; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.util.TypedValue; - /** * Only intended for use by generated reflected code. * **/ public class AllocationAdapter extends Allocation { - AllocationAdapter(int id, RenderScript rs, Allocation alloc) { + AllocationAdapter(long id, RenderScript rs, Allocation alloc) { super(id, rs, alloc.mType, alloc.mUsage); mAdaptedAllocation = alloc; } - int getID(RenderScript rs) { + long getID(RenderScript rs) { throw new RSInvalidStateException( "This operation is not supported with adapters at this time."); } diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index e17d79a..1a15ce6 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -16,8 +16,6 @@ package android.renderscript; -import android.util.Log; - /** * BaseObj is the base class for all RenderScript objects owned by a RS context. * It is responsible for lifetime management and resource tracking. This class @@ -25,7 +23,7 @@ import android.util.Log; * **/ public class BaseObj { - BaseObj(int id, RenderScript rs) { + BaseObj(long id, RenderScript rs) { rs.validate(); mRS = rs; mID = id; @@ -46,9 +44,9 @@ public class BaseObj { * @param rs Context to verify against internal context for * match. * - * @return int + * @return long */ - int getID(RenderScript rs) { + long getID(RenderScript rs) { mRS.validate(); if (mDestroyed) { throw new RSInvalidStateException("using a destroyed object."); @@ -68,7 +66,7 @@ public class BaseObj { } } - private int mID; + private long mID; private boolean mDestroyed; private String mName; RenderScript mRS; @@ -152,7 +150,7 @@ public class BaseObj { */ @Override public int hashCode() { - return mID; + return (int)((mID & 0xfffffff) ^ (mID >> 32)); } /** diff --git a/graphics/java/android/renderscript/Byte2.java b/graphics/java/android/renderscript/Byte2.java index f796de3..3ad79e4 100644 --- a/graphics/java/android/renderscript/Byte2.java +++ b/graphics/java/android/renderscript/Byte2.java @@ -16,9 +16,6 @@ package android.renderscript; -import java.lang.Math; -import android.util.Log; - /** * Class for exposing the native RenderScript byte2 type back to the Android system. diff --git a/graphics/java/android/renderscript/Byte3.java b/graphics/java/android/renderscript/Byte3.java index f2a95ac..a138313 100644 --- a/graphics/java/android/renderscript/Byte3.java +++ b/graphics/java/android/renderscript/Byte3.java @@ -16,9 +16,6 @@ package android.renderscript; -import java.lang.Math; -import android.util.Log; - /** * Class for exposing the native RenderScript byte3 type back to the Android system. diff --git a/graphics/java/android/renderscript/Byte4.java b/graphics/java/android/renderscript/Byte4.java index b8a8a6b..fa4c13d 100644 --- a/graphics/java/android/renderscript/Byte4.java +++ b/graphics/java/android/renderscript/Byte4.java @@ -16,9 +16,6 @@ package android.renderscript; -import java.lang.Math; -import android.util.Log; - /** * Class for exposing the native RenderScript byte4 type back to the Android system. diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index 68badfa..93e839e 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -16,9 +16,6 @@ package android.renderscript; -import java.lang.reflect.Field; -import android.util.Log; - /** * <p>An Element represents one item within an {@link * android.renderscript.Allocation}. An Element is roughly equivalent to a C @@ -759,7 +756,7 @@ public class Element extends BaseObj { return rs.mElement_MATRIX_2X2; } - Element(int id, RenderScript rs, Element[] e, String[] n, int[] as) { + Element(long id, RenderScript rs, Element[] e, String[] n, int[] as) { super(id, rs); mSize = 0; mVectorSize = 1; @@ -776,7 +773,7 @@ public class Element extends BaseObj { updateVisibleSubElements(); } - Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) { + Element(long id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) { super(id, rs); if ((dt != DataType.UNSIGNED_5_6_5) && (dt != DataType.UNSIGNED_4_4_4_4) && @@ -795,7 +792,7 @@ public class Element extends BaseObj { mVectorSize = size; } - Element(int id, RenderScript rs) { + Element(long id, RenderScript rs) { super(id, rs); } @@ -803,6 +800,8 @@ public class Element extends BaseObj { void updateFromNative() { super.updateFromNative(); + // FIXME: updateFromNative is broken in JNI for 64-bit + // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements int[] dataBuffer = new int[5]; mRS.nElementGetNativeData(getID(mRS), dataBuffer); @@ -853,7 +852,7 @@ public class Element extends BaseObj { DataKind dk = DataKind.USER; boolean norm = false; int vecSize = 1; - int id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize); + long id = rs.nElementCreate(dt.mID, dk.mID, norm, vecSize); return new Element(id, rs, dt, dk, norm, vecSize); } @@ -890,7 +889,7 @@ public class Element extends BaseObj { case BOOLEAN: { DataKind dk = DataKind.USER; boolean norm = false; - int id = rs.nElementCreate(dt.mID, dk.mID, norm, size); + long id = rs.nElementCreate(dt.mID, dk.mID, norm, size); return new Element(id, rs, dt, dk, norm, size); } @@ -961,7 +960,7 @@ public class Element extends BaseObj { } boolean norm = true; - int id = rs.nElementCreate(dt.mID, dk.mID, norm, size); + long id = rs.nElementCreate(dt.mID, dk.mID, norm, size); return new Element(id, rs, dt, dk, norm, size); } @@ -1088,11 +1087,12 @@ public class Element extends BaseObj { java.lang.System.arraycopy(mElementNames, 0, sin, 0, mCount); java.lang.System.arraycopy(mArraySizes, 0, asin, 0, mCount); + // FIXME: broken for 64-bit int[] ids = new int[ein.length]; for (int ct = 0; ct < ein.length; ct++ ) { - ids[ct] = ein[ct].getID(mRS); + ids[ct] = (int)ein[ct].getID(mRS); } - int id = mRS.nElementCreate2(ids, sin, asin); + long id = mRS.nElementCreate2(ids, sin, asin); return new Element(id, mRS, ein, sin, asin); } } diff --git a/graphics/java/android/renderscript/FieldPacker.java b/graphics/java/android/renderscript/FieldPacker.java index fed97d6..723ab24 100644 --- a/graphics/java/android/renderscript/FieldPacker.java +++ b/graphics/java/android/renderscript/FieldPacker.java @@ -16,7 +16,6 @@ package android.renderscript; -import android.util.Log; import java.util.BitSet; /** @@ -232,7 +231,8 @@ public class FieldPacker { public void addObj(BaseObj obj) { if (obj != null) { - addI32(obj.getID(null)); + // FIXME: this is fine for 32-bit but needs a path for 64-bit + addI32((int)obj.getID(null)); } else { addI32(0); } diff --git a/graphics/java/android/renderscript/FileA3D.java b/graphics/java/android/renderscript/FileA3D.java index e41f02d..f0acb56 100644 --- a/graphics/java/android/renderscript/FileA3D.java +++ b/graphics/java/android/renderscript/FileA3D.java @@ -17,15 +17,10 @@ package android.renderscript; import java.io.File; -import java.io.IOException; import java.io.InputStream; import android.content.res.AssetManager; import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.util.Log; -import android.util.TypedValue; /** * @hide @@ -80,7 +75,7 @@ public class FileA3D extends BaseObj { public static class IndexEntry { RenderScript mRS; int mIndex; - int mID; + long mID; String mName; EntryType mEntryType; BaseObj mLoadedObj; @@ -156,7 +151,7 @@ public class FileA3D extends BaseObj { return entry.mLoadedObj; } - IndexEntry(RenderScript rs, int index, int id, String name, EntryType type) { + IndexEntry(RenderScript rs, int index, long id, String name, EntryType type) { mRS = rs; mIndex = index; mID = id; @@ -169,7 +164,7 @@ public class FileA3D extends BaseObj { IndexEntry[] mFileEntries; InputStream mInputStream; - FileA3D(int id, RenderScript rs, InputStream stream) { + FileA3D(long id, RenderScript rs, InputStream stream) { super(id, rs); mInputStream = stream; } @@ -232,7 +227,7 @@ public class FileA3D extends BaseObj { */ static public FileA3D createFromAsset(RenderScript rs, AssetManager mgr, String path) { rs.validate(); - int fileId = rs.nFileA3DCreateFromAsset(mgr, path); + long fileId = rs.nFileA3DCreateFromAsset(mgr, path); if(fileId == 0) { throw new RSRuntimeException("Unable to create a3d file from asset " + path); @@ -252,7 +247,7 @@ public class FileA3D extends BaseObj { * @return a3d file containing renderscript objects */ static public FileA3D createFromFile(RenderScript rs, String path) { - int fileId = rs.nFileA3DCreateFromFile(path); + long fileId = rs.nFileA3DCreateFromFile(path); if(fileId == 0) { throw new RSRuntimeException("Unable to create a3d file from " + path); @@ -295,7 +290,7 @@ public class FileA3D extends BaseObj { throw new RSRuntimeException("Unable to open resource " + id); } - int fileId = 0; + long fileId = 0; if (is instanceof AssetManager.AssetInputStream) { int asset = ((AssetManager.AssetInputStream) is).getAssetInt(); fileId = rs.nFileA3DCreateFromAssetStream(asset); diff --git a/graphics/java/android/renderscript/Float2.java b/graphics/java/android/renderscript/Float2.java index 26193d2..e9f8ca7 100644 --- a/graphics/java/android/renderscript/Float2.java +++ b/graphics/java/android/renderscript/Float2.java @@ -26,7 +26,7 @@ public class Float2 { public Float2() { } - /** @hide */ + /** @hide */ public Float2(Float2 data) { this.x = data.x; this.y = data.y; diff --git a/graphics/java/android/renderscript/Font.java b/graphics/java/android/renderscript/Font.java index 0375d2b..4cd89db 100644 --- a/graphics/java/android/renderscript/Font.java +++ b/graphics/java/android/renderscript/Font.java @@ -17,7 +17,6 @@ package android.renderscript; import java.io.File; -import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -26,8 +25,6 @@ import android.os.Environment; import android.content.res.AssetManager; import android.content.res.Resources; -import android.util.Log; -import android.util.TypedValue; /** * @hide diff --git a/graphics/java/android/renderscript/Int3.java b/graphics/java/android/renderscript/Int3.java index c770395..5431b9a 100644 --- a/graphics/java/android/renderscript/Int3.java +++ b/graphics/java/android/renderscript/Int3.java @@ -27,7 +27,7 @@ public class Int3 { public Int3() { } - + /** @hide */ public Int3(int i) { this.x = this.y = this.z = i; diff --git a/graphics/java/android/renderscript/Long3.java b/graphics/java/android/renderscript/Long3.java index 88ff855..8e243cc 100644 --- a/graphics/java/android/renderscript/Long3.java +++ b/graphics/java/android/renderscript/Long3.java @@ -27,7 +27,7 @@ public class Long3 { public Long3() { } - + /** @hide */ public Long3(long i) { this.x = this.y = this.z = i; diff --git a/graphics/java/android/renderscript/Matrix2f.java b/graphics/java/android/renderscript/Matrix2f.java index d3621fa..048262d 100644 --- a/graphics/java/android/renderscript/Matrix2f.java +++ b/graphics/java/android/renderscript/Matrix2f.java @@ -16,9 +16,6 @@ package android.renderscript; -import java.lang.Math; -import android.util.Log; - /** * Class for exposing the native RenderScript rs_matrix2x2 type back to the Android system. diff --git a/graphics/java/android/renderscript/Matrix3f.java b/graphics/java/android/renderscript/Matrix3f.java index 8c3c330..9a4af77 100644 --- a/graphics/java/android/renderscript/Matrix3f.java +++ b/graphics/java/android/renderscript/Matrix3f.java @@ -16,9 +16,6 @@ package android.renderscript; -import java.lang.Math; -import android.util.Log; - /** * Class for exposing the native RenderScript rs_matrix3x3 type back to the Android system. diff --git a/graphics/java/android/renderscript/Matrix4f.java b/graphics/java/android/renderscript/Matrix4f.java index cd18e30..5d5bf5f 100644 --- a/graphics/java/android/renderscript/Matrix4f.java +++ b/graphics/java/android/renderscript/Matrix4f.java @@ -17,7 +17,6 @@ package android.renderscript; import java.lang.Math; -import android.util.Log; /** diff --git a/graphics/java/android/renderscript/Mesh.java b/graphics/java/android/renderscript/Mesh.java index bca4aa3..a4ecc38 100644 --- a/graphics/java/android/renderscript/Mesh.java +++ b/graphics/java/android/renderscript/Mesh.java @@ -18,8 +18,6 @@ package android.renderscript; import java.util.Vector; -import android.util.Log; - /** * @hide * @deprecated in API 16 @@ -91,7 +89,7 @@ public class Mesh extends BaseObj { Allocation[] mIndexBuffers; Primitive[] mPrimitives; - Mesh(int id, RenderScript rs) { + Mesh(long id, RenderScript rs) { super(id, rs); } @@ -367,7 +365,7 @@ public class Mesh extends BaseObj { alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage); } vertexBuffers[ct] = alloc; - vtx[ct] = alloc.getID(mRS); + vtx[ct] = (int)alloc.getID(mRS); } for(int ct = 0; ct < mIndexTypes.size(); ct ++) { @@ -378,15 +376,15 @@ public class Mesh extends BaseObj { } else if(entry.e != null) { alloc = Allocation.createSized(mRS, entry.e, entry.size, mUsage); } - int allocID = (alloc == null) ? 0 : alloc.getID(mRS); + long allocID = (alloc == null) ? 0 : alloc.getID(mRS); indexBuffers[ct] = alloc; primitives[ct] = entry.prim; - idx[ct] = allocID; + idx[ct] = (int)allocID; prim[ct] = entry.prim.mID; } - int id = mRS.nMeshCreate(vtx, idx, prim); + long id = mRS.nMeshCreate(vtx, idx, prim); Mesh newMesh = new Mesh(id, mRS); newMesh.mVertexBuffers = vertexBuffers; newMesh.mIndexBuffers = indexBuffers; @@ -517,20 +515,20 @@ public class Mesh extends BaseObj { for(int ct = 0; ct < mVertexTypeCount; ct ++) { Entry entry = mVertexTypes[ct]; vertexBuffers[ct] = entry.a; - vtx[ct] = entry.a.getID(mRS); + vtx[ct] = (int)entry.a.getID(mRS); } for(int ct = 0; ct < mIndexTypes.size(); ct ++) { Entry entry = (Entry)mIndexTypes.elementAt(ct); - int allocID = (entry.a == null) ? 0 : entry.a.getID(mRS); + long allocID = (entry.a == null) ? 0 : entry.a.getID(mRS); indexBuffers[ct] = entry.a; primitives[ct] = entry.prim; - idx[ct] = allocID; + idx[ct] = (int)allocID; prim[ct] = entry.prim.mID; } - int id = mRS.nMeshCreate(vtx, idx, prim); + long id = mRS.nMeshCreate(vtx, idx, prim); Mesh newMesh = new Mesh(id, mRS); newMesh.mVertexBuffers = vertexBuffers; newMesh.mIndexBuffers = indexBuffers; diff --git a/graphics/java/android/renderscript/Path.java b/graphics/java/android/renderscript/Path.java index 9c4d41b..f3502aa 100644 --- a/graphics/java/android/renderscript/Path.java +++ b/graphics/java/android/renderscript/Path.java @@ -16,9 +16,6 @@ package android.renderscript; -import java.util.Vector; -import android.util.Log; - /** * @hide * @@ -41,7 +38,7 @@ public class Path extends BaseObj { float mQuality; boolean mCoverageToAlpha; - Path(int id, RenderScript rs, Primitive p, Allocation vtx, Allocation loop, float q) { + Path(long id, RenderScript rs, Primitive p, Allocation vtx, Allocation loop, float q) { super(id, rs); mVertexBuffer = vtx; mLoopBuffer = loop; @@ -67,7 +64,7 @@ public class Path extends BaseObj { public static Path createStaticPath(RenderScript rs, Primitive p, float quality, Allocation vtx) { - int id = rs.nPathCreate(p.mID, false, vtx.getID(rs), 0, quality); + long id = rs.nPathCreate(p.mID, false, vtx.getID(rs), 0, quality); Path newPath = new Path(id, rs, p, null, null, quality); return newPath; } diff --git a/graphics/java/android/renderscript/Program.java b/graphics/java/android/renderscript/Program.java index bc2ca35..3eb9b75 100644 --- a/graphics/java/android/renderscript/Program.java +++ b/graphics/java/android/renderscript/Program.java @@ -74,7 +74,7 @@ public class Program extends BaseObj { int mTextureCount; String mShader; - Program(int id, RenderScript rs) { + Program(long id, RenderScript rs) { super(id, rs); } @@ -150,7 +150,7 @@ public class Program extends BaseObj { a.getType().getID(mRS) != mConstants[slot].getID(mRS)) { throw new IllegalArgumentException("Allocation type does not match slot type."); } - int id = a != null ? a.getID(mRS) : 0; + long id = a != null ? a.getID(mRS) : 0; mRS.nProgramBindConstants(getID(mRS), slot, id); } @@ -172,7 +172,7 @@ public class Program extends BaseObj { throw new IllegalArgumentException("Cannot bind cubemap to 2d texture slot"); } - int id = va != null ? va.getID(mRS) : 0; + long id = va != null ? va.getID(mRS) : 0; mRS.nProgramBindTexture(getID(mRS), slot, id); } @@ -192,7 +192,7 @@ public class Program extends BaseObj { throw new IllegalArgumentException("Slot ID out of range."); } - int id = vs != null ? vs.getID(mRS) : 0; + long id = vs != null ? vs.getID(mRS) : 0; mRS.nProgramBindSampler(getID(mRS), slot, id); } diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java index b9ba3fd..2704130 100644 --- a/graphics/java/android/renderscript/ProgramFragment.java +++ b/graphics/java/android/renderscript/ProgramFragment.java @@ -17,9 +17,6 @@ package android.renderscript; -import android.util.Log; - - /** * @hide * @deprecated in API 16 @@ -39,7 +36,7 @@ import android.util.Log; * **/ public class ProgramFragment extends Program { - ProgramFragment(int id, RenderScript rs) { + ProgramFragment(long id, RenderScript rs) { super(id, rs); } @@ -71,23 +68,23 @@ public class ProgramFragment extends Program { for (int i=0; i < mInputCount; i++) { tmp[idx++] = ProgramParam.INPUT.mID; - tmp[idx++] = mInputs[i].getID(mRS); + tmp[idx++] = (int)mInputs[i].getID(mRS); } for (int i=0; i < mOutputCount; i++) { tmp[idx++] = ProgramParam.OUTPUT.mID; - tmp[idx++] = mOutputs[i].getID(mRS); + tmp[idx++] = (int)mOutputs[i].getID(mRS); } for (int i=0; i < mConstantCount; i++) { tmp[idx++] = ProgramParam.CONSTANT.mID; - tmp[idx++] = mConstants[i].getID(mRS); + tmp[idx++] = (int)mConstants[i].getID(mRS); } for (int i=0; i < mTextureCount; i++) { tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID; - tmp[idx++] = mTextureTypes[i].mID; + tmp[idx++] = (int)mTextureTypes[i].mID; texNames[i] = mTextureNames[i]; } - int id = mRS.nProgramFragmentCreate(mShader, texNames, tmp); + long id = mRS.nProgramFragmentCreate(mShader, texNames, tmp); ProgramFragment pf = new ProgramFragment(id, mRS); initProgram(pf); return pf; diff --git a/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java b/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java index 8ae1777..e1c35c5 100644 --- a/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java +++ b/graphics/java/android/renderscript/ProgramFragmentFixedFunction.java @@ -17,9 +17,6 @@ package android.renderscript; -import android.util.Log; - - /** * @hide * @deprecated in API 16 @@ -31,7 +28,7 @@ import android.util.Log; * **/ public class ProgramFragmentFixedFunction extends ProgramFragment { - ProgramFragmentFixedFunction(int id, RenderScript rs) { + ProgramFragmentFixedFunction(long id, RenderScript rs) { super(id, rs); } @@ -58,23 +55,23 @@ public class ProgramFragmentFixedFunction extends ProgramFragment { for (int i=0; i < mInputCount; i++) { tmp[idx++] = ProgramParam.INPUT.mID; - tmp[idx++] = mInputs[i].getID(mRS); + tmp[idx++] = (int)mInputs[i].getID(mRS); } for (int i=0; i < mOutputCount; i++) { tmp[idx++] = ProgramParam.OUTPUT.mID; - tmp[idx++] = mOutputs[i].getID(mRS); + tmp[idx++] = (int)mOutputs[i].getID(mRS); } for (int i=0; i < mConstantCount; i++) { tmp[idx++] = ProgramParam.CONSTANT.mID; - tmp[idx++] = mConstants[i].getID(mRS); + tmp[idx++] = (int)mConstants[i].getID(mRS); } for (int i=0; i < mTextureCount; i++) { tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID; - tmp[idx++] = mTextureTypes[i].mID; + tmp[idx++] = (int)mTextureTypes[i].mID; texNames[i] = mTextureNames[i]; } - int id = mRS.nProgramFragmentCreate(mShader, texNames, tmp); + long id = mRS.nProgramFragmentCreate(mShader, texNames, tmp); ProgramFragmentFixedFunction pf = new ProgramFragmentFixedFunction(id, mRS); initProgram(pf); return pf; diff --git a/graphics/java/android/renderscript/ProgramRaster.java b/graphics/java/android/renderscript/ProgramRaster.java index 216cb4e..8c7c9aa 100644 --- a/graphics/java/android/renderscript/ProgramRaster.java +++ b/graphics/java/android/renderscript/ProgramRaster.java @@ -17,9 +17,6 @@ package android.renderscript; -import android.util.Log; - - /** * @hide * @deprecated in API 16 @@ -54,7 +51,7 @@ public class ProgramRaster extends BaseObj { boolean mPointSprite; CullMode mCullMode; - ProgramRaster(int id, RenderScript rs) { + ProgramRaster(long id, RenderScript rs) { super(id, rs); mPointSprite = false; @@ -154,7 +151,7 @@ public class ProgramRaster extends BaseObj { */ public ProgramRaster create() { mRS.validate(); - int id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID); + long id = mRS.nProgramRasterCreate(mPointSprite, mCullMode.mID); ProgramRaster programRaster = new ProgramRaster(id, mRS); programRaster.mPointSprite = mPointSprite; programRaster.mCullMode = mCullMode; diff --git a/graphics/java/android/renderscript/ProgramStore.java b/graphics/java/android/renderscript/ProgramStore.java index dac9e76..730c51b 100644 --- a/graphics/java/android/renderscript/ProgramStore.java +++ b/graphics/java/android/renderscript/ProgramStore.java @@ -17,9 +17,6 @@ package android.renderscript; -import android.util.Log; - - /** * @hide * <p>ProgramStore contains a set of parameters that control how diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java index 1c5a191..d194ba9 100644 --- a/graphics/java/android/renderscript/ProgramVertex.java +++ b/graphics/java/android/renderscript/ProgramVertex.java @@ -39,10 +39,6 @@ package android.renderscript; -import android.graphics.Matrix; -import android.util.Log; - - /** * @hide * @deprecated in API 16 @@ -53,7 +49,7 @@ import android.util.Log; **/ public class ProgramVertex extends Program { - ProgramVertex(int id, RenderScript rs) { + ProgramVertex(long id, RenderScript rs) { super(id, rs); } @@ -132,23 +128,23 @@ public class ProgramVertex extends Program { for (int i=0; i < mInputCount; i++) { tmp[idx++] = ProgramParam.INPUT.mID; - tmp[idx++] = mInputs[i].getID(mRS); + tmp[idx++] = (int)mInputs[i].getID(mRS); } for (int i=0; i < mOutputCount; i++) { tmp[idx++] = ProgramParam.OUTPUT.mID; - tmp[idx++] = mOutputs[i].getID(mRS); + tmp[idx++] = (int)mOutputs[i].getID(mRS); } for (int i=0; i < mConstantCount; i++) { tmp[idx++] = ProgramParam.CONSTANT.mID; - tmp[idx++] = mConstants[i].getID(mRS); + tmp[idx++] = (int)mConstants[i].getID(mRS); } for (int i=0; i < mTextureCount; i++) { tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID; - tmp[idx++] = mTextureTypes[i].mID; + tmp[idx++] = (int)mTextureTypes[i].mID; texNames[i] = mTextureNames[i]; } - int id = mRS.nProgramVertexCreate(mShader, texNames, tmp); + long id = mRS.nProgramVertexCreate(mShader, texNames, tmp); ProgramVertex pv = new ProgramVertex(id, mRS); initProgram(pv); return pv; diff --git a/graphics/java/android/renderscript/ProgramVertexFixedFunction.java b/graphics/java/android/renderscript/ProgramVertexFixedFunction.java index ad486f3..2d281b8 100644 --- a/graphics/java/android/renderscript/ProgramVertexFixedFunction.java +++ b/graphics/java/android/renderscript/ProgramVertexFixedFunction.java @@ -17,10 +17,6 @@ package android.renderscript; -import android.graphics.Matrix; -import android.util.Log; - - /** * @hide * @deprecated in API 16 @@ -31,7 +27,7 @@ import android.util.Log; **/ public class ProgramVertexFixedFunction extends ProgramVertex { - ProgramVertexFixedFunction(int id, RenderScript rs) { + ProgramVertexFixedFunction(long id, RenderScript rs) { super(id, rs); } @@ -85,23 +81,23 @@ public class ProgramVertexFixedFunction extends ProgramVertex { for (int i=0; i < mInputCount; i++) { tmp[idx++] = ProgramParam.INPUT.mID; - tmp[idx++] = mInputs[i].getID(mRS); + tmp[idx++] = (int)mInputs[i].getID(mRS); } for (int i=0; i < mOutputCount; i++) { tmp[idx++] = ProgramParam.OUTPUT.mID; - tmp[idx++] = mOutputs[i].getID(mRS); + tmp[idx++] = (int)mOutputs[i].getID(mRS); } for (int i=0; i < mConstantCount; i++) { tmp[idx++] = ProgramParam.CONSTANT.mID; - tmp[idx++] = mConstants[i].getID(mRS); + tmp[idx++] = (int)mConstants[i].getID(mRS); } for (int i=0; i < mTextureCount; i++) { tmp[idx++] = ProgramParam.TEXTURE_TYPE.mID; - tmp[idx++] = mTextureTypes[i].mID; + tmp[idx++] = (int)mTextureTypes[i].mID; texNames[i] = mTextureNames[i]; } - int id = mRS.nProgramVertexCreate(mShader, texNames, tmp); + long id = mRS.nProgramVertexCreate(mShader, texNames, tmp); ProgramVertexFixedFunction pv = new ProgramVertexFixedFunction(id, mRS); initProgram(pv); return pv; diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java index 308d97a..5db72d9 100644 --- a/graphics/java/android/renderscript/RSSurfaceView.java +++ b/graphics/java/android/renderscript/RSSurfaceView.java @@ -16,16 +16,8 @@ package android.renderscript; -import java.io.Writer; -import java.util.ArrayList; -import java.util.concurrent.Semaphore; - import android.content.Context; -import android.os.Handler; -import android.os.Message; import android.util.AttributeSet; -import android.util.Log; -import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; diff --git a/graphics/java/android/renderscript/RSTextureView.java b/graphics/java/android/renderscript/RSTextureView.java index 7eeeeae..af3258a 100644 --- a/graphics/java/android/renderscript/RSTextureView.java +++ b/graphics/java/android/renderscript/RSTextureView.java @@ -16,16 +16,9 @@ package android.renderscript; -import java.io.Writer; -import java.util.ArrayList; -import java.util.concurrent.Semaphore; - import android.content.Context; import android.graphics.SurfaceTexture; -import android.os.Handler; -import android.os.Message; import android.util.AttributeSet; -import android.util.Log; import android.view.TextureView; /** diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 7d4a5c4..d2c7456 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -17,15 +17,11 @@ package android.renderscript; import java.io.File; -import java.lang.reflect.Field; import java.lang.reflect.Method; import android.content.Context; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.SurfaceTexture; import android.os.Process; import android.util.Log; @@ -91,14 +87,14 @@ public class RenderScript { } // Non-threadsafe functions. - native int nDeviceCreate(); - native void nDeviceDestroy(int dev); - native void nDeviceSetConfig(int dev, int param, int value); - native int nContextGetUserMessage(int con, int[] data); - native String nContextGetErrorMessage(int con); - native int nContextPeekMessage(int con, int[] subID); - native void nContextInitToClient(int con); - native void nContextDeinitToClient(int con); + native long nDeviceCreate(); + native void nDeviceDestroy(long dev); + native void nDeviceSetConfig(long dev, int param, int value); + native int nContextGetUserMessage(long con, int[] data); + native String nContextGetErrorMessage(long con); + native int nContextPeekMessage(long con, int[] subID); + native void nContextInitToClient(long con); + native void nContextDeinitToClient(long con); static File mCacheDir; @@ -154,13 +150,13 @@ public class RenderScript { // Methods below are wrapped to protect the non-threadsafe // lockless fifo. - native int rsnContextCreateGL(int dev, int ver, int sdkVer, + native long rsnContextCreateGL(long dev, int ver, int sdkVer, int colorMin, int colorPref, int alphaMin, int alphaPref, int depthMin, int depthPref, int stencilMin, int stencilPref, int samplesMin, int samplesPref, float samplesQ, int dpi); - synchronized int nContextCreateGL(int dev, int ver, int sdkVer, + synchronized long nContextCreateGL(long dev, int ver, int sdkVer, int colorMin, int colorPref, int alphaMin, int alphaPref, int depthMin, int depthPref, @@ -171,100 +167,100 @@ public class RenderScript { stencilMin, stencilPref, samplesMin, samplesPref, samplesQ, dpi); } - native int rsnContextCreate(int dev, int ver, int sdkVer, int contextType); - synchronized int nContextCreate(int dev, int ver, int sdkVer, int contextType) { + native long rsnContextCreate(long dev, int ver, int sdkVer, int contextType); + synchronized long nContextCreate(long dev, int ver, int sdkVer, int contextType) { return rsnContextCreate(dev, ver, sdkVer, contextType); } - native void rsnContextDestroy(int con); + native void rsnContextDestroy(long con); synchronized void nContextDestroy() { validate(); rsnContextDestroy(mContext); } - native void rsnContextSetSurface(int con, int w, int h, Surface sur); + native void rsnContextSetSurface(long con, int w, int h, Surface sur); synchronized void nContextSetSurface(int w, int h, Surface sur) { validate(); rsnContextSetSurface(mContext, w, h, sur); } - native void rsnContextSetSurfaceTexture(int con, int w, int h, SurfaceTexture sur); + native void rsnContextSetSurfaceTexture(long con, int w, int h, SurfaceTexture sur); synchronized void nContextSetSurfaceTexture(int w, int h, SurfaceTexture sur) { validate(); rsnContextSetSurfaceTexture(mContext, w, h, sur); } - native void rsnContextSetPriority(int con, int p); + native void rsnContextSetPriority(long con, int p); synchronized void nContextSetPriority(int p) { validate(); rsnContextSetPriority(mContext, p); } - native void rsnContextDump(int con, int bits); + native void rsnContextDump(long con, int bits); synchronized void nContextDump(int bits) { validate(); rsnContextDump(mContext, bits); } - native void rsnContextFinish(int con); + native void rsnContextFinish(long con); synchronized void nContextFinish() { validate(); rsnContextFinish(mContext); } - native void rsnContextSendMessage(int con, int id, int[] data); + native void rsnContextSendMessage(long con, int id, int[] data); synchronized void nContextSendMessage(int id, int[] data) { validate(); rsnContextSendMessage(mContext, id, data); } - native void rsnContextBindRootScript(int con, int script); + native void rsnContextBindRootScript(long con, int script); synchronized void nContextBindRootScript(int script) { validate(); rsnContextBindRootScript(mContext, script); } - native void rsnContextBindSampler(int con, int sampler, int slot); + native void rsnContextBindSampler(long con, int sampler, int slot); synchronized void nContextBindSampler(int sampler, int slot) { validate(); rsnContextBindSampler(mContext, sampler, slot); } - native void rsnContextBindProgramStore(int con, int pfs); + native void rsnContextBindProgramStore(long con, int pfs); synchronized void nContextBindProgramStore(int pfs) { validate(); rsnContextBindProgramStore(mContext, pfs); } - native void rsnContextBindProgramFragment(int con, int pf); + native void rsnContextBindProgramFragment(long con, int pf); synchronized void nContextBindProgramFragment(int pf) { validate(); rsnContextBindProgramFragment(mContext, pf); } - native void rsnContextBindProgramVertex(int con, int pv); + native void rsnContextBindProgramVertex(long con, int pv); synchronized void nContextBindProgramVertex(int pv) { validate(); rsnContextBindProgramVertex(mContext, pv); } - native void rsnContextBindProgramRaster(int con, int pr); + native void rsnContextBindProgramRaster(long con, int pr); synchronized void nContextBindProgramRaster(int pr) { validate(); rsnContextBindProgramRaster(mContext, pr); } - native void rsnContextPause(int con); + native void rsnContextPause(long con); synchronized void nContextPause() { validate(); rsnContextPause(mContext); } - native void rsnContextResume(int con); + native void rsnContextResume(long con); synchronized void nContextResume() { validate(); rsnContextResume(mContext); } - native void rsnAssignName(int con, int obj, byte[] name); - synchronized void nAssignName(int obj, byte[] name) { + native void rsnAssignName(long con, long obj, byte[] name); + synchronized void nAssignName(long obj, byte[] name) { validate(); rsnAssignName(mContext, obj, name); } - native String rsnGetName(int con, int obj); - synchronized String nGetName(int obj) { + native String rsnGetName(long con, long obj); + synchronized String nGetName(long obj) { validate(); return rsnGetName(mContext, obj); } - native void rsnObjDestroy(int con, int id); - synchronized void nObjDestroy(int id) { + native void rsnObjDestroy(long con, long id); + synchronized void nObjDestroy(long id) { // There is a race condition here. The calling code may be run // by the gc while teardown is occuring. This protects againts // deleting dead objects. @@ -273,156 +269,140 @@ public class RenderScript { } } - native int rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize); - synchronized int nElementCreate(int type, int kind, boolean norm, int vecSize) { + native long rsnElementCreate(long con, long type, int kind, boolean norm, int vecSize); + synchronized long nElementCreate(long type, int kind, boolean norm, int vecSize) { validate(); return rsnElementCreate(mContext, type, kind, norm, vecSize); } - native int rsnElementCreate2(int con, int[] elements, String[] names, int[] arraySizes); - synchronized int nElementCreate2(int[] elements, String[] names, int[] arraySizes) { + native long rsnElementCreate2(long con, int[]elements, String[] names, int[] arraySizes); + synchronized long nElementCreate2(int[] elements, String[] names, int[] arraySizes) { validate(); return rsnElementCreate2(mContext, elements, names, arraySizes); } - native void rsnElementGetNativeData(int con, int id, int[] elementData); - synchronized void nElementGetNativeData(int id, int[] elementData) { + native void rsnElementGetNativeData(long con, long id, int[] elementData); + synchronized void nElementGetNativeData(long id, int[] elementData) { validate(); rsnElementGetNativeData(mContext, id, elementData); } - native void rsnElementGetSubElements(int con, int id, + native void rsnElementGetSubElements(long con, long id, int[] IDs, String[] names, int[] arraySizes); - synchronized void nElementGetSubElements(int id, int[] IDs, String[] names, int[] arraySizes) { + synchronized void nElementGetSubElements(long id, int[] IDs, String[] names, int[] arraySizes) { validate(); rsnElementGetSubElements(mContext, id, IDs, names, arraySizes); } - native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv); - synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces, int yuv) { + native long rsnTypeCreate(long con, long eid, int x, int y, int z, boolean mips, boolean faces, int yuv); + synchronized long nTypeCreate(long eid, int x, int y, int z, boolean mips, boolean faces, int yuv) { validate(); return rsnTypeCreate(mContext, eid, x, y, z, mips, faces, yuv); } - native void rsnTypeGetNativeData(int con, int id, int[] typeData); - synchronized void nTypeGetNativeData(int id, int[] typeData) { + native void rsnTypeGetNativeData(long con, long id, int[] typeData); + synchronized void nTypeGetNativeData(long id, int[] typeData) { validate(); rsnTypeGetNativeData(mContext, id, typeData); } - native int rsnAllocationCreateTyped(int con, int type, int mip, int usage, int pointer); - synchronized int nAllocationCreateTyped(int type, int mip, int usage, int pointer) { + native long rsnAllocationCreateTyped(long con, long type, int mip, int usage, int pointer); + synchronized long nAllocationCreateTyped(long type, int mip, int usage, int pointer) { validate(); return rsnAllocationCreateTyped(mContext, type, mip, usage, pointer); } - native int rsnAllocationCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage); - synchronized int nAllocationCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) { + native long rsnAllocationCreateFromBitmap(long con, long type, int mip, Bitmap bmp, int usage); + synchronized long nAllocationCreateFromBitmap(long type, int mip, Bitmap bmp, int usage) { validate(); return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage); } - native int rsnAllocationCreateBitmapBackedAllocation(int con, int type, int mip, Bitmap bmp, int usage); - synchronized int nAllocationCreateBitmapBackedAllocation(int type, int mip, Bitmap bmp, int usage) { + native long rsnAllocationCreateBitmapBackedAllocation(long con, long type, int mip, Bitmap bmp, int usage); + synchronized long nAllocationCreateBitmapBackedAllocation(long type, int mip, Bitmap bmp, int usage) { validate(); return rsnAllocationCreateBitmapBackedAllocation(mContext, type, mip, bmp, usage); } - - native int rsnAllocationCubeCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage); - synchronized int nAllocationCubeCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) { + native long rsnAllocationCubeCreateFromBitmap(long con, long type, int mip, Bitmap bmp, int usage); + synchronized long nAllocationCubeCreateFromBitmap(long type, int mip, Bitmap bmp, int usage) { validate(); return rsnAllocationCubeCreateFromBitmap(mContext, type, mip, bmp, usage); } - native int rsnAllocationCreateBitmapRef(int con, int type, Bitmap bmp); - synchronized int nAllocationCreateBitmapRef(int type, Bitmap bmp) { + native long rsnAllocationCreateBitmapRef(long con, long type, Bitmap bmp); + synchronized long nAllocationCreateBitmapRef(long type, Bitmap bmp) { validate(); return rsnAllocationCreateBitmapRef(mContext, type, bmp); } - native int rsnAllocationCreateFromAssetStream(int con, int mips, int assetStream, int usage); - synchronized int nAllocationCreateFromAssetStream(int mips, int assetStream, int usage) { + native long rsnAllocationCreateFromAssetStream(long con, int mips, int assetStream, int usage); + synchronized long nAllocationCreateFromAssetStream(int mips, int assetStream, int usage) { validate(); return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage); } - native void rsnAllocationCopyToBitmap(int con, int alloc, Bitmap bmp); - synchronized void nAllocationCopyToBitmap(int alloc, Bitmap bmp) { + native void rsnAllocationCopyToBitmap(long con, long alloc, Bitmap bmp); + synchronized void nAllocationCopyToBitmap(long alloc, Bitmap bmp) { validate(); rsnAllocationCopyToBitmap(mContext, alloc, bmp); } - native void rsnAllocationSyncAll(int con, int alloc, int src); - synchronized void nAllocationSyncAll(int alloc, int src) { + native void rsnAllocationSyncAll(long con, long alloc, int src); + synchronized void nAllocationSyncAll(long alloc, int src) { validate(); rsnAllocationSyncAll(mContext, alloc, src); } - native Surface rsnAllocationGetSurface(int con, int alloc); - synchronized Surface nAllocationGetSurface(int alloc) { + native Surface rsnAllocationGetSurface(long con, long alloc); + synchronized Surface nAllocationGetSurface(long alloc) { validate(); return rsnAllocationGetSurface(mContext, alloc); } - native void rsnAllocationSetSurface(int con, int alloc, Surface sur); - synchronized void nAllocationSetSurface(int alloc, Surface sur) { + native void rsnAllocationSetSurface(long con, long alloc, Surface sur); + synchronized void nAllocationSetSurface(long alloc, Surface sur) { validate(); rsnAllocationSetSurface(mContext, alloc, sur); } - native void rsnAllocationIoSend(int con, int alloc); - synchronized void nAllocationIoSend(int alloc) { + native void rsnAllocationIoSend(long con, long alloc); + synchronized void nAllocationIoSend(long alloc) { validate(); rsnAllocationIoSend(mContext, alloc); } - native void rsnAllocationIoReceive(int con, int alloc); - synchronized void nAllocationIoReceive(int alloc) { + native void rsnAllocationIoReceive(long con, long alloc); + synchronized void nAllocationIoReceive(long alloc) { validate(); rsnAllocationIoReceive(mContext, alloc); } - native void rsnAllocationGenerateMipmaps(int con, int alloc); - synchronized void nAllocationGenerateMipmaps(int alloc) { + native void rsnAllocationGenerateMipmaps(long con, long alloc); + synchronized void nAllocationGenerateMipmaps(long alloc) { validate(); rsnAllocationGenerateMipmaps(mContext, alloc); } - native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp); - synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) { + native void rsnAllocationCopyFromBitmap(long con, long alloc, Bitmap bmp); + synchronized void nAllocationCopyFromBitmap(long alloc, Bitmap bmp) { validate(); rsnAllocationCopyFromBitmap(mContext, alloc, bmp); } - native void rsnAllocationData1D(int con, int id, int off, int mip, int count, int[] d, int sizeBytes); - synchronized void nAllocationData1D(int id, int off, int mip, int count, int[] d, int sizeBytes) { - validate(); - rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); - } - native void rsnAllocationData1D(int con, int id, int off, int mip, int count, short[] d, int sizeBytes); - synchronized void nAllocationData1D(int id, int off, int mip, int count, short[] d, int sizeBytes) { - validate(); - rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); - } - native void rsnAllocationData1D(int con, int id, int off, int mip, int count, byte[] d, int sizeBytes); - synchronized void nAllocationData1D(int id, int off, int mip, int count, byte[] d, int sizeBytes) { - validate(); - rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); - } - native void rsnAllocationData1D(int con, int id, int off, int mip, int count, float[] d, int sizeBytes); - synchronized void nAllocationData1D(int id, int off, int mip, int count, float[] d, int sizeBytes) { + native void rsnAllocationData1D(long con, long id, int off, int mip, int count, Object d, int sizeBytes, int dt); + synchronized void nAllocationData1D(long id, int off, int mip, int count, Object d, int sizeBytes, Element.DataType dt) { validate(); - rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); + rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID); } - native void rsnAllocationElementData1D(int con, int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes); - synchronized void nAllocationElementData1D(int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) { + native void rsnAllocationElementData1D(long con,long id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes); + synchronized void nAllocationElementData1D(long id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) { validate(); rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes); } - native void rsnAllocationData2D(int con, - int dstAlloc, int dstXoff, int dstYoff, + native void rsnAllocationData2D(long con, + long dstAlloc, int dstXoff, int dstYoff, int dstMip, int dstFace, int width, int height, - int srcAlloc, int srcXoff, int srcYoff, + long srcAlloc, int srcXoff, int srcYoff, int srcMip, int srcFace); - synchronized void nAllocationData2D(int dstAlloc, int dstXoff, int dstYoff, + synchronized void nAllocationData2D(long dstAlloc, int dstXoff, int dstYoff, int dstMip, int dstFace, int width, int height, - int srcAlloc, int srcXoff, int srcYoff, + long srcAlloc, int srcXoff, int srcYoff, int srcMip, int srcFace) { validate(); rsnAllocationData2D(mContext, @@ -433,42 +413,30 @@ public class RenderScript { srcMip, srcFace); } - native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes); - synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes) { - validate(); - rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); - } - native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes); - synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes) { - validate(); - rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); - } - native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes); - synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes) { - validate(); - rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); - } - native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes); - synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes) { + native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, + int w, int h, Object d, int sizeBytes, int dt); + synchronized void nAllocationData2D(long id, int xoff, int yoff, int mip, int face, + int w, int h, Object d, int sizeBytes, Element.DataType dt) { validate(); - rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); + rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID); } - native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, Bitmap b); - synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, Bitmap b) { + + native void rsnAllocationData2D(long con, long id, int xoff, int yoff, int mip, int face, Bitmap b); + synchronized void nAllocationData2D(long id, int xoff, int yoff, int mip, int face, Bitmap b) { validate(); rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, b); } - native void rsnAllocationData3D(int con, - int dstAlloc, int dstXoff, int dstYoff, int dstZoff, + native void rsnAllocationData3D(long con, + long dstAlloc, int dstXoff, int dstYoff, int dstZoff, int dstMip, int width, int height, int depth, - int srcAlloc, int srcXoff, int srcYoff, int srcZoff, + long srcAlloc, int srcXoff, int srcYoff, int srcZoff, int srcMip); - synchronized void nAllocationData3D(int dstAlloc, int dstXoff, int dstYoff, int dstZoff, + synchronized void nAllocationData3D(long dstAlloc, int dstXoff, int dstYoff, int dstZoff, int dstMip, int width, int height, int depth, - int srcAlloc, int srcXoff, int srcYoff, int srcZoff, + long srcAlloc, int srcXoff, int srcYoff, int srcZoff, int srcMip) { validate(); rsnAllocationData3D(mContext, @@ -477,130 +445,118 @@ public class RenderScript { srcAlloc, srcXoff, srcYoff, srcZoff, srcMip); } - native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes); - synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, byte[] d, int sizeBytes) { - validate(); - rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes); - } - native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes); - synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, short[] d, int sizeBytes) { - validate(); - rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes); - } - native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes); - synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, int[] d, int sizeBytes) { - validate(); - rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes); - } - native void rsnAllocationData3D(int con, int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes); - synchronized void nAllocationData3D(int id, int xoff, int yoff, int zoff, int mip, int w, int h, int depth, float[] d, int sizeBytes) { + native void rsnAllocationData3D(long con, long id, int xoff, int yoff, int zoff, int mip, + int w, int h, int depth, Object d, int sizeBytes, int dt); + synchronized void nAllocationData3D(long id, int xoff, int yoff, int zoff, int mip, + int w, int h, int depth, Object d, int sizeBytes, Element.DataType dt) { validate(); - rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes); + rsnAllocationData3D(mContext, id, xoff, yoff, zoff, mip, w, h, depth, d, sizeBytes, dt.mID); } - - native void rsnAllocationRead(int con, int id, byte[] d); - synchronized void nAllocationRead(int id, byte[] d) { - validate(); - rsnAllocationRead(mContext, id, d); - } - native void rsnAllocationRead(int con, int id, short[] d); - synchronized void nAllocationRead(int id, short[] d) { + native void rsnAllocationRead(long con, long id, Object d, int dt); + synchronized void nAllocationRead(long id, Object d, Element.DataType dt) { validate(); - rsnAllocationRead(mContext, id, d); + rsnAllocationRead(mContext, id, d, dt.mID); } - native void rsnAllocationRead(int con, int id, int[] d); - synchronized void nAllocationRead(int id, int[] d) { + + native void rsnAllocationRead1D(long con, long id, int off, int mip, int count, Object d, + int sizeBytes, int dt); + synchronized void nAllocationRead1D(long id, int off, int mip, int count, Object d, + int sizeBytes, Element.DataType dt) { validate(); - rsnAllocationRead(mContext, id, d); + rsnAllocationRead1D(mContext, id, off, mip, count, d, sizeBytes, dt.mID); } - native void rsnAllocationRead(int con, int id, float[] d); - synchronized void nAllocationRead(int id, float[] d) { + + native void rsnAllocationRead2D(long con, long id, int xoff, int yoff, int mip, int face, + int w, int h, Object d, int sizeBytes, int dt); + synchronized void nAllocationRead2D(long id, int xoff, int yoff, int mip, int face, + int w, int h, Object d, int sizeBytes, Element.DataType dt) { validate(); - rsnAllocationRead(mContext, id, d); + rsnAllocationRead2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes, dt.mID); } - native int rsnAllocationGetType(int con, int id); - synchronized int nAllocationGetType(int id) { + + native long rsnAllocationGetType(long con, long id); + synchronized long nAllocationGetType(long id) { validate(); return rsnAllocationGetType(mContext, id); } - native void rsnAllocationResize1D(int con, int id, int dimX); - synchronized void nAllocationResize1D(int id, int dimX) { + native void rsnAllocationResize1D(long con, long id, int dimX); + synchronized void nAllocationResize1D(long id, int dimX) { validate(); rsnAllocationResize1D(mContext, id, dimX); } - native int rsnFileA3DCreateFromAssetStream(int con, int assetStream); - synchronized int nFileA3DCreateFromAssetStream(int assetStream) { + native long rsnFileA3DCreateFromAssetStream(long con, int assetStream); + synchronized long nFileA3DCreateFromAssetStream(int assetStream) { validate(); return rsnFileA3DCreateFromAssetStream(mContext, assetStream); } - native int rsnFileA3DCreateFromFile(int con, String path); - synchronized int nFileA3DCreateFromFile(String path) { + native long rsnFileA3DCreateFromFile(long con, String path); + synchronized long nFileA3DCreateFromFile(String path) { validate(); return rsnFileA3DCreateFromFile(mContext, path); } - native int rsnFileA3DCreateFromAsset(int con, AssetManager mgr, String path); - synchronized int nFileA3DCreateFromAsset(AssetManager mgr, String path) { + native long rsnFileA3DCreateFromAsset(long con, AssetManager mgr, String path); + synchronized long nFileA3DCreateFromAsset(AssetManager mgr, String path) { validate(); return rsnFileA3DCreateFromAsset(mContext, mgr, path); } - native int rsnFileA3DGetNumIndexEntries(int con, int fileA3D); - synchronized int nFileA3DGetNumIndexEntries(int fileA3D) { + native int rsnFileA3DGetNumIndexEntries(long con, long fileA3D); + synchronized int nFileA3DGetNumIndexEntries(long fileA3D) { validate(); return rsnFileA3DGetNumIndexEntries(mContext, fileA3D); } - native void rsnFileA3DGetIndexEntries(int con, int fileA3D, int numEntries, int[] IDs, String[] names); - synchronized void nFileA3DGetIndexEntries(int fileA3D, int numEntries, int[] IDs, String[] names) { + native void rsnFileA3DGetIndexEntries(long con, long fileA3D, int numEntries, int[] IDs, String[] names); + synchronized void nFileA3DGetIndexEntries(long fileA3D, int numEntries, int[] IDs, String[] names) { validate(); rsnFileA3DGetIndexEntries(mContext, fileA3D, numEntries, IDs, names); } - native int rsnFileA3DGetEntryByIndex(int con, int fileA3D, int index); - synchronized int nFileA3DGetEntryByIndex(int fileA3D, int index) { + native int rsnFileA3DGetEntryByIndex(long con, long fileA3D, int index); + synchronized int nFileA3DGetEntryByIndex(long fileA3D, int index) { validate(); return rsnFileA3DGetEntryByIndex(mContext, fileA3D, index); } - native int rsnFontCreateFromFile(int con, String fileName, float size, int dpi); + native int rsnFontCreateFromFile(long con, String fileName, float size, int dpi); synchronized int nFontCreateFromFile(String fileName, float size, int dpi) { validate(); return rsnFontCreateFromFile(mContext, fileName, size, dpi); } - native int rsnFontCreateFromAssetStream(int con, String name, float size, int dpi, int assetStream); + native int rsnFontCreateFromAssetStream(long con, String name, float size, int dpi, int assetStream); synchronized int nFontCreateFromAssetStream(String name, float size, int dpi, int assetStream) { validate(); return rsnFontCreateFromAssetStream(mContext, name, size, dpi, assetStream); } - native int rsnFontCreateFromAsset(int con, AssetManager mgr, String path, float size, int dpi); + native int rsnFontCreateFromAsset(long con, AssetManager mgr, String path, float size, int dpi); synchronized int nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) { validate(); return rsnFontCreateFromAsset(mContext, mgr, path, size, dpi); } - native void rsnScriptBindAllocation(int con, int script, int alloc, int slot); - synchronized void nScriptBindAllocation(int script, int alloc, int slot) { + native void rsnScriptBindAllocation(long con, long script, long alloc, int slot); + synchronized void nScriptBindAllocation(long script, long alloc, int slot) { validate(); rsnScriptBindAllocation(mContext, script, alloc, slot); } - native void rsnScriptSetTimeZone(int con, int script, byte[] timeZone); - synchronized void nScriptSetTimeZone(int script, byte[] timeZone) { + native void rsnScriptSetTimeZone(long con, long script, byte[] timeZone); + synchronized void nScriptSetTimeZone(long script, byte[] timeZone) { validate(); rsnScriptSetTimeZone(mContext, script, timeZone); } - native void rsnScriptInvoke(int con, int id, int slot); - synchronized void nScriptInvoke(int id, int slot) { + native void rsnScriptInvoke(long con, long id, int slot); + synchronized void nScriptInvoke(long id, int slot) { validate(); rsnScriptInvoke(mContext, id, slot); } - native void rsnScriptForEach(int con, int id, int slot, int ain, int aout, byte[] params); - native void rsnScriptForEach(int con, int id, int slot, int ain, int aout); - native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, byte[] params, + native void rsnScriptForEach(long con, long id, int slot, long ain, long aout, byte[] params); + native void rsnScriptForEach(long con, long id, int slot, long ain, long aout); + native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout, byte[] params, int xstart, int xend, int ystart, int yend, int zstart, int zend); - native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, + native void rsnScriptForEachClipped(long con, long id, int slot, long ain, long aout, int xstart, int xend, int ystart, int yend, int zstart, int zend); - synchronized void nScriptForEach(int id, int slot, int ain, int aout, byte[] params) { + synchronized void nScriptForEach(long id, int slot, long ain, long aout, byte[] params) { validate(); if (params == null) { rsnScriptForEach(mContext, id, slot, ain, aout); @@ -609,7 +565,7 @@ public class RenderScript { } } - synchronized void nScriptForEachClipped(int id, int slot, int ain, int aout, byte[] params, + synchronized void nScriptForEachClipped(long id, int slot, long ain, long aout, byte[] params, int xstart, int xend, int ystart, int yend, int zstart, int zend) { validate(); if (params == null) { @@ -619,127 +575,127 @@ public class RenderScript { } } - native void rsnScriptInvokeV(int con, int id, int slot, byte[] params); - synchronized void nScriptInvokeV(int id, int slot, byte[] params) { + native void rsnScriptInvokeV(long con, long id, int slot, byte[] params); + synchronized void nScriptInvokeV(long id, int slot, byte[] params) { validate(); rsnScriptInvokeV(mContext, id, slot, params); } - native void rsnScriptSetVarI(int con, int id, int slot, int val); - synchronized void nScriptSetVarI(int id, int slot, int val) { + native void rsnScriptSetVarI(long con, long id, int slot, int val); + synchronized void nScriptSetVarI(long id, int slot, int val) { validate(); rsnScriptSetVarI(mContext, id, slot, val); } - native int rsnScriptGetVarI(int con, int id, int slot); - synchronized int nScriptGetVarI(int id, int slot) { + native int rsnScriptGetVarI(long con, long id, int slot); + synchronized int nScriptGetVarI(long id, int slot) { validate(); return rsnScriptGetVarI(mContext, id, slot); } - native void rsnScriptSetVarJ(int con, int id, int slot, long val); - synchronized void nScriptSetVarJ(int id, int slot, long val) { + native void rsnScriptSetVarJ(long con, long id, int slot, long val); + synchronized void nScriptSetVarJ(long id, int slot, long val) { validate(); rsnScriptSetVarJ(mContext, id, slot, val); } - native long rsnScriptGetVarJ(int con, int id, int slot); - synchronized long nScriptGetVarJ(int id, int slot) { + native long rsnScriptGetVarJ(long con, long id, int slot); + synchronized long nScriptGetVarJ(long id, int slot) { validate(); return rsnScriptGetVarJ(mContext, id, slot); } - native void rsnScriptSetVarF(int con, int id, int slot, float val); - synchronized void nScriptSetVarF(int id, int slot, float val) { + native void rsnScriptSetVarF(long con, long id, int slot, float val); + synchronized void nScriptSetVarF(long id, int slot, float val) { validate(); rsnScriptSetVarF(mContext, id, slot, val); } - native float rsnScriptGetVarF(int con, int id, int slot); - synchronized float nScriptGetVarF(int id, int slot) { + native float rsnScriptGetVarF(long con, long id, int slot); + synchronized float nScriptGetVarF(long id, int slot) { validate(); return rsnScriptGetVarF(mContext, id, slot); } - native void rsnScriptSetVarD(int con, int id, int slot, double val); - synchronized void nScriptSetVarD(int id, int slot, double val) { + native void rsnScriptSetVarD(long con, long id, int slot, double val); + synchronized void nScriptSetVarD(long id, int slot, double val) { validate(); rsnScriptSetVarD(mContext, id, slot, val); } - native double rsnScriptGetVarD(int con, int id, int slot); - synchronized double nScriptGetVarD(int id, int slot) { + native double rsnScriptGetVarD(long con, long id, int slot); + synchronized double nScriptGetVarD(long id, int slot) { validate(); return rsnScriptGetVarD(mContext, id, slot); } - native void rsnScriptSetVarV(int con, int id, int slot, byte[] val); - synchronized void nScriptSetVarV(int id, int slot, byte[] val) { + native void rsnScriptSetVarV(long con, long id, int slot, byte[] val); + synchronized void nScriptSetVarV(long id, int slot, byte[] val) { validate(); rsnScriptSetVarV(mContext, id, slot, val); } - native void rsnScriptGetVarV(int con, int id, int slot, byte[] val); - synchronized void nScriptGetVarV(int id, int slot, byte[] val) { + native void rsnScriptGetVarV(long con, long id, int slot, byte[] val); + synchronized void nScriptGetVarV(long id, int slot, byte[] val) { validate(); rsnScriptGetVarV(mContext, id, slot, val); } - native void rsnScriptSetVarVE(int con, int id, int slot, byte[] val, - int e, int[] dims); - synchronized void nScriptSetVarVE(int id, int slot, byte[] val, - int e, int[] dims) { + native void rsnScriptSetVarVE(long con, long id, int slot, byte[] val, + long e, int[] dims); + synchronized void nScriptSetVarVE(long id, int slot, byte[] val, + long e, int[] dims) { validate(); rsnScriptSetVarVE(mContext, id, slot, val, e, dims); } - native void rsnScriptSetVarObj(int con, int id, int slot, int val); - synchronized void nScriptSetVarObj(int id, int slot, int val) { + native void rsnScriptSetVarObj(long con, long id, int slot, long val); + synchronized void nScriptSetVarObj(long id, int slot, long val) { validate(); rsnScriptSetVarObj(mContext, id, slot, val); } - native int rsnScriptCCreate(int con, String resName, String cacheDir, + native int rsnScriptCCreate(long con, String resName, String cacheDir, byte[] script, int length); synchronized int nScriptCCreate(String resName, String cacheDir, byte[] script, int length) { validate(); return rsnScriptCCreate(mContext, resName, cacheDir, script, length); } - native int rsnScriptIntrinsicCreate(int con, int id, int eid); - synchronized int nScriptIntrinsicCreate(int id, int eid) { + native long rsnScriptIntrinsicCreate(long con, int id, long eid); + synchronized long nScriptIntrinsicCreate(int id, long eid) { validate(); return rsnScriptIntrinsicCreate(mContext, id, eid); } - native int rsnScriptKernelIDCreate(int con, int sid, int slot, int sig); - synchronized int nScriptKernelIDCreate(int sid, int slot, int sig) { + native long rsnScriptKernelIDCreate(long con, long sid, int slot, int sig); + synchronized long nScriptKernelIDCreate(long sid, int slot, int sig) { validate(); return rsnScriptKernelIDCreate(mContext, sid, slot, sig); } - native int rsnScriptFieldIDCreate(int con, int sid, int slot); - synchronized int nScriptFieldIDCreate(int sid, int slot) { + native long rsnScriptFieldIDCreate(long con, long sid, int slot); + synchronized long nScriptFieldIDCreate(long sid, int slot) { validate(); return rsnScriptFieldIDCreate(mContext, sid, slot); } - native int rsnScriptGroupCreate(int con, int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types); - synchronized int nScriptGroupCreate(int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types) { + native long rsnScriptGroupCreate(long con, int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types); + synchronized long nScriptGroupCreate(int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types) { validate(); return rsnScriptGroupCreate(mContext, kernels, src, dstk, dstf, types); } - native void rsnScriptGroupSetInput(int con, int group, int kernel, int alloc); - synchronized void nScriptGroupSetInput(int group, int kernel, int alloc) { + native void rsnScriptGroupSetInput(long con, long group, long kernel, long alloc); + synchronized void nScriptGroupSetInput(long group, long kernel, long alloc) { validate(); rsnScriptGroupSetInput(mContext, group, kernel, alloc); } - native void rsnScriptGroupSetOutput(int con, int group, int kernel, int alloc); - synchronized void nScriptGroupSetOutput(int group, int kernel, int alloc) { + native void rsnScriptGroupSetOutput(long con, long group, long kernel, long alloc); + synchronized void nScriptGroupSetOutput(long group, long kernel, long alloc) { validate(); rsnScriptGroupSetOutput(mContext, group, kernel, alloc); } - native void rsnScriptGroupExecute(int con, int group); - synchronized void nScriptGroupExecute(int group) { + native void rsnScriptGroupExecute(long con, long group); + synchronized void nScriptGroupExecute(long group) { validate(); rsnScriptGroupExecute(mContext, group); } - native int rsnSamplerCreate(int con, int magFilter, int minFilter, + native int rsnSamplerCreate(long con, int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso); synchronized int nSamplerCreate(int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso) { @@ -747,7 +703,7 @@ public class RenderScript { return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso); } - native int rsnProgramStoreCreate(int con, boolean r, boolean g, boolean b, boolean a, + native int rsnProgramStoreCreate(long con, boolean r, boolean g, boolean b, boolean a, boolean depthMask, boolean dither, int srcMode, int dstMode, int depthFunc); synchronized int nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a, @@ -758,72 +714,72 @@ public class RenderScript { dstMode, depthFunc); } - native int rsnProgramRasterCreate(int con, boolean pointSprite, int cullMode); - synchronized int nProgramRasterCreate(boolean pointSprite, int cullMode) { + native long rsnProgramRasterCreate(long con, boolean pointSprite, int cullMode); + synchronized long nProgramRasterCreate(boolean pointSprite, int cullMode) { validate(); return rsnProgramRasterCreate(mContext, pointSprite, cullMode); } - native void rsnProgramBindConstants(int con, int pv, int slot, int mID); - synchronized void nProgramBindConstants(int pv, int slot, int mID) { + native void rsnProgramBindConstants(long con, long pv, int slot, long mID); + synchronized void nProgramBindConstants(long pv, int slot, long mID) { validate(); rsnProgramBindConstants(mContext, pv, slot, mID); } - native void rsnProgramBindTexture(int con, int vpf, int slot, int a); - synchronized void nProgramBindTexture(int vpf, int slot, int a) { + native void rsnProgramBindTexture(long con, long vpf, int slot, long a); + synchronized void nProgramBindTexture(long vpf, int slot, long a) { validate(); rsnProgramBindTexture(mContext, vpf, slot, a); } - native void rsnProgramBindSampler(int con, int vpf, int slot, int s); - synchronized void nProgramBindSampler(int vpf, int slot, int s) { + native void rsnProgramBindSampler(long con, long vpf, int slot, long s); + synchronized void nProgramBindSampler(long vpf, int slot, long s) { validate(); rsnProgramBindSampler(mContext, vpf, slot, s); } - native int rsnProgramFragmentCreate(int con, String shader, String[] texNames, int[] params); - synchronized int nProgramFragmentCreate(String shader, String[] texNames, int[] params) { + native long rsnProgramFragmentCreate(long con, String shader, String[] texNames, int[] params); + synchronized long nProgramFragmentCreate(String shader, String[] texNames, int[] params) { validate(); return rsnProgramFragmentCreate(mContext, shader, texNames, params); } - native int rsnProgramVertexCreate(int con, String shader, String[] texNames, int[] params); - synchronized int nProgramVertexCreate(String shader, String[] texNames, int[] params) { + native long rsnProgramVertexCreate(long con, String shader, String[] texNames, int[] params); + synchronized long nProgramVertexCreate(String shader, String[] texNames, int[] params) { validate(); return rsnProgramVertexCreate(mContext, shader, texNames, params); } - native int rsnMeshCreate(int con, int[] vtx, int[] idx, int[] prim); - synchronized int nMeshCreate(int[] vtx, int[] idx, int[] prim) { + native long rsnMeshCreate(long con, int[] vtx, int[] idx, int[] prim); + synchronized long nMeshCreate(int[] vtx, int[] idx, int[] prim) { validate(); return rsnMeshCreate(mContext, vtx, idx, prim); } - native int rsnMeshGetVertexBufferCount(int con, int id); - synchronized int nMeshGetVertexBufferCount(int id) { + native int rsnMeshGetVertexBufferCount(long con, long id); + synchronized int nMeshGetVertexBufferCount(long id) { validate(); return rsnMeshGetVertexBufferCount(mContext, id); } - native int rsnMeshGetIndexCount(int con, int id); - synchronized int nMeshGetIndexCount(int id) { + native int rsnMeshGetIndexCount(long con, long id); + synchronized int nMeshGetIndexCount(long id) { validate(); return rsnMeshGetIndexCount(mContext, id); } - native void rsnMeshGetVertices(int con, int id, int[] vtxIds, int vtxIdCount); - synchronized void nMeshGetVertices(int id, int[] vtxIds, int vtxIdCount) { + native void rsnMeshGetVertices(long con, long id, int[] vtxIds, int vtxIdCount); + synchronized void nMeshGetVertices(long id, int[] vtxIds, int vtxIdCount) { validate(); rsnMeshGetVertices(mContext, id, vtxIds, vtxIdCount); } - native void rsnMeshGetIndices(int con, int id, int[] idxIds, int[] primitives, int vtxIdCount); - synchronized void nMeshGetIndices(int id, int[] idxIds, int[] primitives, int vtxIdCount) { + native void rsnMeshGetIndices(long con, long id, int[] idxIds, int[] primitives, int vtxIdCount); + synchronized void nMeshGetIndices(long id, int[] idxIds, int[] primitives, int vtxIdCount) { validate(); rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount); } - native int rsnPathCreate(int con, int prim, boolean isStatic, int vtx, int loop, float q); - synchronized int nPathCreate(int prim, boolean isStatic, int vtx, int loop, float q) { + native long rsnPathCreate(long con, int prim, boolean isStatic, long vtx, int loop, float q); + synchronized long nPathCreate(int prim, boolean isStatic, long vtx, int loop, float q) { validate(); return rsnPathCreate(mContext, prim, isStatic, vtx, loop, q); } - int mDev; - int mContext; + long mDev; + long mContext; @SuppressWarnings({"FieldCanBeLocal"}) MessageThread mMessageThread; @@ -1248,7 +1204,7 @@ public class RenderScript { return mContext != 0; } - int safeID(BaseObj o) { + long safeID(BaseObj o) { if(o != null) { return o.getID(this); } diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java index bac9c68..714e835 100644 --- a/graphics/java/android/renderscript/RenderScriptGL.java +++ b/graphics/java/android/renderscript/RenderScriptGL.java @@ -16,17 +16,10 @@ package android.renderscript; -import java.lang.reflect.Field; - import android.content.Context; -import android.graphics.PixelFormat; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.SurfaceTexture; -import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; -import android.view.SurfaceView; /** * @hide @@ -286,7 +279,7 @@ public class RenderScriptGL extends RenderScript { */ public void bindRootScript(Script s) { validate(); - nContextBindRootScript(safeID(s)); + nContextBindRootScript((int)safeID(s)); } /** @@ -298,7 +291,7 @@ public class RenderScriptGL extends RenderScript { */ public void bindProgramStore(ProgramStore p) { validate(); - nContextBindProgramStore(safeID(p)); + nContextBindProgramStore((int)safeID(p)); } /** @@ -310,7 +303,7 @@ public class RenderScriptGL extends RenderScript { */ public void bindProgramFragment(ProgramFragment p) { validate(); - nContextBindProgramFragment(safeID(p)); + nContextBindProgramFragment((int)safeID(p)); } /** @@ -322,7 +315,7 @@ public class RenderScriptGL extends RenderScript { */ public void bindProgramRaster(ProgramRaster p) { validate(); - nContextBindProgramRaster(safeID(p)); + nContextBindProgramRaster((int)safeID(p)); } /** @@ -334,7 +327,7 @@ public class RenderScriptGL extends RenderScript { */ public void bindProgramVertex(ProgramVertex p) { validate(); - nContextBindProgramVertex(safeID(p)); + nContextBindProgramVertex((int)safeID(p)); } } diff --git a/graphics/java/android/renderscript/Sampler.java b/graphics/java/android/renderscript/Sampler.java index 623055f..39b867b 100644 --- a/graphics/java/android/renderscript/Sampler.java +++ b/graphics/java/android/renderscript/Sampler.java @@ -16,17 +16,6 @@ package android.renderscript; - -import java.io.IOException; -import java.io.InputStream; - -import android.content.res.Resources; -import android.os.Bundle; -import android.util.Log; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; - /** * Sampler object that defines how Allocations can be read as textures within a * kernel. Samplers are used in conjunction with the {@code rsSample} runtime diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java index 0026e0e..5ab18f7 100644 --- a/graphics/java/android/renderscript/Script.java +++ b/graphics/java/android/renderscript/Script.java @@ -36,7 +36,7 @@ public class Script extends BaseObj { Script mScript; int mSlot; int mSig; - KernelID(int id, RenderScript rs, Script s, int slot, int sig) { + KernelID(long id, RenderScript rs, Script s, int slot, int sig) { super(id, rs); mScript = s; mSlot = slot; @@ -54,7 +54,7 @@ public class Script extends BaseObj { return k; } - int id = mRS.nScriptKernelIDCreate(getID(mRS), slot, sig); + long id = mRS.nScriptKernelIDCreate(getID(mRS), slot, sig); if (id == 0) { throw new RSDriverException("Failed to create KernelID"); } @@ -75,7 +75,7 @@ public class Script extends BaseObj { public static final class FieldID extends BaseObj { Script mScript; int mSlot; - FieldID(int id, RenderScript rs, Script s, int slot) { + FieldID(long id, RenderScript rs, Script s, int slot) { super(id, rs); mScript = s; mSlot = slot; @@ -92,7 +92,7 @@ public class Script extends BaseObj { return f; } - int id = mRS.nScriptFieldIDCreate(getID(mRS), slot); + long id = mRS.nScriptFieldIDCreate(getID(mRS), slot); if (id == 0) { throw new RSDriverException("Failed to create FieldID"); } @@ -132,11 +132,11 @@ public class Script extends BaseObj { throw new RSIllegalArgumentException( "At least one of ain or aout is required to be non-null."); } - int in_id = 0; + long in_id = 0; if (ain != null) { in_id = ain.getID(mRS); } - int out_id = 0; + long out_id = 0; if (aout != null) { out_id = aout.getID(mRS); } @@ -161,11 +161,11 @@ public class Script extends BaseObj { forEach(slot, ain, aout, v); return; } - int in_id = 0; + long in_id = 0; if (ain != null) { in_id = ain.getID(mRS); } - int out_id = 0; + long out_id = 0; if (aout != null) { out_id = aout.getID(mRS); } @@ -176,7 +176,7 @@ public class Script extends BaseObj { mRS.nScriptForEachClipped(getID(mRS), slot, in_id, out_id, params, sc.xstart, sc.xend, sc.ystart, sc.yend, sc.zstart, sc.zend); } - Script(int id, RenderScript rs) { + Script(long id, RenderScript rs) { super(id, rs); } diff --git a/graphics/java/android/renderscript/ScriptC.java b/graphics/java/android/renderscript/ScriptC.java index b0a5759..c7979f6 100644 --- a/graphics/java/android/renderscript/ScriptC.java +++ b/graphics/java/android/renderscript/ScriptC.java @@ -16,18 +16,11 @@ package android.renderscript; -import android.content.Context; import android.content.res.Resources; -import android.util.Log; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.Map.Entry; -import java.util.HashMap; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; /** * The superclass for all user-defined scripts. This is only diff --git a/graphics/java/android/renderscript/ScriptGroup.java b/graphics/java/android/renderscript/ScriptGroup.java index 1416641..f1a7273 100644 --- a/graphics/java/android/renderscript/ScriptGroup.java +++ b/graphics/java/android/renderscript/ScriptGroup.java @@ -16,7 +16,6 @@ package android.renderscript; -import java.lang.reflect.Method; import java.util.ArrayList; /** @@ -89,7 +88,7 @@ public final class ScriptGroup extends BaseObj { } - ScriptGroup(int id, RenderScript rs) { + ScriptGroup(long id, RenderScript rs) { super(id, rs); } @@ -380,6 +379,7 @@ public final class ScriptGroup extends BaseObj { * @return ScriptGroup The new ScriptGroup */ public ScriptGroup create() { + // FIXME: this is broken for 64-bit if (mNodes.size() == 0) { throw new RSInvalidStateException("Empty script groups are not allowed"); @@ -400,7 +400,7 @@ public final class ScriptGroup extends BaseObj { Node n = mNodes.get(ct); for (int ct2=0; ct2 < n.mKernels.size(); ct2++) { final Script.KernelID kid = n.mKernels.get(ct2); - kernels[idx++] = kid.getID(mRS); + kernels[idx++] = (int)kid.getID(mRS); boolean hasInput = false; boolean hasOutput = false; @@ -434,17 +434,17 @@ public final class ScriptGroup extends BaseObj { for (int ct=0; ct < mLines.size(); ct++) { ConnectLine cl = mLines.get(ct); - src[ct] = cl.mFrom.getID(mRS); + src[ct] = (int)cl.mFrom.getID(mRS); if (cl.mToK != null) { - dstk[ct] = cl.mToK.getID(mRS); + dstk[ct] = (int)cl.mToK.getID(mRS); } if (cl.mToF != null) { - dstf[ct] = cl.mToF.getID(mRS); + dstf[ct] = (int)cl.mToF.getID(mRS); } - types[ct] = cl.mAllocationType.getID(mRS); + types[ct] = (int)cl.mAllocationType.getID(mRS); } - int id = mRS.nScriptGroupCreate(kernels, src, dstk, dstf, types); + long id = mRS.nScriptGroupCreate(kernels, src, dstk, dstf, types); if (id == 0) { throw new RSRuntimeException("Object creation error, should not happen."); } diff --git a/graphics/java/android/renderscript/ScriptIntrinsic.java b/graphics/java/android/renderscript/ScriptIntrinsic.java index 096268a..8719e01 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsic.java +++ b/graphics/java/android/renderscript/ScriptIntrinsic.java @@ -25,7 +25,7 @@ package android.renderscript; * Not intended for direct use. **/ public abstract class ScriptIntrinsic extends Script { - ScriptIntrinsic(int id, RenderScript rs) { + ScriptIntrinsic(long id, RenderScript rs) { super(id, rs); } } diff --git a/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java b/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java index 34540a1..33e64bd 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java +++ b/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java @@ -16,8 +16,6 @@ package android.renderscript; -import android.util.Log; - /** * * Intrinsic for converting RGB to RGBA by using a 3D lookup table. The @@ -30,7 +28,7 @@ public final class ScriptIntrinsic3DLUT extends ScriptIntrinsic { private Allocation mLUT; private Element mElement; - private ScriptIntrinsic3DLUT(int id, RenderScript rs, Element e) { + private ScriptIntrinsic3DLUT(long id, RenderScript rs, Element e) { super(id, rs); mElement = e; } @@ -46,7 +44,7 @@ public final class ScriptIntrinsic3DLUT extends ScriptIntrinsic { * @return ScriptIntrinsic3DLUT */ public static ScriptIntrinsic3DLUT create(RenderScript rs, Element e) { - int id = rs.nScriptIntrinsicCreate(8, e.getID(rs)); + long id = rs.nScriptIntrinsicCreate(8, e.getID(rs)); if (!e.isCompatible(Element.U8_4(rs))) { throw new RSIllegalArgumentException("Element must be compatible with uchar4."); diff --git a/graphics/java/android/renderscript/ScriptIntrinsicBlend.java b/graphics/java/android/renderscript/ScriptIntrinsicBlend.java index 0e05bc8..40f1a3e 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicBlend.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicBlend.java @@ -21,7 +21,7 @@ package android.renderscript; * Intrinsic kernels for blending two {@link android.renderscript.Allocation} objects. **/ public class ScriptIntrinsicBlend extends ScriptIntrinsic { - ScriptIntrinsicBlend(int id, RenderScript rs) { + ScriptIntrinsicBlend(long id, RenderScript rs) { super(id, rs); } @@ -35,7 +35,7 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { */ public static ScriptIntrinsicBlend create(RenderScript rs, Element e) { // 7 comes from RS_SCRIPT_INTRINSIC_ID_BLEND in rsDefines.h - int id = rs.nScriptIntrinsicCreate(7, e.getID(rs)); + long id = rs.nScriptIntrinsicCreate(7, e.getID(rs)); return new ScriptIntrinsicBlend(id, rs); } diff --git a/graphics/java/android/renderscript/ScriptIntrinsicBlur.java b/graphics/java/android/renderscript/ScriptIntrinsicBlur.java index aaf5ffc..2b36d27 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicBlur.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicBlur.java @@ -16,10 +16,6 @@ package android.renderscript; -import android.content.Context; -import android.content.res.Resources; -import android.util.Log; - /** * Intrinsic Gausian blur filter. Applies a gaussian blur of the * specified radius to all elements of an allocation. @@ -30,7 +26,7 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic { private final float[] mValues = new float[9]; private Allocation mInput; - private ScriptIntrinsicBlur(int id, RenderScript rs) { + private ScriptIntrinsicBlur(long id, RenderScript rs) { super(id, rs); } @@ -49,7 +45,7 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic { if ((!e.isCompatible(Element.U8_4(rs))) && (!e.isCompatible(Element.U8(rs)))) { throw new RSIllegalArgumentException("Unsuported element type."); } - int id = rs.nScriptIntrinsicCreate(5, e.getID(rs)); + long id = rs.nScriptIntrinsicCreate(5, e.getID(rs)); ScriptIntrinsicBlur sib = new ScriptIntrinsicBlur(id, rs); sib.setRadius(5.f); return sib; diff --git a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java index 32c3d15..4b0d507 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java @@ -16,8 +16,6 @@ package android.renderscript; -import android.util.Log; - /** * Intrinsic for applying a color matrix to allocations. * @@ -43,7 +41,7 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { private final Matrix4f mMatrix = new Matrix4f(); private final Float4 mAdd = new Float4(); - private ScriptIntrinsicColorMatrix(int id, RenderScript rs) { + private ScriptIntrinsicColorMatrix(long id, RenderScript rs) { super(id, rs); } @@ -75,7 +73,7 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { * @return ScriptIntrinsicColorMatrix */ public static ScriptIntrinsicColorMatrix create(RenderScript rs) { - int id = rs.nScriptIntrinsicCreate(2, 0); + long id = rs.nScriptIntrinsicCreate(2, 0); return new ScriptIntrinsicColorMatrix(id, rs); } diff --git a/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java b/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java index 5d3c1d3..a1a1b7e 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicConvolve3x3.java @@ -16,8 +16,6 @@ package android.renderscript; -import android.util.Log; - /** * Intrinsic for applying a 3x3 convolve to an allocation. * @@ -26,7 +24,7 @@ public final class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic { private final float[] mValues = new float[9]; private Allocation mInput; - private ScriptIntrinsicConvolve3x3(int id, RenderScript rs) { + private ScriptIntrinsicConvolve3x3(long id, RenderScript rs) { super(id, rs); } @@ -61,7 +59,7 @@ public final class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic { !e.isCompatible(Element.F32_4(rs))) { throw new RSIllegalArgumentException("Unsuported element type."); } - int id = rs.nScriptIntrinsicCreate(1, e.getID(rs)); + long id = rs.nScriptIntrinsicCreate(1, e.getID(rs)); ScriptIntrinsicConvolve3x3 si = new ScriptIntrinsicConvolve3x3(id, rs); si.setCoefficients(f); return si; diff --git a/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java b/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java index ad09f95..8b66896 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicConvolve5x5.java @@ -16,8 +16,6 @@ package android.renderscript; -import android.util.Log; - /** * Intrinsic for applying a 5x5 convolve to an allocation. * @@ -26,7 +24,7 @@ public final class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic { private final float[] mValues = new float[25]; private Allocation mInput; - private ScriptIntrinsicConvolve5x5(int id, RenderScript rs) { + private ScriptIntrinsicConvolve5x5(long id, RenderScript rs) { super(id, rs); } @@ -62,7 +60,7 @@ public final class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic { throw new RSIllegalArgumentException("Unsuported element type."); } - int id = rs.nScriptIntrinsicCreate(4, e.getID(rs)); + long id = rs.nScriptIntrinsicCreate(4, e.getID(rs)); return new ScriptIntrinsicConvolve5x5(id, rs); } diff --git a/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java b/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java index adc2d95..536663d 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java @@ -16,10 +16,6 @@ package android.renderscript; -import android.content.Context; -import android.content.res.Resources; -import android.util.Log; - /** * Intrinsic Histogram filter. * @@ -28,7 +24,7 @@ import android.util.Log; public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { private Allocation mOut; - private ScriptIntrinsicHistogram(int id, RenderScript rs) { + private ScriptIntrinsicHistogram(long id, RenderScript rs) { super(id, rs); } @@ -52,7 +48,7 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { (!e.isCompatible(Element.U8(rs)))) { throw new RSIllegalArgumentException("Unsuported element type."); } - int id = rs.nScriptIntrinsicCreate(9, e.getID(rs)); + long id = rs.nScriptIntrinsicCreate(9, e.getID(rs)); ScriptIntrinsicHistogram sib = new ScriptIntrinsicHistogram(id, rs); return sib; } diff --git a/graphics/java/android/renderscript/ScriptIntrinsicLUT.java b/graphics/java/android/renderscript/ScriptIntrinsicLUT.java index 0f7ab38..001095c 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicLUT.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicLUT.java @@ -16,8 +16,6 @@ package android.renderscript; -import android.util.Log; - /** * Intrinsic for applying a per-channel lookup table. Each * channel of the input has an independant lookup table. The @@ -30,7 +28,7 @@ public final class ScriptIntrinsicLUT extends ScriptIntrinsic { private final byte mCache[] = new byte[1024]; private boolean mDirty = true; - private ScriptIntrinsicLUT(int id, RenderScript rs) { + private ScriptIntrinsicLUT(long id, RenderScript rs) { super(id, rs); mTables = Allocation.createSized(rs, Element.U8(rs), 1024); for (int ct=0; ct < 256; ct++) { @@ -53,7 +51,7 @@ public final class ScriptIntrinsicLUT extends ScriptIntrinsic { * @return ScriptIntrinsicLUT */ public static ScriptIntrinsicLUT create(RenderScript rs, Element e) { - int id = rs.nScriptIntrinsicCreate(3, e.getID(rs)); + long id = rs.nScriptIntrinsicCreate(3, e.getID(rs)); return new ScriptIntrinsicLUT(id, rs); } diff --git a/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java b/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java index 845625d..f942982 100644 --- a/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java +++ b/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java @@ -27,7 +27,7 @@ package android.renderscript; public final class ScriptIntrinsicYuvToRGB extends ScriptIntrinsic { private Allocation mInput; - ScriptIntrinsicYuvToRGB(int id, RenderScript rs) { + ScriptIntrinsicYuvToRGB(long id, RenderScript rs) { super(id, rs); } @@ -43,7 +43,7 @@ public final class ScriptIntrinsicYuvToRGB extends ScriptIntrinsic { */ public static ScriptIntrinsicYuvToRGB create(RenderScript rs, Element e) { // 6 comes from RS_SCRIPT_INTRINSIC_YUV_TO_RGB in rsDefines.h - int id = rs.nScriptIntrinsicCreate(6, e.getID(rs)); + long id = rs.nScriptIntrinsicCreate(6, e.getID(rs)); ScriptIntrinsicYuvToRGB si = new ScriptIntrinsicYuvToRGB(id, rs); return si; } diff --git a/graphics/java/android/renderscript/Short2.java b/graphics/java/android/renderscript/Short2.java index 070d608..24809f7 100644 --- a/graphics/java/android/renderscript/Short2.java +++ b/graphics/java/android/renderscript/Short2.java @@ -16,7 +16,10 @@ package android.renderscript; -/** + +/** + * Class for exposing the native RenderScript Short2 type back to the Android system. + * * Vector version of the basic short type. * Provides two short fields packed. */ diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java index e023739..83bf4a5 100644 --- a/graphics/java/android/renderscript/Type.java +++ b/graphics/java/android/renderscript/Type.java @@ -16,12 +16,6 @@ package android.renderscript; - -import java.lang.reflect.Field; - -import android.graphics.ImageFormat; -import android.util.Log; - /** * <p>A Type describes the {@link android.renderscript.Element} and dimensions used for an {@link * android.renderscript.Allocation} or a parallel operation. Types are created through {@link @@ -190,16 +184,18 @@ public class Type extends BaseObj { } - Type(int id, RenderScript rs) { + Type(long id, RenderScript rs) { super(id, rs); } @Override void updateFromNative() { + // FIXME: rsaTypeGetNativeData needs 32-bit and 64-bit paths + // We have 6 integer to obtain mDimX; mDimY; mDimZ; // mDimLOD; mDimFaces; mElement; int[] dataBuffer = new int[6]; - mRS.nTypeGetNativeData(getID(mRS), dataBuffer); + mRS.nTypeGetNativeData((int)getID(mRS), dataBuffer); mDimX = dataBuffer[0]; mDimY = dataBuffer[1]; @@ -216,6 +212,81 @@ public class Type extends BaseObj { } /** + * Utility function for creating basic 1D types. The type is + * created without mipmaps enabled. + * + * @param rs The RenderScript context + * @param e The Element for the Type + * @param dimX The X dimension, must be > 0 + * + * @return Type + */ + static public Type createX(RenderScript rs, Element e, int dimX) { + if (dimX < 1) { + throw new RSInvalidStateException("Dimension must be >= 1."); + } + + long id = rs.nTypeCreate(e.getID(rs), dimX, 0, 0, false, false, 0); + Type t = new Type(id, rs); + t.mElement = e; + t.mDimX = dimX; + t.calcElementCount(); + return t; + } + + /** + * Utility function for creating basic 2D types. The type is + * created without mipmaps or cubemaps. + * + * @param rs The RenderScript context + * @param e The Element for the Type + * @param dimX The X dimension, must be > 0 + * @param dimY The Y dimension, must be > 0 + * + * @return Type + */ + static public Type createXY(RenderScript rs, Element e, int dimX, int dimY) { + if ((dimX < 1) || (dimY < 1)) { + throw new RSInvalidStateException("Dimension must be >= 1."); + } + + long id = rs.nTypeCreate(e.getID(rs), dimX, dimY, 0, false, false, 0); + Type t = new Type(id, rs); + t.mElement = e; + t.mDimX = dimX; + t.mDimY = dimY; + t.calcElementCount(); + return t; + } + + /** + * Utility function for creating basic 3D types. The type is + * created without mipmaps. + * + * @param rs The RenderScript context + * @param e The Element for the Type + * @param dimX The X dimension, must be > 0 + * @param dimY The Y dimension, must be > 0 + * @param dimZ The Z dimension, must be > 0 + * + * @return Type + */ + static public Type createXYZ(RenderScript rs, Element e, int dimX, int dimY, int dimZ) { + if ((dimX < 1) || (dimY < 1) || (dimZ < 1)) { + throw new RSInvalidStateException("Dimension must be >= 1."); + } + + long id = rs.nTypeCreate(e.getID(rs), dimX, dimY, dimZ, false, false, 0); + Type t = new Type(id, rs); + t.mElement = e; + t.mDimX = dimX; + t.mDimY = dimY; + t.mDimZ = dimZ; + t.calcElementCount(); + return t; + } + + /** * Builder class for Type. * */ @@ -336,7 +407,7 @@ public class Type extends BaseObj { } } - int id = mRS.nTypeCreate(mElement.getID(mRS), + long id = mRS.nTypeCreate(mElement.getID(mRS), mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces, mYuv); Type t = new Type(id, mRS); t.mElement = mElement; |