diff options
Diffstat (limited to 'rs')
8 files changed, 44 insertions, 29 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index 3d1370a52ae3..017b5d62af0f 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -1616,6 +1616,9 @@ public class RenderScript { nContextDeinitToClient(mContext); mMessageThread.mRun = false; + // Interrupt mMessageThread so it gets to see immediately that mRun is false + // and exit rightaway. + mMessageThread.interrupt(); // Wait for mMessageThread to join. Try in a loop, in case this thread gets interrupted // during the wait. If interrupted, set the "interrupted" status of the current thread. diff --git a/rs/java/android/renderscript/ScriptIntrinsicBlur.java b/rs/java/android/renderscript/ScriptIntrinsicBlur.java index 11483dc52ffd..7a702e877a2e 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicBlur.java +++ b/rs/java/android/renderscript/ScriptIntrinsicBlur.java @@ -44,7 +44,7 @@ public final class ScriptIntrinsicBlur extends ScriptIntrinsic { */ public static ScriptIntrinsicBlur create(RenderScript rs, Element e) { if ((!e.isCompatible(Element.U8_4(rs))) && (!e.isCompatible(Element.U8(rs)))) { - throw new RSIllegalArgumentException("Unsuported element type."); + throw new RSIllegalArgumentException("Unsupported element type."); } long id = rs.nScriptIntrinsicCreate(5, e.getID(rs)); ScriptIntrinsicBlur sib = new ScriptIntrinsicBlur(id, rs); diff --git a/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java index 57d917cd1be3..e8a299c28c51 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java +++ b/rs/java/android/renderscript/ScriptIntrinsicColorMatrix.java @@ -251,7 +251,7 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { !ain.getElement().isCompatible(Element.F32_3(mRS)) && !ain.getElement().isCompatible(Element.F32_4(mRS))) { - throw new RSIllegalArgumentException("Unsuported element type."); + throw new RSIllegalArgumentException("Unsupported element type."); } if (!aout.getElement().isCompatible(Element.U8(mRS)) && @@ -263,7 +263,7 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic { !aout.getElement().isCompatible(Element.F32_3(mRS)) && !aout.getElement().isCompatible(Element.F32_4(mRS))) { - throw new RSIllegalArgumentException("Unsuported element type."); + throw new RSIllegalArgumentException("Unsupported element type."); } forEach(0, ain, aout, null, opt); diff --git a/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java b/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java index 339e0e9dc975..9fe7b2d8f0ef 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java +++ b/rs/java/android/renderscript/ScriptIntrinsicConvolve3x3.java @@ -56,7 +56,7 @@ public final class ScriptIntrinsicConvolve3x3 extends ScriptIntrinsic { !e.isCompatible(Element.F32_2(rs)) && !e.isCompatible(Element.F32_3(rs)) && !e.isCompatible(Element.F32_4(rs))) { - throw new RSIllegalArgumentException("Unsuported element type."); + throw new RSIllegalArgumentException("Unsupported element type."); } long id = rs.nScriptIntrinsicCreate(1, e.getID(rs)); ScriptIntrinsicConvolve3x3 si = new ScriptIntrinsicConvolve3x3(id, rs); diff --git a/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java b/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java index a288cee407f0..8518bb27379d 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java +++ b/rs/java/android/renderscript/ScriptIntrinsicConvolve5x5.java @@ -57,7 +57,7 @@ public final class ScriptIntrinsicConvolve5x5 extends ScriptIntrinsic { !e.isCompatible(Element.F32_2(rs)) && !e.isCompatible(Element.F32_3(rs)) && !e.isCompatible(Element.F32_4(rs))) { - throw new RSIllegalArgumentException("Unsuported element type."); + throw new RSIllegalArgumentException("Unsupported element type."); } long id = rs.nScriptIntrinsicCreate(4, e.getID(rs)); diff --git a/rs/java/android/renderscript/ScriptIntrinsicHistogram.java b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java index f8c0c16b8d15..0e8b36c11952 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicHistogram.java +++ b/rs/java/android/renderscript/ScriptIntrinsicHistogram.java @@ -46,7 +46,7 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic { (!e.isCompatible(Element.U8_3(rs))) && (!e.isCompatible(Element.U8_2(rs))) && (!e.isCompatible(Element.U8(rs)))) { - throw new RSIllegalArgumentException("Unsuported element type."); + throw new RSIllegalArgumentException("Unsupported element type."); } long id = rs.nScriptIntrinsicCreate(9, e.getID(rs)); ScriptIntrinsicHistogram sib = new ScriptIntrinsicHistogram(id, rs); diff --git a/rs/java/android/renderscript/ScriptIntrinsicResize.java b/rs/java/android/renderscript/ScriptIntrinsicResize.java index cee4c33ee87d..45b0a646b924 100644 --- a/rs/java/android/renderscript/ScriptIntrinsicResize.java +++ b/rs/java/android/renderscript/ScriptIntrinsicResize.java @@ -59,7 +59,7 @@ public final class ScriptIntrinsicResize extends ScriptIntrinsic { !e.isCompatible(Element.F32_2(mRS)) && !e.isCompatible(Element.F32_3(mRS)) && !e.isCompatible(Element.F32_4(mRS))) { - throw new RSIllegalArgumentException("Unsuported element type."); + throw new RSIllegalArgumentException("Unsupported element type."); } mInput = ain; diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp index e0f5934cab74..200b54b3c380 100644 --- a/rs/jni/android_renderscript_RenderScript.cpp +++ b/rs/jni/android_renderscript_RenderScript.cpp @@ -421,31 +421,43 @@ nClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong kernelID, goto exit; } - fieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numValues); - if (fieldIDs == nullptr) { - goto exit; + if (numValues > 0) { + fieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numValues); + if (fieldIDs == nullptr) { + goto exit; + } + } else { + // numValues == 0 + // alloca(0) implementation is platform-dependent. + fieldIDs = nullptr; } for (size_t i = 0; i < numValues; i++) { fieldIDs[i] = (RsScriptFieldID)jFieldIDs[i]; } - depClosures = (RsClosure*)alloca(sizeof(RsClosure) * numDependencies); - if (depClosures == nullptr) { - goto exit; - } - - for (size_t i = 0; i < numDependencies; i++) { - depClosures[i] = (RsClosure)jDepClosures[i]; - } - - depFieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numDependencies); - if (depFieldIDs == nullptr) { - goto exit; - } - - for (size_t i = 0; i < numDependencies; i++) { - depFieldIDs[i] = (RsClosure)jDepFieldIDs[i]; + if (numDependencies > 0) { + depClosures = (RsClosure*)alloca(sizeof(RsClosure) * numDependencies); + if (depClosures == nullptr) { + goto exit; + } + + for (size_t i = 0; i < numDependencies; i++) { + depClosures[i] = (RsClosure)jDepClosures[i]; + } + + depFieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numDependencies); + if (depFieldIDs == nullptr) { + goto exit; + } + + for (size_t i = 0; i < numDependencies; i++) { + depFieldIDs[i] = (RsClosure)jDepFieldIDs[i]; + } + } else { + // alloca(0) implementation is platform-dependent. + depClosures = nullptr; + depFieldIDs = nullptr; } ret = (jlong)(uintptr_t)rsClosureCreate( @@ -853,7 +865,7 @@ nContextCreateGL(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer, jint samplesMin, jint samplesPref, jfloat samplesQ, jint dpi) { - RsSurfaceConfig sc; + RsSurfaceConfig sc = {}; sc.alphaMin = alphaMin; sc.alphaPref = alphaPref; sc.colorMin = colorMin; @@ -1403,8 +1415,8 @@ nAllocationElementData(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint xoff, jint yoff, jint zoff, jint lod, jint compIdx, jbyteArray data, jint sizeBytes) { - jint len = _env->GetArrayLength(data); if (kLogApi) { + jint len = _env->GetArrayLength(data); ALOGD("nAllocationElementData, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), " "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len, sizeBytes); @@ -1545,8 +1557,8 @@ nAllocationElementRead(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint xoff, jint yoff, jint zoff, jint lod, jint compIdx, jbyteArray data, jint sizeBytes) { - jint len = _env->GetArrayLength(data); if (kLogApi) { + jint len = _env->GetArrayLength(data); ALOGD("nAllocationElementRead, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), comp(%i), len(%i), " "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, compIdx, len, sizeBytes); |
