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