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 773328c069bf..3d4d40a5aa20 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>
@@ -365,6 +366,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:
@@ -385,6 +387,7 @@ public class Allocation extends BaseObj {
}
mRS.validate();
mRS.nAllocationSyncAll(getIDSafe(), srcLocation);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -393,12 +396,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);
}
/**
@@ -414,12 +419,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);
}
/**
@@ -428,6 +435,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) {
@@ -439,6 +447,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) {
@@ -504,6 +513,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);
@@ -512,7 +522,9 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy an allocation from an array. This variant is not type
* checked which allows an application to fill in structured
@@ -521,6 +533,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);
@@ -529,7 +542,9 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy an allocation from an array. This variant is not type
* checked which allows an application to fill in structured
@@ -538,6 +553,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);
@@ -546,7 +562,9 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy an allocation from an array. This variant is not type
* checked which allows an application to fill in structured
@@ -555,6 +573,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);
@@ -563,8 +582,10 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFromUnchecked(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
+
/**
* Copy an allocation from an array. This variant is type
* checked and will generate exceptions if the Allocation type
@@ -573,6 +594,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);
@@ -581,6 +603,7 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFrom(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -591,6 +614,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);
@@ -599,6 +623,7 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFrom(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -609,6 +634,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);
@@ -617,6 +643,7 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFrom(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -627,6 +654,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);
@@ -635,6 +663,7 @@ public class Allocation extends BaseObj {
} else {
copy1DRangeFrom(0, mCurrentCount, d);
}
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -644,6 +673,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);
@@ -655,6 +685,7 @@ public class Allocation extends BaseObj {
validateBitmapSize(b);
validateBitmapFormat(b);
mRS.nAllocationCopyFromBitmap(getID(mRS), b);
+ Trace.traceEnd(RenderScript.TRACE_TAG);
}
/**
@@ -664,14 +695,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-generate code reflected from the
* renderscript script files.
@@ -763,10 +795,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 part of an allocation from an array. This variant is
* not type checked which allows an application to fill in
@@ -777,10 +812,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 part of an allocation from an array. This variant is
* not type checked which allows an application to fill in
@@ -791,10 +829,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 part of an allocation from an array. This variant is
* not type checked which allows an application to fill in
@@ -805,9 +846,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);
}
/**
@@ -820,8 +863,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);
}
/**
@@ -834,8 +879,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);
}
/**
@@ -848,8 +895,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);
}
/**
@@ -862,10 +911,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 from another allocation.
*
@@ -876,6 +926,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,
@@ -900,34 +951,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 a rectangular region from the array into the allocation.
* The incoming array is assumed to be tightly packed.
@@ -939,23 +997,31 @@ 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);
}
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);
}
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);
}
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);
}
/**
@@ -972,12 +1038,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);
}
/**
@@ -990,6 +1058,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);
@@ -1001,6 +1070,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) {
@@ -1142,10 +1212,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);
}
/**
@@ -1156,9 +1228,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);
}
/**
@@ -1169,9 +1243,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);
}
/**
@@ -1182,9 +1258,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);
}
/**
@@ -1195,9 +1273,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);
}
/**
@@ -1246,6 +1326,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");
@@ -1254,6 +1335,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);
}
@@ -1300,6 +1382,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);
@@ -1309,6 +1392,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);
}
@@ -1369,6 +1453,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
@@ -1404,6 +1489,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);
}