RenderScript.java revision 163766cbe798baf8e86eb8201bc6c3def931d59a
160aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich/* 2be74bdd2349095f203ae0fddcc4816bfbd56bc5dStephen Hines * Copyright (C) 2008-2012 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 216b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liaoimport android.content.Context; 224382467a80dd12c6362d57edca7f2367f7ae877cStephen Hinesimport android.content.pm.ApplicationInfo; 234382467a80dd12c6362d57edca7f2367f7ae877cStephen Hinesimport android.content.pm.PackageManager; 24b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchoukimport android.content.res.AssetManager; 25b8c5a84e7c23746a3fc26013e0880d3d95ca6588Jason Samsimport android.graphics.Bitmap; 26650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guyimport android.graphics.BitmapFactory; 27faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Samsimport android.graphics.SurfaceTexture; 28260c77a4f741c3db76057cc4ea2ee54fe335ecf9Glenn Kastenimport android.os.Process; 2936e612a488511940b61f09803b270aa1c61b68e0Jason Samsimport android.util.Log; 3036e612a488511940b61f09803b270aa1c61b68e0Jason Samsimport android.view.Surface; 3143702d8925c54360ad5f9f66b0d35d61d59f6910Jack Palevich 3260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 334382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines 34e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams/** 353aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * Renderscript base master class. An instance of this class creates native 3627676fe24be7444a174c15df476e49adc5335d03Jason Sams * worker threads for processing commands from this object. This base class 3727676fe24be7444a174c15df476e49adc5335d03Jason Sams * does not provide any extended capabilities beyond simple data processing. 3827676fe24be7444a174c15df476e49adc5335d03Jason Sams * For extended capabilities use derived classes such as RenderScriptGL. 3927676fe24be7444a174c15df476e49adc5335d03Jason Sams * 403aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * <div class="special reference"> 413aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * <h3>Developer Guides</h3> 423aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * <p>For more information about creating an application that uses Renderscript, read the 433aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * <a href="{@docRoot}guide/topics/graphics/renderscript.html">Renderscript</a> developer guide.</p> 443aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * </div> 45e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams **/ 4660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevichpublic class RenderScript { 473bc47d438171dce294e816366d53bc9eca772c5bJason Sams static final String LOG_TAG = "RenderScript_jni"; 48bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final boolean DEBUG = false; 49650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guy @SuppressWarnings({"UnusedDeclaration", "deprecation"}) 5043a17654cf4bfe7f1ec22bd8b7b32daccdf27c09Joe Onorato static final boolean LOG_ENABLED = false; 5160aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 526b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao private Context mApplicationContext; 5360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 546b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao /* 5560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * We use a class initializer to allow the native code to cache some 5660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * field offsets. 5760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich */ 58650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guy @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) 59bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static boolean sInitialized; 60bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams native static void _nInit(); 6160aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 62dba3ba5b5bf6026abceced921b1b0d231b0faefdJason Sams 6360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich static { 6460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich sInitialized = false; 6560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich try { 66e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams System.loadLibrary("rs_jni"); 6760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich _nInit(); 6860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich sInitialized = true; 6960aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } catch (UnsatisfiedLinkError e) { 70fa445b9353972735d8d65e8a936786b1afe9886dJason Sams Log.e(LOG_TAG, "Error loading RS jni library: " + e); 71fa445b9353972735d8d65e8a936786b1afe9886dJason Sams throw new RSRuntimeException("Error loading RS jni library: " + e); 7260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 7360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 7460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // Non-threadsafe functions. 7636e612a488511940b61f09803b270aa1c61b68e0Jason Sams native int nDeviceCreate(); 7736e612a488511940b61f09803b270aa1c61b68e0Jason Sams native void nDeviceDestroy(int dev); 78ebfb436a49673693b98469683451bd9ede797557Jason Sams native void nDeviceSetConfig(int dev, int param, int value); 79edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams native int nContextGetUserMessage(int con, int[] data); 801c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams native String nContextGetErrorMessage(int con); 81edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams native int nContextPeekMessage(int con, int[] subID); 822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void nContextInitToClient(int con); 832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void nContextDeinitToClient(int con); 842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // Methods below are wrapped to protect the non-threadsafe 872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // lockless fifo. 884382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines native int rsnContextCreateGL(int dev, int ver, int sdkVer, 8911c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int colorMin, int colorPref, 9011c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int alphaMin, int alphaPref, 9111c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int depthMin, int depthPref, 9211c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int stencilMin, int stencilPref, 932c74ad9aae29cc64fece926f353825a7925792c2Alex Sakhartchouk int samplesMin, int samplesPref, float samplesQ, int dpi); 944382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines synchronized int nContextCreateGL(int dev, int ver, int sdkVer, 9511c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int colorMin, int colorPref, 9611c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int alphaMin, int alphaPref, 9711c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int depthMin, int depthPref, 9811c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int stencilMin, int stencilPref, 992c74ad9aae29cc64fece926f353825a7925792c2Alex Sakhartchouk int samplesMin, int samplesPref, float samplesQ, int dpi) { 1004382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines return rsnContextCreateGL(dev, ver, sdkVer, colorMin, colorPref, 10111c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams alphaMin, alphaPref, depthMin, depthPref, 10211c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams stencilMin, stencilPref, 1032c74ad9aae29cc64fece926f353825a7925792c2Alex Sakhartchouk samplesMin, samplesPref, samplesQ, dpi); 1042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1054382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines native int rsnContextCreate(int dev, int ver, int sdkVer); 1064382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines synchronized int nContextCreate(int dev, int ver, int sdkVer) { 1074382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines return rsnContextCreate(dev, ver, sdkVer); 1082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1092e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextDestroy(int con); 1102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextDestroy() { 111d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1122e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextDestroy(mContext); 1132e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextSetSurface(int con, int w, int h, Surface sur); 1152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextSetSurface(int w, int h, Surface sur) { 116d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextSetSurface(mContext, w, h, sur); 1182e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 119faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams native void rsnContextSetSurfaceTexture(int con, int w, int h, SurfaceTexture sur); 120faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams synchronized void nContextSetSurfaceTexture(int w, int h, SurfaceTexture sur) { 121faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams validate(); 122faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams rsnContextSetSurfaceTexture(mContext, w, h, sur); 123faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams } 1242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextSetPriority(int con, int p); 1252e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextSetPriority(int p) { 126d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1272e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextSetPriority(mContext, p); 1282e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1292e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextDump(int con, int bits); 1302e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextDump(int bits) { 131d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1322e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextDump(mContext, bits); 1332e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1342e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextFinish(int con); 1352e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextFinish() { 136d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1372e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextFinish(mContext); 1382e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1392e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 1402e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindRootScript(int con, int script); 1412e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindRootScript(int script) { 142d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1432e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindRootScript(mContext, script); 1442e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1452e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindSampler(int con, int sampler, int slot); 1462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindSampler(int sampler, int slot) { 147d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1482e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindSampler(mContext, sampler, slot); 1492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramStore(int con, int pfs); 1512e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramStore(int pfs) { 152d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1532e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramStore(mContext, pfs); 1542e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramFragment(int con, int pf); 1562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramFragment(int pf) { 157d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1582e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramFragment(mContext, pf); 1592e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1602e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramVertex(int con, int pv); 1612e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramVertex(int pv) { 162d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1632e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramVertex(mContext, pv); 1642e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramRaster(int con, int pr); 1662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramRaster(int pr) { 167d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1682e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramRaster(mContext, pr); 1692e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextPause(int con); 1712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextPause() { 172d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextPause(mContext); 1742e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextResume(int con); 1762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextResume() { 177d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1782e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextResume(mContext); 1792e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1802e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 1812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAssignName(int con, int obj, byte[] name); 1822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAssignName(int obj, byte[] name) { 183d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAssignName(mContext, obj, name); 1852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native String rsnGetName(int con, int obj); 1872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized String nGetName(int obj) { 188d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnGetName(mContext, obj); 1902e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1912e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnObjDestroy(int con, int id); 1922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nObjDestroy(int id) { 193d1ac98149737299513da1357e36f68cbb6d74425Jason Sams // There is a race condition here. The calling code may be run 194d1ac98149737299513da1357e36f68cbb6d74425Jason Sams // by the gc while teardown is occuring. This protects againts 195d1ac98149737299513da1357e36f68cbb6d74425Jason Sams // deleting dead objects. 196d1ac98149737299513da1357e36f68cbb6d74425Jason Sams if (mContext != 0) { 197d1ac98149737299513da1357e36f68cbb6d74425Jason Sams rsnObjDestroy(mContext, id); 198d1ac98149737299513da1357e36f68cbb6d74425Jason Sams } 1992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2002e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2012e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize); 2022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nElementCreate(int type, int kind, boolean norm, int vecSize) { 203d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnElementCreate(mContext, type, kind, norm, vecSize); 2052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 20670d4e5024298f71edb3b04867e05568f5495b4ceJason Sams native int rsnElementCreate2(int con, int[] elements, String[] names, int[] arraySizes); 20770d4e5024298f71edb3b04867e05568f5495b4ceJason Sams synchronized int nElementCreate2(int[] elements, String[] names, int[] arraySizes) { 208d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 20970d4e5024298f71edb3b04867e05568f5495b4ceJason Sams return rsnElementCreate2(mContext, elements, names, arraySizes); 2102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2112e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnElementGetNativeData(int con, int id, int[] elementData); 2122e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nElementGetNativeData(int id, int[] elementData) { 213d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnElementGetNativeData(mContext, id, elementData); 2152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2167d5f5e7c8943e043a422ad51c85d4e1684c37e28Alex Sakhartchouk native void rsnElementGetSubElements(int con, int id, 2177d5f5e7c8943e043a422ad51c85d4e1684c37e28Alex Sakhartchouk int[] IDs, String[] names, int[] arraySizes); 2187d5f5e7c8943e043a422ad51c85d4e1684c37e28Alex Sakhartchouk synchronized void nElementGetSubElements(int id, int[] IDs, String[] names, int[] arraySizes) { 219d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2207d5f5e7c8943e043a422ad51c85d4e1684c37e28Alex Sakhartchouk rsnElementGetSubElements(mContext, id, IDs, names, arraySizes); 2212e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2222e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 223bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces); 224bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces) { 225d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 226bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams return rsnTypeCreate(mContext, eid, x, y, z, mips, faces); 2272e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2282e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnTypeGetNativeData(int con, int id, int[] typeData); 2292e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nTypeGetNativeData(int id, int[] typeData) { 230d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnTypeGetNativeData(mContext, id, typeData); 2322e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2332e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 234857d0c7017da763a420e825fffa2f260eb982c97Jason Sams native int rsnAllocationCreateTyped(int con, int type, int mip, int usage, int pointer); 235857d0c7017da763a420e825fffa2f260eb982c97Jason Sams synchronized int nAllocationCreateTyped(int type, int mip, int usage, int pointer) { 236d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 237857d0c7017da763a420e825fffa2f260eb982c97Jason Sams return rsnAllocationCreateTyped(mContext, type, mip, usage, pointer); 2382e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2395476b450e50939940dcf3f15c92335cee2fc572dJason Sams native int rsnAllocationCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage); 2405476b450e50939940dcf3f15c92335cee2fc572dJason Sams synchronized int nAllocationCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) { 241d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2425476b450e50939940dcf3f15c92335cee2fc572dJason Sams return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage); 24326ae3904e8050eae655722caf93ee5d3f0ab195aAlex Sakhartchouk } 2445476b450e50939940dcf3f15c92335cee2fc572dJason Sams native int rsnAllocationCubeCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage); 2455476b450e50939940dcf3f15c92335cee2fc572dJason Sams synchronized int nAllocationCubeCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) { 246d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2475476b450e50939940dcf3f15c92335cee2fc572dJason Sams return rsnAllocationCubeCreateFromBitmap(mContext, type, mip, bmp, usage); 24867f2e442a31b8395e3c1951f8e91139ec7f2be99Alex Sakhartchouk } 2492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationCreateBitmapRef(int con, int type, Bitmap bmp); 2502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationCreateBitmapRef(int type, Bitmap bmp) { 251d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2522e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationCreateBitmapRef(mContext, type, bmp); 2532e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2545476b450e50939940dcf3f15c92335cee2fc572dJason Sams native int rsnAllocationCreateFromAssetStream(int con, int mips, int assetStream, int usage); 2555476b450e50939940dcf3f15c92335cee2fc572dJason Sams synchronized int nAllocationCreateFromAssetStream(int mips, int assetStream, int usage) { 256d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2575476b450e50939940dcf3f15c92335cee2fc572dJason Sams return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage); 2585476b450e50939940dcf3f15c92335cee2fc572dJason Sams } 2595476b450e50939940dcf3f15c92335cee2fc572dJason Sams 2604ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams native void rsnAllocationCopyToBitmap(int con, int alloc, Bitmap bmp); 2614ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams synchronized void nAllocationCopyToBitmap(int alloc, Bitmap bmp) { 262d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2634ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams rsnAllocationCopyToBitmap(mContext, alloc, bmp); 2644ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams } 2654ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams 2664ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams 2675476b450e50939940dcf3f15c92335cee2fc572dJason Sams native void rsnAllocationSyncAll(int con, int alloc, int src); 2685476b450e50939940dcf3f15c92335cee2fc572dJason Sams synchronized void nAllocationSyncAll(int alloc, int src) { 269d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2705476b450e50939940dcf3f15c92335cee2fc572dJason Sams rsnAllocationSyncAll(mContext, alloc, src); 2715476b450e50939940dcf3f15c92335cee2fc572dJason Sams } 272615e7cee03d1a53072b0369fa9f247811ac56845Jason Sams native int rsnAllocationGetSurfaceTextureID(int con, int alloc); 273615e7cee03d1a53072b0369fa9f247811ac56845Jason Sams synchronized int nAllocationGetSurfaceTextureID(int alloc) { 274615e7cee03d1a53072b0369fa9f247811ac56845Jason Sams validate(); 275615e7cee03d1a53072b0369fa9f247811ac56845Jason Sams return rsnAllocationGetSurfaceTextureID(mContext, alloc); 276615e7cee03d1a53072b0369fa9f247811ac56845Jason Sams } 277163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams native void rsnAllocationSetSurfaceTexture(int con, int alloc, SurfaceTexture sur); 278163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams synchronized void nAllocationSetSurfaceTexture(int alloc, SurfaceTexture sur) { 279163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams validate(); 280163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams rsnAllocationSetSurfaceTexture(mContext, alloc, sur); 281163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams } 282163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams native void rsnAllocationIoSend(int con, int alloc); 283163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams synchronized void nAllocationIoSend(int alloc) { 284163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams validate(); 285163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams rsnAllocationIoSend(mContext, alloc); 286163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams } 287163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams native void rsnAllocationIoReceive(int con, int alloc); 288163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams synchronized void nAllocationIoReceive(int alloc) { 289163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams validate(); 290163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams rsnAllocationIoReceive(mContext, alloc); 291163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams } 292163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams 293615e7cee03d1a53072b0369fa9f247811ac56845Jason Sams 294f7086090cfc8d97b5bd3b4d7801a27af11f7c207Jason Sams native void rsnAllocationGenerateMipmaps(int con, int alloc); 295f7086090cfc8d97b5bd3b4d7801a27af11f7c207Jason Sams synchronized void nAllocationGenerateMipmaps(int alloc) { 296d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 297f7086090cfc8d97b5bd3b4d7801a27af11f7c207Jason Sams rsnAllocationGenerateMipmaps(mContext, alloc); 298f7086090cfc8d97b5bd3b4d7801a27af11f7c207Jason Sams } 2994ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp); 3004ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) { 301d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 3024ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams rsnAllocationCopyFromBitmap(mContext, alloc, bmp); 3032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 3052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 30649a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData1D(int con, int id, int off, int mip, int count, int[] d, int sizeBytes); 30749a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData1D(int id, int off, int mip, int count, int[] d, int sizeBytes) { 308d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 30949a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); 3102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 31149a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData1D(int con, int id, int off, int mip, int count, short[] d, int sizeBytes); 31249a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData1D(int id, int off, int mip, int count, short[] d, int sizeBytes) { 313d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 31449a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); 3152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 31649a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData1D(int con, int id, int off, int mip, int count, byte[] d, int sizeBytes); 31749a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData1D(int id, int off, int mip, int count, byte[] d, int sizeBytes) { 318d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 31949a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); 3202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 32149a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData1D(int con, int id, int off, int mip, int count, float[] d, int sizeBytes); 32249a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData1D(int id, int off, int mip, int count, float[] d, int sizeBytes) { 323d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 32449a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); 32549bdaf0293408159df18a1d8540360f9623c40f7Jason Sams } 32649a05d7b82956009f03acbb92a064eed054eb031Jason Sams 32749a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationElementData1D(int con, int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes); 32849a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationElementData1D(int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) { 329d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 33049a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes); 3312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3322e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 333304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk native void rsnAllocationData2D(int con, 334304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int dstAlloc, int dstXoff, int dstYoff, 335304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int dstMip, int dstFace, 336304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int width, int height, 337304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int srcAlloc, int srcXoff, int srcYoff, 338304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int srcMip, int srcFace); 339304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk synchronized void nAllocationData2D(int dstAlloc, int dstXoff, int dstYoff, 340304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int dstMip, int dstFace, 341304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int width, int height, 342304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int srcAlloc, int srcXoff, int srcYoff, 343304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int srcMip, int srcFace) { 344304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk validate(); 345304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk rsnAllocationData2D(mContext, 346304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk dstAlloc, dstXoff, dstYoff, 347304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk dstMip, dstFace, 348304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk width, height, 349304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk srcAlloc, srcXoff, srcYoff, 350304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk srcMip, srcFace); 351304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk } 352304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk 353fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes); 354fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes) { 355d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 356fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); 357fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 358fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes); 359fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes) { 360d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 361fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); 362fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 36349a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes); 36449a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes) { 365d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 36649a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); 3672e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 36849a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes); 36949a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes) { 370d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 37149a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); 3722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 373fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, Bitmap b); 374fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, Bitmap b) { 375d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 376fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, b); 377fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 37849a05d7b82956009f03acbb92a064eed054eb031Jason Sams 379fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationRead(int con, int id, byte[] d); 380fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationRead(int id, byte[] d) { 381d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 382fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationRead(mContext, id, d); 383fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 384fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationRead(int con, int id, short[] d); 385fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationRead(int id, short[] d) { 386d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 387fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationRead(mContext, id, d); 388fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 3892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationRead(int con, int id, int[] d); 3902e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationRead(int id, int[] d) { 391d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 3922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationRead(mContext, id, d); 3932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationRead(int con, int id, float[] d); 3952e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationRead(int id, float[] d) { 396d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 3972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationRead(mContext, id, d); 3982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationGetType(int con, int id); 4002e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationGetType(int id) { 401d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationGetType(mContext, id); 4032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 4055edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams native void rsnAllocationResize1D(int con, int id, int dimX); 4065edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams synchronized void nAllocationResize1D(int id, int dimX) { 407d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4085edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams rsnAllocationResize1D(mContext, id, dimX); 4095edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams } 4105edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams native void rsnAllocationResize2D(int con, int id, int dimX, int dimY); 4115edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams synchronized void nAllocationResize2D(int id, int dimX, int dimY) { 412d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4135edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams rsnAllocationResize2D(mContext, id, dimX, dimY); 4145edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams } 4155edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams 4162e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DCreateFromAssetStream(int con, int assetStream); 4172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DCreateFromAssetStream(int assetStream) { 418d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DCreateFromAssetStream(mContext, assetStream); 4202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 421b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk native int rsnFileA3DCreateFromFile(int con, String path); 422b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk synchronized int nFileA3DCreateFromFile(String path) { 423d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 424b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk return rsnFileA3DCreateFromFile(mContext, path); 425b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk } 426b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk native int rsnFileA3DCreateFromAsset(int con, AssetManager mgr, String path); 427b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk synchronized int nFileA3DCreateFromAsset(AssetManager mgr, String path) { 428d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 429b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk return rsnFileA3DCreateFromAsset(mContext, mgr, path); 430b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk } 4312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DGetNumIndexEntries(int con, int fileA3D); 4322e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DGetNumIndexEntries(int fileA3D) { 433d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4342e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DGetNumIndexEntries(mContext, fileA3D); 4352e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4362e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnFileA3DGetIndexEntries(int con, int fileA3D, int numEntries, int[] IDs, String[] names); 4372e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nFileA3DGetIndexEntries(int fileA3D, int numEntries, int[] IDs, String[] names) { 438d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4392e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnFileA3DGetIndexEntries(mContext, fileA3D, numEntries, IDs, names); 4402e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4412e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DGetEntryByIndex(int con, int fileA3D, int index); 4422e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DGetEntryByIndex(int fileA3D, int index) { 443d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4442e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DGetEntryByIndex(mContext, fileA3D, index); 4452e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 447e27cdeeecba5b445e307d653d9cb7da007adfac3Alex Sakhartchouk native int rsnFontCreateFromFile(int con, String fileName, float size, int dpi); 448e27cdeeecba5b445e307d653d9cb7da007adfac3Alex Sakhartchouk synchronized int nFontCreateFromFile(String fileName, float size, int dpi) { 449d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFontCreateFromFile(mContext, fileName, size, dpi); 4512e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 452b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk native int rsnFontCreateFromAssetStream(int con, String name, float size, int dpi, int assetStream); 453b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk synchronized int nFontCreateFromAssetStream(String name, float size, int dpi, int assetStream) { 454d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 455b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk return rsnFontCreateFromAssetStream(mContext, name, size, dpi, assetStream); 456b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk } 457b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk native int rsnFontCreateFromAsset(int con, AssetManager mgr, String path, float size, int dpi); 458b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk synchronized int nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) { 459d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 460b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk return rsnFontCreateFromAsset(mContext, mgr, path, size, dpi); 461b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk } 4622e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 4632e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 4642e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptBindAllocation(int con, int script, int alloc, int slot); 4652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptBindAllocation(int script, int alloc, int slot) { 466d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4672e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptBindAllocation(mContext, script, alloc, slot); 4682e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4692e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetTimeZone(int con, int script, byte[] timeZone); 4702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetTimeZone(int script, byte[] timeZone) { 471d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetTimeZone(mContext, script, timeZone); 4732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4742e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptInvoke(int con, int id, int slot); 4752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptInvoke(int id, int slot) { 476d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4772e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptInvoke(mContext, id, slot); 4782e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4796e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams native void rsnScriptForEach(int con, int id, int slot, int ain, int aout, byte[] params); 4806e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams native void rsnScriptForEach(int con, int id, int slot, int ain, int aout); 4816e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams synchronized void nScriptForEach(int id, int slot, int ain, int aout, byte[] params) { 4826e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams validate(); 4836e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams if (params == null) { 4846e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams rsnScriptForEach(mContext, id, slot, ain, aout); 4856e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams } else { 4866e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams rsnScriptForEach(mContext, id, slot, ain, aout, params); 4876e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams } 4886e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams } 4892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptInvokeV(int con, int id, int slot, byte[] params); 4902e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptInvokeV(int id, int slot, byte[] params) { 491d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptInvokeV(mContext, id, slot, params); 4932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarI(int con, int id, int slot, int val); 4952e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarI(int id, int slot, int val) { 496d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarI(mContext, id, slot, val); 4982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 499031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines native void rsnScriptSetVarJ(int con, int id, int slot, long val); 500031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines synchronized void nScriptSetVarJ(int id, int slot, long val) { 501d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 502031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines rsnScriptSetVarJ(mContext, id, slot, val); 503031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines } 5042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarF(int con, int id, int slot, float val); 5052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarF(int id, int slot, float val) { 506d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5072e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarF(mContext, id, slot, val); 5082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 509ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines native void rsnScriptSetVarD(int con, int id, int slot, double val); 510ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines synchronized void nScriptSetVarD(int id, int slot, double val) { 511d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 512ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines rsnScriptSetVarD(mContext, id, slot, val); 513ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines } 5142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarV(int con, int id, int slot, byte[] val); 5152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarV(int id, int slot, byte[] val) { 516d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarV(mContext, id, slot, val); 5182e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5196f4cf0b8885403ead157ae00fd43cf1282331c23Jason Sams native void rsnScriptSetVarObj(int con, int id, int slot, int val); 5206f4cf0b8885403ead157ae00fd43cf1282331c23Jason Sams synchronized void nScriptSetVarObj(int id, int slot, int val) { 521d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5226f4cf0b8885403ead157ae00fd43cf1282331c23Jason Sams rsnScriptSetVarObj(mContext, id, slot, val); 5236f4cf0b8885403ead157ae00fd43cf1282331c23Jason Sams } 5242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 525e4a06c5fc738bf219f2a495e12a637b2d0871651Jason Sams native int rsnScriptCCreate(int con, String resName, String cacheDir, 526e4a06c5fc738bf219f2a495e12a637b2d0871651Jason Sams byte[] script, int length); 527e4a06c5fc738bf219f2a495e12a637b2d0871651Jason Sams synchronized int nScriptCCreate(String resName, String cacheDir, byte[] script, int length) { 528d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 529e4a06c5fc738bf219f2a495e12a637b2d0871651Jason Sams return rsnScriptCCreate(mContext, resName, cacheDir, script, length); 5302e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 532a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk native int rsnSamplerCreate(int con, int magFilter, int minFilter, 533a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk int wrapS, int wrapT, int wrapR, float aniso); 534a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk synchronized int nSamplerCreate(int magFilter, int minFilter, 535a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk int wrapS, int wrapT, int wrapR, float aniso) { 536d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 537a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso); 5382e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5392e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 540331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams native int rsnProgramStoreCreate(int con, boolean r, boolean g, boolean b, boolean a, 541331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams boolean depthMask, boolean dither, 542331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams int srcMode, int dstMode, int depthFunc); 543331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams synchronized int nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a, 544331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams boolean depthMask, boolean dither, 545331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams int srcMode, int dstMode, int depthFunc) { 546d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 547bd184c55850997a5c5e285357998dadbe95b7b5dJason Sams return rsnProgramStoreCreate(mContext, r, g, b, a, depthMask, dither, srcMode, 548bd184c55850997a5c5e285357998dadbe95b7b5dJason Sams dstMode, depthFunc); 5492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 55194aaed38467c71a6c804f0e18b41346a4013c25bJason Sams native int rsnProgramRasterCreate(int con, boolean pointSprite, int cullMode); 55294aaed38467c71a6c804f0e18b41346a4013c25bJason Sams synchronized int nProgramRasterCreate(boolean pointSprite, int cullMode) { 553d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 55494aaed38467c71a6c804f0e18b41346a4013c25bJason Sams return rsnProgramRasterCreate(mContext, pointSprite, cullMode); 5552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 5572e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindConstants(int con, int pv, int slot, int mID); 5582e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindConstants(int pv, int slot, int mID) { 559d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5602e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindConstants(mContext, pv, slot, mID); 5612e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5622e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindTexture(int con, int vpf, int slot, int a); 5632e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindTexture(int vpf, int slot, int a) { 564d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindTexture(mContext, vpf, slot, a); 5662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5672e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindSampler(int con, int vpf, int slot, int s); 5682e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindSampler(int vpf, int slot, int s) { 569d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindSampler(mContext, vpf, slot, s); 5712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 572b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk native int rsnProgramFragmentCreate(int con, String shader, int[] params); 573b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk synchronized int nProgramFragmentCreate(String shader, int[] params) { 574d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 575b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk return rsnProgramFragmentCreate(mContext, shader, params); 5762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 577b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk native int rsnProgramVertexCreate(int con, String shader, int[] params); 578b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk synchronized int nProgramVertexCreate(String shader, int[] params) { 579d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 580b89aaacb2ca9d062e0a17a32e3d4dbf3f6948a17Alex Sakhartchouk return rsnProgramVertexCreate(mContext, shader, params); 5812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 58325999a08a6652ff5d7d0973f279f1e92e04b3506Alex Sakhartchouk native int rsnMeshCreate(int con, int[] vtx, int[] idx, int[] prim); 58425999a08a6652ff5d7d0973f279f1e92e04b3506Alex Sakhartchouk synchronized int nMeshCreate(int[] vtx, int[] idx, int[] prim) { 585d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 58625999a08a6652ff5d7d0973f279f1e92e04b3506Alex Sakhartchouk return rsnMeshCreate(mContext, vtx, idx, prim); 5879d71e2180062931416092f26276a07e55b318f62Alex Sakhartchouk } 5882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnMeshGetVertexBufferCount(int con, int id); 5892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nMeshGetVertexBufferCount(int id) { 590d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5912e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnMeshGetVertexBufferCount(mContext, id); 5922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnMeshGetIndexCount(int con, int id); 5942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nMeshGetIndexCount(int id) { 595d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5962e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnMeshGetIndexCount(mContext, id); 5972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnMeshGetVertices(int con, int id, int[] vtxIds, int vtxIdCount); 5992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nMeshGetVertices(int id, int[] vtxIds, int vtxIdCount) { 600d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 6012e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnMeshGetVertices(mContext, id, vtxIds, vtxIdCount); 6022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnMeshGetIndices(int con, int id, int[] idxIds, int[] primitives, int vtxIdCount); 6042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nMeshGetIndices(int id, int[] idxIds, int[] primitives, int vtxIdCount) { 605d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 6062e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount); 6072e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 609f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams native int rsnPathCreate(int con, int prim, boolean isStatic, int vtx, int loop, float q); 610f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams synchronized int nPathCreate(int prim, boolean isStatic, int vtx, int loop, float q) { 611f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams validate(); 612f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams return rsnPathCreate(mContext, prim, isStatic, vtx, loop, q); 613f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams } 61460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 615bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int mDev; 616bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int mContext; 617650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guy @SuppressWarnings({"FieldCanBeLocal"}) 618bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams MessageThread mMessageThread; 61960aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 6208cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U8; 6218cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I8; 6228cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U16; 6238cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I16; 6248cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U32; 6258cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I32; 62652d836332f6aae74ed97fda1b53681f36710af64Stephen Hines Element mElement_U64; 627ef1dac28d3bf98bd61cd9874fb3ccab42105e9b6Stephen Hines Element mElement_I64; 6288cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_F32; 62902f41705199336f808ece50d81585450e7f8f61fStephen Hines Element mElement_F64; 630f110d4b787b91dabe968a812e76e5c1f8d953487Jason Sams Element mElement_BOOLEAN; 6318cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams 6328cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_ELEMENT; 6338cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_TYPE; 6348cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_ALLOCATION; 6358cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_SAMPLER; 6368cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_SCRIPT; 6378cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_MESH; 6388cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_FRAGMENT; 6398cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_VERTEX; 6408cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_RASTER; 6418cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_STORE; 642a70f416c9cf2fc6cc5e132c1d656ce07441d6b82Jason Sams 6433c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_A_8; 6443c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGB_565; 6453c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGB_888; 6463c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_5551; 6473c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_4444; 6483c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_8888; 6493c0dfbab807a459622aeade4940daddf482dec66Jason Sams 6508cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_2; 6518cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_3; 6528cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_4; 653836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 654836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_DOUBLE_2; 655836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_DOUBLE_3; 656836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_DOUBLE_4; 657836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 658836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UCHAR_2; 659836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UCHAR_3; 6608cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_UCHAR_4; 6617d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 662836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_CHAR_2; 663836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_CHAR_3; 664836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_CHAR_4; 665836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 666836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_USHORT_2; 667836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_USHORT_3; 668836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_USHORT_4; 669836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 670836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_SHORT_2; 671836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_SHORT_3; 672836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_SHORT_4; 673836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 674836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UINT_2; 675836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UINT_3; 676836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UINT_4; 677836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 678836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_INT_2; 679836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_INT_3; 680836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_INT_4; 681836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 682836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_ULONG_2; 683836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_ULONG_3; 684836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_ULONG_4; 685836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 686836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_LONG_2; 687836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_LONG_3; 688836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_LONG_4; 689836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 6901d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_4X4; 6911d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_3X3; 6921d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_2X2; 6931d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams 6944d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_NEAREST; 6954d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_LINEAR; 6964d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_LINEAR_MIP_LINEAR; 6974d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_NEAREST; 6984d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_LINEAR; 6994d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_LINEAR_MIP_LINEAR; 7004d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams 701d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_NONE_DEPTH_TEST; 702d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH; 703d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_TEST; 704d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH; 705d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk 706d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_BACK; 707d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_FRONT; 708d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_NONE; 70932e09b5891da0174f161d99e2d3ebe67d6efa39cAlex Sakhartchouk 71060aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich /////////////////////////////////////////////////////////////////////////////////// 71143702d8925c54360ad5f9f66b0d35d61d59f6910Jack Palevich // 71260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 71327676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 71427676fe24be7444a174c15df476e49adc5335d03Jason Sams * Base class application should derive from for handling RS messages 7158cecbb5293f73e3f63f2601dda68016762c58a0cStephen Hines * coming from their scripts. When a script calls sendToClient the data 71627676fe24be7444a174c15df476e49adc5335d03Jason Sams * fields will be filled in and then the run method called by a message 71727676fe24be7444a174c15df476e49adc5335d03Jason Sams * handling thread. This will occur some time after sendToClient completes 71827676fe24be7444a174c15df476e49adc5335d03Jason Sams * in the script. 71927676fe24be7444a174c15df476e49adc5335d03Jason Sams * 72027676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 721bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public static class RSMessageHandler implements Runnable { 722516c31911578db8ce53529483c3ded918ac7dc6bJason Sams protected int[] mData; 723516c31911578db8ce53529483c3ded918ac7dc6bJason Sams protected int mID; 7241c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams protected int mLength; 725516c31911578db8ce53529483c3ded918ac7dc6bJason Sams public void run() { 726516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 727516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 72827676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 72927676fe24be7444a174c15df476e49adc5335d03Jason Sams * If an application is expecting messages it should set this field to an 73027676fe24be7444a174c15df476e49adc5335d03Jason Sams * instance of RSMessage. This instance will receive all the user messages 73127676fe24be7444a174c15df476e49adc5335d03Jason Sams * sent from sendToClient by scripts from this context. 73227676fe24be7444a174c15df476e49adc5335d03Jason Sams * 73327676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 734bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams RSMessageHandler mMessageCallback = null; 735bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams 736bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public void setMessageHandler(RSMessageHandler msg) { 737bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams mMessageCallback = msg; 738bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams } 739bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public RSMessageHandler getMessageHandler() { 740bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams return mMessageCallback; 741bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams } 742516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 74327676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 74427676fe24be7444a174c15df476e49adc5335d03Jason Sams * Runtime error base class. An application should derive from this class 74527676fe24be7444a174c15df476e49adc5335d03Jason Sams * if it wishes to install an error handler. When errors occur at runtime 74627676fe24be7444a174c15df476e49adc5335d03Jason Sams * the fields in this class will be filled and the run method called. 74727676fe24be7444a174c15df476e49adc5335d03Jason Sams * 74827676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 749bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public static class RSErrorHandler implements Runnable { 7501c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams protected String mErrorMessage; 7511c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams protected int mErrorNum; 7521c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams public void run() { 7531c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 7541c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 75527676fe24be7444a174c15df476e49adc5335d03Jason Sams 75627676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 75727676fe24be7444a174c15df476e49adc5335d03Jason Sams * Application Error handler. All runtime errors will be dispatched to the 75827676fe24be7444a174c15df476e49adc5335d03Jason Sams * instance of RSAsyncError set here. If this field is null a 75927676fe24be7444a174c15df476e49adc5335d03Jason Sams * RSRuntimeException will instead be thrown with details about the error. 76027676fe24be7444a174c15df476e49adc5335d03Jason Sams * This will cause program termaination. 76127676fe24be7444a174c15df476e49adc5335d03Jason Sams * 76227676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 763bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams RSErrorHandler mErrorCallback = null; 764bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams 765bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public void setErrorHandler(RSErrorHandler msg) { 766bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams mErrorCallback = msg; 767bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams } 768bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public RSErrorHandler getErrorHandler() { 769bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams return mErrorCallback; 770bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams } 7711c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 77227676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 77327676fe24be7444a174c15df476e49adc5335d03Jason Sams * RenderScript worker threads priority enumeration. The default value is 77427676fe24be7444a174c15df476e49adc5335d03Jason Sams * NORMAL. Applications wishing to do background processing such as 77527676fe24be7444a174c15df476e49adc5335d03Jason Sams * wallpapers should set their priority to LOW to avoid starving forground 77627676fe24be7444a174c15df476e49adc5335d03Jason Sams * processes. 77727676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 7787d787b4722eaeb79cab42c36060336e092b77b5fJason Sams public enum Priority { 779260c77a4f741c3db76057cc4ea2ee54fe335ecf9Glenn Kasten LOW (Process.THREAD_PRIORITY_BACKGROUND + (5 * Process.THREAD_PRIORITY_LESS_FAVORABLE)), 780260c77a4f741c3db76057cc4ea2ee54fe335ecf9Glenn Kasten NORMAL (Process.THREAD_PRIORITY_DISPLAY); 7817d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 7827d787b4722eaeb79cab42c36060336e092b77b5fJason Sams int mID; 7837d787b4722eaeb79cab42c36060336e092b77b5fJason Sams Priority(int id) { 7847d787b4722eaeb79cab42c36060336e092b77b5fJason Sams mID = id; 7857d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 7867d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 7877d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 788771bebb94054d06f97284379c93a2620613513c3Jason Sams void validate() { 789771bebb94054d06f97284379c93a2620613513c3Jason Sams if (mContext == 0) { 790c1d6210fb5cc558ccea95a59a2b33bb9015fc7deJason Sams throw new RSInvalidStateException("Calling RS with no Context active."); 791771bebb94054d06f97284379c93a2620613513c3Jason Sams } 792771bebb94054d06f97284379c93a2620613513c3Jason Sams } 793771bebb94054d06f97284379c93a2620613513c3Jason Sams 79427676fe24be7444a174c15df476e49adc5335d03Jason Sams 79527676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 79627676fe24be7444a174c15df476e49adc5335d03Jason Sams * Change the priority of the worker threads for this context. 79727676fe24be7444a174c15df476e49adc5335d03Jason Sams * 79827676fe24be7444a174c15df476e49adc5335d03Jason Sams * @param p New priority to be set. 79927676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 800bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public void setPriority(Priority p) { 8015dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 8027d787b4722eaeb79cab42c36060336e092b77b5fJason Sams nContextSetPriority(p.mID); 8037d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 8047d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 805bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static class MessageThread extends Thread { 806516c31911578db8ce53529483c3ded918ac7dc6bJason Sams RenderScript mRS; 807516c31911578db8ce53529483c3ded918ac7dc6bJason Sams boolean mRun = true; 808bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int[] mAuxData = new int[2]; 8091c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 810bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_NONE = 0; 811bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_EXCEPTION = 1; 812bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_RESIZE = 2; 813bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_ERROR = 3; 814bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_USER = 4; 815516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 816bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_ERROR_FATAL_UNKNOWN = 0x1000; 817add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams 818516c31911578db8ce53529483c3ded918ac7dc6bJason Sams MessageThread(RenderScript rs) { 819516c31911578db8ce53529483c3ded918ac7dc6bJason Sams super("RSMessageThread"); 820516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mRS = rs; 821516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 822516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 823516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 824516c31911578db8ce53529483c3ded918ac7dc6bJason Sams public void run() { 825516c31911578db8ce53529483c3ded918ac7dc6bJason Sams // This function is a temporary solution. The final solution will 826516c31911578db8ce53529483c3ded918ac7dc6bJason Sams // used typed allocations where the message id is the type indicator. 827516c31911578db8ce53529483c3ded918ac7dc6bJason Sams int[] rbuf = new int[16]; 8282e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams mRS.nContextInitToClient(mRS.mContext); 829516c31911578db8ce53529483c3ded918ac7dc6bJason Sams while(mRun) { 8301d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams rbuf[0] = 0; 831edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams int msg = mRS.nContextPeekMessage(mRS.mContext, mAuxData); 832bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int size = mAuxData[1]; 833bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int subID = mAuxData[0]; 8341c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 8351c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if (msg == RS_MESSAGE_TO_CLIENT_USER) { 8361c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if ((size>>2) >= rbuf.length) { 8371c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams rbuf = new int[(size + 3) >> 2]; 8381c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 839edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams if (mRS.nContextGetUserMessage(mRS.mContext, rbuf) != 840edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams RS_MESSAGE_TO_CLIENT_USER) { 841edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams throw new RSDriverException("Error processing message from Renderscript."); 842edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams } 8431c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 8441c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if(mRS.mMessageCallback != null) { 8451c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mMessageCallback.mData = rbuf; 8461c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mMessageCallback.mID = subID; 8471c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mMessageCallback.mLength = size; 8481c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mMessageCallback.run(); 8491d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams } else { 8501c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams throw new RSInvalidStateException("Received a message from the script with no message handler installed."); 851516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 852ab98bb6e8b95bef7415c1ad239be71f93322fbadStephen Hines continue; 853516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 8541c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 8551c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if (msg == RS_MESSAGE_TO_CLIENT_ERROR) { 8561c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams String e = mRS.nContextGetErrorMessage(mRS.mContext); 8571c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 858add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams if (subID >= RS_ERROR_FATAL_UNKNOWN) { 859add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams throw new RSRuntimeException("Fatal error " + subID + ", details: " + e); 860add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams } 861add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams 8621c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if(mRS.mErrorCallback != null) { 8631c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mErrorCallback.mErrorMessage = e; 8641c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mErrorCallback.mErrorNum = subID; 8651c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mErrorCallback.run(); 8661c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } else { 867be74bdd2349095f203ae0fddcc4816bfbd56bc5dStephen Hines // Do not throw here. In these cases, we do not have 868be74bdd2349095f203ae0fddcc4816bfbd56bc5dStephen Hines // a fatal error. 8691c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 8701c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams continue; 8711c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 8721c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 8731c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams // 2: teardown. 8741c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams // But we want to avoid starving other threads during 8751c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams // teardown by yielding until the next line in the destructor 8761c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams // can execute to set mRun = false 8771c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams try { 8781c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams sleep(1, 0); 8791c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } catch(InterruptedException e) { 880516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 881516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 8823bc47d438171dce294e816366d53bc9eca772c5bJason Sams Log.d(LOG_TAG, "MessageThread exiting."); 883516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 884516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 885516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 8866b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao RenderScript(Context ctx) { 8876b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao mApplicationContext = ctx.getApplicationContext(); 88860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 88960aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 89027676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 8916b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao * Gets the application context associated with the RenderScript context. 89227676fe24be7444a174c15df476e49adc5335d03Jason Sams * 8936b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao * @return The application context. 8946b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao */ 8956b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao public final Context getApplicationContext() { 8966b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao return mApplicationContext; 8976b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao } 8986b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao 8994382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines static int getTargetSdkVersion(Context ctx) { 90085397d8dcbcbe098c805b90fe7779206125e2399Jason Sams return ctx.getApplicationInfo().targetSdkVersion; 9014382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines } 9024382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines 9036b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao /** 9046b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao * Create a basic RenderScript context. 90527676fe24be7444a174c15df476e49adc5335d03Jason Sams * 9066b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao * @param ctx The context. 90727676fe24be7444a174c15df476e49adc5335d03Jason Sams * @return RenderScript 90827676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 9096b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao public static RenderScript create(Context ctx) { 9106b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao RenderScript rs = new RenderScript(ctx); 911704ff64b099406bb328898a7443921f22dbffd6dJason Sams 9124382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines int sdkVersion = getTargetSdkVersion(ctx); 9134382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines 914704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mDev = rs.nDeviceCreate(); 9154382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion); 9162698536b3ff60bfee85e47e4a8d4b25fdfdf4db5Jason Sams if (rs.mContext == 0) { 9172698536b3ff60bfee85e47e4a8d4b25fdfdf4db5Jason Sams throw new RSDriverException("Failed to create RS context."); 9182698536b3ff60bfee85e47e4a8d4b25fdfdf4db5Jason Sams } 919704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mMessageThread = new MessageThread(rs); 920704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mMessageThread.start(); 921704ff64b099406bb328898a7443921f22dbffd6dJason Sams return rs; 922efd9b6fb2e0f31b50db089352118e5daeb268879Jason Sams } 923efd9b6fb2e0f31b50db089352118e5daeb268879Jason Sams 92427676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 92527676fe24be7444a174c15df476e49adc5335d03Jason Sams * Print the currently available debugging information about the state of 92627676fe24be7444a174c15df476e49adc5335d03Jason Sams * the RS context to the log. 92727676fe24be7444a174c15df476e49adc5335d03Jason Sams * 92827676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 929bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public void contextDump() { 9305dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 931bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams nContextDump(0); 932715333b832fb448c32165c7d97d408a3fa43f7cbJason Sams } 933715333b832fb448c32165c7d97d408a3fa43f7cbJason Sams 93427676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 93527676fe24be7444a174c15df476e49adc5335d03Jason Sams * Wait for any commands in the fifo between the java bindings and native to 93627676fe24be7444a174c15df476e49adc5335d03Jason Sams * be processed. 93727676fe24be7444a174c15df476e49adc5335d03Jason Sams * 93827676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 93996ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams public void finish() { 94096ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams nContextFinish(); 94196ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams } 94296ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams 94327676fe24be7444a174c15df476e49adc5335d03Jason Sams /** 94427676fe24be7444a174c15df476e49adc5335d03Jason Sams * Destroy this renderscript context. Once this function is called its no 94527676fe24be7444a174c15df476e49adc5335d03Jason Sams * longer legal to use this or any objects created by this context. 94627676fe24be7444a174c15df476e49adc5335d03Jason Sams * 94727676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 948f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams public void destroy() { 9495dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 9502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams nContextDeinitToClient(mContext); 951516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mMessageThread.mRun = false; 952a8bf9429b29743b3489817feb21bde2416acc465Jason Sams try { 953a8bf9429b29743b3489817feb21bde2416acc465Jason Sams mMessageThread.join(); 954a8bf9429b29743b3489817feb21bde2416acc465Jason Sams } catch(InterruptedException e) { 955a8bf9429b29743b3489817feb21bde2416acc465Jason Sams } 956516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 9572e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams nContextDestroy(); 958f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams mContext = 0; 959f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams 960f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams nDeviceDestroy(mDev); 961f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams mDev = 0; 962f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams } 96302fb2cb531035779a25dbf9595e0628ea40585b0Jason Sams 964a9e7a05b84470257637c97d65f6562aa832c66efJason Sams boolean isAlive() { 965a9e7a05b84470257637c97d65f6562aa832c66efJason Sams return mContext != 0; 966a9e7a05b84470257637c97d65f6562aa832c66efJason Sams } 967a9e7a05b84470257637c97d65f6562aa832c66efJason Sams 968bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int safeID(BaseObj o) { 9696b9dec00afec359f091ed353f371f08ff150278aJason Sams if(o != null) { 97006d69de78845659e6904ae4964e606a7f1a6a4a8Jason Sams return o.getID(); 971d8e4161f114331343b897cbacea927e7e60e7b17Jason Sams } 9726b9dec00afec359f091ed353f371f08ff150278aJason Sams return 0; 97360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 97460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich} 975