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