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> 2464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams#include <android/bitmap.h> 250f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines#include <android/log.h> 2698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include "jni.h" 2798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <rs.h> 2898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <rsEnv.h> 2998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams//#define LOG_API ALOG 3198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#define LOG_API(...) 3298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 330f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines#define NELEM(m) (sizeof(m) / sizeof((m)[0])) 3498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsclass AutoJavaStringToUTF8 { 3698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samspublic: 3798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8(JNIEnv* env, jstring str) : fEnv(env), fJStr(str) { 3898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fCStr = env->GetStringUTFChars(str, NULL); 3998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fLength = env->GetStringUTFLength(str); 4098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 4198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ~AutoJavaStringToUTF8() { 4298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fEnv->ReleaseStringUTFChars(fJStr, fCStr); 4398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 4498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char* c_str() const { return fCStr; } 4598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length() const { return fLength; } 4698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 4798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsprivate: 4898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv* fEnv; 4998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring fJStr; 5098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char* fCStr; 5198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize fLength; 5298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 5398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 5498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsclass AutoJavaStringArrayToUTF8 { 5598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samspublic: 5698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringArrayToUTF8(JNIEnv* env, jobjectArray strings, jsize stringsLength) 5798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams : mEnv(env), mStrings(strings), mStringsLength(stringsLength) { 5898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings = NULL; 5998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray = NULL; 6098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (stringsLength > 0) { 6198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings = (const char **)calloc(stringsLength, sizeof(char *)); 6298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray = (size_t*)calloc(stringsLength, sizeof(size_t)); 6398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for (jsize ct = 0; ct < stringsLength; ct ++) { 6498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct); 6598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings[ct] = mEnv->GetStringUTFChars(s, NULL); 6698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray[ct] = mEnv->GetStringUTFLength(s); 6798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 6898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 6998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ~AutoJavaStringArrayToUTF8() { 7198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for (jsize ct=0; ct < mStringsLength; ct++) { 7298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct); 7398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mEnv->ReleaseStringUTFChars(s, mCStrings[ct]); 7498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(mCStrings); 7698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(mSizeArray); 7798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **c_str() const { return mCStrings; } 7998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *c_str_len() const { return mSizeArray; } 8098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length() const { return mStringsLength; } 8198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 8298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsprivate: 8398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv *mEnv; 8498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jobjectArray mStrings; 8598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **mCStrings; 8698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *mSizeArray; 8798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize mStringsLength; 8898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 8998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 9198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 9398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextFinish(JNIEnv *_env, jobject _this, RsContext con) 9498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 9598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextFinish, con(%p)", con); 9698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextFinish(con); 9798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 9898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 10098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnObjDestroy(JNIEnv *_env, jobject _this, RsContext con, jint obj) 10198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 10298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nObjDestroy, con(%p) obj(%p)", con, (void *)obj); 10398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsObjDestroy(con, (void *)obj); 10498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 10598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 10798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 10998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceCreate(JNIEnv *_env, jobject _this) 11098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 11198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceCreate"); 11298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsDeviceCreate(); 11398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 11498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 11598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 11698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceDestroy(JNIEnv *_env, jobject _this, jint dev) 11798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 11898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceDestroy"); 11998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return rsDeviceDestroy((RsDevice)dev); 12098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 12198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 12298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 12398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceSetConfig(JNIEnv *_env, jobject _this, jint dev, jint p, jint value) 12498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 12598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value); 12698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return rsDeviceSetConfig((RsDevice)dev, (RsDeviceParam)p, value); 12798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 12898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 12998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 130f681be1f0ec328acaa311478887352a456d52be8Jason SamsnContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer, jint ct) 13198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 13298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextCreate"); 13333841c8333bce105d65aba5590fa5e325c517a81Tim Murray return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer, (RsContextType)ct, 0); 13498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 13598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 13698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 13798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 13898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextSetPriority(JNIEnv *_env, jobject _this, RsContext con, jint p) 13998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 14098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("ContextSetPriority, con(%p), priority(%i)", con, p); 14198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextSetPriority(con, p); 14298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 14398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 14498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 14598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 14698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 14798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextDestroy(JNIEnv *_env, jobject _this, RsContext con) 14898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 14998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDestroy, con(%p)", con); 15098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDestroy(con); 15198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 15298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 15398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 15498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextDump(JNIEnv *_env, jobject _this, RsContext con, jint bits) 15598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 15698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDump, con(%p) bits(%i)", (RsContext)con, bits); 15798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDump((RsContext)con, bits); 15898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 15998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jstring 16298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextGetErrorMessage(JNIEnv *_env, jobject _this, RsContext con) 16398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 16498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextGetErrorMessage, con(%p)", con); 16598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams char buf[1024]; 16698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 16898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 16998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextGetMessage(con, 17098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams buf, sizeof(buf), 17198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &receiveLen, sizeof(receiveLen), 17298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 17398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!id && receiveLen) { 1744c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, 1754c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // "message receive buffer too small. %zu", receiveLen); 17698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 17798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return _env->NewStringUTF(buf); 17898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 17998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 18098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 18198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextGetUserMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray data) 18298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 18398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 18498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextGetMessage, con(%p), len(%i)", con, len); 18598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 18698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 18798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 18898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextGetMessage(con, 18998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ptr, len * 4, 19098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &receiveLen, sizeof(receiveLen), 19198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 19298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!id && receiveLen) { 1934c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, 1944c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // "message receive buffer too small. %zu", receiveLen); 19598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 19698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, 0); 19798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 19898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 19998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 20098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 20198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextPeekMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray auxData) 20298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 20398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextPeekMessage, con(%p)", con); 20498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *auxDataPtr = _env->GetIntArrayElements(auxData, NULL); 20598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 20698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 20798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextPeekMessage(con, &receiveLen, sizeof(receiveLen), 20898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 20998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams auxDataPtr[0] = (jint)subID; 21098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams auxDataPtr[1] = (jint)receiveLen; 21198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(auxData, auxDataPtr, 0); 21298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 21398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 21498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 21598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void nContextInitToClient(JNIEnv *_env, jobject _this, RsContext con) 21698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 21798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextInitToClient, con(%p)", con); 21898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextInitToClient(con); 21998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 22098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 22198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void nContextDeinitToClient(JNIEnv *_env, jobject _this, RsContext con) 22298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 22398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDeinitToClient, con(%p)", con); 22498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDeinitToClient(con); 22598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 22698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 2272da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hinesstatic void 2282da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen HinesnContextSendMessage(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArray data) 2292da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{ 2302da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint *ptr = NULL; 2312da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint len = 0; 2322da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines if (data) { 2332da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines len = _env->GetArrayLength(data); 2342da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint *ptr = _env->GetIntArrayElements(data, NULL); 2352da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines } 2362da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines LOG_API("nContextSendMessage, con(%p), id(%i), len(%i)", con, id, len); 2372da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines rsContextSendMessage(con, id, (const uint8_t *)ptr, len * sizeof(int)); 2382da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines if (data) { 2392da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 2402da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines } 2412da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines} 2422da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines 2432da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines 24498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 24598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 24698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementCreate(JNIEnv *_env, jobject _this, RsContext con, jint type, jint kind, jboolean norm, jint size) 24798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 24898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", con, type, kind, norm, size); 24998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsElementCreate(con, (RsDataType)type, (RsDataKind)kind, norm, size); 25098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 25198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 25298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 25398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementCreate2(JNIEnv *_env, jobject _this, RsContext con, 25498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _ids, jobjectArray _names, jintArray _arraySizes) 25598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 25698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int fieldCount = _env->GetArrayLength(_ids); 25798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementCreate2, con(%p)", con); 25898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 25998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ids = _env->GetIntArrayElements(_ids, NULL); 26098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *arraySizes = _env->GetIntArrayElements(_arraySizes, NULL); 26198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringArrayToUTF8 names(_env, _names, fieldCount); 26398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **nameArray = names.c_str(); 26598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *sizeArray = names.c_str_len(); 26698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint id = (jint)rsElementCreate2(con, 26898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsElement *)ids, fieldCount, 26998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams nameArray, fieldCount * sizeof(size_t), sizeArray, 27098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const uint32_t *)arraySizes, fieldCount); 27198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(_ids, ids, JNI_ABORT); 27398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(_arraySizes, arraySizes, JNI_ABORT); 27498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)id; 27598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 27698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 28098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementGetSubElements(JNIEnv *_env, jobject _this, RsContext con, jint id, 28198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _IDs, 28298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jobjectArray _names, 28398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _arraySizes) 28498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 28598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int dataSize = _env->GetArrayLength(_IDs); 28698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementGetSubElements, con(%p)", con); 28798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t *ids = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); 28998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **names = (const char **)malloc((uint32_t)dataSize * sizeof(const char *)); 29098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t *arraySizes = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); 29198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsaElementGetSubElements(con, (RsElement)id, ids, names, arraySizes, (uint32_t)dataSize); 29398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for(jint i = 0; i < dataSize; i++) { 29598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i])); 29698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetIntArrayRegion(_IDs, i, 1, (const jint*)&ids[i]); 29798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetIntArrayRegion(_arraySizes, i, 1, (const jint*)&arraySizes[i]); 29898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 29998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 30098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(ids); 30198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(names); 30298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(arraySizes); 30398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 30498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 30598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 30698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 30798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 30898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid, 3099fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv) 31098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 3119fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)", 3129fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams con, eid, dimx, dimy, dimz, mips, faces, yuv); 31398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3149fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv); 31598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)id; 31698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 31798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 31898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 31998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 32198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mips, jint usage, jint pointer) 32298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 32398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", con, (RsElement)type, mips, usage, (void *)pointer); 32498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint) rsAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uint32_t)pointer); 32598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 32698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 32898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits) 32998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 33098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", con, (RsAllocation)a, bits); 33198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits); 33298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 33398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 33498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 33598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, RsContext con, jint alloc) 33698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 33798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", con, (RsAllocation)alloc); 33898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationGenerateMipmaps(con, (RsAllocation)alloc); 33998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 34098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 34164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Samsstatic size_t GetBitmapSize(JNIEnv *env, jobject jbitmap) { 34264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 34364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 34464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(env, jbitmap, &info); 34564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams size_t s = info.width * info.height; 34664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams switch (info.format) { 34764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGBA_8888: s *= 4; break; 34864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGB_565: s *= 2; break; 34964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGBA_4444: s *= 2; break; 35064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 35164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams return s; 35264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams} 35364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 35498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 35598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 35698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 3570f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines jint id = 0; 3580f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines void *pixels = NULL; 3590f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 36064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 3610f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines if (pixels != NULL) { 3620f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines id = (jint)rsAllocationCreateFromBitmap(con, 3630f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines (RsType)type, (RsAllocationMipmapControl)mip, 3640f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines pixels, GetBitmapSize(_env, jbitmap), usage); 3650f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines AndroidBitmap_unlockPixels(_env, jbitmap); 3660f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines } 367c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray return id; 368c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray} 369c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray 370c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murraystatic int 371c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim MurraynAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 372c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray{ 3730f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines jint id = 0; 3740f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines void *pixels = NULL; 3750f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 376c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray 3770f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines if (pixels != NULL) { 3780f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines id = (jint)rsAllocationCreateTyped(con, 3790f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines (RsType)type, (RsAllocationMipmapControl)mip, 3800f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines (uint32_t)usage, (uintptr_t)pixels); 3810f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines AndroidBitmap_unlockPixels(_env, jbitmap); 3820f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines } 38398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 38498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 38598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 38698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 38798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 38898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 38964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 39064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 39164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 39264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams jint id = 0; 39364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 39464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams id = (jint)rsAllocationCubeCreateFromBitmap(con, 39564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams (RsType)type, (RsAllocationMipmapControl)mip, 39664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams pixels, GetBitmapSize(_env, jbitmap), usage); 39764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 39864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 39998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 40098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 40198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 40298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 40398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) 40498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 40564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 40664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 40764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(_env, jbitmap, &info); 40864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 40964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 41064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 41164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 41264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 41364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams rsAllocation2DData(con, (RsAllocation)alloc, 0, 0, 41464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, 4151b370e358d16cc3b50b169511d6b387db09f972dJason Sams info.width, info.height, pixels, GetBitmapSize(_env, jbitmap), 0); 41664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 41764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 41898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 41998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 42098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 42198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) 42298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 42364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 42464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 42564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(_env, jbitmap, &info); 42698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 42764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 42864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 42964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 43064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 43164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams rsAllocationCopyToBitmap(con, (RsAllocation)alloc, pixels, GetBitmapSize(_env, jbitmap)); 43264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 43364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 43464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams //bitmap.notifyPixelsChanged(); 43598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 43698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 43798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 43898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 43998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jintArray data, int sizeBytes) 44098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 44198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 44298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 44398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 44498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 44598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 44698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 44798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 44898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 44998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jshortArray data, int sizeBytes) 45098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 45198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 45298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_s, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 45398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 45498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 45598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 45698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 45798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 45898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 45998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jbyteArray data, int sizeBytes) 46098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 46198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 46298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_b, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 46398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 46498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 46598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 46698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 46798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 46898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 46998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jfloatArray data, int sizeBytes) 47098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 47198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 47298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 47398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 47498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 47598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 47698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 47798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 47898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 47998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// native void rsnAllocationElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); 48098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationElementData1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint compIdx, jbyteArray data, int sizeBytes) 48198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 48298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 48398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes); 48498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 48598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DElementData(con, (RsAllocation)alloc, offset, lod, ptr, sizeBytes, compIdx); 48698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 48798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 48898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 48998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 49098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 49198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jshortArray data, int sizeBytes) 49298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 49398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 49498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 49598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 4961b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 49798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 49898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 49998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 50098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 50198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 50298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jbyteArray data, int sizeBytes) 50398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 50498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 50598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 50698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 5071b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 50898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 50998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 51098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 51198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 51298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 51398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jintArray data, int sizeBytes) 51498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 51598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 51698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 51798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 5181b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 51998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 52098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 52198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 52298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 52398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 52498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jfloatArray data, int sizeBytes) 52598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 52698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 52798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 52898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 5291b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 53098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 53198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 53298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 53398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 53498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_alloc(JNIEnv *_env, jobject _this, RsContext con, 53598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dstAlloc, jint dstXoff, jint dstYoff, 53698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dstMip, jint dstFace, 53798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint width, jint height, 53898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint srcAlloc, jint srcXoff, jint srcYoff, 53998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint srcMip, jint srcFace) 54098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 54198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," 54298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams " dstMip(%i), dstFace(%i), width(%i), height(%i)," 54398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", 54498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, 54598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); 54698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 54798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationCopy2DRange(con, 54898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsAllocation)dstAlloc, 54998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams dstXoff, dstYoff, 55098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams dstMip, dstFace, 55198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams width, height, 55298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsAllocation)srcAlloc, 55398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams srcXoff, srcYoff, 55498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams srcMip, srcFace); 55598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 55698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 55798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 55837ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason SamsnAllocationData3D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod, 55937ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint w, jint h, jint d, jshortArray data, int sizeBytes) 56037ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{ 56137ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint len = _env->GetArrayLength(data); 56237ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams LOG_API("nAllocation3DData_s, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len); 56337ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 56437ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0); 56537ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 56637ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams} 56737ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams 56837ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Samsstatic void 56937ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason SamsnAllocationData3D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod, 57037ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint w, jint h, jint d, jbyteArray data, int sizeBytes) 57137ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{ 57237ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint len = _env->GetArrayLength(data); 57337ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams LOG_API("nAllocation3DData_b, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len); 57437ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 57537ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0); 57637ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 57737ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams} 57837ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams 57937ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Samsstatic void 58037ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason SamsnAllocationData3D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod, 58137ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint w, jint h, jint d, jintArray data, int sizeBytes) 58237ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{ 58337ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint len = _env->GetArrayLength(data); 58437ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams LOG_API("nAllocation3DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len); 58537ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 58637ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0); 58737ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 58837ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams} 58937ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams 59037ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Samsstatic void 59137ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason SamsnAllocationData3D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint zoff, jint lod, 59237ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint w, jint h, jint d, jfloatArray data, int sizeBytes) 59337ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{ 59437ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint len = _env->GetArrayLength(data); 59537ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams LOG_API("nAllocation3DData_f, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, zoff, w, h, d, len); 59637ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 59737ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams rsAllocation3DData(con, (RsAllocation)alloc, xoff, yoff, zoff, lod, w, h, d, ptr, sizeBytes, 0); 59837ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 59937ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams} 60037ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams 60137ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Samsstatic void 60237ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason SamsnAllocationData3D_alloc(JNIEnv *_env, jobject _this, RsContext con, 60337ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint dstAlloc, jint dstXoff, jint dstYoff, jint dstZoff, 60437ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint dstMip, 60537ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint width, jint height, jint depth, 60637ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint srcAlloc, jint srcXoff, jint srcYoff, jint srcZoff, 60737ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams jint srcMip) 60837ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{ 60937ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams LOG_API("nAllocationData3D_alloc, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," 61037ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams " dstMip(%i), width(%i), height(%i)," 61137ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i)", 61237ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, 61337ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); 61437ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams 61537ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams rsAllocationCopy3DRange(con, 61637ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams (RsAllocation)dstAlloc, 61737ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams dstXoff, dstYoff, dstZoff, dstMip, 61837ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams width, height, depth, 61937ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams (RsAllocation)srcAlloc, 62037ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams srcXoff, srcYoff, srcZoff, srcMip); 62137ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams} 62237ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams 62337ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Samsstatic void 62498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintArray data) 62598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 62698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 62798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 62898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 62998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 63098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(int)); 63198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, 0); 63298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 63398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 63498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 63598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jshortArray data) 63698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 63798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 63898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 63998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 64098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 64198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(short)); 64298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, 0); 64398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 64498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 64598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 64698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jbyteArray data) 64798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 64898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 64998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 65098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 65198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 65298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(char)); 65398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, 0); 65498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 65598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 65698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 65798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jfloatArray data) 65898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 65998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 66098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_f, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 66198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 66298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 66398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(float)); 66498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, 0); 66598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 66698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 66798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 66898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationGetType(JNIEnv *_env, jobject _this, RsContext con, jint a) 66998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 67098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationGetType, con(%p), a(%p)", con, (RsAllocation)a); 67198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint) rsaAllocationGetType(con, (RsAllocation)a); 67298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 67398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 67498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 67598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationResize1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX) 67698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 67798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", con, (RsAllocation)alloc, dimX); 67898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationResize1D(con, (RsAllocation)alloc, dimX); 67998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 68098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 68198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 68298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 68398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 68498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptBindAllocation(JNIEnv *_env, jobject _this, RsContext con, jint script, jint alloc, jint slot) 68598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 68698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", con, (RsScript)script, (RsAllocation)alloc, slot); 68798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptBindAllocation(con, (RsScript)script, (RsAllocation)alloc, slot); 68898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 68998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 69098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 69198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarI(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val) 69298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 69398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val); 69498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarI(con, (RsScript)script, slot, val); 69598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 69698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 69798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 69898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarObj(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val) 69998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 70098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val); 70198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarObj(con, (RsScript)script, slot, (RsObjectBase)val); 70298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 70398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 70498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 70598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jlong val) 70698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 70798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", con, (void *)script, slot, val); 70898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarJ(con, (RsScript)script, slot, val); 70998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 71098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 71198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 71298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, float val) 71398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 71498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", con, (void *)script, slot, val); 71598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarF(con, (RsScript)script, slot, val); 71698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 71798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 71898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 71998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarD(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, double val) 72098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 72198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", con, (void *)script, slot, val); 72298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarD(con, (RsScript)script, slot, val); 72398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 72498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 72598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 72698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data) 72798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 72898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 72998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 73098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 73198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarV(con, (RsScript)script, slot, ptr, len); 73298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 73398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 73498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 73598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 73698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarVE(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data, jint elem, jintArray dims) 73798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 73898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarVE, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 73998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 74098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 74198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dimsLen = _env->GetArrayLength(dims) * sizeof(int); 74298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *dimsPtr = _env->GetIntArrayElements(dims, NULL); 74398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarVE(con, (RsScript)script, slot, ptr, len, (RsElement)elem, 744eedc6b244cd80923757b46b8929a846ee33e4bddStephen Hines (const uint32_t *)dimsPtr, dimsLen); 74598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 74698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(dims, dimsPtr, JNI_ABORT); 74798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 74898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 74998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 75098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 75198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetTimeZone(JNIEnv *_env, jobject _this, RsContext con, jint script, jbyteArray timeZone) 75298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 75398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, (void *)script, (const char *)timeZone); 75498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 75598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint length = _env->GetArrayLength(timeZone); 75698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte* timeZone_ptr; 75798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0); 75898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 75998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetTimeZone(con, (RsScript)script, (const char *)timeZone_ptr, length); 76098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 76198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (timeZone_ptr) { 76298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0); 76398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 76498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 76598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 76698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 76798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptInvoke(JNIEnv *_env, jobject _this, RsContext con, jint obj, jint slot) 76898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 76998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptInvoke, con(%p), script(%p)", con, (void *)obj); 77098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptInvoke(con, (RsScript)obj, slot); 77198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 77298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 77398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 77498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptInvokeV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data) 77598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 77698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 77798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 77898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 77998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptInvokeV(con, (RsScript)script, slot, ptr, len); 78098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 78198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 78298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 78398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 78498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptForEach(JNIEnv *_env, jobject _this, RsContext con, 78598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint script, jint slot, jint ain, jint aout) 78698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 78798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 788be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, NULL, 0); 78998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 79098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 79198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptForEachV(JNIEnv *_env, jobject _this, RsContext con, 79298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint script, jint slot, jint ain, jint aout, jbyteArray params) 79398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 79498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 79598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(params); 79698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(params, NULL); 797be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, NULL, 0); 798be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT); 799be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray} 800be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray 801be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murraystatic void 802be995a8c3431dd87ca8877f56d922689eea35ac1Tim MurraynScriptForEachClipped(JNIEnv *_env, jobject _this, RsContext con, 803be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray jint script, jint slot, jint ain, jint aout, 8042da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint xstart, jint xend, 805be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray jint ystart, jint yend, jint zstart, jint zend) 806be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray{ 807be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 8082da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines RsScriptCall sc; 8092da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.xStart = xstart; 8102da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.xEnd = xend; 8112da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.yStart = ystart; 8122da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.yEnd = yend; 8132da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.zStart = zstart; 8142da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.zEnd = zend; 8152da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE; 8162da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.arrayStart = 0; 8172da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.arrayEnd = 0; 8182da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc)); 8192da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines} 8202da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines 8212da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hinesstatic void 8222da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen HinesnScriptForEachClippedV(JNIEnv *_env, jobject _this, RsContext con, 8232da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint script, jint slot, jint ain, jint aout, 8242da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jbyteArray params, jint xstart, jint xend, 8252da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint ystart, jint yend, jint zstart, jint zend) 8262da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{ 8272da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 828be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray jint len = _env->GetArrayLength(params); 829be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray jbyte *ptr = _env->GetByteArrayElements(params, NULL); 830be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray RsScriptCall sc; 831be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.xStart = xstart; 832be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.xEnd = xend; 833be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.yStart = ystart; 834be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.yEnd = yend; 835be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.zStart = zstart; 836be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.zEnd = zend; 837be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE; 838be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.arrayStart = 0; 839be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.arrayEnd = 0; 840be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, &sc, sizeof(sc)); 84198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT); 84298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 84398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 84498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 84598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 84698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 84798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptCCreate(JNIEnv *_env, jobject _this, RsContext con, 84898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring resName, jstring cacheDir, 84998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyteArray scriptRef, jint length) 85098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 85198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptCCreate, con(%p)", con); 85298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 85398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8 resNameUTF(_env, resName); 85498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir); 85598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint ret = 0; 85698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte* script_ptr = NULL; 85798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint _exception = 0; 85898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint remaining; 85998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!scriptRef) { 86098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 86198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", "script == null"); 86298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 86398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 86498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (length < 0) { 86598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 86698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", "length < 0"); 86798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 86898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 86998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams remaining = _env->GetArrayLength(scriptRef); 87098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (remaining < length) { 87198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 87298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", 87398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams // "length > script.length - offset"); 87498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 87598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 87698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams script_ptr = (jbyte *) 87798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0); 87898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 87998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //rsScriptCSetText(con, (const char *)script_ptr, length); 88098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 88198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ret = (jint)rsScriptCCreate(con, 88298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams resNameUTF.c_str(), resNameUTF.length(), 88398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams cacheDirUTF.c_str(), cacheDirUTF.length(), 88498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const char *)script_ptr, length); 88598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 88698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsexit: 88798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (script_ptr) { 88898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleasePrimitiveArrayCritical(scriptRef, script_ptr, 88998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception ? JNI_ABORT: 0); 89098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 89198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 89298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return ret; 89398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 89498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 8951b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 8961b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptIntrinsicCreate(JNIEnv *_env, jobject _this, RsContext con, jint id, jint eid) 8971b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8981b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", con, id, (void *)eid); 8991b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptIntrinsicCreate(con, id, (RsElement)eid); 9001b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9011b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9021b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 9031b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptKernelIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot, jint sig) 9041b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9051b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", con, (void *)sid, slot, sig); 9061b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptKernelIDCreate(con, (RsScript)sid, slot, sig); 9071b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9081b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9091b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 9101b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptFieldIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot) 9111b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9121b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", con, (void *)sid, slot); 9131b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptFieldIDCreate(con, (RsScript)sid, slot); 9141b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9151b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9161b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 9171b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupCreate(JNIEnv *_env, jobject _this, RsContext con, jintArray _kernels, jintArray _src, 9181b370e358d16cc3b50b169511d6b387db09f972dJason Sams jintArray _dstk, jintArray _dstf, jintArray _types) 9191b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9201b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupCreate, con(%p)", con); 9211b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9221b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint kernelsLen = _env->GetArrayLength(_kernels) * sizeof(int); 9231b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *kernelsPtr = _env->GetIntArrayElements(_kernels, NULL); 9241b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint srcLen = _env->GetArrayLength(_src) * sizeof(int); 9251b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *srcPtr = _env->GetIntArrayElements(_src, NULL); 9261b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint dstkLen = _env->GetArrayLength(_dstk) * sizeof(int); 9271b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *dstkPtr = _env->GetIntArrayElements(_dstk, NULL); 9281b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint dstfLen = _env->GetArrayLength(_dstf) * sizeof(int); 9291b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *dstfPtr = _env->GetIntArrayElements(_dstf, NULL); 9301b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint typesLen = _env->GetArrayLength(_types) * sizeof(int); 9311b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *typesPtr = _env->GetIntArrayElements(_types, NULL); 9321b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9331b370e358d16cc3b50b169511d6b387db09f972dJason Sams int id = (int)rsScriptGroupCreate(con, 9341b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)kernelsPtr, kernelsLen, 9351b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)srcPtr, srcLen, 9361b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)dstkPtr, dstkLen, 9371b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptFieldID *)dstfPtr, dstfLen, 9381b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsType *)typesPtr, typesLen); 9391b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9401b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_kernels, kernelsPtr, 0); 9411b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_src, srcPtr, 0); 9421b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_dstk, dstkPtr, 0); 9431b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_dstf, dstfPtr, 0); 9441b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_types, typesPtr, 0); 9451b370e358d16cc3b50b169511d6b387db09f972dJason Sams return id; 9461b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9471b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9481b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 9491b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupSetInput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc) 9501b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9511b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", con, 9521b370e358d16cc3b50b169511d6b387db09f972dJason Sams (void *)gid, (void *)kid, (void *)alloc); 9531b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupSetInput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); 9541b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9551b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9561b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 9571b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupSetOutput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc) 9581b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9591b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", con, 9601b370e358d16cc3b50b169511d6b387db09f972dJason Sams (void *)gid, (void *)kid, (void *)alloc); 9611b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupSetOutput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); 9621b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9631b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9641b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 9651b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupExecute(JNIEnv *_env, jobject _this, RsContext con, jint gid) 9661b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9671b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetOutput, con(%p) group(%p)", con, (void *)gid); 9681b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupExecute(con, (RsScriptGroup)gid); 9691b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9701b370e358d16cc3b50b169511d6b387db09f972dJason Sams 97198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 97298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 97398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 97498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnSamplerCreate(JNIEnv *_env, jobject _this, RsContext con, jint magFilter, jint minFilter, 97598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint wrapS, jint wrapT, jint wrapR, jfloat aniso) 97698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 97798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nSamplerCreate, con(%p)", con); 97898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsSamplerCreate(con, 97998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)magFilter, 98098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)minFilter, 98198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapS, 98298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapT, 98398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapR, 98498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams aniso); 98598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 98698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 98798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 98898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 98998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 99098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic const char *classPathName = "android/support/v8/renderscript/RenderScript"; 99198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 99298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic JNINativeMethod methods[] = { 99398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceCreate", "()I", (void*)nDeviceCreate }, 99498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, 99598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig }, 99698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextGetUserMessage", "(I[I)I", (void*)nContextGetUserMessage }, 99798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextGetErrorMessage", "(I)Ljava/lang/String;", (void*)nContextGetErrorMessage }, 99898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextPeekMessage", "(I[I)I", (void*)nContextPeekMessage }, 99998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 100098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextInitToClient", "(I)V", (void*)nContextInitToClient }, 100198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextDeinitToClient", "(I)V", (void*)nContextDeinitToClient }, 100298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 100398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 100498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// All methods below are thread protected in java. 1005f681be1f0ec328acaa311478887352a456d52be8Jason Sams{"rsnContextCreate", "(IIII)I", (void*)nContextCreate }, 100698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextFinish", "(I)V", (void*)nContextFinish }, 100798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority }, 100898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextDestroy", "(I)V", (void*)nContextDestroy }, 100998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextDump", "(II)V", (void*)nContextDump }, 10102da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{"rsnContextSendMessage", "(II[I)V", (void*)nContextSendMessage }, 101198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnObjDestroy", "(II)V", (void*)nObjDestroy }, 101298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 101398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementCreate", "(IIIZI)I", (void*)nElementCreate }, 101498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementCreate2", "(I[I[Ljava/lang/String;[I)I", (void*)nElementCreate2 }, 101598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;[I)V", (void*)nElementGetSubElements }, 101698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10179fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams{"rsnTypeCreate", "(IIIIIZZI)I", (void*)nTypeCreate }, 101898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 101998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCreateTyped", "(IIIII)I", (void*)nAllocationCreateTyped }, 102098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap }, 1021c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray{"rsnAllocationCreateBitmapBackedAllocation", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateBitmapBackedAllocation }, 102298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap }, 102398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 102498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, 102598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCopyToBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap }, 102698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 102798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, 102898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[II)V", (void*)nAllocationData1D_i }, 102998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[SI)V", (void*)nAllocationData1D_s }, 103098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[BI)V", (void*)nAllocationData1D_b }, 103198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[FI)V", (void*)nAllocationData1D_f }, 103298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationElementData1D", "(IIIII[BI)V", (void*)nAllocationElementData1D }, 103398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[II)V", (void*)nAllocationData2D_i }, 103498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[SI)V", (void*)nAllocationData2D_s }, 103598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[BI)V", (void*)nAllocationData2D_b }, 103698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f }, 103798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIIIIIIII)V", (void*)nAllocationData2D_alloc }, 103837ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{"rsnAllocationData3D", "(IIIIIIIII[II)V", (void*)nAllocationData3D_i }, 103937ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{"rsnAllocationData3D", "(IIIIIIIII[SI)V", (void*)nAllocationData3D_s }, 104037ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{"rsnAllocationData3D", "(IIIIIIIII[BI)V", (void*)nAllocationData3D_b }, 104137ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{"rsnAllocationData3D", "(IIIIIIIII[FI)V", (void*)nAllocationData3D_f }, 104237ead9e1087bd091b52867d97cd7c2dd7b3f3a39Jason Sams{"rsnAllocationData3D", "(IIIIIIIIIIIIII)V", (void*)nAllocationData3D_alloc }, 104398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i }, 104498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[S)V", (void*)nAllocationRead_s }, 104598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[B)V", (void*)nAllocationRead_b }, 104698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[F)V", (void*)nAllocationRead_f }, 104798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationGetType", "(II)I", (void*)nAllocationGetType}, 104898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationResize1D", "(III)V", (void*)nAllocationResize1D }, 104998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationGenerateMipmaps", "(II)V", (void*)nAllocationGenerateMipmaps }, 105098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 105198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptBindAllocation", "(IIII)V", (void*)nScriptBindAllocation }, 105298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetTimeZone", "(II[B)V", (void*)nScriptSetTimeZone }, 105398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptInvoke", "(III)V", (void*)nScriptInvoke }, 105498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptInvokeV", "(III[B)V", (void*)nScriptInvokeV }, 105598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptForEach", "(IIIII)V", (void*)nScriptForEach }, 105698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptForEach", "(IIIII[B)V", (void*)nScriptForEachV }, 10572da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{"rsnScriptForEachClipped", "(IIIIIIIIIII)V", (void*)nScriptForEachClipped }, 10582da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{"rsnScriptForEachClipped", "(IIIII[BIIIIII)V", (void*)nScriptForEachClippedV }, 105998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarI", "(IIII)V", (void*)nScriptSetVarI }, 106098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarJ", "(IIIJ)V", (void*)nScriptSetVarJ }, 106198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF }, 106298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarD", "(IIID)V", (void*)nScriptSetVarD }, 106398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarV", "(III[B)V", (void*)nScriptSetVarV }, 106498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarVE", "(III[BI[I)V", (void*)nScriptSetVarVE }, 106598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarObj", "(IIII)V", (void*)nScriptSetVarObj }, 106698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 106798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptCCreate", "(ILjava/lang/String;Ljava/lang/String;[BI)I", (void*)nScriptCCreate }, 10681b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptIntrinsicCreate", "(III)I", (void*)nScriptIntrinsicCreate }, 10691b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptKernelIDCreate", "(IIII)I", (void*)nScriptKernelIDCreate }, 10701b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptFieldIDCreate", "(III)I", (void*)nScriptFieldIDCreate }, 10711b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupCreate", "(I[I[I[I[I[I)I", (void*)nScriptGroupCreate }, 10721b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupSetInput", "(IIII)V", (void*)nScriptGroupSetInput }, 10731b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupSetOutput", "(IIII)V", (void*)nScriptGroupSetOutput }, 10741b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupExecute", "(II)V", (void*)nScriptGroupExecute }, 107598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 107698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnSamplerCreate", "(IIIIIIF)I", (void*)nSamplerCreate }, 107798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 107898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 107998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 108098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 108198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 108298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsjint JNI_OnLoad(JavaVM* vm, void* reserved) 108398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 108498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv* env = NULL; 10850f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines jclass clazz = NULL; 108698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint result = -1; 108798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 108898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { 10894c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, 10904c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // "ERROR: GetEnv failed\n"); 10910f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines goto bail; 10920f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines } 10930f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines if (env == NULL) { 10944c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "ERROR: env == NULL"); 10950f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines goto bail; 10960f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines } 10970f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines 10980f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines clazz = env->FindClass(classPathName); 10990f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines if (clazz == NULL) { 110098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto bail; 110198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 110298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 11030f5bae87e2e3e3b0e66803122b5c4c7dd36d43ddStephen Hines if (env->RegisterNatives(clazz, methods, NELEM(methods)) < 0) { 11044c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, 11054c3f90a3aaf733956e99c99e4e41c0a555e651b1Tim Murray // "ERROR: MediaPlayer native registration failed\n"); 110698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto bail; 110798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 110898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 110998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams /* success -- return valid version number */ 111098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams result = JNI_VERSION_1_4; 111198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 111298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsbail: 111398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return result; 111498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 1115