diff options
Diffstat (limited to 'graphics')
19 files changed, 270 insertions, 61 deletions
diff --git a/graphics/java/android/graphics/BitmapRegionDecoder.java b/graphics/java/android/graphics/BitmapRegionDecoder.java index 454eb4a..496e0c7 100644 --- a/graphics/java/android/graphics/BitmapRegionDecoder.java +++ b/graphics/java/android/graphics/BitmapRegionDecoder.java @@ -39,7 +39,7 @@ public final class BitmapRegionDecoder { /** * Create a BitmapRegionDecoder from the specified byte array. - * Currently only the Jpeg format is supported. + * Currently only the JPEG and PNG formats are supported. * * @param data byte array of compressed image data. * @param offset offset into data for where the decoder should begin @@ -67,7 +67,7 @@ public final class BitmapRegionDecoder { * Create a BitmapRegionDecoder from the file descriptor. * The position within the descriptor will not be changed when * this returns, so the descriptor can be used again as is. - * Currently only the Jpeg format is supported. + * Currently only the JPEG and PNG formats are supported. * * @param fd The file descriptor containing the data to decode * @param isShareable If this is true, then the BitmapRegionDecoder may keep a @@ -89,7 +89,7 @@ public final class BitmapRegionDecoder { * Create a BitmapRegionDecoder from an input stream. * The stream's position will be where ever it was after the encoded data * was read. - * Currently only the Jpeg format is supported. + * Currently only the JPEG and PNG formats are supported. * * @param is The input stream that holds the raw data to be decoded into a * BitmapRegionDecoder. @@ -126,7 +126,7 @@ public final class BitmapRegionDecoder { /** * Create a BitmapRegionDecoder from a file path. - * Currently only the Jpeg format is supported. + * Currently only the JPEG and PNG formats are supported. * * @param pathName complete path name for the file to be decoded. * @param isShareable If this is true, then the BitmapRegionDecoder may keep a diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index 66c6d81..184620b 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -85,8 +85,12 @@ public class Canvas { @Override protected void finalize() throws Throwable { - if (mNativeCanvas != 0) { - finalizer(mNativeCanvas); + try { + if (mNativeCanvas != 0) { + finalizer(mNativeCanvas); + } + } finally { + super.finalize(); } } } @@ -137,6 +141,8 @@ public class Canvas { * Returns null. * * @deprecated This method is not supported and should not be invoked. + * + * @hide */ @Deprecated protected GL getGL() { diff --git a/graphics/java/android/graphics/Shader.java b/graphics/java/android/graphics/Shader.java index 3acf1ea..43758e7 100644 --- a/graphics/java/android/graphics/Shader.java +++ b/graphics/java/android/graphics/Shader.java @@ -66,7 +66,7 @@ public class Shader { public boolean getLocalMatrix(Matrix localM) { if (mLocalMatrix != null) { localM.set(mLocalMatrix); - return true; + return !mLocalMatrix.isIdentity(); } return false; } diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 53962e1..0c33a5f 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -18,7 +18,6 @@ package android.renderscript; import java.io.IOException; import java.io.InputStream; - import android.content.res.Resources; import android.content.res.AssetManager; import android.graphics.Bitmap; @@ -47,28 +46,62 @@ public class Allocation extends BaseObj { Bitmap mBitmap; int mUsage; + /** + * The usage of the allocation. These signal to renderscript + * where to place the allocation in memory. + * + * SCRIPT The allocation will be bound to and accessed by + * scripts. + */ public static final int USAGE_SCRIPT = 0x0001; + + /** + * GRAPHICS_TEXTURE The allcation will be used as a texture + * source by one or more graphcics programs. + * + */ public static final int USAGE_GRAPHICS_TEXTURE = 0x0002; - public static final int USAGE_GRAPHICS_VERTEX = 0x0004; - public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008; + /** + * GRAPHICS_VERTEX The allocation will be used as a graphics + * mesh. + * + */ + public static final int USAGE_GRAPHICS_VERTEX = 0x0004; - public enum CubemapLayout { - VERTICAL_FACE_LIST (0), - HORIZONTAL_FACE_LIST (1), - VERTICAL_CROSS (2), - HORIZONTAL_CROSS (3); - int mID; - CubemapLayout(int id) { - mID = id; - } - } + /** + * GRAPHICS_CONSTANTS The allocation will be used as the source + * of shader constants by one or more programs. + * + */ + public static final int USAGE_GRAPHICS_CONSTANTS = 0x0008; + /** + * Controls mipmap behavior when using the bitmap creation and + * update functions. + */ public enum MipmapControl { + /** + * No mipmaps will be generated and the type generated from the + * incoming bitmap will not contain additional LODs. + */ MIPMAP_NONE(0), + + /** + * A Full mipmap chain will be created in script memory. The + * type of the allocation will contain a full mipmap chain. On + * upload to graphics the full chain will be transfered. + */ MIPMAP_FULL(1), + + /** + * The type of the allocation will be the same as MIPMAP_NONE. + * It will not contain mipmaps. On upload to graphics the + * graphics copy of the allocation data will contain a full + * mipmap chain generated from the top level in script memory. + */ MIPMAP_ON_SYNC_TO_TEXTURE(2); int mID; @@ -135,6 +168,49 @@ public class Allocation extends BaseObj { mType.getY() != b.getHeight()) { throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch"); } + Bitmap.Config bc = b.getConfig(); + switch (bc) { + case ALPHA_8: + if (mType.getElement().mKind != Element.DataKind.PIXEL_A) { + throw new RSIllegalArgumentException("Allocation kind is " + + mType.getElement().mKind + ", type " + + mType.getElement().mType + + " of " + mType.getElement().getSizeBytes() + + " bytes, passed bitmap was " + bc); + } + break; + case ARGB_8888: + if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) || + (mType.getElement().getSizeBytes() != 4)) { + throw new RSIllegalArgumentException("Allocation kind is " + + mType.getElement().mKind + ", type " + + mType.getElement().mType + + " of " + mType.getElement().getSizeBytes() + + " bytes, passed bitmap was " + bc); + } + break; + case RGB_565: + if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGB) || + (mType.getElement().getSizeBytes() != 2)) { + throw new RSIllegalArgumentException("Allocation kind is " + + mType.getElement().mKind + ", type " + + mType.getElement().mType + + " of " + mType.getElement().getSizeBytes() + + " bytes, passed bitmap was " + bc); + } + break; + case ARGB_4444: + if ((mType.getElement().mKind != Element.DataKind.PIXEL_RGBA) || + (mType.getElement().getSizeBytes() != 2)) { + throw new RSIllegalArgumentException("Allocation kind is " + + mType.getElement().mKind + ", type " + + mType.getElement().mType + + " of " + mType.getElement().getSizeBytes() + + " bytes, passed bitmap was " + bc); + } + break; + + } } public void copyFrom(int[] d) { @@ -227,6 +303,20 @@ public class Allocation extends BaseObj { } } + /** + * Generate a mipmap chain. Requires the type of the allocation + * include mipmaps. + * + * This function will generate a complete set of mipmaps from + * the top level lod and place them into the script memoryspace. + * + * If the allocation is also using other memory spaces a + * followup sync will be required. + */ + public void generateMipmaps() { + mRS.nAllocationGenerateMipmaps(getID()); + } + public void copy1DRangeFrom(int off, int count, int[] d) { int dataSize = mType.mElement.getSizeBytes() * count; data1DChecks(off, count, d.length * 4, dataSize); @@ -249,29 +339,49 @@ public class Allocation extends BaseObj { } - public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] d) { + /** + * Copy a rectanglular region from the array into the + * allocation. The incoming array is assumed to be tightly + * packed. + * + * @param xoff X offset of the region to update + * @param yoff Y offset of the region to update + * @param w Width of the incoming region to update + * @param h Height of the incoming region to update + * @param data to be placed into the allocation + */ + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, byte[] data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length); } - public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] d) { + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, short[] data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 2); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 2); } - public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] d) { + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, int[] data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 4); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 4); } - public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] d) { + public void copy2DRangeFrom(int xoff, int yoff, int w, int h, float[] data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, d, d.length * 4); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, w, h, data, data.length * 4); } - public void copy2DRangeFrom(int xoff, int yoff, Bitmap b) { + /** + * Copy a bitmap into an allocation. The height and width of + * the update will use the height and width of the incoming + * bitmap. + * + * @param xoff X offset of the region to update + * @param yoff Y offset of the region to update + * @param data the bitmap to be copied + */ + public void copy2DRangeFrom(int xoff, int yoff, Bitmap data) { mRS.validate(); - mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, b); + mRS.nAllocationData2D(getID(), xoff, yoff, 0, 0, data); } @@ -300,6 +410,18 @@ public class Allocation extends BaseObj { mRS.nAllocationRead(getID(), d); } + /** + * Resize a 1D allocation. The contents of the allocation are + * preserved. If new elements are allocated objects are created + * with null contents and the new region is otherwise undefined. + * + * If the new region is smaller the references of any objects + * outside the new region will be released. + * + * A new type will be created with the new dimension. + * + * @param dimX The new size of the allocation. + */ public synchronized void resize(int dimX) { if ((mType.getY() > 0)|| (mType.getZ() > 0) || mType.hasFaces() || mType.hasMipmaps()) { throw new RSInvalidStateException("Resize only support for 1D allocations at this time."); @@ -416,33 +538,41 @@ public class Allocation extends BaseObj { USAGE_GRAPHICS_TEXTURE); } + /** + * Creates a cubemap allocation from a bitmap containing the + * horizontal list of cube faces. Each individual face must be + * the same size and power of 2 + * + * @param rs + * @param b bitmap with cubemap faces layed out in the following + * format: right, left, top, bottom, front, back + * @param mips specifies desired mipmap behaviour for the cubemap + * @param usage bitfield specifying how the cubemap is utilized + * + **/ static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b, MipmapControl mips, - CubemapLayout layout, int usage) { rs.validate(); int height = b.getHeight(); int width = b.getWidth(); - if (layout != CubemapLayout.VERTICAL_FACE_LIST) { - throw new RSIllegalArgumentException("Only vertical face list supported"); - } - if (height % 6 != 0) { + if (width % 6 != 0) { throw new RSIllegalArgumentException("Cubemap height must be multiple of 6"); } - if (height / 6 != width) { - throw new RSIllegalArgumentException("Only square cobe map faces supported"); + if (width / 6 != height) { + throw new RSIllegalArgumentException("Only square cube map faces supported"); } - boolean isPow2 = (width & (width - 1)) == 0; + boolean isPow2 = (height & (height - 1)) == 0; if (!isPow2) { throw new RSIllegalArgumentException("Only power of 2 cube faces supported"); } Element e = elementFromBitmap(rs, b); Type.Builder tb = new Type.Builder(rs, e); - tb.setX(width); - tb.setY(width); + tb.setX(height); + tb.setY(height); tb.setFaces(true); tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL); Type t = tb.create(); @@ -454,10 +584,71 @@ public class Allocation extends BaseObj { return new Allocation(id, rs, t, usage); } - static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b, - CubemapLayout layout) { + static public Allocation createCubemapFromBitmap(RenderScript rs, + Bitmap b) { return createCubemapFromBitmap(rs, b, MipmapControl.MIPMAP_NONE, - layout, USAGE_GRAPHICS_TEXTURE); + USAGE_GRAPHICS_TEXTURE); + } + + static public Allocation createCubemapFromCubeFaces(RenderScript rs, + Bitmap xpos, + Bitmap xneg, + Bitmap ypos, + Bitmap yneg, + Bitmap zpos, + Bitmap zneg, + MipmapControl mips, + int usage) { + int height = xpos.getHeight(); + if (xpos.getWidth() != height || + xneg.getWidth() != height || xneg.getHeight() != height || + ypos.getWidth() != height || ypos.getHeight() != height || + yneg.getWidth() != height || yneg.getHeight() != height || + zpos.getWidth() != height || zpos.getHeight() != height || + zneg.getWidth() != height || zneg.getHeight() != height) { + throw new RSIllegalArgumentException("Only square cube map faces supported"); + } + boolean isPow2 = (height & (height - 1)) == 0; + if (!isPow2) { + throw new RSIllegalArgumentException("Only power of 2 cube faces supported"); + } + + Element e = elementFromBitmap(rs, xpos); + Type.Builder tb = new Type.Builder(rs, e); + tb.setX(height); + tb.setY(height); + tb.setFaces(true); + tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL); + Type t = tb.create(); + Allocation cubemap = Allocation.createTyped(rs, t, mips, usage); + + AllocationAdapter adapter = AllocationAdapter.create2D(rs, cubemap); + adapter.setFace(Type.CubemapFace.POSITVE_X); + adapter.copyFrom(xpos); + adapter.setFace(Type.CubemapFace.NEGATIVE_X); + adapter.copyFrom(xneg); + adapter.setFace(Type.CubemapFace.POSITVE_Y); + adapter.copyFrom(ypos); + adapter.setFace(Type.CubemapFace.NEGATIVE_Y); + adapter.copyFrom(yneg); + adapter.setFace(Type.CubemapFace.POSITVE_Z); + adapter.copyFrom(zpos); + adapter.setFace(Type.CubemapFace.NEGATIVE_Z); + adapter.copyFrom(zneg); + + return cubemap; + } + + static public Allocation createCubemapFromCubeFaces(RenderScript rs, + Bitmap xpos, + Bitmap xneg, + Bitmap ypos, + Bitmap yneg, + Bitmap zpos, + Bitmap zneg) { + return createCubemapFromCubeFaces(rs, xpos, xneg, ypos, yneg, + zpos, zneg, MipmapControl.MIPMAP_NONE, + USAGE_GRAPHICS_TEXTURE); } static public Allocation createFromBitmapResource(RenderScript rs, diff --git a/graphics/java/android/renderscript/AllocationAdapter.java b/graphics/java/android/renderscript/AllocationAdapter.java index e682e93..f2fedea 100644 --- a/graphics/java/android/renderscript/AllocationAdapter.java +++ b/graphics/java/android/renderscript/AllocationAdapter.java @@ -24,7 +24,6 @@ import android.util.Log; import android.util.TypedValue; /** - * @hide * **/ public class AllocationAdapter extends Allocation { diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index e07fdfb..10dc35b 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -425,7 +425,13 @@ public class Element extends BaseObj { Element(int id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) { super(id, rs); - mSize = dt.mSize * size; + if ((dt != DataType.UNSIGNED_5_6_5) && + (dt != DataType.UNSIGNED_4_4_4_4) && + (dt != DataType.UNSIGNED_5_5_5_1)) { + mSize = dt.mSize * size; + } else { + mSize = dt.mSize; + } mType = dt; mKind = dk; mNormalized = norm; diff --git a/graphics/java/android/renderscript/FileA3D.java b/graphics/java/android/renderscript/FileA3D.java index 01a9a82..90d102c 100644 --- a/graphics/java/android/renderscript/FileA3D.java +++ b/graphics/java/android/renderscript/FileA3D.java @@ -28,7 +28,6 @@ import android.util.Log; import android.util.TypedValue; /** - * @hide * **/ public class FileA3D extends BaseObj { diff --git a/graphics/java/android/renderscript/Font.java b/graphics/java/android/renderscript/Font.java index ae209fa..252ffc1 100644 --- a/graphics/java/android/renderscript/Font.java +++ b/graphics/java/android/renderscript/Font.java @@ -30,7 +30,6 @@ import android.util.Log; import android.util.TypedValue; /** - * @hide * **/ public class Font extends BaseObj { diff --git a/graphics/java/android/renderscript/Long2.java b/graphics/java/android/renderscript/Long2.java index 11ead2f..834d13c 100644 --- a/graphics/java/android/renderscript/Long2.java +++ b/graphics/java/android/renderscript/Long2.java @@ -21,7 +21,6 @@ import android.util.Log; /** - * @hide * **/ public class Long2 { diff --git a/graphics/java/android/renderscript/Long3.java b/graphics/java/android/renderscript/Long3.java index 1604532..c6d7289 100644 --- a/graphics/java/android/renderscript/Long3.java +++ b/graphics/java/android/renderscript/Long3.java @@ -21,7 +21,6 @@ import android.util.Log; /** - * @hide * **/ public class Long3 { diff --git a/graphics/java/android/renderscript/Long4.java b/graphics/java/android/renderscript/Long4.java index 2fd2747..032c1d3 100644 --- a/graphics/java/android/renderscript/Long4.java +++ b/graphics/java/android/renderscript/Long4.java @@ -21,7 +21,6 @@ import android.util.Log; /** - * @hide * **/ public class Long4 { diff --git a/graphics/java/android/renderscript/Mesh.java b/graphics/java/android/renderscript/Mesh.java index b77fe7d..f1f1237 100644 --- a/graphics/java/android/renderscript/Mesh.java +++ b/graphics/java/android/renderscript/Mesh.java @@ -22,7 +22,6 @@ import android.util.Config; import android.util.Log; /** - * @hide * Mesh class is a container for geometric data displayed in * renderscript. * @@ -205,7 +204,7 @@ public class Mesh extends BaseObj { /** * Adds a vertex data type to the builder object * - * @param r type of the vertex data allocation to be created + * @param t type of the vertex data allocation to be created * * @return this **/ diff --git a/graphics/java/android/renderscript/RSDriverException.java b/graphics/java/android/renderscript/RSDriverException.java index 61787e6..ce85b53 100644 --- a/graphics/java/android/renderscript/RSDriverException.java +++ b/graphics/java/android/renderscript/RSDriverException.java @@ -20,7 +20,6 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * Renderscript - * @hide */ public class RSDriverException extends RSRuntimeException { public RSDriverException(String string) { diff --git a/graphics/java/android/renderscript/RSIllegalArgumentException.java b/graphics/java/android/renderscript/RSIllegalArgumentException.java index 8d67a8d..954c0e8 100644 --- a/graphics/java/android/renderscript/RSIllegalArgumentException.java +++ b/graphics/java/android/renderscript/RSIllegalArgumentException.java @@ -20,7 +20,6 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * Renderscript - * @hide */ public class RSIllegalArgumentException extends RSRuntimeException { public RSIllegalArgumentException(String string) { diff --git a/graphics/java/android/renderscript/RSInvalidStateException.java b/graphics/java/android/renderscript/RSInvalidStateException.java index 53b9479..691aeba 100644 --- a/graphics/java/android/renderscript/RSInvalidStateException.java +++ b/graphics/java/android/renderscript/RSInvalidStateException.java @@ -20,7 +20,6 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * Renderscript - * @hide */ public class RSInvalidStateException extends RSRuntimeException { public RSInvalidStateException(String string) { diff --git a/graphics/java/android/renderscript/RSRuntimeException.java b/graphics/java/android/renderscript/RSRuntimeException.java index 4c97937..5a16478 100644 --- a/graphics/java/android/renderscript/RSRuntimeException.java +++ b/graphics/java/android/renderscript/RSRuntimeException.java @@ -20,7 +20,6 @@ package android.renderscript; /** * Base class for all exceptions thrown by the Android * Renderscript - * @hide */ public class RSRuntimeException extends java.lang.RuntimeException { diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java index 507f41f..be893bb 100644 --- a/graphics/java/android/renderscript/RSSurfaceView.java +++ b/graphics/java/android/renderscript/RSSurfaceView.java @@ -30,16 +30,16 @@ import android.view.SurfaceHolder; import android.view.SurfaceView; /** - * @hide * - **/ + */ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback { private SurfaceHolder mSurfaceHolder; private RenderScriptGL mRS; /** * Standard View constructor. In order to render something, you - * must call {@link #setRenderer} to register a renderer. + * must call {@link android.opengl.GLSurfaceView#setRenderer} to + * register a renderer. */ public RSSurfaceView(Context context) { super(context); @@ -49,7 +49,8 @@ public class RSSurfaceView extends SurfaceView implements SurfaceHolder.Callback /** * Standard View constructor. In order to render something, you - * must call {@link #setRenderer} to register a renderer. + * must call {@link android.opengl.GLSurfaceView#setRenderer} to + * register a renderer. */ public RSSurfaceView(Context context, AttributeSet attrs) { super(context, attrs); diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 4c9ad56..28b32d5 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -223,6 +223,10 @@ public class RenderScript { synchronized void nAllocationSyncAll(int alloc, int src) { rsnAllocationSyncAll(mContext, alloc, src); } + native void rsnAllocationGenerateMipmaps(int con, int alloc); + synchronized void nAllocationGenerateMipmaps(int alloc) { + rsnAllocationGenerateMipmaps(mContext, alloc); + } native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp); synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) { rsnAllocationCopyFromBitmap(mContext, alloc, bmp); diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 1817a1b..a7913d7 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -411,6 +411,13 @@ nAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits); } +static void +nAllocationGenerateMipmaps(JNIEnv *_env, jobject _this, RsContext con, jint alloc) +{ + LOG_API("nAllocationGenerateMipmaps, con(%p), a(%p)", con, (RsAllocation)alloc); + rsAllocationGenerateMipmaps(con, (RsAllocation)alloc); +} + static int nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) { @@ -445,10 +452,14 @@ nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); + int w = bitmap.width(); + int h = bitmap.height(); bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); - rsAllocationCopyFromBitmap(con, (RsAllocation)alloc, ptr, bitmap.getSize()); + rsAllocation2DData(con, (RsAllocation)alloc, 0, 0, + 0, RS_ALLOCATION_CUBMAP_FACE_POSITVE_X, + w, h, ptr, bitmap.getSize()); bitmap.unlockPixels(); } @@ -1211,6 +1222,7 @@ static JNINativeMethod methods[] = { {"rsnAllocationGetType", "(II)I", (void*)nAllocationGetType}, {"rsnAllocationResize1D", "(III)V", (void*)nAllocationResize1D }, {"rsnAllocationResize2D", "(IIII)V", (void*)nAllocationResize2D }, +{"rsnAllocationGenerateMipmaps", "(II)V", (void*)nAllocationGenerateMipmaps }, {"rsnScriptBindAllocation", "(IIII)V", (void*)nScriptBindAllocation }, {"rsnScriptSetTimeZone", "(II[B)V", (void*)nScriptSetTimeZone }, |