summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2011-06-14 11:13:19 -0700
committerAlex Sakhartchouk <alexst@google.com>2011-06-14 11:13:19 -0700
commit304b1f5497155bcf91e7b855cfab7a675e80bf26 (patch)
tree3a73f3855d29591f9b74f4967d594ec2476262b1 /graphics/java
parentbd3e537980027f4502a13c204b3c7b9d10adad31 (diff)
downloadframeworks_base-304b1f5497155bcf91e7b855cfab7a675e80bf26.zip
frameworks_base-304b1f5497155bcf91e7b855cfab7a675e80bf26.tar.gz
frameworks_base-304b1f5497155bcf91e7b855cfab7a675e80bf26.tar.bz2
Allocation copy functions.
Change-Id: Idce6d44a4f4bb2e399284a40c0f90dc1bff912fd
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/renderscript/Allocation.java45
-rw-r--r--graphics/java/android/renderscript/AllocationAdapter.java48
-rw-r--r--graphics/java/android/renderscript/RenderScript.java20
3 files changed, 106 insertions, 7 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 3c8aba3..a63abb9 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -588,13 +588,29 @@ public class Allocation extends BaseObj {
*
* @param off The offset of the first element to be copied.
* @param count The number of elements to be copied.
- * @param d the source data array
+ * @param d the source data array.
*/
public void copy1DRangeFrom(int off, int count, float[] d) {
validateIsFloat32();
copy1DRangeFromUnchecked(off, count, d);
}
+ /**
+ * Copy part of an allocation from another allocation.
+ *
+ * @param off The offset of the first element to be copied.
+ * @param count The number of elements to be copied.
+ * @param data the source data allocation.
+ * @param dataOff off The offset of the first element in data to
+ * be copied.
+ */
+ public void copy1DRangeFrom(int off, int count, Allocation data, int dataOff) {
+ mRS.nAllocationData2D(getID(), off, 0,
+ 0, Type.CubemapFace.POSITVE_X.mID,
+ count, 1, data.getID(), dataOff, 0,
+ 0, Type.CubemapFace.POSITVE_X.mID);
+ }
+
private void validate2DRange(int xoff, int yoff, int w, int h) {
if (xoff < 0 || yoff < 0) {
throw new RSIllegalArgumentException("Offset cannot be negative.");
@@ -609,9 +625,8 @@ public class Allocation extends BaseObj {
}
/**
- * Copy a rectanglular region from the array into the
- * allocation. The incoming array is assumed to be tightly
- * packed.
+ * Copy a rectangular region from the array into the allocation.
+ * The incoming array is assumed to be tightly packed.
*
* @param xoff X offset of the region to update
* @param yoff Y offset of the region to update
@@ -644,6 +659,28 @@ public class Allocation extends BaseObj {
}
/**
+ * Copy a rectangular region into the allocation from another
+ * allocation.
+ *
+ * @param xoff X offset of the region to update.
+ * @param yoff Y offset of the region to update.
+ * @param w Width of the incoming region to update.
+ * @param h Height of the incoming region to update.
+ * @param data source allocation.
+ * @param dataXoff X offset in data of the region to update.
+ * @param dataYoff Y offset in data of the region to update.
+ */
+ public void copy2DRangeFrom(int xoff, int yoff, int w, int h,
+ Allocation data, int dataXoff, int dataYoff) {
+ mRS.validate();
+ validate2DRange(xoff, yoff, w, h);
+ mRS.nAllocationData2D(getID(), xoff, yoff,
+ 0, Type.CubemapFace.POSITVE_X.mID,
+ w, h, data.getID(), dataXoff, dataYoff,
+ 0, Type.CubemapFace.POSITVE_X.mID);
+ }
+
+ /**
* Copy a bitmap into an allocation. The height and width of
* the update will use the height and width of the incoming
* bitmap.
diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/graphics/java/android/renderscript/AllocationAdapter.java
index f2fedea..07a1f5d 100644
--- a/graphics/java/android/renderscript/AllocationAdapter.java
+++ b/graphics/java/android/renderscript/AllocationAdapter.java
@@ -33,7 +33,7 @@ public class AllocationAdapter extends Allocation {
private Allocation mAlloc;
private int mSelectedLOD = 0;
- private Type.CubemapFace mSelectedFace = Type.CubemapFace.POSITVE_X;;
+ private Type.CubemapFace mSelectedFace = Type.CubemapFace.POSITVE_X;
AllocationAdapter(int id, RenderScript rs, Allocation alloc) {
super(id, rs, null, alloc.mUsage);
@@ -163,15 +163,54 @@ public class AllocationAdapter extends Allocation {
mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize);
}
+ /**
+ * Copy part of an allocation from another allocation.
+ *
+ * @param off The offset of the first element to be copied.
+ * @param count The number of elements to be copied.
+ * @param data the source data allocation.
+ * @param dataOff off The offset of the first element in data to
+ * be copied.
+ */
+ public void subData1D(int off, int count, AllocationAdapter data, int dataOff) {
+ mRS.nAllocationData2D(getID(), off, 0,
+ mSelectedLOD, mSelectedFace.mID,
+ count, 1, data.getID(), dataOff, 0,
+ data.mSelectedLOD, data.mSelectedFace.mID);
+ }
+
public void subData2D(int xoff, int yoff, int w, int h, int[] d) {
mRS.validate();
- mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, d, d.length * 4);
+ mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, d, d.length * 4);
}
public void subData2D(int xoff, int yoff, int w, int h, float[] d) {
mRS.validate();
- mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID, w, h, d, d.length * 4);
+ mRS.nAllocationData2D(getID(), xoff, yoff, mSelectedLOD, mSelectedFace.mID,
+ w, h, d, d.length * 4);
+ }
+
+ /**
+ * Copy a rectangular region into the allocation from another
+ * allocation.
+ *
+ * @param xoff X offset of the region to update.
+ * @param yoff Y offset of the region to update.
+ * @param w Width of the incoming region to update.
+ * @param h Height of the incoming region to update.
+ * @param data source allocation.
+ * @param dataXoff X offset in data of the region to update.
+ * @param dataYoff Y offset in data of the region to update.
+ */
+ public void subData2D(int xoff, int yoff, int w, int h,
+ AllocationAdapter data, int dataXoff, int dataYoff) {
+ mRS.validate();
+ mRS.nAllocationData2D(getID(), xoff, yoff,
+ mSelectedLOD, mSelectedFace.mID,
+ w, h, data.getID(), dataXoff, dataYoff,
+ data.mSelectedLOD, data.mSelectedFace.mID);
}
public void readData(int[] d) {
@@ -185,12 +224,15 @@ public class AllocationAdapter extends Allocation {
}
public void setLOD(int lod) {
+ mSelectedLOD = lod;
}
public void setFace(Type.CubemapFace cf) {
+ mSelectedFace = cf;
}
public void setY(int y) {
+ mSelectedDimY = y;
}
public void setZ(int z) {
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 17f0fa6..2110e37 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -295,6 +295,26 @@ public class RenderScript {
rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes);
}
+ native void rsnAllocationData2D(int con,
+ int dstAlloc, int dstXoff, int dstYoff,
+ int dstMip, int dstFace,
+ int width, int height,
+ int srcAlloc, int srcXoff, int srcYoff,
+ int srcMip, int srcFace);
+ synchronized void nAllocationData2D(int dstAlloc, int dstXoff, int dstYoff,
+ int dstMip, int dstFace,
+ int width, int height,
+ int srcAlloc, int srcXoff, int srcYoff,
+ int srcMip, int srcFace) {
+ validate();
+ rsnAllocationData2D(mContext,
+ dstAlloc, dstXoff, dstYoff,
+ dstMip, dstFace,
+ width, height,
+ srcAlloc, srcXoff, srcYoff,
+ srcMip, srcFace);
+ }
+
native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes);
synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, byte[] d, int sizeBytes) {
validate();