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