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