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