RenderScript.java revision e4d9a01bfc7451afff1ed399a5801c7aa2af2831
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 19a6f338ca5f0c8359d1952167858851dd025e47e2Jason Samsimport java.io.File; 20fe1d5ffd1b6c4977a9f301997d2ad90e5b049a3bJason Samsimport java.lang.reflect.Field; 2136e612a488511940b61f09803b270aa1c61b68e0Jason Sams 226b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liaoimport android.content.Context; 234382467a80dd12c6362d57edca7f2367f7ae877cStephen Hinesimport android.content.pm.ApplicationInfo; 244382467a80dd12c6362d57edca7f2367f7ae877cStephen Hinesimport android.content.pm.PackageManager; 25b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchoukimport android.content.res.AssetManager; 26b8c5a84e7c23746a3fc26013e0880d3d95ca6588Jason Samsimport android.graphics.Bitmap; 27650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guyimport android.graphics.BitmapFactory; 28faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Samsimport android.graphics.SurfaceTexture; 29260c77a4f741c3db76057cc4ea2ee54fe335ecf9Glenn Kastenimport android.os.Process; 3036e612a488511940b61f09803b270aa1c61b68e0Jason Samsimport android.util.Log; 3136e612a488511940b61f09803b270aa1c61b68e0Jason Samsimport android.view.Surface; 32e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrillimport android.os.SystemProperties; 3343702d8925c54360ad5f9f66b0d35d61d59f6910Jack Palevich 3460aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 354382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines 369c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines/** 373aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * Renderscript base master class. An instance of this class creates native 3827676fe24be7444a174c15df476e49adc5335d03Jason Sams * worker threads for processing commands from this object. This base class 3927676fe24be7444a174c15df476e49adc5335d03Jason Sams * does not provide any extended capabilities beyond simple data processing. 4027676fe24be7444a174c15df476e49adc5335d03Jason Sams * For extended capabilities use derived classes such as RenderScriptGL. 4127676fe24be7444a174c15df476e49adc5335d03Jason Sams * 423aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * <div class="special reference"> 433aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * <h3>Developer Guides</h3> 443aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * <p>For more information about creating an application that uses Renderscript, read the 45b47fa1699a02a96d5da8e175966e9584c6bd5565Scott Main * <a href="{@docRoot}guide/topics/renderscript/index.html">Renderscript</a> developer guide.</p> 463aef8e1d1b2f0b87d470bcccf37ba4ebb6560c45Joe Fernandez * </div> 47e29d471e5ca9781d8772d445ec7832e94856fd14Jason Sams **/ 4860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevichpublic class RenderScript { 493bc47d438171dce294e816366d53bc9eca772c5bJason Sams static final String LOG_TAG = "RenderScript_jni"; 50bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final boolean DEBUG = false; 51650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guy @SuppressWarnings({"UnusedDeclaration", "deprecation"}) 5243a17654cf4bfe7f1ec22bd8b7b32daccdf27c09Joe Onorato static final boolean LOG_ENABLED = false; 5360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 546b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao private Context mApplicationContext; 5560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 566b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao /* 5760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * We use a class initializer to allow the native code to cache some 5860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich * field offsets. 5960aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich */ 60e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // TODO: now used locally; remove? 61bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static boolean sInitialized; 62bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams native static void _nInit(); 6360aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 64dba3ba5b5bf6026abceced921b1b0d231b0faefdJason Sams 6560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich static { 6660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich sInitialized = false; 67e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill if (!SystemProperties.getBoolean("config.disable_renderscript", false)) { 68e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill try { 69e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill System.loadLibrary("rs_jni"); 70e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill _nInit(); 71e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill sInitialized = true; 72e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill } catch (UnsatisfiedLinkError e) { 73e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill Log.e(LOG_TAG, "Error loading RS jni library: " + e); 74e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill throw new RSRuntimeException("Error loading RS jni library: " + e); 75e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill } 7660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 7760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 7860aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 792e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // Non-threadsafe functions. 8036e612a488511940b61f09803b270aa1c61b68e0Jason Sams native int nDeviceCreate(); 8136e612a488511940b61f09803b270aa1c61b68e0Jason Sams native void nDeviceDestroy(int dev); 82ebfb436a49673693b98469683451bd9ede797557Jason Sams native void nDeviceSetConfig(int dev, int param, int value); 83edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams native int nContextGetUserMessage(int con, int[] data); 841c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams native String nContextGetErrorMessage(int con); 85edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams native int nContextPeekMessage(int con, int[] subID); 862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void nContextInitToClient(int con); 872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void nContextDeinitToClient(int con); 882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 89a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams /** 90a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams * Name of the file that holds the object cache. 91a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams */ 92a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams private static final String CACHE_PATH = "com.android.renderscript.cache"; 931a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams static String mCachePath; 94a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams 95a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams /** 96a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams * Sets the directory to use as a persistent storage for the 97a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams * renderscript object file cache. 98a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams * 99a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams * @hide 100a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams * @param cacheDir A directory the current process can write to 101a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams */ 102a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams public static void setupDiskCache(File cacheDir) { 103e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill if (!sInitialized) { 104e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill Log.e(LOG_TAG, "RenderScript.setupDiskCache() called when disabled"); 105e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill return; 106e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill } 107e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill 108a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams File f = new File(cacheDir, CACHE_PATH); 109a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams mCachePath = f.getAbsolutePath(); 110a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams f.mkdirs(); 111a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams } 112a6f338ca5f0c8359d1952167858851dd025e47e2Jason Sams 113add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams public enum ContextType { 114add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams NORMAL (0), 115add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams DEBUG (1), 116add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams PROFILE (2); 117add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams 118add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams int mID; 119add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams ContextType(int id) { 120add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams mID = id; 121add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams } 122add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams } 1232e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 1242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // Methods below are wrapped to protect the non-threadsafe 1252e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams // lockless fifo. 1264382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines native int rsnContextCreateGL(int dev, int ver, int sdkVer, 12711c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int colorMin, int colorPref, 12811c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int alphaMin, int alphaPref, 12911c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int depthMin, int depthPref, 13011c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int stencilMin, int stencilPref, 1312c74ad9aae29cc64fece926f353825a7925792c2Alex Sakhartchouk int samplesMin, int samplesPref, float samplesQ, int dpi); 1324382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines synchronized int nContextCreateGL(int dev, int ver, int sdkVer, 13311c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int colorMin, int colorPref, 13411c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int alphaMin, int alphaPref, 13511c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int depthMin, int depthPref, 13611c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams int stencilMin, int stencilPref, 1372c74ad9aae29cc64fece926f353825a7925792c2Alex Sakhartchouk int samplesMin, int samplesPref, float samplesQ, int dpi) { 1384382467a80dd12c6362d57edca7f2367f7ae877cStephen Hines return rsnContextCreateGL(dev, ver, sdkVer, colorMin, colorPref, 13911c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams alphaMin, alphaPref, depthMin, depthPref, 14011c8af9ded3a319635b4e91a639a616ec97fc7e3Jason Sams stencilMin, stencilPref, 1412c74ad9aae29cc64fece926f353825a7925792c2Alex Sakhartchouk samplesMin, samplesPref, samplesQ, dpi); 1422e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 143add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams native int rsnContextCreate(int dev, int ver, int sdkVer, int contextType); 144add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams synchronized int nContextCreate(int dev, int ver, int sdkVer, int contextType) { 145add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams return rsnContextCreate(dev, ver, sdkVer, contextType); 1462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1472e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextDestroy(int con); 1482e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextDestroy() { 149d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextDestroy(mContext); 1512e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1522e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextSetSurface(int con, int w, int h, Surface sur); 1532e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextSetSurface(int w, int h, Surface sur) { 154d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextSetSurface(mContext, w, h, sur); 1562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 157faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams native void rsnContextSetSurfaceTexture(int con, int w, int h, SurfaceTexture sur); 158faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams synchronized void nContextSetSurfaceTexture(int w, int h, SurfaceTexture sur) { 159faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams validate(); 160faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams rsnContextSetSurfaceTexture(mContext, w, h, sur); 161faa32b33b50ad941f631716dd0915e936bdc3ac5Jason Sams } 1622e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextSetPriority(int con, int p); 1632e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextSetPriority(int p) { 164d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextSetPriority(mContext, p); 1662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1672e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextDump(int con, int bits); 1682e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextDump(int bits) { 169d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1702e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextDump(mContext, bits); 1712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextFinish(int con); 1732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextFinish() { 174d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextFinish(mContext); 1762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1772e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 178455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams native void rsnContextSendMessage(int con, int id, int[] data); 179455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams synchronized void nContextSendMessage(int id, int[] data) { 180455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams validate(); 181455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams rsnContextSendMessage(mContext, id, data); 182455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams } 183455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams 1842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindRootScript(int con, int script); 1852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindRootScript(int script) { 186d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindRootScript(mContext, script); 1882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindSampler(int con, int sampler, int slot); 1902e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindSampler(int sampler, int slot) { 191d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindSampler(mContext, sampler, slot); 1932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramStore(int con, int pfs); 1952e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramStore(int pfs) { 196d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 1972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramStore(mContext, pfs); 1982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 1992e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramFragment(int con, int pf); 2002e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramFragment(int pf) { 201d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramFragment(mContext, pf); 2032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramVertex(int con, int pv); 2052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramVertex(int pv) { 206d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2072e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramVertex(mContext, pv); 2082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2092e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextBindProgramRaster(int con, int pr); 2102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextBindProgramRaster(int pr) { 211d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2122e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextBindProgramRaster(mContext, pr); 2132e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextPause(int con); 2152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextPause() { 216d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextPause(mContext); 2182e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnContextResume(int con); 2202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nContextResume() { 221d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2222e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnContextResume(mContext); 2232e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2252e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAssignName(int con, int obj, byte[] name); 2262e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAssignName(int obj, byte[] name) { 227d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2282e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAssignName(mContext, obj, name); 2292e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2302e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native String rsnGetName(int con, int obj); 2312e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized String nGetName(int obj) { 232d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2332e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnGetName(mContext, obj); 2342e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2352e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnObjDestroy(int con, int id); 2362e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nObjDestroy(int id) { 237d1ac98149737299513da1357e36f68cbb6d74425Jason Sams // There is a race condition here. The calling code may be run 238d1ac98149737299513da1357e36f68cbb6d74425Jason Sams // by the gc while teardown is occuring. This protects againts 239d1ac98149737299513da1357e36f68cbb6d74425Jason Sams // deleting dead objects. 240d1ac98149737299513da1357e36f68cbb6d74425Jason Sams if (mContext != 0) { 241d1ac98149737299513da1357e36f68cbb6d74425Jason Sams rsnObjDestroy(mContext, id); 242d1ac98149737299513da1357e36f68cbb6d74425Jason Sams } 2432e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2442e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 2452e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize); 2462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nElementCreate(int type, int kind, boolean norm, int vecSize) { 247d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2482e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnElementCreate(mContext, type, kind, norm, vecSize); 2492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 25070d4e5024298f71edb3b04867e05568f5495b4ceJason Sams native int rsnElementCreate2(int con, int[] elements, String[] names, int[] arraySizes); 25170d4e5024298f71edb3b04867e05568f5495b4ceJason Sams synchronized int nElementCreate2(int[] elements, String[] names, int[] arraySizes) { 252d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 25370d4e5024298f71edb3b04867e05568f5495b4ceJason Sams return rsnElementCreate2(mContext, elements, names, arraySizes); 2542e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnElementGetNativeData(int con, int id, int[] elementData); 2562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nElementGetNativeData(int id, int[] elementData) { 257d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2582e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnElementGetNativeData(mContext, id, elementData); 2592e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2607d5f5e7c8943e043a422ad51c85d4e1684c37e28Alex Sakhartchouk native void rsnElementGetSubElements(int con, int id, 2617d5f5e7c8943e043a422ad51c85d4e1684c37e28Alex Sakhartchouk int[] IDs, String[] names, int[] arraySizes); 2627d5f5e7c8943e043a422ad51c85d4e1684c37e28Alex Sakhartchouk synchronized void nElementGetSubElements(int id, int[] IDs, String[] names, int[] arraySizes) { 263d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2647d5f5e7c8943e043a422ad51c85d4e1684c37e28Alex Sakhartchouk rsnElementGetSubElements(mContext, id, IDs, names, arraySizes); 2652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 267b109cc78616abee7291eb42094cd156b5db3355dJason Sams native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv); 268b109cc78616abee7291eb42094cd156b5db3355dJason Sams synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces, int yuv) { 269d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 270b109cc78616abee7291eb42094cd156b5db3355dJason Sams return rsnTypeCreate(mContext, eid, x, y, z, mips, faces, yuv); 2712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnTypeGetNativeData(int con, int id, int[] typeData); 2732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nTypeGetNativeData(int id, int[] typeData) { 274d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnTypeGetNativeData(mContext, id, typeData); 2762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2772e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 278857d0c7017da763a420e825fffa2f260eb982c97Jason Sams native int rsnAllocationCreateTyped(int con, int type, int mip, int usage, int pointer); 279857d0c7017da763a420e825fffa2f260eb982c97Jason Sams synchronized int nAllocationCreateTyped(int type, int mip, int usage, int pointer) { 280d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 281857d0c7017da763a420e825fffa2f260eb982c97Jason Sams return rsnAllocationCreateTyped(mContext, type, mip, usage, pointer); 2822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 2835476b450e50939940dcf3f15c92335cee2fc572dJason Sams native int rsnAllocationCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage); 2845476b450e50939940dcf3f15c92335cee2fc572dJason Sams synchronized int nAllocationCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) { 285d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2865476b450e50939940dcf3f15c92335cee2fc572dJason Sams return rsnAllocationCreateFromBitmap(mContext, type, mip, bmp, usage); 28726ae3904e8050eae655722caf93ee5d3f0ab195aAlex Sakhartchouk } 288a314551d69098537337c970da615a8f8af58e1f1Tim Murray 289a314551d69098537337c970da615a8f8af58e1f1Tim Murray native int rsnAllocationCreateBitmapBackedAllocation(int con, int type, int mip, Bitmap bmp, int usage); 290a314551d69098537337c970da615a8f8af58e1f1Tim Murray synchronized int nAllocationCreateBitmapBackedAllocation(int type, int mip, Bitmap bmp, int usage) { 291a314551d69098537337c970da615a8f8af58e1f1Tim Murray validate(); 292a314551d69098537337c970da615a8f8af58e1f1Tim Murray return rsnAllocationCreateBitmapBackedAllocation(mContext, type, mip, bmp, usage); 293a314551d69098537337c970da615a8f8af58e1f1Tim Murray } 294a314551d69098537337c970da615a8f8af58e1f1Tim Murray 295a314551d69098537337c970da615a8f8af58e1f1Tim Murray 2965476b450e50939940dcf3f15c92335cee2fc572dJason Sams native int rsnAllocationCubeCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage); 2975476b450e50939940dcf3f15c92335cee2fc572dJason Sams synchronized int nAllocationCubeCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) { 298d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 2995476b450e50939940dcf3f15c92335cee2fc572dJason Sams return rsnAllocationCubeCreateFromBitmap(mContext, type, mip, bmp, usage); 30067f2e442a31b8395e3c1951f8e91139ec7f2be99Alex Sakhartchouk } 3012e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationCreateBitmapRef(int con, int type, Bitmap bmp); 3022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationCreateBitmapRef(int type, Bitmap bmp) { 303d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 3042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationCreateBitmapRef(mContext, type, bmp); 3052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3065476b450e50939940dcf3f15c92335cee2fc572dJason Sams native int rsnAllocationCreateFromAssetStream(int con, int mips, int assetStream, int usage); 3075476b450e50939940dcf3f15c92335cee2fc572dJason Sams synchronized int nAllocationCreateFromAssetStream(int mips, int assetStream, int usage) { 308d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 3095476b450e50939940dcf3f15c92335cee2fc572dJason Sams return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage); 3105476b450e50939940dcf3f15c92335cee2fc572dJason Sams } 3115476b450e50939940dcf3f15c92335cee2fc572dJason Sams 3124ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams native void rsnAllocationCopyToBitmap(int con, int alloc, Bitmap bmp); 3134ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams synchronized void nAllocationCopyToBitmap(int alloc, Bitmap bmp) { 314d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 3154ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams rsnAllocationCopyToBitmap(mContext, alloc, bmp); 3164ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams } 3174ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams 3184ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams 3195476b450e50939940dcf3f15c92335cee2fc572dJason Sams native void rsnAllocationSyncAll(int con, int alloc, int src); 3205476b450e50939940dcf3f15c92335cee2fc572dJason Sams synchronized void nAllocationSyncAll(int alloc, int src) { 321d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 3225476b450e50939940dcf3f15c92335cee2fc572dJason Sams rsnAllocationSyncAll(mContext, alloc, src); 3235476b450e50939940dcf3f15c92335cee2fc572dJason Sams } 32472226e0543461133b9e177a3e78ae50b0c65e797Jason Sams native Surface rsnAllocationGetSurface(int con, int alloc); 32572226e0543461133b9e177a3e78ae50b0c65e797Jason Sams synchronized Surface nAllocationGetSurface(int alloc) { 326615e7cee03d1a53072b0369fa9f247811ac56845Jason Sams validate(); 32772226e0543461133b9e177a3e78ae50b0c65e797Jason Sams return rsnAllocationGetSurface(mContext, alloc); 328fe1d5ffd1b6c4977a9f301997d2ad90e5b049a3bJason Sams } 329fb9aa9f3ef11878caaf6fcfb5ea49ffb9f7abf33Jason Sams native void rsnAllocationSetSurface(int con, int alloc, Surface sur); 330fb9aa9f3ef11878caaf6fcfb5ea49ffb9f7abf33Jason Sams synchronized void nAllocationSetSurface(int alloc, Surface sur) { 331163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams validate(); 332fb9aa9f3ef11878caaf6fcfb5ea49ffb9f7abf33Jason Sams rsnAllocationSetSurface(mContext, alloc, sur); 333163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams } 334163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams native void rsnAllocationIoSend(int con, int alloc); 335163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams synchronized void nAllocationIoSend(int alloc) { 336163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams validate(); 337163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams rsnAllocationIoSend(mContext, alloc); 338163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams } 339163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams native void rsnAllocationIoReceive(int con, int alloc); 340163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams synchronized void nAllocationIoReceive(int alloc) { 341163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams validate(); 342163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams rsnAllocationIoReceive(mContext, alloc); 343163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams } 344163766cbe798baf8e86eb8201bc6c3def931d59aJason Sams 345615e7cee03d1a53072b0369fa9f247811ac56845Jason Sams 346f7086090cfc8d97b5bd3b4d7801a27af11f7c207Jason Sams native void rsnAllocationGenerateMipmaps(int con, int alloc); 347f7086090cfc8d97b5bd3b4d7801a27af11f7c207Jason Sams synchronized void nAllocationGenerateMipmaps(int alloc) { 348d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 349f7086090cfc8d97b5bd3b4d7801a27af11f7c207Jason Sams rsnAllocationGenerateMipmaps(mContext, alloc); 350f7086090cfc8d97b5bd3b4d7801a27af11f7c207Jason Sams } 3514ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp); 3524ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) { 353d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 3544ef6650bd05a39a09958ea1db92f120ea4949cb1Jason Sams rsnAllocationCopyFromBitmap(mContext, alloc, bmp); 3552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 3572e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 35849a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData1D(int con, int id, int off, int mip, int count, int[] d, int sizeBytes); 35949a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData1D(int id, int off, int mip, int count, int[] d, int sizeBytes) { 360d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 36149a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); 3622e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 36349a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData1D(int con, int id, int off, int mip, int count, short[] d, int sizeBytes); 36449a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData1D(int id, int off, int mip, int count, short[] d, int sizeBytes) { 365d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 36649a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); 3672e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 36849a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData1D(int con, int id, int off, int mip, int count, byte[] d, int sizeBytes); 36949a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData1D(int id, int off, int mip, int count, byte[] d, int sizeBytes) { 370d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 37149a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); 3722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 37349a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData1D(int con, int id, int off, int mip, int count, float[] d, int sizeBytes); 37449a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData1D(int id, int off, int mip, int count, float[] d, int sizeBytes) { 375d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 37649a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); 37749bdaf0293408159df18a1d8540360f9623c40f7Jason Sams } 37849a05d7b82956009f03acbb92a064eed054eb031Jason Sams 37949a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationElementData1D(int con, int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes); 38049a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationElementData1D(int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) { 381d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 38249a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes); 3832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 3842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 385304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk native void rsnAllocationData2D(int con, 386304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int dstAlloc, int dstXoff, int dstYoff, 387304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int dstMip, int dstFace, 388304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int width, int height, 389304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int srcAlloc, int srcXoff, int srcYoff, 390304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int srcMip, int srcFace); 391304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk synchronized void nAllocationData2D(int dstAlloc, int dstXoff, int dstYoff, 392304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int dstMip, int dstFace, 393304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int width, int height, 394304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int srcAlloc, int srcXoff, int srcYoff, 395304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk int srcMip, int srcFace) { 396304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk validate(); 397304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk rsnAllocationData2D(mContext, 398304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk dstAlloc, dstXoff, dstYoff, 399304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk dstMip, dstFace, 400304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk width, height, 401304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk srcAlloc, srcXoff, srcYoff, 402304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk srcMip, srcFace); 403304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk } 404304b1f5497155bcf91e7b855cfab7a675e80bf26Alex Sakhartchouk 405fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes); 406fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes) { 407d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 408fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); 409fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 410fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes); 411fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, short[] d, int sizeBytes) { 412d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 413fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); 414fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 41549a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes); 41649a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes) { 417d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 41849a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); 4192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 42049a05d7b82956009f03acbb92a064eed054eb031Jason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes); 42149a05d7b82956009f03acbb92a064eed054eb031Jason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes) { 422d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 42349a05d7b82956009f03acbb92a064eed054eb031Jason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); 4242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 425fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, Bitmap b); 426fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, Bitmap b) { 427d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 428fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, b); 429fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 43049a05d7b82956009f03acbb92a064eed054eb031Jason Sams 431fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationRead(int con, int id, byte[] d); 432fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationRead(int id, byte[] d) { 433d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 434fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationRead(mContext, id, d); 435fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 436fa445b9353972735d8d65e8a936786b1afe9886dJason Sams native void rsnAllocationRead(int con, int id, short[] d); 437fa445b9353972735d8d65e8a936786b1afe9886dJason Sams synchronized void nAllocationRead(int id, short[] d) { 438d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 439fa445b9353972735d8d65e8a936786b1afe9886dJason Sams rsnAllocationRead(mContext, id, d); 440fa445b9353972735d8d65e8a936786b1afe9886dJason Sams } 4412e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationRead(int con, int id, int[] d); 4422e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationRead(int id, int[] d) { 443d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4442e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationRead(mContext, id, d); 4452e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4462e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnAllocationRead(int con, int id, float[] d); 4472e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nAllocationRead(int id, float[] d) { 448d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4492e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnAllocationRead(mContext, id, d); 4502e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4512e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnAllocationGetType(int con, int id); 4522e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nAllocationGetType(int id) { 453d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4542e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnAllocationGetType(mContext, id); 4552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 4575edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams native void rsnAllocationResize1D(int con, int id, int dimX); 4585edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams synchronized void nAllocationResize1D(int id, int dimX) { 459d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4605edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams rsnAllocationResize1D(mContext, id, dimX); 4615edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams } 4625edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams native void rsnAllocationResize2D(int con, int id, int dimX, int dimY); 4635edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams synchronized void nAllocationResize2D(int id, int dimX, int dimY) { 464d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4655edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams rsnAllocationResize2D(mContext, id, dimX, dimY); 4665edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams } 4675edc608a0749ed4b7074b5c1243043eb722c3c31Jason Sams 4682e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DCreateFromAssetStream(int con, int assetStream); 4692e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DCreateFromAssetStream(int assetStream) { 470d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DCreateFromAssetStream(mContext, assetStream); 4722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 473b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk native int rsnFileA3DCreateFromFile(int con, String path); 474b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk synchronized int nFileA3DCreateFromFile(String path) { 475d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 476b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk return rsnFileA3DCreateFromFile(mContext, path); 477b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk } 478b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk native int rsnFileA3DCreateFromAsset(int con, AssetManager mgr, String path); 479b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk synchronized int nFileA3DCreateFromAsset(AssetManager mgr, String path) { 480d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 481b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk return rsnFileA3DCreateFromAsset(mContext, mgr, path); 482b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk } 4832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DGetNumIndexEntries(int con, int fileA3D); 4842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DGetNumIndexEntries(int fileA3D) { 485d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DGetNumIndexEntries(mContext, fileA3D); 4872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4882e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnFileA3DGetIndexEntries(int con, int fileA3D, int numEntries, int[] IDs, String[] names); 4892e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nFileA3DGetIndexEntries(int fileA3D, int numEntries, int[] IDs, String[] names) { 490d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4912e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnFileA3DGetIndexEntries(mContext, fileA3D, numEntries, IDs, names); 4922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4932e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnFileA3DGetEntryByIndex(int con, int fileA3D, int index); 4942e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nFileA3DGetEntryByIndex(int fileA3D, int index) { 495d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 4962e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFileA3DGetEntryByIndex(mContext, fileA3D, index); 4972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 4982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 499e27cdeeecba5b445e307d653d9cb7da007adfac3Alex Sakhartchouk native int rsnFontCreateFromFile(int con, String fileName, float size, int dpi); 500e27cdeeecba5b445e307d653d9cb7da007adfac3Alex Sakhartchouk synchronized int nFontCreateFromFile(String fileName, float size, int dpi) { 501d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5022e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnFontCreateFromFile(mContext, fileName, size, dpi); 5032e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 504b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk native int rsnFontCreateFromAssetStream(int con, String name, float size, int dpi, int assetStream); 505b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk synchronized int nFontCreateFromAssetStream(String name, float size, int dpi, int assetStream) { 506d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 507b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk return rsnFontCreateFromAssetStream(mContext, name, size, dpi, assetStream); 508b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk } 509b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk native int rsnFontCreateFromAsset(int con, AssetManager mgr, String path, float size, int dpi); 510b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk synchronized int nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) { 511d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 512b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk return rsnFontCreateFromAsset(mContext, mgr, path, size, dpi); 513b0253ea6969bdd27bf574e0da7fa91aa6d09f44fAlex Sakhartchouk } 5142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 5152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 5162e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptBindAllocation(int con, int script, int alloc, int slot); 5172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptBindAllocation(int script, int alloc, int slot) { 518d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptBindAllocation(mContext, script, alloc, slot); 5202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5212e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetTimeZone(int con, int script, byte[] timeZone); 5222e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetTimeZone(int script, byte[] timeZone) { 523d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetTimeZone(mContext, script, timeZone); 5252e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5262e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptInvoke(int con, int id, int slot); 5272e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptInvoke(int id, int slot) { 528d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5292e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptInvoke(mContext, id, slot); 5302e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5316e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams native void rsnScriptForEach(int con, int id, int slot, int ain, int aout, byte[] params); 5326e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams native void rsnScriptForEach(int con, int id, int slot, int ain, int aout); 533eb8c29cb7ece3f4b7ad18e5393b07fa7418a541cTim Murray native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, byte[] params, 534eb8c29cb7ece3f4b7ad18e5393b07fa7418a541cTim Murray int xstart, int xend, int ystart, int yend, int zstart, int zend); 535dac6ed0b69b23ab25757085dd5ce68092516ee2fStephen Hines native void rsnScriptForEachClipped(int con, int id, int slot, int ain, int aout, 536dac6ed0b69b23ab25757085dd5ce68092516ee2fStephen Hines int xstart, int xend, int ystart, int yend, int zstart, int zend); 5376e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams synchronized void nScriptForEach(int id, int slot, int ain, int aout, byte[] params) { 5386e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams validate(); 5396e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams if (params == null) { 5406e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams rsnScriptForEach(mContext, id, slot, ain, aout); 5416e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams } else { 5426e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams rsnScriptForEach(mContext, id, slot, ain, aout, params); 5436e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams } 5446e494d3ab606be8c06f8d4930fbec572bbfa15c2Jason Sams } 545eb8c29cb7ece3f4b7ad18e5393b07fa7418a541cTim Murray 546eb8c29cb7ece3f4b7ad18e5393b07fa7418a541cTim Murray synchronized void nScriptForEachClipped(int id, int slot, int ain, int aout, byte[] params, 547eb8c29cb7ece3f4b7ad18e5393b07fa7418a541cTim Murray int xstart, int xend, int ystart, int yend, int zstart, int zend) { 548eb8c29cb7ece3f4b7ad18e5393b07fa7418a541cTim Murray validate(); 549dac6ed0b69b23ab25757085dd5ce68092516ee2fStephen Hines if (params == null) { 550dac6ed0b69b23ab25757085dd5ce68092516ee2fStephen Hines rsnScriptForEachClipped(mContext, id, slot, ain, aout, xstart, xend, ystart, yend, zstart, zend); 551dac6ed0b69b23ab25757085dd5ce68092516ee2fStephen Hines } else { 552dac6ed0b69b23ab25757085dd5ce68092516ee2fStephen Hines rsnScriptForEachClipped(mContext, id, slot, ain, aout, params, xstart, xend, ystart, yend, zstart, zend); 553dac6ed0b69b23ab25757085dd5ce68092516ee2fStephen Hines } 554eb8c29cb7ece3f4b7ad18e5393b07fa7418a541cTim Murray } 555eb8c29cb7ece3f4b7ad18e5393b07fa7418a541cTim Murray 5562e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptInvokeV(int con, int id, int slot, byte[] params); 5572e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptInvokeV(int id, int slot, byte[] params) { 558d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5592e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptInvokeV(mContext, id, slot, params); 5602e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 5612e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarI(int con, int id, int slot, int val); 5622e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarI(int id, int slot, int val) { 563d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5642e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarI(mContext, id, slot, val); 5652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 566031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines native void rsnScriptSetVarJ(int con, int id, int slot, long val); 567031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines synchronized void nScriptSetVarJ(int id, int slot, long val) { 568d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 569031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines rsnScriptSetVarJ(mContext, id, slot, val); 570031ec58cfc7a20927302a5300eba3f5fc1709b50Stephen Hines } 5712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarF(int con, int id, int slot, float val); 5722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarF(int id, int slot, float val) { 573d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5742e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarF(mContext, id, slot, val); 5752e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 576ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines native void rsnScriptSetVarD(int con, int id, int slot, double val); 577ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines synchronized void nScriptSetVarD(int id, int slot, double val) { 578d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 579ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines rsnScriptSetVarD(mContext, id, slot, val); 580ca54ec302f5bddd1674ea1f36cd3b7c540b2fbcaStephen Hines } 5812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnScriptSetVarV(int con, int id, int slot, byte[] val); 5822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nScriptSetVarV(int id, int slot, byte[] val) { 583d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnScriptSetVarV(mContext, id, slot, val); 5852e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 586adeb809201fcb77ba2b76a814ae4cdc9dacb326bStephen Hines native void rsnScriptSetVarVE(int con, int id, int slot, byte[] val, 587adeb809201fcb77ba2b76a814ae4cdc9dacb326bStephen Hines int e, int[] dims); 588adeb809201fcb77ba2b76a814ae4cdc9dacb326bStephen Hines synchronized void nScriptSetVarVE(int id, int slot, byte[] val, 589adeb809201fcb77ba2b76a814ae4cdc9dacb326bStephen Hines int e, int[] dims) { 590adeb809201fcb77ba2b76a814ae4cdc9dacb326bStephen Hines validate(); 591adeb809201fcb77ba2b76a814ae4cdc9dacb326bStephen Hines rsnScriptSetVarVE(mContext, id, slot, val, e, dims); 592adeb809201fcb77ba2b76a814ae4cdc9dacb326bStephen Hines } 5936f4cf0b8885403ead157ae00fd43cf1282331c23Jason Sams native void rsnScriptSetVarObj(int con, int id, int slot, int val); 5946f4cf0b8885403ead157ae00fd43cf1282331c23Jason Sams synchronized void nScriptSetVarObj(int id, int slot, int val) { 595d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 5966f4cf0b8885403ead157ae00fd43cf1282331c23Jason Sams rsnScriptSetVarObj(mContext, id, slot, val); 5976f4cf0b8885403ead157ae00fd43cf1282331c23Jason Sams } 5982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 599e4a06c5fc738bf219f2a495e12a637b2d0871651Jason Sams native int rsnScriptCCreate(int con, String resName, String cacheDir, 600e4a06c5fc738bf219f2a495e12a637b2d0871651Jason Sams byte[] script, int length); 601e4a06c5fc738bf219f2a495e12a637b2d0871651Jason Sams synchronized int nScriptCCreate(String resName, String cacheDir, byte[] script, int length) { 602d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 603e4a06c5fc738bf219f2a495e12a637b2d0871651Jason Sams return rsnScriptCCreate(mContext, resName, cacheDir, script, length); 6042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 6066ab97682fd444586ee135912a4210417a1c8781bJason Sams native int rsnScriptIntrinsicCreate(int con, int id, int eid); 6076ab97682fd444586ee135912a4210417a1c8781bJason Sams synchronized int nScriptIntrinsicCreate(int id, int eid) { 6086ab97682fd444586ee135912a4210417a1c8781bJason Sams validate(); 6096ab97682fd444586ee135912a4210417a1c8781bJason Sams return rsnScriptIntrinsicCreate(mContext, id, eid); 6106ab97682fd444586ee135912a4210417a1c8781bJason Sams } 6116ab97682fd444586ee135912a4210417a1c8781bJason Sams 61208a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams native int rsnScriptKernelIDCreate(int con, int sid, int slot, int sig); 61308a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams synchronized int nScriptKernelIDCreate(int sid, int slot, int sig) { 61408a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams validate(); 61508a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams return rsnScriptKernelIDCreate(mContext, sid, slot, sig); 61608a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams } 61708a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams 61808a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams native int rsnScriptFieldIDCreate(int con, int sid, int slot); 61908a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams synchronized int nScriptFieldIDCreate(int sid, int slot) { 62008a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams validate(); 62108a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams return rsnScriptFieldIDCreate(mContext, sid, slot); 62208a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams } 62308a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams 62408a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams native int rsnScriptGroupCreate(int con, int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types); 62508a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams synchronized int nScriptGroupCreate(int[] kernels, int[] src, int[] dstk, int[] dstf, int[] types) { 62608a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams validate(); 62708a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams return rsnScriptGroupCreate(mContext, kernels, src, dstk, dstf, types); 62808a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams } 62908a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams 63008a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams native void rsnScriptGroupSetInput(int con, int group, int kernel, int alloc); 63108a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams synchronized void nScriptGroupSetInput(int group, int kernel, int alloc) { 63208a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams validate(); 63308a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams rsnScriptGroupSetInput(mContext, group, kernel, alloc); 63408a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams } 63508a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams 63608a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams native void rsnScriptGroupSetOutput(int con, int group, int kernel, int alloc); 63708a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams synchronized void nScriptGroupSetOutput(int group, int kernel, int alloc) { 63808a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams validate(); 63908a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams rsnScriptGroupSetOutput(mContext, group, kernel, alloc); 64008a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams } 64108a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams 64208a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams native void rsnScriptGroupExecute(int con, int group); 64308a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams synchronized void nScriptGroupExecute(int group) { 64408a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams validate(); 64508a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams rsnScriptGroupExecute(mContext, group); 64608a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams } 64708a81583c18a849e442ceeb8d7baeca743fb3be8Jason Sams 648a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk native int rsnSamplerCreate(int con, int magFilter, int minFilter, 649a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk int wrapS, int wrapT, int wrapR, float aniso); 650a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk synchronized int nSamplerCreate(int magFilter, int minFilter, 651a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk int wrapS, int wrapT, int wrapR, float aniso) { 652d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 653a89094aa3bc059c6e03b20b4c5b1ede4582f3da9Alex Sakhartchouk return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso); 6542e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6552e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 656331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams native int rsnProgramStoreCreate(int con, boolean r, boolean g, boolean b, boolean a, 657331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams boolean depthMask, boolean dither, 658331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams int srcMode, int dstMode, int depthFunc); 659331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams synchronized int nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a, 660331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams boolean depthMask, boolean dither, 661331bf9b14b1c5c1e88f5c4092b6e24fae887fb3bJason Sams int srcMode, int dstMode, int depthFunc) { 662d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 663bd184c55850997a5c5e285357998dadbe95b7b5dJason Sams return rsnProgramStoreCreate(mContext, r, g, b, a, depthMask, dither, srcMode, 664bd184c55850997a5c5e285357998dadbe95b7b5dJason Sams dstMode, depthFunc); 6652e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6662e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 66794aaed38467c71a6c804f0e18b41346a4013c25bJason Sams native int rsnProgramRasterCreate(int con, boolean pointSprite, int cullMode); 66894aaed38467c71a6c804f0e18b41346a4013c25bJason Sams synchronized int nProgramRasterCreate(boolean pointSprite, int cullMode) { 669d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 67094aaed38467c71a6c804f0e18b41346a4013c25bJason Sams return rsnProgramRasterCreate(mContext, pointSprite, cullMode); 6712e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6722e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 6732e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindConstants(int con, int pv, int slot, int mID); 6742e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindConstants(int pv, int slot, int mID) { 675d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 6762e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindConstants(mContext, pv, slot, mID); 6772e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6782e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindTexture(int con, int vpf, int slot, int a); 6792e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindTexture(int vpf, int slot, int a) { 680d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 6812e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindTexture(mContext, vpf, slot, a); 6822e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6832e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnProgramBindSampler(int con, int vpf, int slot, int s); 6842e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nProgramBindSampler(int vpf, int slot, int s) { 685d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 6862e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnProgramBindSampler(mContext, vpf, slot, s); 6872e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6882123b46ba85adb2cfb78068f8368e830640118d3Alex Sakhartchouk native int rsnProgramFragmentCreate(int con, String shader, String[] texNames, int[] params); 6892123b46ba85adb2cfb78068f8368e830640118d3Alex Sakhartchouk synchronized int nProgramFragmentCreate(String shader, String[] texNames, int[] params) { 690d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 6912123b46ba85adb2cfb78068f8368e830640118d3Alex Sakhartchouk return rsnProgramFragmentCreate(mContext, shader, texNames, params); 6922e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6932123b46ba85adb2cfb78068f8368e830640118d3Alex Sakhartchouk native int rsnProgramVertexCreate(int con, String shader, String[] texNames, int[] params); 6942123b46ba85adb2cfb78068f8368e830640118d3Alex Sakhartchouk synchronized int nProgramVertexCreate(String shader, String[] texNames, int[] params) { 695d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 6962123b46ba85adb2cfb78068f8368e830640118d3Alex Sakhartchouk return rsnProgramVertexCreate(mContext, shader, texNames, params); 6972e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 6982e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 69925999a08a6652ff5d7d0973f279f1e92e04b3506Alex Sakhartchouk native int rsnMeshCreate(int con, int[] vtx, int[] idx, int[] prim); 70025999a08a6652ff5d7d0973f279f1e92e04b3506Alex Sakhartchouk synchronized int nMeshCreate(int[] vtx, int[] idx, int[] prim) { 701d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 70225999a08a6652ff5d7d0973f279f1e92e04b3506Alex Sakhartchouk return rsnMeshCreate(mContext, vtx, idx, prim); 7039d71e2180062931416092f26276a07e55b318f62Alex Sakhartchouk } 7042e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnMeshGetVertexBufferCount(int con, int id); 7052e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nMeshGetVertexBufferCount(int id) { 706d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 7072e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnMeshGetVertexBufferCount(mContext, id); 7082e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 7092e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native int rsnMeshGetIndexCount(int con, int id); 7102e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized int nMeshGetIndexCount(int id) { 711d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 7122e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams return rsnMeshGetIndexCount(mContext, id); 7132e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 7142e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnMeshGetVertices(int con, int id, int[] vtxIds, int vtxIdCount); 7152e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nMeshGetVertices(int id, int[] vtxIds, int vtxIdCount) { 716d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 7172e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnMeshGetVertices(mContext, id, vtxIds, vtxIdCount); 7182e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 7192e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams native void rsnMeshGetIndices(int con, int id, int[] idxIds, int[] primitives, int vtxIdCount); 7202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams synchronized void nMeshGetIndices(int id, int[] idxIds, int[] primitives, int vtxIdCount) { 721d1ac98149737299513da1357e36f68cbb6d74425Jason Sams validate(); 7222e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount); 7232e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams } 7242e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams 725f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams native int rsnPathCreate(int con, int prim, boolean isStatic, int vtx, int loop, float q); 726f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams synchronized int nPathCreate(int prim, boolean isStatic, int vtx, int loop, float q) { 727f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams validate(); 728f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams return rsnPathCreate(mContext, prim, isStatic, vtx, loop, q); 729f15ed0124ea7f7f87e4188a1dd15cc4917a62ee9Jason Sams } 73060aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 731bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int mDev; 732bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int mContext; 733650a3eb7d621dc8e81573142a4498bbd07bcde27Romain Guy @SuppressWarnings({"FieldCanBeLocal"}) 734bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams MessageThread mMessageThread; 73560aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 7368cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U8; 7378cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I8; 7388cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U16; 7398cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I16; 7408cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_U32; 7418cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_I32; 74252d836332f6aae74ed97fda1b53681f36710af64Stephen Hines Element mElement_U64; 743ef1dac28d3bf98bd61cd9874fb3ccab42105e9b6Stephen Hines Element mElement_I64; 7448cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_F32; 74502f41705199336f808ece50d81585450e7f8f61fStephen Hines Element mElement_F64; 746f110d4b787b91dabe968a812e76e5c1f8d953487Jason Sams Element mElement_BOOLEAN; 7478cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams 7488cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_ELEMENT; 7498cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_TYPE; 7508cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_ALLOCATION; 7518cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_SAMPLER; 7528cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_SCRIPT; 7538cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_MESH; 7548cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_FRAGMENT; 7558cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_VERTEX; 7568cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_RASTER; 7578cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_PROGRAM_STORE; 7583a2914132146f340511425d7f78540098606b512Stephen Hines Element mElement_FONT; 759a70f416c9cf2fc6cc5e132c1d656ce07441d6b82Jason Sams 7603c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_A_8; 7613c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGB_565; 7623c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGB_888; 7633c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_5551; 7643c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_4444; 7653c0dfbab807a459622aeade4940daddf482dec66Jason Sams Element mElement_RGBA_8888; 7663c0dfbab807a459622aeade4940daddf482dec66Jason Sams 7678cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_2; 7688cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_3; 7698cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_FLOAT_4; 770836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 771836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_DOUBLE_2; 772836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_DOUBLE_3; 773836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_DOUBLE_4; 774836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 775836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UCHAR_2; 776836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UCHAR_3; 7778cb39de03aef6097a90033600d11a60ae000a6e4Jason Sams Element mElement_UCHAR_4; 7787d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 779836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_CHAR_2; 780836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_CHAR_3; 781836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_CHAR_4; 782836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 783836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_USHORT_2; 784836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_USHORT_3; 785836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_USHORT_4; 786836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 787836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_SHORT_2; 788836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_SHORT_3; 789836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_SHORT_4; 790836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 791836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UINT_2; 792836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UINT_3; 793836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_UINT_4; 794836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 795836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_INT_2; 796836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_INT_3; 797836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_INT_4; 798836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 799836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_ULONG_2; 800836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_ULONG_3; 801836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_ULONG_4; 802836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 803836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_LONG_2; 804836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_LONG_3; 805836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines Element mElement_LONG_4; 806836c4a58a7f03485ef433dcdb61837cbc0c39735Stephen Hines 8071d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_4X4; 8081d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_3X3; 8091d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams Element mElement_MATRIX_2X2; 8101d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams 8114d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_NEAREST; 8124d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_LINEAR; 8134d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_CLAMP_LINEAR_MIP_LINEAR; 8144d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_NEAREST; 8154d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_LINEAR; 8164d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams Sampler mSampler_WRAP_LINEAR_MIP_LINEAR; 8176b9b2caf2bf977508e223792bb5eba75091c232dTim Murray Sampler mSampler_MIRRORED_REPEAT_NEAREST; 8186b9b2caf2bf977508e223792bb5eba75091c232dTim Murray Sampler mSampler_MIRRORED_REPEAT_LINEAR; 8196b9b2caf2bf977508e223792bb5eba75091c232dTim Murray Sampler mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR; 8204d3399337d18ef04116bc8a2e5799274655d0c30Jason Sams 821d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_NONE_DEPTH_TEST; 822d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_NONE_DEPTH_NO_DEPTH; 823d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_TEST; 824d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramStore mProgramStore_BLEND_ALPHA_DEPTH_NO_DEPTH; 825d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk 826d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_BACK; 827d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_FRONT; 828d36f248eaf06c569010649902df653da1a9e2accAlex Sakhartchouk ProgramRaster mProgramRaster_CULL_NONE; 82932e09b5891da0174f161d99e2d3ebe67d6efa39cAlex Sakhartchouk 83060aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich /////////////////////////////////////////////////////////////////////////////////// 83143702d8925c54360ad5f9f66b0d35d61d59f6910Jack Palevich // 83260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 8339c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 83427676fe24be7444a174c15df476e49adc5335d03Jason Sams * Base class application should derive from for handling RS messages 8358cecbb5293f73e3f63f2601dda68016762c58a0cStephen Hines * coming from their scripts. When a script calls sendToClient the data 83627676fe24be7444a174c15df476e49adc5335d03Jason Sams * fields will be filled in and then the run method called by a message 83727676fe24be7444a174c15df476e49adc5335d03Jason Sams * handling thread. This will occur some time after sendToClient completes 83827676fe24be7444a174c15df476e49adc5335d03Jason Sams * in the script. 83927676fe24be7444a174c15df476e49adc5335d03Jason Sams * 84027676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 841bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public static class RSMessageHandler implements Runnable { 842516c31911578db8ce53529483c3ded918ac7dc6bJason Sams protected int[] mData; 843516c31911578db8ce53529483c3ded918ac7dc6bJason Sams protected int mID; 8441c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams protected int mLength; 845516c31911578db8ce53529483c3ded918ac7dc6bJason Sams public void run() { 846516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 847516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 8489c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 84927676fe24be7444a174c15df476e49adc5335d03Jason Sams * If an application is expecting messages it should set this field to an 85027676fe24be7444a174c15df476e49adc5335d03Jason Sams * instance of RSMessage. This instance will receive all the user messages 85127676fe24be7444a174c15df476e49adc5335d03Jason Sams * sent from sendToClient by scripts from this context. 85227676fe24be7444a174c15df476e49adc5335d03Jason Sams * 85327676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 854bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams RSMessageHandler mMessageCallback = null; 855bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams 856bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public void setMessageHandler(RSMessageHandler msg) { 857bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams mMessageCallback = msg; 858bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams } 859bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public RSMessageHandler getMessageHandler() { 860bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams return mMessageCallback; 861bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams } 862516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 8639c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 864455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams * @hide 865455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams * 866455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams * @param id 867455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams * @param data 868455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams */ 869455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams public void sendMessage(int id, int[] data) { 870455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams nContextSendMessage(id, data); 871455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams } 872455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams 873455d64426615e5d269a3bd05cd91b67c3811fcdfJason Sams /** 87427676fe24be7444a174c15df476e49adc5335d03Jason Sams * Runtime error base class. An application should derive from this class 87527676fe24be7444a174c15df476e49adc5335d03Jason Sams * if it wishes to install an error handler. When errors occur at runtime 87627676fe24be7444a174c15df476e49adc5335d03Jason Sams * the fields in this class will be filled and the run method called. 87727676fe24be7444a174c15df476e49adc5335d03Jason Sams * 87827676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 879bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public static class RSErrorHandler implements Runnable { 8801c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams protected String mErrorMessage; 8811c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams protected int mErrorNum; 8821c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams public void run() { 8831c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 8841c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 88527676fe24be7444a174c15df476e49adc5335d03Jason Sams 8869c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 88727676fe24be7444a174c15df476e49adc5335d03Jason Sams * Application Error handler. All runtime errors will be dispatched to the 88827676fe24be7444a174c15df476e49adc5335d03Jason Sams * instance of RSAsyncError set here. If this field is null a 88927676fe24be7444a174c15df476e49adc5335d03Jason Sams * RSRuntimeException will instead be thrown with details about the error. 89027676fe24be7444a174c15df476e49adc5335d03Jason Sams * This will cause program termaination. 89127676fe24be7444a174c15df476e49adc5335d03Jason Sams * 89227676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 893bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams RSErrorHandler mErrorCallback = null; 894bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams 895bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public void setErrorHandler(RSErrorHandler msg) { 896bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams mErrorCallback = msg; 897bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams } 898bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public RSErrorHandler getErrorHandler() { 899bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams return mErrorCallback; 900bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams } 9011c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 9029c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 90327676fe24be7444a174c15df476e49adc5335d03Jason Sams * RenderScript worker threads priority enumeration. The default value is 90427676fe24be7444a174c15df476e49adc5335d03Jason Sams * NORMAL. Applications wishing to do background processing such as 90527676fe24be7444a174c15df476e49adc5335d03Jason Sams * wallpapers should set their priority to LOW to avoid starving forground 90627676fe24be7444a174c15df476e49adc5335d03Jason Sams * processes. 90727676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 9087d787b4722eaeb79cab42c36060336e092b77b5fJason Sams public enum Priority { 909260c77a4f741c3db76057cc4ea2ee54fe335ecf9Glenn Kasten LOW (Process.THREAD_PRIORITY_BACKGROUND + (5 * Process.THREAD_PRIORITY_LESS_FAVORABLE)), 910260c77a4f741c3db76057cc4ea2ee54fe335ecf9Glenn Kasten NORMAL (Process.THREAD_PRIORITY_DISPLAY); 9117d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 9127d787b4722eaeb79cab42c36060336e092b77b5fJason Sams int mID; 9137d787b4722eaeb79cab42c36060336e092b77b5fJason Sams Priority(int id) { 9147d787b4722eaeb79cab42c36060336e092b77b5fJason Sams mID = id; 9157d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 9167d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 9177d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 918771bebb94054d06f97284379c93a2620613513c3Jason Sams void validate() { 919771bebb94054d06f97284379c93a2620613513c3Jason Sams if (mContext == 0) { 920c1d6210fb5cc558ccea95a59a2b33bb9015fc7deJason Sams throw new RSInvalidStateException("Calling RS with no Context active."); 921771bebb94054d06f97284379c93a2620613513c3Jason Sams } 922771bebb94054d06f97284379c93a2620613513c3Jason Sams } 923771bebb94054d06f97284379c93a2620613513c3Jason Sams 92427676fe24be7444a174c15df476e49adc5335d03Jason Sams 9259c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 92627676fe24be7444a174c15df476e49adc5335d03Jason Sams * Change the priority of the worker threads for this context. 92727676fe24be7444a174c15df476e49adc5335d03Jason Sams * 92827676fe24be7444a174c15df476e49adc5335d03Jason Sams * @param p New priority to be set. 92927676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 930bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public void setPriority(Priority p) { 9315dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 9327d787b4722eaeb79cab42c36060336e092b77b5fJason Sams nContextSetPriority(p.mID); 9337d787b4722eaeb79cab42c36060336e092b77b5fJason Sams } 9347d787b4722eaeb79cab42c36060336e092b77b5fJason Sams 935bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static class MessageThread extends Thread { 936516c31911578db8ce53529483c3ded918ac7dc6bJason Sams RenderScript mRS; 937516c31911578db8ce53529483c3ded918ac7dc6bJason Sams boolean mRun = true; 938bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int[] mAuxData = new int[2]; 9391c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 940bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_NONE = 0; 941bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_EXCEPTION = 1; 942bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_RESIZE = 2; 943bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_ERROR = 3; 944bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_MESSAGE_TO_CLIENT_USER = 4; 945516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 946bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams static final int RS_ERROR_FATAL_UNKNOWN = 0x1000; 947add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams 948516c31911578db8ce53529483c3ded918ac7dc6bJason Sams MessageThread(RenderScript rs) { 949516c31911578db8ce53529483c3ded918ac7dc6bJason Sams super("RSMessageThread"); 950516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mRS = rs; 951516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 952516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 953516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 954516c31911578db8ce53529483c3ded918ac7dc6bJason Sams public void run() { 955516c31911578db8ce53529483c3ded918ac7dc6bJason Sams // This function is a temporary solution. The final solution will 956516c31911578db8ce53529483c3ded918ac7dc6bJason Sams // used typed allocations where the message id is the type indicator. 957516c31911578db8ce53529483c3ded918ac7dc6bJason Sams int[] rbuf = new int[16]; 9582e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams mRS.nContextInitToClient(mRS.mContext); 959516c31911578db8ce53529483c3ded918ac7dc6bJason Sams while(mRun) { 9601d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams rbuf[0] = 0; 961edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams int msg = mRS.nContextPeekMessage(mRS.mContext, mAuxData); 962bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int size = mAuxData[1]; 963bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int subID = mAuxData[0]; 9641c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 9651c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if (msg == RS_MESSAGE_TO_CLIENT_USER) { 9661c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if ((size>>2) >= rbuf.length) { 9671c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams rbuf = new int[(size + 3) >> 2]; 9681c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 969edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams if (mRS.nContextGetUserMessage(mRS.mContext, rbuf) != 970edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams RS_MESSAGE_TO_CLIENT_USER) { 971edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams throw new RSDriverException("Error processing message from Renderscript."); 972edbfabdb98a2974f973d6c042e6efd547dc02fc5Jason Sams } 9731c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 9741c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if(mRS.mMessageCallback != null) { 9751c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mMessageCallback.mData = rbuf; 9761c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mMessageCallback.mID = subID; 9771c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mMessageCallback.mLength = size; 9781c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mMessageCallback.run(); 9791d45c47975ab2a8cef6db5a8976276de31e1e8d0Jason Sams } else { 9801c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams throw new RSInvalidStateException("Received a message from the script with no message handler installed."); 981516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 982ab98bb6e8b95bef7415c1ad239be71f93322fbadStephen Hines continue; 983516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 9841c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 9851c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if (msg == RS_MESSAGE_TO_CLIENT_ERROR) { 9861c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams String e = mRS.nContextGetErrorMessage(mRS.mContext); 9871c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 988add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams if (subID >= RS_ERROR_FATAL_UNKNOWN) { 989add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams throw new RSRuntimeException("Fatal error " + subID + ", details: " + e); 990add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams } 991add9d9633205f76cc34f04368b8482c2c369ba63Jason Sams 9921c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams if(mRS.mErrorCallback != null) { 9931c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mErrorCallback.mErrorMessage = e; 9941c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mErrorCallback.mErrorNum = subID; 9951c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams mRS.mErrorCallback.run(); 9961c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } else { 997a4b7bc97862e01d38b483524f1d1cf433d29e294Jason Sams android.util.Log.e(LOG_TAG, "non fatal RS error, " + e); 998be74bdd2349095f203ae0fddcc4816bfbd56bc5dStephen Hines // Do not throw here. In these cases, we do not have 999be74bdd2349095f203ae0fddcc4816bfbd56bc5dStephen Hines // a fatal error. 10001c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 10011c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams continue; 10021c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } 10031c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams 10041c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams // 2: teardown. 10051c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams // But we want to avoid starving other threads during 10061c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams // teardown by yielding until the next line in the destructor 10071c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams // can execute to set mRun = false 10081c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams try { 10091c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams sleep(1, 0); 10101c41517124a90fcfdb95dc069fc492c6fcf1ff25Jason Sams } catch(InterruptedException e) { 1011516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 1012516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 10133bc47d438171dce294e816366d53bc9eca772c5bJason Sams Log.d(LOG_TAG, "MessageThread exiting."); 1014516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 1015516c31911578db8ce53529483c3ded918ac7dc6bJason Sams } 1016516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 10176b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao RenderScript(Context ctx) { 10181a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams if (ctx != null) { 10191a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams mApplicationContext = ctx.getApplicationContext(); 10201a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams } 102160aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 102260aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich 10239c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 10246b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao * Gets the application context associated with the RenderScript context. 102527676fe24be7444a174c15df476e49adc5335d03Jason Sams * 10266b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao * @return The application context. 10276b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao */ 10286b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao public final Context getApplicationContext() { 10296b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao return mApplicationContext; 10306b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao } 10316b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao 10329c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 1033add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams * @hide 1034add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams */ 1035add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams public static RenderScript create(Context ctx, int sdkVersion) { 1036add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams return create(ctx, sdkVersion, ContextType.NORMAL); 1037add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams } 1038add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams 1039add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams /** 10406b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao * Create a basic RenderScript context. 104127676fe24be7444a174c15df476e49adc5335d03Jason Sams * 10421a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams * @hide 10436b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao * @param ctx The context. 104427676fe24be7444a174c15df476e49adc5335d03Jason Sams * @return RenderScript 104527676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 1046add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams public static RenderScript create(Context ctx, int sdkVersion, ContextType ct) { 1047e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill if (!sInitialized) { 1048e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill Log.e(LOG_TAG, "RenderScript.create() called when disabled; someone is likely to crash"); 1049e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill return null; 1050e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill } 1051e4d9a01bfc7451afff1ed399a5801c7aa2af2831Dan Morrill 10526b32fab1dbfd8bc1cc176557fe0a7b2ebd4966bdShih-wei Liao RenderScript rs = new RenderScript(ctx); 1053704ff64b099406bb328898a7443921f22dbffd6dJason Sams 1054704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mDev = rs.nDeviceCreate(); 1055add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams rs.mContext = rs.nContextCreate(rs.mDev, 0, sdkVersion, ct.mID); 10562698536b3ff60bfee85e47e4a8d4b25fdfdf4db5Jason Sams if (rs.mContext == 0) { 10572698536b3ff60bfee85e47e4a8d4b25fdfdf4db5Jason Sams throw new RSDriverException("Failed to create RS context."); 10582698536b3ff60bfee85e47e4a8d4b25fdfdf4db5Jason Sams } 1059704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mMessageThread = new MessageThread(rs); 1060704ff64b099406bb328898a7443921f22dbffd6dJason Sams rs.mMessageThread.start(); 1061704ff64b099406bb328898a7443921f22dbffd6dJason Sams return rs; 1062efd9b6fb2e0f31b50db089352118e5daeb268879Jason Sams } 1063efd9b6fb2e0f31b50db089352118e5daeb268879Jason Sams 10649c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 10651a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams * Create a basic RenderScript context. 10661a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams * 10671a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams * @param ctx The context. 10681a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams * @return RenderScript 10691a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams */ 10701a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams public static RenderScript create(Context ctx) { 1071add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams return create(ctx, ContextType.NORMAL); 1072add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams } 1073add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams 1074add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams /** 1075add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams * Create a basic RenderScript context. 1076add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams * 1077add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams * @hide 1078add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams * 1079add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams * @param ctx The context. 1080add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams * @return RenderScript 1081add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams */ 1082add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams public static RenderScript create(Context ctx, ContextType ct) { 10831a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams int v = ctx.getApplicationInfo().targetSdkVersion; 1084add26dca07cc5a5c935bc68f57bee2c1cd96a79eJason Sams return create(ctx, v, ct); 10851a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams } 10861a4e1f3efd077f3a61038aedab84dc84c9c44d19Jason Sams 10879c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 108827676fe24be7444a174c15df476e49adc5335d03Jason Sams * Print the currently available debugging information about the state of 108927676fe24be7444a174c15df476e49adc5335d03Jason Sams * the RS context to the log. 109027676fe24be7444a174c15df476e49adc5335d03Jason Sams * 109127676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 1092bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams public void contextDump() { 10935dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 1094bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams nContextDump(0); 1095715333b832fb448c32165c7d97d408a3fa43f7cbJason Sams } 1096715333b832fb448c32165c7d97d408a3fa43f7cbJason Sams 10979c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 109827676fe24be7444a174c15df476e49adc5335d03Jason Sams * Wait for any commands in the fifo between the java bindings and native to 109927676fe24be7444a174c15df476e49adc5335d03Jason Sams * be processed. 110027676fe24be7444a174c15df476e49adc5335d03Jason Sams * 110127676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 110296ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams public void finish() { 110396ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams nContextFinish(); 110496ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams } 110596ed4cfa62dd09aafb3f9da01e047661b4fe3c95Jason Sams 11069c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines /** 110727676fe24be7444a174c15df476e49adc5335d03Jason Sams * Destroy this renderscript context. Once this function is called its no 110827676fe24be7444a174c15df476e49adc5335d03Jason Sams * longer legal to use this or any objects created by this context. 110927676fe24be7444a174c15df476e49adc5335d03Jason Sams * 111027676fe24be7444a174c15df476e49adc5335d03Jason Sams */ 1111f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams public void destroy() { 11125dbfe93b3f15f3a837836d024958635fd8f9ad14Jason Sams validate(); 11132e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams nContextDeinitToClient(mContext); 1114516c31911578db8ce53529483c3ded918ac7dc6bJason Sams mMessageThread.mRun = false; 1115a8bf9429b29743b3489817feb21bde2416acc465Jason Sams try { 1116a8bf9429b29743b3489817feb21bde2416acc465Jason Sams mMessageThread.join(); 1117a8bf9429b29743b3489817feb21bde2416acc465Jason Sams } catch(InterruptedException e) { 1118a8bf9429b29743b3489817feb21bde2416acc465Jason Sams } 1119516c31911578db8ce53529483c3ded918ac7dc6bJason Sams 11202e1872fe07cf8952812a417985e6e1f61bdeab5dJason Sams nContextDestroy(); 1121f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams mContext = 0; 1122f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams 1123f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams nDeviceDestroy(mDev); 1124f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams mDev = 0; 1125f5b4596a383b6ab83f92edecfe054e80b555c2d0Jason Sams } 112602fb2cb531035779a25dbf9595e0628ea40585b0Jason Sams 1127a9e7a05b84470257637c97d65f6562aa832c66efJason Sams boolean isAlive() { 1128a9e7a05b84470257637c97d65f6562aa832c66efJason Sams return mContext != 0; 1129a9e7a05b84470257637c97d65f6562aa832c66efJason Sams } 1130a9e7a05b84470257637c97d65f6562aa832c66efJason Sams 1131bf6ef8d78fffbce6c1849a4a28fb3f4401ad039eJason Sams int safeID(BaseObj o) { 11326b9dec00afec359f091ed353f371f08ff150278aJason Sams if(o != null) { 1133e07694b24f7d12d72b084b6651356681ebd0efd6Jason Sams return o.getID(this); 1134d8e4161f114331343b897cbacea927e7e60e7b17Jason Sams } 11356b9dec00afec359f091ed353f371f08ff150278aJason Sams return 0; 113660aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich } 113760aa3eaf559b1410898c228e4f6ab7920f3953d0Jack Palevich} 1138