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