Merge "Ensure RenderScript tracing is always balanced via try/finally"

This commit is contained in:
Chris Craik
2015-06-04 17:24:12 +00:00
committed by Gerrit Code Review

View File

@@ -51,6 +51,7 @@ import android.os.Trace;
* <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p> * <a href="{@docRoot}guide/topics/renderscript/index.html">RenderScript</a> developer guide.</p>
* </div> * </div>
**/ **/
public class Allocation extends BaseObj { public class Allocation extends BaseObj {
Type mType; Type mType;
Bitmap mBitmap; Bitmap mBitmap;
@@ -455,6 +456,7 @@ public class Allocation extends BaseObj {
* *
*/ */
public void syncAll(int srcLocation) { public void syncAll(int srcLocation) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "syncAll"); Trace.traceBegin(RenderScript.TRACE_TAG, "syncAll");
switch (srcLocation) { switch (srcLocation) {
case USAGE_GRAPHICS_TEXTURE: case USAGE_GRAPHICS_TEXTURE:
@@ -476,8 +478,10 @@ public class Allocation extends BaseObj {
} }
mRS.validate(); mRS.validate();
mRS.nAllocationSyncAll(getIDSafe(), srcLocation); mRS.nAllocationSyncAll(getIDSafe(), srcLocation);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Send a buffer to the output stream. The contents of the Allocation will * Send a buffer to the output stream. The contents of the Allocation will
@@ -487,6 +491,7 @@ public class Allocation extends BaseObj {
* *
*/ */
public void ioSend() { public void ioSend() {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "ioSend"); Trace.traceBegin(RenderScript.TRACE_TAG, "ioSend");
if ((mUsage & USAGE_IO_OUTPUT) == 0) { if ((mUsage & USAGE_IO_OUTPUT) == 0) {
throw new RSIllegalArgumentException( throw new RSIllegalArgumentException(
@@ -494,8 +499,10 @@ public class Allocation extends BaseObj {
} }
mRS.validate(); mRS.validate();
mRS.nAllocationIoSend(getID(mRS)); mRS.nAllocationIoSend(getID(mRS));
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Receive the latest input into the Allocation. This operation * Receive the latest input into the Allocation. This operation
@@ -503,6 +510,7 @@ public class Allocation extends BaseObj {
* *
*/ */
public void ioReceive() { public void ioReceive() {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "ioReceive"); Trace.traceBegin(RenderScript.TRACE_TAG, "ioReceive");
if ((mUsage & USAGE_IO_INPUT) == 0) { if ((mUsage & USAGE_IO_INPUT) == 0) {
throw new RSIllegalArgumentException( throw new RSIllegalArgumentException(
@@ -510,8 +518,10 @@ public class Allocation extends BaseObj {
} }
mRS.validate(); mRS.validate();
mRS.nAllocationIoReceive(getID(mRS)); mRS.nAllocationIoReceive(getID(mRS));
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy an array of RS objects to the Allocation. * Copy an array of RS objects to the Allocation.
@@ -519,6 +529,7 @@ public class Allocation extends BaseObj {
* @param d Source array. * @param d Source array.
*/ */
public void copyFrom(BaseObj[] d) { public void copyFrom(BaseObj[] d) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate(); mRS.validate();
validateIsObject(); validateIsObject();
@@ -536,12 +547,14 @@ public class Allocation extends BaseObj {
} else { } else {
int i[] = new int[d.length]; int i[] = new int[d.length];
for (int ct=0; ct < d.length; ct++) { for (int ct=0; ct < d.length; ct++) {
i[ct] = (int)d[ct].getID(mRS); i[ct] = (int) d[ct].getID(mRS);
} }
copy1DRangeFromUnchecked(0, mCurrentCount, i); copy1DRangeFromUnchecked(0, mCurrentCount, i);
} }
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
private void validateBitmapFormat(Bitmap b) { private void validateBitmapFormat(Bitmap b) {
Bitmap.Config bc = b.getConfig(); Bitmap.Config bc = b.getConfig();
@@ -599,6 +612,7 @@ public class Allocation extends BaseObj {
} }
private void copyFromUnchecked(Object array, Element.DataType dt, int arrayLen) { private void copyFromUnchecked(Object array, Element.DataType dt, int arrayLen) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked"); Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
mRS.validate(); mRS.validate();
if (mCurrentDimZ > 0) { if (mCurrentDimZ > 0) {
@@ -608,8 +622,10 @@ public class Allocation extends BaseObj {
} else { } else {
copy1DRangeFromUnchecked(0, mCurrentCount, array, dt, arrayLen); copy1DRangeFromUnchecked(0, mCurrentCount, array, dt, arrayLen);
} }
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy into this Allocation from an array. This method does not guarantee * Copy into this Allocation from an array. This method does not guarantee
@@ -619,11 +635,14 @@ public class Allocation extends BaseObj {
* @param array The source data array * @param array The source data array
*/ */
public void copyFromUnchecked(Object array) { public void copyFromUnchecked(Object array) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked"); Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
copyFromUnchecked(array, validateObjectIsPrimitiveArray(array, false), copyFromUnchecked(array, validateObjectIsPrimitiveArray(array, false),
java.lang.reflect.Array.getLength(array)); java.lang.reflect.Array.getLength(array));
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy into this Allocation from an array. This method does not guarantee * Copy into this Allocation from an array. This method does not guarantee
@@ -679,11 +698,14 @@ public class Allocation extends BaseObj {
* @param array The source data array * @param array The source data array
*/ */
public void copyFrom(Object array) { public void copyFrom(Object array) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
copyFromUnchecked(array, validateObjectIsPrimitiveArray(array, true), copyFromUnchecked(array, validateObjectIsPrimitiveArray(array, true),
java.lang.reflect.Array.getLength(array)); java.lang.reflect.Array.getLength(array));
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy into this Allocation from an array. This variant is type checked * Copy into this Allocation from an array. This variant is type checked
@@ -747,6 +769,7 @@ public class Allocation extends BaseObj {
* @param b the source bitmap * @param b the source bitmap
*/ */
public void copyFrom(Bitmap b) { public void copyFrom(Bitmap b) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate(); mRS.validate();
if (b.getConfig() == null) { if (b.getConfig() == null) {
@@ -759,8 +782,10 @@ public class Allocation extends BaseObj {
validateBitmapSize(b); validateBitmapSize(b);
validateBitmapFormat(b); validateBitmapFormat(b);
mRS.nAllocationCopyFromBitmap(getID(mRS), b); mRS.nAllocationCopyFromBitmap(getID(mRS), b);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy an Allocation from an Allocation. The types of both allocations * Copy an Allocation from an Allocation. The types of both allocations
@@ -769,14 +794,17 @@ public class Allocation extends BaseObj {
* @param a the source allocation * @param a the source allocation
*/ */
public void copyFrom(Allocation a) { public void copyFrom(Allocation a) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom"); Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate(); mRS.validate();
if (!mType.equals(a.getType())) { if (!mType.equals(a.getType())) {
throw new RSIllegalArgumentException("Types of allocations must match."); throw new RSIllegalArgumentException("Types of allocations must match.");
} }
copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, a, 0, 0); copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, a, 0, 0);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* This is only intended to be used by auto-generated code reflected from * This is only intended to be used by auto-generated code reflected from
@@ -891,6 +919,7 @@ public class Allocation extends BaseObj {
private void copy1DRangeFromUnchecked(int off, int count, Object array, private void copy1DRangeFromUnchecked(int off, int count, Object array,
Element.DataType dt, int arrayLen) { Element.DataType dt, int arrayLen) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
final int dataSize = mType.mElement.getBytesSize() * count; final int dataSize = mType.mElement.getBytesSize() * count;
// AutoPadding for Vec3 Element // AutoPadding for Vec3 Element
@@ -901,8 +930,10 @@ public class Allocation extends BaseObj {
data1DChecks(off, count, arrayLen * dt.mSize, dataSize, usePadding); data1DChecks(off, count, arrayLen * dt.mSize, dataSize, usePadding);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt, mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt,
mType.mElement.mType.mSize, usePadding); mType.mElement.mType.mSize, usePadding);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy an array into part of this Allocation. This method does not * Copy an array into part of this Allocation. This method does not
@@ -1075,6 +1106,7 @@ public class Allocation extends BaseObj {
void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, Object array, void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, Object array,
Element.DataType dt, int arrayLen) { Element.DataType dt, int arrayLen) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
mRS.validate(); mRS.validate();
validate2DRange(xoff, yoff, w, h); validate2DRange(xoff, yoff, w, h);
@@ -1096,8 +1128,10 @@ public class Allocation extends BaseObj {
mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h,
array, sizeBytes, dt, array, sizeBytes, dt,
mType.mElement.mType.mSize, usePadding); mType.mElement.mType.mSize, usePadding);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy from an array into a rectangular region in this Allocation. The * Copy from an array into a rectangular region in this Allocation. The
@@ -1110,12 +1144,15 @@ public class Allocation extends BaseObj {
* @param array Data to be placed into the Allocation * @param array Data to be placed into the Allocation
*/ */
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, Object array) { public void copy2DRangeFrom(int xoff, int yoff, int w, int h, Object array) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
copy2DRangeFromUnchecked(xoff, yoff, w, h, array, copy2DRangeFromUnchecked(xoff, yoff, w, h, array,
validateObjectIsPrimitiveArray(array, true), validateObjectIsPrimitiveArray(array, true),
java.lang.reflect.Array.getLength(array)); java.lang.reflect.Array.getLength(array));
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy from an array into a rectangular region in this Allocation. The * Copy from an array into a rectangular region in this Allocation. The
@@ -1195,6 +1232,7 @@ public class Allocation extends BaseObj {
*/ */
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, public void copy2DRangeFrom(int xoff, int yoff, int w, int h,
Allocation data, int dataXoff, int dataYoff) { Allocation data, int dataXoff, int dataYoff) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
mRS.validate(); mRS.validate();
validate2DRange(xoff, yoff, w, h); validate2DRange(xoff, yoff, w, h);
@@ -1202,8 +1240,10 @@ public class Allocation extends BaseObj {
mSelectedLOD, mSelectedFace.mID, mSelectedLOD, mSelectedFace.mID,
w, h, data.getID(mRS), dataXoff, dataYoff, w, h, data.getID(mRS), dataXoff, dataYoff,
data.mSelectedLOD, data.mSelectedFace.mID); data.mSelectedLOD, data.mSelectedFace.mID);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy a {@link android.graphics.Bitmap} into an Allocation. The height * Copy a {@link android.graphics.Bitmap} into an Allocation. The height
@@ -1256,6 +1296,7 @@ public class Allocation extends BaseObj {
*/ */
private void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, private void copy3DRangeFromUnchecked(int xoff, int yoff, int zoff, int w, int h, int d,
Object array, Element.DataType dt, int arrayLen) { Object array, Element.DataType dt, int arrayLen) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFromUnchecked"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFromUnchecked");
mRS.validate(); mRS.validate();
validate3DRange(xoff, yoff, zoff, w, h, d); validate3DRange(xoff, yoff, zoff, w, h, d);
@@ -1277,8 +1318,10 @@ public class Allocation extends BaseObj {
mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d, mRS.nAllocationData3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d,
array, sizeBytes, dt, array, sizeBytes, dt,
mType.mElement.mType.mSize, usePadding); mType.mElement.mType.mSize, usePadding);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* @hide * @hide
@@ -1294,12 +1337,15 @@ public class Allocation extends BaseObj {
* @param array to be placed into the allocation * @param array to be placed into the allocation
*/ */
public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, Object array) { public void copy3DRangeFrom(int xoff, int yoff, int zoff, int w, int h, int d, Object array) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFrom"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeFrom");
copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, array, copy3DRangeFromUnchecked(xoff, yoff, zoff, w, h, d, array,
validateObjectIsPrimitiveArray(array, true), validateObjectIsPrimitiveArray(array, true),
java.lang.reflect.Array.getLength(array)); java.lang.reflect.Array.getLength(array));
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* @hide * @hide
@@ -1334,15 +1380,19 @@ public class Allocation extends BaseObj {
* @param b The bitmap to be set from the Allocation. * @param b The bitmap to be set from the Allocation.
*/ */
public void copyTo(Bitmap b) { public void copyTo(Bitmap b) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
mRS.validate(); mRS.validate();
validateBitmapFormat(b); validateBitmapFormat(b);
validateBitmapSize(b); validateBitmapSize(b);
mRS.nAllocationCopyToBitmap(getID(mRS), b); mRS.nAllocationCopyToBitmap(getID(mRS), b);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
private void copyTo(Object array, Element.DataType dt, int arrayLen) { private void copyTo(Object array, Element.DataType dt, int arrayLen) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo"); Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
mRS.validate(); mRS.validate();
boolean usePadding = false; boolean usePadding = false;
@@ -1361,8 +1411,10 @@ public class Allocation extends BaseObj {
} }
} }
mRS.nAllocationRead(getID(mRS), array, dt, mType.mElement.mType.mSize, usePadding); mRS.nAllocationRead(getID(mRS), array, dt, mType.mElement.mType.mSize, usePadding);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* Copy from the Allocation into an array. The array must be at * Copy from the Allocation into an array. The array must be at
@@ -1498,6 +1550,7 @@ public class Allocation extends BaseObj {
private void copy1DRangeToUnchecked(int off, int count, Object array, private void copy1DRangeToUnchecked(int off, int count, Object array,
Element.DataType dt, int arrayLen) { Element.DataType dt, int arrayLen) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeToUnchecked"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeToUnchecked");
final int dataSize = mType.mElement.getBytesSize() * count; final int dataSize = mType.mElement.getBytesSize() * count;
// AutoPadding for Vec3 Element // AutoPadding for Vec3 Element
@@ -1508,8 +1561,10 @@ public class Allocation extends BaseObj {
data1DChecks(off, count, arrayLen * dt.mSize, dataSize, usePadding); data1DChecks(off, count, arrayLen * dt.mSize, dataSize, usePadding);
mRS.nAllocationRead1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt, mRS.nAllocationRead1D(getIDSafe(), off, mSelectedLOD, count, array, dataSize, dt,
mType.mElement.mType.mSize, usePadding); mType.mElement.mType.mSize, usePadding);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* @hide * @hide
@@ -1658,6 +1713,7 @@ public class Allocation extends BaseObj {
void copy2DRangeToUnchecked(int xoff, int yoff, int w, int h, Object array, void copy2DRangeToUnchecked(int xoff, int yoff, int w, int h, Object array,
Element.DataType dt, int arrayLen) { Element.DataType dt, int arrayLen) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeToUnchecked"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeToUnchecked");
mRS.validate(); mRS.validate();
validate2DRange(xoff, yoff, w, h); validate2DRange(xoff, yoff, w, h);
@@ -1678,8 +1734,10 @@ public class Allocation extends BaseObj {
} }
mRS.nAllocationRead2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, mRS.nAllocationRead2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h,
array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* @hide * @hide
@@ -1768,6 +1826,7 @@ public class Allocation extends BaseObj {
*/ */
private void copy3DRangeToUnchecked(int xoff, int yoff, int zoff, int w, int h, int d, private void copy3DRangeToUnchecked(int xoff, int yoff, int zoff, int w, int h, int d,
Object array, Element.DataType dt, int arrayLen) { Object array, Element.DataType dt, int arrayLen) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeToUnchecked"); Trace.traceBegin(RenderScript.TRACE_TAG, "copy3DRangeToUnchecked");
mRS.validate(); mRS.validate();
validate3DRange(xoff, yoff, zoff, w, h, d); validate3DRange(xoff, yoff, zoff, w, h, d);
@@ -1788,8 +1847,10 @@ public class Allocation extends BaseObj {
} }
mRS.nAllocationRead3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d, mRS.nAllocationRead3D(getIDSafe(), xoff, yoff, zoff, mSelectedLOD, w, h, d,
array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding); array, sizeBytes, dt, mType.mElement.mType.mSize, usePadding);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG); Trace.traceEnd(RenderScript.TRACE_TAG);
} }
}
/** /**
* @hide * @hide
@@ -1827,6 +1888,7 @@ public class Allocation extends BaseObj {
* utilized * utilized
*/ */
static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips, int usage) { static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips, int usage) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "createTyped"); Trace.traceBegin(RenderScript.TRACE_TAG, "createTyped");
rs.validate(); rs.validate();
if (type.getID(rs) == 0) { if (type.getID(rs) == 0) {
@@ -1836,8 +1898,10 @@ public class Allocation extends BaseObj {
if (id == 0) { if (id == 0) {
throw new RSRuntimeException("Allocation creation failed."); throw new RSRuntimeException("Allocation creation failed.");
} }
Trace.traceEnd(RenderScript.TRACE_TAG);
return new Allocation(id, rs, type, usage); return new Allocation(id, rs, type, usage);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG);
}
} }
/** /**
@@ -1881,6 +1945,7 @@ public class Allocation extends BaseObj {
*/ */
static public Allocation createSized(RenderScript rs, Element e, static public Allocation createSized(RenderScript rs, Element e,
int count, int usage) { int count, int usage) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "createSized"); Trace.traceBegin(RenderScript.TRACE_TAG, "createSized");
rs.validate(); rs.validate();
Type.Builder b = new Type.Builder(rs, e); Type.Builder b = new Type.Builder(rs, e);
@@ -1891,8 +1956,10 @@ public class Allocation extends BaseObj {
if (id == 0) { if (id == 0) {
throw new RSRuntimeException("Allocation creation failed."); throw new RSRuntimeException("Allocation creation failed.");
} }
Trace.traceEnd(RenderScript.TRACE_TAG);
return new Allocation(id, rs, t, usage); return new Allocation(id, rs, t, usage);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG);
}
} }
/** /**
@@ -1951,6 +2018,7 @@ public class Allocation extends BaseObj {
static public Allocation createFromBitmap(RenderScript rs, Bitmap b, static public Allocation createFromBitmap(RenderScript rs, Bitmap b,
MipmapControl mips, MipmapControl mips,
int usage) { int usage) {
try {
Trace.traceBegin(RenderScript.TRACE_TAG, "createFromBitmap"); Trace.traceBegin(RenderScript.TRACE_TAG, "createFromBitmap");
rs.validate(); rs.validate();
@@ -1987,8 +2055,10 @@ public class Allocation extends BaseObj {
if (id == 0) { if (id == 0) {
throw new RSRuntimeException("Load failed."); throw new RSRuntimeException("Load failed.");
} }
Trace.traceEnd(RenderScript.TRACE_TAG);
return new Allocation(id, rs, t, usage); return new Allocation(id, rs, t, usage);
} finally {
Trace.traceEnd(RenderScript.TRACE_TAG);
}
} }
/** /**