summaryrefslogtreecommitdiff
path: root/graphics/java/android/renderscript/Allocation.java
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/java/android/renderscript/Allocation.java')
-rw-r--r--graphics/java/android/renderscript/Allocation.java92
1 files changed, 89 insertions, 3 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index b460a4ddee5f..362b58637606 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -28,6 +28,7 @@ import android.graphics.SurfaceTexture;
import android.util.Log;
import android.util.TypedValue;
import android.graphics.Canvas;
+import android.os.Trace;
/**
* <p> This class provides the primary method through which data is passed to
@@ -352,6 +353,7 @@ public class Allocation extends BaseObj {
*
*/
public void syncAll(int srcLocation) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "syncAll");
switch (srcLocation) {
case USAGE_GRAPHICS_TEXTURE:
case USAGE_SCRIPT:
@@ -372,6 +374,7 @@ public class Allocation extends BaseObj {
}
mRS.validate();
mRS.nAllocationSyncAll(getIDSafe(), srcLocation);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -382,12 +385,14 @@ public class Allocation extends BaseObj {
*
*/
public void ioSend() {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "ioSend");
if ((mUsage & USAGE_IO_OUTPUT) == 0) {
throw new RSIllegalArgumentException(
"Can only send buffer if IO_OUTPUT usage specified.");
}
mRS.validate();
mRS.nAllocationIoSend(getID(mRS));
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -404,12 +409,14 @@ public class Allocation extends BaseObj {
*
*/
public void ioReceive() {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "ioReceive");
if ((mUsage & USAGE_IO_INPUT) == 0) {
throw new RSIllegalArgumentException(
"Can only receive if IO_INPUT usage specified.");
}
mRS.validate();
mRS.nAllocationIoReceive(getID(mRS));
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -418,6 +425,7 @@ public class Allocation extends BaseObj {
* @param d Source array.
*/
public void copyFrom(BaseObj[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate();
validateIsObject();
if (d.length != mCurrentCount) {
@@ -429,6 +437,7 @@ public class Allocation extends BaseObj {
i[ct] = d[ct].getID(mRS);
}
copy1DRangeFromUnchecked(0, mCurrentCount, i);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
private void validateBitmapFormat(Bitmap b) {
@@ -494,6 +503,7 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copyFromUnchecked(int[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
mRS.validate();
if (mCurrentDimZ > 0) {
copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
@@ -502,7 +512,9 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy into this Allocation from an array. This method does not guarantee
* that the Allocation is compatible with the input buffer; it copies memory
@@ -511,6 +523,7 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copyFromUnchecked(short[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
mRS.validate();
if (mCurrentDimZ > 0) {
copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
@@ -519,7 +532,9 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy into this Allocation from an array. This method does not guarantee
* that the Allocation is compatible with the input buffer; it copies memory
@@ -528,6 +543,7 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copyFromUnchecked(byte[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
mRS.validate();
if (mCurrentDimZ > 0) {
copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
@@ -536,7 +552,9 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy into this Allocation from an array. This method does not guarantee
* that the Allocation is compatible with the input buffer; it copies memory
@@ -545,6 +563,7 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copyFromUnchecked(float[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFromUnchecked");
mRS.validate();
if (mCurrentDimZ > 0) {
copy3DRangeFromUnchecked(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
@@ -553,8 +572,10 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy into this Allocation from an array. This variant is type checked
* and will generate exceptions if the Allocation's {@link
@@ -563,6 +584,7 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copyFrom(int[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate();
if (mCurrentDimZ > 0) {
copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
@@ -571,6 +593,7 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFrom(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -581,6 +604,7 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copyFrom(short[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate();
if (mCurrentDimZ > 0) {
copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
@@ -589,6 +613,7 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFrom(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -599,6 +624,7 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copyFrom(byte[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate();
if (mCurrentDimZ > 0) {
copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
@@ -607,6 +633,7 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFrom(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -617,6 +644,7 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copyFrom(float[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate();
if (mCurrentDimZ > 0) {
copy3DRangeFrom(0, 0, 0, mCurrentDimX, mCurrentDimY, mCurrentDimZ, d);
@@ -625,6 +653,7 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFrom(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -641,6 +670,7 @@ public class Allocation extends BaseObj {
* @param b the source bitmap
*/
public void copyFrom(Bitmap b) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate();
if (b.getConfig() == null) {
Bitmap newBitmap = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.ARGB_8888);
@@ -652,6 +682,7 @@ public class Allocation extends BaseObj {
validateBitmapSize(b);
validateBitmapFormat(b);
mRS.nAllocationCopyFromBitmap(getID(mRS), b);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -661,14 +692,15 @@ public class Allocation extends BaseObj {
* @param a the source allocation
*/
public void copyFrom(Allocation a) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyFrom");
mRS.validate();
if (!mType.equals(a.getType())) {
throw new RSIllegalArgumentException("Types of allocations must match.");
}
copy2DRangeFrom(0, 0, mCurrentDimX, mCurrentDimY, a, 0, 0);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
-
/**
* This is only intended to be used by auto-generated code reflected from
* the RenderScript script files and should not be used by developers.
@@ -759,10 +791,13 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, int[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
int dataSize = mType.mElement.getBytesSize() * count;
data1DChecks(off, count, d.length * 4, dataSize);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy an array into part of this Allocation. This method does not
* guarantee that the Allocation is compatible with the input buffer.
@@ -772,10 +807,13 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, short[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
int dataSize = mType.mElement.getBytesSize() * count;
data1DChecks(off, count, d.length * 2, dataSize);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy an array into part of this Allocation. This method does not
* guarantee that the Allocation is compatible with the input buffer.
@@ -785,10 +823,13 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, byte[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
int dataSize = mType.mElement.getBytesSize() * count;
data1DChecks(off, count, d.length, dataSize);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy an array into part of this Allocation. This method does not
* guarantee that the Allocation is compatible with the input buffer.
@@ -798,9 +839,11 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copy1DRangeFromUnchecked(int off, int count, float[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFromUnchecked");
int dataSize = mType.mElement.getBytesSize() * count;
data1DChecks(off, count, d.length * 4, dataSize);
mRS.nAllocationData1D(getIDSafe(), off, mSelectedLOD, count, d, dataSize);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -813,8 +856,10 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copy1DRangeFrom(int off, int count, int[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
validateIsInt32();
copy1DRangeFromUnchecked(off, count, d);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -827,8 +872,10 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copy1DRangeFrom(int off, int count, short[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
validateIsInt16();
copy1DRangeFromUnchecked(off, count, d);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -841,8 +888,10 @@ public class Allocation extends BaseObj {
* @param d the source data array
*/
public void copy1DRangeFrom(int off, int count, byte[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
validateIsInt8();
copy1DRangeFromUnchecked(off, count, d);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -855,10 +904,11 @@ public class Allocation extends BaseObj {
* @param d the source data array.
*/
public void copy1DRangeFrom(int off, int count, float[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
validateIsFloat32();
copy1DRangeFromUnchecked(off, count, d);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
-
/**
* Copy part of an Allocation into this Allocation.
*
@@ -869,6 +919,7 @@ public class Allocation extends BaseObj {
* be copied.
*/
public void copy1DRangeFrom(int off, int count, Allocation data, int dataOff) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy1DRangeFrom");
mRS.nAllocationData2D(getIDSafe(), off, 0,
mSelectedLOD, mSelectedFace.mID,
count, 1, data.getID(mRS), dataOff, 0,
@@ -893,34 +944,41 @@ public class Allocation extends BaseObj {
}
void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, byte[] data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
mRS.validate();
validate2DRange(xoff, yoff, w, h);
mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
w, h, data, data.length);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, short[] data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
mRS.validate();
validate2DRange(xoff, yoff, w, h);
mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
w, h, data, data.length * 2);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, int[] data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
mRS.validate();
validate2DRange(xoff, yoff, w, h);
mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
w, h, data, data.length * 4);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
void copy2DRangeFromUnchecked(int xoff, int yoff, int w, int h, float[] data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFromUnchecked");
mRS.validate();
validate2DRange(xoff, yoff, w, h);
mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
w, h, data, data.length * 4);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
-
/**
* Copy from an array into a rectangular region in this Allocation. The
* array is assumed to be tightly packed.
@@ -932,8 +990,10 @@ public class Allocation extends BaseObj {
* @param data to be placed into the Allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
validateIsInt8();
copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -947,8 +1007,10 @@ public class Allocation extends BaseObj {
* @param data to be placed into the Allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
validateIsInt16();
copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -962,8 +1024,10 @@ public class Allocation extends BaseObj {
* @param data to be placed into the Allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
validateIsInt32();
copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -977,8 +1041,10 @@ public class Allocation extends BaseObj {
* @param data to be placed into the Allocation
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
validateIsFloat32();
copy2DRangeFromUnchecked(xoff, yoff, w, h, data);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -995,12 +1061,14 @@ public class Allocation extends BaseObj {
*/
public void copy2DRangeFrom(int xoff, int yoff, int w, int h,
Allocation data, int dataXoff, int dataYoff) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
mRS.validate();
validate2DRange(xoff, yoff, w, h);
mRS.nAllocationData2D(getIDSafe(), xoff, yoff,
mSelectedLOD, mSelectedFace.mID,
w, h, data.getID(mRS), dataXoff, dataYoff,
data.mSelectedLOD, data.mSelectedFace.mID);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -1013,6 +1081,7 @@ public class Allocation extends BaseObj {
* @param data the Bitmap to be copied
*/
public void copy2DRangeFrom(int xoff, int yoff, Bitmap data) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copy2DRangeFrom");
mRS.validate();
if (data.getConfig() == null) {
Bitmap newBitmap = Bitmap.createBitmap(data.getWidth(), data.getHeight(), Bitmap.Config.ARGB_8888);
@@ -1024,6 +1093,7 @@ public class Allocation extends BaseObj {
validateBitmapFormat(data);
validate2DRange(xoff, yoff, data.getWidth(), data.getHeight());
mRS.nAllocationData2D(getIDSafe(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, data);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
private void validate3DRange(int xoff, int yoff, int zoff, int w, int h, int d) {
@@ -1166,10 +1236,12 @@ public class Allocation extends BaseObj {
* @param b The bitmap to be set from the Allocation.
*/
public void copyTo(Bitmap b) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
mRS.validate();
validateBitmapFormat(b);
validateBitmapSize(b);
mRS.nAllocationCopyToBitmap(getID(mRS), b);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -1180,9 +1252,11 @@ public class Allocation extends BaseObj {
* @param d The array to be set from the Allocation.
*/
public void copyTo(byte[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
validateIsInt8();
mRS.validate();
mRS.nAllocationRead(getID(mRS), d);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -1193,9 +1267,11 @@ public class Allocation extends BaseObj {
* @param d The array to be set from the Allocation.
*/
public void copyTo(short[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
validateIsInt16();
mRS.validate();
mRS.nAllocationRead(getID(mRS), d);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -1206,9 +1282,11 @@ public class Allocation extends BaseObj {
* @param d The array to be set from the Allocation.
*/
public void copyTo(int[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
validateIsInt32();
mRS.validate();
mRS.nAllocationRead(getID(mRS), d);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -1219,9 +1297,11 @@ public class Allocation extends BaseObj {
* @param d The array to be set from the Allocation.
*/
public void copyTo(float[] d) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "copyTo");
validateIsFloat32();
mRS.validate();
mRS.nAllocationRead(getID(mRS), d);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -1271,6 +1351,7 @@ public class Allocation extends BaseObj {
* utilized
*/
static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mips, int usage) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "createTyped");
rs.validate();
if (type.getID(rs) == 0) {
throw new RSInvalidStateException("Bad Type");
@@ -1279,6 +1360,7 @@ public class Allocation extends BaseObj {
if (id == 0) {
throw new RSRuntimeException("Allocation creation failed.");
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
return new Allocation(id, rs, type, usage);
}
@@ -1323,6 +1405,7 @@ public class Allocation extends BaseObj {
*/
static public Allocation createSized(RenderScript rs, Element e,
int count, int usage) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "createSized");
rs.validate();
Type.Builder b = new Type.Builder(rs, e);
b.setX(count);
@@ -1332,6 +1415,7 @@ public class Allocation extends BaseObj {
if (id == 0) {
throw new RSRuntimeException("Allocation creation failed.");
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
return new Allocation(id, rs, t, usage);
}
@@ -1391,6 +1475,7 @@ public class Allocation extends BaseObj {
static public Allocation createFromBitmap(RenderScript rs, Bitmap b,
MipmapControl mips,
int usage) {
+ Trace.traceBegin(RenderScript.TRACE_TAG, "createFromBitmap");
rs.validate();
// WAR undocumented color formats
@@ -1426,6 +1511,7 @@ public class Allocation extends BaseObj {
if (id == 0) {
throw new RSRuntimeException("Load failed.");
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
return new Allocation(id, rs, t, usage);
}