diff options
-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 | ||||
-rw-r--r-- | libs/rs/RenderScript.h | 9 | ||||
-rw-r--r-- | libs/rs/rs.spec | 87 | ||||
-rw-r--r-- | libs/rs/rsAllocation.cpp | 58 | ||||
-rw-r--r-- | libs/rs/rsAllocation.h | 11 | ||||
-rw-r--r-- | libs/rs/rsFont.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsHandcode.h | 43 |
11 files changed, 359 insertions, 529 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 }, diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index 3ad453f..87758e5 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -111,6 +111,15 @@ enum RsAllocationMipmapControl { RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2 }; +enum RsAllocationCubemapFace { + RS_ALLOCATION_CUBMAP_FACE_POSITVE_X = 0, + RS_ALLOCATION_CUBMAP_FACE_NEGATIVE_X = 1, + RS_ALLOCATION_CUBMAP_FACE_POSITVE_Y = 2, + RS_ALLOCATION_CUBMAP_FACE_NEGATIVE_Y = 3, + RS_ALLOCATION_CUBMAP_FACE_POSITVE_Z = 4, + RS_ALLOCATION_CUBMAP_FACE_NEGATIVE_Z = 5 +}; + enum RsDataType { RS_TYPE_NONE, RS_TYPE_FLOAT_16, diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index a5810d4..3483a5d 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -89,28 +89,11 @@ AllocationCopyToBitmap { param size_t dataLen } -AllocationUploadToTexture { - param RsAllocation alloc - param bool genMipMaps - param uint32_t baseMipLevel - } - -AllocationUploadToBufferObject { - param RsAllocation alloc - } - - -AllocationData { - param RsAllocation va - param const void * data - param uint32_t bytes - handcodeApi - togglePlay - } -Allocation1DSubData { +Allocation1DData { param RsAllocation va param uint32_t xoff + param uint32_t lod param uint32_t count param const void *data param uint32_t bytes @@ -118,9 +101,10 @@ Allocation1DSubData { togglePlay } -Allocation1DSubElementData { +Allocation1DElementData { param RsAllocation va param uint32_t x + param uint32_t lod param const void *data param uint32_t comp_offset param uint32_t bytes @@ -128,20 +112,24 @@ Allocation1DSubElementData { togglePlay } -Allocation2DSubData { +Allocation2DData { param RsAllocation va param uint32_t xoff param uint32_t yoff + param uint32_t lod + param RsAllocationCubemapFace face param uint32_t w param uint32_t h param const void *data param uint32_t bytes } -Allocation2DSubElementData { +Allocation2DElementData { param RsAllocation va param uint32_t x param uint32_t y + param uint32_t lod + param RsAllocationCubemapFace face param const void *data param uint32_t element_offset param uint32_t bytes @@ -157,61 +145,6 @@ AllocationSyncAll { param RsAllocationUsageType src } -Adapter1DCreate { - ret RsAdapter1D - } - -Adapter1DBindAllocation { - param RsAdapter1D adapt - param RsAllocation alloc - } - -Adapter1DSetConstraint { - param RsAdapter1D adapter - param RsDimension dim - param uint32_t value - } - -Adapter1DData { - param RsAdapter1D adapter - param const void * data - } - -Adapter1DSubData { - param RsAdapter1D adapter - param uint32_t xoff - param uint32_t count - param const void *data - } - -Adapter2DCreate { - ret RsAdapter2D - } - -Adapter2DBindAllocation { - param RsAdapter2D adapt - param RsAllocation alloc - } - -Adapter2DSetConstraint { - param RsAdapter2D adapter - param RsDimension dim - param uint32_t value - } - -Adapter2DData { - param RsAdapter2D adapter - param const void *data - } - -Adapter2DSubData { - param RsAdapter2D adapter - param uint32_t xoff - param uint32_t yoff - param uint32_t w - param uint32_t h - param const void *data - } AllocationResize1D { param RsAllocation va diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index ec1f684..3608e43 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -307,29 +307,12 @@ void Allocation::uploadCheck(Context *rsc) { } } - -void Allocation::data(Context *rsc, const void *data, uint32_t sizeBytes) { - uint32_t size = mType->getSizeBytes(); - if (size != sizeBytes) { - LOGE("Allocation::data called with mismatched size expected %i, got %i", size, sizeBytes); - return; - } - - if (mType->getElement()->getHasReferences()) { - incRefs(data, sizeBytes / mType->getElement()->getSizeBytes()); - decRefs(mPtr, sizeBytes / mType->getElement()->getSizeBytes()); - } - - memcpy(mPtr, data, size); - sendDirty(); - mUploadDefered = true; -} - void Allocation::read(void *data) { memcpy(data, mPtr, mType->getSizeBytes()); } -void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes) { +void Allocation::data(Context *rsc, uint32_t xoff, uint32_t lod, + uint32_t count, const void *data, uint32_t sizeBytes) { uint32_t eSize = mType->getElementSizeBytes(); uint8_t * ptr = static_cast<uint8_t *>(mPtr); ptr += eSize * xoff; @@ -351,7 +334,7 @@ void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t count, const void mUploadDefered = true; } -void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t yoff, +void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) { uint32_t eSize = mType->getElementSizeBytes(); uint32_t lineSize = eSize * w; @@ -379,11 +362,11 @@ void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t yoff, mUploadDefered = true; } -void Allocation::subData(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, +void Allocation::data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, RsAllocationCubemapFace face, uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes) { } -void Allocation::subElementData(Context *rsc, uint32_t x, const void *data, +void Allocation::elementData(Context *rsc, uint32_t x, const void *data, uint32_t cIdx, uint32_t sizeBytes) { uint32_t eSize = mType->getElementSizeBytes(); uint8_t * ptr = static_cast<uint8_t *>(mPtr); @@ -420,7 +403,7 @@ void Allocation::subElementData(Context *rsc, uint32_t x, const void *data, mUploadDefered = true; } -void Allocation::subElementData(Context *rsc, uint32_t x, uint32_t y, +void Allocation::elementData(Context *rsc, uint32_t x, uint32_t y, const void *data, uint32_t cIdx, uint32_t sizeBytes) { uint32_t eSize = mType->getElementSizeBytes(); uint8_t * ptr = static_cast<uint8_t *>(mPtr); @@ -539,8 +522,10 @@ Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) { Allocation *alloc = new Allocation(rsc, type, RS_ALLOCATION_USAGE_SCRIPT); alloc->setName(name.string(), name.size()); + uint32_t count = dataSize / type->getElementSizeBytes(); + // Read in all of our allocation data - alloc->data(rsc, stream->getPtr() + stream->getPos(), dataSize); + alloc->data(rsc, 0, 0, count, stream->getPtr() + stream->getPos(), dataSize); stream->reset(stream->getPos() + dataSize); return alloc; @@ -741,29 +726,28 @@ void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_ memcpy(data, texAlloc->getPtr(), s); } -void rsi_AllocationData(Context *rsc, RsAllocation va, const void *data, uint32_t sizeBytes) { - Allocation *a = static_cast<Allocation *>(va); - a->data(rsc, data, sizeBytes); -} - -void rsi_Allocation1DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes) { +void rsi_Allocation1DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t lod, + uint32_t count, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); - a->subData(rsc, xoff, count, data, sizeBytes); + a->data(rsc, xoff, lod, count, data, sizeBytes); } -void rsi_Allocation2DSubElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, const void *data, uint32_t eoff, uint32_t sizeBytes) { +void rsi_Allocation2DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t y, uint32_t lod, RsAllocationCubemapFace face, + const void *data, uint32_t eoff, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); - a->subElementData(rsc, x, y, data, eoff, sizeBytes); + a->elementData(rsc, x, y, data, eoff, sizeBytes); } -void rsi_Allocation1DSubElementData(Context *rsc, RsAllocation va, uint32_t x, const void *data, uint32_t eoff, uint32_t sizeBytes) { +void rsi_Allocation1DElementData(Context *rsc, RsAllocation va, uint32_t x, uint32_t lod, + const void *data, uint32_t eoff, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); - a->subElementData(rsc, x, data, eoff, sizeBytes); + a->elementData(rsc, x, data, eoff, sizeBytes); } -void rsi_Allocation2DSubData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) { +void rsi_Allocation2DData(Context *rsc, RsAllocation va, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, + uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes) { Allocation *a = static_cast<Allocation *>(va); - a->subData(rsc, xoff, yoff, w, h, data, sizeBytes); + a->data(rsc, xoff, yoff, lod, face, w, h, data, sizeBytes); } void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data) { diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h index 44dce0d..a8d086e 100644 --- a/libs/rs/rsAllocation.h +++ b/libs/rs/rsAllocation.h @@ -61,16 +61,15 @@ public: void resize1D(Context *rsc, uint32_t dimX); void resize2D(Context *rsc, uint32_t dimX, uint32_t dimY); - void data(Context *rsc, const void *data, uint32_t sizeBytes); - void subData(Context *rsc, uint32_t xoff, uint32_t count, const void *data, uint32_t sizeBytes); - void subData(Context *rsc, uint32_t xoff, uint32_t yoff, + void data(Context *rsc, uint32_t xoff, uint32_t lod, uint32_t count, const void *data, uint32_t sizeBytes); + void data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, uint32_t w, uint32_t h, const void *data, uint32_t sizeBytes); - void subData(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, + void data(Context *rsc, uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod, RsAllocationCubemapFace face, uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); - void subElementData(Context *rsc, uint32_t x, + void elementData(Context *rsc, uint32_t x, const void *data, uint32_t elementOff, uint32_t sizeBytes); - void subElementData(Context *rsc, uint32_t x, uint32_t y, + void elementData(Context *rsc, uint32_t x, uint32_t y, const void *data, uint32_t elementOff, uint32_t sizeBytes); void read(void *data); diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp index 80bca43..3dcf743 100644 --- a/libs/rs/rsFont.cpp +++ b/libs/rs/rsFont.cpp @@ -606,7 +606,7 @@ void FontState::issueDrawCommand() { mRSC->setProgramStore(mFontProgramStore.get()); if (mConstantsDirty) { - mFontShaderFConstant->data(mRSC, &mConstants, sizeof(mConstants)); + mFontShaderFConstant->data(mRSC, 0, 0, 1, &mConstants, sizeof(mConstants)); mConstantsDirty = false; } diff --git a/libs/rs/rsHandcode.h b/libs/rs/rsHandcode.h index 122a9ed..6f21a35 100644 --- a/libs/rs/rsHandcode.h +++ b/libs/rs/rsHandcode.h @@ -49,64 +49,49 @@ static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t s } } -static inline void rsHCAPI_AllocationData (RsContext rsc, RsAllocation va, const void * data, uint32_t sizeBytes) { +static inline void rsHCAPI_Allocation1DData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t lod, + uint32_t count, const void * data, uint32_t sizeBytes) { ThreadIO *io = &((Context *)rsc)->mIO; - uint32_t size = sizeof(RS_CMD_AllocationData); + uint32_t size = sizeof(RS_CMD_Allocation1DData); if (sizeBytes < DATA_SYNC_SIZE) { size += (sizeBytes + 3) & ~3; } - RS_CMD_AllocationData *cmd = static_cast<RS_CMD_AllocationData *>(io->mToCore.reserve(size)); - cmd->va = va; - cmd->bytes = sizeBytes; - cmd->data = data; - if (sizeBytes < DATA_SYNC_SIZE) { - cmd->data = (void *)(cmd+1); - memcpy(cmd+1, data, sizeBytes); - io->mToCore.commit(RS_CMD_ID_AllocationData, size); - } else { - io->mToCore.commitSync(RS_CMD_ID_AllocationData, size); - } -} - -static inline void rsHCAPI_Allocation1DSubData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void * data, uint32_t sizeBytes) { - ThreadIO *io = &((Context *)rsc)->mIO; - uint32_t size = sizeof(RS_CMD_Allocation1DSubData); - if (sizeBytes < DATA_SYNC_SIZE) { - size += (sizeBytes + 3) & ~3; - } - RS_CMD_Allocation1DSubData *cmd = static_cast<RS_CMD_Allocation1DSubData *>(io->mToCore.reserve(size)); + RS_CMD_Allocation1DData *cmd = static_cast<RS_CMD_Allocation1DData *>(io->mToCore.reserve(size)); cmd->va = va; cmd->xoff = xoff; + cmd->lod = lod; cmd->count = count; cmd->data = data; cmd->bytes = sizeBytes; if (sizeBytes < DATA_SYNC_SIZE) { cmd->data = (void *)(cmd+1); memcpy(cmd+1, data, sizeBytes); - io->mToCore.commit(RS_CMD_ID_Allocation1DSubData, size); + io->mToCore.commit(RS_CMD_ID_Allocation1DData, size); } else { - io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubData, size); + io->mToCore.commitSync(RS_CMD_ID_Allocation1DData, size); } } -static inline void rsHCAPI_Allocation1DSubElementData (RsContext rsc, RsAllocation va, uint32_t x, const void * data, uint32_t comp_offset, uint32_t sizeBytes) { +static inline void rsHCAPI_Allocation1DElementData (RsContext rsc, RsAllocation va, uint32_t x, uint32_t lod, + const void * data, uint32_t comp_offset, uint32_t sizeBytes) { ThreadIO *io = &((Context *)rsc)->mIO; - uint32_t size = sizeof(RS_CMD_Allocation1DSubElementData); + uint32_t size = sizeof(RS_CMD_Allocation1DElementData); if (sizeBytes < DATA_SYNC_SIZE) { size += (sizeBytes + 3) & ~3; } - RS_CMD_Allocation1DSubElementData *cmd = static_cast<RS_CMD_Allocation1DSubElementData *>(io->mToCore.reserve(size)); + RS_CMD_Allocation1DElementData *cmd = static_cast<RS_CMD_Allocation1DElementData *>(io->mToCore.reserve(size)); cmd->va = va; cmd->x = x; + cmd->lod = lod; cmd->data = data; cmd->comp_offset = comp_offset; cmd->bytes = sizeBytes; if (sizeBytes < DATA_SYNC_SIZE) { cmd->data = (void *)(cmd+1); memcpy(cmd+1, data, sizeBytes); - io->mToCore.commit(RS_CMD_ID_Allocation1DSubElementData, size); + io->mToCore.commit(RS_CMD_ID_Allocation1DElementData, size); } else { - io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubElementData, size); + io->mToCore.commitSync(RS_CMD_ID_Allocation1DElementData, size); } } |