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