Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
Stephen Hines | 4cbe25a | 2012-01-18 18:46:27 -0800 | [diff] [blame] | 2 | * Copyright (C) 2011-2012 The Android Open Source Project |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jason Sams | f29ca50 | 2009-06-23 12:22:47 -0700 | [diff] [blame] | 17 | #define LOG_TAG "libRS_jni" |
| 18 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 19 | #include <stdlib.h> |
| 20 | #include <stdio.h> |
| 21 | #include <fcntl.h> |
| 22 | #include <unistd.h> |
| 23 | #include <math.h> |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 24 | #include <utils/misc.h> |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 25 | #include <inttypes.h> |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 26 | |
Derek Sollenberger | eece0dd | 2014-02-27 14:31:29 -0500 | [diff] [blame] | 27 | #include <SkBitmap.h> |
Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 28 | |
Mathias Agopian | b13b9bd | 2012-02-17 18:27:36 -0800 | [diff] [blame] | 29 | #include <androidfw/Asset.h> |
| 30 | #include <androidfw/AssetManager.h> |
| 31 | #include <androidfw/ResourceTypes.h> |
Jason Sams | f29ca50 | 2009-06-23 12:22:47 -0700 | [diff] [blame] | 32 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 33 | #include "jni.h" |
| 34 | #include "JNIHelp.h" |
| 35 | #include "android_runtime/AndroidRuntime.h" |
Jim Miller | ee95605 | 2010-08-19 18:56:00 -0700 | [diff] [blame] | 36 | #include "android_runtime/android_view_Surface.h" |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 37 | #include "android_runtime/android_util_AssetManager.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 38 | |
Jason Sams | 1d6983a | 2012-02-16 16:07:49 -0800 | [diff] [blame] | 39 | #include <rs.h> |
| 40 | #include <rsEnv.h> |
Jason Sams | fb9aa9f | 2012-03-28 15:30:07 -0700 | [diff] [blame] | 41 | #include <gui/Surface.h> |
Andy McFadden | d47f7d8 | 2012-12-18 09:48:38 -0800 | [diff] [blame] | 42 | #include <gui/GLConsumer.h> |
Mathias Agopian | 5280061 | 2013-02-14 17:11:20 -0800 | [diff] [blame] | 43 | #include <gui/Surface.h> |
Jason Sams | faa32b3 | 2011-06-20 16:58:04 -0700 | [diff] [blame] | 44 | #include <android_runtime/android_graphics_SurfaceTexture.h> |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 45 | |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 46 | //#define LOG_API ALOGE |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 47 | static constexpr bool kLogApi = false; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 48 | |
| 49 | using namespace android; |
| 50 | |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 51 | template <typename... T> |
| 52 | void UNUSED(T... t) {} |
| 53 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 54 | #define PER_ARRAY_TYPE(flag, fnc, readonly, ...) { \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 55 | jint len = 0; \ |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 56 | void *ptr = nullptr; \ |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 57 | size_t typeBytes = 0; \ |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 58 | jint relFlag = 0; \ |
| 59 | if (readonly) { \ |
| 60 | /* The on-release mode should only be JNI_ABORT for read-only accesses. */ \ |
| 61 | relFlag = JNI_ABORT; \ |
| 62 | } \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 63 | switch(dataType) { \ |
| 64 | case RS_TYPE_FLOAT_32: \ |
| 65 | len = _env->GetArrayLength((jfloatArray)data); \ |
| 66 | ptr = _env->GetFloatArrayElements((jfloatArray)data, flag); \ |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 67 | typeBytes = 4; \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 68 | fnc(__VA_ARGS__); \ |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 69 | _env->ReleaseFloatArrayElements((jfloatArray)data, (jfloat *)ptr, relFlag); \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 70 | return; \ |
| 71 | case RS_TYPE_FLOAT_64: \ |
| 72 | len = _env->GetArrayLength((jdoubleArray)data); \ |
| 73 | ptr = _env->GetDoubleArrayElements((jdoubleArray)data, flag); \ |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 74 | typeBytes = 8; \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 75 | fnc(__VA_ARGS__); \ |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 76 | _env->ReleaseDoubleArrayElements((jdoubleArray)data, (jdouble *)ptr, relFlag); \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 77 | return; \ |
| 78 | case RS_TYPE_SIGNED_8: \ |
| 79 | case RS_TYPE_UNSIGNED_8: \ |
| 80 | len = _env->GetArrayLength((jbyteArray)data); \ |
| 81 | ptr = _env->GetByteArrayElements((jbyteArray)data, flag); \ |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 82 | typeBytes = 1; \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 83 | fnc(__VA_ARGS__); \ |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 84 | _env->ReleaseByteArrayElements((jbyteArray)data, (jbyte*)ptr, relFlag); \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 85 | return; \ |
| 86 | case RS_TYPE_SIGNED_16: \ |
| 87 | case RS_TYPE_UNSIGNED_16: \ |
| 88 | len = _env->GetArrayLength((jshortArray)data); \ |
| 89 | ptr = _env->GetShortArrayElements((jshortArray)data, flag); \ |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 90 | typeBytes = 2; \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 91 | fnc(__VA_ARGS__); \ |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 92 | _env->ReleaseShortArrayElements((jshortArray)data, (jshort *)ptr, relFlag); \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 93 | return; \ |
| 94 | case RS_TYPE_SIGNED_32: \ |
| 95 | case RS_TYPE_UNSIGNED_32: \ |
| 96 | len = _env->GetArrayLength((jintArray)data); \ |
| 97 | ptr = _env->GetIntArrayElements((jintArray)data, flag); \ |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 98 | typeBytes = 4; \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 99 | fnc(__VA_ARGS__); \ |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 100 | _env->ReleaseIntArrayElements((jintArray)data, (jint *)ptr, relFlag); \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 101 | return; \ |
| 102 | case RS_TYPE_SIGNED_64: \ |
| 103 | case RS_TYPE_UNSIGNED_64: \ |
| 104 | len = _env->GetArrayLength((jlongArray)data); \ |
| 105 | ptr = _env->GetLongArrayElements((jlongArray)data, flag); \ |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 106 | typeBytes = 8; \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 107 | fnc(__VA_ARGS__); \ |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 108 | _env->ReleaseLongArrayElements((jlongArray)data, (jlong *)ptr, relFlag); \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 109 | return; \ |
| 110 | default: \ |
| 111 | break; \ |
| 112 | } \ |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 113 | UNUSED(len, ptr, typeBytes, relFlag); \ |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 117 | class AutoJavaStringToUTF8 { |
| 118 | public: |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 119 | AutoJavaStringToUTF8(JNIEnv* env, jstring str) : fEnv(env), fJStr(str) { |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 120 | fCStr = env->GetStringUTFChars(str, nullptr); |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 121 | fLength = env->GetStringUTFLength(str); |
| 122 | } |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 123 | ~AutoJavaStringToUTF8() { |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 124 | fEnv->ReleaseStringUTFChars(fJStr, fCStr); |
| 125 | } |
| 126 | const char* c_str() const { return fCStr; } |
| 127 | jsize length() const { return fLength; } |
| 128 | |
| 129 | private: |
| 130 | JNIEnv* fEnv; |
| 131 | jstring fJStr; |
| 132 | const char* fCStr; |
| 133 | jsize fLength; |
| 134 | }; |
| 135 | |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 136 | class AutoJavaStringArrayToUTF8 { |
| 137 | public: |
| 138 | AutoJavaStringArrayToUTF8(JNIEnv* env, jobjectArray strings, jsize stringsLength) |
| 139 | : mEnv(env), mStrings(strings), mStringsLength(stringsLength) { |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 140 | mCStrings = nullptr; |
| 141 | mSizeArray = nullptr; |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 142 | if (stringsLength > 0) { |
| 143 | mCStrings = (const char **)calloc(stringsLength, sizeof(char *)); |
| 144 | mSizeArray = (size_t*)calloc(stringsLength, sizeof(size_t)); |
| 145 | for (jsize ct = 0; ct < stringsLength; ct ++) { |
| 146 | jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 147 | mCStrings[ct] = mEnv->GetStringUTFChars(s, nullptr); |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 148 | mSizeArray[ct] = mEnv->GetStringUTFLength(s); |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | ~AutoJavaStringArrayToUTF8() { |
| 153 | for (jsize ct=0; ct < mStringsLength; ct++) { |
| 154 | jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct); |
| 155 | mEnv->ReleaseStringUTFChars(s, mCStrings[ct]); |
| 156 | } |
| 157 | free(mCStrings); |
| 158 | free(mSizeArray); |
| 159 | } |
| 160 | const char **c_str() const { return mCStrings; } |
| 161 | size_t *c_str_len() const { return mSizeArray; } |
| 162 | jsize length() const { return mStringsLength; } |
| 163 | |
| 164 | private: |
| 165 | JNIEnv *mEnv; |
| 166 | jobjectArray mStrings; |
| 167 | const char **mCStrings; |
| 168 | size_t *mSizeArray; |
| 169 | jsize mStringsLength; |
| 170 | }; |
| 171 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 172 | // --------------------------------------------------------------------------- |
| 173 | |
Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 174 | static jfieldID gContextId = 0; |
| 175 | static jfieldID gNativeBitmapID = 0; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 176 | |
| 177 | static void _nInit(JNIEnv *_env, jclass _this) |
| 178 | { |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 179 | gContextId = _env->GetFieldID(_this, "mContext", "J"); |
Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 180 | |
| 181 | jclass bitmapClass = _env->FindClass("android/graphics/Bitmap"); |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 182 | gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "J"); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 185 | // --------------------------------------------------------------------------- |
| 186 | |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 187 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 188 | nContextFinish(JNIEnv *_env, jobject _this, jlong con) |
Jason Sams | 96ed4cf | 2010-06-15 12:15:57 -0700 | [diff] [blame] | 189 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 190 | if (kLogApi) { |
| 191 | ALOGD("nContextFinish, con(%p)", (RsContext)con); |
| 192 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 193 | rsContextFinish((RsContext)con); |
Jason Sams | 96ed4cf | 2010-06-15 12:15:57 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Yang Ni | 281c325 | 2014-10-24 08:52:24 -0700 | [diff] [blame] | 196 | static jlong |
| 197 | nClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong kernelID, |
| 198 | jlong returnValue, jlongArray fieldIDArray, |
| 199 | jlongArray valueArray, jintArray sizeArray, |
| 200 | jlongArray depClosureArray, jlongArray depFieldIDArray) { |
| 201 | jlong* jFieldIDs = _env->GetLongArrayElements(fieldIDArray, nullptr); |
| 202 | jsize fieldIDs_length = _env->GetArrayLength(fieldIDArray); |
| 203 | RsScriptFieldID* fieldIDs = |
| 204 | (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * fieldIDs_length); |
| 205 | for (int i = 0; i< fieldIDs_length; i++) { |
| 206 | fieldIDs[i] = (RsScriptFieldID)jFieldIDs[i]; |
| 207 | } |
| 208 | |
| 209 | jlong* jValues = _env->GetLongArrayElements(valueArray, nullptr); |
| 210 | jsize values_length = _env->GetArrayLength(valueArray); |
| 211 | uintptr_t* values = (uintptr_t*)alloca(sizeof(uintptr_t) * values_length); |
| 212 | for (int i = 0; i < values_length; i++) { |
| 213 | values[i] = (uintptr_t)jValues[i]; |
| 214 | } |
| 215 | |
| 216 | jint* sizes = _env->GetIntArrayElements(sizeArray, nullptr); |
| 217 | jsize sizes_length = _env->GetArrayLength(sizeArray); |
| 218 | |
| 219 | jlong* jDepClosures = |
| 220 | _env->GetLongArrayElements(depClosureArray, nullptr); |
| 221 | jsize depClosures_length = _env->GetArrayLength(depClosureArray); |
| 222 | RsClosure* depClosures = |
| 223 | (RsClosure*)alloca(sizeof(RsClosure) * depClosures_length); |
| 224 | for (int i = 0; i < depClosures_length; i++) { |
| 225 | depClosures[i] = (RsClosure)jDepClosures[i]; |
| 226 | } |
| 227 | |
| 228 | jlong* jDepFieldIDs = |
| 229 | _env->GetLongArrayElements(depFieldIDArray, nullptr); |
| 230 | jsize depFieldIDs_length = _env->GetArrayLength(depFieldIDArray); |
| 231 | RsScriptFieldID* depFieldIDs = |
| 232 | (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * depFieldIDs_length); |
| 233 | for (int i = 0; i < depClosures_length; i++) { |
| 234 | depFieldIDs[i] = (RsClosure)jDepFieldIDs[i]; |
| 235 | } |
| 236 | |
| 237 | return (jlong)(uintptr_t)rsClosureCreate( |
| 238 | (RsContext)con, (RsScriptKernelID)kernelID, (RsAllocation)returnValue, |
| 239 | fieldIDs, (size_t)fieldIDs_length, values, (size_t)values_length, |
| 240 | (size_t*)sizes, (size_t)sizes_length, |
| 241 | depClosures, (size_t)depClosures_length, |
| 242 | depFieldIDs, (size_t)depFieldIDs_length); |
| 243 | } |
| 244 | |
| 245 | static void |
| 246 | nClosureSetArg(JNIEnv *_env, jobject _this, jlong con, jlong closureID, |
| 247 | jint index, jlong value, jint size) { |
| 248 | rsClosureSetArg((RsContext)con, (RsClosure)closureID, (uint32_t)index, |
| 249 | (uintptr_t)value, (size_t)size); |
| 250 | } |
| 251 | |
| 252 | static void |
| 253 | nClosureSetGlobal(JNIEnv *_env, jobject _this, jlong con, jlong closureID, |
| 254 | jlong fieldID, jlong value, jint size) { |
| 255 | rsClosureSetGlobal((RsContext)con, (RsClosure)closureID, |
| 256 | (RsScriptFieldID)fieldID, (uintptr_t)value, (size_t)size); |
| 257 | } |
| 258 | |
| 259 | static long |
| 260 | nScriptGroup2Create(JNIEnv *_env, jobject _this, jlong con, |
Yang Ni | ebf6340 | 2015-01-16 11:06:26 -0800 | [diff] [blame] | 261 | jstring cacheDir, jlongArray closureArray) { |
| 262 | AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir); |
| 263 | |
Yang Ni | 281c325 | 2014-10-24 08:52:24 -0700 | [diff] [blame] | 264 | jlong* jClosures = _env->GetLongArrayElements(closureArray, nullptr); |
| 265 | jsize numClosures = _env->GetArrayLength(closureArray); |
| 266 | RsClosure* closures = (RsClosure*)alloca(sizeof(RsClosure) * numClosures); |
| 267 | for (int i = 0; i < numClosures; i++) { |
| 268 | closures[i] = (RsClosure)jClosures[i]; |
| 269 | } |
| 270 | |
Yang Ni | ebf6340 | 2015-01-16 11:06:26 -0800 | [diff] [blame] | 271 | return (jlong)(uintptr_t)rsScriptGroup2Create( |
| 272 | (RsContext)con, cacheDirUTF.c_str(), cacheDirUTF.length(), |
| 273 | closures, numClosures); |
Yang Ni | 281c325 | 2014-10-24 08:52:24 -0700 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | static void |
| 277 | nScriptGroup2Execute(JNIEnv *_env, jobject _this, jlong con, jlong groupID) { |
| 278 | rsScriptGroupExecute((RsContext)con, (RsScriptGroup2)groupID); |
| 279 | } |
| 280 | |
Jason Sams | 96ed4cf | 2010-06-15 12:15:57 -0700 | [diff] [blame] | 281 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 282 | nAssignName(JNIEnv *_env, jobject _this, jlong con, jlong obj, jbyteArray str) |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 283 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 284 | if (kLogApi) { |
| 285 | ALOGD("nAssignName, con(%p), obj(%p)", (RsContext)con, (void *)obj); |
| 286 | } |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 287 | jint len = _env->GetArrayLength(str); |
| 288 | jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 289 | rsAssignName((RsContext)con, (void *)obj, (const char *)cptr, len); |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 290 | _env->ReleasePrimitiveArrayCritical(str, cptr, JNI_ABORT); |
| 291 | } |
| 292 | |
Alex Sakhartchouk | fb10c16 | 2010-08-04 14:45:48 -0700 | [diff] [blame] | 293 | static jstring |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 294 | nGetName(JNIEnv *_env, jobject _this, jlong con, jlong obj) |
Alex Sakhartchouk | fb10c16 | 2010-08-04 14:45:48 -0700 | [diff] [blame] | 295 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 296 | if (kLogApi) { |
| 297 | ALOGD("nGetName, con(%p), obj(%p)", (RsContext)con, (void *)obj); |
| 298 | } |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 299 | const char *name = nullptr; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 300 | rsaGetName((RsContext)con, (void *)obj, &name); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 301 | if(name == nullptr || strlen(name) == 0) { |
| 302 | return nullptr; |
Alex Sakhartchouk | 581cc64 | 2010-10-27 14:10:07 -0700 | [diff] [blame] | 303 | } |
Alex Sakhartchouk | fb10c16 | 2010-08-04 14:45:48 -0700 | [diff] [blame] | 304 | return _env->NewStringUTF(name); |
| 305 | } |
| 306 | |
Jason Sams | 7ce033d | 2009-08-18 14:14:24 -0700 | [diff] [blame] | 307 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 308 | nObjDestroy(JNIEnv *_env, jobject _this, jlong con, jlong obj) |
Jason Sams | 7ce033d | 2009-08-18 14:14:24 -0700 | [diff] [blame] | 309 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 310 | if (kLogApi) { |
| 311 | ALOGD("nObjDestroy, con(%p) obj(%p)", (RsContext)con, (void *)obj); |
| 312 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 313 | rsObjDestroy((RsContext)con, (void *)obj); |
Jason Sams | 7ce033d | 2009-08-18 14:14:24 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 316 | // --------------------------------------------------------------------------- |
| 317 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 318 | static jlong |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 319 | nDeviceCreate(JNIEnv *_env, jobject _this) |
| 320 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 321 | if (kLogApi) { |
| 322 | ALOGD("nDeviceCreate"); |
| 323 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 324 | return (jlong)(uintptr_t)rsDeviceCreate(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | static void |
Tim Murray | 5eaf468 | 2014-01-10 11:25:52 -0800 | [diff] [blame] | 328 | nDeviceDestroy(JNIEnv *_env, jobject _this, jlong dev) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 329 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 330 | if (kLogApi) { |
| 331 | ALOGD("nDeviceDestroy"); |
| 332 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 333 | return rsDeviceDestroy((RsDevice)dev); |
| 334 | } |
| 335 | |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 336 | static void |
Tim Murray | 5eaf468 | 2014-01-10 11:25:52 -0800 | [diff] [blame] | 337 | nDeviceSetConfig(JNIEnv *_env, jobject _this, jlong dev, jint p, jint value) |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 338 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 339 | if (kLogApi) { |
| 340 | ALOGD("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value); |
| 341 | } |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 342 | return rsDeviceSetConfig((RsDevice)dev, (RsDeviceParam)p, value); |
| 343 | } |
| 344 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 345 | static jlong |
Jason Sams | 81cd2b1 | 2014-12-02 12:36:43 -0800 | [diff] [blame] | 346 | nContextCreate(JNIEnv *_env, jobject _this, jlong dev, jint flags, jint sdkVer, jint contextType) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 347 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 348 | if (kLogApi) { |
| 349 | ALOGD("nContextCreate"); |
| 350 | } |
Jason Sams | 81cd2b1 | 2014-12-02 12:36:43 -0800 | [diff] [blame] | 351 | return (jlong)(uintptr_t)rsContextCreate((RsDevice)dev, 0, sdkVer, (RsContextType)contextType, flags); |
Jason Sams | 704ff64 | 2010-02-09 16:05:07 -0800 | [diff] [blame] | 352 | } |
| 353 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 354 | static jlong |
Tim Murray | 5eaf468 | 2014-01-10 11:25:52 -0800 | [diff] [blame] | 355 | nContextCreateGL(JNIEnv *_env, jobject _this, jlong dev, jint ver, jint sdkVer, |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 356 | jint colorMin, jint colorPref, |
| 357 | jint alphaMin, jint alphaPref, |
| 358 | jint depthMin, jint depthPref, |
| 359 | jint stencilMin, jint stencilPref, |
| 360 | jint samplesMin, jint samplesPref, jfloat samplesQ, |
| 361 | jint dpi) |
Jason Sams | 704ff64 | 2010-02-09 16:05:07 -0800 | [diff] [blame] | 362 | { |
Jason Sams | 11c8af9 | 2010-10-13 15:31:10 -0700 | [diff] [blame] | 363 | RsSurfaceConfig sc; |
| 364 | sc.alphaMin = alphaMin; |
| 365 | sc.alphaPref = alphaPref; |
| 366 | sc.colorMin = colorMin; |
| 367 | sc.colorPref = colorPref; |
| 368 | sc.depthMin = depthMin; |
| 369 | sc.depthPref = depthPref; |
| 370 | sc.samplesMin = samplesMin; |
| 371 | sc.samplesPref = samplesPref; |
| 372 | sc.samplesQ = samplesQ; |
| 373 | |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 374 | if (kLogApi) { |
| 375 | ALOGD("nContextCreateGL"); |
| 376 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 377 | return (jlong)(uintptr_t)rsContextCreateGL((RsDevice)dev, ver, sdkVer, sc, dpi); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 381 | nContextSetPriority(JNIEnv *_env, jobject _this, jlong con, jint p) |
Jason Sams | 7d787b4 | 2009-11-15 12:14:26 -0800 | [diff] [blame] | 382 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 383 | if (kLogApi) { |
| 384 | ALOGD("ContextSetPriority, con(%p), priority(%i)", (RsContext)con, p); |
| 385 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 386 | rsContextSetPriority((RsContext)con, p); |
Jason Sams | 7d787b4 | 2009-11-15 12:14:26 -0800 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | |
| 390 | |
| 391 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 392 | nContextSetSurface(JNIEnv *_env, jobject _this, jlong con, jint width, jint height, jobject wnd) |
Jason Sams | efd9b6fb | 2009-11-03 13:58:36 -0800 | [diff] [blame] | 393 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 394 | if (kLogApi) { |
| 395 | ALOGD("nContextSetSurface, con(%p), width(%i), height(%i), surface(%p)", (RsContext)con, |
| 396 | width, height, (Surface *)wnd); |
| 397 | } |
Jason Sams | efd9b6fb | 2009-11-03 13:58:36 -0800 | [diff] [blame] | 398 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 399 | ANativeWindow * window = nullptr; |
| 400 | if (wnd == nullptr) { |
Jason Sams | efd9b6fb | 2009-11-03 13:58:36 -0800 | [diff] [blame] | 401 | |
| 402 | } else { |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 403 | window = android_view_Surface_getNativeWindow(_env, wnd).get(); |
Jason Sams | efd9b6fb | 2009-11-03 13:58:36 -0800 | [diff] [blame] | 404 | } |
| 405 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 406 | rsContextSetSurface((RsContext)con, width, height, window); |
Jason Sams | efd9b6fb | 2009-11-03 13:58:36 -0800 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 410 | nContextDestroy(JNIEnv *_env, jobject _this, jlong con) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 411 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 412 | if (kLogApi) { |
| 413 | ALOGD("nContextDestroy, con(%p)", (RsContext)con); |
| 414 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 415 | rsContextDestroy((RsContext)con); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 416 | } |
| 417 | |
Jason Sams | 715333b | 2009-11-17 17:26:46 -0800 | [diff] [blame] | 418 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 419 | nContextDump(JNIEnv *_env, jobject _this, jlong con, jint bits) |
Jason Sams | 715333b | 2009-11-17 17:26:46 -0800 | [diff] [blame] | 420 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 421 | if (kLogApi) { |
| 422 | ALOGD("nContextDump, con(%p) bits(%i)", (RsContext)con, bits); |
| 423 | } |
Jason Sams | 715333b | 2009-11-17 17:26:46 -0800 | [diff] [blame] | 424 | rsContextDump((RsContext)con, bits); |
| 425 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 426 | |
| 427 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 428 | nContextPause(JNIEnv *_env, jobject _this, jlong con) |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 429 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 430 | if (kLogApi) { |
| 431 | ALOGD("nContextPause, con(%p)", (RsContext)con); |
| 432 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 433 | rsContextPause((RsContext)con); |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 437 | nContextResume(JNIEnv *_env, jobject _this, jlong con) |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 438 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 439 | if (kLogApi) { |
| 440 | ALOGD("nContextResume, con(%p)", (RsContext)con); |
| 441 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 442 | rsContextResume((RsContext)con); |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 443 | } |
| 444 | |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 445 | |
| 446 | static jstring |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 447 | nContextGetErrorMessage(JNIEnv *_env, jobject _this, jlong con) |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 448 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 449 | if (kLogApi) { |
| 450 | ALOGD("nContextGetErrorMessage, con(%p)", (RsContext)con); |
| 451 | } |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 452 | char buf[1024]; |
| 453 | |
| 454 | size_t receiveLen; |
| 455 | uint32_t subID; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 456 | int id = rsContextGetMessage((RsContext)con, |
Jason Sams | 65bdaf1 | 2011-04-26 14:50:00 -0700 | [diff] [blame] | 457 | buf, sizeof(buf), |
| 458 | &receiveLen, sizeof(receiveLen), |
Jason Sams | edbfabd | 2011-05-17 15:01:29 -0700 | [diff] [blame] | 459 | &subID, sizeof(subID)); |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 460 | if (!id && receiveLen) { |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 461 | ALOGV("message receive buffer too small. %zu", receiveLen); |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 462 | } |
| 463 | return _env->NewStringUTF(buf); |
| 464 | } |
| 465 | |
Jason Sams | edbfabd | 2011-05-17 15:01:29 -0700 | [diff] [blame] | 466 | static jint |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 467 | nContextGetUserMessage(JNIEnv *_env, jobject _this, jlong con, jintArray data) |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 468 | { |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 469 | jint len = _env->GetArrayLength(data); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 470 | if (kLogApi) { |
| 471 | ALOGD("nContextGetMessage, con(%p), len(%i)", (RsContext)con, len); |
| 472 | } |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 473 | jint *ptr = _env->GetIntArrayElements(data, nullptr); |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 474 | size_t receiveLen; |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 475 | uint32_t subID; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 476 | int id = rsContextGetMessage((RsContext)con, |
Jason Sams | 65bdaf1 | 2011-04-26 14:50:00 -0700 | [diff] [blame] | 477 | ptr, len * 4, |
| 478 | &receiveLen, sizeof(receiveLen), |
Jason Sams | edbfabd | 2011-05-17 15:01:29 -0700 | [diff] [blame] | 479 | &subID, sizeof(subID)); |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 480 | if (!id && receiveLen) { |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 481 | ALOGV("message receive buffer too small. %zu", receiveLen); |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 482 | } |
| 483 | _env->ReleaseIntArrayElements(data, ptr, 0); |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 484 | return (jint)id; |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | static jint |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 488 | nContextPeekMessage(JNIEnv *_env, jobject _this, jlong con, jintArray auxData) |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 489 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 490 | if (kLogApi) { |
| 491 | ALOGD("nContextPeekMessage, con(%p)", (RsContext)con); |
| 492 | } |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 493 | jint *auxDataPtr = _env->GetIntArrayElements(auxData, nullptr); |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 494 | size_t receiveLen; |
| 495 | uint32_t subID; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 496 | int id = rsContextPeekMessage((RsContext)con, &receiveLen, sizeof(receiveLen), |
Jason Sams | edbfabd | 2011-05-17 15:01:29 -0700 | [diff] [blame] | 497 | &subID, sizeof(subID)); |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 498 | auxDataPtr[0] = (jint)subID; |
| 499 | auxDataPtr[1] = (jint)receiveLen; |
| 500 | _env->ReleaseIntArrayElements(auxData, auxDataPtr, 0); |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 501 | return (jint)id; |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 504 | static void nContextInitToClient(JNIEnv *_env, jobject _this, jlong con) |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 505 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 506 | if (kLogApi) { |
| 507 | ALOGD("nContextInitToClient, con(%p)", (RsContext)con); |
| 508 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 509 | rsContextInitToClient((RsContext)con); |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 510 | } |
| 511 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 512 | static void nContextDeinitToClient(JNIEnv *_env, jobject _this, jlong con) |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 513 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 514 | if (kLogApi) { |
| 515 | ALOGD("nContextDeinitToClient, con(%p)", (RsContext)con); |
| 516 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 517 | rsContextDeinitToClient((RsContext)con); |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 518 | } |
| 519 | |
Jason Sams | 455d644 | 2013-02-05 19:20:18 -0800 | [diff] [blame] | 520 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 521 | nContextSendMessage(JNIEnv *_env, jobject _this, jlong con, jint id, jintArray data) |
Jason Sams | 455d644 | 2013-02-05 19:20:18 -0800 | [diff] [blame] | 522 | { |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 523 | jint *ptr = nullptr; |
Jason Sams | 455d644 | 2013-02-05 19:20:18 -0800 | [diff] [blame] | 524 | jint len = 0; |
| 525 | if (data) { |
| 526 | len = _env->GetArrayLength(data); |
Stephen Hines | 4a043c1 | 2014-08-21 23:20:32 -0700 | [diff] [blame] | 527 | ptr = _env->GetIntArrayElements(data, nullptr); |
Jason Sams | 455d644 | 2013-02-05 19:20:18 -0800 | [diff] [blame] | 528 | } |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 529 | if (kLogApi) { |
| 530 | ALOGD("nContextSendMessage, con(%p), id(%i), len(%i)", (RsContext)con, id, len); |
| 531 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 532 | rsContextSendMessage((RsContext)con, id, (const uint8_t *)ptr, len * sizeof(int)); |
Jason Sams | 455d644 | 2013-02-05 19:20:18 -0800 | [diff] [blame] | 533 | if (data) { |
| 534 | _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 539 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 540 | static jlong |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 541 | nElementCreate(JNIEnv *_env, jobject _this, jlong con, jlong type, jint kind, jboolean norm, |
| 542 | jint size) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 543 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 544 | if (kLogApi) { |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 545 | ALOGD("nElementCreate, con(%p), type(%" PRId64 "), kind(%i), norm(%i), size(%i)", (RsContext)con, |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 546 | type, kind, norm, size); |
| 547 | } |
| 548 | return (jlong)(uintptr_t)rsElementCreate((RsContext)con, (RsDataType)type, (RsDataKind)kind, |
| 549 | norm, size); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 550 | } |
| 551 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 552 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 553 | nElementCreate2(JNIEnv *_env, jobject _this, jlong con, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 554 | jlongArray _ids, jobjectArray _names, jintArray _arraySizes) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 555 | { |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 556 | int fieldCount = _env->GetArrayLength(_ids); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 557 | if (kLogApi) { |
| 558 | ALOGD("nElementCreate2, con(%p)", (RsContext)con); |
| 559 | } |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 560 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 561 | jlong *jIds = _env->GetLongArrayElements(_ids, nullptr); |
| 562 | jint *jArraySizes = _env->GetIntArrayElements(_arraySizes, nullptr); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 563 | |
| 564 | RsElement *ids = (RsElement*)malloc(fieldCount * sizeof(RsElement)); |
| 565 | uint32_t *arraySizes = (uint32_t *)malloc(fieldCount * sizeof(uint32_t)); |
| 566 | |
| 567 | for(int i = 0; i < fieldCount; i ++) { |
| 568 | ids[i] = (RsElement)jIds[i]; |
| 569 | arraySizes[i] = (uint32_t)jArraySizes[i]; |
| 570 | } |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 571 | |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 572 | AutoJavaStringArrayToUTF8 names(_env, _names, fieldCount); |
| 573 | |
| 574 | const char **nameArray = names.c_str(); |
| 575 | size_t *sizeArray = names.c_str_len(); |
| 576 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 577 | jlong id = (jlong)(uintptr_t)rsElementCreate2((RsContext)con, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 578 | (const RsElement *)ids, fieldCount, |
Jason Sams | 7a22e10 | 2011-05-06 14:14:30 -0700 | [diff] [blame] | 579 | nameArray, fieldCount * sizeof(size_t), sizeArray, |
Alex Sakhartchouk | e7c4a75 | 2011-04-06 10:57:51 -0700 | [diff] [blame] | 580 | (const uint32_t *)arraySizes, fieldCount); |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 581 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 582 | free(ids); |
| 583 | free(arraySizes); |
| 584 | _env->ReleaseLongArrayElements(_ids, jIds, JNI_ABORT); |
| 585 | _env->ReleaseIntArrayElements(_arraySizes, jArraySizes, JNI_ABORT); |
| 586 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 587 | return (jlong)(uintptr_t)id; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 588 | } |
| 589 | |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 590 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 591 | nElementGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jintArray _elementData) |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 592 | { |
| 593 | int dataSize = _env->GetArrayLength(_elementData); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 594 | if (kLogApi) { |
| 595 | ALOGD("nElementGetNativeData, con(%p)", (RsContext)con); |
| 596 | } |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 597 | |
| 598 | // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements |
| 599 | assert(dataSize == 5); |
| 600 | |
Narayan Kamath | 78c0ce5 | 2014-03-19 10:15:51 +0000 | [diff] [blame] | 601 | uintptr_t elementData[5]; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 602 | rsaElementGetNativeData((RsContext)con, (RsElement)id, elementData, dataSize); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 603 | |
| 604 | for(jint i = 0; i < dataSize; i ++) { |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 605 | const jint data = (jint)elementData[i]; |
| 606 | _env->SetIntArrayRegion(_elementData, i, 1, &data); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 607 | } |
| 608 | } |
| 609 | |
| 610 | |
| 611 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 612 | nElementGetSubElements(JNIEnv *_env, jobject _this, jlong con, jlong id, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 613 | jlongArray _IDs, |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 614 | jobjectArray _names, |
| 615 | jintArray _arraySizes) |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 616 | { |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 617 | uint32_t dataSize = _env->GetArrayLength(_IDs); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 618 | if (kLogApi) { |
| 619 | ALOGD("nElementGetSubElements, con(%p)", (RsContext)con); |
| 620 | } |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 621 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 622 | uintptr_t *ids = (uintptr_t*)malloc(dataSize * sizeof(uintptr_t)); |
| 623 | const char **names = (const char **)malloc(dataSize * sizeof(const char *)); |
Narayan Kamath | 78c0ce5 | 2014-03-19 10:15:51 +0000 | [diff] [blame] | 624 | uint32_t *arraySizes = (uint32_t *)malloc(dataSize * sizeof(uint32_t)); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 625 | |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 626 | rsaElementGetSubElements((RsContext)con, (RsElement)id, ids, names, arraySizes, |
| 627 | (uint32_t)dataSize); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 628 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 629 | for(uint32_t i = 0; i < dataSize; i++) { |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 630 | const jlong id = (jlong)(uintptr_t)ids[i]; |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 631 | const jint arraySize = (jint)arraySizes[i]; |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 632 | _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i])); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 633 | _env->SetLongArrayRegion(_IDs, i, 1, &id); |
| 634 | _env->SetIntArrayRegion(_arraySizes, i, 1, &arraySize); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | free(ids); |
| 638 | free(names); |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 639 | free(arraySizes); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 642 | // ----------------------------------- |
| 643 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 644 | static jlong |
| 645 | nTypeCreate(JNIEnv *_env, jobject _this, jlong con, jlong eid, |
Jason Sams | b109cc7 | 2013-01-07 18:20:12 -0800 | [diff] [blame] | 646 | jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 647 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 648 | if (kLogApi) { |
| 649 | ALOGD("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)", |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 650 | (RsContext)con, (void*)eid, dimx, dimy, dimz, mips, faces, yuv); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 651 | } |
Jason Sams | 3b9c52a | 2010-10-14 17:48:46 -0700 | [diff] [blame] | 652 | |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 653 | return (jlong)(uintptr_t)rsTypeCreate((RsContext)con, (RsElement)eid, dimx, dimy, dimz, mips, |
| 654 | faces, yuv); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 655 | } |
| 656 | |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 657 | static void |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 658 | nTypeGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jlongArray _typeData) |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 659 | { |
| 660 | // We are packing 6 items: mDimX; mDimY; mDimZ; |
| 661 | // mDimLOD; mDimFaces; mElement; into typeData |
| 662 | int elementCount = _env->GetArrayLength(_typeData); |
| 663 | |
| 664 | assert(elementCount == 6); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 665 | if (kLogApi) { |
| 666 | ALOGD("nTypeGetNativeData, con(%p)", (RsContext)con); |
| 667 | } |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 668 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 669 | uintptr_t typeData[6]; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 670 | rsaTypeGetNativeData((RsContext)con, (RsType)id, typeData, 6); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 671 | |
| 672 | for(jint i = 0; i < elementCount; i ++) { |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 673 | const jlong data = (jlong)(uintptr_t)typeData[i]; |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 674 | _env->SetLongArrayRegion(_typeData, i, 1, &data); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 675 | } |
| 676 | } |
| 677 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 678 | // ----------------------------------- |
| 679 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 680 | static jlong |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 681 | nAllocationCreateTyped(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mips, jint usage, |
| 682 | jlong pointer) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 683 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 684 | if (kLogApi) { |
| 685 | ALOGD("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", |
| 686 | (RsContext)con, (RsElement)type, mips, usage, (void *)pointer); |
| 687 | } |
| 688 | return (jlong)(uintptr_t) rsAllocationCreateTyped((RsContext)con, (RsType)type, |
| 689 | (RsAllocationMipmapControl)mips, |
| 690 | (uint32_t)usage, (uintptr_t)pointer); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 691 | } |
| 692 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 693 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 694 | nAllocationSyncAll(JNIEnv *_env, jobject _this, jlong con, jlong a, jint bits) |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 695 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 696 | if (kLogApi) { |
| 697 | ALOGD("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", (RsContext)con, (RsAllocation)a, |
| 698 | bits); |
| 699 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 700 | rsAllocationSyncAll((RsContext)con, (RsAllocation)a, (RsAllocationUsageType)bits); |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 701 | } |
| 702 | |
Jason Sams | 72226e0 | 2013-02-22 12:45:54 -0800 | [diff] [blame] | 703 | static jobject |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 704 | nAllocationGetSurface(JNIEnv *_env, jobject _this, jlong con, jlong a) |
Jason Sams | 615e7ce | 2012-01-13 14:01:20 -0800 | [diff] [blame] | 705 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 706 | if (kLogApi) { |
| 707 | ALOGD("nAllocationGetSurface, con(%p), a(%p)", (RsContext)con, (RsAllocation)a); |
| 708 | } |
Jason Sams | 615e7ce | 2012-01-13 14:01:20 -0800 | [diff] [blame] | 709 | |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 710 | IGraphicBufferProducer *v = (IGraphicBufferProducer *)rsAllocationGetSurface((RsContext)con, |
| 711 | (RsAllocation)a); |
Jason Sams | 72226e0 | 2013-02-22 12:45:54 -0800 | [diff] [blame] | 712 | sp<IGraphicBufferProducer> bp = v; |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 713 | v->decStrong(nullptr); |
Jason Sams | fe1d5ff | 2012-03-23 11:47:26 -0700 | [diff] [blame] | 714 | |
Jason Sams | 72226e0 | 2013-02-22 12:45:54 -0800 | [diff] [blame] | 715 | jobject o = android_view_Surface_createFromIGraphicBufferProducer(_env, bp); |
| 716 | return o; |
Jason Sams | fe1d5ff | 2012-03-23 11:47:26 -0700 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 720 | nAllocationSetSurface(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject sur) |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 721 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 722 | if (kLogApi) { |
| 723 | ALOGD("nAllocationSetSurface, con(%p), alloc(%p), surface(%p)", (RsContext)con, |
| 724 | (RsAllocation)alloc, (Surface *)sur); |
| 725 | } |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 726 | |
Jason Sams | fb9aa9f | 2012-03-28 15:30:07 -0700 | [diff] [blame] | 727 | sp<Surface> s; |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 728 | if (sur != 0) { |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 729 | s = android_view_Surface_getSurface(_env, sur); |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 730 | } |
| 731 | |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 732 | rsAllocationSetSurface((RsContext)con, (RsAllocation)alloc, |
| 733 | static_cast<ANativeWindow *>(s.get())); |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 737 | nAllocationIoSend(JNIEnv *_env, jobject _this, jlong con, jlong alloc) |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 738 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 739 | if (kLogApi) { |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 740 | ALOGD("nAllocationIoSend, con(%p), alloc(%p)", (RsContext)con, (RsAllocation)alloc); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 741 | } |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 742 | rsAllocationIoSend((RsContext)con, (RsAllocation)alloc); |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 746 | nAllocationIoReceive(JNIEnv *_env, jobject _this, jlong con, jlong alloc) |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 747 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 748 | if (kLogApi) { |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 749 | ALOGD("nAllocationIoReceive, con(%p), alloc(%p)", (RsContext)con, (RsAllocation)alloc); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 750 | } |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 751 | rsAllocationIoReceive((RsContext)con, (RsAllocation)alloc); |
Jason Sams | 163766c | 2012-02-15 12:04:24 -0800 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | |
| 755 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 756 | nAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, jlong con, jlong alloc) |
Jason Sams | f708609 | 2011-01-12 13:28:37 -0800 | [diff] [blame] | 757 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 758 | if (kLogApi) { |
| 759 | ALOGD("nAllocationGenerateMipmaps, con(%p), a(%p)", (RsContext)con, (RsAllocation)alloc); |
| 760 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 761 | rsAllocationGenerateMipmaps((RsContext)con, (RsAllocation)alloc); |
Jason Sams | f708609 | 2011-01-12 13:28:37 -0800 | [diff] [blame] | 762 | } |
| 763 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 764 | static jlong |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 765 | nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, |
| 766 | jobject jbitmap, jint usage) |
Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 767 | { |
Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 768 | SkBitmap const * nativeBitmap = |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 769 | (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); |
Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 770 | const SkBitmap& bitmap(*nativeBitmap); |
Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 771 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 772 | bitmap.lockPixels(); |
| 773 | const void* ptr = bitmap.getPixels(); |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 774 | jlong id = (jlong)(uintptr_t)rsAllocationCreateFromBitmap((RsContext)con, |
Jason Sams | 65bdaf1 | 2011-04-26 14:50:00 -0700 | [diff] [blame] | 775 | (RsType)type, (RsAllocationMipmapControl)mip, |
| 776 | ptr, bitmap.getSize(), usage); |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 777 | bitmap.unlockPixels(); |
| 778 | return id; |
Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 779 | } |
Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 780 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 781 | static jlong |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 782 | nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, jlong con, jlong type, |
| 783 | jint mip, jobject jbitmap, jint usage) |
Tim Murray | a314551 | 2012-12-04 17:59:29 -0800 | [diff] [blame] | 784 | { |
| 785 | SkBitmap const * nativeBitmap = |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 786 | (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); |
Tim Murray | a314551 | 2012-12-04 17:59:29 -0800 | [diff] [blame] | 787 | const SkBitmap& bitmap(*nativeBitmap); |
| 788 | |
| 789 | bitmap.lockPixels(); |
| 790 | const void* ptr = bitmap.getPixels(); |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 791 | jlong id = (jlong)(uintptr_t)rsAllocationCreateTyped((RsContext)con, |
Tim Murray | a314551 | 2012-12-04 17:59:29 -0800 | [diff] [blame] | 792 | (RsType)type, (RsAllocationMipmapControl)mip, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 793 | (uint32_t)usage, (uintptr_t)ptr); |
Tim Murray | a314551 | 2012-12-04 17:59:29 -0800 | [diff] [blame] | 794 | bitmap.unlockPixels(); |
| 795 | return id; |
| 796 | } |
| 797 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 798 | static jlong |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 799 | nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type, jint mip, |
| 800 | jobject jbitmap, jint usage) |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 801 | { |
| 802 | SkBitmap const * nativeBitmap = |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 803 | (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 804 | const SkBitmap& bitmap(*nativeBitmap); |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 805 | |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 806 | bitmap.lockPixels(); |
| 807 | const void* ptr = bitmap.getPixels(); |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 808 | jlong id = (jlong)(uintptr_t)rsAllocationCubeCreateFromBitmap((RsContext)con, |
Jason Sams | 65bdaf1 | 2011-04-26 14:50:00 -0700 | [diff] [blame] | 809 | (RsType)type, (RsAllocationMipmapControl)mip, |
| 810 | ptr, bitmap.getSize(), usage); |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 811 | bitmap.unlockPixels(); |
| 812 | return id; |
Alex Sakhartchouk | 67f2e44 | 2010-11-18 15:22:43 -0800 | [diff] [blame] | 813 | } |
| 814 | |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 815 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 816 | nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject jbitmap) |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 817 | { |
| 818 | SkBitmap const * nativeBitmap = |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 819 | (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 820 | const SkBitmap& bitmap(*nativeBitmap); |
Jason Sams | f708609 | 2011-01-12 13:28:37 -0800 | [diff] [blame] | 821 | int w = bitmap.width(); |
| 822 | int h = bitmap.height(); |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 823 | |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 824 | bitmap.lockPixels(); |
| 825 | const void* ptr = bitmap.getPixels(); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 826 | rsAllocation2DData((RsContext)con, (RsAllocation)alloc, 0, 0, |
Alex Sakhartchouk | 304b1f5 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 827 | 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, |
Tim Murray | 38faea3 | 2012-11-27 14:55:08 -0800 | [diff] [blame] | 828 | w, h, ptr, bitmap.getSize(), 0); |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 829 | bitmap.unlockPixels(); |
| 830 | } |
| 831 | |
| 832 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 833 | nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject jbitmap) |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 834 | { |
| 835 | SkBitmap const * nativeBitmap = |
Ashok Bhat | 36bef0b | 2014-01-20 20:08:01 +0000 | [diff] [blame] | 836 | (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID); |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 837 | const SkBitmap& bitmap(*nativeBitmap); |
| 838 | |
| 839 | bitmap.lockPixels(); |
| 840 | void* ptr = bitmap.getPixels(); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 841 | rsAllocationCopyToBitmap((RsContext)con, (RsAllocation)alloc, ptr, bitmap.getSize()); |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 842 | bitmap.unlockPixels(); |
Alex Sakhartchouk | 835b854 | 2011-07-20 14:33:10 -0700 | [diff] [blame] | 843 | bitmap.notifyPixelsChanged(); |
Alex Sakhartchouk | 26ae390 | 2010-10-11 12:35:15 -0700 | [diff] [blame] | 844 | } |
| 845 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 846 | // Copies from the Java object data into the Allocation pointed to by _alloc. |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 847 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 848 | nAllocationData1D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint offset, jint lod, |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 849 | jint count, jobject data, jint sizeBytes, jint dataType) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 850 | { |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 851 | RsAllocation *alloc = (RsAllocation *)_alloc; |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 852 | if (kLogApi) { |
| 853 | ALOGD("nAllocation1DData, con(%p), adapter(%p), offset(%i), count(%i), sizeBytes(%i), " |
| 854 | "dataType(%i)", (RsContext)con, (RsAllocation)alloc, offset, count, sizeBytes, |
| 855 | dataType); |
| 856 | } |
| 857 | PER_ARRAY_TYPE(nullptr, rsAllocation1DData, true, (RsContext)con, alloc, offset, lod, count, |
| 858 | ptr, sizeBytes); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 859 | } |
| 860 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 861 | // Copies from the Java array data into the Allocation pointed to by alloc. |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 862 | static void |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 863 | // native void rsnAllocationElementData1D(long con, long id, int xoff, int compIdx, byte[] d, int sizeBytes); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 864 | nAllocationElementData1D(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint offset, jint lod, |
| 865 | jint compIdx, jbyteArray data, jint sizeBytes) |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 866 | { |
| 867 | jint len = _env->GetArrayLength(data); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 868 | if (kLogApi) { |
| 869 | ALOGD("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), " |
| 870 | "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, offset, compIdx, len, |
| 871 | sizeBytes); |
| 872 | } |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 873 | jbyte *ptr = _env->GetByteArrayElements(data, nullptr); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 874 | rsAllocation1DElementData((RsContext)con, (RsAllocation)alloc, offset, lod, ptr, sizeBytes, compIdx); |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 875 | _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); |
| 876 | } |
| 877 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 878 | // Copies from the Java object data into the Allocation pointed to by _alloc. |
Jason Sams | 49bdaf0 | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 879 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 880 | nAllocationData2D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xoff, jint yoff, jint lod, jint _face, |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 881 | jint w, jint h, jobject data, jint sizeBytes, jint dataType) |
Jason Sams | fb9f82c | 2011-01-12 14:53:25 -0800 | [diff] [blame] | 882 | { |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 883 | RsAllocation *alloc = (RsAllocation *)_alloc; |
| 884 | RsAllocationCubemapFace face = (RsAllocationCubemapFace)_face; |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 885 | if (kLogApi) { |
| 886 | ALOGD("nAllocation2DData, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i) " |
| 887 | "type(%i)", (RsContext)con, alloc, xoff, yoff, w, h, sizeBytes, dataType); |
| 888 | } |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 889 | PER_ARRAY_TYPE(nullptr, rsAllocation2DData, true, (RsContext)con, alloc, xoff, yoff, lod, face, w, h, ptr, sizeBytes, 0); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 890 | } |
| 891 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 892 | // Copies from the Allocation pointed to by srcAlloc into the Allocation |
| 893 | // pointed to by dstAlloc. |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 894 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 895 | nAllocationData2D_alloc(JNIEnv *_env, jobject _this, jlong con, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 896 | jlong dstAlloc, jint dstXoff, jint dstYoff, |
Alex Sakhartchouk | 304b1f5 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 897 | jint dstMip, jint dstFace, |
| 898 | jint width, jint height, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 899 | jlong srcAlloc, jint srcXoff, jint srcYoff, |
Alex Sakhartchouk | 304b1f5 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 900 | jint srcMip, jint srcFace) |
| 901 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 902 | if (kLogApi) { |
| 903 | ALOGD("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," |
| 904 | " dstMip(%i), dstFace(%i), width(%i), height(%i)," |
| 905 | " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", |
| 906 | (RsContext)con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, |
| 907 | width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); |
| 908 | } |
Alex Sakhartchouk | 304b1f5 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 909 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 910 | rsAllocationCopy2DRange((RsContext)con, |
Alex Sakhartchouk | 304b1f5 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 911 | (RsAllocation)dstAlloc, |
| 912 | dstXoff, dstYoff, |
| 913 | dstMip, dstFace, |
| 914 | width, height, |
| 915 | (RsAllocation)srcAlloc, |
| 916 | srcXoff, srcYoff, |
| 917 | srcMip, srcFace); |
| 918 | } |
| 919 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 920 | // Copies from the Java object data into the Allocation pointed to by _alloc. |
Alex Sakhartchouk | 304b1f5 | 2011-06-14 11:13:19 -0700 | [diff] [blame] | 921 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 922 | nAllocationData3D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xoff, jint yoff, jint zoff, jint lod, |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 923 | jint w, jint h, jint d, jobject data, int sizeBytes, int dataType) |
Jason Sams | b05d689 | 2013-04-09 15:59:24 -0700 | [diff] [blame] | 924 | { |
Jason Sams | e729a94 | 2013-11-06 11:22:02 -0800 | [diff] [blame] | 925 | RsAllocation *alloc = (RsAllocation *)_alloc; |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 926 | if (kLogApi) { |
| 927 | ALOGD("nAllocation3DData, con(%p), alloc(%p), xoff(%i), yoff(%i), zoff(%i), lod(%i), w(%i)," |
| 928 | " h(%i), d(%i), sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, yoff, zoff, |
| 929 | lod, w, h, d, sizeBytes); |
| 930 | } |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 931 | PER_ARRAY_TYPE(nullptr, rsAllocation3DData, true, (RsContext)con, alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0); |
Jason Sams | b05d689 | 2013-04-09 15:59:24 -0700 | [diff] [blame] | 932 | } |
| 933 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 934 | // Copies from the Allocation pointed to by srcAlloc into the Allocation |
| 935 | // pointed to by dstAlloc. |
Jason Sams | b05d689 | 2013-04-09 15:59:24 -0700 | [diff] [blame] | 936 | static void |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 937 | nAllocationData3D_alloc(JNIEnv *_env, jobject _this, jlong con, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 938 | jlong dstAlloc, jint dstXoff, jint dstYoff, jint dstZoff, |
Jason Sams | b05d689 | 2013-04-09 15:59:24 -0700 | [diff] [blame] | 939 | jint dstMip, |
| 940 | jint width, jint height, jint depth, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 941 | jlong srcAlloc, jint srcXoff, jint srcYoff, jint srcZoff, |
Jason Sams | b05d689 | 2013-04-09 15:59:24 -0700 | [diff] [blame] | 942 | jint srcMip) |
| 943 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 944 | if (kLogApi) { |
| 945 | ALOGD("nAllocationData3D_alloc, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," |
| 946 | " dstMip(%i), width(%i), height(%i)," |
| 947 | " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i)", |
| 948 | (RsContext)con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, |
| 949 | width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip); |
| 950 | } |
Jason Sams | b05d689 | 2013-04-09 15:59:24 -0700 | [diff] [blame] | 951 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 952 | rsAllocationCopy3DRange((RsContext)con, |
Jason Sams | b05d689 | 2013-04-09 15:59:24 -0700 | [diff] [blame] | 953 | (RsAllocation)dstAlloc, |
| 954 | dstXoff, dstYoff, dstZoff, dstMip, |
| 955 | width, height, depth, |
| 956 | (RsAllocation)srcAlloc, |
| 957 | srcXoff, srcYoff, srcZoff, srcMip); |
| 958 | } |
| 959 | |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 960 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 961 | // Copies from the Allocation pointed to by _alloc into the Java object data. |
Jason Sams | b05d689 | 2013-04-09 15:59:24 -0700 | [diff] [blame] | 962 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 963 | nAllocationRead(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jobject data, int dataType) |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 964 | { |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 965 | RsAllocation *alloc = (RsAllocation *)_alloc; |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 966 | if (kLogApi) { |
| 967 | ALOGD("nAllocationRead, con(%p), alloc(%p)", (RsContext)con, (RsAllocation)alloc); |
| 968 | } |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 969 | PER_ARRAY_TYPE(0, rsAllocationRead, false, (RsContext)con, alloc, ptr, len * typeBytes); |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 970 | } |
| 971 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 972 | // Copies from the Allocation pointed to by _alloc into the Java object data. |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 973 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 974 | nAllocationRead1D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint offset, jint lod, |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 975 | jint count, jobject data, int sizeBytes, int dataType) |
Jason Sams | fb9f82c | 2011-01-12 14:53:25 -0800 | [diff] [blame] | 976 | { |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 977 | RsAllocation *alloc = (RsAllocation *)_alloc; |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 978 | if (kLogApi) { |
| 979 | ALOGD("nAllocation1DRead, con(%p), adapter(%p), offset(%i), count(%i), sizeBytes(%i), " |
| 980 | "dataType(%i)", (RsContext)con, alloc, offset, count, sizeBytes, dataType); |
| 981 | } |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 982 | PER_ARRAY_TYPE(0, rsAllocation1DRead, false, (RsContext)con, alloc, offset, lod, count, ptr, sizeBytes); |
Jason Sams | fb9f82c | 2011-01-12 14:53:25 -0800 | [diff] [blame] | 983 | } |
| 984 | |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 985 | // Copies from the Allocation pointed to by _alloc into the Java object data. |
Jason Sams | fb9f82c | 2011-01-12 14:53:25 -0800 | [diff] [blame] | 986 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 987 | nAllocationRead2D(JNIEnv *_env, jobject _this, jlong con, jlong _alloc, jint xoff, jint yoff, jint lod, jint _face, |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 988 | jint w, jint h, jobject data, int sizeBytes, int dataType) |
Jason Sams | fb9f82c | 2011-01-12 14:53:25 -0800 | [diff] [blame] | 989 | { |
Jason Sams | 21659ac | 2013-11-06 15:08:07 -0800 | [diff] [blame] | 990 | RsAllocation *alloc = (RsAllocation *)_alloc; |
| 991 | RsAllocationCubemapFace face = (RsAllocationCubemapFace)_face; |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 992 | if (kLogApi) { |
| 993 | ALOGD("nAllocation2DRead, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i) " |
| 994 | "type(%i)", (RsContext)con, alloc, xoff, yoff, w, h, sizeBytes, dataType); |
| 995 | } |
| 996 | PER_ARRAY_TYPE(0, rsAllocation2DRead, false, (RsContext)con, alloc, xoff, yoff, lod, face, w, h, |
| 997 | ptr, sizeBytes, 0); |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 998 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 999 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1000 | static jlong |
| 1001 | nAllocationGetType(JNIEnv *_env, jobject _this, jlong con, jlong a) |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 1002 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1003 | if (kLogApi) { |
| 1004 | ALOGD("nAllocationGetType, con(%p), a(%p)", (RsContext)con, (RsAllocation)a); |
| 1005 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1006 | return (jlong)(uintptr_t) rsaAllocationGetType((RsContext)con, (RsAllocation)a); |
Alex Sakhartchouk | dfac814 | 2010-07-15 11:33:03 -0700 | [diff] [blame] | 1007 | } |
| 1008 | |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 1009 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1010 | nAllocationResize1D(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint dimX) |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 1011 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1012 | if (kLogApi) { |
| 1013 | ALOGD("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", (RsContext)con, |
| 1014 | (RsAllocation)alloc, dimX); |
| 1015 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1016 | rsAllocationResize1D((RsContext)con, (RsAllocation)alloc, dimX); |
Jason Sams | 5edc608 | 2010-10-05 13:32:49 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1019 | // ----------------------------------- |
| 1020 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1021 | static jlong |
| 1022 | nFileA3DCreateFromAssetStream(JNIEnv *_env, jobject _this, jlong con, jlong native_asset) |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1023 | { |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1024 | Asset* asset = reinterpret_cast<Asset*>(native_asset); |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1025 | ALOGV("______nFileA3D %p", asset); |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1026 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1027 | jlong id = (jlong)(uintptr_t)rsaFileA3DCreateFromMemory((RsContext)con, asset->getBuffer(false), asset->getLength()); |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1028 | return id; |
| 1029 | } |
| 1030 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1031 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1032 | nFileA3DCreateFromAsset(JNIEnv *_env, jobject _this, jlong con, jobject _assetMgr, jstring _path) |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1033 | { |
| 1034 | AssetManager* mgr = assetManagerForJavaObject(_env, _assetMgr); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1035 | if (mgr == nullptr) { |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1036 | return 0; |
| 1037 | } |
| 1038 | |
| 1039 | AutoJavaStringToUTF8 str(_env, _path); |
| 1040 | Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1041 | if (asset == nullptr) { |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1042 | return 0; |
| 1043 | } |
| 1044 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1045 | jlong id = (jlong)(uintptr_t)rsaFileA3DCreateFromAsset((RsContext)con, asset); |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1046 | return id; |
| 1047 | } |
| 1048 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1049 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1050 | nFileA3DCreateFromFile(JNIEnv *_env, jobject _this, jlong con, jstring fileName) |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1051 | { |
| 1052 | AutoJavaStringToUTF8 fileNameUTF(_env, fileName); |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1053 | jlong id = (jlong)(uintptr_t)rsaFileA3DCreateFromFile((RsContext)con, fileNameUTF.c_str()); |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1054 | |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1055 | return id; |
| 1056 | } |
| 1057 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1058 | static jint |
| 1059 | nFileA3DGetNumIndexEntries(JNIEnv *_env, jobject _this, jlong con, jlong fileA3D) |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1060 | { |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1061 | int32_t numEntries = 0; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1062 | rsaFileA3DGetNumIndexEntries((RsContext)con, &numEntries, (RsFile)fileA3D); |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1063 | return (jint)numEntries; |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1064 | } |
| 1065 | |
| 1066 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1067 | nFileA3DGetIndexEntries(JNIEnv *_env, jobject _this, jlong con, jlong fileA3D, jint numEntries, jintArray _ids, jobjectArray _entries) |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1068 | { |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1069 | ALOGV("______nFileA3D %p", (RsFile) fileA3D); |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1070 | RsFileIndexEntry *fileEntries = (RsFileIndexEntry*)malloc((uint32_t)numEntries * sizeof(RsFileIndexEntry)); |
| 1071 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1072 | rsaFileA3DGetIndexEntries((RsContext)con, fileEntries, (uint32_t)numEntries, (RsFile)fileA3D); |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1073 | |
| 1074 | for(jint i = 0; i < numEntries; i ++) { |
| 1075 | _env->SetObjectArrayElement(_entries, i, _env->NewStringUTF(fileEntries[i].objectName)); |
| 1076 | _env->SetIntArrayRegion(_ids, i, 1, (const jint*)&fileEntries[i].classID); |
| 1077 | } |
| 1078 | |
| 1079 | free(fileEntries); |
| 1080 | } |
| 1081 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1082 | static jlong |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1083 | nFileA3DGetEntryByIndex(JNIEnv *_env, jobject _this, jlong con, jlong fileA3D, jint index) |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1084 | { |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1085 | ALOGV("______nFileA3D %p", (RsFile) fileA3D); |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1086 | jlong id = (jlong)(uintptr_t)rsaFileA3DGetEntryByIndex((RsContext)con, (uint32_t)index, (RsFile)fileA3D); |
Alex Sakhartchouk | aae74ad | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 1087 | return id; |
| 1088 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1089 | |
| 1090 | // ----------------------------------- |
| 1091 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1092 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1093 | nFontCreateFromFile(JNIEnv *_env, jobject _this, jlong con, |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1094 | jstring fileName, jfloat fontSize, jint dpi) |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 1095 | { |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1096 | AutoJavaStringToUTF8 fileNameUTF(_env, fileName); |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1097 | jlong id = (jlong)(uintptr_t)rsFontCreateFromFile((RsContext)con, |
Alex Sakhartchouk | e7c4a75 | 2011-04-06 10:57:51 -0700 | [diff] [blame] | 1098 | fileNameUTF.c_str(), fileNameUTF.length(), |
| 1099 | fontSize, dpi); |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 1100 | |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1101 | return id; |
| 1102 | } |
| 1103 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1104 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1105 | nFontCreateFromAssetStream(JNIEnv *_env, jobject _this, jlong con, |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1106 | jstring name, jfloat fontSize, jint dpi, jlong native_asset) |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1107 | { |
| 1108 | Asset* asset = reinterpret_cast<Asset*>(native_asset); |
| 1109 | AutoJavaStringToUTF8 nameUTF(_env, name); |
| 1110 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1111 | jlong id = (jlong)(uintptr_t)rsFontCreateFromMemory((RsContext)con, |
Alex Sakhartchouk | e7c4a75 | 2011-04-06 10:57:51 -0700 | [diff] [blame] | 1112 | nameUTF.c_str(), nameUTF.length(), |
| 1113 | fontSize, dpi, |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1114 | asset->getBuffer(false), asset->getLength()); |
| 1115 | return id; |
| 1116 | } |
| 1117 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1118 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1119 | nFontCreateFromAsset(JNIEnv *_env, jobject _this, jlong con, jobject _assetMgr, jstring _path, |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1120 | jfloat fontSize, jint dpi) |
| 1121 | { |
| 1122 | AssetManager* mgr = assetManagerForJavaObject(_env, _assetMgr); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1123 | if (mgr == nullptr) { |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1124 | return 0; |
| 1125 | } |
| 1126 | |
| 1127 | AutoJavaStringToUTF8 str(_env, _path); |
| 1128 | Asset* asset = mgr->open(str.c_str(), Asset::ACCESS_BUFFER); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1129 | if (asset == nullptr) { |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1130 | return 0; |
| 1131 | } |
| 1132 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1133 | jlong id = (jlong)(uintptr_t)rsFontCreateFromMemory((RsContext)con, |
Alex Sakhartchouk | e7c4a75 | 2011-04-06 10:57:51 -0700 | [diff] [blame] | 1134 | str.c_str(), str.length(), |
| 1135 | fontSize, dpi, |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1136 | asset->getBuffer(false), asset->getLength()); |
| 1137 | delete asset; |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 1138 | return id; |
| 1139 | } |
| 1140 | |
Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 1141 | // ----------------------------------- |
| 1142 | |
| 1143 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1144 | nScriptBindAllocation(JNIEnv *_env, jobject _this, jlong con, jlong script, jlong alloc, jint slot) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1145 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1146 | if (kLogApi) { |
| 1147 | ALOGD("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", (RsContext)con, |
| 1148 | (RsScript)script, (RsAllocation)alloc, slot); |
| 1149 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1150 | rsScriptBindAllocation((RsContext)con, (RsScript)script, (RsAllocation)alloc, slot); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1151 | } |
| 1152 | |
| 1153 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1154 | nScriptSetVarI(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jint val) |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1155 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1156 | if (kLogApi) { |
| 1157 | ALOGD("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", (RsContext)con, (void *)script, |
| 1158 | slot, val); |
| 1159 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1160 | rsScriptSetVarI((RsContext)con, (RsScript)script, slot, val); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1163 | static jint |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1164 | nScriptGetVarI(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1165 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1166 | if (kLogApi) { |
| 1167 | ALOGD("nScriptGetVarI, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1168 | } |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1169 | int value = 0; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1170 | rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value)); |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1171 | return value; |
| 1172 | } |
| 1173 | |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1174 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1175 | nScriptSetVarObj(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jlong val) |
Jason Sams | 6f4cf0b | 2010-11-16 17:37:02 -0800 | [diff] [blame] | 1176 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1177 | if (kLogApi) { |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 1178 | ALOGD("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%" PRId64 ")", (RsContext)con, (void *)script, |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1179 | slot, val); |
| 1180 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1181 | rsScriptSetVarObj((RsContext)con, (RsScript)script, slot, (RsObjectBase)val); |
Jason Sams | 6f4cf0b | 2010-11-16 17:37:02 -0800 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1185 | nScriptSetVarJ(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jlong val) |
Stephen Hines | 031ec58c | 2010-10-11 10:54:21 -0700 | [diff] [blame] | 1186 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1187 | if (kLogApi) { |
Bernhard Rosenkränzer | 09993f7 | 2014-11-17 20:25:28 +0100 | [diff] [blame] | 1188 | ALOGD("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%" PRId64 ")", (RsContext)con, (void *)script, |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1189 | slot, val); |
| 1190 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1191 | rsScriptSetVarJ((RsContext)con, (RsScript)script, slot, val); |
Stephen Hines | 031ec58c | 2010-10-11 10:54:21 -0700 | [diff] [blame] | 1192 | } |
| 1193 | |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1194 | static jlong |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1195 | nScriptGetVarJ(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1196 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1197 | if (kLogApi) { |
| 1198 | ALOGD("nScriptGetVarJ, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1199 | } |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1200 | jlong value = 0; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1201 | rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value)); |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1202 | return value; |
| 1203 | } |
| 1204 | |
Stephen Hines | 031ec58c | 2010-10-11 10:54:21 -0700 | [diff] [blame] | 1205 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1206 | nScriptSetVarF(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, float val) |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1207 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1208 | if (kLogApi) { |
| 1209 | ALOGD("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", (RsContext)con, (void *)script, |
| 1210 | slot, val); |
| 1211 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1212 | rsScriptSetVarF((RsContext)con, (RsScript)script, slot, val); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1213 | } |
| 1214 | |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1215 | static jfloat |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1216 | nScriptGetVarF(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1217 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1218 | if (kLogApi) { |
| 1219 | ALOGD("nScriptGetVarF, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1220 | } |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1221 | jfloat value = 0; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1222 | rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value)); |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1223 | return value; |
| 1224 | } |
| 1225 | |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1226 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1227 | nScriptSetVarD(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, double val) |
Stephen Hines | ca54ec3 | 2010-09-20 17:20:30 -0700 | [diff] [blame] | 1228 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1229 | if (kLogApi) { |
| 1230 | ALOGD("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", (RsContext)con, (void *)script, |
| 1231 | slot, val); |
| 1232 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1233 | rsScriptSetVarD((RsContext)con, (RsScript)script, slot, val); |
Stephen Hines | ca54ec3 | 2010-09-20 17:20:30 -0700 | [diff] [blame] | 1234 | } |
| 1235 | |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1236 | static jdouble |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1237 | nScriptGetVarD(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot) |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1238 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1239 | if (kLogApi) { |
| 1240 | ALOGD("nScriptGetVarD, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1241 | } |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1242 | jdouble value = 0; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1243 | rsScriptGetVarV((RsContext)con, (RsScript)script, slot, &value, sizeof(value)); |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1244 | return value; |
| 1245 | } |
| 1246 | |
Stephen Hines | ca54ec3 | 2010-09-20 17:20:30 -0700 | [diff] [blame] | 1247 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1248 | nScriptSetVarV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data) |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1249 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1250 | if (kLogApi) { |
| 1251 | ALOGD("nScriptSetVarV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1252 | } |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1253 | jint len = _env->GetArrayLength(data); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1254 | jbyte *ptr = _env->GetByteArrayElements(data, nullptr); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1255 | rsScriptSetVarV((RsContext)con, (RsScript)script, slot, ptr, len); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1256 | _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); |
| 1257 | } |
| 1258 | |
Stephen Hines | adeb809 | 2012-04-20 14:26:06 -0700 | [diff] [blame] | 1259 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1260 | nScriptGetVarV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data) |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1261 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1262 | if (kLogApi) { |
| 1263 | ALOGD("nScriptSetVarV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1264 | } |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1265 | jint len = _env->GetArrayLength(data); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1266 | jbyte *ptr = _env->GetByteArrayElements(data, nullptr); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1267 | rsScriptGetVarV((RsContext)con, (RsScript)script, slot, ptr, len); |
Stephen Hines | 414fa2c | 2014-04-17 01:02:42 -0700 | [diff] [blame] | 1268 | _env->ReleaseByteArrayElements(data, ptr, 0); |
Tim Murray | 7c4caad | 2013-04-10 16:21:40 -0700 | [diff] [blame] | 1269 | } |
| 1270 | |
| 1271 | static void |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1272 | nScriptSetVarVE(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data, |
| 1273 | jlong elem, jintArray dims) |
Stephen Hines | adeb809 | 2012-04-20 14:26:06 -0700 | [diff] [blame] | 1274 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1275 | if (kLogApi) { |
| 1276 | ALOGD("nScriptSetVarVE, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1277 | } |
Stephen Hines | adeb809 | 2012-04-20 14:26:06 -0700 | [diff] [blame] | 1278 | jint len = _env->GetArrayLength(data); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1279 | jbyte *ptr = _env->GetByteArrayElements(data, nullptr); |
Stephen Hines | adeb809 | 2012-04-20 14:26:06 -0700 | [diff] [blame] | 1280 | jint dimsLen = _env->GetArrayLength(dims) * sizeof(int); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1281 | jint *dimsPtr = _env->GetIntArrayElements(dims, nullptr); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1282 | rsScriptSetVarVE((RsContext)con, (RsScript)script, slot, ptr, len, (RsElement)elem, |
Stephen Hines | bc5d3ee | 2014-06-25 00:03:39 -0700 | [diff] [blame] | 1283 | (const uint32_t*) dimsPtr, dimsLen); |
Stephen Hines | adeb809 | 2012-04-20 14:26:06 -0700 | [diff] [blame] | 1284 | _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); |
| 1285 | _env->ReleaseIntArrayElements(dims, dimsPtr, JNI_ABORT); |
| 1286 | } |
| 1287 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1288 | |
| 1289 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1290 | nScriptSetTimeZone(JNIEnv *_env, jobject _this, jlong con, jlong script, jbyteArray timeZone) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1291 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1292 | if (kLogApi) { |
| 1293 | ALOGD("nScriptCSetTimeZone, con(%p), s(%p)", (RsContext)con, (void *)script); |
| 1294 | } |
Romain Guy | 584a375 | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 1295 | |
| 1296 | jint length = _env->GetArrayLength(timeZone); |
| 1297 | jbyte* timeZone_ptr; |
| 1298 | timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0); |
| 1299 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1300 | rsScriptSetTimeZone((RsContext)con, (RsScript)script, (const char *)timeZone_ptr, length); |
Romain Guy | 584a375 | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 1301 | |
| 1302 | if (timeZone_ptr) { |
| 1303 | _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0); |
| 1304 | } |
| 1305 | } |
| 1306 | |
Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 1307 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1308 | nScriptInvoke(JNIEnv *_env, jobject _this, jlong con, jlong obj, jint slot) |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 1309 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1310 | if (kLogApi) { |
| 1311 | ALOGD("nScriptInvoke, con(%p), script(%p)", (RsContext)con, (void *)obj); |
| 1312 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1313 | rsScriptInvoke((RsContext)con, (RsScript)obj, slot); |
Jason Sams | be2e841 | 2009-09-16 15:04:38 -0700 | [diff] [blame] | 1314 | } |
| 1315 | |
| 1316 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1317 | nScriptInvokeV(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, jbyteArray data) |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1318 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1319 | if (kLogApi) { |
| 1320 | ALOGD("nScriptInvokeV, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1321 | } |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1322 | jint len = _env->GetArrayLength(data); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1323 | jbyte *ptr = _env->GetByteArrayElements(data, nullptr); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1324 | rsScriptInvokeV((RsContext)con, (RsScript)script, slot, ptr, len); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 1325 | _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); |
| 1326 | } |
| 1327 | |
Jason Sams | 6e494d3 | 2011-04-27 16:33:11 -0700 | [diff] [blame] | 1328 | static void |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1329 | nScriptForEach(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot, |
| 1330 | jlongArray ains, jlong aout, jbyteArray params, |
| 1331 | jintArray limits) |
Jason Sams | 6e494d3 | 2011-04-27 16:33:11 -0700 | [diff] [blame] | 1332 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1333 | if (kLogApi) { |
| 1334 | ALOGD("nScriptForEach, con(%p), s(%p), slot(%i)", (RsContext)con, (void *)script, slot); |
| 1335 | } |
Jason Sams | 6e494d3 | 2011-04-27 16:33:11 -0700 | [diff] [blame] | 1336 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1337 | jint in_len = 0; |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1338 | jlong *in_ptr = nullptr; |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1339 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1340 | RsAllocation *in_allocs = nullptr; |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1341 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1342 | if (ains != nullptr) { |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1343 | in_len = _env->GetArrayLength(ains); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1344 | in_ptr = _env->GetLongArrayElements(ains, nullptr); |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1345 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1346 | if (sizeof(RsAllocation) == sizeof(jlong)) { |
| 1347 | in_allocs = (RsAllocation*)in_ptr; |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1348 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1349 | } else { |
| 1350 | // Convert from 64-bit jlong types to the native pointer type. |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1351 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1352 | in_allocs = (RsAllocation*)alloca(in_len * sizeof(RsAllocation)); |
| 1353 | |
| 1354 | for (int index = in_len; --index >= 0;) { |
| 1355 | in_allocs[index] = (RsAllocation)in_ptr[index]; |
| 1356 | } |
| 1357 | } |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1358 | } |
| 1359 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1360 | jint param_len = 0; |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1361 | jbyte *param_ptr = nullptr; |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1362 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1363 | if (params != nullptr) { |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1364 | param_len = _env->GetArrayLength(params); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1365 | param_ptr = _env->GetByteArrayElements(params, nullptr); |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1366 | } |
| 1367 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1368 | RsScriptCall sc, *sca = nullptr; |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1369 | uint32_t sc_size = 0; |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1370 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1371 | jint limit_len = 0; |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1372 | jint *limit_ptr = nullptr; |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1373 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1374 | if (limits != nullptr) { |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1375 | limit_len = _env->GetArrayLength(limits); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1376 | limit_ptr = _env->GetIntArrayElements(limits, nullptr); |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1377 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1378 | assert(limit_len == 6); |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1379 | UNUSED(limit_len); // As the assert might not be compiled. |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1380 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1381 | sc.xStart = limit_ptr[0]; |
| 1382 | sc.xEnd = limit_ptr[1]; |
| 1383 | sc.yStart = limit_ptr[2]; |
| 1384 | sc.yEnd = limit_ptr[3]; |
| 1385 | sc.zStart = limit_ptr[4]; |
| 1386 | sc.zEnd = limit_ptr[5]; |
| 1387 | sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE; |
Jason Sams | 14331ab | 2015-01-26 18:14:36 -0800 | [diff] [blame] | 1388 | sc.arrayStart = 0; |
| 1389 | sc.arrayEnd = 0; |
| 1390 | sc.array2Start = 0; |
| 1391 | sc.array2End = 0; |
| 1392 | sc.array3Start = 0; |
| 1393 | sc.array3End = 0; |
| 1394 | sc.array4Start = 0; |
| 1395 | sc.array4End = 0; |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1396 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1397 | sca = ≻ |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1398 | } |
| 1399 | |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1400 | rsScriptForEachMulti((RsContext)con, (RsScript)script, slot, |
| 1401 | in_allocs, in_len, (RsAllocation)aout, |
| 1402 | param_ptr, param_len, sca, sc_size); |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1403 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1404 | if (ains != nullptr) { |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1405 | _env->ReleaseLongArrayElements(ains, in_ptr, JNI_ABORT); |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1406 | } |
| 1407 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1408 | if (params != nullptr) { |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1409 | _env->ReleaseByteArrayElements(params, param_ptr, JNI_ABORT); |
| 1410 | } |
| 1411 | |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1412 | if (limits != nullptr) { |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1413 | _env->ReleaseIntArrayElements(limits, limit_ptr, JNI_ABORT); |
| 1414 | } |
Chris Wailes | 9496106 | 2014-06-11 12:01:28 -0700 | [diff] [blame] | 1415 | } |
| 1416 | |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1417 | // ----------------------------------- |
| 1418 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1419 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1420 | nScriptCCreate(JNIEnv *_env, jobject _this, jlong con, |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1421 | jstring resName, jstring cacheDir, |
| 1422 | jbyteArray scriptRef, jint length) |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1423 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1424 | if (kLogApi) { |
| 1425 | ALOGD("nScriptCCreate, con(%p)", (RsContext)con); |
| 1426 | } |
Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1427 | |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1428 | AutoJavaStringToUTF8 resNameUTF(_env, resName); |
| 1429 | AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir); |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1430 | jlong ret = 0; |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1431 | jbyte* script_ptr = nullptr; |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1432 | jint _exception = 0; |
| 1433 | jint remaining; |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1434 | if (!scriptRef) { |
| 1435 | _exception = 1; |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 1436 | //jniThrowException(_env, "java/lang/IllegalArgumentException", "script == null"); |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1437 | goto exit; |
| 1438 | } |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1439 | if (length < 0) { |
| 1440 | _exception = 1; |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 1441 | //jniThrowException(_env, "java/lang/IllegalArgumentException", "length < 0"); |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1442 | goto exit; |
| 1443 | } |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1444 | remaining = _env->GetArrayLength(scriptRef); |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1445 | if (remaining < length) { |
| 1446 | _exception = 1; |
Elliott Hughes | 8451b25 | 2011-04-07 19:17:57 -0700 | [diff] [blame] | 1447 | //jniThrowException(_env, "java/lang/IllegalArgumentException", |
| 1448 | // "length > script.length - offset"); |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1449 | goto exit; |
| 1450 | } |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1451 | script_ptr = (jbyte *) |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1452 | _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0); |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1453 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1454 | //rsScriptCSetText((RsContext)con, (const char *)script_ptr, length); |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1455 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1456 | ret = (jlong)(uintptr_t)rsScriptCCreate((RsContext)con, |
Alex Sakhartchouk | e7c4a75 | 2011-04-06 10:57:51 -0700 | [diff] [blame] | 1457 | resNameUTF.c_str(), resNameUTF.length(), |
| 1458 | cacheDirUTF.c_str(), cacheDirUTF.length(), |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1459 | (const char *)script_ptr, length); |
Jason Sams | 39ddc950 | 2009-06-05 17:35:09 -0700 | [diff] [blame] | 1460 | |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1461 | exit: |
Jason Sams | e4a06c5 | 2011-03-16 16:29:28 -0700 | [diff] [blame] | 1462 | if (script_ptr) { |
| 1463 | _env->ReleasePrimitiveArrayCritical(scriptRef, script_ptr, |
Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1464 | _exception ? JNI_ABORT: 0); |
| 1465 | } |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1466 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1467 | return (jlong)(uintptr_t)ret; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1468 | } |
| 1469 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1470 | static jlong |
| 1471 | nScriptIntrinsicCreate(JNIEnv *_env, jobject _this, jlong con, jint id, jlong eid) |
Jason Sams | 6ab9768 | 2012-08-10 12:09:43 -0700 | [diff] [blame] | 1472 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1473 | if (kLogApi) { |
| 1474 | ALOGD("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", (RsContext)con, id, |
| 1475 | (void *)eid); |
| 1476 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1477 | return (jlong)(uintptr_t)rsScriptIntrinsicCreate((RsContext)con, id, (RsElement)eid); |
Jason Sams | 6ab9768 | 2012-08-10 12:09:43 -0700 | [diff] [blame] | 1478 | } |
| 1479 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1480 | static jlong |
| 1481 | nScriptKernelIDCreate(JNIEnv *_env, jobject _this, jlong con, jlong sid, jint slot, jint sig) |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1482 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1483 | if (kLogApi) { |
| 1484 | ALOGD("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", (RsContext)con, |
| 1485 | (void *)sid, slot, sig); |
| 1486 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1487 | return (jlong)(uintptr_t)rsScriptKernelIDCreate((RsContext)con, (RsScript)sid, slot, sig); |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1488 | } |
| 1489 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1490 | static jlong |
| 1491 | nScriptFieldIDCreate(JNIEnv *_env, jobject _this, jlong con, jlong sid, jint slot) |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1492 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1493 | if (kLogApi) { |
| 1494 | ALOGD("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", (RsContext)con, (void *)sid, |
| 1495 | slot); |
| 1496 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1497 | return (jlong)(uintptr_t)rsScriptFieldIDCreate((RsContext)con, (RsScript)sid, slot); |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1498 | } |
| 1499 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1500 | static jlong |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1501 | nScriptGroupCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _kernels, jlongArray _src, |
| 1502 | jlongArray _dstk, jlongArray _dstf, jlongArray _types) |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1503 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1504 | if (kLogApi) { |
| 1505 | ALOGD("nScriptGroupCreate, con(%p)", (RsContext)con); |
| 1506 | } |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1507 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1508 | jint kernelsLen = _env->GetArrayLength(_kernels); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1509 | jlong *jKernelsPtr = _env->GetLongArrayElements(_kernels, nullptr); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1510 | RsScriptKernelID* kernelsPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * kernelsLen); |
| 1511 | for(int i = 0; i < kernelsLen; ++i) { |
| 1512 | kernelsPtr[i] = (RsScriptKernelID)jKernelsPtr[i]; |
| 1513 | } |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1514 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1515 | jint srcLen = _env->GetArrayLength(_src); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1516 | jlong *jSrcPtr = _env->GetLongArrayElements(_src, nullptr); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1517 | RsScriptKernelID* srcPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * srcLen); |
| 1518 | for(int i = 0; i < srcLen; ++i) { |
| 1519 | srcPtr[i] = (RsScriptKernelID)jSrcPtr[i]; |
| 1520 | } |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1521 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1522 | jint dstkLen = _env->GetArrayLength(_dstk); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1523 | jlong *jDstkPtr = _env->GetLongArrayElements(_dstk, nullptr); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1524 | RsScriptKernelID* dstkPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * dstkLen); |
| 1525 | for(int i = 0; i < dstkLen; ++i) { |
| 1526 | dstkPtr[i] = (RsScriptKernelID)jDstkPtr[i]; |
| 1527 | } |
| 1528 | |
| 1529 | jint dstfLen = _env->GetArrayLength(_dstf); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1530 | jlong *jDstfPtr = _env->GetLongArrayElements(_dstf, nullptr); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1531 | RsScriptKernelID* dstfPtr = (RsScriptKernelID*) malloc(sizeof(RsScriptKernelID) * dstfLen); |
| 1532 | for(int i = 0; i < dstfLen; ++i) { |
| 1533 | dstfPtr[i] = (RsScriptKernelID)jDstfPtr[i]; |
| 1534 | } |
| 1535 | |
| 1536 | jint typesLen = _env->GetArrayLength(_types); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1537 | jlong *jTypesPtr = _env->GetLongArrayElements(_types, nullptr); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1538 | RsType* typesPtr = (RsType*) malloc(sizeof(RsType) * typesLen); |
| 1539 | for(int i = 0; i < typesLen; ++i) { |
| 1540 | typesPtr[i] = (RsType)jTypesPtr[i]; |
| 1541 | } |
| 1542 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1543 | jlong id = (jlong)(uintptr_t)rsScriptGroupCreate((RsContext)con, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1544 | (RsScriptKernelID *)kernelsPtr, kernelsLen * sizeof(RsScriptKernelID), |
| 1545 | (RsScriptKernelID *)srcPtr, srcLen * sizeof(RsScriptKernelID), |
| 1546 | (RsScriptKernelID *)dstkPtr, dstkLen * sizeof(RsScriptKernelID), |
| 1547 | (RsScriptFieldID *)dstfPtr, dstfLen * sizeof(RsScriptKernelID), |
| 1548 | (RsType *)typesPtr, typesLen * sizeof(RsType)); |
| 1549 | |
| 1550 | free(kernelsPtr); |
| 1551 | free(srcPtr); |
| 1552 | free(dstkPtr); |
| 1553 | free(dstfPtr); |
| 1554 | free(typesPtr); |
| 1555 | _env->ReleaseLongArrayElements(_kernels, jKernelsPtr, 0); |
| 1556 | _env->ReleaseLongArrayElements(_src, jSrcPtr, 0); |
| 1557 | _env->ReleaseLongArrayElements(_dstk, jDstkPtr, 0); |
| 1558 | _env->ReleaseLongArrayElements(_dstf, jDstfPtr, 0); |
| 1559 | _env->ReleaseLongArrayElements(_types, jTypesPtr, 0); |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1560 | return id; |
| 1561 | } |
| 1562 | |
| 1563 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1564 | nScriptGroupSetInput(JNIEnv *_env, jobject _this, jlong con, jlong gid, jlong kid, jlong alloc) |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1565 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1566 | if (kLogApi) { |
| 1567 | ALOGD("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", (RsContext)con, |
| 1568 | (void *)gid, (void *)kid, (void *)alloc); |
| 1569 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1570 | rsScriptGroupSetInput((RsContext)con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1571 | } |
| 1572 | |
| 1573 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1574 | nScriptGroupSetOutput(JNIEnv *_env, jobject _this, jlong con, jlong gid, jlong kid, jlong alloc) |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1575 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1576 | if (kLogApi) { |
| 1577 | ALOGD("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", (RsContext)con, |
| 1578 | (void *)gid, (void *)kid, (void *)alloc); |
| 1579 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1580 | rsScriptGroupSetOutput((RsContext)con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1581 | } |
| 1582 | |
| 1583 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1584 | nScriptGroupExecute(JNIEnv *_env, jobject _this, jlong con, jlong gid) |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1585 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1586 | if (kLogApi) { |
| 1587 | ALOGD("nScriptGroupSetOutput, con(%p) group(%p)", (RsContext)con, (void *)gid); |
| 1588 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1589 | rsScriptGroupExecute((RsContext)con, (RsScriptGroup)gid); |
Jason Sams | 08a8158 | 2012-09-18 12:32:10 -0700 | [diff] [blame] | 1590 | } |
| 1591 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1592 | // --------------------------------------------------------------------------- |
| 1593 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1594 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1595 | nProgramStoreCreate(JNIEnv *_env, jobject _this, jlong con, |
Jason Sams | 331bf9b | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 1596 | jboolean colorMaskR, jboolean colorMaskG, jboolean colorMaskB, jboolean colorMaskA, |
| 1597 | jboolean depthMask, jboolean ditherEnable, |
| 1598 | jint srcFunc, jint destFunc, |
| 1599 | jint depthFunc) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1600 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1601 | if (kLogApi) { |
| 1602 | ALOGD("nProgramStoreCreate, con(%p)", (RsContext)con); |
| 1603 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1604 | return (jlong)(uintptr_t)rsProgramStoreCreate((RsContext)con, colorMaskR, colorMaskG, colorMaskB, colorMaskA, |
Jason Sams | 331bf9b | 2011-04-06 11:23:54 -0700 | [diff] [blame] | 1605 | depthMask, ditherEnable, (RsBlendSrcFunc)srcFunc, |
| 1606 | (RsBlendDstFunc)destFunc, (RsDepthFunc)depthFunc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1607 | } |
| 1608 | |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 1609 | // --------------------------------------------------------------------------- |
| 1610 | |
| 1611 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1612 | nProgramBindConstants(JNIEnv *_env, jobject _this, jlong con, jlong vpv, jint slot, jlong a) |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 1613 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1614 | if (kLogApi) { |
| 1615 | ALOGD("nProgramBindConstants, con(%p), vpf(%p), sloat(%i), a(%p)", (RsContext)con, |
| 1616 | (RsProgramVertex)vpv, slot, (RsAllocation)a); |
| 1617 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1618 | rsProgramBindConstants((RsContext)con, (RsProgram)vpv, slot, (RsAllocation)a); |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 1619 | } |
Jason Sams | 54c0ec1 | 2009-11-30 14:49:55 -0800 | [diff] [blame] | 1620 | |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 1621 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1622 | nProgramBindTexture(JNIEnv *_env, jobject _this, jlong con, jlong vpf, jint slot, jlong a) |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 1623 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1624 | if (kLogApi) { |
| 1625 | ALOGD("nProgramBindTexture, con(%p), vpf(%p), slot(%i), a(%p)", (RsContext)con, |
| 1626 | (RsProgramFragment)vpf, slot, (RsAllocation)a); |
| 1627 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1628 | rsProgramBindTexture((RsContext)con, (RsProgramFragment)vpf, slot, (RsAllocation)a); |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 1629 | } |
| 1630 | |
| 1631 | static void |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1632 | nProgramBindSampler(JNIEnv *_env, jobject _this, jlong con, jlong vpf, jint slot, jlong a) |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 1633 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1634 | if (kLogApi) { |
| 1635 | ALOGD("nProgramBindSampler, con(%p), vpf(%p), slot(%i), a(%p)", (RsContext)con, |
| 1636 | (RsProgramFragment)vpf, slot, (RsSampler)a); |
| 1637 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1638 | rsProgramBindSampler((RsContext)con, (RsProgramFragment)vpf, slot, (RsSampler)a); |
Jason Sams | 68afd01 | 2009-12-17 16:55:08 -0800 | [diff] [blame] | 1639 | } |
| 1640 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1641 | // --------------------------------------------------------------------------- |
| 1642 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1643 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1644 | nProgramFragmentCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1645 | jobjectArray texNames, jlongArray params) |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 1646 | { |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1647 | AutoJavaStringToUTF8 shaderUTF(_env, shader); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1648 | jlong *jParamPtr = _env->GetLongArrayElements(params, nullptr); |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 1649 | jint paramLen = _env->GetArrayLength(params); |
| 1650 | |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 1651 | int texCount = _env->GetArrayLength(texNames); |
| 1652 | AutoJavaStringArrayToUTF8 names(_env, texNames, texCount); |
| 1653 | const char ** nameArray = names.c_str(); |
| 1654 | size_t* sizeArray = names.c_str_len(); |
| 1655 | |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1656 | if (kLogApi) { |
| 1657 | ALOGD("nProgramFragmentCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen); |
| 1658 | } |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 1659 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1660 | uintptr_t * paramPtr = (uintptr_t*) malloc(sizeof(uintptr_t) * paramLen); |
| 1661 | for(int i = 0; i < paramLen; ++i) { |
| 1662 | paramPtr[i] = (uintptr_t)jParamPtr[i]; |
| 1663 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1664 | jlong ret = (jlong)(uintptr_t)rsProgramFragmentCreate((RsContext)con, shaderUTF.c_str(), shaderUTF.length(), |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 1665 | nameArray, texCount, sizeArray, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1666 | paramPtr, paramLen); |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 1667 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1668 | free(paramPtr); |
| 1669 | _env->ReleaseLongArrayElements(params, jParamPtr, JNI_ABORT); |
Jason Sams | 7e5ab3b | 2009-12-15 13:27:04 -0800 | [diff] [blame] | 1670 | return ret; |
| 1671 | } |
| 1672 | |
| 1673 | |
Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1674 | // --------------------------------------------------------------------------- |
| 1675 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1676 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1677 | nProgramVertexCreate(JNIEnv *_env, jobject _this, jlong con, jstring shader, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1678 | jobjectArray texNames, jlongArray params) |
Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1679 | { |
Alex Sakhartchouk | b0253ea | 2011-01-07 11:12:08 -0800 | [diff] [blame] | 1680 | AutoJavaStringToUTF8 shaderUTF(_env, shader); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1681 | jlong *jParamPtr = _env->GetLongArrayElements(params, nullptr); |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 1682 | jint paramLen = _env->GetArrayLength(params); |
Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1683 | |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1684 | if (kLogApi) { |
| 1685 | ALOGD("nProgramVertexCreate, con(%p), paramLen(%i)", (RsContext)con, paramLen); |
| 1686 | } |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 1687 | |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 1688 | int texCount = _env->GetArrayLength(texNames); |
| 1689 | AutoJavaStringArrayToUTF8 names(_env, texNames, texCount); |
| 1690 | const char ** nameArray = names.c_str(); |
| 1691 | size_t* sizeArray = names.c_str_len(); |
| 1692 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1693 | uintptr_t * paramPtr = (uintptr_t*) malloc(sizeof(uintptr_t) * paramLen); |
| 1694 | for(int i = 0; i < paramLen; ++i) { |
| 1695 | paramPtr[i] = (uintptr_t)jParamPtr[i]; |
| 1696 | } |
| 1697 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1698 | jlong ret = (jlong)(uintptr_t)rsProgramVertexCreate((RsContext)con, shaderUTF.c_str(), shaderUTF.length(), |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 1699 | nameArray, texCount, sizeArray, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1700 | paramPtr, paramLen); |
Alex Sakhartchouk | 2123b46 | 2012-02-15 16:21:46 -0800 | [diff] [blame] | 1701 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1702 | free(paramPtr); |
| 1703 | _env->ReleaseLongArrayElements(params, jParamPtr, JNI_ABORT); |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 1704 | return ret; |
| 1705 | } |
Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1706 | |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 1707 | // --------------------------------------------------------------------------- |
| 1708 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1709 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1710 | nProgramRasterCreate(JNIEnv *_env, jobject _this, jlong con, jboolean pointSprite, jint cull) |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 1711 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1712 | if (kLogApi) { |
| 1713 | ALOGD("nProgramRasterCreate, con(%p), pointSprite(%i), cull(%i)", (RsContext)con, |
| 1714 | pointSprite, cull); |
| 1715 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1716 | return (jlong)(uintptr_t)rsProgramRasterCreate((RsContext)con, pointSprite, (RsCullMode)cull); |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 1717 | } |
| 1718 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1719 | |
| 1720 | // --------------------------------------------------------------------------- |
| 1721 | |
| 1722 | static void |
Narayan Kamath | 78c0ce5 | 2014-03-19 10:15:51 +0000 | [diff] [blame] | 1723 | nContextBindRootScript(JNIEnv *_env, jobject _this, jlong con, jlong script) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1724 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1725 | if (kLogApi) { |
| 1726 | ALOGD("nContextBindRootScript, con(%p), script(%p)", (RsContext)con, (RsScript)script); |
| 1727 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1728 | rsContextBindRootScript((RsContext)con, (RsScript)script); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1729 | } |
| 1730 | |
| 1731 | static void |
Narayan Kamath | 78c0ce5 | 2014-03-19 10:15:51 +0000 | [diff] [blame] | 1732 | nContextBindProgramStore(JNIEnv *_env, jobject _this, jlong con, jlong pfs) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1733 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1734 | if (kLogApi) { |
| 1735 | ALOGD("nContextBindProgramStore, con(%p), pfs(%p)", (RsContext)con, (RsProgramStore)pfs); |
| 1736 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1737 | rsContextBindProgramStore((RsContext)con, (RsProgramStore)pfs); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1738 | } |
| 1739 | |
| 1740 | static void |
Narayan Kamath | 78c0ce5 | 2014-03-19 10:15:51 +0000 | [diff] [blame] | 1741 | nContextBindProgramFragment(JNIEnv *_env, jobject _this, jlong con, jlong pf) |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1742 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1743 | if (kLogApi) { |
| 1744 | ALOGD("nContextBindProgramFragment, con(%p), pf(%p)", (RsContext)con, |
| 1745 | (RsProgramFragment)pf); |
| 1746 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1747 | rsContextBindProgramFragment((RsContext)con, (RsProgramFragment)pf); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1748 | } |
| 1749 | |
Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 1750 | static void |
Narayan Kamath | 78c0ce5 | 2014-03-19 10:15:51 +0000 | [diff] [blame] | 1751 | nContextBindProgramVertex(JNIEnv *_env, jobject _this, jlong con, jlong pf) |
Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 1752 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1753 | if (kLogApi) { |
| 1754 | ALOGD("nContextBindProgramVertex, con(%p), pf(%p)", (RsContext)con, (RsProgramVertex)pf); |
| 1755 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1756 | rsContextBindProgramVertex((RsContext)con, (RsProgramVertex)pf); |
Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 1757 | } |
| 1758 | |
Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 1759 | static void |
Narayan Kamath | 78c0ce5 | 2014-03-19 10:15:51 +0000 | [diff] [blame] | 1760 | nContextBindProgramRaster(JNIEnv *_env, jobject _this, jlong con, jlong pf) |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 1761 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1762 | if (kLogApi) { |
| 1763 | ALOGD("nContextBindProgramRaster, con(%p), pf(%p)", (RsContext)con, (RsProgramRaster)pf); |
| 1764 | } |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1765 | rsContextBindProgramRaster((RsContext)con, (RsProgramRaster)pf); |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 1766 | } |
| 1767 | |
Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 1768 | |
Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1769 | // --------------------------------------------------------------------------- |
| 1770 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1771 | static jlong |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1772 | nSamplerCreate(JNIEnv *_env, jobject _this, jlong con, jint magFilter, jint minFilter, |
Alex Sakhartchouk | a89094a | 2011-05-04 17:45:36 -0700 | [diff] [blame] | 1773 | jint wrapS, jint wrapT, jint wrapR, jfloat aniso) |
Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1774 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1775 | if (kLogApi) { |
| 1776 | ALOGD("nSamplerCreate, con(%p)", (RsContext)con); |
| 1777 | } |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1778 | return (jlong)(uintptr_t)rsSamplerCreate((RsContext)con, |
Alex Sakhartchouk | a89094a | 2011-05-04 17:45:36 -0700 | [diff] [blame] | 1779 | (RsSamplerValue)magFilter, |
| 1780 | (RsSamplerValue)minFilter, |
| 1781 | (RsSamplerValue)wrapS, |
| 1782 | (RsSamplerValue)wrapT, |
| 1783 | (RsSamplerValue)wrapR, |
| 1784 | aniso); |
Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1785 | } |
| 1786 | |
Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1787 | // --------------------------------------------------------------------------- |
| 1788 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1789 | static jlong |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1790 | nPathCreate(JNIEnv *_env, jobject _this, jlong con, jint prim, jboolean isStatic, jlong _vtx, jlong _loop, jfloat q) { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1791 | if (kLogApi) { |
| 1792 | ALOGD("nPathCreate, con(%p)", (RsContext)con); |
| 1793 | } |
Jason Sams | f15ed01 | 2011-10-31 13:23:43 -0700 | [diff] [blame] | 1794 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1795 | jlong id = (jlong)(uintptr_t)rsPathCreate((RsContext)con, (RsPathPrimitive)prim, isStatic, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1796 | (RsAllocation)_vtx, |
| 1797 | (RsAllocation)_loop, q); |
Jason Sams | f15ed01 | 2011-10-31 13:23:43 -0700 | [diff] [blame] | 1798 | return id; |
| 1799 | } |
| 1800 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1801 | static jlong |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1802 | nMeshCreate(JNIEnv *_env, jobject _this, jlong con, jlongArray _vtx, jlongArray _idx, jintArray _prim) |
Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1803 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1804 | if (kLogApi) { |
| 1805 | ALOGD("nMeshCreate, con(%p)", (RsContext)con); |
| 1806 | } |
Alex Sakhartchouk | 25999a0 | 2011-05-12 10:38:03 -0700 | [diff] [blame] | 1807 | |
| 1808 | jint vtxLen = _env->GetArrayLength(_vtx); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1809 | jlong *jVtxPtr = _env->GetLongArrayElements(_vtx, nullptr); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1810 | RsAllocation* vtxPtr = (RsAllocation*) malloc(sizeof(RsAllocation) * vtxLen); |
| 1811 | for(int i = 0; i < vtxLen; ++i) { |
| 1812 | vtxPtr[i] = (RsAllocation)(uintptr_t)jVtxPtr[i]; |
| 1813 | } |
| 1814 | |
Alex Sakhartchouk | 25999a0 | 2011-05-12 10:38:03 -0700 | [diff] [blame] | 1815 | jint idxLen = _env->GetArrayLength(_idx); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1816 | jlong *jIdxPtr = _env->GetLongArrayElements(_idx, nullptr); |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1817 | RsAllocation* idxPtr = (RsAllocation*) malloc(sizeof(RsAllocation) * idxLen); |
| 1818 | for(int i = 0; i < idxLen; ++i) { |
| 1819 | idxPtr[i] = (RsAllocation)(uintptr_t)jIdxPtr[i]; |
| 1820 | } |
| 1821 | |
Alex Sakhartchouk | 25999a0 | 2011-05-12 10:38:03 -0700 | [diff] [blame] | 1822 | jint primLen = _env->GetArrayLength(_prim); |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 1823 | jint *primPtr = _env->GetIntArrayElements(_prim, nullptr); |
Alex Sakhartchouk | 25999a0 | 2011-05-12 10:38:03 -0700 | [diff] [blame] | 1824 | |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1825 | jlong id = (jlong)(uintptr_t)rsMeshCreate((RsContext)con, |
Alex Sakhartchouk | 25999a0 | 2011-05-12 10:38:03 -0700 | [diff] [blame] | 1826 | (RsAllocation *)vtxPtr, vtxLen, |
| 1827 | (RsAllocation *)idxPtr, idxLen, |
| 1828 | (uint32_t *)primPtr, primLen); |
| 1829 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1830 | free(vtxPtr); |
| 1831 | free(idxPtr); |
| 1832 | _env->ReleaseLongArrayElements(_vtx, jVtxPtr, 0); |
| 1833 | _env->ReleaseLongArrayElements(_idx, jIdxPtr, 0); |
Alex Sakhartchouk | 25999a0 | 2011-05-12 10:38:03 -0700 | [diff] [blame] | 1834 | _env->ReleaseIntArrayElements(_prim, primPtr, 0); |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 1835 | return id; |
| 1836 | } |
| 1837 | |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1838 | static jint |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1839 | nMeshGetVertexBufferCount(JNIEnv *_env, jobject _this, jlong con, jlong mesh) |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1840 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1841 | if (kLogApi) { |
| 1842 | ALOGD("nMeshGetVertexBufferCount, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); |
| 1843 | } |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1844 | jint vtxCount = 0; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1845 | rsaMeshGetVertexBufferCount((RsContext)con, (RsMesh)mesh, &vtxCount); |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1846 | return vtxCount; |
| 1847 | } |
| 1848 | |
| 1849 | static jint |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1850 | nMeshGetIndexCount(JNIEnv *_env, jobject _this, jlong con, jlong mesh) |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1851 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1852 | if (kLogApi) { |
| 1853 | ALOGD("nMeshGetIndexCount, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); |
| 1854 | } |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1855 | jint idxCount = 0; |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1856 | rsaMeshGetIndexCount((RsContext)con, (RsMesh)mesh, &idxCount); |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1857 | return idxCount; |
| 1858 | } |
| 1859 | |
| 1860 | static void |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1861 | nMeshGetVertices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _ids, jint numVtxIDs) |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1862 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1863 | if (kLogApi) { |
| 1864 | ALOGD("nMeshGetVertices, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); |
| 1865 | } |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1866 | |
| 1867 | RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numVtxIDs * sizeof(RsAllocation)); |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1868 | rsaMeshGetVertices((RsContext)con, (RsMesh)mesh, allocs, (uint32_t)numVtxIDs); |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1869 | |
| 1870 | for(jint i = 0; i < numVtxIDs; i ++) { |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1871 | const jlong alloc = (jlong)(uintptr_t)allocs[i]; |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1872 | _env->SetLongArrayRegion(_ids, i, 1, &alloc); |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1873 | } |
| 1874 | |
| 1875 | free(allocs); |
| 1876 | } |
| 1877 | |
| 1878 | static void |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1879 | nMeshGetIndices(JNIEnv *_env, jobject _this, jlong con, jlong mesh, jlongArray _idxIds, jintArray _primitives, jint numIndices) |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1880 | { |
Andreas Gampe | 6733392 | 2014-11-10 20:35:59 -0800 | [diff] [blame] | 1881 | if (kLogApi) { |
| 1882 | ALOGD("nMeshGetVertices, con(%p), Mesh(%p)", (RsContext)con, (RsMesh)mesh); |
| 1883 | } |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1884 | |
| 1885 | RsAllocation *allocs = (RsAllocation*)malloc((uint32_t)numIndices * sizeof(RsAllocation)); |
| 1886 | uint32_t *prims= (uint32_t*)malloc((uint32_t)numIndices * sizeof(uint32_t)); |
| 1887 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1888 | rsaMeshGetIndices((RsContext)con, (RsMesh)mesh, allocs, prims, (uint32_t)numIndices); |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1889 | |
| 1890 | for(jint i = 0; i < numIndices; i ++) { |
Tim Murray | 3aa89c1 | 2014-08-18 17:51:22 -0700 | [diff] [blame] | 1891 | const jlong alloc = (jlong)(uintptr_t)allocs[i]; |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1892 | const jint prim = (jint)prims[i]; |
| 1893 | _env->SetLongArrayRegion(_idxIds, i, 1, &alloc); |
| 1894 | _env->SetIntArrayRegion(_primitives, i, 1, &prim); |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 1895 | } |
| 1896 | |
| 1897 | free(allocs); |
| 1898 | free(prims); |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 1899 | } |
| 1900 | |
Tim Murray | 56f9e6f | 2014-05-16 11:47:26 -0700 | [diff] [blame] | 1901 | static jint |
| 1902 | nSystemGetPointerSize(JNIEnv *_env, jobject _this) { |
| 1903 | return (jint)sizeof(void*); |
| 1904 | } |
| 1905 | |
| 1906 | |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 1907 | // --------------------------------------------------------------------------- |
| 1908 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1909 | |
Jason Sams | 94d8e90a | 2009-06-10 16:09:05 -0700 | [diff] [blame] | 1910 | static const char *classPathName = "android/renderscript/RenderScript"; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1911 | |
| 1912 | static JNINativeMethod methods[] = { |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 1913 | {"_nInit", "()V", (void*)_nInit }, |
Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 1914 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1915 | {"nDeviceCreate", "()J", (void*)nDeviceCreate }, |
| 1916 | {"nDeviceDestroy", "(J)V", (void*)nDeviceDestroy }, |
| 1917 | {"nDeviceSetConfig", "(JII)V", (void*)nDeviceSetConfig }, |
| 1918 | {"nContextGetUserMessage", "(J[I)I", (void*)nContextGetUserMessage }, |
| 1919 | {"nContextGetErrorMessage", "(J)Ljava/lang/String;", (void*)nContextGetErrorMessage }, |
| 1920 | {"nContextPeekMessage", "(J[I)I", (void*)nContextPeekMessage }, |
Jason Sams | 1c41517 | 2010-11-08 17:06:46 -0800 | [diff] [blame] | 1921 | |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1922 | {"nContextInitToClient", "(J)V", (void*)nContextInitToClient }, |
| 1923 | {"nContextDeinitToClient", "(J)V", (void*)nContextDeinitToClient }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1924 | |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 1925 | |
Jason Sams | 2e1872f | 2010-08-17 16:25:41 -0700 | [diff] [blame] | 1926 | // All methods below are thread protected in java. |
Tim Murray | eff663f | 2013-11-15 13:08:30 -0800 | [diff] [blame] | 1927 | {"rsnContextCreate", "(JIII)J", (void*)nContextCreate }, |
| 1928 | {"rsnContextCreateGL", "(JIIIIIIIIIIIIFI)J", (void*)nContextCreateGL }, |
| 1929 | {"rsnContextFinish", "(J)V", (void*)nContextFinish }, |
| 1930 | {"rsnContextSetPriority", "(JI)V", (void*)nContextSetPriority }, |
| 1931 | {"rsnContextSetSurface", "(JIILandroid/view/Surface;)V", (void*)nContextSetSurface }, |
| 1932 | {"rsnContextDestroy", "(J)V", (void*)nContextDestroy }, |
| 1933 | {"rsnContextDump", "(JI)V", (void*)nContextDump }, |
| 1934 | {"rsnContextPause", "(J)V", (void*)nContextPause }, |
| 1935 | {"rsnContextResume", "(J)V", (void*)nContextResume }, |
| 1936 | {"rsnContextSendMessage", "(JI[I)V", (void*)nContextSendMessage }, |
Yang Ni | 281c325 | 2014-10-24 08:52:24 -0700 | [diff] [blame] | 1937 | {"rsnClosureCreate", "(JJJ[J[J[I[J[J)J", (void*)nClosureCreate }, |
| 1938 | {"rsnClosureSetArg", "(JJIJI)V", (void*)nClosureSetArg }, |
| 1939 | {"rsnClosureSetGlobal", "(JJJJI)V", (void*)nClosureSetGlobal }, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1940 | {"rsnAssignName", "(JJ[B)V", (void*)nAssignName }, |
| 1941 | {"rsnGetName", "(JJ)Ljava/lang/String;", (void*)nGetName }, |
| 1942 | {"rsnObjDestroy", "(JJ)V", (void*)nObjDestroy }, |
Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 1943 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1944 | {"rsnFileA3DCreateFromFile", "(JLjava/lang/String;)J", (void*)nFileA3DCreateFromFile }, |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1945 | {"rsnFileA3DCreateFromAssetStream", "(JJ)J", (void*)nFileA3DCreateFromAssetStream }, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1946 | {"rsnFileA3DCreateFromAsset", "(JLandroid/content/res/AssetManager;Ljava/lang/String;)J", (void*)nFileA3DCreateFromAsset }, |
| 1947 | {"rsnFileA3DGetNumIndexEntries", "(JJ)I", (void*)nFileA3DGetNumIndexEntries }, |
| 1948 | {"rsnFileA3DGetIndexEntries", "(JJI[I[Ljava/lang/String;)V", (void*)nFileA3DGetIndexEntries }, |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1949 | {"rsnFileA3DGetEntryByIndex", "(JJI)J", (void*)nFileA3DGetEntryByIndex }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1950 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 1951 | {"rsnFontCreateFromFile", "(JLjava/lang/String;FI)J", (void*)nFontCreateFromFile }, |
| 1952 | {"rsnFontCreateFromAssetStream", "(JLjava/lang/String;FIJ)J", (void*)nFontCreateFromAssetStream }, |
| 1953 | {"rsnFontCreateFromAsset", "(JLandroid/content/res/AssetManager;Ljava/lang/String;FI)J", (void*)nFontCreateFromAsset }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1954 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1955 | {"rsnElementCreate", "(JJIZI)J", (void*)nElementCreate }, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1956 | {"rsnElementCreate2", "(J[J[Ljava/lang/String;[I)J", (void*)nElementCreate2 }, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1957 | {"rsnElementGetNativeData", "(JJ[I)V", (void*)nElementGetNativeData }, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1958 | {"rsnElementGetSubElements", "(JJ[J[Ljava/lang/String;[I)V", (void*)nElementGetSubElements }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1959 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1960 | {"rsnTypeCreate", "(JJIIIZZI)J", (void*)nTypeCreate }, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1961 | {"rsnTypeGetNativeData", "(JJ[J)V", (void*)nTypeGetNativeData }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1962 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 1963 | {"rsnAllocationCreateTyped", "(JJIIJ)J", (void*)nAllocationCreateTyped }, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1964 | {"rsnAllocationCreateFromBitmap", "(JJILandroid/graphics/Bitmap;I)J", (void*)nAllocationCreateFromBitmap }, |
| 1965 | {"rsnAllocationCreateBitmapBackedAllocation", "(JJILandroid/graphics/Bitmap;I)J", (void*)nAllocationCreateBitmapBackedAllocation }, |
| 1966 | {"rsnAllocationCubeCreateFromBitmap","(JJILandroid/graphics/Bitmap;I)J", (void*)nAllocationCubeCreateFromBitmap }, |
Jason Sams | 5476b45 | 2010-12-08 16:14:36 -0800 | [diff] [blame] | 1967 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1968 | {"rsnAllocationCopyFromBitmap", "(JJLandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, |
| 1969 | {"rsnAllocationCopyToBitmap", "(JJLandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap }, |
Jason Sams | 4ef6650 | 2010-12-10 16:03:15 -0800 | [diff] [blame] | 1970 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1971 | {"rsnAllocationSyncAll", "(JJI)V", (void*)nAllocationSyncAll }, |
| 1972 | {"rsnAllocationGetSurface", "(JJ)Landroid/view/Surface;", (void*)nAllocationGetSurface }, |
| 1973 | {"rsnAllocationSetSurface", "(JJLandroid/view/Surface;)V", (void*)nAllocationSetSurface }, |
| 1974 | {"rsnAllocationIoSend", "(JJ)V", (void*)nAllocationIoSend }, |
| 1975 | {"rsnAllocationIoReceive", "(JJ)V", (void*)nAllocationIoReceive }, |
| 1976 | {"rsnAllocationData1D", "(JJIIILjava/lang/Object;II)V", (void*)nAllocationData1D }, |
| 1977 | {"rsnAllocationElementData1D", "(JJIII[BI)V", (void*)nAllocationElementData1D }, |
| 1978 | {"rsnAllocationData2D", "(JJIIIIIILjava/lang/Object;II)V", (void*)nAllocationData2D }, |
| 1979 | {"rsnAllocationData2D", "(JJIIIIIIJIIII)V", (void*)nAllocationData2D_alloc }, |
| 1980 | {"rsnAllocationData3D", "(JJIIIIIIILjava/lang/Object;II)V", (void*)nAllocationData3D }, |
| 1981 | {"rsnAllocationData3D", "(JJIIIIIIIJIIII)V", (void*)nAllocationData3D_alloc }, |
| 1982 | {"rsnAllocationRead", "(JJLjava/lang/Object;I)V", (void*)nAllocationRead }, |
| 1983 | {"rsnAllocationRead1D", "(JJIIILjava/lang/Object;II)V", (void*)nAllocationRead1D }, |
| 1984 | {"rsnAllocationRead2D", "(JJIIIIIILjava/lang/Object;II)V", (void*)nAllocationRead2D }, |
| 1985 | {"rsnAllocationGetType", "(JJ)J", (void*)nAllocationGetType}, |
| 1986 | {"rsnAllocationResize1D", "(JJI)V", (void*)nAllocationResize1D }, |
| 1987 | {"rsnAllocationGenerateMipmaps", "(JJ)V", (void*)nAllocationGenerateMipmaps }, |
Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 1988 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1989 | {"rsnScriptBindAllocation", "(JJJI)V", (void*)nScriptBindAllocation }, |
| 1990 | {"rsnScriptSetTimeZone", "(JJ[B)V", (void*)nScriptSetTimeZone }, |
| 1991 | {"rsnScriptInvoke", "(JJI)V", (void*)nScriptInvoke }, |
| 1992 | {"rsnScriptInvokeV", "(JJI[B)V", (void*)nScriptInvokeV }, |
Chris Wailes | be7b1de | 2014-07-15 10:56:14 -0700 | [diff] [blame] | 1993 | |
| 1994 | {"rsnScriptForEach", "(JJI[JJ[B[I)V", (void*)nScriptForEach }, |
| 1995 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 1996 | {"rsnScriptSetVarI", "(JJII)V", (void*)nScriptSetVarI }, |
| 1997 | {"rsnScriptGetVarI", "(JJI)I", (void*)nScriptGetVarI }, |
| 1998 | {"rsnScriptSetVarJ", "(JJIJ)V", (void*)nScriptSetVarJ }, |
| 1999 | {"rsnScriptGetVarJ", "(JJI)J", (void*)nScriptGetVarJ }, |
| 2000 | {"rsnScriptSetVarF", "(JJIF)V", (void*)nScriptSetVarF }, |
| 2001 | {"rsnScriptGetVarF", "(JJI)F", (void*)nScriptGetVarF }, |
| 2002 | {"rsnScriptSetVarD", "(JJID)V", (void*)nScriptSetVarD }, |
| 2003 | {"rsnScriptGetVarD", "(JJI)D", (void*)nScriptGetVarD }, |
| 2004 | {"rsnScriptSetVarV", "(JJI[B)V", (void*)nScriptSetVarV }, |
| 2005 | {"rsnScriptGetVarV", "(JJI[B)V", (void*)nScriptGetVarV }, |
| 2006 | {"rsnScriptSetVarVE", "(JJI[BJ[I)V", (void*)nScriptSetVarVE }, |
| 2007 | {"rsnScriptSetVarObj", "(JJIJ)V", (void*)nScriptSetVarObj }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2008 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 2009 | {"rsnScriptCCreate", "(JLjava/lang/String;Ljava/lang/String;[BI)J", (void*)nScriptCCreate }, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 2010 | {"rsnScriptIntrinsicCreate", "(JIJ)J", (void*)nScriptIntrinsicCreate }, |
| 2011 | {"rsnScriptKernelIDCreate", "(JJII)J", (void*)nScriptKernelIDCreate }, |
| 2012 | {"rsnScriptFieldIDCreate", "(JJI)J", (void*)nScriptFieldIDCreate }, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 2013 | {"rsnScriptGroupCreate", "(J[J[J[J[J[J)J", (void*)nScriptGroupCreate }, |
Yang Ni | ebf6340 | 2015-01-16 11:06:26 -0800 | [diff] [blame] | 2014 | {"rsnScriptGroup2Create", "(JLjava/lang/String;[J)J", (void*)nScriptGroup2Create }, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 2015 | {"rsnScriptGroupSetInput", "(JJJJ)V", (void*)nScriptGroupSetInput }, |
| 2016 | {"rsnScriptGroupSetOutput", "(JJJJ)V", (void*)nScriptGroupSetOutput }, |
| 2017 | {"rsnScriptGroupExecute", "(JJ)V", (void*)nScriptGroupExecute }, |
Yang Ni | 281c325 | 2014-10-24 08:52:24 -0700 | [diff] [blame] | 2018 | {"rsnScriptGroup2Execute", "(JJ)V", (void*)nScriptGroup2Execute }, |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 2019 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 2020 | {"rsnProgramStoreCreate", "(JZZZZZZIII)J", (void*)nProgramStoreCreate }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2021 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 2022 | {"rsnProgramBindConstants", "(JJIJ)V", (void*)nProgramBindConstants }, |
| 2023 | {"rsnProgramBindTexture", "(JJIJ)V", (void*)nProgramBindTexture }, |
| 2024 | {"rsnProgramBindSampler", "(JJIJ)V", (void*)nProgramBindSampler }, |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 2025 | |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 2026 | {"rsnProgramFragmentCreate", "(JLjava/lang/String;[Ljava/lang/String;[J)J", (void*)nProgramFragmentCreate }, |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 2027 | {"rsnProgramRasterCreate", "(JZI)J", (void*)nProgramRasterCreate }, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 2028 | {"rsnProgramVertexCreate", "(JLjava/lang/String;[Ljava/lang/String;[J)J", (void*)nProgramVertexCreate }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2029 | |
Narayan Kamath | 78c0ce5 | 2014-03-19 10:15:51 +0000 | [diff] [blame] | 2030 | {"rsnContextBindRootScript", "(JJ)V", (void*)nContextBindRootScript }, |
| 2031 | {"rsnContextBindProgramStore", "(JJ)V", (void*)nContextBindProgramStore }, |
| 2032 | {"rsnContextBindProgramFragment", "(JJ)V", (void*)nContextBindProgramFragment }, |
| 2033 | {"rsnContextBindProgramVertex", "(JJ)V", (void*)nContextBindProgramVertex }, |
| 2034 | {"rsnContextBindProgramRaster", "(JJ)V", (void*)nContextBindProgramRaster }, |
Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 2035 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 2036 | {"rsnSamplerCreate", "(JIIIIIF)J", (void*)nSamplerCreate }, |
Alex Sakhartchouk | 164aaed | 2010-07-01 16:14:06 -0700 | [diff] [blame] | 2037 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 2038 | {"rsnPathCreate", "(JIZJJF)J", (void*)nPathCreate }, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 2039 | {"rsnMeshCreate", "(J[J[J[I)J", (void*)nMeshCreate }, |
Jason Sams | 2e1872f | 2010-08-17 16:25:41 -0700 | [diff] [blame] | 2040 | |
Tim Murray | 460a049 | 2013-11-19 12:45:54 -0800 | [diff] [blame] | 2041 | {"rsnMeshGetVertexBufferCount", "(JJ)I", (void*)nMeshGetVertexBufferCount }, |
| 2042 | {"rsnMeshGetIndexCount", "(JJ)I", (void*)nMeshGetIndexCount }, |
Ashok Bhat | 9807155 | 2014-02-12 09:54:43 +0000 | [diff] [blame] | 2043 | {"rsnMeshGetVertices", "(JJ[JI)V", (void*)nMeshGetVertices }, |
| 2044 | {"rsnMeshGetIndices", "(JJ[J[II)V", (void*)nMeshGetIndices }, |
Alex Sakhartchouk | 80a4c2c | 2010-07-12 15:50:32 -0700 | [diff] [blame] | 2045 | |
Tim Murray | 56f9e6f | 2014-05-16 11:47:26 -0700 | [diff] [blame] | 2046 | {"rsnSystemGetPointerSize", "()I", (void*)nSystemGetPointerSize }, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2047 | }; |
| 2048 | |
| 2049 | static int registerFuncs(JNIEnv *_env) |
| 2050 | { |
| 2051 | return android::AndroidRuntime::registerNativeMethods( |
| 2052 | _env, classPathName, methods, NELEM(methods)); |
| 2053 | } |
| 2054 | |
| 2055 | // --------------------------------------------------------------------------- |
| 2056 | |
| 2057 | jint JNI_OnLoad(JavaVM* vm, void* reserved) |
| 2058 | { |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 2059 | JNIEnv* env = nullptr; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2060 | jint result = -1; |
| 2061 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2062 | if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 2063 | ALOGE("ERROR: GetEnv failed\n"); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2064 | goto bail; |
| 2065 | } |
Chris Wailes | 488230c3 | 2014-08-14 11:22:40 -0700 | [diff] [blame] | 2066 | assert(env != nullptr); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2067 | |
| 2068 | if (registerFuncs(env) < 0) { |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 2069 | ALOGE("ERROR: Renderscript native registration failed\n"); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 2070 | goto bail; |
| 2071 | } |
| 2072 | |
| 2073 | /* success -- return valid version number */ |
| 2074 | result = JNI_VERSION_1_4; |
| 2075 | |
| 2076 | bail: |
| 2077 | return result; |
| 2078 | } |