android_renderscript_RenderScript.cpp revision 9fdd33763a41feb9b0906078c660949fb2c3b930
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 24798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 24898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 24998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementCreate(JNIEnv *_env, jobject _this, RsContext con, jint type, jint kind, jboolean norm, jint size) 25098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 25198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementCreate, con(%p), type(%i), kind(%i), norm(%i), size(%i)", con, type, kind, norm, size); 25298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsElementCreate(con, (RsDataType)type, (RsDataKind)kind, norm, size); 25398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 25498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 25598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 25698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementCreate2(JNIEnv *_env, jobject _this, RsContext con, 25798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _ids, jobjectArray _names, jintArray _arraySizes) 25898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 25998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int fieldCount = _env->GetArrayLength(_ids); 26098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementCreate2, con(%p)", con); 26198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ids = _env->GetIntArrayElements(_ids, NULL); 26398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *arraySizes = _env->GetIntArrayElements(_arraySizes, NULL); 26498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringArrayToUTF8 names(_env, _names, fieldCount); 26698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 26798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **nameArray = names.c_str(); 26898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams size_t *sizeArray = names.c_str_len(); 26998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint id = (jint)rsElementCreate2(con, 27198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsElement *)ids, fieldCount, 27298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams nameArray, fieldCount * sizeof(size_t), sizeArray, 27398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const uint32_t *)arraySizes, fieldCount); 27498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 27598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(_ids, ids, JNI_ABORT); 27698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(_arraySizes, arraySizes, JNI_ABORT); 27798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)id; 27898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 27998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 28298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 28398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnElementGetSubElements(JNIEnv *_env, jobject _this, RsContext con, jint id, 28498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _IDs, 28598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jobjectArray _names, 28698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jintArray _arraySizes) 28798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 28898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams int dataSize = _env->GetArrayLength(_IDs); 28998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nElementGetSubElements, con(%p)", con); 29098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t *ids = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); 29298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams const char **names = (const char **)malloc((uint32_t)dataSize * sizeof(const char *)); 29398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams uint32_t *arraySizes = (uint32_t *)malloc((uint32_t)dataSize * sizeof(uint32_t)); 29498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsaElementGetSubElements(con, (RsElement)id, ids, names, arraySizes, (uint32_t)dataSize); 29698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 29798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams for(jint i = 0; i < dataSize; i++) { 29898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetObjectArrayElement(_names, i, _env->NewStringUTF(names[i])); 29998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetIntArrayRegion(_IDs, i, 1, (const jint*)&ids[i]); 30098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->SetIntArrayRegion(_arraySizes, i, 1, (const jint*)&arraySizes[i]); 30198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 30298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 30398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(ids); 30498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(names); 30598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams free(arraySizes); 30698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 30798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 30898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 30998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 31098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 31198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid, 3129fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv) 31398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 3149fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)", 3159fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams con, eid, dimx, dimy, dimz, mips, faces, yuv); 31698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 3179fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv); 31898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)id; 31998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 32098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 32298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 32398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 32498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mips, jint usage, jint pointer) 32598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 32698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i), ptr(%p)", con, (RsElement)type, mips, usage, (void *)pointer); 32798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint) rsAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage, (uint32_t)pointer); 32898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 32998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 33098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 33198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits) 33298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 33398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", con, (RsAllocation)a, bits); 33498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits); 33598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 33698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 33798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 33898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, RsContext con, jint alloc) 33998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 34098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", con, (RsAllocation)alloc); 34198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationGenerateMipmaps(con, (RsAllocation)alloc); 34298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 34398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 34464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Samsstatic size_t GetBitmapSize(JNIEnv *env, jobject jbitmap) { 34564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 34664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 34764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(env, jbitmap, &info); 34864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams size_t s = info.width * info.height; 34964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams switch (info.format) { 35064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGBA_8888: s *= 4; break; 35164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGB_565: s *= 2; break; 35264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams case ANDROID_BITMAP_FORMAT_RGBA_4444: s *= 2; break; 35364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 35464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams return s; 35564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams} 35664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 35798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 35898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 35998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 360c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray SkBitmap const * nativeBitmap = 361c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); 362c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray const SkBitmap& bitmap(*nativeBitmap); 36364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 364c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray bitmap.lockPixels(); 365c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray const void* ptr = bitmap.getPixels(); 366c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray jint id = (jint)rsAllocationCreateFromBitmap(con, 367c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (RsType)type, (RsAllocationMipmapControl)mip, 368c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray ptr, bitmap.getSize(), usage); 369c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray bitmap.unlockPixels(); 370c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray return id; 371c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray} 372c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray 373c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murraystatic int 374c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim MurraynAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 375c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray{ 376c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray SkBitmap const * nativeBitmap = 377c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); 378c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray const SkBitmap& bitmap(*nativeBitmap); 379c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray 380c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray bitmap.lockPixels(); 381c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray const void* ptr = bitmap.getPixels(); 382c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray jint id = (jint)rsAllocationCreateTyped(con, 383c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (RsType)type, (RsAllocationMipmapControl)mip, 384c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray (uint32_t)usage, (size_t)ptr); 385c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray bitmap.unlockPixels(); 38698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 38798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 38898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 38998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int 39098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) 39198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 39264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 39364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 39464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 39564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams jint id = 0; 39664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 39764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams id = (jint)rsAllocationCubeCreateFromBitmap(con, 39864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams (RsType)type, (RsAllocationMipmapControl)mip, 39964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams pixels, GetBitmapSize(_env, jbitmap), usage); 40064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 40164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 40298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return id; 40398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 40498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 40598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 40698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) 40798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 40864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 40964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 41064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(_env, jbitmap, &info); 41164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 41264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 41364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 41464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 41564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 41664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams rsAllocation2DData(con, (RsAllocation)alloc, 0, 0, 41764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, 4181b370e358d16cc3b50b169511d6b387db09f972dJason Sams info.width, info.height, pixels, GetBitmapSize(_env, jbitmap), 0); 41964965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 42064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 42198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 42298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 42398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 42498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) 42598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 42664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmapInfo info; 42764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams memset(&info, 0, sizeof(info)); 42864965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_getInfo(_env, jbitmap, &info); 42998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 43064965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams void *pixels = NULL; 43164965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_lockPixels(_env, jbitmap, &pixels); 43264965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams 43364965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams if (pixels != NULL) { 43464965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams rsAllocationCopyToBitmap(con, (RsAllocation)alloc, pixels, GetBitmapSize(_env, jbitmap)); 43564965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams AndroidBitmap_unlockPixels(_env, jbitmap); 43664965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams } 43764965801cc56f4fca5c8e55bdd27de57359f7a0eJason Sams //bitmap.notifyPixelsChanged(); 43898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 43998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 44098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 44198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 44298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jintArray data, int sizeBytes) 44398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 44498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 44598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 44698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 44798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 44898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 44998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 45098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 45198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 45298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jshortArray data, int sizeBytes) 45398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 45498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 45598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_s, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 45698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 45798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 45898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 45998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 46098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 46198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 46298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jbyteArray data, int sizeBytes) 46398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 46498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 46598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_b, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 46698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 46798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 46898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 46998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 47098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 47198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 47298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData1D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jfloatArray data, int sizeBytes) 47398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 47498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 47598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation1DData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); 47698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 47798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); 47898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 47998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 48098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 48198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 48298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// native void rsnAllocationElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); 48398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationElementData1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint compIdx, jbyteArray data, int sizeBytes) 48498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 48598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 48698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes); 48798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 48898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocation1DElementData(con, (RsAllocation)alloc, offset, lod, ptr, sizeBytes, compIdx); 48998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 49098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 49198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 49298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 49398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 49498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jshortArray data, int sizeBytes) 49598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 49698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 49798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 49898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 4991b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 50098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); 50198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 50298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 50398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 50498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 50598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jbyteArray data, int sizeBytes) 50698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 50798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 50898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 50998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 5101b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 51198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 51298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 51398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 51498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 51598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 51698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jintArray data, int sizeBytes) 51798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 51898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 51998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 52098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 5211b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 52298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); 52398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 52498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 52598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 52698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, 52798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint w, jint h, jfloatArray data, int sizeBytes) 52898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 52998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 53098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason 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); 53198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 5321b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes, 0); 53398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); 53498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 53598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 53698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 53798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationData2D_alloc(JNIEnv *_env, jobject _this, RsContext con, 53898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dstAlloc, jint dstXoff, jint dstYoff, 53998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dstMip, jint dstFace, 54098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint width, jint height, 54198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint srcAlloc, jint srcXoff, jint srcYoff, 54298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint srcMip, jint srcFace) 54398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 54498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff(%i), dstYoff(%i)," 54598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams " dstMip(%i), dstFace(%i), width(%i), height(%i)," 54698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", 54798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, 54898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); 54998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 55098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationCopy2DRange(con, 55198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsAllocation)dstAlloc, 55298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams dstXoff, dstYoff, 55398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams dstMip, dstFace, 55498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams width, height, 55598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsAllocation)srcAlloc, 55698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams srcXoff, srcYoff, 55798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams srcMip, srcFace); 55898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 55998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 56098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 56198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintArray data) 56298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 56398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 56498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 56598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *ptr = _env->GetIntArrayElements(data, NULL); 56698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 56798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(int)); 56898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(data, ptr, 0); 56998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 57098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 57198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 57298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jshortArray data) 57398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 57498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 57598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 57698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jshort *ptr = _env->GetShortArrayElements(data, NULL); 57798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 57898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(short)); 57998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseShortArrayElements(data, ptr, 0); 58098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 58198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 58298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 58398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jbyteArray data) 58498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 58598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 58698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_i, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 58798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 58898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 58998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(char)); 59098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, 0); 59198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 59298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 59398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 59498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationRead_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jfloatArray data) 59598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 59698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 59798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationRead_f, con(%p), alloc(%p), len(%i)", con, (RsAllocation)alloc, len); 59898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jfloat *ptr = _env->GetFloatArrayElements(data, NULL); 59998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jsize length = _env->GetArrayLength(data); 60098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationRead(con, (RsAllocation)alloc, ptr, length * sizeof(float)); 60198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseFloatArrayElements(data, ptr, 0); 60298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 60398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 60498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 60598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationGetType(JNIEnv *_env, jobject _this, RsContext con, jint a) 60698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 60798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationGetType, con(%p), a(%p)", con, (RsAllocation)a); 60898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint) rsaAllocationGetType(con, (RsAllocation)a); 60998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 61098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 61198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 61298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationResize1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX) 61398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 61498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i)", con, (RsAllocation)alloc, dimX); 61598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationResize1D(con, (RsAllocation)alloc, dimX); 61698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 61798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 61898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 61998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnAllocationResize2D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint dimX, jint dimY) 62098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 62198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nAllocationResize1D, con(%p), alloc(%p), sizeX(%i), sizeY(%i)", con, (RsAllocation)alloc, dimX, dimY); 62298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsAllocationResize2D(con, (RsAllocation)alloc, dimX, dimY); 62398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 62498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 62598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 62698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 62798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 62898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptBindAllocation(JNIEnv *_env, jobject _this, RsContext con, jint script, jint alloc, jint slot) 62998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 63098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptBindAllocation, con(%p), script(%p), alloc(%p), slot(%i)", con, (RsScript)script, (RsAllocation)alloc, slot); 63198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptBindAllocation(con, (RsScript)script, (RsAllocation)alloc, slot); 63298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 63398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 63498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 63598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarI(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val) 63698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 63798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarI, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val); 63898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarI(con, (RsScript)script, slot, val); 63998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 64098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 64198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 64298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarObj(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jint val) 64398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 64498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarObj, con(%p), s(%p), slot(%i), val(%i)", con, (void *)script, slot, val); 64598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarObj(con, (RsScript)script, slot, (RsObjectBase)val); 64698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 64798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 64898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 64998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jlong val) 65098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 65198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", con, (void *)script, slot, val); 65298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarJ(con, (RsScript)script, slot, val); 65398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 65498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 65598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 65698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, float val) 65798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 65898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", con, (void *)script, slot, val); 65998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarF(con, (RsScript)script, slot, val); 66098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 66198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 66298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 66398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarD(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, double val) 66498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 66598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarD, con(%p), s(%p), slot(%i), val(%lf)", con, (void *)script, slot, val); 66698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarD(con, (RsScript)script, slot, val); 66798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 66898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 66998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 67098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data) 67198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 67298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 67398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 67498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 67598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarV(con, (RsScript)script, slot, ptr, len); 67698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 67798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 67898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 67998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 68098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetVarVE(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data, jint elem, jintArray dims) 68198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 68298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptSetVarVE, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 68398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 68498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 68598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint dimsLen = _env->GetArrayLength(dims) * sizeof(int); 68698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint *dimsPtr = _env->GetIntArrayElements(dims, NULL); 68798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetVarVE(con, (RsScript)script, slot, ptr, len, (RsElement)elem, 68898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const size_t*) dimsPtr, dimsLen); 68998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 69098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseIntArrayElements(dims, dimsPtr, JNI_ABORT); 69198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 69298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 69398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 69498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 69598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptSetTimeZone(JNIEnv *_env, jobject _this, RsContext con, jint script, jbyteArray timeZone) 69698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 69798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptCSetTimeZone, con(%p), s(%p), timeZone(%s)", con, (void *)script, (const char *)timeZone); 69898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 69998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint length = _env->GetArrayLength(timeZone); 70098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte* timeZone_ptr; 70198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0); 70298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 70398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptSetTimeZone(con, (RsScript)script, (const char *)timeZone_ptr, length); 70498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 70598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (timeZone_ptr) { 70698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0); 70798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 70898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 70998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 71098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 71198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptInvoke(JNIEnv *_env, jobject _this, RsContext con, jint obj, jint slot) 71298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 71398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptInvoke, con(%p), script(%p)", con, (void *)obj); 71498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptInvoke(con, (RsScript)obj, slot); 71598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 71698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 71798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 71898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptInvokeV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data) 71998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 72098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptInvokeV, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 72198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(data); 72298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(data, NULL); 72398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptInvokeV(con, (RsScript)script, slot, ptr, len); 72498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); 72598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 72698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 72798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 72898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptForEach(JNIEnv *_env, jobject _this, RsContext con, 72998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint script, jint slot, jint ain, jint aout) 73098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 73198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 73298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, NULL, 0); 73398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 73498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic void 73598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptForEachV(JNIEnv *_env, jobject _this, RsContext con, 73698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint script, jint slot, jint ain, jint aout, jbyteArray params) 73798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 73898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptForEach, con(%p), s(%p), slot(%i)", con, (void *)script, slot); 73998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint len = _env->GetArrayLength(params); 74098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte *ptr = _env->GetByteArrayElements(params, NULL); 74198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams rsScriptForEach(con, (RsScript)script, slot, (RsAllocation)ain, (RsAllocation)aout, ptr, len); 74298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleaseByteArrayElements(params, ptr, JNI_ABORT); 74398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 74498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 74598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 74698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// ----------------------------------- 74798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 74898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 74998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnScriptCCreate(JNIEnv *_env, jobject _this, RsContext con, 75098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jstring resName, jstring cacheDir, 75198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyteArray scriptRef, jint length) 75298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 75398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nScriptCCreate, con(%p)", con); 75498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 75598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8 resNameUTF(_env, resName); 75698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams AutoJavaStringToUTF8 cacheDirUTF(_env, cacheDir); 75798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint ret = 0; 75898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jbyte* script_ptr = NULL; 75998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint _exception = 0; 76098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint remaining; 76198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (!scriptRef) { 76298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 76398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", "script == null"); 76498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 76598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 76698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (length < 0) { 76798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 76898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", "length < 0"); 76998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 77098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 77198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams remaining = _env->GetArrayLength(scriptRef); 77298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (remaining < length) { 77398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception = 1; 77498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //jniThrowException(_env, "java/lang/IllegalArgumentException", 77598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams // "length > script.length - offset"); 77698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto exit; 77798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 77898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams script_ptr = (jbyte *) 77998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->GetPrimitiveArrayCritical(scriptRef, (jboolean *)0); 78098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 78198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams //rsScriptCSetText(con, (const char *)script_ptr, length); 78298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 78398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ret = (jint)rsScriptCCreate(con, 78498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams resNameUTF.c_str(), resNameUTF.length(), 78598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams cacheDirUTF.c_str(), cacheDirUTF.length(), 78698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (const char *)script_ptr, length); 78798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 78898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsexit: 78998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (script_ptr) { 79098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env->ReleasePrimitiveArrayCritical(scriptRef, script_ptr, 79198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _exception ? JNI_ABORT: 0); 79298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 79398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 79498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return ret; 79598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 79698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 7971b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 7981b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptIntrinsicCreate(JNIEnv *_env, jobject _this, RsContext con, jint id, jint eid) 7991b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8001b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptIntrinsicCreate, con(%p) id(%i) element(%p)", con, id, (void *)eid); 8011b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptIntrinsicCreate(con, id, (RsElement)eid); 8021b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8031b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8041b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 8051b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptKernelIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot, jint sig) 8061b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8071b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptKernelIDCreate, con(%p) script(%p), slot(%i), sig(%i)", con, (void *)sid, slot, sig); 8081b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptKernelIDCreate(con, (RsScript)sid, slot, sig); 8091b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8101b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8111b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 8121b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptFieldIDCreate(JNIEnv *_env, jobject _this, RsContext con, jint sid, jint slot) 8131b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8141b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptFieldIDCreate, con(%p) script(%p), slot(%i)", con, (void *)sid, slot); 8151b370e358d16cc3b50b169511d6b387db09f972dJason Sams return (jint)rsScriptFieldIDCreate(con, (RsScript)sid, slot); 8161b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8171b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8181b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic jint 8191b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupCreate(JNIEnv *_env, jobject _this, RsContext con, jintArray _kernels, jintArray _src, 8201b370e358d16cc3b50b169511d6b387db09f972dJason Sams jintArray _dstk, jintArray _dstf, jintArray _types) 8211b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8221b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupCreate, con(%p)", con); 8231b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8241b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint kernelsLen = _env->GetArrayLength(_kernels) * sizeof(int); 8251b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *kernelsPtr = _env->GetIntArrayElements(_kernels, NULL); 8261b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint srcLen = _env->GetArrayLength(_src) * sizeof(int); 8271b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *srcPtr = _env->GetIntArrayElements(_src, NULL); 8281b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint dstkLen = _env->GetArrayLength(_dstk) * sizeof(int); 8291b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *dstkPtr = _env->GetIntArrayElements(_dstk, NULL); 8301b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint dstfLen = _env->GetArrayLength(_dstf) * sizeof(int); 8311b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *dstfPtr = _env->GetIntArrayElements(_dstf, NULL); 8321b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint typesLen = _env->GetArrayLength(_types) * sizeof(int); 8331b370e358d16cc3b50b169511d6b387db09f972dJason Sams jint *typesPtr = _env->GetIntArrayElements(_types, NULL); 8341b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8351b370e358d16cc3b50b169511d6b387db09f972dJason Sams int id = (int)rsScriptGroupCreate(con, 8361b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)kernelsPtr, kernelsLen, 8371b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)srcPtr, srcLen, 8381b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptKernelID *)dstkPtr, dstkLen, 8391b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsScriptFieldID *)dstfPtr, dstfLen, 8401b370e358d16cc3b50b169511d6b387db09f972dJason Sams (RsType *)typesPtr, typesLen); 8411b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8421b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_kernels, kernelsPtr, 0); 8431b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_src, srcPtr, 0); 8441b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_dstk, dstkPtr, 0); 8451b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_dstf, dstfPtr, 0); 8461b370e358d16cc3b50b169511d6b387db09f972dJason Sams _env->ReleaseIntArrayElements(_types, typesPtr, 0); 8471b370e358d16cc3b50b169511d6b387db09f972dJason Sams return id; 8481b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8491b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8501b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 8511b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupSetInput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc) 8521b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8531b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetInput, con(%p) group(%p), kernelId(%p), alloc(%p)", con, 8541b370e358d16cc3b50b169511d6b387db09f972dJason Sams (void *)gid, (void *)kid, (void *)alloc); 8551b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupSetInput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); 8561b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8571b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8581b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 8591b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupSetOutput(JNIEnv *_env, jobject _this, RsContext con, jint gid, jint kid, jint alloc) 8601b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8611b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetOutput, con(%p) group(%p), kernelId(%p), alloc(%p)", con, 8621b370e358d16cc3b50b169511d6b387db09f972dJason Sams (void *)gid, (void *)kid, (void *)alloc); 8631b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupSetOutput(con, (RsScriptGroup)gid, (RsScriptKernelID)kid, (RsAllocation)alloc); 8641b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8651b370e358d16cc3b50b169511d6b387db09f972dJason Sams 8661b370e358d16cc3b50b169511d6b387db09f972dJason Samsstatic void 8671b370e358d16cc3b50b169511d6b387db09f972dJason SamsnScriptGroupExecute(JNIEnv *_env, jobject _this, RsContext con, jint gid) 8681b370e358d16cc3b50b169511d6b387db09f972dJason Sams{ 8691b370e358d16cc3b50b169511d6b387db09f972dJason Sams LOG_API("nScriptGroupSetOutput, con(%p) group(%p)", con, (void *)gid); 8701b370e358d16cc3b50b169511d6b387db09f972dJason Sams rsScriptGroupExecute(con, (RsScriptGroup)gid); 8711b370e358d16cc3b50b169511d6b387db09f972dJason Sams} 8721b370e358d16cc3b50b169511d6b387db09f972dJason Sams 87398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 87498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 87598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic jint 87698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason SamsnSamplerCreate(JNIEnv *_env, jobject _this, RsContext con, jint magFilter, jint minFilter, 87798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint wrapS, jint wrapT, jint wrapR, jfloat aniso) 87898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 87998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams LOG_API("nSamplerCreate, con(%p)", con); 88098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return (jint)rsSamplerCreate(con, 88198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)magFilter, 88298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)minFilter, 88398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapS, 88498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapT, 88598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams (RsSamplerValue)wrapR, 88698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams aniso); 88798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 88898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 88998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 89098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 89198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 89298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic const char *classPathName = "android/support/v8/renderscript/RenderScript"; 89398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 89498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic JNINativeMethod methods[] = { 89598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"_nInit", "()V", (void*)_nInit }, 89698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 89798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceCreate", "()I", (void*)nDeviceCreate }, 89898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, 89998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nDeviceSetConfig", "(III)V", (void*)nDeviceSetConfig }, 90098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextGetUserMessage", "(I[I)I", (void*)nContextGetUserMessage }, 90198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextGetErrorMessage", "(I)Ljava/lang/String;", (void*)nContextGetErrorMessage }, 90298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextPeekMessage", "(I[I)I", (void*)nContextPeekMessage }, 90398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 90498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextInitToClient", "(I)V", (void*)nContextInitToClient }, 90598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"nContextDeinitToClient", "(I)V", (void*)nContextDeinitToClient }, 90698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 90798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 90898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// All methods below are thread protected in java. 90998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextCreate", "(III)I", (void*)nContextCreate }, 91098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextFinish", "(I)V", (void*)nContextFinish }, 91198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextSetPriority", "(II)V", (void*)nContextSetPriority }, 91298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextDestroy", "(I)V", (void*)nContextDestroy }, 91398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnContextDump", "(II)V", (void*)nContextDump }, 91498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnObjDestroy", "(II)V", (void*)nObjDestroy }, 91598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 91698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementCreate", "(IIIZI)I", (void*)nElementCreate }, 91798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementCreate2", "(I[I[Ljava/lang/String;[I)I", (void*)nElementCreate2 }, 91898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnElementGetSubElements", "(II[I[Ljava/lang/String;[I)V", (void*)nElementGetSubElements }, 91998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 9209fdd33763a41feb9b0906078c660949fb2c3b930Jason Sams{"rsnTypeCreate", "(IIIIIZZI)I", (void*)nTypeCreate }, 92198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 92298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCreateTyped", "(IIIII)I", (void*)nAllocationCreateTyped }, 92398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap }, 924c5b37c751f22199fd3cf14f6ef19ed4b9664510fTim Murray{"rsnAllocationCreateBitmapBackedAllocation", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateBitmapBackedAllocation }, 92598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap }, 92698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 92798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, 92898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationCopyToBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap }, 92998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 93098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, 93198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[II)V", (void*)nAllocationData1D_i }, 93298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[SI)V", (void*)nAllocationData1D_s }, 93398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[BI)V", (void*)nAllocationData1D_b }, 93498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData1D", "(IIIII[FI)V", (void*)nAllocationData1D_f }, 93598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationElementData1D", "(IIIII[BI)V", (void*)nAllocationElementData1D }, 93698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[II)V", (void*)nAllocationData2D_i }, 93798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[SI)V", (void*)nAllocationData2D_s }, 93898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[BI)V", (void*)nAllocationData2D_b }, 93998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f }, 94098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationData2D", "(IIIIIIIIIIIII)V", (void*)nAllocationData2D_alloc }, 94198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i }, 94298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[S)V", (void*)nAllocationRead_s }, 94398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[B)V", (void*)nAllocationRead_b }, 94498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationRead", "(II[F)V", (void*)nAllocationRead_f }, 94598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationGetType", "(II)I", (void*)nAllocationGetType}, 94698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationResize1D", "(III)V", (void*)nAllocationResize1D }, 94798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationResize2D", "(IIII)V", (void*)nAllocationResize2D }, 94898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnAllocationGenerateMipmaps", "(II)V", (void*)nAllocationGenerateMipmaps }, 94998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 95098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptBindAllocation", "(IIII)V", (void*)nScriptBindAllocation }, 95198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetTimeZone", "(II[B)V", (void*)nScriptSetTimeZone }, 95298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptInvoke", "(III)V", (void*)nScriptInvoke }, 95398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptInvokeV", "(III[B)V", (void*)nScriptInvokeV }, 95498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptForEach", "(IIIII)V", (void*)nScriptForEach }, 95598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptForEach", "(IIIII[B)V", (void*)nScriptForEachV }, 95698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarI", "(IIII)V", (void*)nScriptSetVarI }, 95798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarJ", "(IIIJ)V", (void*)nScriptSetVarJ }, 95898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF }, 95998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarD", "(IIID)V", (void*)nScriptSetVarD }, 96098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarV", "(III[B)V", (void*)nScriptSetVarV }, 96198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarVE", "(III[BI[I)V", (void*)nScriptSetVarVE }, 96298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptSetVarObj", "(IIII)V", (void*)nScriptSetVarObj }, 96398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 96498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnScriptCCreate", "(ILjava/lang/String;Ljava/lang/String;[BI)I", (void*)nScriptCCreate }, 9651b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptIntrinsicCreate", "(III)I", (void*)nScriptIntrinsicCreate }, 9661b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptKernelIDCreate", "(IIII)I", (void*)nScriptKernelIDCreate }, 9671b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptFieldIDCreate", "(III)I", (void*)nScriptFieldIDCreate }, 9681b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupCreate", "(I[I[I[I[I[I)I", (void*)nScriptGroupCreate }, 9691b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupSetInput", "(IIII)V", (void*)nScriptGroupSetInput }, 9701b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupSetOutput", "(IIII)V", (void*)nScriptGroupSetOutput }, 9711b370e358d16cc3b50b169511d6b387db09f972dJason Sams{"rsnScriptGroupExecute", "(II)V", (void*)nScriptGroupExecute }, 97298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 97398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{"rsnSamplerCreate", "(IIIIIIF)I", (void*)nSamplerCreate }, 97498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 97598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams}; 97698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 97798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsstatic int registerFuncs(JNIEnv *_env) 97898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 97998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return android::AndroidRuntime::registerNativeMethods( 98098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams _env, classPathName, methods, NELEM(methods)); 98198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 98298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 98398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams// --------------------------------------------------------------------------- 98498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 98598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsjint JNI_OnLoad(JavaVM* vm, void* reserved) 98698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams{ 98798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams JNIEnv* env = NULL; 98898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams jint result = -1; 98998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 99098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { 99198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGE("ERROR: GetEnv failed\n"); 99298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto bail; 99398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 99498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams assert(env != NULL); 99598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 99698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams if (registerFuncs(env) < 0) { 99798a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams ALOGE("ERROR: MediaPlayer native registration failed\n"); 99898a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams goto bail; 99998a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams } 100098a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 100198a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams /* success -- return valid version number */ 100298a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams result = JNI_VERSION_1_4; 100398a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams 100498a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Samsbail: 100598a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams return result; 100698a281354fe06d1f970d0521c9a08d9eb0aa1a45Jason Sams} 1007