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