| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 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 | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 26 | #include <ui/Surface.h> |
| 27 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 28 | #include <core/SkBitmap.h> |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 29 | #include <core/SkPixelRef.h> |
| 30 | #include <core/SkStream.h> |
| 31 | #include <core/SkTemplates.h> |
| 32 | #include <images/SkImageDecoder.h> |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 33 | |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 34 | #include <utils/Asset.h> |
| 35 | #include <utils/ResourceTypes.h> |
| Jason Sams | f29ca50 | 2009-06-23 12:22:47 -0700 | [diff] [blame] | 36 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 37 | #include "jni.h" |
| 38 | #include "JNIHelp.h" |
| 39 | #include "android_runtime/AndroidRuntime.h" |
| 40 | |
| Jason Sams | e29d471 | 2009-07-23 15:19:03 -0700 | [diff] [blame] | 41 | #include <RenderScript.h> |
| 42 | #include <RenderScriptEnv.h> |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 43 | |
| 44 | //#define LOG_API LOGE |
| 45 | #define LOG_API(...) |
| 46 | |
| 47 | using namespace android; |
| 48 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 49 | // --------------------------------------------------------------------------- |
| 50 | |
| 51 | static void doThrow(JNIEnv* env, const char* exc, const char* msg = NULL) |
| 52 | { |
| 53 | jclass npeClazz = env->FindClass(exc); |
| 54 | env->ThrowNew(npeClazz, msg); |
| 55 | } |
| 56 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 57 | static jfieldID gContextId = 0; |
| 58 | static jfieldID gNativeBitmapID = 0; |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 59 | static jfieldID gTypeNativeCache = 0; |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 60 | |
| 61 | static void _nInit(JNIEnv *_env, jclass _this) |
| 62 | { |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 63 | gContextId = _env->GetFieldID(_this, "mContext", "I"); |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 64 | |
| 65 | jclass bitmapClass = _env->FindClass("android/graphics/Bitmap"); |
| 66 | gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "I"); |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 67 | |
| 68 | jclass typeClass = _env->FindClass("android/renderscript/Type"); |
| 69 | gTypeNativeCache = _env->GetFieldID(typeClass, "mNativeCache", "I"); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | |
| 73 | // --------------------------------------------------------------------------- |
| 74 | |
| Jason Sams | 3eaa338e | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 75 | static void |
| 76 | nAssignName(JNIEnv *_env, jobject _this, jint obj, jbyteArray str) |
| 77 | { |
| 78 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 79 | LOG_API("nAssignName, con(%p), obj(%p)", con, (void *)obj); |
| Jason Sams | 3eaa338e | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 80 | |
| 81 | jint len = _env->GetArrayLength(str); |
| 82 | jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 83 | rsAssignName(con, (void *)obj, (const char *)cptr, len); |
| Jason Sams | 3eaa338e | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 84 | _env->ReleasePrimitiveArrayCritical(str, cptr, JNI_ABORT); |
| 85 | } |
| 86 | |
| Jason Sams | 7ce033d | 2009-08-18 14:14:24 -0700 | [diff] [blame] | 87 | static void |
| 88 | nObjDestroy(JNIEnv *_env, jobject _this, jint obj) |
| 89 | { |
| 90 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 91 | LOG_API("nObjDestroy, con(%p) obj(%p)", con, (void *)obj); |
| 92 | rsObjDestroy(con, (void *)obj); |
| 93 | } |
| 94 | |
| Jason Sams | 730ee65 | 2009-08-18 17:07:09 -0700 | [diff] [blame] | 95 | static void |
| 96 | nObjDestroyOOB(JNIEnv *_env, jobject _this, jint obj) |
| 97 | { |
| 98 | // This function only differs from nObjDestroy in that it calls the |
| 99 | // special Out Of Band version of ObjDestroy which is thread safe. |
| 100 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 101 | LOG_API("nObjDestroyOOB, con(%p) obj(%p)", con, (void *)obj); |
| 102 | rsObjDestroyOOB(con, (void *)obj); |
| 103 | } |
| Jason Sams | 3eaa338e | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 104 | |
| Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 105 | static jint |
| 106 | nFileOpen(JNIEnv *_env, jobject _this, jbyteArray str) |
| 107 | { |
| 108 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 109 | LOG_API("nFileOpen, con(%p)", con); |
| 110 | |
| 111 | jint len = _env->GetArrayLength(str); |
| 112 | jbyte * cptr = (jbyte *) _env->GetPrimitiveArrayCritical(str, 0); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 113 | jint ret = (jint)rsFileOpen(con, (const char *)cptr, len); |
| Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 114 | _env->ReleasePrimitiveArrayCritical(str, cptr, JNI_ABORT); |
| 115 | return ret; |
| 116 | } |
| 117 | |
| Jason Sams | 3eaa338e | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 118 | // --------------------------------------------------------------------------- |
| 119 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 120 | static jint |
| 121 | nDeviceCreate(JNIEnv *_env, jobject _this) |
| 122 | { |
| 123 | LOG_API("nDeviceCreate"); |
| 124 | return (jint)rsDeviceCreate(); |
| 125 | } |
| 126 | |
| 127 | static void |
| 128 | nDeviceDestroy(JNIEnv *_env, jobject _this, jint dev) |
| 129 | { |
| 130 | LOG_API("nDeviceDestroy"); |
| 131 | return rsDeviceDestroy((RsDevice)dev); |
| 132 | } |
| 133 | |
| 134 | static jint |
| Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 135 | nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver, jboolean useDepth) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 136 | { |
| 137 | LOG_API("nContextCreate"); |
| 138 | |
| 139 | if (wnd == NULL) { |
| 140 | not_valid_surface: |
| 141 | doThrow(_env, "java/lang/IllegalArgumentException", |
| 142 | "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"); |
| 143 | return 0; |
| 144 | } |
| 145 | jclass surface_class = _env->FindClass("android/view/Surface"); |
| 146 | jfieldID surfaceFieldID = _env->GetFieldID(surface_class, "mSurface", "I"); |
| 147 | Surface * window = (Surface*)_env->GetIntField(wnd, surfaceFieldID); |
| 148 | if (window == NULL) |
| 149 | goto not_valid_surface; |
| 150 | |
| Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 151 | return (jint)rsContextCreate((RsDevice)dev, window, ver, useDepth); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | static void |
| 155 | nContextDestroy(JNIEnv *_env, jobject _this, jint con) |
| 156 | { |
| 157 | LOG_API("nContextDestroy, con(%p)", (RsContext)con); |
| 158 | return rsContextDestroy((RsContext)con); |
| 159 | } |
| 160 | |
| 161 | |
| 162 | static void |
| 163 | nElementBegin(JNIEnv *_env, jobject _this) |
| 164 | { |
| 165 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 166 | LOG_API("nElementBegin, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 167 | rsElementBegin(con); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | static void |
| 171 | nElementAddPredefined(JNIEnv *_env, jobject _this, jint predef) |
| 172 | { |
| 173 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 174 | LOG_API("nElementAddPredefined, con(%p), predef(%i)", con, predef); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 175 | rsElementAddPredefined(con, (RsElementPredefined)predef); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static void |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 179 | nElementAdd(JNIEnv *_env, jobject _this, jint kind, jint type, jint norm, jint bits, jstring name) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 180 | { |
| 181 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 182 | const char* n = NULL; |
| 183 | if (name) { |
| 184 | n = _env->GetStringUTFChars(name, NULL); |
| 185 | } |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 186 | LOG_API("nElementAdd, con(%p), kind(%i), type(%i), norm(%i), bits(%i)", con, kind, type, norm, bits); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 187 | rsElementAdd(con, (RsDataKind)kind, (RsDataType)type, norm != 0, (size_t)bits, n); |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 188 | if (n) { |
| 189 | _env->ReleaseStringUTFChars(name, n); |
| 190 | } |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | static jint |
| 194 | nElementCreate(JNIEnv *_env, jobject _this) |
| 195 | { |
| 196 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 197 | LOG_API("nElementCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 198 | return (jint)rsElementCreate(con); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | static jint |
| 202 | nElementGetPredefined(JNIEnv *_env, jobject _this, jint predef) |
| 203 | { |
| 204 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 205 | LOG_API("nElementGetPredefined, con(%p) predef(%i)", con, predef); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 206 | return (jint)rsElementGetPredefined(con, (RsElementPredefined)predef); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 209 | // ----------------------------------- |
| 210 | |
| 211 | static void |
| 212 | nTypeBegin(JNIEnv *_env, jobject _this, jint eID) |
| 213 | { |
| 214 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 215 | LOG_API("nTypeBegin, con(%p) e(%p)", con, (RsElement)eID); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 216 | rsTypeBegin(con, (RsElement)eID); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | static void |
| 220 | nTypeAdd(JNIEnv *_env, jobject _this, jint dim, jint val) |
| 221 | { |
| 222 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 223 | LOG_API("nTypeAdd, con(%p) dim(%i), val(%i)", con, dim, val); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 224 | rsTypeAdd(con, (RsDimension)dim, val); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | static jint |
| 228 | nTypeCreate(JNIEnv *_env, jobject _this) |
| 229 | { |
| 230 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 231 | LOG_API("nTypeCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 232 | return (jint)rsTypeCreate(con); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 233 | } |
| 234 | |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 235 | static void * SF_LoadInt(JNIEnv *_env, jobject _obj, jfieldID _field, void *buffer) |
| 236 | { |
| 237 | ((int32_t *)buffer)[0] = _env->GetIntField(_obj, _field); |
| 238 | return ((uint8_t *)buffer) + 4; |
| 239 | } |
| 240 | |
| 241 | static void * SF_LoadShort(JNIEnv *_env, jobject _obj, jfieldID _field, void *buffer) |
| 242 | { |
| 243 | ((int16_t *)buffer)[0] = _env->GetShortField(_obj, _field); |
| 244 | return ((uint8_t *)buffer) + 2; |
| 245 | } |
| 246 | |
| 247 | static void * SF_LoadByte(JNIEnv *_env, jobject _obj, jfieldID _field, void *buffer) |
| 248 | { |
| 249 | ((int8_t *)buffer)[0] = _env->GetByteField(_obj, _field); |
| 250 | return ((uint8_t *)buffer) + 1; |
| 251 | } |
| 252 | |
| 253 | static void * SF_LoadFloat(JNIEnv *_env, jobject _obj, jfieldID _field, void *buffer) |
| 254 | { |
| 255 | ((float *)buffer)[0] = _env->GetFloatField(_obj, _field); |
| 256 | return ((uint8_t *)buffer) + 4; |
| 257 | } |
| 258 | |
| 259 | struct TypeFieldCache { |
| 260 | jfieldID field; |
| 261 | int bits; |
| 262 | void * (*ptr)(JNIEnv *, jobject, jfieldID, void *buffer); |
| 263 | }; |
| 264 | |
| 265 | struct TypeCache { |
| 266 | int fieldCount; |
| 267 | int size; |
| 268 | TypeFieldCache fields[1]; |
| 269 | }; |
| 270 | |
| 271 | //{"nTypeFinalDestroy", "(Landroid/renderscript/Type;)V", (void*)nTypeFinalDestroy }, |
| 272 | static void |
| 273 | nTypeFinalDestroy(JNIEnv *_env, jobject _this, jobject _type) |
| 274 | { |
| 275 | TypeCache *tc = (TypeCache *)_env->GetIntField(_type, gTypeNativeCache); |
| 276 | free(tc); |
| 277 | } |
| 278 | |
| 279 | // native void nTypeSetupFields(Type t, int[] types, int[] bits, Field[] IDs); |
| 280 | static void |
| 281 | nTypeSetupFields(JNIEnv *_env, jobject _this, jobject _type, jintArray _types, jintArray _bits, jobjectArray _IDs) |
| 282 | { |
| 283 | int fieldCount = _env->GetArrayLength(_types); |
| 284 | size_t structSize = sizeof(TypeCache) + (sizeof(TypeFieldCache) * (fieldCount-1)); |
| 285 | TypeCache *tc = (TypeCache *)malloc(structSize); |
| 286 | memset(tc, 0, structSize); |
| 287 | |
| 288 | TypeFieldCache *tfc = &tc->fields[0]; |
| 289 | tc->fieldCount = fieldCount; |
| 290 | _env->SetIntField(_type, gTypeNativeCache, (jint)tc); |
| 291 | |
| 292 | jint *fType = _env->GetIntArrayElements(_types, NULL); |
| 293 | jint *fBits = _env->GetIntArrayElements(_bits, NULL); |
| 294 | for (int ct=0; ct < fieldCount; ct++) { |
| 295 | jobject field = _env->GetObjectArrayElement(_IDs, ct); |
| 296 | tfc[ct].field = _env->FromReflectedField(field); |
| 297 | tfc[ct].bits = fBits[ct]; |
| 298 | |
| 299 | switch(fType[ct]) { |
| 300 | case RS_TYPE_FLOAT: |
| 301 | tfc[ct].ptr = SF_LoadFloat; |
| 302 | break; |
| 303 | case RS_TYPE_UNSIGNED: |
| 304 | case RS_TYPE_SIGNED: |
| 305 | switch(tfc[ct].bits) { |
| 306 | case 32: tfc[ct].ptr = SF_LoadInt; break; |
| 307 | case 16: tfc[ct].ptr = SF_LoadShort; break; |
| 308 | case 8: tfc[ct].ptr = SF_LoadByte; break; |
| 309 | } |
| 310 | break; |
| 311 | } |
| 312 | tc->size += 4; |
| 313 | } |
| 314 | |
| 315 | _env->ReleaseIntArrayElements(_types, fType, JNI_ABORT); |
| 316 | _env->ReleaseIntArrayElements(_bits, fBits, JNI_ABORT); |
| 317 | } |
| 318 | |
| 319 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 320 | // ----------------------------------- |
| 321 | |
| 322 | static jint |
| 323 | nAllocationCreateTyped(JNIEnv *_env, jobject _this, jint e) |
| 324 | { |
| 325 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 326 | LOG_API("nAllocationCreateTyped, con(%p), e(%p)", con, (RsElement)e); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 327 | return (jint) rsAllocationCreateTyped(con, (RsElement)e); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | static jint |
| 331 | nAllocationCreatePredefSized(JNIEnv *_env, jobject _this, jint predef, jint count) |
| 332 | { |
| 333 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 334 | LOG_API("nAllocationCreatePredefSized, con(%p), predef(%i), count(%i)", con, predef, count); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 335 | return (jint) rsAllocationCreatePredefSized(con, (RsElementPredefined)predef, count); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | static jint |
| 339 | nAllocationCreateSized(JNIEnv *_env, jobject _this, jint e, jint count) |
| 340 | { |
| 341 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 342 | LOG_API("nAllocationCreateSized, con(%p), e(%p), count(%i)", con, (RsElement)e, count); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 343 | return (jint) rsAllocationCreateSized(con, (RsElement)e, count); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | static void |
| 347 | nAllocationUploadToTexture(JNIEnv *_env, jobject _this, jint a, jint mip) |
| 348 | { |
| 349 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 350 | LOG_API("nAllocationUploadToTexture, con(%p), a(%p), mip(%i)", con, (RsAllocation)a, mip); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 351 | rsAllocationUploadToTexture(con, (RsAllocation)a, mip); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 352 | } |
| 353 | |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 354 | static void |
| 355 | nAllocationUploadToBufferObject(JNIEnv *_env, jobject _this, jint a) |
| 356 | { |
| 357 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 358 | LOG_API("nAllocationUploadToBufferObject, con(%p), a(%p)", con, (RsAllocation)a); |
| 359 | rsAllocationUploadToBufferObject(con, (RsAllocation)a); |
| 360 | } |
| 361 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 362 | static RsElementPredefined SkBitmapToPredefined(SkBitmap::Config cfg) |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 363 | { |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 364 | switch (cfg) { |
| 365 | case SkBitmap::kA8_Config: |
| 366 | return RS_ELEMENT_A_8; |
| 367 | case SkBitmap::kARGB_4444_Config: |
| 368 | return RS_ELEMENT_RGBA_4444; |
| 369 | case SkBitmap::kARGB_8888_Config: |
| 370 | return RS_ELEMENT_RGBA_8888; |
| 371 | case SkBitmap::kRGB_565_Config: |
| 372 | return RS_ELEMENT_RGB_565; |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 373 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 374 | default: |
| 375 | break; |
| 376 | } |
| 377 | // If we don't have a conversion mark it as a user type. |
| 378 | LOGE("Unsupported bitmap type"); |
| 379 | return RS_ELEMENT_USER_U8; |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 380 | } |
| 381 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 382 | static int |
| 383 | nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jobject jbitmap) |
| 384 | { |
| 385 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 386 | SkBitmap const * nativeBitmap = |
| 387 | (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); |
| 388 | const SkBitmap& bitmap(*nativeBitmap); |
| 389 | SkBitmap::Config config = bitmap.getConfig(); |
| 390 | |
| 391 | RsElementPredefined e = SkBitmapToPredefined(config); |
| 392 | |
| 393 | if (e != RS_ELEMENT_USER_U8) { |
| 394 | bitmap.lockPixels(); |
| 395 | const int w = bitmap.width(); |
| 396 | const int h = bitmap.height(); |
| 397 | const void* ptr = bitmap.getPixels(); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 398 | jint id = (jint)rsAllocationCreateFromBitmap(con, w, h, (RsElementPredefined)dstFmt, e, genMips, ptr); |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 399 | bitmap.unlockPixels(); |
| 400 | return id; |
| 401 | } |
| 402 | return 0; |
| 403 | } |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 404 | |
| Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 405 | static int |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 406 | nAllocationCreateFromAssetStream(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jint native_asset) |
| 407 | { |
| 408 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 409 | |
| 410 | Asset* asset = reinterpret_cast<Asset*>(native_asset); |
| 411 | SkBitmap bitmap; |
| 412 | SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(), |
| 413 | &bitmap, SkBitmap::kNo_Config, SkImageDecoder::kDecodePixels_Mode); |
| 414 | |
| 415 | SkBitmap::Config config = bitmap.getConfig(); |
| 416 | |
| 417 | RsElementPredefined e = SkBitmapToPredefined(config); |
| 418 | |
| 419 | if (e != RS_ELEMENT_USER_U8) { |
| 420 | bitmap.lockPixels(); |
| 421 | const int w = bitmap.width(); |
| 422 | const int h = bitmap.height(); |
| 423 | const void* ptr = bitmap.getPixels(); |
| 424 | jint id = (jint)rsAllocationCreateFromBitmap(con, w, h, (RsElementPredefined)dstFmt, e, genMips, ptr); |
| 425 | bitmap.unlockPixels(); |
| 426 | return id; |
| 427 | } |
| 428 | return 0; |
| 429 | } |
| 430 | |
| 431 | static int |
| Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 432 | nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jobject jbitmap) |
| 433 | { |
| 434 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 435 | SkBitmap const * nativeBitmap = |
| 436 | (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); |
| 437 | const SkBitmap& bitmap(*nativeBitmap); |
| 438 | SkBitmap::Config config = bitmap.getConfig(); |
| 439 | |
| 440 | RsElementPredefined e = SkBitmapToPredefined(config); |
| 441 | |
| 442 | if (e != RS_ELEMENT_USER_U8) { |
| 443 | bitmap.lockPixels(); |
| 444 | const int w = bitmap.width(); |
| 445 | const int h = bitmap.height(); |
| 446 | const void* ptr = bitmap.getPixels(); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 447 | jint id = (jint)rsAllocationCreateFromBitmapBoxed(con, w, h, (RsElementPredefined)dstFmt, e, genMips, ptr); |
| Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 448 | bitmap.unlockPixels(); |
| 449 | return id; |
| 450 | } |
| 451 | return 0; |
| 452 | } |
| 453 | |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 454 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 455 | static void |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 456 | nAllocationData_i(JNIEnv *_env, jobject _this, jint alloc, jintArray data, int sizeBytes) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 457 | { |
| 458 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 459 | jint len = _env->GetArrayLength(data); |
| 460 | LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); |
| 461 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 462 | rsAllocationData(con, (RsAllocation)alloc, ptr, sizeBytes); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 463 | _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); |
| 464 | } |
| 465 | |
| 466 | static void |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 467 | nAllocationData_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data, int sizeBytes) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 468 | { |
| 469 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 470 | jint len = _env->GetArrayLength(data); |
| 471 | LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); |
| 472 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 473 | rsAllocationData(con, (RsAllocation)alloc, ptr, sizeBytes); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 474 | _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); |
| 475 | } |
| 476 | |
| 477 | static void |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 478 | nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data, int sizeBytes) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 479 | { |
| 480 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 481 | jint len = _env->GetArrayLength(data); |
| 482 | LOG_API("nAllocation1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len); |
| 483 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 484 | rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 485 | _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); |
| 486 | } |
| 487 | |
| 488 | static void |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 489 | nAllocationSubData1D_f(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jfloatArray data, int sizeBytes) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 490 | { |
| 491 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 492 | jint len = _env->GetArrayLength(data); |
| 493 | LOG_API("nAllocation1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len); |
| 494 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 495 | rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 496 | _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); |
| 497 | } |
| 498 | |
| 499 | static void |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 500 | nAllocationSubData2D_i(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jintArray data, int sizeBytes) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 501 | { |
| 502 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 503 | jint len = _env->GetArrayLength(data); |
| 504 | LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len); |
| 505 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 506 | rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr, sizeBytes); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 507 | _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); |
| 508 | } |
| 509 | |
| 510 | static void |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 511 | nAllocationSubData2D_f(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jfloatArray data, int sizeBytes) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 512 | { |
| 513 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 514 | jint len = _env->GetArrayLength(data); |
| 515 | LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len); |
| 516 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 517 | rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr, sizeBytes); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 518 | _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); |
| 519 | } |
| 520 | |
| Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 521 | static void |
| 522 | nAllocationRead_i(JNIEnv *_env, jobject _this, jint alloc, jintArray data) |
| 523 | { |
| 524 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 525 | jint len = _env->GetArrayLength(data); |
| 526 | LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); |
| 527 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 528 | rsAllocationRead(con, (RsAllocation)alloc, ptr); |
| Joe Onorato | ae209ac | 2009-08-31 17:23:53 -0700 | [diff] [blame^] | 529 | _env->ReleaseIntArrayElements(data, ptr, 0); |
| Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | static void |
| 533 | nAllocationRead_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data) |
| 534 | { |
| 535 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 536 | jint len = _env->GetArrayLength(data); |
| Joe Onorato | a8f2ace | 2009-08-12 11:47:23 -0700 | [diff] [blame] | 537 | 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] | 538 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 539 | rsAllocationRead(con, (RsAllocation)alloc, ptr); |
| Joe Onorato | ae209ac | 2009-08-31 17:23:53 -0700 | [diff] [blame^] | 540 | _env->ReleaseFloatArrayElements(data, ptr, 0); |
| Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 541 | } |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 542 | |
| 543 | |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 544 | //{"nAllocationDataFromObject", "(ILandroid/renderscript/Type;Ljava/lang/Object;)V", (void*)nAllocationDataFromObject }, |
| 545 | static void |
| 546 | nAllocationDataFromObject(JNIEnv *_env, jobject _this, jint alloc, jobject _type, jobject _o) |
| 547 | { |
| 548 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 549 | LOG_API("nAllocationDataFromObject con(%p), alloc(%p)", con, (RsAllocation)alloc); |
| 550 | |
| 551 | const TypeCache *tc = (TypeCache *)_env->GetIntField(_type, gTypeNativeCache); |
| 552 | |
| 553 | void * bufAlloc = malloc(tc->size); |
| 554 | void * buf = bufAlloc; |
| 555 | for (int ct=0; ct < tc->fieldCount; ct++) { |
| 556 | const TypeFieldCache *tfc = &tc->fields[ct]; |
| 557 | buf = tfc->ptr(_env, _o, tfc->field, buf); |
| 558 | } |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 559 | rsAllocationData(con, (RsAllocation)alloc, bufAlloc, tc->size); |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 560 | const uint32_t * tmp = (const uint32_t *)bufAlloc; |
| 561 | free(bufAlloc); |
| 562 | } |
| 563 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 564 | // ----------------------------------- |
| 565 | |
| 566 | static void |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 567 | nTriangleMeshBegin(JNIEnv *_env, jobject _this, jint v, jint i) |
| 568 | { |
| 569 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 570 | LOG_API("nTriangleMeshBegin, con(%p), vertex(%p), index(%p)", con, (RsElement)v, (RsElement)i); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 571 | rsTriangleMeshBegin(con, (RsElement)v, (RsElement)i); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | static void |
| 575 | nTriangleMeshAddVertex_XY(JNIEnv *_env, jobject _this, jfloat x, jfloat y) |
| 576 | { |
| 577 | float v[] = {x, y}; |
| 578 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 579 | LOG_API("nTriangleMeshAddVertex_XY, con(%p), x(%f), y(%f)", con, x, y); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 580 | rsTriangleMeshAddVertex(con, v); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | static void |
| 584 | nTriangleMeshAddVertex_XYZ(JNIEnv *_env, jobject _this, jfloat x, jfloat y, jfloat z) |
| 585 | { |
| 586 | float v[] = {x, y, z}; |
| 587 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 588 | LOG_API("nTriangleMeshAddVertex_XYZ, con(%p), x(%f), y(%f), z(%f)", con, x, y, z); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 589 | rsTriangleMeshAddVertex(con, v); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | static void |
| 593 | nTriangleMeshAddVertex_XY_ST(JNIEnv *_env, jobject _this, jfloat x, jfloat y, jfloat s, jfloat t) |
| 594 | { |
| 595 | float v[] = {s, t, x, y}; |
| 596 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 597 | LOG_API("nTriangleMeshAddVertex_XY_ST, con(%p), x(%f), y(%f), s(%f), t(%f)", con, x, y, s, t); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 598 | rsTriangleMeshAddVertex(con, v); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | static void |
| 602 | nTriangleMeshAddVertex_XYZ_ST(JNIEnv *_env, jobject _this, jfloat x, jfloat y, jfloat z, jfloat s, jfloat t) |
| 603 | { |
| 604 | float v[] = {s, t, x, y, z}; |
| 605 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 606 | LOG_API("nTriangleMeshAddVertex_XYZ_ST, con(%p), x(%f), y(%f), z(%f), s(%f), t(%f)", con, x, y, z, s, t); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 607 | rsTriangleMeshAddVertex(con, v); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | static void |
| Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 611 | nTriangleMeshAddVertex_XYZ_ST_NORM(JNIEnv *_env, jobject _this, jfloat x, jfloat y, jfloat z, jfloat s, jfloat t, jfloat nx, jfloat ny, jfloat nz) |
| 612 | { |
| 613 | float v[] = {nx, ny, nz, s, t, x, y, z}; |
| 614 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 615 | LOG_API("nTriangleMeshAddVertex_XYZ_ST, con(%p), x(%f), y(%f), z(%f), s(%f), t(%f)", con, x, y, z, s, t); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 616 | rsTriangleMeshAddVertex(con, v); |
| Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | static void |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 620 | nTriangleMeshAddTriangle(JNIEnv *_env, jobject _this, jint i1, jint i2, jint i3) |
| 621 | { |
| 622 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 623 | LOG_API("nTriangleMeshAddTriangle, con(%p), i1(%i), i2(%i), i3(%i)", con, i1, i2, i3); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 624 | rsTriangleMeshAddTriangle(con, i1, i2, i3); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | static jint |
| 628 | nTriangleMeshCreate(JNIEnv *_env, jobject _this) |
| 629 | { |
| 630 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 631 | LOG_API("nTriangleMeshCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 632 | return (jint) rsTriangleMeshCreate(con); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | // ----------------------------------- |
| 636 | |
| 637 | static void |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 638 | nAdapter1DBindAllocation(JNIEnv *_env, jobject _this, jint adapter, jint alloc) |
| 639 | { |
| 640 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 641 | LOG_API("nAdapter1DBindAllocation, con(%p), adapter(%p), alloc(%p)", con, (RsAdapter1D)adapter, (RsAllocation)alloc); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 642 | rsAdapter1DBindAllocation(con, (RsAdapter1D)adapter, (RsAllocation)alloc); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | static void |
| 646 | nAdapter1DSetConstraint(JNIEnv *_env, jobject _this, jint adapter, jint dim, jint value) |
| 647 | { |
| 648 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 649 | LOG_API("nAdapter1DSetConstraint, con(%p), adapter(%p), dim(%i), value(%i)", con, (RsAdapter1D)adapter, dim, value); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 650 | rsAdapter1DSetConstraint(con, (RsAdapter1D)adapter, (RsDimension)dim, value); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | static void |
| 654 | nAdapter1DData_i(JNIEnv *_env, jobject _this, jint adapter, jintArray data) |
| 655 | { |
| 656 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 657 | jint len = _env->GetArrayLength(data); |
| 658 | LOG_API("nAdapter1DData_i, con(%p), adapter(%p), len(%i)", con, (RsAdapter1D)adapter, len); |
| 659 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 660 | rsAdapter1DData(con, (RsAdapter1D)adapter, ptr); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 661 | _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 662 | } |
| 663 | |
| 664 | static void |
| 665 | nAdapter1DSubData_i(JNIEnv *_env, jobject _this, jint adapter, jint offset, jint count, jintArray data) |
| 666 | { |
| 667 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 668 | jint len = _env->GetArrayLength(data); |
| 669 | LOG_API("nAdapter1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAdapter1D)adapter, offset, count, len); |
| 670 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 671 | rsAdapter1DSubData(con, (RsAdapter1D)adapter, offset, count, ptr); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 672 | _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 673 | } |
| 674 | |
| 675 | static void |
| 676 | nAdapter1DData_f(JNIEnv *_env, jobject _this, jint adapter, jfloatArray data) |
| 677 | { |
| 678 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 679 | jint len = _env->GetArrayLength(data); |
| 680 | LOG_API("nAdapter1DData_f, con(%p), adapter(%p), len(%i)", con, (RsAdapter1D)adapter, len); |
| 681 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 682 | rsAdapter1DData(con, (RsAdapter1D)adapter, ptr); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 683 | _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 684 | } |
| 685 | |
| 686 | static void |
| 687 | nAdapter1DSubData_f(JNIEnv *_env, jobject _this, jint adapter, jint offset, jint count, jfloatArray data) |
| 688 | { |
| 689 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 690 | jint len = _env->GetArrayLength(data); |
| 691 | LOG_API("nAdapter1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAdapter1D)adapter, offset, count, len); |
| 692 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 693 | rsAdapter1DSubData(con, (RsAdapter1D)adapter, offset, count, ptr); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 694 | _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 695 | } |
| 696 | |
| 697 | static jint |
| 698 | nAdapter1DCreate(JNIEnv *_env, jobject _this) |
| 699 | { |
| 700 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 701 | LOG_API("nAdapter1DCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 702 | return (jint)rsAdapter1DCreate(con); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | // ----------------------------------- |
| 706 | |
| 707 | static void |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 708 | nAdapter2DBindAllocation(JNIEnv *_env, jobject _this, jint adapter, jint alloc) |
| 709 | { |
| 710 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 711 | LOG_API("nAdapter2DBindAllocation, con(%p), adapter(%p), alloc(%p)", con, (RsAdapter2D)adapter, (RsAllocation)alloc); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 712 | rsAdapter2DBindAllocation(con, (RsAdapter2D)adapter, (RsAllocation)alloc); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | static void |
| 716 | nAdapter2DSetConstraint(JNIEnv *_env, jobject _this, jint adapter, jint dim, jint value) |
| 717 | { |
| 718 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 719 | LOG_API("nAdapter2DSetConstraint, con(%p), adapter(%p), dim(%i), value(%i)", con, (RsAdapter2D)adapter, dim, value); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 720 | rsAdapter2DSetConstraint(con, (RsAdapter2D)adapter, (RsDimension)dim, value); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | static void |
| 724 | nAdapter2DData_i(JNIEnv *_env, jobject _this, jint adapter, jintArray data) |
| 725 | { |
| 726 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 727 | jint len = _env->GetArrayLength(data); |
| 728 | LOG_API("nAdapter2DData_i, con(%p), adapter(%p), len(%i)", con, (RsAdapter2D)adapter, len); |
| 729 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 730 | rsAdapter2DData(con, (RsAdapter2D)adapter, ptr); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 731 | _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 732 | } |
| 733 | |
| 734 | static void |
| 735 | nAdapter2DData_f(JNIEnv *_env, jobject _this, jint adapter, jfloatArray data) |
| 736 | { |
| 737 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 738 | jint len = _env->GetArrayLength(data); |
| 739 | LOG_API("nAdapter2DData_f, con(%p), adapter(%p), len(%i)", con, (RsAdapter2D)adapter, len); |
| 740 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 741 | rsAdapter2DData(con, (RsAdapter2D)adapter, ptr); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 742 | _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 743 | } |
| 744 | |
| 745 | static void |
| 746 | nAdapter2DSubData_i(JNIEnv *_env, jobject _this, jint adapter, jint xoff, jint yoff, jint w, jint h, jintArray data) |
| 747 | { |
| 748 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 749 | jint len = _env->GetArrayLength(data); |
| 750 | LOG_API("nAdapter2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", |
| 751 | con, (RsAdapter2D)adapter, xoff, yoff, w, h, len); |
| 752 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 753 | rsAdapter2DSubData(con, (RsAdapter2D)adapter, xoff, yoff, w, h, ptr); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 754 | _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 755 | } |
| 756 | |
| 757 | static void |
| 758 | nAdapter2DSubData_f(JNIEnv *_env, jobject _this, jint adapter, jint xoff, jint yoff, jint w, jint h, jfloatArray data) |
| 759 | { |
| 760 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 761 | jint len = _env->GetArrayLength(data); |
| 762 | LOG_API("nAdapter2DSubData_f, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", |
| 763 | con, (RsAdapter2D)adapter, xoff, yoff, w, h, len); |
| 764 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 765 | rsAdapter2DSubData(con, (RsAdapter1D)adapter, xoff, yoff, w, h, ptr); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 766 | _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 767 | } |
| 768 | |
| 769 | static jint |
| 770 | nAdapter2DCreate(JNIEnv *_env, jobject _this) |
| 771 | { |
| 772 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 773 | LOG_API("nAdapter2DCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 774 | return (jint)rsAdapter2DCreate(con); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | // ----------------------------------- |
| 778 | |
| 779 | static void |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 780 | nScriptBindAllocation(JNIEnv *_env, jobject _this, jint script, jint alloc, jint slot) |
| 781 | { |
| 782 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 783 | 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] | 784 | rsScriptBindAllocation(con, (RsScript)script, (RsAllocation)alloc, slot); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | static void |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 788 | nScriptSetClearColor(JNIEnv *_env, jobject _this, jint script, jfloat r, jfloat g, jfloat b, jfloat a) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 789 | { |
| 790 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 791 | LOG_API("nScriptSetClearColor, con(%p), s(%p), r(%f), g(%f), b(%f), a(%f)", con, (void *)script, r, g, b, a); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 792 | rsScriptSetClearColor(con, (RsScript)script, r, g, b, a); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | static void |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 796 | nScriptSetClearDepth(JNIEnv *_env, jobject _this, jint script, jfloat d) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 797 | { |
| 798 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 799 | LOG_API("nScriptCSetClearDepth, con(%p), s(%p), depth(%f)", con, (void *)script, d); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 800 | rsScriptSetClearDepth(con, (RsScript)script, d); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | static void |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 804 | nScriptSetClearStencil(JNIEnv *_env, jobject _this, jint script, jint stencil) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 805 | { |
| 806 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 807 | LOG_API("nScriptCSetClearStencil, con(%p), s(%p), stencil(%i)", con, (void *)script, stencil); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 808 | rsScriptSetClearStencil(con, (RsScript)script, stencil); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | static void |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 812 | nScriptSetTimeZone(JNIEnv *_env, jobject _this, jint script, jbyteArray timeZone) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 813 | { |
| 814 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 815 | 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] | 816 | |
| 817 | jint length = _env->GetArrayLength(timeZone); |
| 818 | jbyte* timeZone_ptr; |
| 819 | timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0); |
| 820 | |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 821 | rsScriptSetTimeZone(con, (RsScript)script, (const char *)timeZone_ptr, length); |
| Romain Guy | 584a375 | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 822 | |
| 823 | if (timeZone_ptr) { |
| 824 | _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0); |
| 825 | } |
| 826 | } |
| 827 | |
| Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 828 | static void |
| Jason Sams | 334ea0c | 2009-08-17 13:56:09 -0700 | [diff] [blame] | 829 | nScriptSetType(JNIEnv *_env, jobject _this, jint type, jboolean writable, jstring _str, jint slot) |
| Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 830 | { |
| 831 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 334ea0c | 2009-08-17 13:56:09 -0700 | [diff] [blame] | 832 | LOG_API("nScriptCAddType, con(%p), type(%p), writable(%i), slot(%i)", con, (RsType)type, writable, slot); |
| Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 833 | const char* n = NULL; |
| 834 | if (_str) { |
| 835 | n = _env->GetStringUTFChars(_str, NULL); |
| 836 | } |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 837 | rsScriptSetType(con, (RsType)type, slot, writable, n); |
| Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 838 | if (n) { |
| 839 | _env->ReleaseStringUTFChars(_str, n); |
| 840 | } |
| 841 | } |
| 842 | |
| 843 | static void |
| 844 | nScriptSetRoot(JNIEnv *_env, jobject _this, jboolean isRoot) |
| 845 | { |
| 846 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 847 | LOG_API("nScriptCSetRoot, con(%p), isRoot(%i)", con, isRoot); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 848 | rsScriptSetRoot(con, isRoot); |
| Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 849 | } |
| 850 | |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 851 | // ----------------------------------- |
| 852 | |
| 853 | static void |
| 854 | nScriptCBegin(JNIEnv *_env, jobject _this) |
| 855 | { |
| 856 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 857 | LOG_API("nScriptCBegin, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 858 | rsScriptCBegin(con); |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 859 | } |
| 860 | |
| Romain Guy | 584a375 | 2009-07-30 18:45:01 -0700 | [diff] [blame] | 861 | static void |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 862 | nScriptCSetScript(JNIEnv *_env, jobject _this, jbyteArray scriptRef, |
| 863 | jint offset, jint length) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 864 | { |
| 865 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 866 | LOG_API("!!! nScriptCSetScript, con(%p)", con); |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 867 | jint _exception = 0; |
| 868 | jint remaining; |
| 869 | jbyte* script_base = 0; |
| 870 | jbyte* script_ptr; |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 871 | if (!scriptRef) { |
| 872 | _exception = 1; |
| 873 | //_env->ThrowNew(IAEClass, "script == null"); |
| 874 | goto exit; |
| 875 | } |
| 876 | if (offset < 0) { |
| 877 | _exception = 1; |
| 878 | //_env->ThrowNew(IAEClass, "offset < 0"); |
| 879 | goto exit; |
| 880 | } |
| 881 | if (length < 0) { |
| 882 | _exception = 1; |
| 883 | //_env->ThrowNew(IAEClass, "length < 0"); |
| 884 | goto exit; |
| 885 | } |
| 886 | remaining = _env->GetArrayLength(scriptRef) - offset; |
| 887 | if (remaining < length) { |
| 888 | _exception = 1; |
| 889 | //_env->ThrowNew(IAEClass, "length > script.length - offset"); |
| 890 | goto exit; |
| 891 | } |
| 892 | script_base = (jbyte *) |
| 893 | _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0); |
| 894 | script_ptr = script_base + offset; |
| 895 | |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 896 | rsScriptCSetText(con, (const char *)script_ptr, length); |
| Jason Sams | 39ddc950 | 2009-06-05 17:35:09 -0700 | [diff] [blame] | 897 | |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 898 | exit: |
| 899 | if (script_base) { |
| 900 | _env->ReleasePrimitiveArrayCritical(scriptRef, script_base, |
| 901 | _exception ? JNI_ABORT: 0); |
| 902 | } |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | static jint |
| 906 | nScriptCCreate(JNIEnv *_env, jobject _this) |
| 907 | { |
| 908 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 909 | LOG_API("nScriptCCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 910 | return (jint)rsScriptCCreate(con); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 911 | } |
| 912 | |
| Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 913 | static void |
| 914 | nScriptCAddDefineI32(JNIEnv *_env, jobject _this, jstring name, jint value) |
| 915 | { |
| 916 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 917 | const char* n = _env->GetStringUTFChars(name, NULL); |
| 918 | LOG_API("nScriptCAddDefineI32, con(%p) name(%s) value(%d)", con, n, value); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 919 | rsScriptCSetDefineI32(con, n, value); |
| Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 920 | _env->ReleaseStringUTFChars(name, n); |
| 921 | } |
| 922 | |
| 923 | static void |
| 924 | nScriptCAddDefineF(JNIEnv *_env, jobject _this, jstring name, jfloat value) |
| 925 | { |
| 926 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 927 | const char* n = _env->GetStringUTFChars(name, NULL); |
| 928 | LOG_API("nScriptCAddDefineF, con(%p) name(%s) value(%f)", con, n, value); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 929 | rsScriptCSetDefineF(con, n, value); |
| Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 930 | _env->ReleaseStringUTFChars(name, n); |
| 931 | } |
| 932 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 933 | // --------------------------------------------------------------------------- |
| 934 | |
| 935 | static void |
| 936 | nProgramFragmentStoreBegin(JNIEnv *_env, jobject _this, jint in, jint out) |
| 937 | { |
| 938 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 939 | LOG_API("nProgramFragmentStoreBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 940 | rsProgramFragmentStoreBegin(con, (RsElement)in, (RsElement)out); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | static void |
| 944 | nProgramFragmentStoreDepthFunc(JNIEnv *_env, jobject _this, jint func) |
| 945 | { |
| 946 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 947 | LOG_API("nProgramFragmentStoreDepthFunc, con(%p), func(%i)", con, func); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 948 | rsProgramFragmentStoreDepthFunc(con, (RsDepthFunc)func); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | static void |
| 952 | nProgramFragmentStoreDepthMask(JNIEnv *_env, jobject _this, jboolean enable) |
| 953 | { |
| 954 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 955 | LOG_API("nProgramFragmentStoreDepthMask, con(%p), enable(%i)", con, enable); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 956 | rsProgramFragmentStoreDepthMask(con, enable); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | static void |
| 960 | nProgramFragmentStoreColorMask(JNIEnv *_env, jobject _this, jboolean r, jboolean g, jboolean b, jboolean a) |
| 961 | { |
| 962 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 963 | LOG_API("nProgramFragmentStoreColorMask, con(%p), r(%i), g(%i), b(%i), a(%i)", con, r, g, b, a); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 964 | rsProgramFragmentStoreColorMask(con, r, g, b, a); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 965 | } |
| 966 | |
| 967 | static void |
| 968 | nProgramFragmentStoreBlendFunc(JNIEnv *_env, jobject _this, int src, int dst) |
| 969 | { |
| 970 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 971 | LOG_API("nProgramFragmentStoreBlendFunc, con(%p), src(%i), dst(%i)", con, src, dst); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 972 | rsProgramFragmentStoreBlendFunc(con, (RsBlendSrcFunc)src, (RsBlendDstFunc)dst); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 973 | } |
| 974 | |
| 975 | static void |
| 976 | nProgramFragmentStoreDither(JNIEnv *_env, jobject _this, jboolean enable) |
| 977 | { |
| 978 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 979 | LOG_API("nProgramFragmentStoreDither, con(%p), enable(%i)", con, enable); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 980 | rsProgramFragmentStoreDither(con, enable); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | static jint |
| 984 | nProgramFragmentStoreCreate(JNIEnv *_env, jobject _this) |
| 985 | { |
| 986 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 987 | LOG_API("nProgramFragmentStoreCreate, con(%p)", con); |
| Jason Sams | 3eaa338e | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 988 | |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 989 | return (jint)rsProgramFragmentStoreCreate(con); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | // --------------------------------------------------------------------------- |
| 993 | |
| 994 | static void |
| Jason Sams | 25ffcdc | 2009-08-20 16:10:36 -0700 | [diff] [blame] | 995 | nProgramFragmentBegin(JNIEnv *_env, jobject _this, jint in, jint out, jboolean pointSpriteEnable) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 996 | { |
| 997 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 25ffcdc | 2009-08-20 16:10:36 -0700 | [diff] [blame] | 998 | LOG_API("nProgramFragmentBegin, con(%p), in(%p), out(%p) PointSprite(%i)", con, (RsElement)in, (RsElement)out, pointSpriteEnable); |
| 999 | rsProgramFragmentBegin(con, (RsElement)in, (RsElement)out, pointSpriteEnable); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
| 1002 | static void |
| 1003 | nProgramFragmentBindTexture(JNIEnv *_env, jobject _this, jint vpf, jint slot, jint a) |
| 1004 | { |
| 1005 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1006 | LOG_API("nProgramFragmentBindTexture, con(%p), vpf(%p), slot(%i), a(%p)", con, (RsProgramFragment)vpf, slot, (RsAllocation)a); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1007 | rsProgramFragmentBindTexture(con, (RsProgramFragment)vpf, slot, (RsAllocation)a); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | static void |
| 1011 | nProgramFragmentBindSampler(JNIEnv *_env, jobject _this, jint vpf, jint slot, jint a) |
| 1012 | { |
| 1013 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1014 | LOG_API("nProgramFragmentBindSampler, con(%p), vpf(%p), slot(%i), a(%p)", con, (RsProgramFragment)vpf, slot, (RsSampler)a); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1015 | rsProgramFragmentBindSampler(con, (RsProgramFragment)vpf, slot, (RsSampler)a); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1016 | } |
| 1017 | |
| 1018 | static void |
| Jason Sams | 25ffcdc | 2009-08-20 16:10:36 -0700 | [diff] [blame] | 1019 | nProgramFragmentSetSlot(JNIEnv *_env, jobject _this, jint slot, jboolean enable, jint env, jint vt) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1020 | { |
| 1021 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 25ffcdc | 2009-08-20 16:10:36 -0700 | [diff] [blame] | 1022 | LOG_API("nProgramFragmentSetType, con(%p), slot(%i), enable(%i), env(%i), vt(%p)", con, slot, enable, env, (RsType)vt); |
| 1023 | rsProgramFragmentSetSlot(con, slot, enable, (RsTexEnvMode)env, (RsType)vt); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | static jint |
| 1027 | nProgramFragmentCreate(JNIEnv *_env, jobject _this, jint slot, jboolean enable) |
| 1028 | { |
| 1029 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1030 | LOG_API("nProgramFragmentCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1031 | return (jint)rsProgramFragmentCreate(con); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1034 | // --------------------------------------------------------------------------- |
| 1035 | |
| 1036 | static void |
| 1037 | nProgramVertexBegin(JNIEnv *_env, jobject _this, jint in, jint out) |
| 1038 | { |
| 1039 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1040 | LOG_API("nProgramVertexBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1041 | rsProgramVertexBegin(con, (RsElement)in, (RsElement)out); |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | static void |
| Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 1045 | nProgramVertexBindAllocation(JNIEnv *_env, jobject _this, jint vpv, jint a) |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1046 | { |
| 1047 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 1048 | LOG_API("nProgramVertexBindAllocation, con(%p), vpf(%p), a(%p)", con, (RsProgramVertex)vpv, (RsAllocation)a); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1049 | rsProgramVertexBindAllocation(con, (RsProgramFragment)vpv, (RsAllocation)a); |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1050 | } |
| 1051 | |
| 1052 | static void |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1053 | nProgramVertexSetTextureMatrixEnable(JNIEnv *_env, jobject _this, jboolean enable) |
| 1054 | { |
| 1055 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1056 | LOG_API("nProgramVertexSetTextureMatrixEnable, con(%p), enable(%i)", con, enable); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1057 | rsProgramVertexSetTextureMatrixEnable(con, enable); |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1058 | } |
| 1059 | |
| Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 1060 | static void |
| 1061 | nProgramVertexAddLight(JNIEnv *_env, jobject _this, jint light) |
| 1062 | { |
| 1063 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1064 | LOG_API("nProgramVertexAddLight, con(%p), light(%p)", con, (RsLight)light); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1065 | rsProgramVertexAddLight(con, (RsLight)light); |
| Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 1066 | } |
| 1067 | |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1068 | static jint |
| 1069 | nProgramVertexCreate(JNIEnv *_env, jobject _this) |
| 1070 | { |
| 1071 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1072 | LOG_API("nProgramVertexCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1073 | return (jint)rsProgramVertexCreate(con); |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1074 | } |
| 1075 | |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1076 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1077 | |
| 1078 | // --------------------------------------------------------------------------- |
| 1079 | |
| 1080 | static void |
| 1081 | nContextBindRootScript(JNIEnv *_env, jobject _this, jint script) |
| 1082 | { |
| 1083 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1084 | LOG_API("nContextBindRootScript, con(%p), script(%p)", con, (RsScript)script); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1085 | rsContextBindRootScript(con, (RsScript)script); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | static void |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1089 | nContextBindProgramFragmentStore(JNIEnv *_env, jobject _this, jint pfs) |
| 1090 | { |
| 1091 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1092 | LOG_API("nContextBindProgramFragmentStore, con(%p), pfs(%p)", con, (RsProgramFragmentStore)pfs); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1093 | rsContextBindProgramFragmentStore(con, (RsProgramFragmentStore)pfs); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1094 | } |
| 1095 | |
| 1096 | static void |
| 1097 | nContextBindProgramFragment(JNIEnv *_env, jobject _this, jint pf) |
| 1098 | { |
| 1099 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1100 | LOG_API("nContextBindProgramFragment, con(%p), pf(%p)", con, (RsProgramFragment)pf); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1101 | rsContextBindProgramFragment(con, (RsProgramFragment)pf); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1102 | } |
| 1103 | |
| Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 1104 | static void |
| 1105 | nContextBindProgramVertex(JNIEnv *_env, jobject _this, jint pf) |
| 1106 | { |
| 1107 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1108 | LOG_API("nContextBindProgramVertex, con(%p), pf(%p)", con, (RsProgramVertex)pf); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1109 | rsContextBindProgramVertex(con, (RsProgramVertex)pf); |
| Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 1110 | } |
| 1111 | |
| Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 1112 | static void |
| 1113 | nContextAddDefineI32(JNIEnv *_env, jobject _this, jstring name, jint value) |
| 1114 | { |
| 1115 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1116 | const char* n = _env->GetStringUTFChars(name, NULL); |
| 1117 | LOG_API("nScriptCAddDefineI32, con(%p) name(%s) value(%d)", con, n, value); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1118 | rsContextSetDefineI32(con, n, value); |
| Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 1119 | _env->ReleaseStringUTFChars(name, n); |
| 1120 | } |
| 1121 | |
| 1122 | static void |
| 1123 | nContextAddDefineF(JNIEnv *_env, jobject _this, jstring name, jfloat value) |
| 1124 | { |
| 1125 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1126 | const char* n = _env->GetStringUTFChars(name, NULL); |
| 1127 | LOG_API("nScriptCAddDefineF, con(%p) name(%s) value(%f)", con, n, value); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1128 | rsContextSetDefineF(con, n, value); |
| Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 1129 | _env->ReleaseStringUTFChars(name, n); |
| 1130 | } |
| 1131 | |
| 1132 | |
| Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1133 | // --------------------------------------------------------------------------- |
| 1134 | |
| 1135 | static void |
| Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1136 | nSamplerBegin(JNIEnv *_env, jobject _this) |
| 1137 | { |
| 1138 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1139 | LOG_API("nSamplerBegin, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1140 | rsSamplerBegin(con); |
| Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | static void |
| 1144 | nSamplerSet(JNIEnv *_env, jobject _this, jint p, jint v) |
| 1145 | { |
| 1146 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1147 | LOG_API("nSamplerSet, con(%p), param(%i), value(%i)", con, p, v); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1148 | rsSamplerSet(con, (RsSamplerParam)p, (RsSamplerValue)v); |
| Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1149 | } |
| 1150 | |
| 1151 | static jint |
| 1152 | nSamplerCreate(JNIEnv *_env, jobject _this) |
| 1153 | { |
| 1154 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1155 | LOG_API("nSamplerCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1156 | return (jint)rsSamplerCreate(con); |
| Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1157 | } |
| 1158 | |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1159 | // --------------------------------------------------------------------------- |
| 1160 | |
| 1161 | static void |
| 1162 | nLightBegin(JNIEnv *_env, jobject _this) |
| 1163 | { |
| 1164 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1165 | LOG_API("nLightBegin, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1166 | rsLightBegin(con); |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1167 | } |
| 1168 | |
| 1169 | static void |
| 1170 | nLightSetIsMono(JNIEnv *_env, jobject _this, jboolean isMono) |
| 1171 | { |
| 1172 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1173 | LOG_API("nLightSetIsMono, con(%p), isMono(%i)", con, isMono); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1174 | rsLightSetMonochromatic(con, isMono); |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1175 | } |
| 1176 | |
| 1177 | static void |
| 1178 | nLightSetIsLocal(JNIEnv *_env, jobject _this, jboolean isLocal) |
| 1179 | { |
| 1180 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1181 | LOG_API("nLightSetIsLocal, con(%p), isLocal(%i)", con, isLocal); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1182 | rsLightSetLocal(con, isLocal); |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | static jint |
| 1186 | nLightCreate(JNIEnv *_env, jobject _this) |
| 1187 | { |
| 1188 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1189 | LOG_API("nLightCreate, con(%p)", con); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1190 | return (jint)rsLightCreate(con); |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1191 | } |
| 1192 | |
| 1193 | static void |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1194 | nLightSetColor(JNIEnv *_env, jobject _this, jint light, float r, float g, float b) |
| 1195 | { |
| 1196 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1197 | LOG_API("nLightSetColor, con(%p), light(%p), r(%f), g(%f), b(%f)", con, (RsLight)light, r, g, b); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1198 | rsLightSetColor(con, (RsLight)light, r, g, b); |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1199 | } |
| 1200 | |
| 1201 | static void |
| 1202 | nLightSetPosition(JNIEnv *_env, jobject _this, jint light, float x, float y, float z) |
| 1203 | { |
| 1204 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1205 | LOG_API("nLightSetPosition, con(%p), light(%p), x(%f), y(%f), z(%f)", con, (RsLight)light, x, y, z); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1206 | rsLightSetPosition(con, (RsLight)light, x, y, z); |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1207 | } |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1208 | |
| 1209 | // --------------------------------------------------------------------------- |
| 1210 | |
| Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 1211 | static jint |
| 1212 | nSimpleMeshCreate(JNIEnv *_env, jobject _this, jint batchID, jint indexID, jintArray vtxIDs, jint primID) |
| 1213 | { |
| 1214 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1215 | jint len = _env->GetArrayLength(vtxIDs); |
| 1216 | LOG_API("nSimpleMeshCreate, con(%p), batchID(%i), indexID(%i), vtxIDs.len(%i), primID(%i)", |
| 1217 | con, batchID, indexID, len, primID); |
| 1218 | jint *ptr = _env->GetIntArrayElements(vtxIDs, NULL); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1219 | int id = (int)rsSimpleMeshCreate(con, (void *)batchID, (void *)indexID, (void **)ptr, len, primID); |
| Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 1220 | _env->ReleaseIntArrayElements(vtxIDs, ptr, 0/*JNI_ABORT*/); |
| 1221 | return id; |
| 1222 | } |
| 1223 | |
| 1224 | static void |
| 1225 | nSimpleMeshBindVertex(JNIEnv *_env, jobject _this, jint s, jint alloc, jint slot) |
| 1226 | { |
| 1227 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1228 | LOG_API("nSimpleMeshBindVertex, con(%p), SimpleMesh(%p), Alloc(%p), slot(%i)", con, (RsSimpleMesh)s, (RsAllocation)alloc, slot); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1229 | rsSimpleMeshBindVertex(con, (RsSimpleMesh)s, (RsAllocation)alloc, slot); |
| Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | static void |
| 1233 | nSimpleMeshBindIndex(JNIEnv *_env, jobject _this, jint s, jint alloc) |
| 1234 | { |
| 1235 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 1236 | LOG_API("nSimpleMeshBindIndex, con(%p), SimpleMesh(%p), Alloc(%p)", con, (RsSimpleMesh)s, (RsAllocation)alloc); |
| Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 1237 | rsSimpleMeshBindIndex(con, (RsSimpleMesh)s, (RsAllocation)alloc); |
| Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 1238 | } |
| 1239 | |
| 1240 | // --------------------------------------------------------------------------- |
| 1241 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1242 | |
| Jason Sams | 94d8e90a | 2009-06-10 16:09:05 -0700 | [diff] [blame] | 1243 | static const char *classPathName = "android/renderscript/RenderScript"; |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1244 | |
| 1245 | static JNINativeMethod methods[] = { |
| 1246 | {"_nInit", "()V", (void*)_nInit }, |
| 1247 | {"nDeviceCreate", "()I", (void*)nDeviceCreate }, |
| 1248 | {"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, |
| Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 1249 | {"nContextCreate", "(ILandroid/view/Surface;IZ)I", (void*)nContextCreate }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1250 | {"nContextDestroy", "(I)V", (void*)nContextDestroy }, |
| Jason Sams | 3eaa338e | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 1251 | {"nAssignName", "(I[B)V", (void*)nAssignName }, |
| Jason Sams | 7ce033d | 2009-08-18 14:14:24 -0700 | [diff] [blame] | 1252 | {"nObjDestroy", "(I)V", (void*)nObjDestroy }, |
| Jason Sams | 730ee65 | 2009-08-18 17:07:09 -0700 | [diff] [blame] | 1253 | {"nObjDestroyOOB", "(I)V", (void*)nObjDestroyOOB }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1254 | |
| Jason Sams | 64676f3 | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 1255 | {"nFileOpen", "([B)I", (void*)nFileOpen }, |
| 1256 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1257 | {"nElementBegin", "()V", (void*)nElementBegin }, |
| 1258 | {"nElementAddPredefined", "(I)V", (void*)nElementAddPredefined }, |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 1259 | {"nElementAdd", "(IIIILjava/lang/String;)V", (void*)nElementAdd }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1260 | {"nElementCreate", "()I", (void*)nElementCreate }, |
| 1261 | {"nElementGetPredefined", "(I)I", (void*)nElementGetPredefined }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1262 | |
| 1263 | {"nTypeBegin", "(I)V", (void*)nTypeBegin }, |
| 1264 | {"nTypeAdd", "(II)V", (void*)nTypeAdd }, |
| 1265 | {"nTypeCreate", "()I", (void*)nTypeCreate }, |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 1266 | {"nTypeFinalDestroy", "(Landroid/renderscript/Type;)V", (void*)nTypeFinalDestroy }, |
| 1267 | {"nTypeSetupFields", "(Landroid/renderscript/Type;[I[I[Ljava/lang/reflect/Field;)V", (void*)nTypeSetupFields }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1268 | |
| 1269 | {"nAllocationCreateTyped", "(I)I", (void*)nAllocationCreateTyped }, |
| 1270 | {"nAllocationCreatePredefSized", "(II)I", (void*)nAllocationCreatePredefSized }, |
| 1271 | {"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized }, |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame] | 1272 | {"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap }, |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 1273 | {"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed }, |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 1274 | {"nAllocationCreateFromAssetStream","(IZI)I", (void*)nAllocationCreateFromAssetStream }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1275 | {"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture }, |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 1276 | {"nAllocationUploadToBufferObject","(I)V", (void*)nAllocationUploadToBufferObject }, |
| 1277 | {"nAllocationData", "(I[II)V", (void*)nAllocationData_i }, |
| 1278 | {"nAllocationData", "(I[FI)V", (void*)nAllocationData_f }, |
| 1279 | {"nAllocationSubData1D", "(III[II)V", (void*)nAllocationSubData1D_i }, |
| 1280 | {"nAllocationSubData1D", "(III[FI)V", (void*)nAllocationSubData1D_f }, |
| 1281 | {"nAllocationSubData2D", "(IIIII[II)V", (void*)nAllocationSubData2D_i }, |
| 1282 | {"nAllocationSubData2D", "(IIIII[FI)V", (void*)nAllocationSubData2D_f }, |
| Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 1283 | {"nAllocationRead", "(I[I)V", (void*)nAllocationRead_i }, |
| 1284 | {"nAllocationRead", "(I[F)V", (void*)nAllocationRead_f }, |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 1285 | {"nAllocationDataFromObject", "(ILandroid/renderscript/Type;Ljava/lang/Object;)V", (void*)nAllocationDataFromObject }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1286 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1287 | {"nTriangleMeshBegin", "(II)V", (void*)nTriangleMeshBegin }, |
| 1288 | {"nTriangleMeshAddVertex_XY", "(FF)V", (void*)nTriangleMeshAddVertex_XY }, |
| 1289 | {"nTriangleMeshAddVertex_XYZ", "(FFF)V", (void*)nTriangleMeshAddVertex_XYZ }, |
| 1290 | {"nTriangleMeshAddVertex_XY_ST", "(FFFF)V", (void*)nTriangleMeshAddVertex_XY_ST }, |
| 1291 | {"nTriangleMeshAddVertex_XYZ_ST", "(FFFFF)V", (void*)nTriangleMeshAddVertex_XYZ_ST }, |
| Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 1292 | {"nTriangleMeshAddVertex_XYZ_ST_NORM", "(FFFFFFFF)V", (void*)nTriangleMeshAddVertex_XYZ_ST_NORM }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1293 | {"nTriangleMeshAddTriangle", "(III)V", (void*)nTriangleMeshAddTriangle }, |
| 1294 | {"nTriangleMeshCreate", "()I", (void*)nTriangleMeshCreate }, |
| 1295 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1296 | {"nAdapter1DBindAllocation", "(II)V", (void*)nAdapter1DBindAllocation }, |
| 1297 | {"nAdapter1DSetConstraint", "(III)V", (void*)nAdapter1DSetConstraint }, |
| 1298 | {"nAdapter1DData", "(I[I)V", (void*)nAdapter1DData_i }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1299 | {"nAdapter1DData", "(I[F)V", (void*)nAdapter1DData_f }, |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 1300 | {"nAdapter1DSubData", "(III[I)V", (void*)nAdapter1DSubData_i }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1301 | {"nAdapter1DSubData", "(III[F)V", (void*)nAdapter1DSubData_f }, |
| 1302 | {"nAdapter1DCreate", "()I", (void*)nAdapter1DCreate }, |
| 1303 | |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 1304 | {"nAdapter2DBindAllocation", "(II)V", (void*)nAdapter2DBindAllocation }, |
| 1305 | {"nAdapter2DSetConstraint", "(III)V", (void*)nAdapter2DSetConstraint }, |
| 1306 | {"nAdapter2DData", "(I[I)V", (void*)nAdapter2DData_i }, |
| 1307 | {"nAdapter2DData", "(I[F)V", (void*)nAdapter2DData_f }, |
| 1308 | {"nAdapter2DSubData", "(IIIII[I)V", (void*)nAdapter2DSubData_i }, |
| 1309 | {"nAdapter2DSubData", "(IIIII[F)V", (void*)nAdapter2DSubData_f }, |
| 1310 | {"nAdapter2DCreate", "()I", (void*)nAdapter2DCreate }, |
| 1311 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1312 | {"nScriptBindAllocation", "(III)V", (void*)nScriptBindAllocation }, |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1313 | {"nScriptSetClearColor", "(IFFFF)V", (void*)nScriptSetClearColor }, |
| 1314 | {"nScriptSetClearDepth", "(IF)V", (void*)nScriptSetClearDepth }, |
| 1315 | {"nScriptSetClearStencil", "(II)V", (void*)nScriptSetClearStencil }, |
| 1316 | {"nScriptSetTimeZone", "(I[B)V", (void*)nScriptSetTimeZone }, |
| Jason Sams | 334ea0c | 2009-08-17 13:56:09 -0700 | [diff] [blame] | 1317 | {"nScriptSetType", "(IZLjava/lang/String;I)V", (void*)nScriptSetType }, |
| Jason Sams | fbf0b9e | 2009-08-13 12:59:04 -0700 | [diff] [blame] | 1318 | {"nScriptSetRoot", "(Z)V", (void*)nScriptSetRoot }, |
| Jason Sams | 2253417 | 2009-08-04 16:58:20 -0700 | [diff] [blame] | 1319 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1320 | {"nScriptCBegin", "()V", (void*)nScriptCBegin }, |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 1321 | {"nScriptCSetScript", "([BII)V", (void*)nScriptCSetScript }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1322 | {"nScriptCCreate", "()I", (void*)nScriptCCreate }, |
| Joe Onorato | d7b3774 | 2009-08-09 22:57:44 -0700 | [diff] [blame] | 1323 | {"nScriptCAddDefineI32", "(Ljava/lang/String;I)V", (void*)nScriptCAddDefineI32 }, |
| 1324 | {"nScriptCAddDefineF", "(Ljava/lang/String;F)V", (void*)nScriptCAddDefineF }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1325 | |
| 1326 | {"nProgramFragmentStoreBegin", "(II)V", (void*)nProgramFragmentStoreBegin }, |
| 1327 | {"nProgramFragmentStoreDepthFunc", "(I)V", (void*)nProgramFragmentStoreDepthFunc }, |
| 1328 | {"nProgramFragmentStoreDepthMask", "(Z)V", (void*)nProgramFragmentStoreDepthMask }, |
| 1329 | {"nProgramFragmentStoreColorMask", "(ZZZZ)V", (void*)nProgramFragmentStoreColorMask }, |
| 1330 | {"nProgramFragmentStoreBlendFunc", "(II)V", (void*)nProgramFragmentStoreBlendFunc }, |
| 1331 | {"nProgramFragmentStoreDither", "(Z)V", (void*)nProgramFragmentStoreDither }, |
| 1332 | {"nProgramFragmentStoreCreate", "()I", (void*)nProgramFragmentStoreCreate }, |
| 1333 | |
| Jason Sams | 25ffcdc | 2009-08-20 16:10:36 -0700 | [diff] [blame] | 1334 | {"nProgramFragmentBegin", "(IIZ)V", (void*)nProgramFragmentBegin }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1335 | {"nProgramFragmentBindTexture", "(III)V", (void*)nProgramFragmentBindTexture }, |
| 1336 | {"nProgramFragmentBindSampler", "(III)V", (void*)nProgramFragmentBindSampler }, |
| Jason Sams | 25ffcdc | 2009-08-20 16:10:36 -0700 | [diff] [blame] | 1337 | {"nProgramFragmentSetSlot", "(IZII)V", (void*)nProgramFragmentSetSlot }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1338 | {"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate }, |
| 1339 | |
| Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 1340 | {"nProgramVertexBindAllocation", "(II)V", (void*)nProgramVertexBindAllocation }, |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1341 | {"nProgramVertexBegin", "(II)V", (void*)nProgramVertexBegin }, |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1342 | {"nProgramVertexSetTextureMatrixEnable", "(Z)V", (void*)nProgramVertexSetTextureMatrixEnable }, |
| Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 1343 | {"nProgramVertexAddLight", "(I)V", (void*)nProgramVertexAddLight }, |
| Jason Sams | 1fe9b8c | 2009-06-11 14:46:10 -0700 | [diff] [blame] | 1344 | {"nProgramVertexCreate", "()I", (void*)nProgramVertexCreate }, |
| 1345 | |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1346 | {"nLightBegin", "()V", (void*)nLightBegin }, |
| 1347 | {"nLightSetIsMono", "(Z)V", (void*)nLightSetIsMono }, |
| 1348 | {"nLightSetIsLocal", "(Z)V", (void*)nLightSetIsLocal }, |
| 1349 | {"nLightCreate", "()I", (void*)nLightCreate }, |
| Jason Sams | bba134c | 2009-06-22 15:49:21 -0700 | [diff] [blame] | 1350 | {"nLightSetColor", "(IFFF)V", (void*)nLightSetColor }, |
| 1351 | {"nLightSetPosition", "(IFFF)V", (void*)nLightSetPosition }, |
| 1352 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1353 | {"nContextBindRootScript", "(I)V", (void*)nContextBindRootScript }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1354 | {"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore }, |
| 1355 | {"nContextBindProgramFragment", "(I)V", (void*)nContextBindProgramFragment }, |
| Jason Sams | 0826a6f | 2009-06-15 19:04:56 -0700 | [diff] [blame] | 1356 | {"nContextBindProgramVertex", "(I)V", (void*)nContextBindProgramVertex }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1357 | |
| Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 1358 | {"nSamplerBegin", "()V", (void*)nSamplerBegin }, |
| 1359 | {"nSamplerSet", "(II)V", (void*)nSamplerSet }, |
| 1360 | {"nSamplerCreate", "()I", (void*)nSamplerCreate }, |
| 1361 | |
| Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 1362 | {"nSimpleMeshCreate", "(II[II)I", (void*)nSimpleMeshCreate }, |
| 1363 | {"nSimpleMeshBindVertex", "(III)V", (void*)nSimpleMeshBindVertex }, |
| 1364 | {"nSimpleMeshBindIndex", "(II)V", (void*)nSimpleMeshBindIndex }, |
| 1365 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1366 | }; |
| 1367 | |
| 1368 | static int registerFuncs(JNIEnv *_env) |
| 1369 | { |
| 1370 | return android::AndroidRuntime::registerNativeMethods( |
| 1371 | _env, classPathName, methods, NELEM(methods)); |
| 1372 | } |
| 1373 | |
| 1374 | // --------------------------------------------------------------------------- |
| 1375 | |
| 1376 | jint JNI_OnLoad(JavaVM* vm, void* reserved) |
| 1377 | { |
| 1378 | JNIEnv* env = NULL; |
| 1379 | jint result = -1; |
| 1380 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1381 | if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { |
| 1382 | LOGE("ERROR: GetEnv failed\n"); |
| 1383 | goto bail; |
| 1384 | } |
| 1385 | assert(env != NULL); |
| 1386 | |
| 1387 | if (registerFuncs(env) < 0) { |
| 1388 | LOGE("ERROR: MediaPlayer native registration failed\n"); |
| 1389 | goto bail; |
| 1390 | } |
| 1391 | |
| 1392 | /* success -- return valid version number */ |
| 1393 | result = JNI_VERSION_1_4; |
| 1394 | |
| 1395 | bail: |
| 1396 | return result; |
| 1397 | } |