summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2014-02-03 22:44:47 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-02-03 22:44:47 +0000
commit4e5e654e7aac2212e40915df16fe6ad8598fb4bc (patch)
treed5b905f7ee18ef1a3b8646799581060a3ec3729c /graphics
parentb0a79d35929d874628c3e0add672eff498e26b83 (diff)
parent69914882509b8ad81c23eadd1ebae53fb532042b (diff)
downloadframeworks_base-4e5e654e7aac2212e40915df16fe6ad8598fb4bc.zip
frameworks_base-4e5e654e7aac2212e40915df16fe6ad8598fb4bc.tar.gz
frameworks_base-4e5e654e7aac2212e40915df16fe6ad8598fb4bc.tar.bz2
am 69914882: am e559d7ee: Merge "Utility API for creating types."
* commit '69914882509b8ad81c23eadd1ebae53fb532042b': Utility API for creating types.
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/renderscript/Type.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java
index e023739..db4b577 100644
--- a/graphics/java/android/renderscript/Type.java
+++ b/graphics/java/android/renderscript/Type.java
@@ -216,6 +216,81 @@ public class Type extends BaseObj {
}
/**
+ * Utility function for creating basic 1D types. The type is
+ * created without mipmaps enabled.
+ *
+ * @param rs The RenderScript context
+ * @param e The Element for the Type
+ * @param dimX The X dimension, must be > 0
+ *
+ * @return Type
+ */
+ static public Type createX(RenderScript rs, Element e, int dimX) {
+ if (dimX < 1) {
+ throw new RSInvalidStateException("Dimension must be >= 1.");
+ }
+
+ int id = rs.nTypeCreate(e.getID(rs), dimX, 0, 0, false, false, 0);
+ Type t = new Type(id, rs);
+ t.mElement = e;
+ t.mDimX = dimX;
+ t.calcElementCount();
+ return t;
+ }
+
+ /**
+ * Utility function for creating basic 2D types. The type is
+ * created without mipmaps or cubemaps.
+ *
+ * @param rs The RenderScript context
+ * @param e The Element for the Type
+ * @param dimX The X dimension, must be > 0
+ * @param dimY The Y dimension, must be > 0
+ *
+ * @return Type
+ */
+ static public Type createXY(RenderScript rs, Element e, int dimX, int dimY) {
+ if ((dimX < 1) || (dimY < 1)) {
+ throw new RSInvalidStateException("Dimension must be >= 1.");
+ }
+
+ int id = rs.nTypeCreate(e.getID(rs), dimX, dimY, 0, false, false, 0);
+ Type t = new Type(id, rs);
+ t.mElement = e;
+ t.mDimX = dimX;
+ t.mDimY = dimY;
+ t.calcElementCount();
+ return t;
+ }
+
+ /**
+ * Utility function for creating basic 3D types. The type is
+ * created without mipmaps.
+ *
+ * @param rs The RenderScript context
+ * @param e The Element for the Type
+ * @param dimX The X dimension, must be > 0
+ * @param dimY The Y dimension, must be > 0
+ * @param dimZ The Z dimension, must be > 0
+ *
+ * @return Type
+ */
+ static public Type createXYZ(RenderScript rs, Element e, int dimX, int dimY, int dimZ) {
+ if ((dimX < 1) || (dimY < 1) || (dimZ < 1)) {
+ throw new RSInvalidStateException("Dimension must be >= 1.");
+ }
+
+ int id = rs.nTypeCreate(e.getID(rs), dimX, dimY, dimZ, false, false, 0);
+ Type t = new Type(id, rs);
+ t.mElement = e;
+ t.mDimX = dimX;
+ t.mDimY = dimY;
+ t.mDimZ = dimZ;
+ t.calcElementCount();
+ return t;
+ }
+
+ /**
* Builder class for Type.
*
*/