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