| 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 | |
| 17 | #include <stdlib.h> |
| 18 | #include <stdio.h> |
| 19 | #include <fcntl.h> |
| 20 | #include <unistd.h> |
| 21 | #include <math.h> |
| 22 | |
| 23 | #include <utils/misc.h> |
| 24 | #include <utils/Log.h> |
| 25 | |
| 26 | #include <ui/EGLNativeWindowSurface.h> |
| 27 | #include <ui/Surface.h> |
| 28 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame^] | 29 | #include <core/SkBitmap.h> |
| 30 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 31 | #include "jni.h" |
| 32 | #include "JNIHelp.h" |
| 33 | #include "android_runtime/AndroidRuntime.h" |
| 34 | |
| 35 | #include "../RenderScript.h" |
| 36 | #include "../RenderScriptEnv.h" |
| 37 | |
| Jack Palevich | 55d4522 | 2009-05-26 18:58:04 -0700 | [diff] [blame] | 38 | #include "acc/acc.h" |
| Jack Palevich | 55d4522 | 2009-05-26 18:58:04 -0700 | [diff] [blame] | 39 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 40 | //#define LOG_API LOGE |
| 41 | #define LOG_API(...) |
| 42 | |
| 43 | using namespace android; |
| 44 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 45 | // --------------------------------------------------------------------------- |
| 46 | |
| 47 | static void doThrow(JNIEnv* env, const char* exc, const char* msg = NULL) |
| 48 | { |
| 49 | jclass npeClazz = env->FindClass(exc); |
| 50 | env->ThrowNew(npeClazz, msg); |
| 51 | } |
| 52 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame^] | 53 | static jfieldID gContextId = 0; |
| 54 | static jfieldID gNativeBitmapID = 0; |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 55 | |
| 56 | static void _nInit(JNIEnv *_env, jclass _this) |
| 57 | { |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 58 | gContextId = _env->GetFieldID(_this, "mContext", "I"); |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame^] | 59 | |
| 60 | jclass bitmapClass = _env->FindClass("android/graphics/Bitmap"); |
| 61 | gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "I"); |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | |
| 65 | // --------------------------------------------------------------------------- |
| 66 | |
| 67 | static jint |
| 68 | nDeviceCreate(JNIEnv *_env, jobject _this) |
| 69 | { |
| 70 | LOG_API("nDeviceCreate"); |
| 71 | return (jint)rsDeviceCreate(); |
| 72 | } |
| 73 | |
| 74 | static void |
| 75 | nDeviceDestroy(JNIEnv *_env, jobject _this, jint dev) |
| 76 | { |
| 77 | LOG_API("nDeviceDestroy"); |
| 78 | return rsDeviceDestroy((RsDevice)dev); |
| 79 | } |
| 80 | |
| 81 | static jint |
| 82 | nContextCreate(JNIEnv *_env, jobject _this, jint dev, jobject wnd, jint ver) |
| 83 | { |
| 84 | LOG_API("nContextCreate"); |
| 85 | |
| 86 | if (wnd == NULL) { |
| 87 | not_valid_surface: |
| 88 | doThrow(_env, "java/lang/IllegalArgumentException", |
| 89 | "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"); |
| 90 | return 0; |
| 91 | } |
| 92 | jclass surface_class = _env->FindClass("android/view/Surface"); |
| 93 | jfieldID surfaceFieldID = _env->GetFieldID(surface_class, "mSurface", "I"); |
| 94 | Surface * window = (Surface*)_env->GetIntField(wnd, surfaceFieldID); |
| 95 | if (window == NULL) |
| 96 | goto not_valid_surface; |
| 97 | |
| 98 | LOGE("nContextCreate 5"); |
| 99 | return (jint)rsContextCreate((RsDevice)dev, window, ver); |
| 100 | } |
| 101 | |
| 102 | static void |
| 103 | nContextDestroy(JNIEnv *_env, jobject _this, jint con) |
| 104 | { |
| 105 | LOG_API("nContextDestroy, con(%p)", (RsContext)con); |
| 106 | return rsContextDestroy((RsContext)con); |
| 107 | } |
| 108 | |
| 109 | |
| 110 | static void |
| 111 | nElementBegin(JNIEnv *_env, jobject _this) |
| 112 | { |
| 113 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 114 | LOG_API("nElementBegin, con(%p)", con); |
| 115 | rsElementBegin(); |
| 116 | } |
| 117 | |
| 118 | static void |
| 119 | nElementAddPredefined(JNIEnv *_env, jobject _this, jint predef) |
| 120 | { |
| 121 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 122 | LOG_API("nElementAddPredefined, con(%p), predef(%i)", con, predef); |
| 123 | rsElementAddPredefined((RsElementPredefined)predef); |
| 124 | } |
| 125 | |
| 126 | static void |
| 127 | nElementAdd(JNIEnv *_env, jobject _this, jint kind, jint type, jint norm, jint bits) |
| 128 | { |
| 129 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 130 | LOG_API("nElementAdd, con(%p), kind(%i), type(%i), norm(%i), bits(%i)", con, kind, type, norm, bits); |
| 131 | rsElementAdd((RsDataKind)kind, (RsDataType)type, norm != 0, (size_t)bits); |
| 132 | } |
| 133 | |
| 134 | static jint |
| 135 | nElementCreate(JNIEnv *_env, jobject _this) |
| 136 | { |
| 137 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 138 | LOG_API("nElementCreate, con(%p)", con); |
| 139 | return (jint)rsElementCreate(); |
| 140 | } |
| 141 | |
| 142 | static jint |
| 143 | nElementGetPredefined(JNIEnv *_env, jobject _this, jint predef) |
| 144 | { |
| 145 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 146 | LOG_API("nElementGetPredefined, con(%p) predef(%i)", con, predef); |
| 147 | return (jint)rsElementGetPredefined((RsElementPredefined)predef); |
| 148 | } |
| 149 | |
| 150 | static void |
| 151 | nElementDestroy(JNIEnv *_env, jobject _this, jint e) |
| 152 | { |
| 153 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 154 | LOG_API("nElementDestroy, con(%p) e(%p)", con, (RsElement)e); |
| 155 | rsElementDestroy((RsElement)e); |
| 156 | } |
| 157 | |
| 158 | // ----------------------------------- |
| 159 | |
| 160 | static void |
| 161 | nTypeBegin(JNIEnv *_env, jobject _this, jint eID) |
| 162 | { |
| 163 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 164 | LOG_API("nTypeBegin, con(%p) e(%p)", con, (RsElement)eID); |
| 165 | rsTypeBegin((RsElement)eID); |
| 166 | } |
| 167 | |
| 168 | static void |
| 169 | nTypeAdd(JNIEnv *_env, jobject _this, jint dim, jint val) |
| 170 | { |
| 171 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 172 | LOG_API("nTypeAdd, con(%p) dim(%i), val(%i)", con, dim, val); |
| 173 | rsTypeAdd((RsDimension)dim, val); |
| 174 | } |
| 175 | |
| 176 | static jint |
| 177 | nTypeCreate(JNIEnv *_env, jobject _this) |
| 178 | { |
| 179 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 180 | LOG_API("nTypeCreate, con(%p)", con); |
| 181 | return (jint)rsTypeCreate(); |
| 182 | } |
| 183 | |
| 184 | static void |
| 185 | nTypeDestroy(JNIEnv *_env, jobject _this, jint eID) |
| 186 | { |
| 187 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 188 | LOG_API("nTypeDestroy, con(%p), t(%p)", con, (RsType)eID); |
| 189 | rsTypeDestroy((RsType)eID); |
| 190 | } |
| 191 | |
| 192 | // ----------------------------------- |
| 193 | |
| 194 | static jint |
| 195 | nAllocationCreateTyped(JNIEnv *_env, jobject _this, jint e) |
| 196 | { |
| 197 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 198 | LOG_API("nAllocationCreateTyped, con(%p), e(%p)", con, (RsElement)e); |
| 199 | return (jint) rsAllocationCreateTyped((RsElement)e); |
| 200 | } |
| 201 | |
| 202 | static jint |
| 203 | nAllocationCreatePredefSized(JNIEnv *_env, jobject _this, jint predef, jint count) |
| 204 | { |
| 205 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 206 | LOG_API("nAllocationCreatePredefSized, con(%p), predef(%i), count(%i)", con, predef, count); |
| 207 | return (jint) rsAllocationCreatePredefSized((RsElementPredefined)predef, count); |
| 208 | } |
| 209 | |
| 210 | static jint |
| 211 | nAllocationCreateSized(JNIEnv *_env, jobject _this, jint e, jint count) |
| 212 | { |
| 213 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 214 | LOG_API("nAllocationCreateSized, con(%p), e(%p), count(%i)", con, (RsElement)e, count); |
| 215 | return (jint) rsAllocationCreateSized((RsElement)e, count); |
| 216 | } |
| 217 | |
| 218 | static void |
| 219 | nAllocationUploadToTexture(JNIEnv *_env, jobject _this, jint a, jint mip) |
| 220 | { |
| 221 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 222 | LOG_API("nAllocationUploadToTexture, con(%p), a(%p), mip(%i)", con, (RsAllocation)a, mip); |
| 223 | rsAllocationUploadToTexture((RsAllocation)a, mip); |
| 224 | } |
| 225 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame^] | 226 | static RsElementPredefined SkBitmapToPredefined(SkBitmap::Config cfg) |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 227 | { |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame^] | 228 | switch (cfg) { |
| 229 | case SkBitmap::kA8_Config: |
| 230 | return RS_ELEMENT_A_8; |
| 231 | case SkBitmap::kARGB_4444_Config: |
| 232 | return RS_ELEMENT_RGBA_4444; |
| 233 | case SkBitmap::kARGB_8888_Config: |
| 234 | return RS_ELEMENT_RGBA_8888; |
| 235 | case SkBitmap::kRGB_565_Config: |
| 236 | return RS_ELEMENT_RGB_565; |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 237 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame^] | 238 | default: |
| 239 | break; |
| 240 | } |
| 241 | // If we don't have a conversion mark it as a user type. |
| 242 | LOGE("Unsupported bitmap type"); |
| 243 | return RS_ELEMENT_USER_U8; |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame^] | 246 | static int |
| 247 | nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jobject jbitmap) |
| 248 | { |
| 249 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 250 | SkBitmap const * nativeBitmap = |
| 251 | (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); |
| 252 | const SkBitmap& bitmap(*nativeBitmap); |
| 253 | SkBitmap::Config config = bitmap.getConfig(); |
| 254 | |
| 255 | RsElementPredefined e = SkBitmapToPredefined(config); |
| 256 | |
| 257 | if (e != RS_ELEMENT_USER_U8) { |
| 258 | bitmap.lockPixels(); |
| 259 | const int w = bitmap.width(); |
| 260 | const int h = bitmap.height(); |
| 261 | const void* ptr = bitmap.getPixels(); |
| 262 | jint id = (jint)rsAllocationCreateFromBitmap(w, h, (RsElementPredefined)dstFmt, e, genMips, ptr); |
| 263 | bitmap.unlockPixels(); |
| 264 | return id; |
| 265 | } |
| 266 | return 0; |
| 267 | } |
| Jason Sams | fe08d99 | 2009-05-27 14:45:32 -0700 | [diff] [blame] | 268 | |
| 269 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 270 | static void |
| 271 | nAllocationDestroy(JNIEnv *_env, jobject _this, jint a) |
| 272 | { |
| 273 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 274 | LOG_API("nAllocationDestroy, con(%p), a(%p)", con, (RsAllocation)a); |
| 275 | rsAllocationDestroy((RsAllocation)a); |
| 276 | } |
| 277 | |
| 278 | static void |
| 279 | nAllocationData_i(JNIEnv *_env, jobject _this, jint alloc, jintArray data) |
| 280 | { |
| 281 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 282 | jint len = _env->GetArrayLength(data); |
| 283 | LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); |
| 284 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| 285 | rsAllocationData((RsAllocation)alloc, ptr); |
| 286 | _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); |
| 287 | } |
| 288 | |
| 289 | static void |
| 290 | nAllocationData_f(JNIEnv *_env, jobject _this, jint alloc, jfloatArray data) |
| 291 | { |
| 292 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 293 | jint len = _env->GetArrayLength(data); |
| 294 | LOG_API("nAllocationData_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); |
| 295 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| 296 | rsAllocationData((RsAllocation)alloc, ptr); |
| 297 | _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); |
| 298 | } |
| 299 | |
| 300 | static void |
| 301 | nAllocationSubData1D_i(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jintArray data) |
| 302 | { |
| 303 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 304 | jint len = _env->GetArrayLength(data); |
| 305 | LOG_API("nAllocation1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len); |
| 306 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| 307 | rsAllocation1DSubData((RsAllocation)alloc, offset, count, ptr); |
| 308 | _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); |
| 309 | } |
| 310 | |
| 311 | static void |
| 312 | nAllocationSubData1D_f(JNIEnv *_env, jobject _this, jint alloc, jint offset, jint count, jfloatArray data) |
| 313 | { |
| 314 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 315 | jint len = _env->GetArrayLength(data); |
| 316 | LOG_API("nAllocation1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAllocation)alloc, offset, count, len); |
| 317 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| 318 | rsAllocation1DSubData((RsAllocation)alloc, offset, count, ptr); |
| 319 | _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); |
| 320 | } |
| 321 | |
| 322 | static void |
| 323 | nAllocationSubData2D_i(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jintArray data) |
| 324 | { |
| 325 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 326 | jint len = _env->GetArrayLength(data); |
| 327 | LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len); |
| 328 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| 329 | rsAllocation2DSubData((RsAllocation)alloc, xoff, yoff, w, h, ptr); |
| 330 | _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); |
| 331 | } |
| 332 | |
| 333 | static void |
| 334 | nAllocationSubData2D_f(JNIEnv *_env, jobject _this, jint alloc, jint xoff, jint yoff, jint w, jint h, jfloatArray data) |
| 335 | { |
| 336 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 337 | jint len = _env->GetArrayLength(data); |
| 338 | LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len); |
| 339 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| 340 | rsAllocation2DSubData((RsAllocation)alloc, xoff, yoff, w, h, ptr); |
| 341 | _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); |
| 342 | } |
| 343 | |
| 344 | |
| 345 | |
| 346 | // ----------------------------------- |
| 347 | |
| 348 | static void |
| 349 | nTriangleMeshDestroy(JNIEnv *_env, jobject _this, jint tm) |
| 350 | { |
| 351 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 352 | LOG_API("nTriangleMeshDestroy, con(%p), tm(%p)", con, (RsAllocation)tm); |
| 353 | rsTriangleMeshDestroy((RsTriangleMesh)tm); |
| 354 | } |
| 355 | |
| 356 | static void |
| 357 | nTriangleMeshBegin(JNIEnv *_env, jobject _this, jint v, jint i) |
| 358 | { |
| 359 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 360 | LOG_API("nTriangleMeshBegin, con(%p), vertex(%p), index(%p)", con, (RsElement)v, (RsElement)i); |
| 361 | rsTriangleMeshBegin((RsElement)v, (RsElement)i); |
| 362 | } |
| 363 | |
| 364 | static void |
| 365 | nTriangleMeshAddVertex_XY(JNIEnv *_env, jobject _this, jfloat x, jfloat y) |
| 366 | { |
| 367 | float v[] = {x, y}; |
| 368 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 369 | LOG_API("nTriangleMeshAddVertex_XY, con(%p), x(%f), y(%f)", con, x, y); |
| 370 | rsTriangleMeshAddVertex(v); |
| 371 | } |
| 372 | |
| 373 | static void |
| 374 | nTriangleMeshAddVertex_XYZ(JNIEnv *_env, jobject _this, jfloat x, jfloat y, jfloat z) |
| 375 | { |
| 376 | float v[] = {x, y, z}; |
| 377 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 378 | LOG_API("nTriangleMeshAddVertex_XYZ, con(%p), x(%f), y(%f), z(%f)", con, x, y, z); |
| 379 | rsTriangleMeshAddVertex(v); |
| 380 | } |
| 381 | |
| 382 | static void |
| 383 | nTriangleMeshAddVertex_XY_ST(JNIEnv *_env, jobject _this, jfloat x, jfloat y, jfloat s, jfloat t) |
| 384 | { |
| 385 | float v[] = {s, t, x, y}; |
| 386 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 387 | LOG_API("nTriangleMeshAddVertex_XY_ST, con(%p), x(%f), y(%f), s(%f), t(%f)", con, x, y, s, t); |
| 388 | rsTriangleMeshAddVertex(v); |
| 389 | } |
| 390 | |
| 391 | static void |
| 392 | nTriangleMeshAddVertex_XYZ_ST(JNIEnv *_env, jobject _this, jfloat x, jfloat y, jfloat z, jfloat s, jfloat t) |
| 393 | { |
| 394 | float v[] = {s, t, x, y, z}; |
| 395 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 396 | LOG_API("nTriangleMeshAddVertex_XYZ_ST, con(%p), x(%f), y(%f), z(%f), s(%f), t(%f)", con, x, y, z, s, t); |
| 397 | rsTriangleMeshAddVertex(v); |
| 398 | } |
| 399 | |
| 400 | static void |
| 401 | nTriangleMeshAddTriangle(JNIEnv *_env, jobject _this, jint i1, jint i2, jint i3) |
| 402 | { |
| 403 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 404 | LOG_API("nTriangleMeshAddTriangle, con(%p), i1(%i), i2(%i), i3(%i)", con, i1, i2, i3); |
| 405 | rsTriangleMeshAddTriangle(i1, i2, i3); |
| 406 | } |
| 407 | |
| 408 | static jint |
| 409 | nTriangleMeshCreate(JNIEnv *_env, jobject _this) |
| 410 | { |
| 411 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 412 | LOG_API("nTriangleMeshCreate, con(%p)", con); |
| 413 | return (jint) rsTriangleMeshCreate(); |
| 414 | } |
| 415 | |
| 416 | // ----------------------------------- |
| 417 | |
| 418 | static void |
| 419 | nAdapter1DDestroy(JNIEnv *_env, jobject _this, jint adapter) |
| 420 | { |
| 421 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 422 | LOG_API("nAdapter1DDestroy, con(%p), adapter(%p)", con, (RsAdapter1D)adapter); |
| 423 | rsAdapter1DDestroy((RsAdapter1D)adapter); |
| 424 | } |
| 425 | |
| 426 | static void |
| 427 | nAdapter1DBindAllocation(JNIEnv *_env, jobject _this, jint adapter, jint alloc) |
| 428 | { |
| 429 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 430 | LOG_API("nAdapter1DBindAllocation, con(%p), adapter(%p), alloc(%p)", con, (RsAdapter1D)adapter, (RsAllocation)alloc); |
| 431 | rsAdapter1DBindAllocation((RsAdapter1D)adapter, (RsAllocation)alloc); |
| 432 | } |
| 433 | |
| 434 | static void |
| 435 | nAdapter1DSetConstraint(JNIEnv *_env, jobject _this, jint adapter, jint dim, jint value) |
| 436 | { |
| 437 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 438 | LOG_API("nAdapter1DSetConstraint, con(%p), adapter(%p), dim(%i), value(%i)", con, (RsAdapter1D)adapter, dim, value); |
| 439 | rsAdapter1DSetConstraint((RsAdapter1D)adapter, (RsDimension)dim, value); |
| 440 | } |
| 441 | |
| 442 | static void |
| 443 | nAdapter1DData_i(JNIEnv *_env, jobject _this, jint adapter, jintArray data) |
| 444 | { |
| 445 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 446 | jint len = _env->GetArrayLength(data); |
| 447 | LOG_API("nAdapter1DData_i, con(%p), adapter(%p), len(%i)", con, (RsAdapter1D)adapter, len); |
| 448 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| 449 | rsAdapter1DData((RsAdapter1D)adapter, ptr); |
| 450 | _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 451 | } |
| 452 | |
| 453 | static void |
| 454 | nAdapter1DSubData_i(JNIEnv *_env, jobject _this, jint adapter, jint offset, jint count, jintArray data) |
| 455 | { |
| 456 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 457 | jint len = _env->GetArrayLength(data); |
| 458 | LOG_API("nAdapter1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAdapter1D)adapter, offset, count, len); |
| 459 | jint *ptr = _env->GetIntArrayElements(data, NULL); |
| 460 | rsAdapter1DSubData((RsAdapter1D)adapter, offset, count, ptr); |
| 461 | _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 462 | } |
| 463 | |
| 464 | static void |
| 465 | nAdapter1DData_f(JNIEnv *_env, jobject _this, jint adapter, jfloatArray data) |
| 466 | { |
| 467 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 468 | jint len = _env->GetArrayLength(data); |
| 469 | LOG_API("nAdapter1DData_f, con(%p), adapter(%p), len(%i)", con, (RsAdapter1D)adapter, len); |
| 470 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| 471 | rsAdapter1DData((RsAdapter1D)adapter, ptr); |
| 472 | _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 473 | } |
| 474 | |
| 475 | static void |
| 476 | nAdapter1DSubData_f(JNIEnv *_env, jobject _this, jint adapter, jint offset, jint count, jfloatArray data) |
| 477 | { |
| 478 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 479 | jint len = _env->GetArrayLength(data); |
| 480 | LOG_API("nAdapter1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAdapter1D)adapter, offset, count, len); |
| 481 | jfloat *ptr = _env->GetFloatArrayElements(data, NULL); |
| 482 | rsAdapter1DSubData((RsAdapter1D)adapter, offset, count, ptr); |
| 483 | _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); |
| 484 | } |
| 485 | |
| 486 | static jint |
| 487 | nAdapter1DCreate(JNIEnv *_env, jobject _this) |
| 488 | { |
| 489 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 490 | LOG_API("nAdapter1DCreate, con(%p)", con); |
| 491 | return (jint)rsAdapter1DCreate(); |
| 492 | } |
| 493 | |
| 494 | // ----------------------------------- |
| 495 | |
| 496 | static void |
| 497 | nScriptDestroy(JNIEnv *_env, jobject _this, jint script) |
| 498 | { |
| 499 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 500 | LOG_API("nScriptDestroy, con(%p), script(%p)", con, (RsScript)script); |
| 501 | rsScriptDestroy((RsScript)script); |
| 502 | } |
| 503 | |
| 504 | static void |
| 505 | nScriptBindAllocation(JNIEnv *_env, jobject _this, jint script, jint alloc, jint slot) |
| 506 | { |
| 507 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 508 | LOG_API("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", con, (RsScript)script, (RsAllocation)alloc, slot); |
| 509 | rsScriptBindAllocation((RsScript)script, (RsAllocation)alloc, slot); |
| 510 | } |
| 511 | |
| 512 | static void |
| 513 | nScriptCBegin(JNIEnv *_env, jobject _this) |
| 514 | { |
| 515 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 516 | LOG_API("nScriptCBegin, con(%p)", con); |
| 517 | rsScriptCBegin(); |
| 518 | } |
| 519 | |
| 520 | static void |
| 521 | nScriptCSetClearColor(JNIEnv *_env, jobject _this, jfloat r, jfloat g, jfloat b, jfloat a) |
| 522 | { |
| 523 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 524 | LOG_API("nScriptCSetClearColor, con(%p), r(%f), g(%f), b(%f), a(%f)", con, r, g, b, a); |
| 525 | rsScriptCSetClearColor(r, g, b, a); |
| 526 | } |
| 527 | |
| 528 | static void |
| 529 | nScriptCSetClearDepth(JNIEnv *_env, jobject _this, jfloat d) |
| 530 | { |
| 531 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 532 | LOG_API("nScriptCSetClearColor, con(%p), depth(%f)", con, d); |
| 533 | rsScriptCSetClearDepth(d); |
| 534 | } |
| 535 | |
| 536 | static void |
| 537 | nScriptCSetClearStencil(JNIEnv *_env, jobject _this, jint stencil) |
| 538 | { |
| 539 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 540 | LOG_API("nScriptCSetClearStencil, con(%p), stencil(%i)", con, stencil); |
| 541 | rsScriptCSetClearStencil(stencil); |
| 542 | } |
| 543 | |
| 544 | static void |
| 545 | nScriptCAddType(JNIEnv *_env, jobject _this, jint type) |
| 546 | { |
| 547 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 548 | LOG_API("nScriptCAddType, con(%p), type(%p)", con, (RsType)type); |
| 549 | rsScriptCAddType((RsType)type); |
| 550 | } |
| 551 | |
| 552 | static void |
| 553 | nScriptCSetRoot(JNIEnv *_env, jobject _this, jboolean isRoot) |
| 554 | { |
| 555 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 556 | LOG_API("nScriptCSetRoot, con(%p), isRoot(%i)", con, isRoot); |
| 557 | rsScriptCSetRoot(isRoot); |
| 558 | } |
| 559 | |
| 560 | static void |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 561 | nScriptCSetScript(JNIEnv *_env, jobject _this, jbyteArray scriptRef, |
| 562 | jint offset, jint length) |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 563 | { |
| 564 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 565 | LOG_API("!!! nScriptCSetScript, con(%p)", con); |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 566 | jint _exception = 0; |
| 567 | jint remaining; |
| 568 | jbyte* script_base = 0; |
| 569 | jbyte* script_ptr; |
| Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 570 | ACCscript* script = 0; |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 571 | void* scriptEntry = 0; |
| 572 | if (!scriptRef) { |
| 573 | _exception = 1; |
| 574 | //_env->ThrowNew(IAEClass, "script == null"); |
| 575 | goto exit; |
| 576 | } |
| 577 | if (offset < 0) { |
| 578 | _exception = 1; |
| 579 | //_env->ThrowNew(IAEClass, "offset < 0"); |
| 580 | goto exit; |
| 581 | } |
| 582 | if (length < 0) { |
| 583 | _exception = 1; |
| 584 | //_env->ThrowNew(IAEClass, "length < 0"); |
| 585 | goto exit; |
| 586 | } |
| 587 | remaining = _env->GetArrayLength(scriptRef) - offset; |
| 588 | if (remaining < length) { |
| 589 | _exception = 1; |
| 590 | //_env->ThrowNew(IAEClass, "length > script.length - offset"); |
| 591 | goto exit; |
| 592 | } |
| 593 | script_base = (jbyte *) |
| 594 | _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0); |
| 595 | script_ptr = script_base + offset; |
| 596 | |
| 597 | { |
| Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 598 | script = accCreateScript(); |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 599 | const char* scriptSource[] = {(const char*) script_ptr}; |
| 600 | int scriptLength[] = {length} ; |
| 601 | accScriptSource(script, 1, scriptSource, scriptLength); |
| 602 | accCompileScript(script); |
| 603 | accGetScriptLabel(script, "main", (ACCvoid**) &scriptEntry); |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 604 | } |
| 605 | if (scriptEntry) { |
| Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 606 | rsScriptCSetScript((void*) script, (void *)scriptEntry); |
| 607 | script = 0; |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 608 | } |
| 609 | exit: |
| Jack Palevich | ec5a20b | 2009-05-28 15:53:04 -0700 | [diff] [blame] | 610 | if (script) { |
| 611 | accDeleteScript(script); |
| 612 | } |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 613 | if (script_base) { |
| 614 | _env->ReleasePrimitiveArrayCritical(scriptRef, script_base, |
| 615 | _exception ? JNI_ABORT: 0); |
| 616 | } |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | static jint |
| 620 | nScriptCCreate(JNIEnv *_env, jobject _this) |
| 621 | { |
| 622 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 623 | LOG_API("nScriptCCreate, con(%p)", con); |
| 624 | return (jint)rsScriptCCreate(); |
| 625 | } |
| 626 | |
| 627 | // --------------------------------------------------------------------------- |
| 628 | |
| 629 | static void |
| 630 | nProgramFragmentStoreBegin(JNIEnv *_env, jobject _this, jint in, jint out) |
| 631 | { |
| 632 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 633 | LOG_API("nProgramFragmentStoreBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out); |
| 634 | rsProgramFragmentStoreBegin((RsElement)in, (RsElement)out); |
| 635 | } |
| 636 | |
| 637 | static void |
| 638 | nProgramFragmentStoreDepthFunc(JNIEnv *_env, jobject _this, jint func) |
| 639 | { |
| 640 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 641 | LOG_API("nProgramFragmentStoreDepthFunc, con(%p), func(%i)", con, func); |
| 642 | rsProgramFragmentStoreDepthFunc((RsDepthFunc)func); |
| 643 | } |
| 644 | |
| 645 | static void |
| 646 | nProgramFragmentStoreDepthMask(JNIEnv *_env, jobject _this, jboolean enable) |
| 647 | { |
| 648 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 649 | LOG_API("nProgramFragmentStoreDepthMask, con(%p), enable(%i)", con, enable); |
| 650 | rsProgramFragmentStoreDepthMask(enable); |
| 651 | } |
| 652 | |
| 653 | static void |
| 654 | nProgramFragmentStoreColorMask(JNIEnv *_env, jobject _this, jboolean r, jboolean g, jboolean b, jboolean a) |
| 655 | { |
| 656 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 657 | LOG_API("nProgramFragmentStoreColorMask, con(%p), r(%i), g(%i), b(%i), a(%i)", con, r, g, b, a); |
| 658 | rsProgramFragmentStoreColorMask(r, g, b, a); |
| 659 | } |
| 660 | |
| 661 | static void |
| 662 | nProgramFragmentStoreBlendFunc(JNIEnv *_env, jobject _this, int src, int dst) |
| 663 | { |
| 664 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 665 | LOG_API("nProgramFragmentStoreBlendFunc, con(%p), src(%i), dst(%i)", con, src, dst); |
| 666 | rsProgramFragmentStoreBlendFunc((RsBlendSrcFunc)src, (RsBlendDstFunc)dst); |
| 667 | } |
| 668 | |
| 669 | static void |
| 670 | nProgramFragmentStoreDither(JNIEnv *_env, jobject _this, jboolean enable) |
| 671 | { |
| 672 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 673 | LOG_API("nProgramFragmentStoreDither, con(%p), enable(%i)", con, enable); |
| 674 | rsProgramFragmentStoreDither(enable); |
| 675 | } |
| 676 | |
| 677 | static jint |
| 678 | nProgramFragmentStoreCreate(JNIEnv *_env, jobject _this) |
| 679 | { |
| 680 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 681 | LOG_API("nProgramFragmentStoreCreate, con(%p)", con); |
| 682 | return (jint)rsProgramFragmentStoreCreate(); |
| 683 | } |
| 684 | |
| 685 | // --------------------------------------------------------------------------- |
| 686 | |
| 687 | static void |
| 688 | nProgramFragmentBegin(JNIEnv *_env, jobject _this, jint in, jint out) |
| 689 | { |
| 690 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 691 | LOG_API("nProgramFragmentBegin, con(%p), in(%p), out(%p)", con, (RsElement)in, (RsElement)out); |
| 692 | rsProgramFragmentBegin((RsElement)in, (RsElement)out); |
| 693 | } |
| 694 | |
| 695 | static void |
| 696 | nProgramFragmentBindTexture(JNIEnv *_env, jobject _this, jint vpf, jint slot, jint a) |
| 697 | { |
| 698 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 699 | LOG_API("nProgramFragmentBindTexture, con(%p), vpf(%p), slot(%i), a(%p)", con, (RsProgramFragment)vpf, slot, (RsAllocation)a); |
| 700 | rsProgramFragmentBindTexture((RsProgramFragment)vpf, slot, (RsAllocation)a); |
| 701 | } |
| 702 | |
| 703 | static void |
| 704 | nProgramFragmentBindSampler(JNIEnv *_env, jobject _this, jint vpf, jint slot, jint a) |
| 705 | { |
| 706 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 707 | LOG_API("nProgramFragmentBindSampler, con(%p), vpf(%p), slot(%i), a(%p)", con, (RsProgramFragment)vpf, slot, (RsSampler)a); |
| 708 | rsProgramFragmentBindSampler((RsProgramFragment)vpf, slot, (RsSampler)a); |
| 709 | } |
| 710 | |
| 711 | static void |
| 712 | nProgramFragmentSetType(JNIEnv *_env, jobject _this, jint slot, jint vt) |
| 713 | { |
| 714 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 715 | LOG_API("nProgramFragmentSetType, con(%p), slot(%i), vt(%p)", con, slot, (RsType)vt); |
| 716 | rsProgramFragmentSetType(slot, (RsType)vt); |
| 717 | } |
| 718 | |
| 719 | static void |
| 720 | nProgramFragmentSetEnvMode(JNIEnv *_env, jobject _this, jint slot, jint env) |
| 721 | { |
| 722 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 723 | LOG_API("nProgramFragmentSetEnvMode, con(%p), slot(%i), vt(%i)", con, slot, env); |
| 724 | rsProgramFragmentSetEnvMode(slot, (RsTexEnvMode)env); |
| 725 | } |
| 726 | |
| 727 | static void |
| 728 | nProgramFragmentSetTexEnable(JNIEnv *_env, jobject _this, jint slot, jboolean enable) |
| 729 | { |
| 730 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 731 | LOG_API("nProgramFragmentSetTexEnable, con(%p), slot(%i), enable(%i)", con, slot, enable); |
| 732 | rsProgramFragmentSetTexEnable(slot, enable); |
| 733 | } |
| 734 | |
| 735 | static jint |
| 736 | nProgramFragmentCreate(JNIEnv *_env, jobject _this, jint slot, jboolean enable) |
| 737 | { |
| 738 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 739 | LOG_API("nProgramFragmentCreate, con(%p)", con); |
| 740 | return (jint)rsProgramFragmentCreate(); |
| 741 | } |
| 742 | |
| 743 | |
| 744 | // --------------------------------------------------------------------------- |
| 745 | |
| 746 | static void |
| 747 | nContextBindRootScript(JNIEnv *_env, jobject _this, jint script) |
| 748 | { |
| 749 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 750 | LOG_API("nContextBindRootScript, con(%p), script(%p)", con, (RsScript)script); |
| 751 | rsContextBindRootScript((RsScript)script); |
| 752 | } |
| 753 | |
| 754 | static void |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 755 | nContextBindProgramFragmentStore(JNIEnv *_env, jobject _this, jint pfs) |
| 756 | { |
| 757 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 758 | LOG_API("nContextBindProgramFragmentStore, con(%p), pfs(%p)", con, (RsProgramFragmentStore)pfs); |
| 759 | rsContextBindProgramFragmentStore((RsProgramFragmentStore)pfs); |
| 760 | } |
| 761 | |
| 762 | static void |
| 763 | nContextBindProgramFragment(JNIEnv *_env, jobject _this, jint pf) |
| 764 | { |
| 765 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 766 | LOG_API("nContextBindProgramFragment, con(%p), pf(%p)", con, (RsProgramFragment)pf); |
| 767 | rsContextBindProgramFragment((RsProgramFragment)pf); |
| 768 | } |
| 769 | |
| Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 770 | // --------------------------------------------------------------------------- |
| 771 | |
| 772 | static void |
| 773 | nSamplerDestroy(JNIEnv *_env, jobject _this, jint s) |
| 774 | { |
| 775 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 776 | LOG_API("nSamplerDestroy, con(%p), sampler(%p)", con, (RsSampler)s); |
| 777 | rsSamplerDestroy((RsSampler)s); |
| 778 | } |
| 779 | |
| 780 | static void |
| 781 | nSamplerBegin(JNIEnv *_env, jobject _this) |
| 782 | { |
| 783 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 784 | LOG_API("nSamplerBegin, con(%p)", con); |
| 785 | rsSamplerBegin(); |
| 786 | } |
| 787 | |
| 788 | static void |
| 789 | nSamplerSet(JNIEnv *_env, jobject _this, jint p, jint v) |
| 790 | { |
| 791 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 792 | LOG_API("nSamplerSet, con(%p), param(%i), value(%i)", con, p, v); |
| 793 | rsSamplerSet((RsSamplerParam)p, (RsSamplerValue)v); |
| 794 | } |
| 795 | |
| 796 | static jint |
| 797 | nSamplerCreate(JNIEnv *_env, jobject _this) |
| 798 | { |
| 799 | RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); |
| 800 | LOG_API("nSamplerCreate, con(%p), script(%p)", con, (RsScript)script); |
| 801 | return (jint)rsSamplerCreate(); |
| 802 | } |
| 803 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 804 | |
| 805 | // --------------------------------------------------------------------------- |
| 806 | |
| 807 | |
| Jack Palevich | df98851 | 2009-05-27 17:00:45 -0700 | [diff] [blame] | 808 | static const char *classPathName = "com/android/fountain/RenderScript"; |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 809 | |
| 810 | static JNINativeMethod methods[] = { |
| 811 | {"_nInit", "()V", (void*)_nInit }, |
| 812 | {"nDeviceCreate", "()I", (void*)nDeviceCreate }, |
| 813 | {"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, |
| 814 | {"nContextCreate", "(ILandroid/view/Surface;I)I", (void*)nContextCreate }, |
| 815 | {"nContextDestroy", "(I)V", (void*)nContextDestroy }, |
| 816 | |
| 817 | {"nElementBegin", "()V", (void*)nElementBegin }, |
| 818 | {"nElementAddPredefined", "(I)V", (void*)nElementAddPredefined }, |
| 819 | {"nElementAdd", "(IIII)V", (void*)nElementAdd }, |
| 820 | {"nElementCreate", "()I", (void*)nElementCreate }, |
| 821 | {"nElementGetPredefined", "(I)I", (void*)nElementGetPredefined }, |
| 822 | {"nElementDestroy", "(I)V", (void*)nElementDestroy }, |
| 823 | |
| 824 | {"nTypeBegin", "(I)V", (void*)nTypeBegin }, |
| 825 | {"nTypeAdd", "(II)V", (void*)nTypeAdd }, |
| 826 | {"nTypeCreate", "()I", (void*)nTypeCreate }, |
| 827 | {"nTypeDestroy", "(I)V", (void*)nTypeDestroy }, |
| 828 | |
| 829 | {"nAllocationCreateTyped", "(I)I", (void*)nAllocationCreateTyped }, |
| 830 | {"nAllocationCreatePredefSized", "(II)I", (void*)nAllocationCreatePredefSized }, |
| 831 | {"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized }, |
| Jason Sams | ffe9f48 | 2009-06-01 17:45:53 -0700 | [diff] [blame^] | 832 | {"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 833 | {"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture }, |
| 834 | {"nAllocationDestroy", "(I)V", (void*)nAllocationDestroy }, |
| 835 | {"nAllocationData", "(I[I)V", (void*)nAllocationData_i }, |
| 836 | {"nAllocationData", "(I[F)V", (void*)nAllocationData_f }, |
| 837 | {"nAllocationSubData1D", "(III[I)V", (void*)nAllocationSubData1D_i }, |
| 838 | {"nAllocationSubData1D", "(III[F)V", (void*)nAllocationSubData1D_f }, |
| 839 | {"nAllocationSubData2D", "(IIIII[I)V", (void*)nAllocationSubData2D_i }, |
| 840 | {"nAllocationSubData2D", "(IIIII[F)V", (void*)nAllocationSubData2D_f }, |
| 841 | |
| 842 | {"nTriangleMeshDestroy", "(I)V", (void*)nTriangleMeshDestroy }, |
| 843 | {"nTriangleMeshBegin", "(II)V", (void*)nTriangleMeshBegin }, |
| 844 | {"nTriangleMeshAddVertex_XY", "(FF)V", (void*)nTriangleMeshAddVertex_XY }, |
| 845 | {"nTriangleMeshAddVertex_XYZ", "(FFF)V", (void*)nTriangleMeshAddVertex_XYZ }, |
| 846 | {"nTriangleMeshAddVertex_XY_ST", "(FFFF)V", (void*)nTriangleMeshAddVertex_XY_ST }, |
| 847 | {"nTriangleMeshAddVertex_XYZ_ST", "(FFFFF)V", (void*)nTriangleMeshAddVertex_XYZ_ST }, |
| 848 | {"nTriangleMeshAddTriangle", "(III)V", (void*)nTriangleMeshAddTriangle }, |
| 849 | {"nTriangleMeshCreate", "()I", (void*)nTriangleMeshCreate }, |
| 850 | |
| 851 | {"nAdapter1DDestroy", "(I)V", (void*)nAdapter1DDestroy }, |
| 852 | {"nAdapter1DBindAllocation", "(II)V", (void*)nAdapter1DBindAllocation }, |
| 853 | {"nAdapter1DSetConstraint", "(III)V", (void*)nAdapter1DSetConstraint }, |
| 854 | {"nAdapter1DData", "(I[I)V", (void*)nAdapter1DData_i }, |
| 855 | {"nAdapter1DSubData", "(III[I)V", (void*)nAdapter1DSubData_i }, |
| 856 | {"nAdapter1DData", "(I[F)V", (void*)nAdapter1DData_f }, |
| 857 | {"nAdapter1DSubData", "(III[F)V", (void*)nAdapter1DSubData_f }, |
| 858 | {"nAdapter1DCreate", "()I", (void*)nAdapter1DCreate }, |
| 859 | |
| 860 | {"nScriptDestroy", "(I)V", (void*)nScriptDestroy }, |
| 861 | {"nScriptBindAllocation", "(III)V", (void*)nScriptBindAllocation }, |
| 862 | {"nScriptCBegin", "()V", (void*)nScriptCBegin }, |
| 863 | {"nScriptCSetClearColor", "(FFFF)V", (void*)nScriptCSetClearColor }, |
| 864 | {"nScriptCSetClearDepth", "(F)V", (void*)nScriptCSetClearDepth }, |
| 865 | {"nScriptCSetClearStencil", "(I)V", (void*)nScriptCSetClearStencil }, |
| 866 | {"nScriptCAddType", "(I)V", (void*)nScriptCAddType }, |
| 867 | {"nScriptCSetRoot", "(Z)V", (void*)nScriptCSetRoot }, |
| Jack Palevich | 43702d8 | 2009-05-28 13:38:16 -0700 | [diff] [blame] | 868 | {"nScriptCSetScript", "([BII)V", (void*)nScriptCSetScript }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 869 | {"nScriptCCreate", "()I", (void*)nScriptCCreate }, |
| 870 | |
| 871 | {"nProgramFragmentStoreBegin", "(II)V", (void*)nProgramFragmentStoreBegin }, |
| 872 | {"nProgramFragmentStoreDepthFunc", "(I)V", (void*)nProgramFragmentStoreDepthFunc }, |
| 873 | {"nProgramFragmentStoreDepthMask", "(Z)V", (void*)nProgramFragmentStoreDepthMask }, |
| 874 | {"nProgramFragmentStoreColorMask", "(ZZZZ)V", (void*)nProgramFragmentStoreColorMask }, |
| 875 | {"nProgramFragmentStoreBlendFunc", "(II)V", (void*)nProgramFragmentStoreBlendFunc }, |
| 876 | {"nProgramFragmentStoreDither", "(Z)V", (void*)nProgramFragmentStoreDither }, |
| 877 | {"nProgramFragmentStoreCreate", "()I", (void*)nProgramFragmentStoreCreate }, |
| 878 | |
| 879 | {"nProgramFragmentBegin", "(II)V", (void*)nProgramFragmentBegin }, |
| 880 | {"nProgramFragmentBindTexture", "(III)V", (void*)nProgramFragmentBindTexture }, |
| 881 | {"nProgramFragmentBindSampler", "(III)V", (void*)nProgramFragmentBindSampler }, |
| 882 | {"nProgramFragmentSetType", "(II)V", (void*)nProgramFragmentSetType }, |
| 883 | {"nProgramFragmentSetEnvMode", "(II)V", (void*)nProgramFragmentSetEnvMode }, |
| 884 | {"nProgramFragmentSetTexEnable", "(IZ)V", (void*)nProgramFragmentSetTexEnable }, |
| 885 | {"nProgramFragmentCreate", "()I", (void*)nProgramFragmentCreate }, |
| 886 | |
| 887 | {"nContextBindRootScript", "(I)V", (void*)nContextBindRootScript }, |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 888 | {"nContextBindProgramFragmentStore","(I)V", (void*)nContextBindProgramFragmentStore }, |
| 889 | {"nContextBindProgramFragment", "(I)V", (void*)nContextBindProgramFragment }, |
| 890 | |
| Jason Sams | 02fb2cb | 2009-05-28 15:37:57 -0700 | [diff] [blame] | 891 | {"nSamplerDestroy", "(I)V", (void*)nSamplerDestroy }, |
| 892 | {"nSamplerBegin", "()V", (void*)nSamplerBegin }, |
| 893 | {"nSamplerSet", "(II)V", (void*)nSamplerSet }, |
| 894 | {"nSamplerCreate", "()I", (void*)nSamplerCreate }, |
| 895 | |
| Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 896 | }; |
| 897 | |
| 898 | static int registerFuncs(JNIEnv *_env) |
| 899 | { |
| 900 | return android::AndroidRuntime::registerNativeMethods( |
| 901 | _env, classPathName, methods, NELEM(methods)); |
| 902 | } |
| 903 | |
| 904 | // --------------------------------------------------------------------------- |
| 905 | |
| 906 | jint JNI_OnLoad(JavaVM* vm, void* reserved) |
| 907 | { |
| 908 | JNIEnv* env = NULL; |
| 909 | jint result = -1; |
| 910 | |
| 911 | LOGE("****************************************************\n"); |
| 912 | |
| 913 | if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { |
| 914 | LOGE("ERROR: GetEnv failed\n"); |
| 915 | goto bail; |
| 916 | } |
| 917 | assert(env != NULL); |
| 918 | |
| 919 | if (registerFuncs(env) < 0) { |
| 920 | LOGE("ERROR: MediaPlayer native registration failed\n"); |
| 921 | goto bail; |
| 922 | } |
| 923 | |
| 924 | /* success -- return valid version number */ |
| 925 | result = JNI_VERSION_1_4; |
| 926 | |
| 927 | bail: |
| 928 | return result; |
| 929 | } |