diff options
author | Jason Sams <rjsams@android.com> | 2010-12-29 14:31:29 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-12-29 14:31:29 -0800 |
commit | 49a05d7b82956009f03acbb92a064eed054eb031 (patch) | |
tree | d0cd4c1b228dfbf08170ffe1712087df41ac38fd /graphics | |
parent | 5c68a712dacf8cf0a419f1b743474a3b4290d024 (diff) | |
download | frameworks_base-49a05d7b82956009f03acbb92a064eed054eb031.zip frameworks_base-49a05d7b82956009f03acbb92a064eed054eb031.tar.gz frameworks_base-49a05d7b82956009f03acbb92a064eed054eb031.tar.bz2 |
Move adapter2D to a derived class from Allocation.
Change-Id: I7e9d8b0028ba95956476f253da38dbe64564d0da
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 117 | ||||
-rw-r--r-- | graphics/java/android/renderscript/AllocationAdapter.java | 213 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 109 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Type.java | 14 | ||||
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 225 |
5 files changed, 299 insertions, 379 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 0dbc204..311326a 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -40,8 +40,6 @@ public class Allocation extends BaseObj { public static final int USAGE_GRAPHICS_VERTEX = 0x0004; public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008; - private static final int USAGE_ALL = 0x000F; - public enum CubemapLayout { VERTICAL_FACE_LIST (0), @@ -55,6 +53,7 @@ public class Allocation extends BaseObj { } } + public enum MipmapControl { MIPMAP_NONE(0), MIPMAP_FULL(1), @@ -68,7 +67,10 @@ public class Allocation extends BaseObj { Allocation(int id, RenderScript rs, Type t, int usage) { super(id, rs); - if (usage > USAGE_ALL) { + if ((usage & ~(USAGE_SCRIPT | + USAGE_GRAPHICS_TEXTURE | + USAGE_GRAPHICS_VERTEX | + USAGE_GRAPHICS_CONSTANTS)) != 0) { throw new RSIllegalArgumentException("Unknown usage specified."); } mType = t; @@ -160,7 +162,7 @@ public class Allocation extends BaseObj { " not divisible by element size " + eSize + "."); } data1DChecks(xoff, count, data.length, data.length); - mRS.nAllocationSubData1D(getID(), xoff, count, data, data.length); + mRS.nAllocationData1D(getID(), xoff, 0, count, data, data.length); } @@ -180,7 +182,7 @@ public class Allocation extends BaseObj { " does not match component size " + eSize + "."); } - mRS.nAllocationSubElementData1D(getID(), xoff, component_number, data, data.length); + mRS.nAllocationElementData1D(getID(), xoff, 0, component_number, data, data.length); } private void data1DChecks(int off, int count, int len, int dataSize) { @@ -203,33 +205,33 @@ public class Allocation extends BaseObj { public void subData1D(int off, int count, int[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 4, dataSize); - mRS.nAllocationSubData1D(getID(), off, count, d, dataSize); + mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void subData1D(int off, int count, short[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 2, dataSize); - mRS.nAllocationSubData1D(getID(), off, count, d, dataSize); + mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void subData1D(int off, int count, byte[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length, dataSize); - mRS.nAllocationSubData1D(getID(), off, count, d, dataSize); + mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void subData1D(int off, int count, float[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 4, dataSize); - mRS.nAllocationSubData1D(getID(), off, count, d, dataSize); + mRS.nAllocationData1D(getID(), off, 0, count, d, dataSize); } public void subData2D(int xoff, int yoff, int w, int h, int[] d) { mRS.validate(); - mRS.nAllocationSubData2D(getID(), xoff, yoff, w, h, d, d.length * 4); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 4); } public void subData2D(int xoff, int yoff, int w, int h, float[] d) { mRS.validate(); - mRS.nAllocationSubData2D(getID(), xoff, yoff, w, h, d, d.length * 4); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 4); } public void readData(int[] d) { @@ -266,98 +268,11 @@ public class Allocation extends BaseObj { } */ - /* - public class Adapter1D extends BaseObj { - Adapter1D(int id, RenderScript rs) { - super(id, rs); - } - - public void setConstraint(Dimension dim, int value) { - mRS.validate(); - mRS.nAdapter1DSetConstraint(getID(), dim.mID, value); - } - - public void data(int[] d) { - mRS.validate(); - mRS.nAdapter1DData(getID(), d); - } - - public void data(float[] d) { - mRS.validate(); - mRS.nAdapter1DData(getID(), d); - } - - public void subData(int off, int count, int[] d) { - mRS.validate(); - mRS.nAdapter1DSubData(getID(), off, count, d); - } - - public void subData(int off, int count, float[] d) { - mRS.validate(); - mRS.nAdapter1DSubData(getID(), off, count, d); - } - } - - public Adapter1D createAdapter1D() { - mRS.validate(); - int id = mRS.nAdapter1DCreate(); - if(id == 0) { - throw new RSRuntimeException("Adapter creation failed."); - } - mRS.nAdapter1DBindAllocation(id, getID()); - return new Adapter1D(id, mRS); - } - */ - - - public class Adapter2D extends BaseObj { - Adapter2D(int id, RenderScript rs) { - super(id, rs); - } - - public void setConstraint(Dimension dim, int value) { - mRS.validate(); - mRS.nAdapter2DSetConstraint(getID(), dim.mID, value); - } - - public void data(int[] d) { - mRS.validate(); - mRS.nAdapter2DData(getID(), d); - } - - public void data(float[] d) { - mRS.validate(); - mRS.nAdapter2DData(getID(), d); - } - - public void subData(int xoff, int yoff, int w, int h, int[] d) { - mRS.validate(); - mRS.nAdapter2DSubData(getID(), xoff, yoff, w, h, d); - } - - public void subData(int xoff, int yoff, int w, int h, float[] d) { - mRS.validate(); - mRS.nAdapter2DSubData(getID(), xoff, yoff, w, h, d); - } - } - - public Adapter2D createAdapter2D() { - mRS.validate(); - int id = mRS.nAdapter2DCreate(); - if(id == 0) { - throw new RSRuntimeException("allocation failed."); - } - mRS.nAdapter2DBindAllocation(id, getID()); - if(id == 0) { - throw new RSRuntimeException("Adapter creation failed."); - } - return new Adapter2D(id, mRS); - } // creation - private static BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options(); + static BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options(); static { mBitmapOptions.inScaled = false; } @@ -400,7 +315,7 @@ public class Allocation extends BaseObj { return createSized(rs, e, count, USAGE_SCRIPT); } - static private Element elementFromBitmap(RenderScript rs, Bitmap b) { + static Element elementFromBitmap(RenderScript rs, Bitmap b) { final Bitmap.Config bc = b.getConfig(); if (bc == Bitmap.Config.ALPHA_8) { return Element.A_8(rs); @@ -417,7 +332,7 @@ public class Allocation extends BaseObj { throw new RSInvalidStateException("Bad bitmap type: " + bc); } - static private Type typeFromBitmap(RenderScript rs, Bitmap b, + static Type typeFromBitmap(RenderScript rs, Bitmap b, MipmapControl mip) { Element e = elementFromBitmap(rs, b); Type.Builder tb = new Type.Builder(rs, e); diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/graphics/java/android/renderscript/AllocationAdapter.java new file mode 100644 index 0000000..e682e93 --- /dev/null +++ b/graphics/java/android/renderscript/AllocationAdapter.java @@ -0,0 +1,213 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.renderscript; + +import android.content.res.Resources; +import android.content.res.AssetManager; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.util.Log; +import android.util.TypedValue; + +/** + * @hide + * + **/ +public class AllocationAdapter extends Allocation { + private int mSelectedDimX; + private int mSelectedDimY; + private int mSelectedCount; + private Allocation mAlloc; + + private int mSelectedLOD = 0; + private Type.CubemapFace mSelectedFace = Type.CubemapFace.POSITVE_X;; + + AllocationAdapter(int id, RenderScript rs, Allocation alloc) { + super(id, rs, null, alloc.mUsage); + Type t = alloc.getType(); + mSelectedDimX = t.getX(); + mSelectedDimY = t.getY(); + mSelectedCount = t.getCount(); + } + + + public void copyFrom(BaseObj[] d) { + mRS.validate(); + if (d.length != mSelectedCount) { + throw new RSIllegalArgumentException("Array size mismatch, allocation size = " + + mSelectedCount + ", array length = " + d.length); + } + int i[] = new int[d.length]; + for (int ct=0; ct < d.length; ct++) { + i[ct] = d[ct].getID(); + } + subData1D(0, mType.getCount(), i); + } + + void validateBitmap(Bitmap b) { + mRS.validate(); + if(mSelectedDimX != b.getWidth() || + mSelectedDimY != b.getHeight()) { + throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch"); + } + } + + public void copyFrom(int[] d) { + mRS.validate(); + subData1D(0, mSelectedCount, d); + } + public void copyFrom(short[] d) { + mRS.validate(); + subData1D(0, mSelectedCount, d); + } + public void copyFrom(byte[] d) { + mRS.validate(); + subData1D(0, mSelectedCount, d); + } + public void copyFrom(float[] d) { + mRS.validate(); + subData1D(0, mSelectedCount, d); + } + public void copyFrom(Bitmap b) { + validateBitmap(b); + mRS.nAllocationCopyFromBitmap(getID(), b); + } + + public void copyTo(Bitmap b) { + validateBitmap(b); + mRS.nAllocationCopyToBitmap(getID(), b); + } + + + public void subData(int xoff, FieldPacker fp) { + int eSize = mType.mElement.getSizeBytes(); + final byte[] data = fp.getData(); + + int count = data.length / eSize; + if ((eSize * count) != data.length) { + throw new RSIllegalArgumentException("Field packer length " + data.length + + " not divisible by element size " + eSize + "."); + } + data1DChecks(xoff, count, data.length, data.length); + mRS.nAllocationData1D(getID(), xoff, mSelectedLOD, count, data, data.length); + } + + + public void subElementData(int xoff, int component_number, FieldPacker fp) { + if (component_number >= mType.mElement.mElements.length) { + throw new RSIllegalArgumentException("Component_number " + component_number + " out of range."); + } + if(xoff < 0) { + throw new RSIllegalArgumentException("Offset must be >= 0."); + } + + final byte[] data = fp.getData(); + int eSize = mType.mElement.mElements[component_number].getSizeBytes(); + + if (data.length != eSize) { + throw new RSIllegalArgumentException("Field packer sizelength " + data.length + + " does not match component size " + eSize + "."); + } + + mRS.nAllocationElementData1D(getID(), xoff, mSelectedLOD, component_number, data, data.length); + } + + void data1DChecks(int off, int count, int len, int dataSize) { + mRS.validate(); + if(off < 0) { + throw new RSIllegalArgumentException("Offset must be >= 0."); + } + if(count < 1) { + throw new RSIllegalArgumentException("Count must be >= 1."); + } + if((off + count) > mSelectedDimX * mSelectedDimY) { + throw new RSIllegalArgumentException("Overflow, Available count " + mType.getCount() + + ", got " + count + " at offset " + off + "."); + } + if((len) < dataSize) { + throw new RSIllegalArgumentException("Array too small for allocation type."); + } + } + + public void subData1D(int off, int count, int[] d) { + int dataSize = mAlloc.mType.mElement.getSizeBytes() * count; + data1DChecks(off, count, d.length * 4, dataSize); + mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize); + } + public void subData1D(int off, int count, short[] d) { + int dataSize = mAlloc.mType.mElement.getSizeBytes() * count; + data1DChecks(off, count, d.length * 2, dataSize); + mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize); + } + public void subData1D(int off, int count, byte[] d) { + int dataSize = mAlloc.mType.mElement.getSizeBytes() * count; + data1DChecks(off, count, d.length, dataSize); + mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize); + } + public void subData1D(int off, int count, float[] d) { + int dataSize = mAlloc.mType.mElement.getSizeBytes() * count; + data1DChecks(off, count, d.length * 4, dataSize); + mRS.nAllocationData1D(getID(), off, mSelectedLOD, count, d, dataSize); + } + + + 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); + } + + 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); + } + + public void readData(int[] d) { + mRS.validate(); + mRS.nAllocationRead(getID(), d); + } + + public void readData(float[] d) { + mRS.validate(); + mRS.nAllocationRead(getID(), d); + } + + public void setLOD(int lod) { + } + + public void setFace(Type.CubemapFace cf) { + } + + public void setY(int y) { + } + + public void setZ(int z) { + } + + // creation + //static public AllocationAdapter create1D(RenderScript rs, Allocation a) { + //} + + static public AllocationAdapter create2D(RenderScript rs, Allocation a) { + rs.validate(); + AllocationAdapter aa = new AllocationAdapter(0, rs, a); + return aa; + } + + +} + + diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 2d16e32..f11b1ab 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -228,44 +228,38 @@ public class RenderScript { rsnAllocationCopyFromBitmap(mContext, alloc, bmp); } - native void rsnAllocationUploadToTexture(int con, int alloc, boolean genMips, int baseMioLevel); - synchronized void nAllocationUploadToTexture(int alloc, boolean genMips, int baseMioLevel) { - rsnAllocationUploadToTexture(mContext, alloc, genMips, baseMioLevel); - } - native void rsnAllocationUploadToBufferObject(int con, int alloc); - synchronized void nAllocationUploadToBufferObject(int alloc) { - rsnAllocationUploadToBufferObject(mContext, alloc); - } - native void rsnAllocationSubData1D(int con, int id, int off, int count, int[] d, int sizeBytes); - synchronized void nAllocationSubData1D(int id, int off, int count, int[] d, int sizeBytes) { - rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); + native void rsnAllocationData1D(int con, int id, int off, int mip, int count, int[] d, int sizeBytes); + synchronized void nAllocationData1D(int id, int off, int mip, int count, int[] d, int sizeBytes) { + rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); } - native void rsnAllocationSubData1D(int con, int id, int off, int count, short[] d, int sizeBytes); - synchronized void nAllocationSubData1D(int id, int off, int count, short[] d, int sizeBytes) { - rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); + native void rsnAllocationData1D(int con, int id, int off, int mip, int count, short[] d, int sizeBytes); + synchronized void nAllocationData1D(int id, int off, int mip, int count, short[] d, int sizeBytes) { + rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); } - native void rsnAllocationSubData1D(int con, int id, int off, int count, byte[] d, int sizeBytes); - synchronized void nAllocationSubData1D(int id, int off, int count, byte[] d, int sizeBytes) { - rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); + native void rsnAllocationData1D(int con, int id, int off, int mip, int count, byte[] d, int sizeBytes); + synchronized void nAllocationData1D(int id, int off, int mip, int count, byte[] d, int sizeBytes) { + rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); } - native void rsnAllocationSubElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); - synchronized void nAllocationSubElementData1D(int id, int xoff, int compIdx, byte[] d, int sizeBytes) { - rsnAllocationSubElementData1D(mContext, id, xoff, compIdx, d, sizeBytes); + native void rsnAllocationData1D(int con, int id, int off, int mip, int count, float[] d, int sizeBytes); + synchronized void nAllocationData1D(int id, int off, int mip, int count, float[] d, int sizeBytes) { + rsnAllocationData1D(mContext, id, off, mip, count, d, sizeBytes); } - native void rsnAllocationSubData1D(int con, int id, int off, int count, float[] d, int sizeBytes); - synchronized void nAllocationSubData1D(int id, int off, int count, float[] d, int sizeBytes) { - rsnAllocationSubData1D(mContext, id, off, count, d, sizeBytes); + + native void rsnAllocationElementData1D(int con, int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes); + synchronized void nAllocationElementData1D(int id, int xoff, int mip, int compIdx, byte[] d, int sizeBytes) { + rsnAllocationElementData1D(mContext, id, xoff, mip, compIdx, d, sizeBytes); } - native void rsnAllocationSubData2D(int con, int id, int xoff, int yoff, int w, int h, int[] d, int sizeBytes); - synchronized void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, int[] d, int sizeBytes) { - rsnAllocationSubData2D(mContext, id, xoff, yoff, w, h, d, sizeBytes); + native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes); + synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, int[] d, int sizeBytes) { + rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); } - native void rsnAllocationSubData2D(int con, int id, int xoff, int yoff, int w, int h, float[] d, int sizeBytes); - synchronized void nAllocationSubData2D(int id, int xoff, int yoff, int w, int h, float[] d, int sizeBytes) { - rsnAllocationSubData2D(mContext, id, xoff, yoff, w, h, d, sizeBytes); + native void rsnAllocationData2D(int con, int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes); + synchronized void nAllocationData2D(int id, int xoff, int yoff, int mip, int face, int w, int h, float[] d, int sizeBytes) { + rsnAllocationData2D(mContext, id, xoff, yoff, mip, face, w, h, d, sizeBytes); } + native void rsnAllocationRead(int con, int id, int[] d); synchronized void nAllocationRead(int id, int[] d) { rsnAllocationRead(mContext, id, d); @@ -310,63 +304,6 @@ public class RenderScript { return rsnFontCreateFromFile(mContext, fileName, size, dpi); } - native void rsnAdapter1DBindAllocation(int con, int ad, int alloc); - synchronized void nAdapter1DBindAllocation(int ad, int alloc) { - rsnAdapter1DBindAllocation(mContext, ad, alloc); - } - native void rsnAdapter1DSetConstraint(int con, int ad, int dim, int value); - synchronized void nAdapter1DSetConstraint(int ad, int dim, int value) { - rsnAdapter1DSetConstraint(mContext, ad, dim, value); - } - native void rsnAdapter1DData(int con, int ad, int[] d); - synchronized void nAdapter1DData(int ad, int[] d) { - rsnAdapter1DData(mContext, ad, d); - } - native void rsnAdapter1DData(int con, int ad, float[] d); - synchronized void nAdapter1DData(int ad, float[] d) { - rsnAdapter1DData(mContext, ad, d); - } - native void rsnAdapter1DSubData(int con, int ad, int off, int count, int[] d); - synchronized void nAdapter1DSubData(int ad, int off, int count, int[] d) { - rsnAdapter1DSubData(mContext, ad, off, count, d); - } - native void rsnAdapter1DSubData(int con, int ad, int off, int count, float[] d); - synchronized void nAdapter1DSubData(int ad, int off, int count, float[] d) { - rsnAdapter1DSubData(mContext, ad, off, count, d); - } - native int rsnAdapter1DCreate(int con); - synchronized int nAdapter1DCreate() { - return rsnAdapter1DCreate(mContext); - } - - native void rsnAdapter2DBindAllocation(int con, int ad, int alloc); - synchronized void nAdapter2DBindAllocation(int ad, int alloc) { - rsnAdapter2DBindAllocation(mContext, ad, alloc); - } - native void rsnAdapter2DSetConstraint(int con, int ad, int dim, int value); - synchronized void nAdapter2DSetConstraint(int ad, int dim, int value) { - rsnAdapter2DSetConstraint(mContext, ad, dim, value); - } - native void rsnAdapter2DData(int con, int ad, int[] d); - synchronized void nAdapter2DData(int ad, int[] d) { - rsnAdapter2DData(mContext, ad, d); - } - native void rsnAdapter2DData(int con, int ad, float[] d); - synchronized void nAdapter2DData(int ad, float[] d) { - rsnAdapter2DData(mContext, ad, d); - } - native void rsnAdapter2DSubData(int con, int ad, int xoff, int yoff, int w, int h, int[] d); - synchronized void nAdapter2DSubData(int ad, int xoff, int yoff, int w, int h, int[] d) { - rsnAdapter2DSubData(mContext, ad, xoff, yoff, w, h, d); - } - native void rsnAdapter2DSubData(int con, int ad, int xoff, int yoff, int w, int h, float[] d); - synchronized void nAdapter2DSubData(int ad, int xoff, int yoff, int w, int h, float[] d) { - rsnAdapter2DSubData(mContext, ad, xoff, yoff, w, h, d); - } - native int rsnAdapter2DCreate(int con); - synchronized int nAdapter2DCreate() { - return rsnAdapter2DCreate(mContext); - } native void rsnScriptBindAllocation(int con, int script, int alloc, int slot); synchronized void nScriptBindAllocation(int script, int alloc, int slot) { diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java index 859369c..d98842a 100644 --- a/graphics/java/android/renderscript/Type.java +++ b/graphics/java/android/renderscript/Type.java @@ -47,6 +47,20 @@ public class Type extends BaseObj { int mElementCount; Element mElement; + public enum CubemapFace { + POSITVE_X (0), + NEGATIVE_X (1), + POSITVE_Y (2), + NEGATIVE_Y (3), + POSITVE_Z (4), + NEGATIVE_Z (5); + + int mID; + CubemapFace(int id) { + mID = id; + } + } + /** * Return the element associated with this Type. * diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 9da4428..fe22269 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -382,20 +382,6 @@ nAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint type, ji } static void -nAllocationUploadToTexture(JNIEnv *_env, jobject _this, RsContext con, jint a, jboolean genMip, jint mip) -{ - LOG_API("nAllocationUploadToTexture, con(%p), a(%p), genMip(%i), mip(%i)", con, (RsAllocation)a, genMip, mip); - rsAllocationUploadToTexture(con, (RsAllocation)a, genMip, mip); -} - -static void -nAllocationUploadToBufferObject(JNIEnv *_env, jobject _this, RsContext con, jint a) -{ - LOG_API("nAllocationUploadToBufferObject, con(%p), a(%p)", con, (RsAllocation)a); - rsAllocationUploadToBufferObject(con, (RsAllocation)a); -} - -static void nAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits) { LOG_API("nAllocationSyncAll, con(%p), a(%p), bits(0x%08x)", con, (RsAllocation)a, bits); @@ -464,73 +450,75 @@ static void ReleaseBitmapCallback(void *bmp) static void -nAllocationSubData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint count, jintArray data, int sizeBytes) +nAllocationData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jintArray data, int sizeBytes) { jint len = _env->GetArrayLength(data); - LOG_API("nAllocation1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); + LOG_API("nAllocation1DData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); jint *ptr = _env->GetIntArrayElements(data, NULL); - rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes); + rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); } static void -nAllocationSubData1D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint count, jshortArray data, int sizeBytes) +nAllocationData1D_s(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jshortArray data, int sizeBytes) { jint len = _env->GetArrayLength(data); - LOG_API("nAllocation1DSubData_s, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); + LOG_API("nAllocation1DData_s, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); jshort *ptr = _env->GetShortArrayElements(data, NULL); - rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes); + rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); _env->ReleaseShortArrayElements(data, ptr, JNI_ABORT); } static void -nAllocationSubData1D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint count, jbyteArray data, int sizeBytes) +nAllocationData1D_b(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jbyteArray data, int sizeBytes) { jint len = _env->GetArrayLength(data); - LOG_API("nAllocation1DSubData_b, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); + LOG_API("nAllocation1DData_b, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); jbyte *ptr = _env->GetByteArrayElements(data, NULL); - rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes); + rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); } static void -nAllocationSubData1D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint count, jfloatArray data, int sizeBytes) +nAllocationData1D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint count, jfloatArray data, int sizeBytes) { jint len = _env->GetArrayLength(data); - LOG_API("nAllocation1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); + LOG_API("nAllocation1DData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, count, len, sizeBytes); jfloat *ptr = _env->GetFloatArrayElements(data, NULL); - rsAllocation1DSubData(con, (RsAllocation)alloc, offset, count, ptr, sizeBytes); + rsAllocation1DData(con, (RsAllocation)alloc, offset, lod, count, ptr, sizeBytes); _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); } static void -// native void rsnAllocationSubElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); -nAllocationSubElementData1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint compIdx, jbyteArray data, int sizeBytes) +// native void rsnAllocationElementData1D(int con, int id, int xoff, int compIdx, byte[] d, int sizeBytes); +nAllocationElementData1D(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint lod, jint compIdx, jbyteArray data, int sizeBytes) { jint len = _env->GetArrayLength(data); - LOG_API("nAllocationSubElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes); + LOG_API("nAllocationElementData1D, con(%p), alloc(%p), offset(%i), comp(%i), len(%i), sizeBytes(%i)", con, (RsAllocation)alloc, offset, compIdx, len, sizeBytes); jbyte *ptr = _env->GetByteArrayElements(data, NULL); - rsAllocation1DSubElementData(con, (RsAllocation)alloc, offset, ptr, compIdx, sizeBytes); + rsAllocation1DElementData(con, (RsAllocation)alloc, offset, lod, ptr, compIdx, sizeBytes); _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT); } static void -nAllocationSubData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint w, jint h, jintArray data, int sizeBytes) +nAllocationData2D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, + jint w, jint h, jintArray data, int sizeBytes) { jint len = _env->GetArrayLength(data); - LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len); + LOG_API("nAllocation2DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len); jint *ptr = _env->GetIntArrayElements(data, NULL); - rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr, sizeBytes); + rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes); _env->ReleaseIntArrayElements(data, ptr, JNI_ABORT); } static void -nAllocationSubData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint w, jint h, jfloatArray data, int sizeBytes) +nAllocationData2D_f(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint xoff, jint yoff, jint lod, jint face, + jint w, jint h, jfloatArray data, int sizeBytes) { jint len = _env->GetArrayLength(data); - LOG_API("nAllocation2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len); + LOG_API("nAllocation2DData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", con, (RsAllocation)alloc, xoff, yoff, w, h, len); jfloat *ptr = _env->GetFloatArrayElements(data, NULL); - rsAllocation2DSubData(con, (RsAllocation)alloc, xoff, yoff, w, h, ptr, sizeBytes); + rsAllocation2DData(con, (RsAllocation)alloc, xoff, yoff, lod, (RsAllocationCubemapFace)face, w, h, ptr, sizeBytes); _env->ReleaseFloatArrayElements(data, ptr, JNI_ABORT); } @@ -631,135 +619,6 @@ nFontCreateFromFile(JNIEnv *_env, jobject _this, RsContext con, jstring fileName return id; } - -// ----------------------------------- - -static void -nAdapter1DBindAllocation(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jint alloc) -{ - LOG_API("nAdapter1DBindAllocation, con(%p), adapter(%p), alloc(%p)", con, (RsAdapter1D)adapter, (RsAllocation)alloc); - rsAdapter1DBindAllocation(con, (RsAdapter1D)adapter, (RsAllocation)alloc); -} - -static void -nAdapter1DSetConstraint(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jint dim, jint value) -{ - LOG_API("nAdapter1DSetConstraint, con(%p), adapter(%p), dim(%i), value(%i)", con, (RsAdapter1D)adapter, dim, value); - rsAdapter1DSetConstraint(con, (RsAdapter1D)adapter, (RsDimension)dim, value); -} - -static void -nAdapter1DData_i(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jintArray data) -{ - jint len = _env->GetArrayLength(data); - LOG_API("nAdapter1DData_i, con(%p), adapter(%p), len(%i)", con, (RsAdapter1D)adapter, len); - jint *ptr = _env->GetIntArrayElements(data, NULL); - rsAdapter1DData(con, (RsAdapter1D)adapter, ptr); - _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); -} - -static void -nAdapter1DSubData_i(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jint offset, jint count, jintArray data) -{ - jint len = _env->GetArrayLength(data); - LOG_API("nAdapter1DSubData_i, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAdapter1D)adapter, offset, count, len); - jint *ptr = _env->GetIntArrayElements(data, NULL); - rsAdapter1DSubData(con, (RsAdapter1D)adapter, offset, count, ptr); - _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); -} - -static void -nAdapter1DData_f(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jfloatArray data) -{ - jint len = _env->GetArrayLength(data); - LOG_API("nAdapter1DData_f, con(%p), adapter(%p), len(%i)", con, (RsAdapter1D)adapter, len); - jfloat *ptr = _env->GetFloatArrayElements(data, NULL); - rsAdapter1DData(con, (RsAdapter1D)adapter, ptr); - _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); -} - -static void -nAdapter1DSubData_f(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jint offset, jint count, jfloatArray data) -{ - jint len = _env->GetArrayLength(data); - LOG_API("nAdapter1DSubData_f, con(%p), adapter(%p), offset(%i), count(%i), len(%i)", con, (RsAdapter1D)adapter, offset, count, len); - jfloat *ptr = _env->GetFloatArrayElements(data, NULL); - rsAdapter1DSubData(con, (RsAdapter1D)adapter, offset, count, ptr); - _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); -} - -static jint -nAdapter1DCreate(JNIEnv *_env, jobject _this, RsContext con) -{ - LOG_API("nAdapter1DCreate, con(%p)", con); - return (jint)rsAdapter1DCreate(con); -} - -// ----------------------------------- - -static void -nAdapter2DBindAllocation(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jint alloc) -{ - LOG_API("nAdapter2DBindAllocation, con(%p), adapter(%p), alloc(%p)", con, (RsAdapter2D)adapter, (RsAllocation)alloc); - rsAdapter2DBindAllocation(con, (RsAdapter2D)adapter, (RsAllocation)alloc); -} - -static void -nAdapter2DSetConstraint(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jint dim, jint value) -{ - LOG_API("nAdapter2DSetConstraint, con(%p), adapter(%p), dim(%i), value(%i)", con, (RsAdapter2D)adapter, dim, value); - rsAdapter2DSetConstraint(con, (RsAdapter2D)adapter, (RsDimension)dim, value); -} - -static void -nAdapter2DData_i(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jintArray data) -{ - jint len = _env->GetArrayLength(data); - LOG_API("nAdapter2DData_i, con(%p), adapter(%p), len(%i)", con, (RsAdapter2D)adapter, len); - jint *ptr = _env->GetIntArrayElements(data, NULL); - rsAdapter2DData(con, (RsAdapter2D)adapter, ptr); - _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); -} - -static void -nAdapter2DData_f(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jfloatArray data) -{ - jint len = _env->GetArrayLength(data); - LOG_API("nAdapter2DData_f, con(%p), adapter(%p), len(%i)", con, (RsAdapter2D)adapter, len); - jfloat *ptr = _env->GetFloatArrayElements(data, NULL); - rsAdapter2DData(con, (RsAdapter2D)adapter, ptr); - _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); -} - -static void -nAdapter2DSubData_i(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jint xoff, jint yoff, jint w, jint h, jintArray data) -{ - jint len = _env->GetArrayLength(data); - LOG_API("nAdapter2DSubData_i, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", - con, (RsAdapter2D)adapter, xoff, yoff, w, h, len); - jint *ptr = _env->GetIntArrayElements(data, NULL); - rsAdapter2DSubData(con, (RsAdapter2D)adapter, xoff, yoff, w, h, ptr); - _env->ReleaseIntArrayElements(data, ptr, 0/*JNI_ABORT*/); -} - -static void -nAdapter2DSubData_f(JNIEnv *_env, jobject _this, RsContext con, jint adapter, jint xoff, jint yoff, jint w, jint h, jfloatArray data) -{ - jint len = _env->GetArrayLength(data); - LOG_API("nAdapter2DSubData_f, con(%p), adapter(%p), xoff(%i), yoff(%i), w(%i), h(%i), len(%i)", - con, (RsAdapter2D)adapter, xoff, yoff, w, h, len); - jfloat *ptr = _env->GetFloatArrayElements(data, NULL); - rsAdapter2DSubData(con, (RsAdapter1D)adapter, xoff, yoff, w, h, ptr); - _env->ReleaseFloatArrayElements(data, ptr, 0/*JNI_ABORT*/); -} - -static jint -nAdapter2DCreate(JNIEnv *_env, jobject _this, RsContext con) -{ - LOG_API("nAdapter2DCreate, con(%p)", con); - return (jint)rsAdapter2DCreate(con); -} - // ----------------------------------- static void @@ -1258,38 +1117,20 @@ static JNINativeMethod methods[] = { {"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, {"rsnAllocationCopyToBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap }, -{"rsnAllocationUploadToTexture", "(IIZI)V", (void*)nAllocationUploadToTexture }, -{"rsnAllocationUploadToBufferObject","(II)V", (void*)nAllocationUploadToBufferObject }, {"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, -{"rsnAllocationSubData1D", "(IIII[II)V", (void*)nAllocationSubData1D_i }, -{"rsnAllocationSubData1D", "(IIII[SI)V", (void*)nAllocationSubData1D_s }, -{"rsnAllocationSubData1D", "(IIII[BI)V", (void*)nAllocationSubData1D_b }, -{"rsnAllocationSubData1D", "(IIII[FI)V", (void*)nAllocationSubData1D_f }, -{"rsnAllocationSubElementData1D", "(IIII[BI)V", (void*)nAllocationSubElementData1D }, -{"rsnAllocationSubData2D", "(IIIIII[II)V", (void*)nAllocationSubData2D_i }, -{"rsnAllocationSubData2D", "(IIIIII[FI)V", (void*)nAllocationSubData2D_f }, +{"rsnAllocationData1D", "(IIIII[II)V", (void*)nAllocationData1D_i }, +{"rsnAllocationData1D", "(IIIII[SI)V", (void*)nAllocationData1D_s }, +{"rsnAllocationData1D", "(IIIII[BI)V", (void*)nAllocationData1D_b }, +{"rsnAllocationData1D", "(IIIII[FI)V", (void*)nAllocationData1D_f }, +{"rsnAllocationElementData1D", "(IIIII[BI)V", (void*)nAllocationElementData1D }, +{"rsnAllocationData2D", "(IIIIIIII[II)V", (void*)nAllocationData2D_i }, +{"rsnAllocationData2D", "(IIIIIIII[FI)V", (void*)nAllocationData2D_f }, {"rsnAllocationRead", "(II[I)V", (void*)nAllocationRead_i }, {"rsnAllocationRead", "(II[F)V", (void*)nAllocationRead_f }, {"rsnAllocationGetType", "(II)I", (void*)nAllocationGetType}, {"rsnAllocationResize1D", "(III)V", (void*)nAllocationResize1D }, {"rsnAllocationResize2D", "(IIII)V", (void*)nAllocationResize2D }, -{"rsnAdapter1DBindAllocation", "(III)V", (void*)nAdapter1DBindAllocation }, -{"rsnAdapter1DSetConstraint", "(IIII)V", (void*)nAdapter1DSetConstraint }, -{"rsnAdapter1DData", "(II[I)V", (void*)nAdapter1DData_i }, -{"rsnAdapter1DData", "(II[F)V", (void*)nAdapter1DData_f }, -{"rsnAdapter1DSubData", "(IIII[I)V", (void*)nAdapter1DSubData_i }, -{"rsnAdapter1DSubData", "(IIII[F)V", (void*)nAdapter1DSubData_f }, -{"rsnAdapter1DCreate", "(I)I", (void*)nAdapter1DCreate }, - -{"rsnAdapter2DBindAllocation", "(III)V", (void*)nAdapter2DBindAllocation }, -{"rsnAdapter2DSetConstraint", "(IIII)V", (void*)nAdapter2DSetConstraint }, -{"rsnAdapter2DData", "(II[I)V", (void*)nAdapter2DData_i }, -{"rsnAdapter2DData", "(II[F)V", (void*)nAdapter2DData_f }, -{"rsnAdapter2DSubData", "(IIIIII[I)V", (void*)nAdapter2DSubData_i }, -{"rsnAdapter2DSubData", "(IIIIII[F)V", (void*)nAdapter2DSubData_f }, -{"rsnAdapter2DCreate", "(I)I", (void*)nAdapter2DCreate }, - {"rsnScriptBindAllocation", "(IIII)V", (void*)nScriptBindAllocation }, {"rsnScriptSetTimeZone", "(II[B)V", (void*)nScriptSetTimeZone }, {"rsnScriptInvoke", "(III)V", (void*)nScriptInvoke }, @@ -1317,13 +1158,13 @@ static JNINativeMethod methods[] = { {"rsnProgramBindTexture", "(IIII)V", (void*)nProgramBindTexture }, {"rsnProgramBindSampler", "(IIII)V", (void*)nProgramBindSampler }, -{"rsnProgramFragmentCreate", "(ILjava/lang/String;[I)I", (void*)nProgramFragmentCreate }, +{"rsnProgramFragmentCreate", "(ILjava/lang/String;[I)I", (void*)nProgramFragmentCreate }, {"rsnProgramRasterCreate", "(IZZZ)I", (void*)nProgramRasterCreate }, {"rsnProgramRasterSetLineWidth", "(IIF)V", (void*)nProgramRasterSetLineWidth }, {"rsnProgramRasterSetCullMode", "(III)V", (void*)nProgramRasterSetCullMode }, -{"rsnProgramVertexCreate", "(ILjava/lang/String;[I)I", (void*)nProgramVertexCreate }, +{"rsnProgramVertexCreate", "(ILjava/lang/String;[I)I", (void*)nProgramVertexCreate }, {"rsnContextBindRootScript", "(II)V", (void*)nContextBindRootScript }, {"rsnContextBindProgramStore", "(II)V", (void*)nContextBindProgramStore }, |