RenderScript.java revision 52d836332f6aae74ed97fda1b53681f36710af64
160aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich/* 260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * Copyright (C) 2008 The Android Open Source Project 360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * 460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * Licensed under the Apache License, Version 2.0 (the "License"); 560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * you may not use this file except in compliance with the License. 660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * You may obtain a copy of the License at 760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * 860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * http://www.apache.org/licenses/LICENSE-2.0 960aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * 1060aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * Unless required by applicable law or agreed to in writing, software 1160aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * distributed under the License is distributed on an "AS IS" BASIS, 1260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * See the License for the specific language governing permissions and 1460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * limitations under the License. 1560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich */ 1660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 1794d8e90ad78ee1dbc0efa315117688abd126ae55Jason Samspackage android.renderscript; 1860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 1943ee06857bb7f99446d1d84f8789016c5d105558Jason Samsimport java.lang.reflect.Field; 2036e612a488511940b61f09803b270aa1c61b68e0Jason Sams 21b8c5a84e7c23746a3fc26013e0880d3d95ca6588Jason Samsimport android.graphics.Bitmap; 22650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guyimport android.graphics.BitmapFactory; 2336e612a488511940b61f09803b270aa1c61b68e0Jason Samsimport android.util.Config; 2436e612a488511940b61f09803b270aa1c61b68e0Jason Samsimport android.util.Log; 2536e612a488511940b61f09803b270aa1c61b68e0Jason Samsimport android.view.Surface; 2643702d8925c54360ad5f9f66b0d35d61d59f6910Jack Palevich 2760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 28e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams/** 29e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams * @hide 30e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams * 31e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams **/ 3260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevichpublic class RenderScript { 333bc47d438171dce294e816366d53bc9eca772c5bJason Sams static final String LOG_TAG = "RenderScript_jni"; 34704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected static final boolean DEBUG = false; 35650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guy @SuppressWarnings({"UnusedDeclaration", "deprecation"}) 36704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV; 3760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 3860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 3960aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 4002fb2cb531035779a25dbf9595e0628ea40585b0Jason Sams /* 4160aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * We use a class initializer to allow the native code to cache some 4260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * field offsets. 4360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich */ 44650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guy @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) 45704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected static boolean sInitialized; 46704ff64b099406bb328898a7443921f22dbffd6dJason Sams native protected static void _nInit(); 4760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 48dba3ba5b5bf6026abceced921b1b0d231b0faefdJason Sams 4960aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich static { 5060aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich sInitialized = false; 5160aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich try { 52e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams System.loadLibrary("rs_jni"); 5360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich _nInit(); 5460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich sInitialized = true; 5560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } catch (UnsatisfiedLinkError e) { 5660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich Log.d(LOG_TAG, "RenderScript JNI library not found!"); 5760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 5860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 5960aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 602e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // Non-threadsafe functions. 61ea84a7c51790f9ba5f2194a66d6cf4ea8d879776Jason Sams native void nInitElements(int a8, int rgba4444, int rgba8888, int rgb565); 6236e612a488511940b61f09803b270aa1c61b68e0Jason Sams native int nDeviceCreate(); 6336e612a488511940b61f09803b270aa1c61b68e0Jason Sams native void nDeviceDestroy(int dev); 64ebfb436a49673693b98469683451bd9ede797557Jason Sams native void nDeviceSetConfig(int dev, int param, int value); 652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int nContextGetMessage(int con, int[] data, boolean wait); 662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void nContextInitToClient(int con); 672e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void nContextDeinitToClient(int con); 682e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 692e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // Methods below are wrapped to protect the non-threadsafe 712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // lockless fifo. 722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnContextCreateGL(int dev, int ver, boolean useDepth); 732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nContextCreateGL(int dev, int ver, boolean useDepth) { 742e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnContextCreateGL(dev, ver, useDepth); 752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnContextCreate(int dev, int ver); 772e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nContextCreate(int dev, int ver) { 782e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnContextCreate(dev, ver); 792e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 802e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextDestroy(int con); 812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextDestroy() { 822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextDestroy(mContext); 832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextSetSurface(int con, int w, int h, Surface sur); 852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextSetSurface(int w, int h, Surface sur) { 862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextSetSurface(mContext, w, h, sur); 872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextSetPriority(int con, int p); 892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextSetPriority(int p) { 902e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextSetPriority(mContext, p); 912e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextDump(int con, int bits); 932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextDump(int bits) { 942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextDump(mContext, bits); 952e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 962e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextFinish(int con); 972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextFinish() { 982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextFinish(mContext); 992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1002e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 1012e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindRootScript(int con, int script); 1022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindRootScript(int script) { 1032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindRootScript(mContext, script); 1042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindSampler(int con, int sampler, int slot); 1062e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindSampler(int sampler, int slot) { 1072e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindSampler(mContext, sampler, slot); 1082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1092e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramStore(int con, int pfs); 1102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramStore(int pfs) { 1112e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramStore(mContext, pfs); 1122e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1132e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramFragment(int con, int pf); 1142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramFragment(int pf) { 1152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramFragment(mContext, pf); 1162e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramVertex(int con, int pv); 1182e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramVertex(int pv) { 1192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramVertex(mContext, pv); 1202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1212e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramRaster(int con, int pr); 1222e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramRaster(int pr) { 1232e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramRaster(mContext, pr); 1242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1252e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextPause(int con); 1262e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextPause() { 1272e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextPause(mContext); 1282e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1292e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextResume(int con); 1302e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextResume() { 1312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextResume(mContext); 1322e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1332e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 1342e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAssignName(int con, int obj, byte[] name); 1352e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAssignName(int obj, byte[] name) { 1362e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAssignName(mContext, obj, name); 1372e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1382e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native String rsnGetName(int con, int obj); 1392e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized String nGetName(int obj) { 1402e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnGetName(mContext, obj); 1412e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1422e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnObjDestroy(int con, int id); 1432e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nObjDestroy(int id) { 1442e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnObjDestroy(mContext, id); 1452e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileOpen(int con, byte[] name); 1472e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileOpen(byte[] name) { 1482e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileOpen(mContext, name); 1492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 1512e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize); 1522e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nElementCreate(int type, int kind, boolean norm, int vecSize) { 1532e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnElementCreate(mContext, type, kind, norm, vecSize); 1542e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 15570d4e5024298f71edb3b04867e05568f5495b4ceJason Sams native int rsnElementCreate2(int con, int[] elements, String[] names, int[] arraySizes); 15670d4e5024298f71edb3b04867e05568f5495b4ceJason Sams synchronized int nElementCreate2(int[] elements, String[] names, int[] arraySizes) { 15770d4e5024298f71edb3b04867e05568f5495b4ceJason Sams return rsnElementCreate2(mContext, elements, names, arraySizes); 1582e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1592e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnElementGetNativeData(int con, int id, int[] elementData); 1602e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nElementGetNativeData(int id, int[] elementData) { 1612e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnElementGetNativeData(mContext, id, elementData); 1622e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1632e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnElementGetSubElements(int con, int id, int[] IDs, String[] names); 1642e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nElementGetSubElements(int id, int[] IDs, String[] names) { 1652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnElementGetSubElements(mContext, id, IDs, names); 1662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1672e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 1682e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnTypeBegin(int con, int elementID); 1692e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nTypeBegin(int elementID) { 1702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnTypeBegin(mContext, elementID); 1712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnTypeAdd(int con, int dim, int val); 1732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nTypeAdd(int dim, int val) { 1742e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnTypeAdd(mContext, dim, val); 1752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnTypeCreate(int con); 1772e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nTypeCreate() { 1782e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnTypeCreate(mContext); 1792e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1802e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnTypeGetNativeData(int con, int id, int[] typeData); 1812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nTypeGetNativeData(int id, int[] typeData) { 1822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnTypeGetNativeData(mContext, id, typeData); 1832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 1852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationCreateTyped(int con, int type); 1862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationCreateTyped(int type) { 1872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationCreateTyped(mContext, type); 1882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 18926ae3904e8050eae655722caf93ee5d3f0ab195aAlex Sakhartchouk native void rsnAllocationUpdateFromBitmap(int con, int alloc, Bitmap bmp); 19026ae3904e8050eae655722caf93ee5d3f0ab195aAlex Sakhartchouk synchronized void nAllocationUpdateFromBitmap(int alloc, Bitmap bmp) { 19126ae3904e8050eae655722caf93ee5d3f0ab195aAlex Sakhartchouk rsnAllocationUpdateFromBitmap(mContext, alloc, bmp); 19226ae3904e8050eae655722caf93ee5d3f0ab195aAlex Sakhartchouk } 1932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationCreateFromBitmap(int con, int dstFmt, boolean genMips, Bitmap bmp); 1942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp) { 1952e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationCreateFromBitmap(mContext, dstFmt, genMips, bmp); 1962e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationCreateBitmapRef(int con, int type, Bitmap bmp); 1982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationCreateBitmapRef(int type, Bitmap bmp) { 1992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationCreateBitmapRef(mContext, type, bmp); 2002e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2012e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationCreateFromAssetStream(int con, int dstFmt, boolean genMips, int assetStream); 2022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationCreateFromAssetStream(int dstFmt, boolean genMips, int assetStream) { 2032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationCreateFromAssetStream(mContext, dstFmt, genMips, assetStream); 2042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2062e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationUploadToTexture(int con, int alloc, boolean genMips, int baseMioLevel); 2072e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationUploadToTexture(int alloc, boolean genMips, int baseMioLevel) { 2082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationUploadToTexture(mContext, alloc, genMips, baseMioLevel); 2092e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationUploadToBufferObject(int con, int alloc); 2112e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationUploadToBufferObject(int alloc) { 2122e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationUploadToBufferObject(mContext, alloc); 2132e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationSubData1D(int con, int id, int off, int count, int[] d, int sizeBytes); 2162e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationSubData1D(int id, int off, int count, int[] d, int sizeBytes) { 2172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); 2182e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationSubData1D(int con, int id, int off, int count, short[] d, int sizeBytes); 2202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationSubData1D(int id, int off, int count, short[] d, int sizeBytes) { 2212e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); 2222e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2232e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationSubData1D(int con, int id, int off, int count, byte[] d, int sizeBytes); 2242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationSubData1D(int id, int off, int count, byte[] d, int sizeBytes) { 2252e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); 2262e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 22749bdaf0293408159df18a1d8540360f9623c40f7Jason Sams native void rsnAllocationSubElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); 22849bdaf0293408159df18a1d8540360f9623c40f7Jason Sams synchronized void nAllocationSubElementData1D(int id, int xoff, int compIdx, byte[] d, int sizeBytes) { 22949bdaf0293408159df18a1d8540360f9623c40f7Jason Sams rsnAllocationSubElementData1D(mContext, id, xoff, compIdx, d, sizeBytes); 23049bdaf0293408159df18a1d8540360f9623c40f7Jason Sams } 2312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationSubData1D(int con, int id, int off, int count, float[] d, int sizeBytes); 2322e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationSubData1D(int id, int off, int count, float[] d, int sizeBytes) { 2332e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); 2342e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2352e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2362e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationSubData2D(int con, int id, int xoff, int yoff, int w, int h, int[] d, int sizeBytes); 2372e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, int[] d, int sizeBytes) { 2382e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationSubData2D(mContext, id, xoff, yoff, w, h, d, sizeBytes); 2392e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2402e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationSubData2D(int con, int id, int xoff, int yoff, int w, int h, float[] d, int sizeBytes); 2412e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, float[] d, int sizeBytes) { 2422e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationSubData2D(mContext, id, xoff, yoff, w, h, d, sizeBytes); 2432e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2442e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationRead(int con, int id, int[] d); 2452e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationRead(int id, int[] d) { 2462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationRead(mContext, id, d); 2472e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2482e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationRead(int con, int id, float[] d); 2492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationRead(int id, float[] d) { 2502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationRead(mContext, id, d); 2512e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2522e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationGetType(int con, int id); 2532e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationGetType(int id) { 2542e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationGetType(mContext, id); 2552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2575edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams native void rsnAllocationResize1D(int con, int id, int dimX); 2585edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams synchronized void nAllocationResize1D(int id, int dimX) { 2595edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams rsnAllocationResize1D(mContext, id, dimX); 2605edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams } 2615edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams native void rsnAllocationResize2D(int con, int id, int dimX, int dimY); 2625edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams synchronized void nAllocationResize2D(int id, int dimX, int dimY) { 2635edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams rsnAllocationResize2D(mContext, id, dimX, dimY); 2645edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams } 2655edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams 2662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DCreateFromAssetStream(int con, int assetStream); 2672e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DCreateFromAssetStream(int assetStream) { 2682e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DCreateFromAssetStream(mContext, assetStream); 2692e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DGetNumIndexEntries(int con, int fileA3D); 2712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DGetNumIndexEntries(int fileA3D) { 2722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DGetNumIndexEntries(mContext, fileA3D); 2732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2742e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnFileA3DGetIndexEntries(int con, int fileA3D, int numEntries, int[] IDs, String[] names); 2752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nFileA3DGetIndexEntries(int fileA3D, int numEntries, int[] IDs, String[] names) { 2762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnFileA3DGetIndexEntries(mContext, fileA3D, numEntries, IDs, names); 2772e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2782e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DGetEntryByIndex(int con, int fileA3D, int index); 2792e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DGetEntryByIndex(int fileA3D, int index) { 2802e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DGetEntryByIndex(mContext, fileA3D, index); 2812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFontCreateFromFile(int con, String fileName, int size, int dpi); 2842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFontCreateFromFile(String fileName, int size, int dpi) { 2852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFontCreateFromFile(mContext, fileName, size, dpi); 2862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter1DBindAllocation(int con, int ad, int alloc); 2892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter1DBindAllocation(int ad, int alloc) { 2902e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter1DBindAllocation(mContext, ad, alloc); 2912e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter1DSetConstraint(int con, int ad, int dim, int value); 2932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter1DSetConstraint(int ad, int dim, int value) { 2942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter1DSetConstraint(mContext, ad, dim, value); 2952e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2962e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter1DData(int con, int ad, int[] d); 2972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter1DData(int ad, int[] d) { 2982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter1DData(mContext, ad, d); 2992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3002e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter1DData(int con, int ad, float[] d); 3012e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter1DData(int ad, float[] d) { 3022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter1DData(mContext, ad, d); 3032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter1DSubData(int con, int ad, int off, int count, int[] d); 3052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter1DSubData(int ad, int off, int count, int[] d) { 3062e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter1DSubData(mContext, ad, off, count, d); 3072e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter1DSubData(int con, int ad, int off, int count, float[] d); 3092e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter1DSubData(int ad, int off, int count, float[] d) { 3102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter1DSubData(mContext, ad, off, count, d); 3112e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3122e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAdapter1DCreate(int con); 3132e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAdapter1DCreate() { 3142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAdapter1DCreate(mContext); 3152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3162e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 3172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter2DBindAllocation(int con, int ad, int alloc); 3182e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter2DBindAllocation(int ad, int alloc) { 3192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter2DBindAllocation(mContext, ad, alloc); 3202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3212e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter2DSetConstraint(int con, int ad, int dim, int value); 3222e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter2DSetConstraint(int ad, int dim, int value) { 3232e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter2DSetConstraint(mContext, ad, dim, value); 3242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3252e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter2DData(int con, int ad, int[] d); 3262e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter2DData(int ad, int[] d) { 3272e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter2DData(mContext, ad, d); 3282e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3292e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter2DData(int con, int ad, float[] d); 3302e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter2DData(int ad, float[] d) { 3312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter2DData(mContext, ad, d); 3322e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3332e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter2DSubData(int con, int ad, int xoff, int yoff, int w, int h, int[] d); 3342e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter2DSubData(int ad, int xoff, int yoff, int w, int h, int[] d) { 3352e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter2DSubData(mContext, ad, xoff, yoff, w, h, d); 3362e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3372e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAdapter2DSubData(int con, int ad, int xoff, int yoff, int w, int h, float[] d); 3382e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAdapter2DSubData(int ad, int xoff, int yoff, int w, int h, float[] d) { 3392e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAdapter2DSubData(mContext, ad, xoff, yoff, w, h, d); 3402e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3412e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAdapter2DCreate(int con); 3422e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAdapter2DCreate() { 3432e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAdapter2DCreate(mContext); 3442e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3452e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 3462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptBindAllocation(int con, int script, int alloc, int slot); 3472e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptBindAllocation(int script, int alloc, int slot) { 3482e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptBindAllocation(mContext, script, alloc, slot); 3492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetTimeZone(int con, int script, byte[] timeZone); 3512e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetTimeZone(int script, byte[] timeZone) { 3522e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetTimeZone(mContext, script, timeZone); 3532e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3542e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptInvoke(int con, int id, int slot); 3552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptInvoke(int id, int slot) { 3562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptInvoke(mContext, id, slot); 3572e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3582e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptInvokeV(int con, int id, int slot, byte[] params); 3592e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptInvokeV(int id, int slot, byte[] params) { 3602e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptInvokeV(mContext, id, slot, params); 3612e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3622e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarI(int con, int id, int slot, int val); 3632e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarI(int id, int slot, int val) { 3642e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarI(mContext, id, slot, val); 3652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 366031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines native void rsnScriptSetVarJ(int con, int id, int slot, long val); 367031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines synchronized void nScriptSetVarJ(int id, int slot, long val) { 368031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines rsnScriptSetVarJ(mContext, id, slot, val); 369031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines } 3702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarF(int con, int id, int slot, float val); 3712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarF(int id, int slot, float val) { 3722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarF(mContext, id, slot, val); 3732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 374ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines native void rsnScriptSetVarD(int con, int id, int slot, double val); 375ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines synchronized void nScriptSetVarD(int id, int slot, double val) { 376ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines rsnScriptSetVarD(mContext, id, slot, val); 377ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines } 3782e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarV(int con, int id, int slot, byte[] val); 3792e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarV(int id, int slot, byte[] val) { 3802e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarV(mContext, id, slot, val); 3812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 3832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptCBegin(int con); 3842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptCBegin() { 3852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptCBegin(mContext); 3862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptCSetScript(int con, byte[] script, int offset, int length); 3882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptCSetScript(byte[] script, int offset, int length) { 3892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptCSetScript(mContext, script, offset, length); 3902e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3912e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnScriptCCreate(int con); 3922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nScriptCCreate() { 3932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnScriptCCreate(mContext); 3942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3952e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 3962e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnSamplerBegin(int con); 3972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nSamplerBegin() { 3982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnSamplerBegin(mContext); 3992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4002e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnSamplerSet(int con, int param, int value); 4012e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nSamplerSet(int param, int value) { 4022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnSamplerSet(mContext, param, value); 4032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 404f5b3510c706ed1f7611760dff0c94f2111531c68Alex Sakhartchouk native void rsnSamplerSet2(int con, int param, float value); 405f5b3510c706ed1f7611760dff0c94f2111531c68Alex Sakhartchouk synchronized void nSamplerSet2(int param, float value) { 406f5b3510c706ed1f7611760dff0c94f2111531c68Alex Sakhartchouk rsnSamplerSet2(mContext, param, value); 407f5b3510c706ed1f7611760dff0c94f2111531c68Alex Sakhartchouk } 4082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnSamplerCreate(int con); 4092e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nSamplerCreate() { 4102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnSamplerCreate(mContext); 4112e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4122e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 4132e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramStoreBegin(int con, int in, int out); 4142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramStoreBegin(int in, int out) { 4152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramStoreBegin(mContext, in, out); 4162e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramStoreDepthFunc(int con, int func); 4182e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramStoreDepthFunc(int func) { 4192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramStoreDepthFunc(mContext, func); 4202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4212e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramStoreDepthMask(int con, boolean enable); 4222e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramStoreDepthMask(boolean enable) { 4232e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramStoreDepthMask(mContext, enable); 4242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4252e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramStoreColorMask(int con, boolean r, boolean g, boolean b, boolean a); 4262e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramStoreColorMask(boolean r, boolean g, boolean b, boolean a) { 4272e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramStoreColorMask(mContext, r, g, b, a); 4282e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4292e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramStoreBlendFunc(int con, int src, int dst); 4302e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramStoreBlendFunc(int src, int dst) { 4312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramStoreBlendFunc(mContext, src, dst); 4322e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4332e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramStoreDither(int con, boolean enable); 4342e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramStoreDither(boolean enable) { 4352e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramStoreDither(mContext, enable); 4362e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4372e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnProgramStoreCreate(int con); 4382e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nProgramStoreCreate() { 4392e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnProgramStoreCreate(mContext); 4402e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4412e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 4422e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnProgramRasterCreate(int con, boolean pointSmooth, boolean lineSmooth, boolean pointSprite); 4432e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nProgramRasterCreate(boolean pointSmooth, boolean lineSmooth, boolean pointSprite) { 4442e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnProgramRasterCreate(mContext, pointSmooth, lineSmooth, pointSprite); 4452e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramRasterSetLineWidth(int con, int pr, float v); 4472e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramRasterSetLineWidth(int pr, float v) { 4482e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramRasterSetLineWidth(mContext, pr, v); 4492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramRasterSetCullMode(int con, int pr, int mode); 4512e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramRasterSetCullMode(int pr, int mode) { 4522e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramRasterSetCullMode(mContext, pr, mode); 4532e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4542e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 4552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindConstants(int con, int pv, int slot, int mID); 4562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindConstants(int pv, int slot, int mID) { 4572e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindConstants(mContext, pv, slot, mID); 4582e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4592e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindTexture(int con, int vpf, int slot, int a); 4602e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindTexture(int vpf, int slot, int a) { 4612e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindTexture(mContext, vpf, slot, a); 4622e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4632e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindSampler(int con, int vpf, int slot, int s); 4642e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindSampler(int vpf, int slot, int s) { 4652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindSampler(mContext, vpf, slot, s); 4662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 467b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk native int rsnProgramFragmentCreate(int con, String shader, int[] params); 468b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk synchronized int nProgramFragmentCreate(String shader, int[] params) { 469b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk return rsnProgramFragmentCreate(mContext, shader, params); 4702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 471b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk native int rsnProgramVertexCreate(int con, String shader, int[] params); 472b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk synchronized int nProgramVertexCreate(String shader, int[] params) { 473b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk return rsnProgramVertexCreate(mContext, shader, params); 4742e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 4762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnMeshCreate(int con, int vtxCount, int indexCount); 4772e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nMeshCreate(int vtxCount, int indexCount) { 4782e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnMeshCreate(mContext, vtxCount, indexCount); 4792e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4802e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnMeshBindVertex(int con, int id, int alloc, int slot); 4812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nMeshBindVertex(int id, int alloc, int slot) { 4822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnMeshBindVertex(mContext, id, alloc, slot); 4832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnMeshBindIndex(int con, int id, int alloc, int prim, int slot); 4852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nMeshBindIndex(int id, int alloc, int prim, int slot) { 4862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnMeshBindIndex(mContext, id, alloc, prim, slot); 4872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnMeshGetVertexBufferCount(int con, int id); 4892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nMeshGetVertexBufferCount(int id) { 4902e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnMeshGetVertexBufferCount(mContext, id); 4912e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnMeshGetIndexCount(int con, int id); 4932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nMeshGetIndexCount(int id) { 4942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnMeshGetIndexCount(mContext, id); 4952e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4962e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnMeshGetVertices(int con, int id, int[] vtxIds, int vtxIdCount); 4972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nMeshGetVertices(int id, int[] vtxIds, int vtxIdCount) { 4982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnMeshGetVertices(mContext, id, vtxIds, vtxIdCount); 4992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5002e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnMeshGetIndices(int con, int id, int[] idxIds, int[] primitives, int vtxIdCount); 5012e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nMeshGetIndices(int id, int[] idxIds, int[] primitives, int vtxIdCount) { 5022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount); 5032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 50560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 506704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected int mDev; 507704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected int mContext; 508650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guy @SuppressWarnings({"FieldCanBeLocal"}) 509704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected MessageThread mMessageThread; 51060aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 5118cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U8; 5128cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I8; 5138cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U16; 5148cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I16; 5158cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U32; 5168cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I32; 51752d836332f6aae74ed97fda1b53681f36710af64Stephen Hines Element mElement_U64; 518ef1dac28d3bf98bd61cd9874fb3ccab42105e9b6Stephen Hines Element mElement_I64; 5198cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_F32; 52002f41705199336f808ece50d81585450e7f8f61fStephen Hines Element mElement_F64; 521f110d4b787b91dabe968a812e76e5c1f8d953487Jason Sams Element mElement_BOOLEAN; 5228cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams 5238cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_ELEMENT; 5248cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_TYPE; 5258cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_ALLOCATION; 5268cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_SAMPLER; 5278cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_SCRIPT; 5288cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_MESH; 5298cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_FRAGMENT; 5308cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_VERTEX; 5318cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_RASTER; 5328cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_STORE; 533a70f416c9cf2fc6cc5e132c1d656ce07441d6b82Jason Sams 5343c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_A_8; 5353c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGB_565; 5363c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGB_888; 5373c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_5551; 5383c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_4444; 5393c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_8888; 5403c0dfbab807a459622aeade4940daddf482dec66Jason Sams 5418cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_2; 5428cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_3; 5438cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_4; 5448cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_UCHAR_4; 5457d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 5461d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_4X4; 5471d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_3X3; 5481d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_2X2; 5491d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams 5504d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_NEAREST; 5514d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_LINEAR; 5524d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_LINEAR_MIP_LINEAR; 5534d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_NEAREST; 5544d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_LINEAR; 5554d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_LINEAR_MIP_LINEAR; 5564d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams 557d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_NONE_DEPTH_TEST; 558d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH; 559d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_TEST; 560d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_WRITE; 561d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_TEST; 562d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH; 563d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_TEST; 564d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_WRITE; 565d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ADD_DEPTH_TEST; 566d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ADD_DEPTH_NO_DEPTH; 567d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ADD_DEPTH_NO_TEST; 568d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ADD_DEPTH_NO_WRITE; 569d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk 570d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_BACK; 571d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_FRONT; 572d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_NONE; 57332e09b5891da0174f161d99e2d3ebe67d6efa39cAlex Sakhartchouk 57460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich /////////////////////////////////////////////////////////////////////////////////// 57543702d8925c54360ad5f9f66b0d35d61d59f6910Jack Palevich // 57660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 577516c31911578db8ce53529483c3ded918ac7dc6bJason Sams public static class RSMessage implements Runnable { 578516c31911578db8ce53529483c3ded918ac7dc6bJason Sams protected int[] mData; 579516c31911578db8ce53529483c3ded918ac7dc6bJason Sams protected int mID; 580516c31911578db8ce53529483c3ded918ac7dc6bJason Sams public void run() { 581516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 582516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 583516c31911578db8ce53529483c3ded918ac7dc6bJason Sams public RSMessage mMessageCallback = null; 584516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 5857d787b4722eaeb79cab42c36060336e092b77b5fJason Sams public enum Priority { 5867d787b4722eaeb79cab42c36060336e092b77b5fJason Sams LOW (5), //ANDROID_PRIORITY_BACKGROUND + 5 5877d787b4722eaeb79cab42c36060336e092b77b5fJason Sams NORMAL (-4); //ANDROID_PRIORITY_DISPLAY 5887d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 5897d787b4722eaeb79cab42c36060336e092b77b5fJason Sams int mID; 5907d787b4722eaeb79cab42c36060336e092b77b5fJason Sams Priority(int id) { 5917d787b4722eaeb79cab42c36060336e092b77b5fJason Sams mID = id; 5927d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 5937d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 5947d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 595771bebb94054d06f97284379c93a2620613513c3Jason Sams void validate() { 596771bebb94054d06f97284379c93a2620613513c3Jason Sams if (mContext == 0) { 597771bebb94054d06f97284379c93a2620613513c3Jason Sams throw new IllegalStateException("Calling RS with no Context active."); 598771bebb94054d06f97284379c93a2620613513c3Jason Sams } 599771bebb94054d06f97284379c93a2620613513c3Jason Sams } 600771bebb94054d06f97284379c93a2620613513c3Jason Sams 6017d787b4722eaeb79cab42c36060336e092b77b5fJason Sams public void contextSetPriority(Priority p) { 6025dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 6037d787b4722eaeb79cab42c36060336e092b77b5fJason Sams nContextSetPriority(p.mID); 6047d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 6057d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 606704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected static class MessageThread extends Thread { 607516c31911578db8ce53529483c3ded918ac7dc6bJason Sams RenderScript mRS; 608516c31911578db8ce53529483c3ded918ac7dc6bJason Sams boolean mRun = true; 609516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 610516c31911578db8ce53529483c3ded918ac7dc6bJason Sams MessageThread(RenderScript rs) { 611516c31911578db8ce53529483c3ded918ac7dc6bJason Sams super("RSMessageThread"); 612516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mRS = rs; 613516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 614516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 615516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 616516c31911578db8ce53529483c3ded918ac7dc6bJason Sams public void run() { 617516c31911578db8ce53529483c3ded918ac7dc6bJason Sams // This function is a temporary solution. The final solution will 618516c31911578db8ce53529483c3ded918ac7dc6bJason Sams // used typed allocations where the message id is the type indicator. 619516c31911578db8ce53529483c3ded918ac7dc6bJason Sams int[] rbuf = new int[16]; 6202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams mRS.nContextInitToClient(mRS.mContext); 621516c31911578db8ce53529483c3ded918ac7dc6bJason Sams while(mRun) { 6221d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams rbuf[0] = 0; 6232e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams int msg = mRS.nContextGetMessage(mRS.mContext, rbuf, true); 624ab98bb6e8b95bef7415c1ad239be71f93322fbadStephen Hines if ((msg == 0)) { 6251d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams // Can happen for two reasons 626ab98bb6e8b95bef7415c1ad239be71f93322fbadStephen Hines if (rbuf[0] > 0 && mRun) { 6271d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams // 1: Buffer needs to be enlarged. 6281d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams rbuf = new int[rbuf[0] + 2]; 6291d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams } else { 6301d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams // 2: teardown. 6311d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams // But we want to avoid starving other threads during 6321d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams // teardown by yielding until the next line in the destructor 6331d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams // can execute to set mRun = false 6341d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams try { 6351d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams sleep(1, 0); 6361d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams } catch(InterruptedException e) { 6371d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams } 638516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 639ab98bb6e8b95bef7415c1ad239be71f93322fbadStephen Hines continue; 640516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 641516c31911578db8ce53529483c3ded918ac7dc6bJason Sams if(mRS.mMessageCallback != null) { 642516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mRS.mMessageCallback.mData = rbuf; 643516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mRS.mMessageCallback.mID = msg; 644516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mRS.mMessageCallback.run(); 645516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 646516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 6473bc47d438171dce294e816366d53bc9eca772c5bJason Sams Log.d(LOG_TAG, "MessageThread exiting."); 648516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 649516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 650516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 651704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected RenderScript() { 65260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 65360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 654704ff64b099406bb328898a7443921f22dbffd6dJason Sams public static RenderScript create() { 655704ff64b099406bb328898a7443921f22dbffd6dJason Sams RenderScript rs = new RenderScript(); 656704ff64b099406bb328898a7443921f22dbffd6dJason Sams 657704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mDev = rs.nDeviceCreate(); 658704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mContext = rs.nContextCreate(rs.mDev, 0); 659704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mMessageThread = new MessageThread(rs); 660704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mMessageThread.start(); 661704ff64b099406bb328898a7443921f22dbffd6dJason Sams Element.initPredefined(rs); 662704ff64b099406bb328898a7443921f22dbffd6dJason Sams return rs; 663efd9b6fb2e0f31b50db089352118e5daeb268879Jason Sams } 664efd9b6fb2e0f31b50db089352118e5daeb268879Jason Sams 665715333b832fb448c32165c7d97d408a3fa43f7cbJason Sams public void contextDump(int bits) { 6665dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 667715333b832fb448c32165c7d97d408a3fa43f7cbJason Sams nContextDump(bits); 668715333b832fb448c32165c7d97d408a3fa43f7cbJason Sams } 669715333b832fb448c32165c7d97d408a3fa43f7cbJason Sams 67096ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams public void finish() { 67196ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams nContextFinish(); 67296ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams } 67396ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams 674f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams public void destroy() { 6755dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 6762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams nContextDeinitToClient(mContext); 677516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mMessageThread.mRun = false; 678a8bf9429b29743b3489817feb21bde2416acc465Jason Sams try { 679a8bf9429b29743b3489817feb21bde2416acc465Jason Sams mMessageThread.join(); 680a8bf9429b29743b3489817feb21bde2416acc465Jason Sams } catch(InterruptedException e) { 681a8bf9429b29743b3489817feb21bde2416acc465Jason Sams } 682516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 6832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams nContextDestroy(); 684f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams mContext = 0; 685f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams 686f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams nDeviceDestroy(mDev); 687f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams mDev = 0; 688f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams } 68902fb2cb531035779a25dbf9595e0628ea40585b0Jason Sams 690a9e7a05b84470257637c97d65f6562aa832c66efJason Sams boolean isAlive() { 691a9e7a05b84470257637c97d65f6562aa832c66efJason Sams return mContext != 0; 692a9e7a05b84470257637c97d65f6562aa832c66efJason Sams } 693a9e7a05b84470257637c97d65f6562aa832c66efJason Sams 69460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich /////////////////////////////////////////////////////////////////////////////////// 69560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich // Root state 69660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 697704ff64b099406bb328898a7443921f22dbffd6dJason Sams protected int safeID(BaseObj o) { 6986b9dec00afec359f091ed353f371f08ff150278aJason Sams if(o != null) { 6996b9dec00afec359f091ed353f371f08ff150278aJason Sams return o.mID; 700d8e4161f114331343b897cbacea927e7e60e7b17Jason Sams } 7016b9dec00afec359f091ed353f371f08ff150278aJason Sams return 0; 70260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 70360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich} 70460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 70536e612a488511940b61f09803b270aa1c61b68e0Jason Sams 70680a4c2cd34aedb4f1a2e5e7d1ac26a9aeebe41aeAlex Sakhartchouk 707