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