diff options
Diffstat (limited to 'rs')
43 files changed, 414 insertions, 227 deletions
diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java index cb5df0a..3cda6de 100644 --- a/rs/java/android/renderscript/Allocation.java +++ b/rs/java/android/renderscript/Allocation.java @@ -16,16 +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.util.Log; -import android.util.TypedValue; import android.graphics.Canvas; import android.os.Trace; @@ -609,7 +605,6 @@ public class Allocation extends BaseObj { * without reinterpretation. * * @param array The source data array - * @hide */ public void copyFromUnchecked(Object array) { Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked"); @@ -669,8 +664,7 @@ public class Allocation extends BaseObj { * android.renderscript.Element} does not match the array's * primitive type. * - * @param d the source data array - * @hide + * @param array The source data array */ public void copyFrom(Object array) { Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); @@ -871,7 +865,6 @@ public class Allocation extends BaseObj { * @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 - * @hide */ public void copy1DRangeFromUnchecked(int off, int count, Object array) { copy1DRangeFromUnchecked(off, count, array, @@ -936,7 +929,6 @@ public class Allocation extends BaseObj { * @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. - * @hide */ public void copy1DRangeFrom(int off, int count, Object array) { copy1DRangeFromUnchecked(off, count, array, @@ -1052,8 +1044,7 @@ public class Allocation extends BaseObj { * @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 data to be placed into the Allocation - * @hide + * @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"); @@ -1283,7 +1274,6 @@ public class Allocation extends BaseObj { * type of the array passed in. * * @param array The array to be set from the Allocation. - * @hide */ public void copyTo(Object array) { copyTo(array, validateObjectIsPrimitiveArray(array, true), @@ -1351,9 +1341,13 @@ public class Allocation extends BaseObj { * @param dimX The new size of the allocation. * * @deprecated RenderScript objects should be immutable once created. The - * replacement is to create a new allocation and copy the contents. + * replacement is to create a new allocation and copy the contents. This + * function will throw an exception if API 21 or higher is used. */ public synchronized void resize(int dimX) { + if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 21) { + throw new RSRuntimeException("Resize is not allowed in API 21+."); + } if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) { throw new RSInvalidStateException("Resize only support for 1D allocations at this time."); } @@ -1874,7 +1868,7 @@ public class Allocation extends BaseObj { } } - static void sendBufferNotification(int id) { + static void sendBufferNotification(long id) { synchronized(mAllocationMap) { Allocation a = mAllocationMap.get(new Long(id)); @@ -1885,4 +1879,3 @@ public class Allocation extends BaseObj { } } - diff --git a/rs/java/android/renderscript/AllocationAdapter.java b/rs/java/android/renderscript/AllocationAdapter.java index fd20cae..3522a52 100644 --- a/rs/java/android/renderscript/AllocationAdapter.java +++ b/rs/java/android/renderscript/AllocationAdapter.java @@ -16,11 +16,6 @@ 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. * diff --git a/rs/java/android/renderscript/Byte2.java b/rs/java/android/renderscript/Byte2.java index f796de3..3ad79e4 100644 --- a/rs/java/android/renderscript/Byte2.java +++ b/rs/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/rs/java/android/renderscript/Byte3.java b/rs/java/android/renderscript/Byte3.java index f2a95ac..a138313 100644 --- a/rs/java/android/renderscript/Byte3.java +++ b/rs/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/rs/java/android/renderscript/Byte4.java b/rs/java/android/renderscript/Byte4.java index b8a8a6b..fa4c13d 100644 --- a/rs/java/android/renderscript/Byte4.java +++ b/rs/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/rs/java/android/renderscript/Element.java b/rs/java/android/renderscript/Element.java index f2f1c86..c6b5b0d 100644 --- a/rs/java/android/renderscript/Element.java +++ b/rs/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 diff --git a/rs/java/android/renderscript/FieldPacker.java b/rs/java/android/renderscript/FieldPacker.java index 9048c31..20b07e7 100644 --- a/rs/java/android/renderscript/FieldPacker.java +++ b/rs/java/android/renderscript/FieldPacker.java @@ -16,7 +16,6 @@ package android.renderscript; -import android.util.Log; import java.util.BitSet; /** diff --git a/rs/java/android/renderscript/FileA3D.java b/rs/java/android/renderscript/FileA3D.java index 04bc7c6..4164810 100644 --- a/rs/java/android/renderscript/FileA3D.java +++ b/rs/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 diff --git a/rs/java/android/renderscript/Float2.java b/rs/java/android/renderscript/Float2.java index 26193d2..e9f8ca7 100644 --- a/rs/java/android/renderscript/Float2.java +++ b/rs/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/rs/java/android/renderscript/Font.java b/rs/java/android/renderscript/Font.java index cfd11c0..4318b9d 100644 --- a/rs/java/android/renderscript/Font.java +++ b/rs/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 @@ -114,10 +111,10 @@ public class Font extends BaseObj { FontFamily serifFamily = new FontFamily(); serifFamily.mNames = sSerifNames; - serifFamily.mNormalFileName = "DroidSerif-Regular.ttf"; - serifFamily.mBoldFileName = "DroidSerif-Bold.ttf"; - serifFamily.mItalicFileName = "DroidSerif-Italic.ttf"; - serifFamily.mBoldItalicFileName = "DroidSerif-BoldItalic.ttf"; + serifFamily.mNormalFileName = "NotoSerif-Regular.ttf"; + serifFamily.mBoldFileName = "NotoSerif-Bold.ttf"; + serifFamily.mItalicFileName = "NotoSerif-Italic.ttf"; + serifFamily.mBoldItalicFileName = "NotoSerif-BoldItalic.ttf"; addFamilyToMap(serifFamily); FontFamily monoFamily = new FontFamily(); diff --git a/rs/java/android/renderscript/Int3.java b/rs/java/android/renderscript/Int3.java index c770395..5431b9a 100644 --- a/rs/java/android/renderscript/Int3.java +++ b/rs/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/rs/java/android/renderscript/Long3.java b/rs/java/android/renderscript/Long3.java index 88ff855..8e243cc 100644 --- a/rs/java/android/renderscript/Long3.java +++ b/rs/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/rs/java/android/renderscript/Matrix2f.java b/rs/java/android/renderscript/Matrix2f.java index d3621fa..048262d 100644 --- a/rs/java/android/renderscript/Matrix2f.java +++ b/rs/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/rs/java/android/renderscript/Matrix3f.java b/rs/java/android/renderscript/Matrix3f.java index 8c3c330..9a4af77 100644 --- a/rs/java/android/renderscript/Matrix3f.java +++ b/rs/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/rs/java/android/renderscript/Matrix4f.java b/rs/java/android/renderscript/Matrix4f.java index cd18e30..5d5bf5f 100644 --- a/rs/java/android/renderscript/Matrix4f.java +++ b/rs/java/android/renderscript/Matrix4f.java @@ -17,7 +17,6 @@ package android.renderscript; import java.lang.Math; -import android.util.Log; /** diff --git a/rs/java/android/renderscript/Mesh.java b/rs/java/android/renderscript/Mesh.java index ca0da9d..1a5dc9e 100644 --- a/rs/java/android/renderscript/Mesh.java +++ b/rs/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 diff --git a/rs/java/android/renderscript/Path.java b/rs/java/android/renderscript/Path.java index 5cc67de..f3502aa 100644 --- a/rs/java/android/renderscript/Path.java +++ b/rs/java/android/renderscript/Path.java @@ -16,9 +16,6 @@ package android.renderscript; -import java.util.Vector; -import android.util.Log; - /** * @hide * diff --git a/rs/java/android/renderscript/ProgramFragment.java b/rs/java/android/renderscript/ProgramFragment.java index 4bb527b..5f71bd1 100644 --- a/rs/java/android/renderscript/ProgramFragment.java +++ b/rs/java/android/renderscript/ProgramFragment.java @@ -17,9 +17,6 @@ package android.renderscript; -import android.util.Log; - - /** * @hide * @deprecated in API 16 diff --git a/rs/java/android/renderscript/ProgramFragmentFixedFunction.java b/rs/java/android/renderscript/ProgramFragmentFixedFunction.java index 2fe68be..2b647c7 100644 --- a/rs/java/android/renderscript/ProgramFragmentFixedFunction.java +++ b/rs/java/android/renderscript/ProgramFragmentFixedFunction.java @@ -17,9 +17,6 @@ package android.renderscript; -import android.util.Log; - - /** * @hide * @deprecated in API 16 diff --git a/rs/java/android/renderscript/ProgramRaster.java b/rs/java/android/renderscript/ProgramRaster.java index e294b05..8c7c9aa 100644 --- a/rs/java/android/renderscript/ProgramRaster.java +++ b/rs/java/android/renderscript/ProgramRaster.java @@ -17,9 +17,6 @@ package android.renderscript; -import android.util.Log; - - /** * @hide * @deprecated in API 16 diff --git a/rs/java/android/renderscript/ProgramStore.java b/rs/java/android/renderscript/ProgramStore.java index 969cc25..c0fa9c4 100644 --- a/rs/java/android/renderscript/ProgramStore.java +++ b/rs/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/rs/java/android/renderscript/ProgramVertex.java b/rs/java/android/renderscript/ProgramVertex.java index d3a51de..0d7e2d9 100644 --- a/rs/java/android/renderscript/ProgramVertex.java +++ b/rs/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 diff --git a/rs/java/android/renderscript/ProgramVertexFixedFunction.java b/rs/java/android/renderscript/ProgramVertexFixedFunction.java index 7026597..45840ae 100644 --- a/rs/java/android/renderscript/ProgramVertexFixedFunction.java +++ b/rs/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 diff --git a/rs/java/android/renderscript/RSSurfaceView.java b/rs/java/android/renderscript/RSSurfaceView.java index 308d97a..5db72d9 100644 --- a/rs/java/android/renderscript/RSSurfaceView.java +++ b/rs/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/rs/java/android/renderscript/RSTextureView.java b/rs/java/android/renderscript/RSTextureView.java index 7eeeeae..af3258a 100644 --- a/rs/java/android/renderscript/RSTextureView.java +++ b/rs/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/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index bd272bc..2ee4ff2 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -17,16 +17,12 @@ package android.renderscript; import java.io.File; -import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.concurrent.locks.ReentrantReadWriteLock; 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; @@ -68,6 +64,25 @@ public class RenderScript { static Method registerNativeFree; /* + * Context creation flag that specifies a normal context. + */ + public static final int CREATE_FLAG_NONE = 0x0000; + + /* + * Context creation flag which specifies a context optimized for low + * latency over peak performance. This is a hint and may have no effect + * on some implementations. + */ + public static final int CREATE_FLAG_LOW_LATENCY = 0x0002; + + /* + * Context creation flag which specifies a context optimized for long + * battery life over peak performance. This is a hint and may have no effect + * on some implementations. + */ + public static final int CREATE_FLAG_LOW_POWER = 0x0004; + + /* * Detect the bitness of the VM to allow FieldPacker to do the right thing. */ static native int rsnSystemGetPointerSize(); @@ -1103,7 +1118,12 @@ public class RenderScript { } if (msg == RS_MESSAGE_TO_CLIENT_NEW_BUFFER) { - Allocation.sendBufferNotification(subID); + if (mRS.nContextGetUserMessage(mRS.mContext, rbuf) != + RS_MESSAGE_TO_CLIENT_NEW_BUFFER) { + throw new RSDriverException("Error processing message from RenderScript."); + } + long bufferID = ((long)rbuf[1] << 32L) + ((long)rbuf[0] & 0xffffffffL); + Allocation.sendBufferNotification(bufferID); continue; } @@ -1141,7 +1161,7 @@ public class RenderScript { * @hide */ public static RenderScript create(Context ctx, int sdkVersion) { - return create(ctx, sdkVersion, ContextType.NORMAL); + return create(ctx, sdkVersion, ContextType.NORMAL, CREATE_FLAG_NONE); } /** @@ -1151,16 +1171,20 @@ public class RenderScript { * @param ctx The context. * @return RenderScript */ - public static RenderScript create(Context ctx, int sdkVersion, ContextType ct) { + public static RenderScript create(Context ctx, int sdkVersion, ContextType ct, int flags) { if (!sInitialized) { Log.e(LOG_TAG, "RenderScript.create() called when disabled; someone is likely to crash"); return null; } + if ((flags & ~(CREATE_FLAG_LOW_LATENCY | CREATE_FLAG_LOW_POWER)) != 0) { + throw new RSIllegalArgumentException("Invalid flags passed."); + } + RenderScript rs = new RenderScript(ctx); rs.mDev = rs.nDeviceCreate(); - rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion, ct.mID); + rs.mContext = rs.nContextCreate(rs.mDev, flags, sdkVersion, ct.mID); rs.mContextType = ct; if (rs.mContext == 0) { throw new RSDriverException("Failed to create RS context."); @@ -1190,7 +1214,21 @@ public class RenderScript { */ public static RenderScript create(Context ctx, ContextType ct) { int v = ctx.getApplicationInfo().targetSdkVersion; - return create(ctx, v, ct); + return create(ctx, v, ct, CREATE_FLAG_NONE); + } + + /** + * Create a RenderScript context. + * + * + * @param ctx The context. + * @param ct The type of context to be created. + * @param flags The OR of the CREATE_FLAG_* options desired + * @return RenderScript + */ + public static RenderScript create(Context ctx, ContextType ct, int flags) { + int v = ctx.getApplicationInfo().targetSdkVersion; + return create(ctx, v, ct, flags); } /** diff --git a/rs/java/android/renderscript/RenderScriptGL.java b/rs/java/android/renderscript/RenderScriptGL.java index d6841c8..6178994 100644 --- a/rs/java/android/renderscript/RenderScriptGL.java +++ b/rs/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 diff --git a/rs/java/android/renderscript/Sampler.java b/rs/java/android/renderscript/Sampler.java index 8d0e29e..a4edbb5 100644 --- a/rs/java/android/renderscript/Sampler.java +++ b/rs/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/rs/java/android/renderscript/ScriptC.java b/rs/java/android/renderscript/ScriptC.java index f27cbd8..64d21e4 100644 --- a/rs/java/android/renderscript/ScriptC.java +++ b/rs/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 @@ -51,7 +44,6 @@ public class ScriptC extends Script { * @param id * @param rs * - * @hide */ protected ScriptC(long id, RenderScript rs) { super(id, rs); @@ -77,7 +69,6 @@ public class ScriptC extends Script { * Only intended for use by the generated derived classes. * * @param rs - * @hide */ protected ScriptC(RenderScript rs, String resName, byte[] bitcode32, byte[] bitcode64) { super(0, rs); diff --git a/rs/java/android/renderscript/ScriptGroup.java b/rs/java/android/renderscript/ScriptGroup.java index 1200a66..51c838f 100644 --- a/rs/java/android/renderscript/ScriptGroup.java +++ b/rs/java/android/renderscript/ScriptGroup.java @@ -16,7 +16,6 @@ package android.renderscript; -import java.lang.reflect.Method; import java.util.ArrayList; /** diff --git a/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java b/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java index 96ec875..ce149d9 100644 --- a/rs/java/android/renderscript/ScriptIntrinsic3DLUT.java +++ b/rs/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 @@ -86,10 +84,23 @@ public final class ScriptIntrinsic3DLUT extends ScriptIntrinsic { * @param aout Output allocation */ public void forEach(Allocation ain, Allocation aout) { - forEach(0, ain, aout, null); + forEach(ain, aout, null); } /** + * Invoke the kernel and apply the lookup to each cell of ain + * and copy to aout. + * + * @param ain Input allocation + * @param aout Output allocation + * @param opt Launch options for kernel + */ + public void forEach(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + forEach(0, ain, aout, null, opt); + } + + + /** * Get a KernelID for this intrinsic kernel. * * @return Script.KernelID The KernelID object. diff --git a/rs/java/android/renderscript/ScriptIntrinsicBlend.java b/rs/java/android/renderscript/ScriptIntrinsicBlend.java index 40f1a3e..906e0f6 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicBlend.java +++ b/rs/java/android/renderscript/ScriptIntrinsicBlend.java @@ -40,14 +40,14 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { } - private void blend(int id, Allocation ain, Allocation aout) { + private void blend(int id, Allocation ain, Allocation aout, Script.LaunchOptions opt) { if (!ain.getElement().isCompatible(Element.U8_4(mRS))) { throw new RSIllegalArgumentException("Input is not of expected format."); } if (!aout.getElement().isCompatible(Element.U8_4(mRS))) { throw new RSIllegalArgumentException("Output is not of expected format."); } - forEach(id, ain, aout, null); + forEach(id, ain, aout, null, opt); } /** @@ -57,7 +57,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachClear(Allocation ain, Allocation aout) { - blend(0, ain, aout); + forEachClear(ain, aout, null); + } + + /** + * Sets dst = {0, 0, 0, 0} + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachClear(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(0, ain, aout, opt); } /** @@ -77,7 +88,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachSrc(Allocation ain, Allocation aout) { - blend(1, ain, aout); + forEachSrc(ain, aout, null); + } + + /** + * Sets dst = src + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachSrc(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(1, ain, aout, null); } /** @@ -102,6 +124,19 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { } /** + * Sets dst = dst + * + * This is a NOP. + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachDst(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + // N, optOP + } + + /** * Get a KernelID for the Dst kernel. * * @return Script.KernelID The KernelID object. @@ -117,7 +152,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachSrcOver(Allocation ain, Allocation aout) { - blend(3, ain, aout); + forEachSrcOver(ain, aout, null); + } + + /** + * Sets dst = src + dst * (1.0 - src.a) + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachSrcOver(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(3, ain, aout, opt); } /** @@ -136,7 +182,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachDstOver(Allocation ain, Allocation aout) { - blend(4, ain, aout); + forEachDstOver(ain, aout, null); + } + + /** + * Sets dst = dst + src * (1.0 - dst.a) + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachDstOver(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(4, ain, aout, opt); } /** @@ -155,7 +212,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachSrcIn(Allocation ain, Allocation aout) { - blend(5, ain, aout); + forEachSrcIn(ain, aout, null); + } + + /** + * Sets dst = src * dst.a + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachSrcIn(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(5, ain, aout, opt); } /** @@ -174,7 +242,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachDstIn(Allocation ain, Allocation aout) { - blend(6, ain, aout); + forEachDstIn(ain, aout, null); + } + + /** + * Sets dst = dst * src.a + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachDstIn(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(6, ain, aout, opt); } /** @@ -193,7 +272,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachSrcOut(Allocation ain, Allocation aout) { - blend(7, ain, aout); + forEachSrcOut(ain, aout, null); + } + + /** + * Sets dst = src * (1.0 - dst.a) + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachSrcOut(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(7, ain, aout, opt); } /** @@ -212,7 +302,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachDstOut(Allocation ain, Allocation aout) { - blend(8, ain, aout); + forEachDstOut(ain, aout, null); + } + + /** + * Sets dst = dst * (1.0 - src.a) + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachDstOut(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(8, ain, aout, opt); } /** @@ -232,7 +333,19 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachSrcAtop(Allocation ain, Allocation aout) { - blend(9, ain, aout); + forEachSrcAtop(ain, aout, null); + } + + /** + * dst.rgb = src.rgb * dst.a + (1.0 - src.a) * dst.rgb + * dst.a = dst.a + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachSrcAtop(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(9, ain, aout, opt); } /** @@ -252,7 +365,19 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachDstAtop(Allocation ain, Allocation aout) { - blend(10, ain, aout); + forEachDstAtop(ain, aout, null); + } + + /** + * dst = dst.rgb * src.a + (1.0 - dst.a) * src.rgb + * dst.a = src.a + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachDstAtop(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(10, ain, aout, opt); } /** @@ -271,7 +396,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachXor(Allocation ain, Allocation aout) { - blend(11, ain, aout); + forEachXor(ain, aout, null); + } + + /** + * Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a} + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachXor(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(11, ain, aout, opt); } /** @@ -300,7 +436,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachMultiply(Allocation ain, Allocation aout) { - blend(14, ain, aout); + forEachMultiply(ain, aout, null); + } + + /** + * Sets dst = src * dst + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachMultiply(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(14, ain, aout, opt); } /** @@ -396,7 +543,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachAdd(Allocation ain, Allocation aout) { - blend(34, ain, aout); + forEachAdd(ain, aout, null); + } + + /** + * Sets dst = min(src + dst, 1.0) + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachAdd(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(34, ain, aout, opt); } /** @@ -415,7 +573,18 @@ public class ScriptIntrinsicBlend extends ScriptIntrinsic { * @param aout The destination buffer */ public void forEachSubtract(Allocation ain, Allocation aout) { - blend(35, ain, aout); + forEachSubtract(ain, aout, null); + } + + /** + * Sets dst = max(dst - src, 0.0) + * + * @param ain The source buffer + * @param aout The destination buffer + * @param opt LaunchOptions for clipping + */ + public void forEachSubtract(Allocation ain, Allocation aout, Script.LaunchOptions opt) { + blend(35, ain, aout, opt); } /** diff --git a/rs/java/android/renderscript/ScriptIntrinsicBlur.java b/rs/java/android/renderscript/ScriptIntrinsicBlur.java index c153712..5c4edd3 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicBlur.java +++ b/rs/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. @@ -92,6 +88,19 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic { } /** + * Apply the filter to the input and save to the specified + * allocation. + * + * @param aout Output allocation. Must match creation element + * type. + * @param opt LaunchOptions for clipping + */ + public void forEach(Allocation aout, Script.LaunchOptions opt) { + forEach(0, (Allocation) null, aout, null, opt); + } + + + /** * Get a KernelID for this intrinsic kernel. * * @return Script.KernelID The KernelID object. diff --git a/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java index 601db17..57d917c 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java +++ b/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java @@ -16,8 +16,6 @@ package android.renderscript; -import android.util.Log; - /** * Intrinsic for applying a color matrix to allocations. * @@ -208,7 +206,6 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { setMatrix(); } - /** * Invoke the kernel and apply the matrix to each cell of input * {@link Allocation} and copy to the output {@link Allocation}. @@ -225,6 +222,26 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { * @param aout Output allocation */ public void forEach(Allocation ain, Allocation aout) { + forEach(ain, aout, null); + } + + /** + * Invoke the kernel and apply the matrix to each cell of input + * {@link Allocation} and copy to the output {@link Allocation}. + * + * If the vector size of the input is less than four, the + * remaining components are treated as zero for the matrix + * multiply. + * + * If the output vector size is less than four, the unused + * vector components are discarded. + * + * + * @param ain Input allocation + * @param aout Output allocation + * @param opt LaunchOptions for clipping + */ + public void forEach(Allocation ain, Allocation aout, Script.LaunchOptions opt) { if (!ain.getElement().isCompatible(Element.U8(mRS)) && !ain.getElement().isCompatible(Element.U8_2(mRS)) && !ain.getElement().isCompatible(Element.U8_3(mRS)) && @@ -249,7 +266,7 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { throw new RSIllegalArgumentException("Unsuported element type."); } - forEach(0, ain, aout, null); + forEach(0, ain, aout, null, opt); } /** diff --git a/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java b/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java index 586930c..76da781 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java +++ b/rs/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. * @@ -112,6 +110,18 @@ public final class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic { } /** + * Apply the filter to the input and save to the specified + * allocation. + * + * @param aout Output allocation. Must match creation element + * type. + * @param opt LaunchOptions for clipping + */ + public void forEach(Allocation aout, Script.LaunchOptions opt) { + forEach(0, (Allocation) null, aout, null, opt); + } + + /** * Get a KernelID for this intrinsic kernel. * * @return Script.KernelID The KernelID object. diff --git a/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java b/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java index aebafc2..2d37600 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java +++ b/rs/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. * @@ -113,6 +111,19 @@ public final class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic { } /** + * Apply the filter to the input and save to the specified + * allocation. + * + * @param aout Output allocation. Must match creation element + * type. + * @param opt LaunchOptions for clipping + */ + public void forEach(Allocation aout, Script.LaunchOptions opt) { + forEach(0, (Allocation) null, aout, null, opt); + } + + + /** * Get a KernelID for this intrinsic kernel. * * @return Script.KernelID The KernelID object. diff --git a/rs/java/android/renderscript/ScriptIntrinsicHistogram.java b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java index 42e4d04..95b610a 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicHistogram.java +++ b/rs/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. * @@ -71,6 +67,24 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { * @param ain The input image */ public void forEach(Allocation ain) { + forEach(ain, null); + } + + /** + * Process an input buffer and place the histogram into the + * output allocation. The output allocation may be a narrower + * vector size than the input. In this case the vector size of + * the output is used to determine how many of the input + * channels are used in the computation. This is useful if you + * have an RGBA input buffer but only want the histogram for + * RGB. + * + * 1D and 2D input allocations are supported. + * + * @param ain The input image + * @param opt LaunchOptions for clipping + */ + public void forEach(Allocation ain, Script.LaunchOptions opt) { if (ain.getType().getElement().getVectorSize() < mOut.getType().getElement().getVectorSize()) { @@ -82,9 +96,11 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { throw new RSIllegalArgumentException("Output type must be U32 or I32."); } - forEach(0, ain, null, null); + forEach(0, ain, null, null, opt); } + + /** * Set the coefficients used for the RGBA to Luminocity * calculation. The default is {0.299f, 0.587f, 0.114f, 0.f}. @@ -141,6 +157,7 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { setVar(1, aout); } + /** * Process an input buffer and place the histogram into the * output allocation. The dot product of the input channel and @@ -152,6 +169,21 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { * @param ain The input image */ public void forEach_Dot(Allocation ain) { + forEach_Dot(ain, null); + } + + /** + * Process an input buffer and place the histogram into the + * output allocation. The dot product of the input channel and + * the coefficients from 'setDotCoefficients' are used to + * calculate the output values. + * + * 1D and 2D input allocations are supported. + * + * @param ain The input image + * @param opt LaunchOptions for clipping + */ + public void forEach_Dot(Allocation ain, Script.LaunchOptions opt) { if (mOut.getType().getElement().getVectorSize() != 1) { throw new RSIllegalArgumentException("Output vector size must be one."); } @@ -160,7 +192,7 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { throw new RSIllegalArgumentException("Output type must be U32 or I32."); } - forEach(1, ain, null, null); + forEach(1, ain, null, null, opt); } diff --git a/rs/java/android/renderscript/ScriptIntrinsicLUT.java b/rs/java/android/renderscript/ScriptIntrinsicLUT.java index c45c015..69ff64a 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicLUT.java +++ b/rs/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 @@ -116,7 +114,6 @@ public final class ScriptIntrinsicLUT extends ScriptIntrinsic { mDirty = true; } - /** * Invoke the kernel and apply the lookup to each cell of ain * and copy to aout. @@ -125,11 +122,23 @@ public final class ScriptIntrinsicLUT extends ScriptIntrinsic { * @param aout Output allocation */ public void forEach(Allocation ain, Allocation aout) { + forEach(ain, aout, null); + } + + /** + * Invoke the kernel and apply the lookup to each cell of ain + * and copy to aout. + * + * @param ain Input allocation + * @param aout Output allocation + * @param opt Options for clipping + */ + public void forEach(Allocation ain, Allocation aout, Script.LaunchOptions opt) { if (mDirty) { mDirty = false; mTables.copyFromUnchecked(mCache); } - forEach(0, ain, aout, null); + forEach(0, ain, aout, null, opt); } /** diff --git a/rs/java/android/renderscript/ScriptIntrinsicResize.java b/rs/java/android/renderscript/ScriptIntrinsicResize.java index 816029f..d6764cc 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicResize.java +++ b/rs/java/android/renderscript/ScriptIntrinsicResize.java @@ -18,7 +18,6 @@ package android.renderscript; /** * Intrinsic for performing a resize of a 2D allocation. - * @hide */ public final class ScriptIntrinsicResize extends ScriptIntrinsic { private Allocation mInput; diff --git a/rs/java/android/renderscript/Short2.java b/rs/java/android/renderscript/Short2.java index 070d608..24809f7 100644 --- a/rs/java/android/renderscript/Short2.java +++ b/rs/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/rs/java/android/renderscript/Type.java b/rs/java/android/renderscript/Type.java index ce7f571..98aeaa9 100644 --- a/rs/java/android/renderscript/Type.java +++ b/rs/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 @@ -216,7 +210,6 @@ public class Type extends BaseObj { } /** - * @hide * Utility function for creating basic 1D types. The type is * created without mipmaps enabled. * @@ -240,7 +233,6 @@ public class Type extends BaseObj { } /** - * @hide * Utility function for creating basic 2D types. The type is * created without mipmaps or cubemaps. * @@ -266,7 +258,6 @@ public class Type extends BaseObj { } /** - * @hide * Utility function for creating basic 3D types. The type is * created without mipmaps. * diff --git a/rs/jni/Android.mk b/rs/jni/Android.mk index 93a824f..f2c2e98 100644 --- a/rs/jni/Android.mk +++ b/rs/jni/Android.mk @@ -23,8 +23,7 @@ rs_generated_include_dir := $(call intermediates-dir-for,SHARED_LIBRARIES,libRS, LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE) \ frameworks/rs \ - $(rs_generated_include_dir) \ - $(call include-path-for, corecg graphics) + $(rs_generated_include_dir) LOCAL_CFLAGS += -Wno-unused-parameter -std=c++11 diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp index 7e2ff84..2d94131 100644 --- a/rs/jni/android_renderscript_RenderScript.cpp +++ b/rs/jni/android_renderscript_RenderScript.cpp @@ -23,10 +23,7 @@ #include <math.h> #include <utils/misc.h> -#include <core/SkBitmap.h> -#include <core/SkPixelRef.h> -#include <core/SkStream.h> -#include <core/SkTemplates.h> +#include <SkBitmap.h> #include <androidfw/Asset.h> #include <androidfw/AssetManager.h> @@ -225,7 +222,7 @@ static jlong nDeviceCreate(JNIEnv *_env, jobject _this) { LOG_API("nDeviceCreate"); - return (jlong)rsDeviceCreate(); + return (jlong)(uintptr_t)rsDeviceCreate(); } static void @@ -246,7 +243,7 @@ static jlong nContextCreate(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer, jint ct) { LOG_API("nContextCreate"); - return (jlong)rsContextCreate((RsDevice)dev, ver, sdkVer, (RsContextType)ct, 0); + return (jlong)(uintptr_t)rsContextCreate((RsDevice)dev, ver, sdkVer, (RsContextType)ct, 0); } static jlong @@ -270,7 +267,7 @@ nContextCreateGL(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer, sc.samplesQ = samplesQ; LOG_API("nContextCreateGL"); - return (jlong)rsContextCreateGL((RsDevice)dev, ver, sdkVer, sc, dpi); + return (jlong)(uintptr_t)rsContextCreateGL((RsDevice)dev, ver, sdkVer, sc, dpi); } static void @@ -397,7 +394,7 @@ nContextSendMessage(JNIEnv *_env, jobject _this, jlong con, jint id, jintArray d jint len = 0; if (data) { len = _env->GetArrayLength(data); - jint *ptr = _env->GetIntArrayElements(data, nullptr); + ptr = _env->GetIntArrayElements(data, nullptr); } LOG_API("nContextSendMessage, con(%p), id(%i), len(%i)", (RsContext)con, id, len); rsContextSendMessage((RsContext)con, id, (const uint8_t *)ptr, len * sizeof(int)); @@ -412,7 +409,7 @@ static jlong nElementCreate(JNIEnv *_env, jobject _this, jlong con, jlong type, jint kind, jboolean norm, jint size) { LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", (RsContext)con, type, kind, norm, size); - return (jlong)rsElementCreate((RsContext)con, (RsDataType)type, (RsDataKind)kind, norm, size); + return (jlong)(uintptr_t)rsElementCreate((RsContext)con, (RsDataType)type, (RsDataKind)kind, norm, size); } static jlong @@ -438,7 +435,7 @@ nElementCreate2(JNIEnv *_env, jobject _this, jlong con, const char **nameArray = names.c_str(); size_t *sizeArray = names.c_str_len(); - jlong id = (jlong)rsElementCreate2((RsContext)con, + jlong id = (jlong)(uintptr_t)rsElementCreate2((RsContext)con, (const RsElement *)ids, fieldCount, nameArray, fieldCount * sizeof(size_t), sizeArray, (const uint32_t *)arraySizes, fieldCount); @@ -448,7 +445,7 @@ nElementCreate2(JNIEnv *_env, jobject _this, jlong con, _env->ReleaseLongArrayElements(_ids, jIds, JNI_ABORT); _env->ReleaseIntArrayElements(_arraySizes, jArraySizes, JNI_ABORT); - return (jlong)id; + return (jlong)(uintptr_t)id; } static void @@ -486,7 +483,7 @@ nElementGetSubElements(JNIEnv *_env, jobject _this, jlong con, jlong id, rsaElementGetSubElements((RsContext)con, (RsElement)id, ids, names, arraySizes, (uint32_t)dataSize); for(uint32_t i = 0; i < dataSize; i++) { - const jlong id = (jlong)ids[i]; + const jlong id = (jlong)(uintptr_t)ids[i]; const jint arraySize = (jint)arraySizes[i]; _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i])); _env->SetLongArrayRegion(_IDs, i, 1, &id); @@ -507,7 +504,7 @@ nTypeCreate(JNIEnv *_env, jobject _this, jlong con, jlong eid, LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)", (RsContext)con, eid, dimx, dimy, dimz, mips, faces, yuv); - return (jlong)rsTypeCreate((RsContext)con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv); + return (jlong)(uintptr_t)rsTypeCreate((RsContext)con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv); } static void @@ -524,7 +521,7 @@ nTypeGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jlongArray rsaTypeGetNativeData((RsContext)con, (RsType)id, typeData, 6); for(jint i = 0; i < elementCount; i ++) { - const jlong data = (jlong)typeData[i]; + const jlong data = (jlong)(uintptr_t)typeData[i]; _env->SetLongArrayRegion(_typeData, i, 1, &data); } } @@ -535,7 +532,7 @@ static jlong nAllocationCreateTyped(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mips, jint usage, jlong pointer) { LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", (RsContext)con, (RsElement)type, mips, usage, (void *)pointer); - return (jlong) rsAllocationCreateTyped((RsContext)con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uintptr_t)pointer); + return (jlong)(uintptr_t) rsAllocationCreateTyped((RsContext)con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uintptr_t)pointer); } static void @@ -603,7 +600,7 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); - jlong id = (jlong)rsAllocationCreateFromBitmap((RsContext)con, + jlong id = (jlong)(uintptr_t)rsAllocationCreateFromBitmap((RsContext)con, (RsType)type, (RsAllocationMipmapControl)mip, ptr, bitmap.getSize(), usage); bitmap.unlockPixels(); @@ -619,7 +616,7 @@ nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, jlong con, bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); - jlong id = (jlong)rsAllocationCreateTyped((RsContext)con, + jlong id = (jlong)(uintptr_t)rsAllocationCreateTyped((RsContext)con, (RsType)type, (RsAllocationMipmapControl)mip, (uint32_t)usage, (uintptr_t)ptr); bitmap.unlockPixels(); @@ -635,7 +632,7 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong ty bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); - jlong id = (jlong)rsAllocationCubeCreateFromBitmap((RsContext)con, + jlong id = (jlong)(uintptr_t)rsAllocationCubeCreateFromBitmap((RsContext)con, (RsType)type, (RsAllocationMipmapControl)mip, ptr, bitmap.getSize(), usage); bitmap.unlockPixels(); @@ -813,7 +810,7 @@ static jlong nAllocationGetType(JNIEnv *_env, jobject _this, jlong con, jlong a) { LOG_API("nAllocationGetType, con(%p), a(%p)", (RsContext)con, (RsAllocation)a); - return (jlong) rsaAllocationGetType((RsContext)con, (RsAllocation)a); + return (jlong)(uintptr_t) rsaAllocationGetType((RsContext)con, (RsAllocation)a); } static void @@ -831,7 +828,7 @@ nFileA3DCreateFromAssetStream(JNIEnv *_env, jobject _this, jlong con, jlong nati Asset* asset = reinterpret_cast<Asset*>(native_asset); ALOGV("______nFileA3D %p", asset); - jlong id = (jlong)rsaFileA3DCreateFromMemory((RsContext)con, asset->getBuffer(false), asset->getLength()); + jlong id = (jlong)(uintptr_t)rsaFileA3DCreateFromMemory((RsContext)con, asset->getBuffer(false), asset->getLength()); return id; } @@ -849,7 +846,7 @@ nFileA3DCreateFromAsset(JNIEnv *_env, jobject _this, jlong con, jobject _assetMg return 0; } - jlong id = (jlong)rsaFileA3DCreateFromAsset((RsContext)con, asset); + jlong id = (jlong)(uintptr_t)rsaFileA3DCreateFromAsset((RsContext)con, asset); return id; } @@ -857,7 +854,7 @@ static jlong nFileA3DCreateFromFile(JNIEnv *_env, jobject _this, jlong con, jstring fileName) { AutoJavaStringToUTF8 fileNameUTF(_env, fileName); - jlong id = (jlong)rsaFileA3DCreateFromFile((RsContext)con, fileNameUTF.c_str()); + jlong id = (jlong)(uintptr_t)rsaFileA3DCreateFromFile((RsContext)con, fileNameUTF.c_str()); return id; } @@ -890,7 +887,7 @@ static jlong nFileA3DGetEntryByIndex(JNIEnv *_env, jobject _this, jlong con, jlong fileA3D, jint index) { ALOGV("______nFileA3D %p", (RsFile) fileA3D); - jlong id = (jlong)rsaFileA3DGetEntryByIndex((RsContext)con, (uint32_t)index, (RsFile)fileA3D); + jlong id = (jlong)(uintptr_t)rsaFileA3DGetEntryByIndex((RsContext)con, (uint32_t)index, (RsFile)fileA3D); return id; } @@ -901,7 +898,7 @@ nFontCreateFromFile(JNIEnv *_env, jobject _this, jlong con, jstring fileName, jfloat fontSize, jint dpi) { AutoJavaStringToUTF8 fileNameUTF(_env, fileName); - jlong id = (jlong)rsFontCreateFromFile((RsContext)con, + jlong id = (jlong)(uintptr_t)rsFontCreateFromFile((RsContext)con, fileNameUTF.c_str(), fileNameUTF.length(), fontSize, dpi); @@ -915,7 +912,7 @@ nFontCreateFromAssetStream(JNIEnv *_env, jobject _this, jlong con, Asset* asset = reinterpret_cast<Asset*>(native_asset); AutoJavaStringToUTF8 nameUTF(_env, name); - jlong id = (jlong)rsFontCreateFromMemory((RsContext)con, + jlong id = (jlong)(uintptr_t)rsFontCreateFromMemory((RsContext)con, nameUTF.c_str(), nameUTF.length(), fontSize, dpi, asset->getBuffer(false), asset->getLength()); @@ -937,7 +934,7 @@ nFontCreateFromAsset(JNIEnv *_env, jobject _this, jlong con, jobject _assetMgr, return 0; } - jlong id = (jlong)rsFontCreateFromMemory((RsContext)con, + jlong id = (jlong)(uintptr_t)rsFontCreateFromMemory((RsContext)con, str.c_str(), str.length(), fontSize, dpi, asset->getBuffer(false), asset->getLength()); @@ -1209,7 +1206,7 @@ nScriptCCreate(JNIEnv *_env, jobject _this, jlong con, //rsScriptCSetText((RsContext)con, (const char *)script_ptr, length); - ret = (jlong)rsScriptCCreate((RsContext)con, + ret = (jlong)(uintptr_t)rsScriptCCreate((RsContext)con, resNameUTF.c_str(), resNameUTF.length(), cacheDirUTF.c_str(), cacheDirUTF.length(), (const char *)script_ptr, length); @@ -1220,28 +1217,28 @@ exit: _exception ? JNI_ABORT: 0); } - return (jlong)ret; + return (jlong)(uintptr_t)ret; } static jlong nScriptIntrinsicCreate(JNIEnv *_env, jobject _this, jlong con, jint id, jlong eid) { LOG_API("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", (RsContext)con, id, (void *)eid); - return (jlong)rsScriptIntrinsicCreate((RsContext)con, id, (RsElement)eid); + return (jlong)(uintptr_t)rsScriptIntrinsicCreate((RsContext)con, id, (RsElement)eid); } static jlong nScriptKernelIDCreate(JNIEnv *_env, jobject _this, jlong con, jlong sid, jint slot, jint sig) { LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", (RsContext)con, (void *)sid, slot, sig); - return (jlong)rsScriptKernelIDCreate((RsContext)con, (RsScript)sid, slot, sig); + return (jlong)(uintptr_t)rsScriptKernelIDCreate((RsContext)con, (RsScript)sid, slot, sig); } static jlong nScriptFieldIDCreate(JNIEnv *_env, jobject _this, jlong con, jlong sid, jint slot) { LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", (RsContext)con, (void *)sid, slot); - return (jlong)rsScriptFieldIDCreate((RsContext)con, (RsScript)sid, slot); + return (jlong)(uintptr_t)rsScriptFieldIDCreate((RsContext)con, (RsScript)sid, slot); } static jlong @@ -1285,7 +1282,7 @@ nScriptGroupCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _kernels, typesPtr[i] = (RsType)jTypesPtr[i]; } - jlong id = (jlong)rsScriptGroupCreate((RsContext)con, + jlong id = (jlong)(uintptr_t)rsScriptGroupCreate((RsContext)con, (RsScriptKernelID *)kernelsPtr, kernelsLen * sizeof(RsScriptKernelID), (RsScriptKernelID *)srcPtr, srcLen * sizeof(RsScriptKernelID), (RsScriptKernelID *)dstkPtr, dstkLen * sizeof(RsScriptKernelID), @@ -1338,7 +1335,7 @@ nProgramStoreCreate(JNIEnv *_env, jobject _this, jlong con, jint depthFunc) { LOG_API("nProgramStoreCreate, con(%p)", (RsContext)con); - return (jlong)rsProgramStoreCreate((RsContext)con, colorMaskR, colorMaskG, colorMaskB, colorMaskA, + return (jlong)(uintptr_t)rsProgramStoreCreate((RsContext)con, colorMaskR, colorMaskG, colorMaskB, colorMaskA, depthMask, ditherEnable, (RsBlendSrcFunc)srcFunc, (RsBlendDstFunc)destFunc, (RsDepthFunc)depthFunc); } @@ -1387,7 +1384,7 @@ nProgramFragmentCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader, for(int i = 0; i < paramLen; ++i) { paramPtr[i] = (uintptr_t)jParamPtr[i]; } - jlong ret = (jlong)rsProgramFragmentCreate((RsContext)con, shaderUTF.c_str(), shaderUTF.length(), + jlong ret = (jlong)(uintptr_t)rsProgramFragmentCreate((RsContext)con, shaderUTF.c_str(), shaderUTF.length(), nameArray, texCount, sizeArray, paramPtr, paramLen); @@ -1419,7 +1416,7 @@ nProgramVertexCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader, paramPtr[i] = (uintptr_t)jParamPtr[i]; } - jlong ret = (jlong)rsProgramVertexCreate((RsContext)con, shaderUTF.c_str(), shaderUTF.length(), + jlong ret = (jlong)(uintptr_t)rsProgramVertexCreate((RsContext)con, shaderUTF.c_str(), shaderUTF.length(), nameArray, texCount, sizeArray, paramPtr, paramLen); @@ -1434,7 +1431,7 @@ static jlong nProgramRasterCreate(JNIEnv *_env, jobject _this, jlong con, jboolean pointSprite, jint cull) { LOG_API("nProgramRasterCreate, con(%p), pointSprite(%i), cull(%i)", (RsContext)con, pointSprite, cull); - return (jlong)rsProgramRasterCreate((RsContext)con, pointSprite, (RsCullMode)cull); + return (jlong)(uintptr_t)rsProgramRasterCreate((RsContext)con, pointSprite, (RsCullMode)cull); } @@ -1483,7 +1480,7 @@ nSamplerCreate(JNIEnv *_env, jobject _this, jlong con, jint magFilter, jint minF jint wrapS, jint wrapT, jint wrapR, jfloat aniso) { LOG_API("nSamplerCreate, con(%p)", (RsContext)con); - return (jlong)rsSamplerCreate((RsContext)con, + return (jlong)(uintptr_t)rsSamplerCreate((RsContext)con, (RsSamplerValue)magFilter, (RsSamplerValue)minFilter, (RsSamplerValue)wrapS, @@ -1498,7 +1495,7 @@ static jlong nPathCreate(JNIEnv *_env, jobject _this, jlong con, jint prim, jboolean isStatic, jlong _vtx, jlong _loop, jfloat q) { LOG_API("nPathCreate, con(%p)", (RsContext)con); - jlong id = (jlong)rsPathCreate((RsContext)con, (RsPathPrimitive)prim, isStatic, + jlong id = (jlong)(uintptr_t)rsPathCreate((RsContext)con, (RsPathPrimitive)prim, isStatic, (RsAllocation)_vtx, (RsAllocation)_loop, q); return id; @@ -1526,7 +1523,7 @@ nMeshCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _vtx, jlongArray jint primLen = _env->GetArrayLength(_prim); jint *primPtr = _env->GetIntArrayElements(_prim, nullptr); - jlong id = (jlong)rsMeshCreate((RsContext)con, + jlong id = (jlong)(uintptr_t)rsMeshCreate((RsContext)con, (RsAllocation *)vtxPtr, vtxLen, (RsAllocation *)idxPtr, idxLen, (uint32_t *)primPtr, primLen); @@ -1566,7 +1563,7 @@ nMeshGetVertices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray rsaMeshGetVertices((RsContext)con, (RsMesh)mesh, allocs, (uint32_t)numVtxIDs); for(jint i = 0; i < numVtxIDs; i ++) { - const jlong alloc = (jlong)allocs[i]; + const jlong alloc = (jlong)(uintptr_t)allocs[i]; _env->SetLongArrayRegion(_ids, i, 1, &alloc); } @@ -1584,7 +1581,7 @@ nMeshGetIndices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _ rsaMeshGetIndices((RsContext)con, (RsMesh)mesh, allocs, prims, (uint32_t)numIndices); for(jint i = 0; i < numIndices; i ++) { - const jlong alloc = (jlong)allocs[i]; + const jlong alloc = (jlong)(uintptr_t)allocs[i]; const jint prim = (jint)prims[i]; _env->SetLongArrayRegion(_idxIds, i, 1, &alloc); _env->SetIntArrayRegion(_primitives, i, 1, &prim); |