2009-05-26 13:45:08 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2009-06-10 16:09:05 -07:00
|
|
|
package android.renderscript;
|
2009-05-26 13:45:08 -07:00
|
|
|
|
2009-08-12 17:54:11 -07:00
|
|
|
import java.lang.reflect.Field;
|
2009-07-31 16:26:13 -07:00
|
|
|
|
2010-12-10 01:03:59 -08:00
|
|
|
import android.content.Context;
|
2011-01-07 11:12:08 -08:00
|
|
|
import android.content.res.AssetManager;
|
2009-07-31 20:40:47 -07:00
|
|
|
import android.graphics.Bitmap;
|
2009-08-31 14:06:43 -07:00
|
|
|
import android.graphics.BitmapFactory;
|
2009-07-31 16:26:13 -07:00
|
|
|
import android.util.Config;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.Surface;
|
2009-05-28 13:38:16 -07:00
|
|
|
|
2009-05-26 13:45:08 -07:00
|
|
|
|
2009-07-23 15:19:03 -07:00
|
|
|
/**
|
2010-11-10 17:00:59 -08:00
|
|
|
* RenderScript base master class. An instance of this class creates native
|
|
|
|
* worker threads for processing commands from this object. This base class
|
|
|
|
* does not provide any extended capabilities beyond simple data processing.
|
|
|
|
* For extended capabilities use derived classes such as RenderScriptGL.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
2009-07-23 15:19:03 -07:00
|
|
|
**/
|
2009-05-26 13:45:08 -07:00
|
|
|
public class RenderScript {
|
2009-11-12 15:10:25 -08:00
|
|
|
static final String LOG_TAG = "RenderScript_jni";
|
2010-12-06 15:59:59 -08:00
|
|
|
static final boolean DEBUG = false;
|
2009-08-31 14:06:43 -07:00
|
|
|
@SuppressWarnings({"UnusedDeclaration", "deprecation"})
|
2010-12-06 15:59:59 -08:00
|
|
|
static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
|
2009-05-26 13:45:08 -07:00
|
|
|
|
2010-12-10 01:03:59 -08:00
|
|
|
private Context mApplicationContext;
|
2009-05-26 13:45:08 -07:00
|
|
|
|
2010-12-10 01:03:59 -08:00
|
|
|
/*
|
2009-05-26 13:45:08 -07:00
|
|
|
* We use a class initializer to allow the native code to cache some
|
|
|
|
* field offsets.
|
|
|
|
*/
|
2009-08-31 14:06:43 -07:00
|
|
|
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
2010-12-06 15:59:59 -08:00
|
|
|
static boolean sInitialized;
|
|
|
|
native static void _nInit();
|
2009-05-26 13:45:08 -07:00
|
|
|
|
2009-07-30 14:56:12 -07:00
|
|
|
|
2009-05-26 13:45:08 -07:00
|
|
|
static {
|
|
|
|
sInitialized = false;
|
|
|
|
try {
|
2009-07-23 15:19:03 -07:00
|
|
|
System.loadLibrary("rs_jni");
|
2009-05-26 13:45:08 -07:00
|
|
|
_nInit();
|
|
|
|
sInitialized = true;
|
|
|
|
} catch (UnsatisfiedLinkError e) {
|
2011-01-07 17:00:07 -08:00
|
|
|
Log.e(LOG_TAG, "Error loading RS jni library: " + e);
|
|
|
|
throw new RSRuntimeException("Error loading RS jni library: " + e);
|
2009-05-26 13:45:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-17 16:25:41 -07:00
|
|
|
// Non-threadsafe functions.
|
2009-07-31 16:26:13 -07:00
|
|
|
native int nDeviceCreate();
|
|
|
|
native void nDeviceDestroy(int dev);
|
2009-09-23 13:57:02 -07:00
|
|
|
native void nDeviceSetConfig(int dev, int param, int value);
|
2010-11-08 17:06:46 -08:00
|
|
|
native void nContextGetUserMessage(int con, int[] data);
|
|
|
|
native String nContextGetErrorMessage(int con);
|
|
|
|
native int nContextPeekMessage(int con, int[] subID, boolean wait);
|
2010-08-17 16:25:41 -07:00
|
|
|
native void nContextInitToClient(int con);
|
|
|
|
native void nContextDeinitToClient(int con);
|
|
|
|
|
|
|
|
|
|
|
|
// Methods below are wrapped to protect the non-threadsafe
|
|
|
|
// lockless fifo.
|
2010-10-13 15:31:10 -07:00
|
|
|
native int rsnContextCreateGL(int dev, int ver,
|
|
|
|
int colorMin, int colorPref,
|
|
|
|
int alphaMin, int alphaPref,
|
|
|
|
int depthMin, int depthPref,
|
|
|
|
int stencilMin, int stencilPref,
|
|
|
|
int samplesMin, int samplesPref, float samplesQ);
|
|
|
|
synchronized int nContextCreateGL(int dev, int ver,
|
|
|
|
int colorMin, int colorPref,
|
|
|
|
int alphaMin, int alphaPref,
|
|
|
|
int depthMin, int depthPref,
|
|
|
|
int stencilMin, int stencilPref,
|
|
|
|
int samplesMin, int samplesPref, float samplesQ) {
|
|
|
|
return rsnContextCreateGL(dev, ver, colorMin, colorPref,
|
|
|
|
alphaMin, alphaPref, depthMin, depthPref,
|
|
|
|
stencilMin, stencilPref,
|
|
|
|
samplesMin, samplesPref, samplesQ);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
|
|
|
native int rsnContextCreate(int dev, int ver);
|
|
|
|
synchronized int nContextCreate(int dev, int ver) {
|
|
|
|
return rsnContextCreate(dev, ver);
|
|
|
|
}
|
|
|
|
native void rsnContextDestroy(int con);
|
|
|
|
synchronized void nContextDestroy() {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextDestroy(mContext);
|
|
|
|
}
|
|
|
|
native void rsnContextSetSurface(int con, int w, int h, Surface sur);
|
|
|
|
synchronized void nContextSetSurface(int w, int h, Surface sur) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextSetSurface(mContext, w, h, sur);
|
|
|
|
}
|
|
|
|
native void rsnContextSetPriority(int con, int p);
|
|
|
|
synchronized void nContextSetPriority(int p) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextSetPriority(mContext, p);
|
|
|
|
}
|
|
|
|
native void rsnContextDump(int con, int bits);
|
|
|
|
synchronized void nContextDump(int bits) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextDump(mContext, bits);
|
|
|
|
}
|
|
|
|
native void rsnContextFinish(int con);
|
|
|
|
synchronized void nContextFinish() {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextFinish(mContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
native void rsnContextBindRootScript(int con, int script);
|
|
|
|
synchronized void nContextBindRootScript(int script) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextBindRootScript(mContext, script);
|
|
|
|
}
|
|
|
|
native void rsnContextBindSampler(int con, int sampler, int slot);
|
|
|
|
synchronized void nContextBindSampler(int sampler, int slot) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextBindSampler(mContext, sampler, slot);
|
|
|
|
}
|
|
|
|
native void rsnContextBindProgramStore(int con, int pfs);
|
|
|
|
synchronized void nContextBindProgramStore(int pfs) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextBindProgramStore(mContext, pfs);
|
|
|
|
}
|
|
|
|
native void rsnContextBindProgramFragment(int con, int pf);
|
|
|
|
synchronized void nContextBindProgramFragment(int pf) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextBindProgramFragment(mContext, pf);
|
|
|
|
}
|
|
|
|
native void rsnContextBindProgramVertex(int con, int pv);
|
|
|
|
synchronized void nContextBindProgramVertex(int pv) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextBindProgramVertex(mContext, pv);
|
|
|
|
}
|
|
|
|
native void rsnContextBindProgramRaster(int con, int pr);
|
|
|
|
synchronized void nContextBindProgramRaster(int pr) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextBindProgramRaster(mContext, pr);
|
|
|
|
}
|
|
|
|
native void rsnContextPause(int con);
|
|
|
|
synchronized void nContextPause() {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextPause(mContext);
|
|
|
|
}
|
|
|
|
native void rsnContextResume(int con);
|
|
|
|
synchronized void nContextResume() {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnContextResume(mContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
native void rsnAssignName(int con, int obj, byte[] name);
|
|
|
|
synchronized void nAssignName(int obj, byte[] name) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnAssignName(mContext, obj, name);
|
|
|
|
}
|
|
|
|
native String rsnGetName(int con, int obj);
|
|
|
|
synchronized String nGetName(int obj) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnGetName(mContext, obj);
|
|
|
|
}
|
|
|
|
native void rsnObjDestroy(int con, int id);
|
|
|
|
synchronized void nObjDestroy(int id) {
|
2011-01-18 18:12:26 -08:00
|
|
|
// There is a race condition here. The calling code may be run
|
|
|
|
// by the gc while teardown is occuring. This protects againts
|
|
|
|
// deleting dead objects.
|
|
|
|
if (mContext != 0) {
|
|
|
|
rsnObjDestroy(mContext, id);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
native int rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize);
|
|
|
|
synchronized int nElementCreate(int type, int kind, boolean norm, int vecSize) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnElementCreate(mContext, type, kind, norm, vecSize);
|
|
|
|
}
|
2010-09-02 17:35:23 -07:00
|
|
|
native int rsnElementCreate2(int con, int[] elements, String[] names, int[] arraySizes);
|
|
|
|
synchronized int nElementCreate2(int[] elements, String[] names, int[] arraySizes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-09-02 17:35:23 -07:00
|
|
|
return rsnElementCreate2(mContext, elements, names, arraySizes);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
|
|
|
native void rsnElementGetNativeData(int con, int id, int[] elementData);
|
|
|
|
synchronized void nElementGetNativeData(int id, int[] elementData) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnElementGetNativeData(mContext, id, elementData);
|
|
|
|
}
|
|
|
|
native void rsnElementGetSubElements(int con, int id, int[] IDs, String[] names);
|
|
|
|
synchronized void nElementGetSubElements(int id, int[] IDs, String[] names) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnElementGetSubElements(mContext, id, IDs, names);
|
|
|
|
}
|
|
|
|
|
2010-12-06 15:59:59 -08:00
|
|
|
native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces);
|
|
|
|
synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-06 15:59:59 -08:00
|
|
|
return rsnTypeCreate(mContext, eid, x, y, z, mips, faces);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
|
|
|
native void rsnTypeGetNativeData(int con, int id, int[] typeData);
|
|
|
|
synchronized void nTypeGetNativeData(int id, int[] typeData) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnTypeGetNativeData(mContext, id, typeData);
|
|
|
|
}
|
|
|
|
|
2010-12-13 15:32:35 -08:00
|
|
|
native int rsnAllocationCreateTyped(int con, int type, int mip, int usage);
|
|
|
|
synchronized int nAllocationCreateTyped(int type, int mip, int usage) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-13 15:32:35 -08:00
|
|
|
return rsnAllocationCreateTyped(mContext, type, mip, usage);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
2010-12-08 16:14:36 -08:00
|
|
|
native int rsnAllocationCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage);
|
|
|
|
synchronized int nAllocationCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-08 16:14:36 -08:00
|
|
|
return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage);
|
2010-10-11 12:35:15 -07:00
|
|
|
}
|
2010-12-08 16:14:36 -08:00
|
|
|
native int rsnAllocationCubeCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage);
|
|
|
|
synchronized int nAllocationCubeCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-08 16:14:36 -08:00
|
|
|
return rsnAllocationCubeCreateFromBitmap(mContext, type, mip, bmp, usage);
|
2010-11-18 15:22:43 -08:00
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
native int rsnAllocationCreateBitmapRef(int con, int type, Bitmap bmp);
|
|
|
|
synchronized int nAllocationCreateBitmapRef(int type, Bitmap bmp) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnAllocationCreateBitmapRef(mContext, type, bmp);
|
|
|
|
}
|
2010-12-08 16:14:36 -08:00
|
|
|
native int rsnAllocationCreateFromAssetStream(int con, int mips, int assetStream, int usage);
|
|
|
|
synchronized int nAllocationCreateFromAssetStream(int mips, int assetStream, int usage) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-08 16:14:36 -08:00
|
|
|
return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage);
|
|
|
|
}
|
|
|
|
|
2010-12-10 16:03:15 -08:00
|
|
|
native void rsnAllocationCopyToBitmap(int con, int alloc, Bitmap bmp);
|
|
|
|
synchronized void nAllocationCopyToBitmap(int alloc, Bitmap bmp) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-10 16:03:15 -08:00
|
|
|
rsnAllocationCopyToBitmap(mContext, alloc, bmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 16:14:36 -08:00
|
|
|
native void rsnAllocationSyncAll(int con, int alloc, int src);
|
|
|
|
synchronized void nAllocationSyncAll(int alloc, int src) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-08 16:14:36 -08:00
|
|
|
rsnAllocationSyncAll(mContext, alloc, src);
|
|
|
|
}
|
2011-01-12 13:28:37 -08:00
|
|
|
native void rsnAllocationGenerateMipmaps(int con, int alloc);
|
|
|
|
synchronized void nAllocationGenerateMipmaps(int alloc) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-12 13:28:37 -08:00
|
|
|
rsnAllocationGenerateMipmaps(mContext, alloc);
|
|
|
|
}
|
2010-12-10 16:03:15 -08:00
|
|
|
native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp);
|
|
|
|
synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-10 16:03:15 -08:00
|
|
|
rsnAllocationCopyFromBitmap(mContext, alloc, bmp);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-29 14:31:29 -08:00
|
|
|
native void rsnAllocationData1D(int con, int id, int off, int mip, int count, int[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationData1D(int id, int off, int mip, int count, int[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-29 14:31:29 -08:00
|
|
|
rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
2010-12-29 14:31:29 -08:00
|
|
|
native void rsnAllocationData1D(int con, int id, int off, int mip, int count, short[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationData1D(int id, int off, int mip, int count, short[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-29 14:31:29 -08:00
|
|
|
rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
2010-12-29 14:31:29 -08:00
|
|
|
native void rsnAllocationData1D(int con, int id, int off, int mip, int count, byte[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationData1D(int id, int off, int mip, int count, byte[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-29 14:31:29 -08:00
|
|
|
rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
2010-12-29 14:31:29 -08:00
|
|
|
native void rsnAllocationData1D(int con, int id, int off, int mip, int count, float[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationData1D(int id, int off, int mip, int count, float[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-29 14:31:29 -08:00
|
|
|
rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes);
|
2010-08-31 13:50:42 -07:00
|
|
|
}
|
2010-12-29 14:31:29 -08:00
|
|
|
|
|
|
|
native void rsnAllocationElementData1D(int con, int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationElementData1D(int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-29 14:31:29 -08:00
|
|
|
rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
|
|
|
|
2011-01-07 17:00:07 -08:00
|
|
|
native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 17:00:07 -08:00
|
|
|
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
|
|
|
|
}
|
|
|
|
native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 17:00:07 -08:00
|
|
|
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
|
|
|
|
}
|
2010-12-29 14:31:29 -08:00
|
|
|
native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-29 14:31:29 -08:00
|
|
|
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
2010-12-29 14:31:29 -08:00
|
|
|
native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes);
|
|
|
|
synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-29 14:31:29 -08:00
|
|
|
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
2011-01-07 17:00:07 -08:00
|
|
|
native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, Bitmap b);
|
|
|
|
synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, Bitmap b) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 17:00:07 -08:00
|
|
|
rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, b);
|
|
|
|
}
|
2010-12-29 14:31:29 -08:00
|
|
|
|
2011-01-07 17:00:07 -08:00
|
|
|
native void rsnAllocationRead(int con, int id, byte[] d);
|
|
|
|
synchronized void nAllocationRead(int id, byte[] d) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 17:00:07 -08:00
|
|
|
rsnAllocationRead(mContext, id, d);
|
|
|
|
}
|
|
|
|
native void rsnAllocationRead(int con, int id, short[] d);
|
|
|
|
synchronized void nAllocationRead(int id, short[] d) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 17:00:07 -08:00
|
|
|
rsnAllocationRead(mContext, id, d);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
native void rsnAllocationRead(int con, int id, int[] d);
|
|
|
|
synchronized void nAllocationRead(int id, int[] d) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnAllocationRead(mContext, id, d);
|
|
|
|
}
|
|
|
|
native void rsnAllocationRead(int con, int id, float[] d);
|
|
|
|
synchronized void nAllocationRead(int id, float[] d) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnAllocationRead(mContext, id, d);
|
|
|
|
}
|
|
|
|
native int rsnAllocationGetType(int con, int id);
|
|
|
|
synchronized int nAllocationGetType(int id) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnAllocationGetType(mContext, id);
|
|
|
|
}
|
|
|
|
|
2010-10-05 13:32:49 -07:00
|
|
|
native void rsnAllocationResize1D(int con, int id, int dimX);
|
|
|
|
synchronized void nAllocationResize1D(int id, int dimX) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-10-05 13:32:49 -07:00
|
|
|
rsnAllocationResize1D(mContext, id, dimX);
|
|
|
|
}
|
|
|
|
native void rsnAllocationResize2D(int con, int id, int dimX, int dimY);
|
|
|
|
synchronized void nAllocationResize2D(int id, int dimX, int dimY) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-10-05 13:32:49 -07:00
|
|
|
rsnAllocationResize2D(mContext, id, dimX, dimY);
|
|
|
|
}
|
|
|
|
|
2010-08-17 16:25:41 -07:00
|
|
|
native int rsnFileA3DCreateFromAssetStream(int con, int assetStream);
|
|
|
|
synchronized int nFileA3DCreateFromAssetStream(int assetStream) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnFileA3DCreateFromAssetStream(mContext, assetStream);
|
|
|
|
}
|
2011-01-07 11:12:08 -08:00
|
|
|
native int rsnFileA3DCreateFromFile(int con, String path);
|
|
|
|
synchronized int nFileA3DCreateFromFile(String path) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 11:12:08 -08:00
|
|
|
return rsnFileA3DCreateFromFile(mContext, path);
|
|
|
|
}
|
|
|
|
native int rsnFileA3DCreateFromAsset(int con, AssetManager mgr, String path);
|
|
|
|
synchronized int nFileA3DCreateFromAsset(AssetManager mgr, String path) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 11:12:08 -08:00
|
|
|
return rsnFileA3DCreateFromAsset(mContext, mgr, path);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
native int rsnFileA3DGetNumIndexEntries(int con, int fileA3D);
|
|
|
|
synchronized int nFileA3DGetNumIndexEntries(int fileA3D) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnFileA3DGetNumIndexEntries(mContext, fileA3D);
|
|
|
|
}
|
|
|
|
native void rsnFileA3DGetIndexEntries(int con, int fileA3D, int numEntries, int[] IDs, String[] names);
|
|
|
|
synchronized void nFileA3DGetIndexEntries(int fileA3D, int numEntries, int[] IDs, String[] names) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnFileA3DGetIndexEntries(mContext, fileA3D, numEntries, IDs, names);
|
|
|
|
}
|
|
|
|
native int rsnFileA3DGetEntryByIndex(int con, int fileA3D, int index);
|
|
|
|
synchronized int nFileA3DGetEntryByIndex(int fileA3D, int index) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnFileA3DGetEntryByIndex(mContext, fileA3D, index);
|
|
|
|
}
|
|
|
|
|
2010-12-17 11:41:08 -08:00
|
|
|
native int rsnFontCreateFromFile(int con, String fileName, float size, int dpi);
|
|
|
|
synchronized int nFontCreateFromFile(String fileName, float size, int dpi) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnFontCreateFromFile(mContext, fileName, size, dpi);
|
|
|
|
}
|
2011-01-07 11:12:08 -08:00
|
|
|
native int rsnFontCreateFromAssetStream(int con, String name, float size, int dpi, int assetStream);
|
|
|
|
synchronized int nFontCreateFromAssetStream(String name, float size, int dpi, int assetStream) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 11:12:08 -08:00
|
|
|
return rsnFontCreateFromAssetStream(mContext, name, size, dpi, assetStream);
|
|
|
|
}
|
|
|
|
native int rsnFontCreateFromAsset(int con, AssetManager mgr, String path, float size, int dpi);
|
|
|
|
synchronized int nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2011-01-07 11:12:08 -08:00
|
|
|
return rsnFontCreateFromAsset(mContext, mgr, path, size, dpi);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
|
|
|
|
|
|
|
|
native void rsnScriptBindAllocation(int con, int script, int alloc, int slot);
|
|
|
|
synchronized void nScriptBindAllocation(int script, int alloc, int slot) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptBindAllocation(mContext, script, alloc, slot);
|
|
|
|
}
|
|
|
|
native void rsnScriptSetTimeZone(int con, int script, byte[] timeZone);
|
|
|
|
synchronized void nScriptSetTimeZone(int script, byte[] timeZone) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptSetTimeZone(mContext, script, timeZone);
|
|
|
|
}
|
|
|
|
native void rsnScriptInvoke(int con, int id, int slot);
|
|
|
|
synchronized void nScriptInvoke(int id, int slot) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptInvoke(mContext, id, slot);
|
|
|
|
}
|
|
|
|
native void rsnScriptInvokeV(int con, int id, int slot, byte[] params);
|
|
|
|
synchronized void nScriptInvokeV(int id, int slot, byte[] params) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptInvokeV(mContext, id, slot, params);
|
|
|
|
}
|
|
|
|
native void rsnScriptSetVarI(int con, int id, int slot, int val);
|
|
|
|
synchronized void nScriptSetVarI(int id, int slot, int val) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptSetVarI(mContext, id, slot, val);
|
|
|
|
}
|
2010-10-11 10:54:21 -07:00
|
|
|
native void rsnScriptSetVarJ(int con, int id, int slot, long val);
|
|
|
|
synchronized void nScriptSetVarJ(int id, int slot, long val) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-10-11 10:54:21 -07:00
|
|
|
rsnScriptSetVarJ(mContext, id, slot, val);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
native void rsnScriptSetVarF(int con, int id, int slot, float val);
|
|
|
|
synchronized void nScriptSetVarF(int id, int slot, float val) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptSetVarF(mContext, id, slot, val);
|
|
|
|
}
|
2010-09-20 17:20:30 -07:00
|
|
|
native void rsnScriptSetVarD(int con, int id, int slot, double val);
|
|
|
|
synchronized void nScriptSetVarD(int id, int slot, double val) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-09-20 17:20:30 -07:00
|
|
|
rsnScriptSetVarD(mContext, id, slot, val);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
native void rsnScriptSetVarV(int con, int id, int slot, byte[] val);
|
|
|
|
synchronized void nScriptSetVarV(int id, int slot, byte[] val) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptSetVarV(mContext, id, slot, val);
|
|
|
|
}
|
2010-11-16 17:37:02 -08:00
|
|
|
native void rsnScriptSetVarObj(int con, int id, int slot, int val);
|
|
|
|
synchronized void nScriptSetVarObj(int id, int slot, int val) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-11-16 17:37:02 -08:00
|
|
|
rsnScriptSetVarObj(mContext, id, slot, val);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
|
|
|
|
native void rsnScriptCBegin(int con);
|
|
|
|
synchronized void nScriptCBegin() {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptCBegin(mContext);
|
|
|
|
}
|
|
|
|
native void rsnScriptCSetScript(int con, byte[] script, int offset, int length);
|
|
|
|
synchronized void nScriptCSetScript(byte[] script, int offset, int length) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnScriptCSetScript(mContext, script, offset, length);
|
|
|
|
}
|
2010-12-20 20:45:56 +08:00
|
|
|
native int rsnScriptCCreate(int con, String packageName, String resName, String cacheDir);
|
|
|
|
synchronized int nScriptCCreate(String packageName, String resName, String cacheDir) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-12-20 20:45:56 +08:00
|
|
|
return rsnScriptCCreate(mContext, packageName, resName, cacheDir);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
native void rsnSamplerBegin(int con);
|
|
|
|
synchronized void nSamplerBegin() {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnSamplerBegin(mContext);
|
|
|
|
}
|
|
|
|
native void rsnSamplerSet(int con, int param, int value);
|
|
|
|
synchronized void nSamplerSet(int param, int value) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnSamplerSet(mContext, param, value);
|
|
|
|
}
|
2010-09-30 11:36:37 -07:00
|
|
|
native void rsnSamplerSet2(int con, int param, float value);
|
|
|
|
synchronized void nSamplerSet2(int param, float value) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-09-30 11:36:37 -07:00
|
|
|
rsnSamplerSet2(mContext, param, value);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
native int rsnSamplerCreate(int con);
|
|
|
|
synchronized int nSamplerCreate() {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnSamplerCreate(mContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
native void rsnProgramStoreBegin(int con, int in, int out);
|
|
|
|
synchronized void nProgramStoreBegin(int in, int out) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramStoreBegin(mContext, in, out);
|
|
|
|
}
|
|
|
|
native void rsnProgramStoreDepthFunc(int con, int func);
|
|
|
|
synchronized void nProgramStoreDepthFunc(int func) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramStoreDepthFunc(mContext, func);
|
|
|
|
}
|
|
|
|
native void rsnProgramStoreDepthMask(int con, boolean enable);
|
|
|
|
synchronized void nProgramStoreDepthMask(boolean enable) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramStoreDepthMask(mContext, enable);
|
|
|
|
}
|
|
|
|
native void rsnProgramStoreColorMask(int con, boolean r, boolean g, boolean b, boolean a);
|
|
|
|
synchronized void nProgramStoreColorMask(boolean r, boolean g, boolean b, boolean a) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramStoreColorMask(mContext, r, g, b, a);
|
|
|
|
}
|
|
|
|
native void rsnProgramStoreBlendFunc(int con, int src, int dst);
|
|
|
|
synchronized void nProgramStoreBlendFunc(int src, int dst) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramStoreBlendFunc(mContext, src, dst);
|
|
|
|
}
|
|
|
|
native void rsnProgramStoreDither(int con, boolean enable);
|
|
|
|
synchronized void nProgramStoreDither(boolean enable) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramStoreDither(mContext, enable);
|
|
|
|
}
|
|
|
|
native int rsnProgramStoreCreate(int con);
|
|
|
|
synchronized int nProgramStoreCreate() {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnProgramStoreCreate(mContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
native int rsnProgramRasterCreate(int con, boolean pointSmooth, boolean lineSmooth, boolean pointSprite);
|
|
|
|
synchronized int nProgramRasterCreate(boolean pointSmooth, boolean lineSmooth, boolean pointSprite) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnProgramRasterCreate(mContext, pointSmooth, lineSmooth, pointSprite);
|
|
|
|
}
|
|
|
|
native void rsnProgramRasterSetLineWidth(int con, int pr, float v);
|
|
|
|
synchronized void nProgramRasterSetLineWidth(int pr, float v) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramRasterSetLineWidth(mContext, pr, v);
|
|
|
|
}
|
|
|
|
native void rsnProgramRasterSetCullMode(int con, int pr, int mode);
|
|
|
|
synchronized void nProgramRasterSetCullMode(int pr, int mode) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramRasterSetCullMode(mContext, pr, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
native void rsnProgramBindConstants(int con, int pv, int slot, int mID);
|
|
|
|
synchronized void nProgramBindConstants(int pv, int slot, int mID) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramBindConstants(mContext, pv, slot, mID);
|
|
|
|
}
|
|
|
|
native void rsnProgramBindTexture(int con, int vpf, int slot, int a);
|
|
|
|
synchronized void nProgramBindTexture(int vpf, int slot, int a) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramBindTexture(mContext, vpf, slot, a);
|
|
|
|
}
|
|
|
|
native void rsnProgramBindSampler(int con, int vpf, int slot, int s);
|
|
|
|
synchronized void nProgramBindSampler(int vpf, int slot, int s) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnProgramBindSampler(mContext, vpf, slot, s);
|
|
|
|
}
|
2010-09-23 16:16:33 -07:00
|
|
|
native int rsnProgramFragmentCreate(int con, String shader, int[] params);
|
|
|
|
synchronized int nProgramFragmentCreate(String shader, int[] params) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-09-23 16:16:33 -07:00
|
|
|
return rsnProgramFragmentCreate(mContext, shader, params);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
2010-09-23 16:16:33 -07:00
|
|
|
native int rsnProgramVertexCreate(int con, String shader, int[] params);
|
|
|
|
synchronized int nProgramVertexCreate(String shader, int[] params) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-09-23 16:16:33 -07:00
|
|
|
return rsnProgramVertexCreate(mContext, shader, params);
|
2010-08-17 16:25:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
native int rsnMeshCreate(int con, int vtxCount, int indexCount);
|
|
|
|
synchronized int nMeshCreate(int vtxCount, int indexCount) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnMeshCreate(mContext, vtxCount, indexCount);
|
|
|
|
}
|
|
|
|
native void rsnMeshBindVertex(int con, int id, int alloc, int slot);
|
|
|
|
synchronized void nMeshBindVertex(int id, int alloc, int slot) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnMeshBindVertex(mContext, id, alloc, slot);
|
|
|
|
}
|
|
|
|
native void rsnMeshBindIndex(int con, int id, int alloc, int prim, int slot);
|
|
|
|
synchronized void nMeshBindIndex(int id, int alloc, int prim, int slot) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnMeshBindIndex(mContext, id, alloc, prim, slot);
|
|
|
|
}
|
2010-11-08 15:10:52 -08:00
|
|
|
native void rsnMeshInitVertexAttribs(int con, int id);
|
|
|
|
synchronized void nMeshInitVertexAttribs(int id) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-11-08 15:10:52 -08:00
|
|
|
rsnMeshInitVertexAttribs(mContext, id);
|
|
|
|
}
|
2010-08-17 16:25:41 -07:00
|
|
|
native int rsnMeshGetVertexBufferCount(int con, int id);
|
|
|
|
synchronized int nMeshGetVertexBufferCount(int id) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnMeshGetVertexBufferCount(mContext, id);
|
|
|
|
}
|
|
|
|
native int rsnMeshGetIndexCount(int con, int id);
|
|
|
|
synchronized int nMeshGetIndexCount(int id) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
return rsnMeshGetIndexCount(mContext, id);
|
|
|
|
}
|
|
|
|
native void rsnMeshGetVertices(int con, int id, int[] vtxIds, int vtxIdCount);
|
|
|
|
synchronized void nMeshGetVertices(int id, int[] vtxIds, int vtxIdCount) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnMeshGetVertices(mContext, id, vtxIds, vtxIdCount);
|
|
|
|
}
|
|
|
|
native void rsnMeshGetIndices(int con, int id, int[] idxIds, int[] primitives, int vtxIdCount);
|
|
|
|
synchronized void nMeshGetIndices(int id, int[] idxIds, int[] primitives, int vtxIdCount) {
|
2011-01-18 18:12:26 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount);
|
|
|
|
}
|
|
|
|
|
2009-05-26 13:45:08 -07:00
|
|
|
|
2010-12-06 15:59:59 -08:00
|
|
|
int mDev;
|
|
|
|
int mContext;
|
2009-08-31 14:06:43 -07:00
|
|
|
@SuppressWarnings({"FieldCanBeLocal"})
|
2010-12-06 15:59:59 -08:00
|
|
|
MessageThread mMessageThread;
|
2009-05-26 13:45:08 -07:00
|
|
|
|
2010-06-01 15:47:01 -07:00
|
|
|
Element mElement_U8;
|
|
|
|
Element mElement_I8;
|
|
|
|
Element mElement_U16;
|
|
|
|
Element mElement_I16;
|
|
|
|
Element mElement_U32;
|
|
|
|
Element mElement_I32;
|
2010-10-11 16:10:42 -07:00
|
|
|
Element mElement_U64;
|
2010-10-01 15:39:33 -07:00
|
|
|
Element mElement_I64;
|
2010-06-01 15:47:01 -07:00
|
|
|
Element mElement_F32;
|
2010-09-30 15:19:22 -07:00
|
|
|
Element mElement_F64;
|
2010-06-21 17:42:41 -07:00
|
|
|
Element mElement_BOOLEAN;
|
2010-06-01 15:47:01 -07:00
|
|
|
|
|
|
|
Element mElement_ELEMENT;
|
|
|
|
Element mElement_TYPE;
|
|
|
|
Element mElement_ALLOCATION;
|
|
|
|
Element mElement_SAMPLER;
|
|
|
|
Element mElement_SCRIPT;
|
|
|
|
Element mElement_MESH;
|
|
|
|
Element mElement_PROGRAM_FRAGMENT;
|
|
|
|
Element mElement_PROGRAM_VERTEX;
|
|
|
|
Element mElement_PROGRAM_RASTER;
|
|
|
|
Element mElement_PROGRAM_STORE;
|
2010-03-26 15:33:42 -07:00
|
|
|
|
2009-09-27 17:50:38 -07:00
|
|
|
Element mElement_A_8;
|
|
|
|
Element mElement_RGB_565;
|
|
|
|
Element mElement_RGB_888;
|
|
|
|
Element mElement_RGBA_5551;
|
|
|
|
Element mElement_RGBA_4444;
|
|
|
|
Element mElement_RGBA_8888;
|
|
|
|
|
2010-06-01 15:47:01 -07:00
|
|
|
Element mElement_FLOAT_2;
|
|
|
|
Element mElement_FLOAT_3;
|
|
|
|
Element mElement_FLOAT_4;
|
|
|
|
Element mElement_UCHAR_4;
|
2009-11-15 12:14:26 -08:00
|
|
|
|
2010-08-25 14:31:48 -07:00
|
|
|
Element mElement_MATRIX_4X4;
|
|
|
|
Element mElement_MATRIX_3X3;
|
|
|
|
Element mElement_MATRIX_2X2;
|
|
|
|
|
2010-05-11 14:03:58 -07:00
|
|
|
Sampler mSampler_CLAMP_NEAREST;
|
|
|
|
Sampler mSampler_CLAMP_LINEAR;
|
|
|
|
Sampler mSampler_CLAMP_LINEAR_MIP_LINEAR;
|
|
|
|
Sampler mSampler_WRAP_NEAREST;
|
|
|
|
Sampler mSampler_WRAP_LINEAR;
|
|
|
|
Sampler mSampler_WRAP_LINEAR_MIP_LINEAR;
|
|
|
|
|
2010-08-24 11:37:33 -07:00
|
|
|
ProgramStore mProgramStore_BLEND_NONE_DEPTH_TEST;
|
|
|
|
ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH;
|
|
|
|
ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_TEST;
|
|
|
|
ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH;
|
|
|
|
|
|
|
|
ProgramRaster mProgramRaster_CULL_BACK;
|
|
|
|
ProgramRaster mProgramRaster_CULL_FRONT;
|
|
|
|
ProgramRaster mProgramRaster_CULL_NONE;
|
2010-08-23 10:24:10 -07:00
|
|
|
|
2009-05-26 13:45:08 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2009-05-28 13:38:16 -07:00
|
|
|
//
|
2009-05-26 13:45:08 -07:00
|
|
|
|
2010-11-10 17:00:59 -08:00
|
|
|
/**
|
|
|
|
* Base class application should derive from for handling RS messages
|
2011-02-28 18:20:34 -08:00
|
|
|
* coming from their scripts. When a script calls sendToClient the data
|
2010-11-10 17:00:59 -08:00
|
|
|
* fields will be filled in and then the run method called by a message
|
|
|
|
* handling thread. This will occur some time after sendToClient completes
|
|
|
|
* in the script.
|
|
|
|
*
|
|
|
|
*/
|
2010-12-06 15:59:59 -08:00
|
|
|
public static class RSMessageHandler implements Runnable {
|
2009-10-06 13:58:47 -07:00
|
|
|
protected int[] mData;
|
|
|
|
protected int mID;
|
2010-11-08 17:06:46 -08:00
|
|
|
protected int mLength;
|
2009-10-06 13:58:47 -07:00
|
|
|
public void run() {
|
|
|
|
}
|
|
|
|
}
|
2010-11-10 17:00:59 -08:00
|
|
|
/**
|
|
|
|
* If an application is expecting messages it should set this field to an
|
|
|
|
* instance of RSMessage. This instance will receive all the user messages
|
|
|
|
* sent from sendToClient by scripts from this context.
|
|
|
|
*
|
|
|
|
*/
|
2010-12-06 15:59:59 -08:00
|
|
|
RSMessageHandler mMessageCallback = null;
|
|
|
|
|
|
|
|
public void setMessageHandler(RSMessageHandler msg) {
|
|
|
|
mMessageCallback = msg;
|
|
|
|
}
|
|
|
|
public RSMessageHandler getMessageHandler() {
|
|
|
|
return mMessageCallback;
|
|
|
|
}
|
2009-10-06 13:58:47 -07:00
|
|
|
|
2010-11-10 17:00:59 -08:00
|
|
|
/**
|
|
|
|
* Runtime error base class. An application should derive from this class
|
|
|
|
* if it wishes to install an error handler. When errors occur at runtime
|
|
|
|
* the fields in this class will be filled and the run method called.
|
|
|
|
*
|
|
|
|
*/
|
2010-12-06 15:59:59 -08:00
|
|
|
public static class RSErrorHandler implements Runnable {
|
2010-11-08 17:06:46 -08:00
|
|
|
protected String mErrorMessage;
|
|
|
|
protected int mErrorNum;
|
|
|
|
public void run() {
|
|
|
|
}
|
|
|
|
}
|
2010-11-10 17:00:59 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Application Error handler. All runtime errors will be dispatched to the
|
|
|
|
* instance of RSAsyncError set here. If this field is null a
|
|
|
|
* RSRuntimeException will instead be thrown with details about the error.
|
|
|
|
* This will cause program termaination.
|
|
|
|
*
|
|
|
|
*/
|
2010-12-06 15:59:59 -08:00
|
|
|
RSErrorHandler mErrorCallback = null;
|
|
|
|
|
|
|
|
public void setErrorHandler(RSErrorHandler msg) {
|
|
|
|
mErrorCallback = msg;
|
|
|
|
}
|
|
|
|
public RSErrorHandler getErrorHandler() {
|
|
|
|
return mErrorCallback;
|
|
|
|
}
|
2010-11-08 17:06:46 -08:00
|
|
|
|
2010-11-10 17:00:59 -08:00
|
|
|
/**
|
|
|
|
* RenderScript worker threads priority enumeration. The default value is
|
|
|
|
* NORMAL. Applications wishing to do background processing such as
|
|
|
|
* wallpapers should set their priority to LOW to avoid starving forground
|
|
|
|
* processes.
|
|
|
|
*/
|
2009-11-15 12:14:26 -08:00
|
|
|
public enum Priority {
|
2010-12-06 15:59:59 -08:00
|
|
|
// Remap these numbers to opaque...
|
2009-11-15 12:14:26 -08:00
|
|
|
LOW (5), //ANDROID_PRIORITY_BACKGROUND + 5
|
|
|
|
NORMAL (-4); //ANDROID_PRIORITY_DISPLAY
|
|
|
|
|
|
|
|
int mID;
|
|
|
|
Priority(int id) {
|
|
|
|
mID = id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-07 12:40:12 -08:00
|
|
|
void validate() {
|
|
|
|
if (mContext == 0) {
|
2010-11-04 14:32:19 -07:00
|
|
|
throw new RSInvalidStateException("Calling RS with no Context active.");
|
2009-12-07 12:40:12 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-10 17:00:59 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the priority of the worker threads for this context.
|
|
|
|
*
|
|
|
|
* @param p New priority to be set.
|
|
|
|
*/
|
2010-12-06 15:59:59 -08:00
|
|
|
public void setPriority(Priority p) {
|
2010-01-27 14:41:43 -08:00
|
|
|
validate();
|
2009-11-15 12:14:26 -08:00
|
|
|
nContextSetPriority(p.mID);
|
|
|
|
}
|
|
|
|
|
2010-12-06 15:59:59 -08:00
|
|
|
static class MessageThread extends Thread {
|
2009-10-06 13:58:47 -07:00
|
|
|
RenderScript mRS;
|
|
|
|
boolean mRun = true;
|
2010-12-06 15:59:59 -08:00
|
|
|
int[] mAuxData = new int[2];
|
2010-11-08 17:06:46 -08:00
|
|
|
|
2010-12-06 15:59:59 -08:00
|
|
|
static final int RS_MESSAGE_TO_CLIENT_NONE = 0;
|
|
|
|
static final int RS_MESSAGE_TO_CLIENT_EXCEPTION = 1;
|
|
|
|
static final int RS_MESSAGE_TO_CLIENT_RESIZE = 2;
|
|
|
|
static final int RS_MESSAGE_TO_CLIENT_ERROR = 3;
|
|
|
|
static final int RS_MESSAGE_TO_CLIENT_USER = 4;
|
2009-10-06 13:58:47 -07:00
|
|
|
|
2010-12-06 15:59:59 -08:00
|
|
|
static final int RS_ERROR_FATAL_UNKNOWN = 0x1000;
|
2010-11-22 16:20:16 -08:00
|
|
|
|
2009-10-06 13:58:47 -07:00
|
|
|
MessageThread(RenderScript rs) {
|
|
|
|
super("RSMessageThread");
|
|
|
|
mRS = rs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
// This function is a temporary solution. The final solution will
|
|
|
|
// used typed allocations where the message id is the type indicator.
|
|
|
|
int[] rbuf = new int[16];
|
2010-08-17 16:25:41 -07:00
|
|
|
mRS.nContextInitToClient(mRS.mContext);
|
2009-10-06 13:58:47 -07:00
|
|
|
while(mRun) {
|
2010-08-25 14:31:48 -07:00
|
|
|
rbuf[0] = 0;
|
2010-12-06 15:59:59 -08:00
|
|
|
int msg = mRS.nContextPeekMessage(mRS.mContext, mAuxData, true);
|
|
|
|
int size = mAuxData[1];
|
|
|
|
int subID = mAuxData[0];
|
2010-11-08 17:06:46 -08:00
|
|
|
|
|
|
|
if (msg == RS_MESSAGE_TO_CLIENT_USER) {
|
|
|
|
if ((size>>2) >= rbuf.length) {
|
|
|
|
rbuf = new int[(size + 3) >> 2];
|
|
|
|
}
|
|
|
|
mRS.nContextGetUserMessage(mRS.mContext, rbuf);
|
|
|
|
|
|
|
|
if(mRS.mMessageCallback != null) {
|
|
|
|
mRS.mMessageCallback.mData = rbuf;
|
|
|
|
mRS.mMessageCallback.mID = subID;
|
|
|
|
mRS.mMessageCallback.mLength = size;
|
|
|
|
mRS.mMessageCallback.run();
|
2010-08-25 14:31:48 -07:00
|
|
|
} else {
|
2010-11-08 17:06:46 -08:00
|
|
|
throw new RSInvalidStateException("Received a message from the script with no message handler installed.");
|
2009-10-06 13:58:47 -07:00
|
|
|
}
|
2010-09-24 14:38:30 -07:00
|
|
|
continue;
|
2009-10-06 13:58:47 -07:00
|
|
|
}
|
2010-11-08 17:06:46 -08:00
|
|
|
|
|
|
|
if (msg == RS_MESSAGE_TO_CLIENT_ERROR) {
|
|
|
|
String e = mRS.nContextGetErrorMessage(mRS.mContext);
|
|
|
|
|
2010-11-22 16:20:16 -08:00
|
|
|
if (subID >= RS_ERROR_FATAL_UNKNOWN) {
|
|
|
|
throw new RSRuntimeException("Fatal error " + subID + ", details: " + e);
|
|
|
|
}
|
|
|
|
|
2010-11-08 17:06:46 -08:00
|
|
|
if(mRS.mErrorCallback != null) {
|
|
|
|
mRS.mErrorCallback.mErrorMessage = e;
|
|
|
|
mRS.mErrorCallback.mErrorNum = subID;
|
|
|
|
mRS.mErrorCallback.run();
|
|
|
|
} else {
|
|
|
|
//throw new RSRuntimeException("Received error num " + subID + ", details: " + e);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2: teardown.
|
|
|
|
// But we want to avoid starving other threads during
|
|
|
|
// teardown by yielding until the next line in the destructor
|
|
|
|
// can execute to set mRun = false
|
|
|
|
try {
|
|
|
|
sleep(1, 0);
|
|
|
|
} catch(InterruptedException e) {
|
2009-10-06 13:58:47 -07:00
|
|
|
}
|
|
|
|
}
|
2009-11-12 15:10:25 -08:00
|
|
|
Log.d(LOG_TAG, "MessageThread exiting.");
|
2009-10-06 13:58:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-10 01:03:59 -08:00
|
|
|
RenderScript(Context ctx) {
|
|
|
|
mApplicationContext = ctx.getApplicationContext();
|
2009-05-26 13:45:08 -07:00
|
|
|
}
|
|
|
|
|
2010-11-10 17:00:59 -08:00
|
|
|
/**
|
2010-12-10 01:03:59 -08:00
|
|
|
* Gets the application context associated with the RenderScript context.
|
2010-11-10 17:00:59 -08:00
|
|
|
*
|
2010-12-10 01:03:59 -08:00
|
|
|
* @return The application context.
|
|
|
|
*/
|
|
|
|
public final Context getApplicationContext() {
|
|
|
|
return mApplicationContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a basic RenderScript context.
|
2010-11-10 17:00:59 -08:00
|
|
|
*
|
2010-12-10 01:03:59 -08:00
|
|
|
* @param ctx The context.
|
2010-11-10 17:00:59 -08:00
|
|
|
* @return RenderScript
|
|
|
|
*/
|
2010-12-10 01:03:59 -08:00
|
|
|
public static RenderScript create(Context ctx) {
|
|
|
|
RenderScript rs = new RenderScript(ctx);
|
2010-02-09 16:05:07 -08:00
|
|
|
|
|
|
|
rs.mDev = rs.nDeviceCreate();
|
|
|
|
rs.mContext = rs.nContextCreate(rs.mDev, 0);
|
|
|
|
rs.mMessageThread = new MessageThread(rs);
|
|
|
|
rs.mMessageThread.start();
|
|
|
|
return rs;
|
2009-11-03 13:58:36 -08:00
|
|
|
}
|
|
|
|
|
2010-11-10 17:00:59 -08:00
|
|
|
/**
|
|
|
|
* Print the currently available debugging information about the state of
|
|
|
|
* the RS context to the log.
|
|
|
|
*
|
|
|
|
*/
|
2010-12-06 15:59:59 -08:00
|
|
|
public void contextDump() {
|
2010-01-27 14:41:43 -08:00
|
|
|
validate();
|
2010-12-06 15:59:59 -08:00
|
|
|
nContextDump(0);
|
2009-11-17 17:26:46 -08:00
|
|
|
}
|
|
|
|
|
2010-11-10 17:00:59 -08:00
|
|
|
/**
|
|
|
|
* Wait for any commands in the fifo between the java bindings and native to
|
|
|
|
* be processed.
|
|
|
|
*
|
|
|
|
*/
|
2010-06-15 12:15:57 -07:00
|
|
|
public void finish() {
|
|
|
|
nContextFinish();
|
|
|
|
}
|
|
|
|
|
2010-11-10 17:00:59 -08:00
|
|
|
/**
|
|
|
|
* Destroy this renderscript context. Once this function is called its no
|
|
|
|
* longer legal to use this or any objects created by this context.
|
|
|
|
*
|
|
|
|
*/
|
2009-08-25 14:49:07 -07:00
|
|
|
public void destroy() {
|
2010-01-27 14:41:43 -08:00
|
|
|
validate();
|
2010-08-17 16:25:41 -07:00
|
|
|
nContextDeinitToClient(mContext);
|
2009-10-06 13:58:47 -07:00
|
|
|
mMessageThread.mRun = false;
|
2010-09-16 13:43:19 -07:00
|
|
|
try {
|
|
|
|
mMessageThread.join();
|
|
|
|
} catch(InterruptedException e) {
|
|
|
|
}
|
2009-10-06 13:58:47 -07:00
|
|
|
|
2010-08-17 16:25:41 -07:00
|
|
|
nContextDestroy();
|
2009-08-25 14:49:07 -07:00
|
|
|
mContext = 0;
|
|
|
|
|
|
|
|
nDeviceDestroy(mDev);
|
|
|
|
mDev = 0;
|
|
|
|
}
|
2009-05-28 15:37:57 -07:00
|
|
|
|
2009-09-25 14:51:22 -07:00
|
|
|
boolean isAlive() {
|
|
|
|
return mContext != 0;
|
|
|
|
}
|
|
|
|
|
2010-12-06 15:59:59 -08:00
|
|
|
int safeID(BaseObj o) {
|
2009-09-23 16:38:37 -07:00
|
|
|
if(o != null) {
|
2010-11-09 17:11:40 -08:00
|
|
|
return o.getID();
|
2009-08-20 17:22:40 -07:00
|
|
|
}
|
2009-09-23 16:38:37 -07:00
|
|
|
return 0;
|
2009-05-26 13:45:08 -07:00
|
|
|
}
|
|
|
|
}
|