Loading graphics/java/android/renderscript/BaseObj.java +6 −8 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ class BaseObj { public int getID() { if (mDestroyed) { throw new IllegalStateException("using a destroyed object."); throw new RSInvalidStateException("using a destroyed object."); } return mID; } Loading @@ -43,13 +43,12 @@ class BaseObj { String mName; RenderScript mRS; public void setName(String s) throws IllegalStateException, IllegalArgumentException { public void setName(String s) { if(s.length() < 1) { throw new IllegalArgumentException("setName does not accept a zero length string."); throw new RSIllegalArgumentException("setName does not accept a zero length string."); } if(mName != null) { throw new IllegalArgumentException("setName object already has a name."); throw new RSIllegalArgumentException("setName object already has a name."); } try { Loading @@ -61,8 +60,7 @@ class BaseObj { } } protected void finalize() throws Throwable { protected void finalize() throws Throwable { if (!mDestroyed) { if(mID != 0 && mRS.isAlive()) { mRS.nObjDestroy(mID); Loading @@ -78,7 +76,7 @@ class BaseObj { public void destroy() { if(mDestroyed) { throw new IllegalStateException("Object already destroyed."); throw new RSInvalidStateException("Object already destroyed."); } mDestroyed = true; mRS.nObjDestroy(mID); Loading graphics/java/android/renderscript/Element.java +20 −8 Original line number Diff line number Diff line Loading @@ -93,6 +93,18 @@ public class Element extends BaseObj { } } public boolean isComplex() { if (mElements == null) { return false; } for (int ct=0; ct < mElements.length; ct++) { if (mElements[ct].mElements != null) { return true; } } return false; } public static Element BOOLEAN(RenderScript rs) { if(rs.mElement_BOOLEAN == null) { rs.mElement_BOOLEAN = createUser(rs, DataType.BOOLEAN); Loading Loading @@ -397,7 +409,7 @@ public class Element extends BaseObj { } public void destroy() throws IllegalStateException { public void destroy() { super.destroy(); } Loading @@ -412,7 +424,7 @@ public class Element extends BaseObj { public static Element createVector(RenderScript rs, DataType dt, int size) { if (size < 2 || size > 4) { throw new IllegalArgumentException("Bad size"); throw new RSIllegalArgumentException("Vector size out of rance 2-4."); } DataKind dk = DataKind.USER; boolean norm = false; Loading @@ -426,22 +438,22 @@ public class Element extends BaseObj { dk == DataKind.PIXEL_LA || dk == DataKind.PIXEL_RGB || dk == DataKind.PIXEL_RGBA)) { throw new IllegalArgumentException("Unsupported DataKind"); throw new RSIllegalArgumentException("Unsupported DataKind"); } if (!(dt == DataType.UNSIGNED_8 || dt == DataType.UNSIGNED_5_6_5 || dt == DataType.UNSIGNED_4_4_4_4 || dt == DataType.UNSIGNED_5_5_5_1)) { throw new IllegalArgumentException("Unsupported DataType"); throw new RSIllegalArgumentException("Unsupported DataType"); } if (dt == DataType.UNSIGNED_5_6_5 && dk != DataKind.PIXEL_RGB) { throw new IllegalArgumentException("Bad kind and type combo"); throw new RSIllegalArgumentException("Bad kind and type combo"); } if (dt == DataType.UNSIGNED_5_5_5_1 && dk != DataKind.PIXEL_RGBA) { throw new IllegalArgumentException("Bad kind and type combo"); throw new RSIllegalArgumentException("Bad kind and type combo"); } if (dt == DataType.UNSIGNED_4_4_4_4 && dk != DataKind.PIXEL_RGBA) { throw new IllegalArgumentException("Bad kind and type combo"); throw new RSIllegalArgumentException("Bad kind and type combo"); } int size = 1; Loading Loading @@ -477,7 +489,7 @@ public class Element extends BaseObj { public void add(Element element, String name, int arraySize) { if (arraySize < 1) { throw new IllegalArgumentException("Array size cannot be less than 1."); throw new RSIllegalArgumentException("Array size cannot be less than 1."); } if(mCount == mElements.length) { Element[] e = new Element[mCount + 8]; Loading graphics/java/android/renderscript/Program.java +19 −3 Original line number Diff line number Diff line Loading @@ -47,6 +47,13 @@ public class Program extends BaseObj { } public void bindConstants(Allocation a, int slot) { if (slot < 0 || slot >= mConstants.length) { throw new IllegalArgumentException("Slot ID out of range."); } if (a != null && a.getType().getID() != mConstants[slot].getID()) { throw new IllegalArgumentException("Allocation type does not match slot type."); } mRS.nProgramBindConstants(mID, slot, a.mID); } Loading Loading @@ -141,7 +148,10 @@ public class Program extends BaseObj { public void addInput(Element e) throws IllegalStateException { // Should check for consistant and non-conflicting names... if(mInputCount >= MAX_INPUT) { throw new IllegalArgumentException("Max input count exceeded."); throw new RSIllegalArgumentException("Max input count exceeded."); } if (e.isComplex()) { throw new RSIllegalArgumentException("Complex elements not allowed."); } mInputs[mInputCount++] = e; } Loading @@ -149,7 +159,10 @@ public class Program extends BaseObj { public void addOutput(Element e) throws IllegalStateException { // Should check for consistant and non-conflicting names... if(mOutputCount >= MAX_OUTPUT) { throw new IllegalArgumentException("Max output count exceeded."); throw new RSIllegalArgumentException("Max output count exceeded."); } if (e.isComplex()) { throw new RSIllegalArgumentException("Complex elements not allowed."); } mOutputs[mOutputCount++] = e; } Loading @@ -164,7 +177,10 @@ public class Program extends BaseObj { public int addConstant(Type t) throws IllegalStateException { // Should check for consistant and non-conflicting names... if(mConstantCount >= MAX_CONSTANT) { throw new IllegalArgumentException("Max input count exceeded."); throw new RSIllegalArgumentException("Max input count exceeded."); } if (t.getElement().isComplex()) { throw new RSIllegalArgumentException("Complex elements not allowed."); } mConstants[mConstantCount] = t; return mConstantCount++; Loading graphics/java/android/renderscript/RenderScript.java +1 −5 Original line number Diff line number Diff line Loading @@ -156,10 +156,6 @@ public class RenderScript { synchronized void nObjDestroy(int id) { rsnObjDestroy(mContext, id); } native int rsnFileOpen(int con, byte[] name); synchronized int nFileOpen(byte[] name) { return rsnFileOpen(mContext, name); } native int rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize); synchronized int nElementCreate(int type, int kind, boolean norm, int vecSize) { Loading Loading @@ -599,7 +595,7 @@ public class RenderScript { void validate() { if (mContext == 0) { throw new IllegalStateException("Calling RS with no Context active."); throw new RSInvalidStateException("Calling RS with no Context active."); } } Loading graphics/java/android/renderscript/RenderScriptGL.java +3 −30 Original line number Diff line number Diff line Loading @@ -68,10 +68,10 @@ public class RenderScriptGL extends RenderScript { private void validateRange(int umin, int upref, int rmin, int rmax) { if (umin < rmin || umin > rmax) { throw new IllegalArgumentException("Minimum value provided out of range."); throw new RSIllegalArgumentException("Minimum value provided out of range."); } if (upref < umin) { throw new IllegalArgumentException("Prefered must be >= Minimum."); throw new RSIllegalArgumentException("Prefered must be >= Minimum."); } } Loading @@ -93,7 +93,7 @@ public class RenderScriptGL extends RenderScript { public void setSamples(int minimum, int prefered, float Q) { validateRange(minimum, prefered, 0, 24); if (Q < 0.0f || Q > 1.0f) { throw new IllegalArgumentException("Quality out of 0-1 range."); throw new RSIllegalArgumentException("Quality out of 0-1 range."); } mSamplesMin = minimum; mSamplesPref = prefered; Loading Loading @@ -188,33 +188,6 @@ public class RenderScriptGL extends RenderScript { nContextBindProgramVertex(safeID(p)); } ////////////////////////////////////////////////////////////////////////////////// // File public class File extends BaseObj { File(int id) { super(id, RenderScriptGL.this); } } public File fileOpen(String s) throws IllegalStateException, IllegalArgumentException { if(s.length() < 1) { throw new IllegalArgumentException("fileOpen does not accept a zero length string."); } try { byte[] bytes = s.getBytes("UTF-8"); int id = nFileOpen(bytes); return new File(id); } catch (java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } } } Loading
graphics/java/android/renderscript/BaseObj.java +6 −8 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ class BaseObj { public int getID() { if (mDestroyed) { throw new IllegalStateException("using a destroyed object."); throw new RSInvalidStateException("using a destroyed object."); } return mID; } Loading @@ -43,13 +43,12 @@ class BaseObj { String mName; RenderScript mRS; public void setName(String s) throws IllegalStateException, IllegalArgumentException { public void setName(String s) { if(s.length() < 1) { throw new IllegalArgumentException("setName does not accept a zero length string."); throw new RSIllegalArgumentException("setName does not accept a zero length string."); } if(mName != null) { throw new IllegalArgumentException("setName object already has a name."); throw new RSIllegalArgumentException("setName object already has a name."); } try { Loading @@ -61,8 +60,7 @@ class BaseObj { } } protected void finalize() throws Throwable { protected void finalize() throws Throwable { if (!mDestroyed) { if(mID != 0 && mRS.isAlive()) { mRS.nObjDestroy(mID); Loading @@ -78,7 +76,7 @@ class BaseObj { public void destroy() { if(mDestroyed) { throw new IllegalStateException("Object already destroyed."); throw new RSInvalidStateException("Object already destroyed."); } mDestroyed = true; mRS.nObjDestroy(mID); Loading
graphics/java/android/renderscript/Element.java +20 −8 Original line number Diff line number Diff line Loading @@ -93,6 +93,18 @@ public class Element extends BaseObj { } } public boolean isComplex() { if (mElements == null) { return false; } for (int ct=0; ct < mElements.length; ct++) { if (mElements[ct].mElements != null) { return true; } } return false; } public static Element BOOLEAN(RenderScript rs) { if(rs.mElement_BOOLEAN == null) { rs.mElement_BOOLEAN = createUser(rs, DataType.BOOLEAN); Loading Loading @@ -397,7 +409,7 @@ public class Element extends BaseObj { } public void destroy() throws IllegalStateException { public void destroy() { super.destroy(); } Loading @@ -412,7 +424,7 @@ public class Element extends BaseObj { public static Element createVector(RenderScript rs, DataType dt, int size) { if (size < 2 || size > 4) { throw new IllegalArgumentException("Bad size"); throw new RSIllegalArgumentException("Vector size out of rance 2-4."); } DataKind dk = DataKind.USER; boolean norm = false; Loading @@ -426,22 +438,22 @@ public class Element extends BaseObj { dk == DataKind.PIXEL_LA || dk == DataKind.PIXEL_RGB || dk == DataKind.PIXEL_RGBA)) { throw new IllegalArgumentException("Unsupported DataKind"); throw new RSIllegalArgumentException("Unsupported DataKind"); } if (!(dt == DataType.UNSIGNED_8 || dt == DataType.UNSIGNED_5_6_5 || dt == DataType.UNSIGNED_4_4_4_4 || dt == DataType.UNSIGNED_5_5_5_1)) { throw new IllegalArgumentException("Unsupported DataType"); throw new RSIllegalArgumentException("Unsupported DataType"); } if (dt == DataType.UNSIGNED_5_6_5 && dk != DataKind.PIXEL_RGB) { throw new IllegalArgumentException("Bad kind and type combo"); throw new RSIllegalArgumentException("Bad kind and type combo"); } if (dt == DataType.UNSIGNED_5_5_5_1 && dk != DataKind.PIXEL_RGBA) { throw new IllegalArgumentException("Bad kind and type combo"); throw new RSIllegalArgumentException("Bad kind and type combo"); } if (dt == DataType.UNSIGNED_4_4_4_4 && dk != DataKind.PIXEL_RGBA) { throw new IllegalArgumentException("Bad kind and type combo"); throw new RSIllegalArgumentException("Bad kind and type combo"); } int size = 1; Loading Loading @@ -477,7 +489,7 @@ public class Element extends BaseObj { public void add(Element element, String name, int arraySize) { if (arraySize < 1) { throw new IllegalArgumentException("Array size cannot be less than 1."); throw new RSIllegalArgumentException("Array size cannot be less than 1."); } if(mCount == mElements.length) { Element[] e = new Element[mCount + 8]; Loading
graphics/java/android/renderscript/Program.java +19 −3 Original line number Diff line number Diff line Loading @@ -47,6 +47,13 @@ public class Program extends BaseObj { } public void bindConstants(Allocation a, int slot) { if (slot < 0 || slot >= mConstants.length) { throw new IllegalArgumentException("Slot ID out of range."); } if (a != null && a.getType().getID() != mConstants[slot].getID()) { throw new IllegalArgumentException("Allocation type does not match slot type."); } mRS.nProgramBindConstants(mID, slot, a.mID); } Loading Loading @@ -141,7 +148,10 @@ public class Program extends BaseObj { public void addInput(Element e) throws IllegalStateException { // Should check for consistant and non-conflicting names... if(mInputCount >= MAX_INPUT) { throw new IllegalArgumentException("Max input count exceeded."); throw new RSIllegalArgumentException("Max input count exceeded."); } if (e.isComplex()) { throw new RSIllegalArgumentException("Complex elements not allowed."); } mInputs[mInputCount++] = e; } Loading @@ -149,7 +159,10 @@ public class Program extends BaseObj { public void addOutput(Element e) throws IllegalStateException { // Should check for consistant and non-conflicting names... if(mOutputCount >= MAX_OUTPUT) { throw new IllegalArgumentException("Max output count exceeded."); throw new RSIllegalArgumentException("Max output count exceeded."); } if (e.isComplex()) { throw new RSIllegalArgumentException("Complex elements not allowed."); } mOutputs[mOutputCount++] = e; } Loading @@ -164,7 +177,10 @@ public class Program extends BaseObj { public int addConstant(Type t) throws IllegalStateException { // Should check for consistant and non-conflicting names... if(mConstantCount >= MAX_CONSTANT) { throw new IllegalArgumentException("Max input count exceeded."); throw new RSIllegalArgumentException("Max input count exceeded."); } if (t.getElement().isComplex()) { throw new RSIllegalArgumentException("Complex elements not allowed."); } mConstants[mConstantCount] = t; return mConstantCount++; Loading
graphics/java/android/renderscript/RenderScript.java +1 −5 Original line number Diff line number Diff line Loading @@ -156,10 +156,6 @@ public class RenderScript { synchronized void nObjDestroy(int id) { rsnObjDestroy(mContext, id); } native int rsnFileOpen(int con, byte[] name); synchronized int nFileOpen(byte[] name) { return rsnFileOpen(mContext, name); } native int rsnElementCreate(int con, int type, int kind, boolean norm, int vecSize); synchronized int nElementCreate(int type, int kind, boolean norm, int vecSize) { Loading Loading @@ -599,7 +595,7 @@ public class RenderScript { void validate() { if (mContext == 0) { throw new IllegalStateException("Calling RS with no Context active."); throw new RSInvalidStateException("Calling RS with no Context active."); } } Loading
graphics/java/android/renderscript/RenderScriptGL.java +3 −30 Original line number Diff line number Diff line Loading @@ -68,10 +68,10 @@ public class RenderScriptGL extends RenderScript { private void validateRange(int umin, int upref, int rmin, int rmax) { if (umin < rmin || umin > rmax) { throw new IllegalArgumentException("Minimum value provided out of range."); throw new RSIllegalArgumentException("Minimum value provided out of range."); } if (upref < umin) { throw new IllegalArgumentException("Prefered must be >= Minimum."); throw new RSIllegalArgumentException("Prefered must be >= Minimum."); } } Loading @@ -93,7 +93,7 @@ public class RenderScriptGL extends RenderScript { public void setSamples(int minimum, int prefered, float Q) { validateRange(minimum, prefered, 0, 24); if (Q < 0.0f || Q > 1.0f) { throw new IllegalArgumentException("Quality out of 0-1 range."); throw new RSIllegalArgumentException("Quality out of 0-1 range."); } mSamplesMin = minimum; mSamplesPref = prefered; Loading Loading @@ -188,33 +188,6 @@ public class RenderScriptGL extends RenderScript { nContextBindProgramVertex(safeID(p)); } ////////////////////////////////////////////////////////////////////////////////// // File public class File extends BaseObj { File(int id) { super(id, RenderScriptGL.this); } } public File fileOpen(String s) throws IllegalStateException, IllegalArgumentException { if(s.length() < 1) { throw new IllegalArgumentException("fileOpen does not accept a zero length string."); } try { byte[] bytes = s.getBytes("UTF-8"); int id = nFileOpen(bytes); return new File(id); } catch (java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } } }