summaryrefslogtreecommitdiffstats
path: root/graphics/java/android/renderscript/Element.java
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2010-09-02 17:35:23 -0700
committerAlex Sakhartchouk <alexst@google.com>2010-09-07 12:06:05 -0700
commit70d4e5024298f71edb3b04867e05568f5495b4ce (patch)
tree031a101a16e33230c0d902f0e2c389aaf7996116 /graphics/java/android/renderscript/Element.java
parent355383e424882b590139590296562d644dd97a95 (diff)
downloadframeworks_base-70d4e5024298f71edb3b04867e05568f5495b4ce.zip
frameworks_base-70d4e5024298f71edb3b04867e05568f5495b4ce.tar.gz
frameworks_base-70d4e5024298f71edb3b04867e05568f5495b4ce.tar.bz2
Add arrays to elements.
Change-Id: I624b03bfc1fd26136afd9305a96026b91b1fad3c
Diffstat (limited to 'graphics/java/android/renderscript/Element.java')
-rw-r--r--graphics/java/android/renderscript/Element.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java
index ed09f89..05b2d60 100644
--- a/graphics/java/android/renderscript/Element.java
+++ b/graphics/java/android/renderscript/Element.java
@@ -27,6 +27,7 @@ public class Element extends BaseObj {
int mSize;
Element[] mElements;
String[] mElementNames;
+ int[] mArraySizes;
DataType mType;
DataKind mKind;
@@ -313,11 +314,12 @@ public class Element extends BaseObj {
return rs.mElement_MATRIX_2X2;
}
- Element(int id, RenderScript rs, Element[] e, String[] n) {
+ Element(int id, RenderScript rs, Element[] e, String[] n, int[] as) {
super(id, rs);
mSize = 0;
mElements = e;
mElementNames = n;
+ mArraySizes = as;
for (int ct = 0; ct < mElements.length; ct++ ) {
mSize += mElements[ct].mSize;
}
@@ -441,6 +443,7 @@ public class Element extends BaseObj {
RenderScript mRS;
Element[] mElements;
String[] mElementNames;
+ int[] mArraySizes;
int mCount;
public Builder(RenderScript rs) {
@@ -448,35 +451,49 @@ public class Element extends BaseObj {
mCount = 0;
mElements = new Element[8];
mElementNames = new String[8];
+ mArraySizes = new int[8];
}
- public void add(Element element, String name) {
+ public void add(Element element, String name, int arraySize) {
+ if (arraySize < 1) {
+ throw new IllegalArgumentException("Array size cannot be less than 1.");
+ }
if(mCount == mElements.length) {
Element[] e = new Element[mCount + 8];
String[] s = new String[mCount + 8];
+ int[] as = new int[mCount + 8];
System.arraycopy(mElements, 0, e, 0, mCount);
System.arraycopy(mElementNames, 0, s, 0, mCount);
+ System.arraycopy(mArraySizes, 0, as, 0, mCount);
mElements = e;
mElementNames = s;
+ mArraySizes = as;
}
mElements[mCount] = element;
mElementNames[mCount] = name;
+ mArraySizes[mCount] = arraySize;
mCount++;
}
+ public void add(Element element, String name) {
+ add(element, name, 1);
+ }
+
public Element create() {
mRS.validate();
Element[] ein = new Element[mCount];
String[] sin = new String[mCount];
+ int[] asin = new int[mCount];
java.lang.System.arraycopy(mElements, 0, ein, 0, mCount);
java.lang.System.arraycopy(mElementNames, 0, sin, 0, mCount);
+ java.lang.System.arraycopy(mArraySizes, 0, asin, 0, mCount);
int[] ids = new int[ein.length];
for (int ct = 0; ct < ein.length; ct++ ) {
ids[ct] = ein[ct].mID;
}
- int id = mRS.nElementCreate2(ids, sin);
- return new Element(id, mRS, ein, sin);
+ int id = mRS.nElementCreate2(ids, sin, asin);
+ return new Element(id, mRS, ein, sin, asin);
}
}