diff options
Diffstat (limited to 'graphics')
4 files changed, 132 insertions, 8 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(); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 60b39b0..7e53cc4 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -468,7 +468,7 @@ nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); rsAllocation2DData(con, (RsAllocation)alloc, 0, 0, - 0, RS_ALLOCATION_CUBMAP_FACE_POSITVE_X, + 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, w, h, ptr, bitmap.getSize()); bitmap.unlockPixels(); } @@ -589,6 +589,30 @@ nAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint } static void +nAllocationData2D_alloc(JNIEnv *_env, jobject _this, RsContext con, + jint dstAlloc, jint dstXoff, jint dstYoff, + jint dstMip, jint dstFace, + jint width, jint height, + jint srcAlloc, jint srcXoff, jint srcYoff, + jint srcMip, jint srcFace) +{ + LOG_API("nAllocation2DData_s, con(%p), dstAlloc(%p), dstXoff, dstYoff," + " dstMip(%i), dstFace(%i), width(%i), height(%i)," + " srcAlloc(%p), srcXoff(%i), srcYoff(%i), srcMip(%i), srcFace(%i)", + con, (RsAllocation)dstAlloc, dstXoff, dstYoff, dstMip, dstFace, + width, height, (RsAllocation)srcAlloc, srcXoff, srcYoff, srcMip, srcFace); + + rsAllocationCopy2DRange(con, + (RsAllocation)dstAlloc, + dstXoff, dstYoff, + dstMip, dstFace, + width, height, + (RsAllocation)srcAlloc, + srcXoff, srcYoff, + srcMip, srcFace); +} + +static void nAllocationRead_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jintArray data) { jint len = _env->GetArrayLength(data); @@ -1217,6 +1241,7 @@ static JNINativeMethod methods[] = { {"rsnAllocationData2D", "(IIIIIIII[SI)V", (void*)nAllocationData2D_s }, {"rsnAllocationData2D", "(IIIIIIII[BI)V", (void*)nAllocationData2D_b }, {"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f }, +{"rsnAllocationData2D", "(IIIIIIIIIIIII)V", (void*)nAllocationData2D_alloc }, {"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i }, {"rsnAllocationRead", "(II[S)V", (void*)nAllocationRead_s }, {"rsnAllocationRead", "(II[B)V", (void*)nAllocationRead_b }, |