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