android_renderscript_RenderScript.cpp revision 64965801cc56f4fca5c8e55bdd27de57359f7a0e
198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams/* 298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Copyright (C) 2011-2012 The Android Open Source Project 398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Licensed under the Apache License, Version 2.0 (the "License"); 598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * you may not use this file except in compliance with the License. 698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * You may obtain a copy of the License at 798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * http://www.apache.org/licenses/LICENSE-2.0 998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 1098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Unless required by applicable law or agreed to in writing, software 1198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * distributed under the License is distributed on an "AS IS" BASIS, 1298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * See the License for the specific language governing permissions and 1498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * limitations under the License. 1598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams */ 1698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 1798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#define LOG_TAG "libRS_jni" 1898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 1998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <stdlib.h> 2098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <stdio.h> 2198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <fcntl.h> 2298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <unistd.h> 2398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <math.h> 2498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <utils/misc.h> 2564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams#include <android/bitmap.h> 2698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include "jni.h" 2798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include "JNIHelp.h" 2898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include "android_runtime/AndroidRuntime.h" 2998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <rs.h> 3098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <rsEnv.h> 3198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams//#define LOG_API ALOG 3398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#define LOG_API(...) 3498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsusing namespace android; 3698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsclass AutoJavaStringToUTF8 { 3898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samspublic: 3998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8(JNIEnv* env, jstring str) : fEnv(env), fJStr(str) { 4098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fCStr = env->GetStringUTFChars(str, NULL); 4198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fLength = env->GetStringUTFLength(str); 4298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 4398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ~AutoJavaStringToUTF8() { 4498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fEnv->ReleaseStringUTFChars(fJStr, fCStr); 4598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 4698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char* c_str() const { return fCStr; } 4798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length() const { return fLength; } 4898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 4998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsprivate: 5098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv* fEnv; 5198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring fJStr; 5298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char* fCStr; 5398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize fLength; 5498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 5598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 5698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsclass AutoJavaStringArrayToUTF8 { 5798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samspublic: 5898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringArrayToUTF8(JNIEnv* env, jobjectArray strings, jsize stringsLength) 5998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams : mEnv(env), mStrings(strings), mStringsLength(stringsLength) { 6098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings = NULL; 6198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray = NULL; 6298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (stringsLength > 0) { 6398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings = (const char **)calloc(stringsLength, sizeof(char *)); 6498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray = (size_t*)calloc(stringsLength, sizeof(size_t)); 6598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for (jsize ct = 0; ct < stringsLength; ct ++) { 6698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct); 6798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings[ct] = mEnv->GetStringUTFChars(s, NULL); 6898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray[ct] = mEnv->GetStringUTFLength(s); 6998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ~AutoJavaStringArrayToUTF8() { 7398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for (jsize ct=0; ct < mStringsLength; ct++) { 7498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct); 7598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mEnv->ReleaseStringUTFChars(s, mCStrings[ct]); 7698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(mCStrings); 7898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(mSizeArray); 7998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 8098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **c_str() const { return mCStrings; } 8198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *c_str_len() const { return mSizeArray; } 8298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length() const { return mStringsLength; } 8398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 8498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsprivate: 8598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv *mEnv; 8698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jobjectArray mStrings; 8798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **mCStrings; 8898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *mSizeArray; 8998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize mStringsLength; 9098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 9198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 9398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jfieldID gContextId = 0; 9598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jfieldID gNativeBitmapID = 0; 9698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jfieldID gTypeNativeCache = 0; 9798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void _nInit(JNIEnv *_env, jclass _this) 9998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 10098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams gContextId = _env->GetFieldID(_this, "mContext", "I"); 10198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jclass bitmapClass = _env->FindClass("android/graphics/Bitmap"); 10398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "I"); 10498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 10598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 10798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 10998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextFinish(JNIEnv *_env, jobject _this, RsContext con) 11098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 11198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextFinish, con(%p)", con); 11298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextFinish(con); 11398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 11498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 11598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 11698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnObjDestroy(JNIEnv *_env, jobject _this, RsContext con, jint obj) 11798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 11898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nObjDestroy, con(%p) obj(%p)", con, (void *)obj); 11998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsObjDestroy(con, (void *)obj); 12098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 12198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 12298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 12398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 12498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 12598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceCreate(JNIEnv *_env, jobject _this) 12698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 12798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceCreate"); 12898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsDeviceCreate(); 12998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 13098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 13198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 13298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceDestroy(JNIEnv *_env, jobject _this, jint dev) 13398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 13498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceDestroy"); 13598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return rsDeviceDestroy((RsDevice)dev); 13698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 13798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 13898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 13998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceSetConfig(JNIEnv *_env, jobject _this, jint dev, jint p, jint value) 14098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 14198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value); 14298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return rsDeviceSetConfig((RsDevice)dev, (RsDeviceParam)p, value); 14398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 14498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 14598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 14698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer) 14798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 14898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextCreate"); 14998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer); 15098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 15198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 15298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 15398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 15498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextSetPriority(JNIEnv *_env, jobject _this, RsContext con, jint p) 15598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 15698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("ContextSetPriority, con(%p), priority(%i)", con, p); 15798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextSetPriority(con, p); 15898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 15998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 16398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextDestroy(JNIEnv *_env, jobject _this, RsContext con) 16498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 16598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDestroy, con(%p)", con); 16698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDestroy(con); 16798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 16898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 17098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextDump(JNIEnv *_env, jobject _this, RsContext con, jint bits) 17198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 17298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDump, con(%p) bits(%i)", (RsContext)con, bits); 17398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDump((RsContext)con, bits); 17498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 17598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 17698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 17798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jstring 17898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextGetErrorMessage(JNIEnv *_env, jobject _this, RsContext con) 17998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 18098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextGetErrorMessage, con(%p)", con); 18198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams char buf[1024]; 18298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 18398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 18498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 18598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextGetMessage(con, 18698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams buf, sizeof(buf), 18798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &receiveLen, sizeof(receiveLen), 18898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 18998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!id && receiveLen) { 19098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGV("message receive buffer too small. %i", receiveLen); 19198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 19298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return _env->NewStringUTF(buf); 19398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 19498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 19598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 19698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextGetUserMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray data) 19798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 19898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 19998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextGetMessage, con(%p), len(%i)", con, len); 20098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 20198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 20298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 20398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextGetMessage(con, 20498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ptr, len * 4, 20598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &receiveLen, sizeof(receiveLen), 20698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 20798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!id && receiveLen) { 20898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGV("message receive buffer too small. %i", receiveLen); 20998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 21098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, 0); 21198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 21298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 21398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 21498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 21598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextPeekMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray auxData) 21698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 21798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextPeekMessage, con(%p)", con); 21898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *auxDataPtr = _env->GetIntArrayElements(auxData, NULL); 21998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 22098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 22198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextPeekMessage(con, &receiveLen, sizeof(receiveLen), 22298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 22398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams auxDataPtr[0] = (jint)subID; 22498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams auxDataPtr[1] = (jint)receiveLen; 22598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(auxData, auxDataPtr, 0); 22698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 22798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 22898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 22998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void nContextInitToClient(JNIEnv *_env, jobject _this, RsContext con) 23098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 23198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextInitToClient, con(%p)", con); 23298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextInitToClient(con); 23398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 23498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 23598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void nContextDeinitToClient(JNIEnv *_env, jobject _this, RsContext con) 23698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 23798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDeinitToClient, con(%p)", con); 23898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDeinitToClient(con); 23998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 24098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 24198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 24298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 24398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementCreate(JNIEnv *_env, jobject _this, RsContext con, jint type, jint kind, jboolean norm, jint size) 24498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 24598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", con, type, kind, norm, size); 24698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsElementCreate(con, (RsDataType)type, (RsDataKind)kind, norm, size); 24798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 24898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 24998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 25098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementCreate2(JNIEnv *_env, jobject _this, RsContext con, 25198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _ids, jobjectArray _names, jintArray _arraySizes) 25298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 25398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int fieldCount = _env->GetArrayLength(_ids); 25498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementCreate2, con(%p)", con); 25598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 25698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ids = _env->GetIntArrayElements(_ids, NULL); 25798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *arraySizes = _env->GetIntArrayElements(_arraySizes, NULL); 25898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 25998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringArrayToUTF8 names(_env, _names, fieldCount); 26098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **nameArray = names.c_str(); 26298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *sizeArray = names.c_str_len(); 26398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint id = (jint)rsElementCreate2(con, 26598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsElement *)ids, fieldCount, 26698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams nameArray, fieldCount * sizeof(size_t), sizeArray, 26798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const uint32_t *)arraySizes, fieldCount); 26898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(_ids, ids, JNI_ABORT); 27098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(_arraySizes, arraySizes, JNI_ABORT); 27198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)id; 27298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 27398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 27798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementGetSubElements(JNIEnv *_env, jobject _this, RsContext con, jint id, 27898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _IDs, 27998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jobjectArray _names, 28098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _arraySizes) 28198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 28298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int dataSize = _env->GetArrayLength(_IDs); 28398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementGetSubElements, con(%p)", con); 28498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t *ids = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); 28698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **names = (const char **)malloc((uint32_t)dataSize * sizeof(const char *)); 28798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t *arraySizes = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); 28898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsaElementGetSubElements(con, (RsElement)id, ids, names, arraySizes, (uint32_t)dataSize); 29098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for(jint i = 0; i < dataSize; i++) { 29298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i])); 29398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetIntArrayRegion(_IDs, i, 1, (const jint*)&ids[i]); 29498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetIntArrayRegion(_arraySizes, i, 1, (const jint*)&arraySizes[i]); 29598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 29698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(ids); 29898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(names); 29998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(arraySizes); 30098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 30198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 30298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 30398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 30498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 30598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid, 30698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces) 30798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 30898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i)", 30998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams con, eid, dimx, dimy, dimz, mips, faces); 31098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 31198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces); 31298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)id; 31398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 31498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 31598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 31698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 31798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 31898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mips, jint usage, jint pointer) 31998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 32098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", con, (RsElement)type, mips, usage, (void *)pointer); 32198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint) rsAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uint32_t)pointer); 32298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 32398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 32598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits) 32698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 32798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", con, (RsAllocation)a, bits); 32898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits); 32998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 33098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 33198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 33298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, RsContext con, jint alloc) 33398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 33498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", con, (RsAllocation)alloc); 33598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationGenerateMipmaps(con, (RsAllocation)alloc); 33698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 33798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 33864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Samsstatic size_t GetBitmapSize(JNIEnv *env, jobject jbitmap) { 33964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 34064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 34164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(env, jbitmap, &info); 34264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams size_t s = info.width * info.height; 34364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams switch (info.format) { 34464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGBA_8888: s *= 4; break; 34564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGB_565: s *= 2; break; 34664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGBA_4444: s *= 2; break; 34764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 34864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams return s; 34964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams} 35064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 35198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 35298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 35398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 35464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 35564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 35664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 35764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams jint id = 0; 35864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 35964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams id = (jint)rsAllocationCreateFromBitmap(con, (RsType)type, 36064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams (RsAllocationMipmapControl)mip, pixels, 36164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams GetBitmapSize(_env, jbitmap), usage); 36264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 36364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 36498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 36598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 36698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 36798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 36898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 36998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 37064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 37164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 37264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 37364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams jint id = 0; 37464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 37564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams id = (jint)rsAllocationCubeCreateFromBitmap(con, 37664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams (RsType)type, (RsAllocationMipmapControl)mip, 37764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams pixels, GetBitmapSize(_env, jbitmap), usage); 37864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 37964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 38098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 38198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 38298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 38398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 38498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) 38598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 38664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 38764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 38864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(_env, jbitmap, &info); 38964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 39064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 39164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 39264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 39364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 39464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams rsAllocation2DData(con, (RsAllocation)alloc, 0, 0, 39564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, 39664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams info.width, info.height, pixels, GetBitmapSize(_env, jbitmap)); 39764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 39864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 39998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 40098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 40198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 40298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) 40398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 40464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 40564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 40664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(_env, jbitmap, &info); 40798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 40864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 40964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 41064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 41164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 41264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams rsAllocationCopyToBitmap(con, (RsAllocation)alloc, pixels, GetBitmapSize(_env, jbitmap)); 41364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 41464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 41564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams //bitmap.notifyPixelsChanged(); 41698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 41798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 41898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 41998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 42098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jintArray data, int sizeBytes) 42198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 42298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 42398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 42498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 42598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 42698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 42798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 42898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 42998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 43098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jshortArray data, int sizeBytes) 43198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 43298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 43398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_s, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 43498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 43598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 43698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 43798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 43898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 43998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 44098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jbyteArray data, int sizeBytes) 44198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 44298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 44398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_b, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 44498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 44598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 44698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 44798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 44898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 44998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 45098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jfloatArray data, int sizeBytes) 45198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 45298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 45398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 45498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 45598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 45698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 45798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 45898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 45998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 46098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// native void rsnAllocationElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); 46198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationElementData1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint compIdx, jbyteArray data, int sizeBytes) 46298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 46398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 46498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes); 46598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 46698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DElementData(con, (RsAllocation)alloc, offset, lod, ptr, sizeBytes, compIdx); 46798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 46898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 46998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 47098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 47198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 47298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jshortArray data, int sizeBytes) 47398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 47498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 47598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 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); 47698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 47798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes); 47898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 47998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 48098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 48198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 48298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 48398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jbyteArray data, int sizeBytes) 48498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 48598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 48698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 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); 48798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 48898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes); 48998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 49098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 49198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 49298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 49398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 49498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jintArray data, int sizeBytes) 49598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 49698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 49798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 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); 49898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 49998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes); 50098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 50198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 50298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 50398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 50498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 50598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jfloatArray data, int sizeBytes) 50698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 50798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 50898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 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); 50998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 51098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes); 51198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 51298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 51398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 51498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 51598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_alloc(JNIEnv *_env, jobject _this, RsContext con, 51698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dstAlloc, jint dstXoff, jint dstYoff, 51798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dstMip, jint dstFace, 51898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint width, jint height, 51998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint srcAlloc, jint srcXoff, jint srcYoff, 52098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint srcMip, jint srcFace) 52198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 52298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," 52398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams " dstMip(%i), dstFace(%i), width(%i), height(%i)," 52498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", 52598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, 52698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); 52798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 52898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationCopy2DRange(con, 52998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsAllocation)dstAlloc, 53098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams dstXoff, dstYoff, 53198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams dstMip, dstFace, 53298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams width, height, 53398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsAllocation)srcAlloc, 53498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams srcXoff, srcYoff, 53598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams srcMip, srcFace); 53698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 53798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 53898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 53998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintArray data) 54098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 54198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 54298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 54398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 54498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 54598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(int)); 54698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, 0); 54798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 54898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 54998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 55098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jshortArray data) 55198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 55298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 55398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 55498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 55598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 55698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(short)); 55798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, 0); 55898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 55998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 56098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 56198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jbyteArray data) 56298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 56398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 56498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 56598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 56698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 56798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(char)); 56898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, 0); 56998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 57098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 57198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 57298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jfloatArray data) 57398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 57498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 57598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_f, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 57698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 57798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 57898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(float)); 57998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, 0); 58098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 58198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 58298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 58398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationGetType(JNIEnv *_env, jobject _this, RsContext con, jint a) 58498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 58598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationGetType, con(%p), a(%p)", con, (RsAllocation)a); 58698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint) rsaAllocationGetType(con, (RsAllocation)a); 58798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 58898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 58998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 59098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationResize1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX) 59198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 59298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", con, (RsAllocation)alloc, dimX); 59398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationResize1D(con, (RsAllocation)alloc, dimX); 59498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 59598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 59698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 59798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationResize2D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX, jint dimY) 59898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 59998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i), sizeY(%i)", con, (RsAllocation)alloc, dimX, dimY); 60098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationResize2D(con, (RsAllocation)alloc, dimX, dimY); 60198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 60298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 60398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 60498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 60598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 60698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptBindAllocation(JNIEnv *_env, jobject _this, RsContext con, jint script, jint alloc, jint slot) 60798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 60898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", con, (RsScript)script, (RsAllocation)alloc, slot); 60998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptBindAllocation(con, (RsScript)script, (RsAllocation)alloc, slot); 61098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 61198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 61298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 61398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarI(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val) 61498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 61598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val); 61698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarI(con, (RsScript)script, slot, val); 61798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 61898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 61998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 62098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarObj(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val) 62198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 62298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val); 62398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarObj(con, (RsScript)script, slot, (RsObjectBase)val); 62498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 62598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 62698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 62798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jlong val) 62898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 62998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", con, (void *)script, slot, val); 63098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarJ(con, (RsScript)script, slot, val); 63198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 63298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 63398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 63498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, float val) 63598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 63698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", con, (void *)script, slot, val); 63798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarF(con, (RsScript)script, slot, val); 63898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 63998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 64098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 64198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarD(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, double val) 64298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 64398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", con, (void *)script, slot, val); 64498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarD(con, (RsScript)script, slot, val); 64598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 64698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 64798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 64898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data) 64998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 65098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 65198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 65298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 65398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarV(con, (RsScript)script, slot, ptr, len); 65498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 65598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 65698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 65798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 65898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarVE(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data, jint elem, jintArray dims) 65998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 66098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarVE, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 66198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 66298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 66398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dimsLen = _env->GetArrayLength(dims) * sizeof(int); 66498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *dimsPtr = _env->GetIntArrayElements(dims, NULL); 66598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarVE(con, (RsScript)script, slot, ptr, len, (RsElement)elem, 66698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const size_t*) dimsPtr, dimsLen); 66798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 66898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(dims, dimsPtr, JNI_ABORT); 66998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 67098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 67198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 67298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 67398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetTimeZone(JNIEnv *_env, jobject _this, RsContext con, jint script, jbyteArray timeZone) 67498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 67598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, (void *)script, (const char *)timeZone); 67698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 67798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint length = _env->GetArrayLength(timeZone); 67898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte* timeZone_ptr; 67998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0); 68098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 68198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetTimeZone(con, (RsScript)script, (const char *)timeZone_ptr, length); 68298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 68398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (timeZone_ptr) { 68498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0); 68598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 68698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 68798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 68898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 68998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptInvoke(JNIEnv *_env, jobject _this, RsContext con, jint obj, jint slot) 69098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 69198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptInvoke, con(%p), script(%p)", con, (void *)obj); 69298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptInvoke(con, (RsScript)obj, slot); 69398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 69498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 69598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 69698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptInvokeV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data) 69798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 69898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 69998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 70098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 70198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptInvokeV(con, (RsScript)script, slot, ptr, len); 70298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 70398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 70498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 70598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 70698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptForEach(JNIEnv *_env, jobject _this, RsContext con, 70798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint script, jint slot, jint ain, jint aout) 70898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 70998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 71098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0); 71198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 71298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 71398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptForEachV(JNIEnv *_env, jobject _this, RsContext con, 71498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint script, jint slot, jint ain, jint aout, jbyteArray params) 71598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 71698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 71798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(params); 71898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(params, NULL); 71998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len); 72098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT); 72198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 72298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 72398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 72498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 72598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 72698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 72798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptCCreate(JNIEnv *_env, jobject _this, RsContext con, 72898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring resName, jstring cacheDir, 72998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyteArray scriptRef, jint length) 73098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 73198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptCCreate, con(%p)", con); 73298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 73398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8 resNameUTF(_env, resName); 73498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir); 73598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint ret = 0; 73698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte* script_ptr = NULL; 73798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint _exception = 0; 73898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint remaining; 73998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!scriptRef) { 74098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 74198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", "script == null"); 74298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 74398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 74498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (length < 0) { 74598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 74698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", "length < 0"); 74798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 74898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 74998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams remaining = _env->GetArrayLength(scriptRef); 75098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (remaining < length) { 75198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 75298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", 75398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams // "length > script.length - offset"); 75498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 75598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 75698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams script_ptr = (jbyte *) 75798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0); 75898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 75998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //rsScriptCSetText(con, (const char *)script_ptr, length); 76098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 76198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ret = (jint)rsScriptCCreate(con, 76298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams resNameUTF.c_str(), resNameUTF.length(), 76398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams cacheDirUTF.c_str(), cacheDirUTF.length(), 76498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const char *)script_ptr, length); 76598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 76698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsexit: 76798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (script_ptr) { 76898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleasePrimitiveArrayCritical(scriptRef, script_ptr, 76998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception ? JNI_ABORT: 0); 77098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 77198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 77298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return ret; 77398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 77498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 77598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 77698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 77798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 77898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnSamplerCreate(JNIEnv *_env, jobject _this, RsContext con, jint magFilter, jint minFilter, 77998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint wrapS, jint wrapT, jint wrapR, jfloat aniso) 78098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 78198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nSamplerCreate, con(%p)", con); 78298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsSamplerCreate(con, 78398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)magFilter, 78498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)minFilter, 78598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapS, 78698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapT, 78798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapR, 78898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams aniso); 78998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 79098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 79198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 79298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 79398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 79498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic const char *classPathName = "android/support/v8/renderscript/RenderScript"; 79598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 79698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic JNINativeMethod methods[] = { 79798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"_nInit", "()V", (void*)_nInit }, 79898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 79998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceCreate", "()I", (void*)nDeviceCreate }, 80098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, 80198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig }, 80298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextGetUserMessage", "(I[I)I", (void*)nContextGetUserMessage }, 80398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextGetErrorMessage", "(I)Ljava/lang/String;", (void*)nContextGetErrorMessage }, 80498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextPeekMessage", "(I[I)I", (void*)nContextPeekMessage }, 80598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 80698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextInitToClient", "(I)V", (void*)nContextInitToClient }, 80798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextDeinitToClient", "(I)V", (void*)nContextDeinitToClient }, 80898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 80998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 81098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// All methods below are thread protected in java. 81198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextCreate", "(III)I", (void*)nContextCreate }, 81298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextFinish", "(I)V", (void*)nContextFinish }, 81398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority }, 81498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextDestroy", "(I)V", (void*)nContextDestroy }, 81598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextDump", "(II)V", (void*)nContextDump }, 81698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnObjDestroy", "(II)V", (void*)nObjDestroy }, 81798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 81898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementCreate", "(IIIZI)I", (void*)nElementCreate }, 81998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementCreate2", "(I[I[Ljava/lang/String;[I)I", (void*)nElementCreate2 }, 82098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;[I)V", (void*)nElementGetSubElements }, 82198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 82298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnTypeCreate", "(IIIIIZZ)I", (void*)nTypeCreate }, 82398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 82498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCreateTyped", "(IIIII)I", (void*)nAllocationCreateTyped }, 82598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap }, 82698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap }, 82798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 82898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, 82998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCopyToBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap }, 83098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 83198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, 83298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[II)V", (void*)nAllocationData1D_i }, 83398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[SI)V", (void*)nAllocationData1D_s }, 83498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[BI)V", (void*)nAllocationData1D_b }, 83598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[FI)V", (void*)nAllocationData1D_f }, 83698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationElementData1D", "(IIIII[BI)V", (void*)nAllocationElementData1D }, 83798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[II)V", (void*)nAllocationData2D_i }, 83898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[SI)V", (void*)nAllocationData2D_s }, 83998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[BI)V", (void*)nAllocationData2D_b }, 84098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f }, 84198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIIIIIIII)V", (void*)nAllocationData2D_alloc }, 84298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i }, 84398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[S)V", (void*)nAllocationRead_s }, 84498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[B)V", (void*)nAllocationRead_b }, 84598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[F)V", (void*)nAllocationRead_f }, 84698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationGetType", "(II)I", (void*)nAllocationGetType}, 84798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationResize1D", "(III)V", (void*)nAllocationResize1D }, 84898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationResize2D", "(IIII)V", (void*)nAllocationResize2D }, 84998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationGenerateMipmaps", "(II)V", (void*)nAllocationGenerateMipmaps }, 85098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 85198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptBindAllocation", "(IIII)V", (void*)nScriptBindAllocation }, 85298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetTimeZone", "(II[B)V", (void*)nScriptSetTimeZone }, 85398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptInvoke", "(III)V", (void*)nScriptInvoke }, 85498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptInvokeV", "(III[B)V", (void*)nScriptInvokeV }, 85598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptForEach", "(IIIII)V", (void*)nScriptForEach }, 85698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptForEach", "(IIIII[B)V", (void*)nScriptForEachV }, 85798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarI", "(IIII)V", (void*)nScriptSetVarI }, 85898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarJ", "(IIIJ)V", (void*)nScriptSetVarJ }, 85998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF }, 86098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarD", "(IIID)V", (void*)nScriptSetVarD }, 86198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarV", "(III[B)V", (void*)nScriptSetVarV }, 86298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarVE", "(III[BI[I)V", (void*)nScriptSetVarVE }, 86398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarObj", "(IIII)V", (void*)nScriptSetVarObj }, 86498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 86598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptCCreate", "(ILjava/lang/String;Ljava/lang/String;[BI)I", (void*)nScriptCCreate }, 86698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 86798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnSamplerCreate", "(IIIIIIF)I", (void*)nSamplerCreate }, 86898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 86998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 87098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 87198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int registerFuncs(JNIEnv *_env) 87298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 87398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return android::AndroidRuntime::registerNativeMethods( 87498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env, classPathName, methods, NELEM(methods)); 87598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 87698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 87798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 87898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 87998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsjint JNI_OnLoad(JavaVM* vm, void* reserved) 88098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 88198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv* env = NULL; 88298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint result = -1; 88398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 88498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { 88598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGE("ERROR: GetEnv failed\n"); 88698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto bail; 88798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 88898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams assert(env != NULL); 88998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 89098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (registerFuncs(env) < 0) { 89198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGE("ERROR: MediaPlayer native registration failed\n"); 89298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto bail; 89398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 89498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 89598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams /* success -- return valid version number */ 89698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams result = JNI_VERSION_1_4; 89798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 89898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsbail: 89998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return result; 90098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 901