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