android_renderscript_RenderScript.cpp revision 2da197aafb9325a3ec5e546c4a15b73ce592c0b9
198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams/* 298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Copyright (C) 2011-2012 The Android Open Source Project 398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Licensed under the Apache License, Version 2.0 (the "License"); 598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * you may not use this file except in compliance with the License. 698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * You may obtain a copy of the License at 798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * http://www.apache.org/licenses/LICENSE-2.0 998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * 1098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * Unless required by applicable law or agreed to in writing, software 1198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * distributed under the License is distributed on an "AS IS" BASIS, 1298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * See the License for the specific language governing permissions and 1498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams * limitations under the License. 1598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams */ 1698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 1798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#define LOG_TAG "libRS_jni" 1898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 1998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <stdlib.h> 2098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <stdio.h> 2198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <fcntl.h> 2298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <unistd.h> 2398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <math.h> 2498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <utils/misc.h> 2564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams#include <android/bitmap.h> 2698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include "jni.h" 2798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include "JNIHelp.h" 2898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include "android_runtime/AndroidRuntime.h" 2998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <rs.h> 3098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#include <rsEnv.h> 3198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray#include <core/SkBitmap.h> 33c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray#include <core/SkPixelRef.h> 34c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray#include <core/SkStream.h> 35c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray#include <core/SkTemplates.h> 36c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray//#include <images/SkImageDecoder.h> 37c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray 3898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams//#define LOG_API ALOG 3998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams#define LOG_API(...) 4098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 4198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsusing namespace android; 4298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 4398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsclass AutoJavaStringToUTF8 { 4498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samspublic: 4598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8(JNIEnv* env, jstring str) : fEnv(env), fJStr(str) { 4698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fCStr = env->GetStringUTFChars(str, NULL); 4798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fLength = env->GetStringUTFLength(str); 4898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 4998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ~AutoJavaStringToUTF8() { 5098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams fEnv->ReleaseStringUTFChars(fJStr, fCStr); 5198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 5298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char* c_str() const { return fCStr; } 5398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length() const { return fLength; } 5498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 5598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsprivate: 5698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv* fEnv; 5798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring fJStr; 5898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char* fCStr; 5998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize fLength; 6098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 6198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 6298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsclass AutoJavaStringArrayToUTF8 { 6398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samspublic: 6498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringArrayToUTF8(JNIEnv* env, jobjectArray strings, jsize stringsLength) 6598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams : mEnv(env), mStrings(strings), mStringsLength(stringsLength) { 6698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings = NULL; 6798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray = NULL; 6898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (stringsLength > 0) { 6998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings = (const char **)calloc(stringsLength, sizeof(char *)); 7098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray = (size_t*)calloc(stringsLength, sizeof(size_t)); 7198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for (jsize ct = 0; ct < stringsLength; ct ++) { 7298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct); 7398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mCStrings[ct] = mEnv->GetStringUTFChars(s, NULL); 7498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mSizeArray[ct] = mEnv->GetStringUTFLength(s); 7598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 7898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ~AutoJavaStringArrayToUTF8() { 7998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for (jsize ct=0; ct < mStringsLength; ct++) { 8098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring s = (jstring)mEnv->GetObjectArrayElement(mStrings, ct); 8198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams mEnv->ReleaseStringUTFChars(s, mCStrings[ct]); 8298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 8398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(mCStrings); 8498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(mSizeArray); 8598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 8698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **c_str() const { return mCStrings; } 8798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *c_str_len() const { return mSizeArray; } 8898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length() const { return mStringsLength; } 8998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsprivate: 9198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv *mEnv; 9298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jobjectArray mStrings; 9398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **mCStrings; 9498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *mSizeArray; 9598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize mStringsLength; 9698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 9798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 9998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jfieldID gContextId = 0; 10198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jfieldID gNativeBitmapID = 0; 10298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jfieldID gTypeNativeCache = 0; 10398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void _nInit(JNIEnv *_env, jclass _this) 10598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 10698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams gContextId = _env->GetFieldID(_this, "mContext", "I"); 10798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 10898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jclass bitmapClass = _env->FindClass("android/graphics/Bitmap"); 10998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "I"); 11098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 11198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 11298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 11398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 11498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 11598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextFinish(JNIEnv *_env, jobject _this, RsContext con) 11698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 11798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextFinish, con(%p)", con); 11898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextFinish(con); 11998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 12098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 12198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 12298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnObjDestroy(JNIEnv *_env, jobject _this, RsContext con, jint obj) 12398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 12498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nObjDestroy, con(%p) obj(%p)", con, (void *)obj); 12598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsObjDestroy(con, (void *)obj); 12698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 12798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 12898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 12998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 13098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 13198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceCreate(JNIEnv *_env, jobject _this) 13298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 13398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceCreate"); 13498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsDeviceCreate(); 13598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 13698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 13798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 13898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceDestroy(JNIEnv *_env, jobject _this, jint dev) 13998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 14098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceDestroy"); 14198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return rsDeviceDestroy((RsDevice)dev); 14298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 14398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 14498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 14598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnDeviceSetConfig(JNIEnv *_env, jobject _this, jint dev, jint p, jint value) 14698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 14798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nDeviceSetConfig dev(%p), param(%i), value(%i)", (void *)dev, p, value); 14898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return rsDeviceSetConfig((RsDevice)dev, (RsDeviceParam)p, value); 14998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 15098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 15198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 15298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextCreate(JNIEnv *_env, jobject _this, jint dev, jint ver, jint sdkVer) 15398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 15498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextCreate"); 15598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsContextCreate((RsDevice)dev, ver, sdkVer); 15698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 15798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 15898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 15998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 16098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextSetPriority(JNIEnv *_env, jobject _this, RsContext con, jint p) 16198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 16298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("ContextSetPriority, con(%p), priority(%i)", con, p); 16398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextSetPriority(con, p); 16498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 16598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 16898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 16998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextDestroy(JNIEnv *_env, jobject _this, RsContext con) 17098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 17198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDestroy, con(%p)", con); 17298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDestroy(con); 17398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 17498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 17598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 17698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextDump(JNIEnv *_env, jobject _this, RsContext con, jint bits) 17798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 17898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDump, con(%p) bits(%i)", (RsContext)con, bits); 17998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDump((RsContext)con, bits); 18098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 18198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 18298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 18398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jstring 18498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextGetErrorMessage(JNIEnv *_env, jobject _this, RsContext con) 18598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 18698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextGetErrorMessage, con(%p)", con); 18798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams char buf[1024]; 18898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 18998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 19098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 19198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextGetMessage(con, 19298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams buf, sizeof(buf), 19398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &receiveLen, sizeof(receiveLen), 19498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 19598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!id && receiveLen) { 19698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGV("message receive buffer too small. %i", receiveLen); 19798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 19898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return _env->NewStringUTF(buf); 19998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 20098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 20198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 20298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextGetUserMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray data) 20398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 20498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 20598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextGetMessage, con(%p), len(%i)", con, len); 20698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 20798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 20898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 20998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextGetMessage(con, 21098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ptr, len * 4, 21198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &receiveLen, sizeof(receiveLen), 21298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 21398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!id && receiveLen) { 21498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGV("message receive buffer too small. %i", receiveLen); 21598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 21698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, 0); 21798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 21898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 21998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 22098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 22198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnContextPeekMessage(JNIEnv *_env, jobject _this, RsContext con, jintArray auxData) 22298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 22398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextPeekMessage, con(%p)", con); 22498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *auxDataPtr = _env->GetIntArrayElements(auxData, NULL); 22598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t receiveLen; 22698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t subID; 22798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int id = rsContextPeekMessage(con, &receiveLen, sizeof(receiveLen), 22898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams &subID, sizeof(subID)); 22998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams auxDataPtr[0] = (jint)subID; 23098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams auxDataPtr[1] = (jint)receiveLen; 23198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(auxData, auxDataPtr, 0); 23298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 23398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 23498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 23598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void nContextInitToClient(JNIEnv *_env, jobject _this, RsContext con) 23698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 23798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextInitToClient, con(%p)", con); 23898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextInitToClient(con); 23998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 24098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 24198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void nContextDeinitToClient(JNIEnv *_env, jobject _this, RsContext con) 24298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 24398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nContextDeinitToClient, con(%p)", con); 24498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsContextDeinitToClient(con); 24598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 24698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 2472da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hinesstatic void 2482da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen HinesnContextSendMessage(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArray data) 2492da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{ 2502da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint *ptr = NULL; 2512da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint len = 0; 2522da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines if (data) { 2532da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines len = _env->GetArrayLength(data); 2542da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint *ptr = _env->GetIntArrayElements(data, NULL); 2552da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines } 2562da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines LOG_API("nContextSendMessage, con(%p), id(%i), len(%i)", con, id, len); 2572da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines rsContextSendMessage(con, id, (const uint8_t *)ptr, len * sizeof(int)); 2582da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines if (data) { 2592da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 2602da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines } 2612da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines} 2622da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines 2632da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines 26498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 26698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementCreate(JNIEnv *_env, jobject _this, RsContext con, jint type, jint kind, jboolean norm, jint size) 26798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 26898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", con, type, kind, norm, size); 26998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsElementCreate(con, (RsDataType)type, (RsDataKind)kind, norm, size); 27098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 27198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 27398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementCreate2(JNIEnv *_env, jobject _this, RsContext con, 27498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _ids, jobjectArray _names, jintArray _arraySizes) 27598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 27698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int fieldCount = _env->GetArrayLength(_ids); 27798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementCreate2, con(%p)", con); 27898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ids = _env->GetIntArrayElements(_ids, NULL); 28098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *arraySizes = _env->GetIntArrayElements(_arraySizes, NULL); 28198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringArrayToUTF8 names(_env, _names, fieldCount); 28398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **nameArray = names.c_str(); 28598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *sizeArray = names.c_str_len(); 28698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint id = (jint)rsElementCreate2(con, 28898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsElement *)ids, fieldCount, 28998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams nameArray, fieldCount * sizeof(size_t), sizeArray, 29098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const uint32_t *)arraySizes, fieldCount); 29198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(_ids, ids, JNI_ABORT); 29398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(_arraySizes, arraySizes, JNI_ABORT); 29498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)id; 29598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 29698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 30098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementGetSubElements(JNIEnv *_env, jobject _this, RsContext con, jint id, 30198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _IDs, 30298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jobjectArray _names, 30398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _arraySizes) 30498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 30598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int dataSize = _env->GetArrayLength(_IDs); 30698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementGetSubElements, con(%p)", con); 30798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 30898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t *ids = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); 30998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **names = (const char **)malloc((uint32_t)dataSize * sizeof(const char *)); 31098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t *arraySizes = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); 31198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 31298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsaElementGetSubElements(con, (RsElement)id, ids, names, arraySizes, (uint32_t)dataSize); 31398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 31498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for(jint i = 0; i < dataSize; i++) { 31598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i])); 31698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetIntArrayRegion(_IDs, i, 1, (const jint*)&ids[i]); 31798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetIntArrayRegion(_arraySizes, i, 1, (const jint*)&arraySizes[i]); 31898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 31998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(ids); 32198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(names); 32298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(arraySizes); 32398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 32498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 32698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 32898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid, 3299fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv) 33098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 3319fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)", 3329fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams con, eid, dimx, dimy, dimz, mips, faces, yuv); 33398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3349fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv); 33598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)id; 33698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 33798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 33898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 33998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 34098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 34198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mips, jint usage, jint pointer) 34298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 34398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", con, (RsElement)type, mips, usage, (void *)pointer); 34498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint) rsAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uint32_t)pointer); 34598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 34698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 34798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 34898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits) 34998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 35098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", con, (RsAllocation)a, bits); 35198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits); 35298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 35398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 35498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 35598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, RsContext con, jint alloc) 35698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 35798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", con, (RsAllocation)alloc); 35898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationGenerateMipmaps(con, (RsAllocation)alloc); 35998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 36098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 36164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Samsstatic size_t GetBitmapSize(JNIEnv *env, jobject jbitmap) { 36264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 36364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 36464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(env, jbitmap, &info); 36564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams size_t s = info.width * info.height; 36664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams switch (info.format) { 36764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGBA_8888: s *= 4; break; 36864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGB_565: s *= 2; break; 36964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGBA_4444: s *= 2; break; 37064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 37164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams return s; 37264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams} 37364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 37498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 37598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 37698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 377c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray SkBitmap const * nativeBitmap = 378c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); 379c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray const SkBitmap& bitmap(*nativeBitmap); 38064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 381c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray bitmap.lockPixels(); 382c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray const void* ptr = bitmap.getPixels(); 383c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray jint id = (jint)rsAllocationCreateFromBitmap(con, 384c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (RsType)type, (RsAllocationMipmapControl)mip, 385c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray ptr, bitmap.getSize(), usage); 386c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray bitmap.unlockPixels(); 387c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray return id; 388c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray} 389c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray 390c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murraystatic int 391c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim MurraynAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 392c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray{ 393c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray SkBitmap const * nativeBitmap = 394c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); 395c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray const SkBitmap& bitmap(*nativeBitmap); 396c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray 397c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray bitmap.lockPixels(); 398c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray const void* ptr = bitmap.getPixels(); 399c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray jint id = (jint)rsAllocationCreateTyped(con, 400c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (RsType)type, (RsAllocationMipmapControl)mip, 401c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (uint32_t)usage, (size_t)ptr); 402c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray bitmap.unlockPixels(); 40398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 40498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 40598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 40698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 40798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 40898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 40964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 41064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 41164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 41264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams jint id = 0; 41364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 41464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams id = (jint)rsAllocationCubeCreateFromBitmap(con, 41564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams (RsType)type, (RsAllocationMipmapControl)mip, 41664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams pixels, GetBitmapSize(_env, jbitmap), usage); 41764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 41864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 41998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 42098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 42198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 42298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 42398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) 42498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 42564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 42664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 42764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(_env, jbitmap, &info); 42864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 42964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 43064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 43164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 43264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 43364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams rsAllocation2DData(con, (RsAllocation)alloc, 0, 0, 43464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, 4351b370e358d16cc3b50b169511d6b387db09f972dJason Sams info.width, info.height, pixels, GetBitmapSize(_env, jbitmap), 0); 43664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 43764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 43898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 43998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 44098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 44198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) 44298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 44364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 44464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 44564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(_env, jbitmap, &info); 44698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 44764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 44864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 44964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 45064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 45164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams rsAllocationCopyToBitmap(con, (RsAllocation)alloc, pixels, GetBitmapSize(_env, jbitmap)); 45264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 45364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 45464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams //bitmap.notifyPixelsChanged(); 45598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 45698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 45798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 45898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 45998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jintArray data, int sizeBytes) 46098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 46198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 46298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 46398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 46498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 46598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 46698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 46798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 46898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 46998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jshortArray data, int sizeBytes) 47098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 47198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 47298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_s, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 47398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 47498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 47598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 47698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 47798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 47898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 47998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jbyteArray data, int sizeBytes) 48098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 48198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 48298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_b, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 48398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 48498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 48598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 48698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 48798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 48898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 48998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jfloatArray data, int sizeBytes) 49098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 49198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 49298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 49398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 49498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 49598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 49698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 49798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 49898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 49998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// native void rsnAllocationElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); 50098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationElementData1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint compIdx, jbyteArray data, int sizeBytes) 50198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 50298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 50398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes); 50498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 50598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DElementData(con, (RsAllocation)alloc, offset, lod, ptr, sizeBytes, compIdx); 50698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 50798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 50898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 50998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 51098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 51198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jshortArray data, int sizeBytes) 51298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 51398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 51498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 51598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 5161b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 51798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 51898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 51998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 52098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 52198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 52298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jbyteArray data, int sizeBytes) 52398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 52498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 52598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 52698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 5271b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 52898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 52998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 53098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 53198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 53298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 53398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jintArray data, int sizeBytes) 53498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 53598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 53698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 53798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 5381b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 53998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 54098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 54198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 54298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 54398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 54498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jfloatArray data, int sizeBytes) 54598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 54698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 54798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 54898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 5491b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 55098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 55198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 55298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 55398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 55498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_alloc(JNIEnv *_env, jobject _this, RsContext con, 55598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dstAlloc, jint dstXoff, jint dstYoff, 55698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dstMip, jint dstFace, 55798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint width, jint height, 55898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint srcAlloc, jint srcXoff, jint srcYoff, 55998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint srcMip, jint srcFace) 56098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 56198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," 56298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams " dstMip(%i), dstFace(%i), width(%i), height(%i)," 56398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", 56498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, 56598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); 56698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 56798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationCopy2DRange(con, 56898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsAllocation)dstAlloc, 56998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams dstXoff, dstYoff, 57098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams dstMip, dstFace, 57198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams width, height, 57298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsAllocation)srcAlloc, 57398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams srcXoff, srcYoff, 57498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams srcMip, srcFace); 57598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 57698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 57798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 57898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintArray data) 57998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 58098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 58198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 58298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 58398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 58498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(int)); 58598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, 0); 58698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 58798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 58898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 58998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jshortArray data) 59098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 59198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 59298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 59398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 59498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 59598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(short)); 59698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, 0); 59798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 59898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 59998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 60098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jbyteArray data) 60198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 60298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 60398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 60498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 60598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 60698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(char)); 60798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, 0); 60898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 60998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 61098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 61198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jfloatArray data) 61298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 61398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 61498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_f, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 61598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 61698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 61798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(float)); 61898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, 0); 61998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 62098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 62198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 62298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationGetType(JNIEnv *_env, jobject _this, RsContext con, jint a) 62398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 62498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationGetType, con(%p), a(%p)", con, (RsAllocation)a); 62598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint) rsaAllocationGetType(con, (RsAllocation)a); 62698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 62798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 62898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 62998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationResize1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX) 63098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 63198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", con, (RsAllocation)alloc, dimX); 63298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationResize1D(con, (RsAllocation)alloc, dimX); 63398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 63498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 63598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 63698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationResize2D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX, jint dimY) 63798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 63898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i), sizeY(%i)", con, (RsAllocation)alloc, dimX, dimY); 63998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationResize2D(con, (RsAllocation)alloc, dimX, dimY); 64098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 64198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 64298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 64398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 64498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 64598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptBindAllocation(JNIEnv *_env, jobject _this, RsContext con, jint script, jint alloc, jint slot) 64698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 64798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", con, (RsScript)script, (RsAllocation)alloc, slot); 64898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptBindAllocation(con, (RsScript)script, (RsAllocation)alloc, slot); 64998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 65098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 65198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 65298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarI(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val) 65398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 65498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val); 65598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarI(con, (RsScript)script, slot, val); 65698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 65798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 65898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 65998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarObj(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val) 66098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 66198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val); 66298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarObj(con, (RsScript)script, slot, (RsObjectBase)val); 66398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 66498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 66598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 66698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jlong val) 66798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 66898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", con, (void *)script, slot, val); 66998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarJ(con, (RsScript)script, slot, val); 67098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 67198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 67298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 67398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, float val) 67498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 67598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", con, (void *)script, slot, val); 67698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarF(con, (RsScript)script, slot, val); 67798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 67898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 67998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 68098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarD(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, double val) 68198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 68298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", con, (void *)script, slot, val); 68398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarD(con, (RsScript)script, slot, val); 68498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 68598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 68698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 68798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data) 68898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 68998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 69098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 69198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 69298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarV(con, (RsScript)script, slot, ptr, len); 69398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 69498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 69598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 69698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 69798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarVE(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data, jint elem, jintArray dims) 69898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 69998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarVE, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 70098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 70198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 70298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dimsLen = _env->GetArrayLength(dims) * sizeof(int); 70398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *dimsPtr = _env->GetIntArrayElements(dims, NULL); 70498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarVE(con, (RsScript)script, slot, ptr, len, (RsElement)elem, 70598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const size_t*) dimsPtr, dimsLen); 70698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 70798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(dims, dimsPtr, JNI_ABORT); 70898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 70998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 71098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 71198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 71298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetTimeZone(JNIEnv *_env, jobject _this, RsContext con, jint script, jbyteArray timeZone) 71398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 71498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, (void *)script, (const char *)timeZone); 71598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 71698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint length = _env->GetArrayLength(timeZone); 71798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte* timeZone_ptr; 71898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0); 71998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 72098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetTimeZone(con, (RsScript)script, (const char *)timeZone_ptr, length); 72198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 72298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (timeZone_ptr) { 72398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0); 72498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 72598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 72698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 72798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 72898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptInvoke(JNIEnv *_env, jobject _this, RsContext con, jint obj, jint slot) 72998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 73098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptInvoke, con(%p), script(%p)", con, (void *)obj); 73198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptInvoke(con, (RsScript)obj, slot); 73298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 73398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 73498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 73598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptInvokeV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data) 73698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 73798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 73898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 73998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 74098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptInvokeV(con, (RsScript)script, slot, ptr, len); 74198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 74298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 74398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 74498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 74598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptForEach(JNIEnv *_env, jobject _this, RsContext con, 74698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint script, jint slot, jint ain, jint aout) 74798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 74898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 749be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, NULL, 0); 75098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 75198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 75298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptForEachV(JNIEnv *_env, jobject _this, RsContext con, 75398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint script, jint slot, jint ain, jint aout, jbyteArray params) 75498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 75598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 75698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(params); 75798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(params, NULL); 758be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, NULL, 0); 759be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT); 760be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray} 761be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray 762be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murraystatic void 763be995a8c3431dd87ca8877f56d922689eea35ac1Tim MurraynScriptForEachClipped(JNIEnv *_env, jobject _this, RsContext con, 764be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray jint script, jint slot, jint ain, jint aout, 7652da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint xstart, jint xend, 766be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray jint ystart, jint yend, jint zstart, jint zend) 767be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray{ 768be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 7692da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines RsScriptCall sc; 7702da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.xStart = xstart; 7712da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.xEnd = xend; 7722da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.yStart = ystart; 7732da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.yEnd = yend; 7742da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.zStart = zstart; 7752da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.zEnd = zend; 7762da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE; 7772da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.arrayStart = 0; 7782da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines sc.arrayEnd = 0; 7792da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0, &sc, sizeof(sc)); 7802da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines} 7812da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines 7822da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hinesstatic void 7832da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen HinesnScriptForEachClippedV(JNIEnv *_env, jobject _this, RsContext con, 7842da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint script, jint slot, jint ain, jint aout, 7852da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jbyteArray params, jint xstart, jint xend, 7862da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines jint ystart, jint yend, jint zstart, jint zend) 7872da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{ 7882da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines LOG_API("nScriptForEachClipped, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 789be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray jint len = _env->GetArrayLength(params); 790be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray jbyte *ptr = _env->GetByteArrayElements(params, NULL); 791be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray RsScriptCall sc; 792be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.xStart = xstart; 793be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.xEnd = xend; 794be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.yStart = ystart; 795be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.yEnd = yend; 796be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.zStart = zstart; 797be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.zEnd = zend; 798be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE; 799be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.arrayStart = 0; 800be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray sc.arrayEnd = 0; 801be995a8c3431dd87ca8877f56d922689eea35ac1Tim Murray rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len, &sc, sizeof(sc)); 80298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT); 80398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 80498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 80598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 80698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 80798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 80898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptCCreate(JNIEnv *_env, jobject _this, RsContext con, 80998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring resName, jstring cacheDir, 81098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyteArray scriptRef, jint length) 81198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 81298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptCCreate, con(%p)", con); 81398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 81498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8 resNameUTF(_env, resName); 81598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir); 81698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint ret = 0; 81798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte* script_ptr = NULL; 81898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint _exception = 0; 81998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint remaining; 82098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!scriptRef) { 82198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 82298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", "script == null"); 82398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 82498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 82598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (length < 0) { 82698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 82798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", "length < 0"); 82898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 82998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 83098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams remaining = _env->GetArrayLength(scriptRef); 83198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (remaining < length) { 83298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 83398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", 83498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams // "length > script.length - offset"); 83598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 83698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 83798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams script_ptr = (jbyte *) 83898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0); 83998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 84098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //rsScriptCSetText(con, (const char *)script_ptr, length); 84198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 84298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ret = (jint)rsScriptCCreate(con, 84398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams resNameUTF.c_str(), resNameUTF.length(), 84498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams cacheDirUTF.c_str(), cacheDirUTF.length(), 84598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const char *)script_ptr, length); 84698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 84798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsexit: 84898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (script_ptr) { 84998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleasePrimitiveArrayCritical(scriptRef, script_ptr, 85098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception ? JNI_ABORT: 0); 85198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 85298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 85398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return ret; 85498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 85598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 8561b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 8571b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptIntrinsicCreate(JNIEnv *_env, jobject _this, RsContext con, jint id, jint eid) 8581b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8591b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", con, id, (void *)eid); 8601b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptIntrinsicCreate(con, id, (RsElement)eid); 8611b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8621b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8631b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 8641b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptKernelIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot, jint sig) 8651b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8661b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", con, (void *)sid, slot, sig); 8671b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptKernelIDCreate(con, (RsScript)sid, slot, sig); 8681b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8691b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8701b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 8711b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptFieldIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot) 8721b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8731b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", con, (void *)sid, slot); 8741b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptFieldIDCreate(con, (RsScript)sid, slot); 8751b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8761b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8771b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 8781b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupCreate(JNIEnv *_env, jobject _this, RsContext con, jintArray _kernels, jintArray _src, 8791b370e358d16cc3b50b169511d6b387db09f972dJason Sams jintArray _dstk, jintArray _dstf, jintArray _types) 8801b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8811b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupCreate, con(%p)", con); 8821b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8831b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint kernelsLen = _env->GetArrayLength(_kernels) * sizeof(int); 8841b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *kernelsPtr = _env->GetIntArrayElements(_kernels, NULL); 8851b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint srcLen = _env->GetArrayLength(_src) * sizeof(int); 8861b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *srcPtr = _env->GetIntArrayElements(_src, NULL); 8871b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint dstkLen = _env->GetArrayLength(_dstk) * sizeof(int); 8881b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *dstkPtr = _env->GetIntArrayElements(_dstk, NULL); 8891b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint dstfLen = _env->GetArrayLength(_dstf) * sizeof(int); 8901b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *dstfPtr = _env->GetIntArrayElements(_dstf, NULL); 8911b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint typesLen = _env->GetArrayLength(_types) * sizeof(int); 8921b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *typesPtr = _env->GetIntArrayElements(_types, NULL); 8931b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8941b370e358d16cc3b50b169511d6b387db09f972dJason Sams int id = (int)rsScriptGroupCreate(con, 8951b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)kernelsPtr, kernelsLen, 8961b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)srcPtr, srcLen, 8971b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)dstkPtr, dstkLen, 8981b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptFieldID *)dstfPtr, dstfLen, 8991b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsType *)typesPtr, typesLen); 9001b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9011b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_kernels, kernelsPtr, 0); 9021b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_src, srcPtr, 0); 9031b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_dstk, dstkPtr, 0); 9041b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_dstf, dstfPtr, 0); 9051b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_types, typesPtr, 0); 9061b370e358d16cc3b50b169511d6b387db09f972dJason Sams return id; 9071b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9081b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9091b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 9101b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupSetInput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc) 9111b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9121b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", con, 9131b370e358d16cc3b50b169511d6b387db09f972dJason Sams (void *)gid, (void *)kid, (void *)alloc); 9141b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupSetInput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); 9151b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9161b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9171b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 9181b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupSetOutput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc) 9191b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9201b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", con, 9211b370e358d16cc3b50b169511d6b387db09f972dJason Sams (void *)gid, (void *)kid, (void *)alloc); 9221b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupSetOutput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); 9231b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9241b370e358d16cc3b50b169511d6b387db09f972dJason Sams 9251b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 9261b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupExecute(JNIEnv *_env, jobject _this, RsContext con, jint gid) 9271b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 9281b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetOutput, con(%p) group(%p)", con, (void *)gid); 9291b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupExecute(con, (RsScriptGroup)gid); 9301b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 9311b370e358d16cc3b50b169511d6b387db09f972dJason Sams 93298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 93398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 93498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 93598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnSamplerCreate(JNIEnv *_env, jobject _this, RsContext con, jint magFilter, jint minFilter, 93698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint wrapS, jint wrapT, jint wrapR, jfloat aniso) 93798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 93898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nSamplerCreate, con(%p)", con); 93998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsSamplerCreate(con, 94098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)magFilter, 94198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)minFilter, 94298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapS, 94398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapT, 94498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapR, 94598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams aniso); 94698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 94798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 94898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 94998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 95098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 95198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic const char *classPathName = "android/support/v8/renderscript/RenderScript"; 95298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 95398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic JNINativeMethod methods[] = { 95498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"_nInit", "()V", (void*)_nInit }, 95598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 95698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceCreate", "()I", (void*)nDeviceCreate }, 95798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, 95898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig }, 95998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextGetUserMessage", "(I[I)I", (void*)nContextGetUserMessage }, 96098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextGetErrorMessage", "(I)Ljava/lang/String;", (void*)nContextGetErrorMessage }, 96198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextPeekMessage", "(I[I)I", (void*)nContextPeekMessage }, 96298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 96398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextInitToClient", "(I)V", (void*)nContextInitToClient }, 96498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextDeinitToClient", "(I)V", (void*)nContextDeinitToClient }, 96598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 96698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 96798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// All methods below are thread protected in java. 96898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextCreate", "(III)I", (void*)nContextCreate }, 96998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextFinish", "(I)V", (void*)nContextFinish }, 97098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority }, 97198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextDestroy", "(I)V", (void*)nContextDestroy }, 97298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextDump", "(II)V", (void*)nContextDump }, 9732da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{"rsnContextSendMessage", "(II[I)V", (void*)nContextSendMessage }, 97498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnObjDestroy", "(II)V", (void*)nObjDestroy }, 97598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 97698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementCreate", "(IIIZI)I", (void*)nElementCreate }, 97798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementCreate2", "(I[I[Ljava/lang/String;[I)I", (void*)nElementCreate2 }, 97898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;[I)V", (void*)nElementGetSubElements }, 97998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9809fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams{"rsnTypeCreate", "(IIIIIZZI)I", (void*)nTypeCreate }, 98198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 98298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCreateTyped", "(IIIII)I", (void*)nAllocationCreateTyped }, 98398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap }, 984c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray{"rsnAllocationCreateBitmapBackedAllocation", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateBitmapBackedAllocation }, 98598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap }, 98698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 98798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, 98898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCopyToBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap }, 98998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 99098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, 99198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[II)V", (void*)nAllocationData1D_i }, 99298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[SI)V", (void*)nAllocationData1D_s }, 99398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[BI)V", (void*)nAllocationData1D_b }, 99498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[FI)V", (void*)nAllocationData1D_f }, 99598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationElementData1D", "(IIIII[BI)V", (void*)nAllocationElementData1D }, 99698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[II)V", (void*)nAllocationData2D_i }, 99798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[SI)V", (void*)nAllocationData2D_s }, 99898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[BI)V", (void*)nAllocationData2D_b }, 99998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f }, 100098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIIIIIIII)V", (void*)nAllocationData2D_alloc }, 100198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i }, 100298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[S)V", (void*)nAllocationRead_s }, 100398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[B)V", (void*)nAllocationRead_b }, 100498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[F)V", (void*)nAllocationRead_f }, 100598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationGetType", "(II)I", (void*)nAllocationGetType}, 100698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationResize1D", "(III)V", (void*)nAllocationResize1D }, 100798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationResize2D", "(IIII)V", (void*)nAllocationResize2D }, 100898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationGenerateMipmaps", "(II)V", (void*)nAllocationGenerateMipmaps }, 100998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 101098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptBindAllocation", "(IIII)V", (void*)nScriptBindAllocation }, 101198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetTimeZone", "(II[B)V", (void*)nScriptSetTimeZone }, 101298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptInvoke", "(III)V", (void*)nScriptInvoke }, 101398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptInvokeV", "(III[B)V", (void*)nScriptInvokeV }, 101498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptForEach", "(IIIII)V", (void*)nScriptForEach }, 101598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptForEach", "(IIIII[B)V", (void*)nScriptForEachV }, 10162da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{"rsnScriptForEachClipped", "(IIIIIIIIIII)V", (void*)nScriptForEachClipped }, 10172da197aafb9325a3ec5e546c4a15b73ce592c0b9Stephen Hines{"rsnScriptForEachClipped", "(IIIII[BIIIIII)V", (void*)nScriptForEachClippedV }, 101898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarI", "(IIII)V", (void*)nScriptSetVarI }, 101998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarJ", "(IIIJ)V", (void*)nScriptSetVarJ }, 102098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF }, 102198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarD", "(IIID)V", (void*)nScriptSetVarD }, 102298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarV", "(III[B)V", (void*)nScriptSetVarV }, 102398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarVE", "(III[BI[I)V", (void*)nScriptSetVarVE }, 102498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarObj", "(IIII)V", (void*)nScriptSetVarObj }, 102598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 102698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptCCreate", "(ILjava/lang/String;Ljava/lang/String;[BI)I", (void*)nScriptCCreate }, 10271b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptIntrinsicCreate", "(III)I", (void*)nScriptIntrinsicCreate }, 10281b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptKernelIDCreate", "(IIII)I", (void*)nScriptKernelIDCreate }, 10291b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptFieldIDCreate", "(III)I", (void*)nScriptFieldIDCreate }, 10301b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupCreate", "(I[I[I[I[I[I)I", (void*)nScriptGroupCreate }, 10311b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupSetInput", "(IIII)V", (void*)nScriptGroupSetInput }, 10321b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupSetOutput", "(IIII)V", (void*)nScriptGroupSetOutput }, 10331b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupExecute", "(II)V", (void*)nScriptGroupExecute }, 103498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 103598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnSamplerCreate", "(IIIIIIF)I", (void*)nSamplerCreate }, 103698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 103798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 103898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 103998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int registerFuncs(JNIEnv *_env) 104098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 104198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return android::AndroidRuntime::registerNativeMethods( 104298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env, classPathName, methods, NELEM(methods)); 104398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 104498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 104598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 104698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 104798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsjint JNI_OnLoad(JavaVM* vm, void* reserved) 104898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 104998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv* env = NULL; 105098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint result = -1; 105198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 105298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { 105398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGE("ERROR: GetEnv failed\n"); 105498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto bail; 105598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 105698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams assert(env != NULL); 105798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 105898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (registerFuncs(env) < 0) { 105998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGE("ERROR: MediaPlayer native registration failed\n"); 106098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto bail; 106198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 106298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 106398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams /* success -- return valid version number */ 106498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams result = JNI_VERSION_1_4; 106598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 106698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsbail: 106798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return result; 106898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 1069